Advertisement

Sending and Recieving Game Map Files.

Started by May 31, 2015 05:48 AM
29 comments, last by hplus0603 9 years, 4 months ago

I was hoping I could just replace the URL http://www.boost.org/LICENSE_1_0.txt with http://127.0.0.1:86/C:/RTSServer/test.txt the location on laptops HD.


Just a quick observation: you don't plan to expose the entire server hard disk under the /C:/ path, do you?

This would be a very Bad Thing (tm)

But how do I connect to my lap top what do I need to run to connect.


Are you doing this for testing, or for external users to use?

Your laptop won't always be on, and its publicly visible IP is typically that of your current router/cable-modem/hotspot, not the local/private address on the network. For more about this, check the FAQ section on "how do I host a server for my game?"

For the testing case, if you're running a server on a port on your local machine, connecting to 127.0.0.1:port should work, from that same local machine.
enum Bool { True, False, FileNotFound };
Advertisement

Hi.
Yeah I'm using loopback just to test for now.

I think I need the server to listen on a tcp stream for the URL connection. But first I'm going to read the FAQ section on hosting.

Are you all talking about using some thing like MySQL to do the file share management.

No. We are talking about using an http server, like IIS or Apache or one of the many other http servers. They will serve files in a designated directory over http.

Configutation for bigger webservers can be a pain. You may want to roll some http serving code into your server.

Search for "http server for boost"

No. We are talking about using an http server, like IIS or Apache or one of the many other http servers. They will serve files in a designated directory over http.

Configutation for bigger webservers can be a pain. You may want to roll some http serving code into your server.

Search for "http server for boost"

Not only would this work very well, it also has the advantage, being HTTP, that it might be possible if your game grows beyond your expectations to scale it using apache's mod_proxy or similar, so you are still using boost to generate the output, but you use apache, IIS, etc to take advantage of its advanced caching features, ssl, or whatever else you needed.

Automatically distributing and using user created content, while a nice piece of functionality, is also dangerous.

Be sure to fuzz the map files to make sure that you aren't providing a mechanism for someone to compromise player's machines.

Reference: http://www.gdcvault.com/play/1022059/How-to-Protect-Your-Game

Advertisement

Hey all.

Its been a long slog. Looked into using boost http server setup, also look into apache and in all cases I would of needed to open a new port.

Plus making my load bar display current down load looked unworkable or a hack.

Inet(I called it Inet) uses a tcp stream packeted protocol serialized with google protocol buffers for data transfer over the wire.

So all I had to do was google protocol the image files and create 4 new network messages and 6 classes to manage the data and a boost bi map after I discovered that multiple clients could upload the same map at the same time bad news... fixed with a boost::bimap with filename and client id keys.

stops clients from uploading more then once at a time and only 1 mappack of the same name can be uploaded at a time.

handles fuzzed files. I forgot to reset the map pack on a test run and multiple uploads accumulated map pack and only noticed when my load bar started to slow down so I broke into the code and checked map packs and 96 files lol, that was in the editor. and in the game I passed the wrong file name in end of file and that made the server send the last file again but packed the data into the wrong file container on deserialization it was caught and left me scratching my head for a bit.

So the sever can handle multiple clients uploading different mappack and downloading to game clients who need the map, plus chat and other messages and be sent while sending files can mix the stream.

one thing Im not sure on is what to do when a client uploads a map to the server then players joint that map but while joining a new client uploads the same map and current players get one type of map and later joined clients get the other.... quick fix is all new map uploads go to a wait area then get published

I'm thinking of having public and private maps settings.

Other then that its working fine. Oh and about 100 hours.

Thanks all.

I was Wrong about the players getting wrong map data in joined games. I forgot when a room gets created it loads the map into memory and stays there untill the room is destroyed(after idel no player for some time). The down side to that is if that client who uploaded his new map joins the game with the old map it will over write there edited map.

But nope the more I think about this issue the harder it sounds.


Other then that its working fine. Oh and about 100 hours.

Congratulations on getting it working. You will get much faster at most of those things as you gain experience.


one thing Im not sure on is what to do when a client uploads a map to the server then players joint that map but while joining a new client uploads the same map and ...

All your file naming issues you discussed, including your new issue about someone uploading a duplicate named file while others are playing, can be resolved by not using the client's file name. Use a generated name on your server. The simplest is just start naming them sequentially, "1.map", "2.map", "3.map", and have some table on your server that associates the server's name with all the details like who uploaded it, their IP address, the timestamp, number of times it was played, and so on.

Looking through the UI system where players get to select a map I was just loading them from file of the client this was ok post network, But now the solution is a redesign

on how client can select maps.

The first thing is maps will now be assign a public or a private setting. all maps in the public domain can be changed at will by any client.

next the UI no longer loads all maps from files but will recieve the maps currently on the server. This way a client cant select a map that was not uploaded to the server from the editor when creating a game.

The hard part is do I use FindFirstFile

do while(FindNextFile(hFind, &ffd) != 0);

//every time a client joins the server or does the client app have a refresh button to get all the map names

what ever way I go there could be like thousands of map.

What would be a good solution for getting map names from the server to all clients.

I'm leaning towards a refresh button on the create game menu that tells the server to send the next 10 or more map names

But what way can I use FindNextFile on sever to do that for each clients.??????.

Dumping the FindFirstFile for boost::recursive_directory_iterator it(root); Then the Client can send a index to add to the interator for the next bunch of map names until it gets to the end then starts over.

Is it safe to have boost::recursive_directory_iterator open from the time the server starts till close. What about new file getting added to this directory.

A few comments:

1) If you want to re-implement the file picker dialog (not just use the GetOpenFileName() function) then FindFirstFile/FindNextFile is a good way of finding the files in a directory.

2) If you allow users to upload files, then you have to be really paranoid about the contents of those files. Set strict upper limits on the size. Make sure that all the code that parses the files is very paranoid about bounds checking. Make sure that nothing in the file attempts to "point" outside the file, or "count" more (or fewer) items than what are in the files. If you don't do this, there will be security holes in your game.

3) In general, when you want to manage "a bunch of stuff," then the best solution is a database of some sort. On a server, that might be a separate process like MySQL. On a client, that might be a simple linkable library like sqlite. I'm not saying you must put all your maps in a database, but you could think about whether it makes sense in your case.

4) You might want to consider a ".mymap" file format, which is perhpas just a text file with the names of the other files. Then, you will look for files named ".mymap" rather than having to sort through all the other files, and see which one goes with which. The ".mymap" might also have information like "who made the map" and "when was it uploaded" and such.

5) The server should probably read in the set of maps once, on start-up, and then just keep the list of maps in memory. (Not the data of every map -- just the names/file names for each map.) You don't want to be doing synchronous file I/O or waiting on disk during runtime if you can help it.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement