3
\$\begingroup\$

The main aim is to keep the games variables server-side for obvious security reasons. I believe having server-side code to check before updating the games database values will protect me from classic game hacking methods.

To avoid clients sending direct updates to the database, the server first validates the clients requested actions.

The database keeps track of every Mobile & Item

The Server has all the game-logic

The clients simply render and work as controllers that send the server actions that wont occur unless validated by the servers logic.

Clients should only send the server "Action Request"

Server then checks the "Action Request" with two possible outcomes :

  1. Valid Request : Update DB and Re-send updated data to Clients for post-processing.
  2. Invalid Request : Notify the client that the Request was invalid.

I need to know if im thinking in the right tracks. Thanks.

\$\endgroup\$
5
\$\begingroup\$

It isn't necessarily as clean cut as you expressed but in overly simplified terms and generalized notions, you are on track.

The thing to remember is that the client expresses it's intent to perform some operation. Some operations are entirely authoritative by the server. In these cases, the server must respond before the client can proceed. This works well for turn based or critical operations such as trading items within a game, inventory updates, etc. But this type of behavior isn't appropriate in all cases.

In the case of movement, it's often a better approach to allow the client to express intent to the server and simply allow the server to veto an operation should it deem the action invalid. In this case, the client begins to move as soon as the user presses the movement keys, the server simply can tell the client to back to position x, y, z if it determines the client is moving too fast or moved to an area they aren't suppose to be within. The server still is authoritative, but allows the client to provide a better user experience in exchange for a bit more complicated interpolation and handling of error responses.

\$\endgroup\$
  • \$\begingroup\$ Do you mind checking the comments below? I would like to know your opinion, as you seem experienced in the field. (Im not sure if this type of comments are allowed) \$\endgroup\$ – unknown.0perator Oct 6 '14 at 10:56
5
\$\begingroup\$

You should take a look at how games like Minecraft, Halflife, and World of Warcraft handle this, most games take the simulated client input actions and send them to the server and simulate the world on both the client and server and correct when the simulations differ by correcting the client state to match the server state. Here you can see the entire current Minecraft protocol.

Also, given that you are interested in making an MMO, that usually contains a fair amount of relational data that may be useful to query through, I would use MySQL or another RDBMS and then use a Key Value store like Redis for simple things you will never have to search/query over and for a second layer of cache below your game server's memory cache (or just use Redis and save yourself the effort of building a memory cache for your game state).

Since you're developing an MMO, it would do you a great deal of good to look through the ArcEmu source code, ArcEmu is an open source World of Warcraft server and demonstrates everything you need to know to build an MMO server.

\$\endgroup\$
  • \$\begingroup\$ Thanks, inspiring. Since it will always be my favourite MMO... Ultima Online's Protocol \$\endgroup\$ – unknown.0perator Oct 4 '14 at 1:09
  • \$\begingroup\$ Exactly, also, if you aren't as familiar with laying out your own binary protocol and using set data structures, you could use JSON RPC or Apache Thrift. If you want to learn more about client-server networking and simulation there's also the open source Quake code; and learning networking at Gafferon Games. \$\endgroup\$ – user5665 Oct 4 '14 at 2:21
  • \$\begingroup\$ I am thinking what DB System I will be using, currently reading Visual Guide to NoSQL Systems . To avoid reading/writing the db constantly: Read the DB when a player logs in and save data into Bidirectional arrays, for persistence once the player logs out, the data from that player in the array is droped because its no longer needed (updating the db and free memory from array) \$\endgroup\$ – unknown.0perator Oct 4 '14 at 15:21
  • \$\begingroup\$ I don't know what kind of MMO you have in mind, but the system you describe could lose a lot of player data if there was a server crash, not only that you lose the ability to do any informational queries with all of that player and world entity data you're going to store in NoSQL, NoSQL is evangelized among many as the solution to better data storage, but it's just another tool, it serves a far different purpose than an RDBMS such as MySQL. \$\endgroup\$ – user5665 Oct 4 '14 at 18:30
  • 1
    \$\begingroup\$ Since you guys are talking about MMO db solutions, I thought I'd mention that there is a school of thought that relational dbs are NOT optimal for an MMO because of the vast number of transactions that can be taking place. SQL is great for queries, but it is slow as molasses when you are talking hundreds of thousands of players making millions of trades, object creation, etc etc. Epic (and some other big developer studios) use an Object db for their MMOs (like Neverwinter). Yes, you can run the db in memory and use batch processing, but it's a hack; you are undermining ACID to do it. \$\endgroup\$ – JBiggs Mar 15 '17 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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