Jump to content
  • Advertisement
Sign in to follow this  
Decryphe

How would I implement networking here?

This topic is 3163 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

Hello everyone! For school I've programmed this game: Galactitrade Now that the part for school is finished, I thought I'd expand this with some multiplayer networking. But for that I'd need some help to know where and how I should implement networking into the existing structure. Well then, down to what's in Galactitrade: I have programmed an "Object System" (made up of objects, yay) that can store data and variable names for each and every object (and can convert to/from strings/floats/ints). Additionally I build a tree with all the Objects in game, so I can split things up a bit and make handling of game states, objects, players, etc. much easier. To make the object even more versatile I use C++ polymorphism to implement object types of space ships, planets, markets, game states and so on. Well, what I am going to do soon as well is the implementation of CEGUI right into this object system. That means that a GUI-element can be attached to an object and every time the object's data changes, the GUI-element gets notified so that it will always display recent data. As of network programming, I thought that the following architecture might seem suited for this type of game (or maybe any kind of game): Since I have this object system, I could let objects notify a network handler that they have been changed and need an update over the network. The network handler would put this update onto a queue and check against a database (or something) how often each variable needs to be updated (immediately, every 100ms, never) and then queue it for sending as soon as necessary or as soon as there's free bandwidth. To implement this, I suppose that I'd have to give every object an integer-ID, so that a message really does arrive at the right place. As for receiving data, where in code should I do updates and how should I implement interpolation between network-data and actual displayed data in my object system? And should I do this the Peer2Peer or the Client/Server way? Greetings Decryphe

Share this post


Link to post
Share on other sites
Advertisement
All that you talk about can be done, and can work. The details depend on what the specifics of the game are.

Note that I wouldn't have a "database" of how often data needs to be updated; instead I'd have a way to tag each property you want to distribute with an update rate, so that the network dispatcher can just look it up as part of the data update event when it gets it.

Also, you should be very careful about who makes what decisions in the network game. If a piece of data has changed on node A, and is in transit to node B, then node A and node B will make different decisions if that piece of data is involved. This is the #1 reason why single-player games often fail to work as multi-player games -- you really have to structure the entire gameplay and logic around the fact that latency causes inconsistencies.

That, or run everything on a single node (call it the "server") and make the other nodes simply provide input to that node, and display the output from that node.

Share this post


Link to post
Share on other sites
Quote:
Original post by hplus0603
All that you talk about can be done, and can work. The details depend on what the specifics of the game are.

Note that I wouldn't have a "database" of how often data needs to be updated; instead I'd have a way to tag each property you want to distribute with an update rate, so that the network dispatcher can just look it up as part of the data update event when it gets it.

Also, you should be very careful about who makes what decisions in the network game. If a piece of data has changed on node A, and is in transit to node B, then node A and node B will make different decisions if that piece of data is involved. This is the #1 reason why single-player games often fail to work as multi-player games -- you really have to structure the entire gameplay and logic around the fact that latency causes inconsistencies.

That, or run everything on a single node (call it the "server") and make the other nodes simply provide input to that node, and display the output from that node.

That tagging seems the most viable way of doing things, since it's always part of a certain type of object to have a static set of variables. I think it's just as simple as declaring a map of <variable name,update frequency> as static member of each class.

Making decisions seems rather complicated... maybe there should be a few different scenarios: Some decisions are made on just one single node (like creating a path and following it with it's own units and telling the other nodes what the units are making), some should be made on every node (usually that's just choosing to display certain data onscreen) and some should be asked for whether or not they can be made (checking whether or not a building can be built and such things and if all nodes say yes, then the building is built). I suppose that these three scenarios seem to be those making up the P2P way of networking.

Client/Server would be easier there, because it's all about one server dictating all clients what to display and it tells what is possible and what not.

Thanks for your reply. =)

Greetings
Decryphe

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!