There's a lot more to it than that; accounting for latency requires the ability to rollback game state (to resolve disagreements between client game states).
Retrofitting such a networking solution to starsector would be a truly monumental task; even my unending optimism believes that solution to be impossible (without direct access to the source).
A more practicable solution is to make the game state deterministic, and just share (and buffer) player inputs.
It's all been thought about & discussed on the forums before, along with a significant amount of planning & prototyping work.
Correct me if i am wrong but could a system similar to the one used in Supreme Commander work? It enforces a minimum lag of 500ms (iirc) between players so the game has time to synch everything properly.
I don't know how 501+ms lag is handled though.
Yes, SupCom used a peer-to-peer deterministic lock-step model to keep the clients in perfect sync, and that 500ms enforced latency would be precisely because of the buffering necessary to achieve this.
There's an article on the subject
here that specifically mentions SupCom (among other RTS games).
- Making Starsector deterministic is relatively easy if you're familiar with Java instrumentation.
- Making it fixed time step is likewise doable
- Capturing, relaying, buffering & remotely interpreting user inputs (in a symmetric way) is a little more involved, but again nothing impossible.
- Making the AI behave symmetrically is an unknown to me at this point, as I've not looked at that code yet. Though I don't anticipate it being too hard to work around, or fix if necessary.
- Building the backend for matchmaking, leaderboards etc etc is time consuming, but straightfoward.
With modern broadband, I'm hoping SS MP will have a much increased simulation rate (and thus a far smaller input buffer); something in the range of 100ms.
Though there's no reason it can't dynamically tune itself to the latency between the clients involved.
I've tested the game with an artificial latency on inputs, and it remains perfectly playable well above 200ms; in fact almost unnoticeable most of the time.
That said, aiming ship weapons does suffer a little, especially on the smaller ships.
Fortunately most of the time you defer weapon targeting to the AI, and as that's part of the simulation it's obviously unaffected by the latency.
Implementing it is all perfectly possible, and well within my understanding; it's just a case of finding the time
Ironically the most difficult part so far has been writing instrumentation to inject menu options.
You'd think it'd be straightforward....(and it would be, if it were a good gui API like Swing or Javafx)... but the home brew ui that Starsector uses is... shall we say... less than perfect.