Slashdot Mirror


Designing Multiplayer Game Engines?

mikera asks: "I'm a pretty experienced programmer but I've just embarked on my first (massively?) multiplayer strategy game. To make things even more interesting, I've decided to write it in C# and pick up a new language at the same time. I've chosen a client-server architecture where the server holds the one 'true' state of the world. The only communication from clients would be commands to units, which is simple enough, but the server will have to propagate game state changes (events) to all clients. I would like to ask Slashdot readers if they have solved a problem like this before or can offer some opinions on the best way to implement a solution."

"Lag is not really critical, but I still want things to be responsive and it must scale up well with the number of clients. The size of the map data, the complexity of the objects and bandwidth constraints rule out sending the complete game state, so only incremental updates will work. The situation is further complicated by the need to limit updates to just the areas of the map that are visible to a given player/team - this is clearly necessary to prevent client-side hacks such as gaining full map knowledge.

I understand the theory well enough, but I'm interested in practical advice on how to implement a solid architecture. What should the object model look like? How do I propagate events that are only partly within a client's field of view? Are there any novel features in C# that might make my life easier? How can I make the networking code as transparent as possible so I don't have to write SendUpdate() after every assignment?"

Your comments, insights, hints and flames are eagerly awaited."

6 of 397 comments (clear)

  1. WorldForge by Shiny+Metal+S. · · Score: 4, Redundant

    Take a look at The WorldForge Project. You probably won't learn more anywhere else.

    --

    ~shiny
    WILL HACK FOR $$$

  2. Mod This Up To +5!!! by cybrpnk · · Score: 1, Redundant

    WorldForge is the first thing that should be considered in a discussion on this topic...

  3. You should check out WorldForge... by Adrian+Voinea · · Score: 1, Redundant

    The WorldForge project is a very interesting site. They have all the sources to their clients/servers available. You should find some useful information there.

  4. Might check out WorldForge by sparrow_hawk · · Score: 0, Redundant

    Check out WorldForge, an open-source MMORPG project. Nothing like seeing the principles in action!

  5. Mod This Up To +5!!!! by cybrpnk · · Score: 1, Redundant

    WorldForge is the first thing that should be considered on this topic...

  6. My two cents by Bob+Smith+157 · · Score: 0, Redundant

    I'll avoid most of my comments about your choice of language because most of it is of a political nature, rather than practical one; however, I really wouldn't suggest trying to make a massively multiplayer game with a language you're unfamiliar with. It's quite an undertaking even with a language you know. I know; i'm working on one.

    As for the networking code transparency, this one seems fairly obvious to me.. Just keep a datastructure containing all the changed or "tainted" objects as you go. Make mutator functions of your classes set objects as tainted. Then, just do the networking updates once or twice every time through the main loop (assuming it's in the same thread. Otherwise, you can implement something that might end up being a little more efficient).

    As for updating only what the player needs to be updated on, this seems like a question of algorithm efficiency. I don't know the specifics of your game, but with most massively multiplater games, transmitting the entire world state, or even the entire list of changes to every client, every cycle would be insane. So, you have to only update the section of the world that the player can see. How to do this well depends on the internal structure of the world, and what sort of stuff the player can "see". If the game is room-based, then this is easy. If the player can always just see a specific size circle or rectangle around him, this is also easy (each event can check distance to all players in its regeon). If it works like most RTS with arbitrary viewing areas, then you might have to be a little more clever. Whether this is even much of a concern is really a question of the number of people supported, and the expected hardware this'll be running on.

    Hope that helps,
    Bob

    --


    "It's funny. On the outside, I was an honest man. Straight as an arrow. I had to come to prison to be a crook."