Algorithm next:
- Server load world.
- Client(s) connect to server.
- Server transfer all world data (json | gz)
- Client (unpack) load data to all structures (overmap, submaps, player, etc)
Do_turn
- Server send “turn” signal to player
- Player has some seconds to turn. Other players wait or plan actions. If action is planned player turn instantly. If time out then player wait.
- After turn player send action to server.
- Server verify action and return changed data (json)
- Client merge data from json
10 Goto 6 if moves > 0
- Goto 6 for turn next player
- Turn for zombies etc.
- Goto 5
Refactoring:
- Separate ui, action and data logic. Schema:
| client | | server
UI<->Control <- interface -> Data
Interface has two work mode - for local playing and remote.
2. Add state_id for all structures (for check changes)
3. Some fixes with serialize interfaces
It is real, but ton of work.
Except for the part where players can trigger activities that take many hours of in-game time to resolve, and the game being basically impossible to play if you only have a few seconds to take your next action.
You could make a multiplayer dda, but by the time you’re done it would either be terrible or only remotely resemble dda. I’d strongly suggest starting from scratch, especially since the game loop isn’t remotely suited for multiplayer, so you’d basically have to throw that out too.
One thing that might be worthwhile would be to build a multiplayer dda-alike that can consume dda json for item and monster definitons.
I think a prerequisite to multiplayer CDDA would be a realtime CDDA. It would necessitate turning the current action system on its head, so that the clock drives the game, and the player only gives commands and waits until the actions resolve (i.e. like in Dwarf Fortress). Then you could make headway towards making simultaneous multiplayer work.
If Kerbal Space Program can have multiplayer despite time-warp, I think it’s feasible that CDDA can have it too.
[spoiler=some useless info]actualy its possible to play cataclysm multiplayer but you cant see other players and can cause desync
2 players go to this same place
player 1 enter this place first
player 2 enter this place second
player 2 loot everything
player 2 save game
player 1 save game
both players go away
place is still full of loot because player one loaded it first and saved last[/spoiler]
well i think its possible to make multiplayer without changing whole game, of course we talk about small game with friends/fellow survivors not great mmo
turns are speed right?
so maybe do something like this?:
server wait for players to input command
all players input command (if someone do not do anything for [insert time here] he skip his turn
players and monsters move
server check if any player or monster have speed higher than 0
players with speed higher than 0 input commands
players and monster move
server give speed to players and monsters
repeat