This is essentially a 'follow up' of the issues discussed in this topic:
https://forum.megaglest.org/index.php?topic=4696.0I've come to the point where I felt I needed to get this resolved, Daniel never got the tmp_refactor branch building, so I blazed my own path, and came up with a somewhat different solution.
This probably better belongs on the dev mailing list, but I can post pretty pictures here
The problem in a nutshell is the Network <-> Game/World interface. The NetworkInterface is created by MenuStates before the Game and World exist, but needs ultimately to interact very closely with them, this is achieved through a static object (a singleton) called NetworkManager, which creates and destroys the Interfaces as required, and provides queries for the game to determine if this is a network game, and provide pointers to the interface.
The old model:With lots of additions to the networking code (admittedly much of it only there for debugging atm) this slightly messy approach became very messy. I've added an abstract, but highly functional, class called SimulationInterface, it's owned by the Program, and represents the Interface to a, potentially non-existent, World and Game (renamed GameState for now, pending a better name coming up...)
There is always one and only one, the three concrete types are LocalInterface (very thin), ClientInterface & ServerInterface. Initially the Program creates a LocalInterface, in MenuStateJoinGame it is told to change into ClientInterface, MenuStateNewGame might or might not change it to Server, SimulationInterface::changeRole() by default copies the GameSettings and Stats from the previous Interface to the new.
The new model:Much of the stuff in Game that related more or less directly to the World (game speed, the Commander, etc) now lives in the SimulationInterface, along with the GameSettings and Stats, which previously has to be very carefully handed around when ProgramStates were changed.
The NetworkManager is gone, what was the old NetworkInterface and been renamed NetworkConnection, a NetworkInterface is now what used to be GameNetworkInterface (or GameInterface in very recent GAE code).
The SimulationInterface contains some code from the Game (GameState) and some from the old NetworkGameInterface, and some from the UnitUpdater which was eliminated last week. Anything which effects the game world goes through the SimulationInterface, so the client/server specific stuff is all handled through virtuals, the only 'network role' checks left atm are in the chat manager, and they will be coming into the SimulationInterface too.
All fairly much done and (importantly) working, I just need to go through and clean up some more, and will commit direct to trunk this week some time.