MCPcopy Create free account
hub / github.com/diasurgical/devilution / msg_wait_for_turns

Function msg_wait_for_turns

Source/msg.cpp:112–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112int msg_wait_for_turns()
113{
114 BOOL received;
115 DWORD turns;
116
117 if (!sgbDeltaChunks) {
118 nthread_send_and_recv_turn(0, 0);
119 if (!SNetGetOwnerTurnsWaiting(&turns) && SErrGetLastError() == STORM_ERROR_NOT_IN_GAME)
120 return 100;
121 if (SDL_GetTicks() - sgdwOwnerWait <= 2000 && turns < gdwTurnsInTransit)
122 return 0;
123 sgbDeltaChunks++;
124 }
125 multi_process_network_packets();
126 nthread_send_and_recv_turn(0, 0);
127 if (nthread_has_500ms_passed(FALSE))
128 nthread_recv_turns(&received);
129
130 if (gbGameDestroyed)
131 return 100;
132 if (gbDeltaSender >= MAX_PLRS) {
133 sgbDeltaChunks = 0;
134 sgbRecvCmd = CMD_DLEVEL_END;
135 gbDeltaSender = myplr;
136 nthread_set_turn_upper_bit();
137 }
138 if (sgbDeltaChunks == 20) {
139 sgbDeltaChunks = 21;
140 return 99;
141 }
142 return 100 * sgbDeltaChunks / 21;
143}
144
145void msg_process_net_packets()
146{

Callers

nothing calls this directly

Calls 7

SNetGetOwnerTurnsWaitingFunction · 0.85
SErrGetLastErrorFunction · 0.85
nthread_has_500ms_passedFunction · 0.85
nthread_recv_turnsFunction · 0.85

Tested by

no test coverage detected