0
\$\begingroup\$

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.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ 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 :) \$\endgroup\$ Commented Jan 26, 2013 at 11:52
  • 1
    \$\begingroup\$ "the best way" questions are pretty much unanswerable. Especially when you don't say what "best" means in this context. \$\endgroup\$ Commented Jan 27, 2013 at 7:05

2 Answers 2

1
\$\begingroup\$

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.

\$\endgroup\$
-1
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .