RTS Netcode: any tips?

Miscellaneous Forums/General Discussion/RTS Netcode: any tips?

As a spare-time project, I'm tinkering with ideas for an RTS, and I was wondering how best to structure the netcode.

Should I have each client send every order their player gives back to the server, and have the server redistribute that back out to the other clients? That sounds like it could get pretty hairy once the orders start flying.

Any thoughts?

No reason why not I guess, but that doesn't mean the server has to cause those orders to be acted upon instantly - maybe I'm wrong but I thought that a game like Starcraft would receive the order at the server and then after a short delay would cause it to be acted upon - not due to lag but deliberately so that it doesn't have to send everything all at once.

as long as what the player sees on his screen is the same as what someone elses player sees, with regards to where the units are, what action they are engaged in and their hp/energy/death/effects status' are. Then there is no problem.

In other words. If it doesn't effect gameplay. It can be different on each machine. For example. Idle animations. Hell.. Even character models (America's Army anyone?)..

As long as units move to the same locations, at nearly the same time (notice, you could give units identicle orders, know that the pathfinding will get them all to the same place in the same way, and just interrupt if that changes and readjust if units aren't -exactly- in the same place) the player won't know or care that his orc is dancing on his screen while on his friends screen the orc is giving you the finger.

As long as when something comes up to attack it, they both reflect the same HP. do the same attacks, and otherwise do the same things.

It is a lot less information than you think.

And you can get crafty and leave out info that one player doesn't know and can't see if you really want to. As long as when he 'discovers' the base it doesn't just blink in.

In other words.. the server could keep tabs on the map and if the 2 (or more) players can't see eachother, they just don't bother to send that info. I mean... If all the base building is going on under fog-of-war ... why send the info.

Then when the other player uses some magic to spy in that location. The server sends the info before it is 'enacted' and that info would be what buildings are where, how much HP they have, and where units are and where they are headed and what they are doing.

Unless you are dealing with thousands of on-screen units, you shouldn't run into any trouble.

And if you don't plan to have thousands of ON MAP units.. you prolly don't have ANYTHING to worry about.


In other words.. the server could keep tabs on the map and if the 2 (or more) players can't see eachother, they just don't bother to send that info. I mean... If all the base building is going on under fog-of-war ... why send the info.


Not only can you omit sending the information if they can't see it, you SHOULD NOT send the information - otherwise people will be able to sniff the packets and get information that they shouldn't have. Ever hear of ShowEQ, the everquest program that read the info off the incoming packets and then displayed things on a players map they normally couldn't see? There are a ton of programs like that for every MMO that sends data that way, and there will be some for your program too if it gets popular.

I suppose you could send the info right away if you wanted, if you encrypted it. Of course, the extra time the server spends encrypting every message is going to be more overhead and more of a pain then just sending the info *only* when it is needed.

Okay, guys, thanks for the info. If I ever have anything awesome to show, I'll post it.