Convert multi_endlevel to dispatch through a vtable

This commit is contained in:
Kp 2020-12-20 20:39:07 +00:00
parent a3eb82cefd
commit e2c95058db
5 changed files with 4 additions and 24 deletions

View file

@ -251,6 +251,7 @@ struct dispatch_table
virtual endlevel_poll_function_type *get_endlevel_poll2() const = 0;
virtual void kick_player(const _sockaddr &dump_addr, int why) const = 0;
virtual void disconnect_player(int playernum) const = 0;
virtual int end_current_level(int *secret) const = 0;
};
}
}
@ -487,7 +488,6 @@ void multi_send_bounty( void );
void multi_consistency_error(int reset);
window_event_result multi_level_sync();
int multi_endlevel(int *secret);
#ifdef dsx
namespace dsx {
void multi_send_hostage_door_status(vcwallptridx_t wallnum);

View file

@ -33,12 +33,12 @@ struct dispatch_table final : multi::dispatch_table
virtual endlevel_poll_function_type *get_endlevel_poll2() const override;
virtual void kick_player(const _sockaddr &dump_addr, int why) const override;
virtual void disconnect_player(int playernum) const override;
virtual int end_current_level(int *secret) const override;
};
extern const dispatch_table dispatch;
int kmatrix_poll2(newmenu *menu, const d_event &event, const unused_newmenu_userdata_t *);
void leave_game();
int endlevel(int *secret);
}
using udp::dispatch;
}

View file

@ -1688,7 +1688,7 @@ static window_event_result AdvanceLevel(int secret_flag)
if (Game_mode & GM_MULTI)
{
int result;
result = multi_endlevel(&secret_flag); // Wait for other players to reach this point
result = multi::dispatch->end_current_level(&secret_flag); // Wait for other players to reach this point
if (result) // failed to sync
{
// check if player has finished the game

View file

@ -1119,26 +1119,6 @@ void multi_show_player_list()
}
int multi_endlevel(int *const secret)
{
int result = 0;
switch (multi_protocol)
{
#if DXX_USE_UDP
case MULTI_PROTO_UDP:
result = multi::udp::endlevel(secret);
break;
#endif
default:
(void)secret;
Error("Protocol handling missing in multi_endlevel\n");
break;
}
return(result);
}
//
// Part 2 : functions that act on network messages and change the
// the state of the game in some way.

View file

@ -1489,7 +1489,7 @@ int kmatrix_poll2( newmenu *,const d_event &event, const unused_newmenu_userdata
return rval;
}
int endlevel(int *secret)
int dispatch_table::end_current_level(int *secret) const
{
// Do whatever needs to be done between levels
#if defined(DXX_BUILD_DESCENT_II)