I didn't know how to search for this, so I'm sorry if this is covered somewhere. I really, really, really hate desync, and I'm trying to optimize my mission for multiplayer.
To illustrate my dilemma, let's start with a simple example. Suppose I want to teleport someone with setPos, using the following code:
bob setPos getpos boblogic
I could run that either only on the server or on every computer. Theoretically, both options should give the same result. But I'm not sure which option would be laggier.
On the one hand, if I execute the command only on the server, for a few milliseconds the clients are going to disagree with the server on where bob is. The server is going to have to send out messages to each client to synchronize the location of bob, thus increasing traffic.
On the other hand, if every computer executes that setpos command, it may be that every
computer will now send messages to everyone else telling them to update the position, causing even more traffic. And these messages won't be needed because every computer set bob to the same location, anyway.
I don't really know how OFP's netcode works though (except that it often doesn't work well
). So, can anyone weigh in on whether it would be better to execute such code only on the server or on server and clients? Obviously some global commands (such as createvehicle) should only be run on server, but what about others like setPos?
To be more specific about what I'm facing:
As described in my previous thread, I'm trying to have players start in random locations, and to do this I'm going to need setPos. (Simply grouping to markers or using the placement radius won't work because I want to limit the possible locations, and because I don't want two groups to end up at the same position).
And to make things even more confusing, setPos commands run on one computer during briefing seem to be completely disregarded when they attempt to move other computers' players. (Anti-cheating measure, maybe?) Therefore, either all computers must execute the same setPos commands during initialization or none at all.* I could execute the setPos commands on the server after
initialization (say during a titlecut black-out), that seems to work. I'm just not sure which option will lead to the best performance.
I'm also looking at setting a large number of units to a certain skill level, depending on parameters selected by the players during the multiplayer setup screen. I can only suppose that setSkill is global, so once again, I wonder whether it is better to run such commands only on the server or on every client as well. I may want to use other global commands, as well.
Thanks for any help.
* Or I suppose I could have each player's computer setpos only their own player, but that would take a lot of brainwork. I'd rather try one of the other options if either is less laggy.