MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / MultiSendLevelEnded

Function MultiSendLevelEnded

Descent3/multi.cpp:3599–3637  ·  view source on GitHub ↗

Tells all the clients to end the level

Source from the content-addressed store, hash-verified

3597
3598// Tells all the clients to end the level
3599void MultiSendLevelEnded(int success, int next_level) {
3600 MULTI_ASSERT(Netgame.local_role == LR_SERVER, NULL);
3601
3602 uint8_t data[MAX_GAME_DATA_SIZE];
3603 int count = 0;
3604 int size_offset;
3605
3606 mprintf(0, "Sending level ended!\n");
3607
3608 size_offset = START_DATA(MP_LEVEL_ENDED, data, &count, 1);
3609 MultiAddByte(success, data, &count);
3610 MultiAddByte(next_level, data, &count);
3611 END_DATA(count, data, size_offset);
3612
3613 // First send out to all the people who are playing
3614 MultiSendReliablyToAllExcept(Player_num, data, count, NETSEQ_OBJECTS, true);
3615
3616 // Now send a connect bail on all the ones who are connecting
3617 MultiSendConnectBail();
3618
3619 NetPlayers[Player_num].sequence = NETSEQ_LEVEL_END;
3620
3621 if (success)
3622 SetGameState(GAMESTATE_LVLEND);
3623 else
3624 SetGameState(GAMESTATE_LVLFAILED);
3625
3626 if (Netgame.local_role == LR_SERVER) {
3627 for (int i = 0; i < MAX_PLAYERS; i++) {
3628 if (NetPlayers[i].flags & NPF_CONNECTED && NetPlayers[i].sequence == NETSEQ_PLAYING)
3629 NetPlayers[i].sequence = NETSEQ_WAITING_FOR_LEVEL;
3630 }
3631 }
3632 // Do this so it gets sent off now.
3633 for (int t = 0; t < 10; t++) {
3634 nw_DoNetworkIdle();
3635 Sleep(100);
3636 }
3637}
3638
3639extern void MultiClearPlayerMarkers(int slot);
3640// Do leave game stuff

Callers 1

EndLevelFunction · 0.85

Calls 8

START_DATAFunction · 0.85
MultiAddByteFunction · 0.85
END_DATAFunction · 0.85
MultiSendConnectBailFunction · 0.85
SetGameStateFunction · 0.85
nw_DoNetworkIdleFunction · 0.85
SleepFunction · 0.50

Tested by

no test coverage detected