Jump to content
  • Advertisement
Sign in to follow this  
spikaa

Ensuring game data consistency

This topic is 2776 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. I'm planning on making an online multiplayer game using XNA Game Studio.

I'm thinking of storing hundreds of game data. Game data would be item characteristics (type, cost, damage, etc.) and unit characteristics (type, base HP, etc.). The game data is to be loaded after opening the game.
If I were to store the game data locally, then values could easily be changed by users. If different users battle each other, their game data might not be the same, which causes problems.

To solve this problem, I'm thinking that the server checks the user's game data on initial connection. The problem now is how the server checks if the game data has been modified. Iterating over hundred lines of text could take a long time, and there might be a more efficient way of doing it.

Another solution is don't even make the server check game data, but the server just sends over game data from the database on startup. Game data would still be stored locally, but they will be overwritten upon connection to the server; this way the game still works offline, but could potentially load modified game data...

If there are other ways of doing this please let me know.

Share this post


Link to post
Share on other sites
Advertisement
Another possible solution is through code obfuscation. Maybe have the data be stored in class files, and when I compile all source code and obfuscate them, there will be no easy way of changing data. The problem is how I will make the game automatically update old game data when a new game data from the database is needed. I have very little experience with obfuscation, so I don't really know if this approach is possible.

Share this post


Link to post
Share on other sites
The first question to ask here is: What is your attack scenario? What are the kinds of things you're worried might happen, and that you want to prevent? This is a non-trivial thing to consider, because of the following:

Scenario 1: Two players meet in a multi-player battle. One of them changes his game data in an attempt to make his strategy / his units more powerful in order to beat the other guy unfairly.

Clearly, you want to prevent this, or at least make it obvious that one of the guys is cheating, so that match results can be nullified if there is some kind of global ladder in place.

Scenario 2: A couple of good buddies want to have some hilarity. They all change their game data files in weird ways (but they all change them in the same way!) to modify unit statistics in ridiculous ways, just to mess around.

Since nobody else is being hurt in the process, this is something you should allow - unless you enjoy being a dickhead.

So we only really care about whether modifying the game data files opens the door for cheats as in scenario 1. To understand them better, you need to first clearly distinguish the three categories of cheats in multi-player games:

1. Information cheats. This is where a player gets access to more information than would usually be available; includes reveal map cheats in RTS, and wallhacks in FPS as an example.

2. "Physical" rule violations. This is where a player is able to change the properties of (parts of) the game world in ways that she is not supposed to, e.g.: increasing the strength of the player's weapons, or their speed, giving the player an unlimited amount of money, making them invincible, etc.

3. Doping. This is where a player enhances their biological capabilities in ways they're not supposed to, e.g. with an aimbot.

Second, you need to realize that there are things that you can truly protect against, and things that are, ultimately, impossible to protect against.

For example, it is impossible to truly protect against Doping, period. Even if you were able to completely lock down the player's computer, a particularly bloody-minded cheater could splice the video output, feed it into a second computer that analyses the picture that is sent to the monitor, and use that to generate input events to implement an aimbot. Usually, the best thing you can with doping is to accept it as a fact of life and design your game in such a way that its scope becomes limited or uninteresting, or part of the game design. Most likely, your game will be small enough anyway that nobody will bother to write the utilities to enable widespread doping. If you do not want to or cannot design around doping, be prepared for an exhausting cat and mouse game with dopers if your game ever becomes sufficiently popular.

The other two categories of cheats, on the other hand, can be entirely protected against, depending on the architecture of your networking system and the type of game. For example, every reasonable first person shooter completely prevents physical rule violations, simply due to the fact that they use client-server networking where the entire simulation is run on the server. Clients only send input commands to the server, and as long as the server is not compromised, it will only allow legal movements and actions to occur.

Similarly, an RTS that uses a client-server architecture can completely eliminate information cheats, if the simulation runs entirely on the server and the server only sends information about units outside of fog of war to the clients.

So coming back to your original question, I guess the cheat category you're worried about is physical rule violations. Do you use a client-server model where the server is trusted by all players? Then you simply need to write your server in such a way that it does not trust the clients, and checks everything they send, and then your problem becomes moot.

Is your networking model such that one of the players acts as a server? Then you need to be very careful indeed. Basically, if only the server is responsible for the game simulation, then the player who runs the server can completely mess up the simulation anyway, whether they change game data files or not - so again, your original problem becomes moot because you have a much bigger problem (or not - maybe your player community is such that trusted players are found to run the servers).

If you use a parallel simulation model where each computer runs a full simulation of the entire game, then you only need to check whether the game states stay synchronized between all the players. Once you ensure this, none of the players can perform physical rule violations, because any such violations would cause the game to desync, and the cheating to be detected. This is the strategy we use in Widelands (see the link in my signature). Again, this renders your original problem moot.

tl;dr: You were asking the wrong question. The real question is: Who has control over the game simulation, and do you trust them? Answer this question, and you will realize that modifying game data files is either moot, or the least of your worries.

Share this post


Link to post
Share on other sites
My game is turn based strategy, so Doping is not a problem.


Parallel simulation model sounds cool, since having a single server hosting several games at once could be very process and resource heavy. It might have reconnection limitations though. I'll look more into it. Thanks

Share this post


Link to post
Share on other sites
Yup, reconnecting can be difficult - you need a way to transfer the full state, really everything, from the other clients - and information cheats become rather easy with it.

The only reason we used it in Widelands is that a client-server model can require a lot of bandwidth for a real-time game with lots of units, and we wanted to avoid that (of course this is getting less of a concern as broadband gets more widespread, but even today it's nicer not to just assume everybody always has broadband available). In a turn-based game, bandwidth should not be that much of a concern.

Share this post


Link to post
Share on other sites
I have another concern.

While it is true that battles between users will not have problems when using client-server or parallel simulation, users with modified game data will still see modified tooltips and text. Although their tooltips and text are different, their actual effect in the game is correct and consistent.

Is this a common problem for other games? If not, how do they solve this? Thanks

EDIT:
I guess it shouldn't be much of a deal, since the users will have to actually work to change data for some weird reason. However, to me, it sounds more of an unprofessionally made game, if you can change data that aren't supposed to be changed.

I guess now, I'm asking for a more professional way to encrypt data, rather than having them in text files or common image formats, which are easily modified.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!