Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working on my first multiplayer game, as I have become bored with my single player indie games. However, I have a question. Players will be placing items on a map which is arranged in a grid, what is the best way to store this data on a server?

UPDATE: So essentially this is what I need to do. I currently have a database with player money, etc. I need some way of once the player places something on the map, for the server to check my database for how much it costs, so it can see if the player is cheating or not. My issue is I don't know the best way to communicate this data to the server and have it store it (the location of different things on the map, etc)

I was originally thinking to serialize the map, send it to my server, and store it in my database, but to query the database EVERY SINGLE TIME that the user changes something on the map seems to be a little ridiculous.

share|improve this question
Do you mean storing as in a persistent save game or only during runtime of the map? Or is the question exactly what data to store? It's hard to tell, please add some more information, thanks :) – Maik Semder Jan 26 '13 at 11:52
"the best way" questions are pretty much unanswerable. Especially when you don't say what "best" means in this context. – Trevor Powell Jan 27 '13 at 7:05

When the server needs to have constant access to the map, then it would be better to load it once and keep the map in the servers memory. That way you avoid contacting the database all the time. When you don't want to lose any game state when the server crashes, you could save the map sporadically (like every few minutes, assuming that the players actually changed something).

You didn't write anything about the gameplay concept and the scale of your game, but when your maps are very large, it might be a good idea to divide them into sections ("chunks") and store these individually in the database. That way you don't have to load the whole map, but only the chunks close to the active players. You also don't need to save the whole map, but only those chunks which have changes.

share|improve this answer

What I would say is to keep all data in the client as a "backup like" storage then whenever a player does anything it gets what was changed and sends it to the server.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.