Skip to content

Commit 59a362e

Browse files
fix end-mission sexp in multi (#6943)
A previous attempt to fix the end-mission sexp in multi such that it wouldn't trigger the jump out sequence was horribly broken. Notable safety checks, state changes and server/client syncing was skipped over. This caused, as one particular bug, a standalone server to stop communicating with the game host. When this happened stats couldn't be accepted/tossed and you were stuck at the debrief screen, being forced to disconnect from the standalone in order to continue. A proper fix for this is to use multi sexps to tell clients to enter a debrief state before the standard end mission request is handled. This will allow it the bypass the actual warp out animation for players while still doing the normal end of mission handling. NOTE: This is a breaking, but not fatal, multi change and should be safe considering the recent version bump in early June. As such an additional version bump is not required with this for 25.0.
1 parent 7780769 commit 59a362e

3 files changed

Lines changed: 21 additions & 32 deletions

File tree

code/network/multimsgs.cpp

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3952,22 +3952,6 @@ void process_ingame_nak(ubyte *data, header *hinfo)
39523952
}
39533953
}
39543954

3955-
// If the end_mission SEXP has been used tell clients to skip straight to the debrief screen
3956-
void send_force_end_mission_packet()
3957-
{
3958-
ubyte data[MAX_PACKET_SIZE];
3959-
int packet_size;
3960-
3961-
packet_size = 0;
3962-
BUILD_HEADER(FORCE_MISSION_END);
3963-
3964-
if (Net_player->flags & NETINFO_FLAG_AM_MASTER)
3965-
{
3966-
// tell everyone to leave the game
3967-
multi_io_send_to_all_reliable(data, packet_size);
3968-
}
3969-
}
3970-
39713955
// process a packet indicating that we should jump straight to the debrief screen
39723956
void process_force_end_mission_packet(ubyte * /*data*/, header *hinfo)
39733957
{
@@ -3977,13 +3961,13 @@ void process_force_end_mission_packet(ubyte * /*data*/, header *hinfo)
39773961

39783962
PACKET_SET_SIZE();
39793963

3980-
ml_string("Receiving force end mission packet");
3981-
3982-
// Since only the server sends out these packets it should never receive one
3983-
Assert (!(Net_player->flags & NETINFO_FLAG_AM_MASTER));
3984-
3985-
multi_handle_sudden_mission_end();
3986-
send_debrief_event();
3964+
// TODO: Obsolete packet - Remove on next multi bump
3965+
//
3966+
// This method of ending a mission was horribly broken and skipped over a
3967+
// lot of necessary state changes resulting in broken standalone net traffic
3968+
//
3969+
// We need to support receiving this packet for compatibility sake, but it
3970+
// should be removed on the next multi bump (as noted in #6927)
39873971
}
39883972

39893973
// send a packet telling players to end the mission

code/network/multimsgs.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,6 @@ void send_new_player_packet(int new_player_num,net_player *target);
360360
// send a packet telling players to end the mission
361361
void send_endgame_packet(net_player *pl = NULL);
362362

363-
// send a skip to debrief item packet
364-
void send_force_end_mission_packet();
365-
366363
// send a position/orientation update for myself (if I'm an observer)
367364
void send_observer_update_packet();
368365

code/parse/sexp.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17064,12 +17064,16 @@ void sexp_end_mission(int n)
1706417064
send_debrief_event();
1706517065
}
1706617066

17067-
// Karajorma - callback all the clients here.
17068-
if (MULTIPLAYER_MASTER)
17069-
{
17070-
multi_handle_sudden_mission_end();
17071-
send_force_end_mission_packet();
17072-
}
17067+
Current_sexp_network_packet.do_callback();
17068+
}
17069+
17070+
void multi_sexp_end_mission()
17071+
{
17072+
// This is a bit of hack, but when in a debrief state clients will skip the
17073+
// warp out sequence when the endgame packet is processed.
17074+
send_debrief_event();
17075+
// Standard way to end mission (equivalent to Alt-J)
17076+
multi_handle_end_mission_request();
1707317077
}
1707417078

1707517079
// Goober5000
@@ -30678,6 +30682,10 @@ void multi_sexp_eval()
3067830682
multi_sexp_red_alert();
3067930683
break;
3068030684

30685+
case OP_END_MISSION:
30686+
multi_sexp_end_mission();
30687+
break;
30688+
3068130689
// bad sexp in the packet
3068230690
default:
3068330691
// probably just a version error where the host supports a SEXP but a client does not

0 commit comments

Comments
 (0)