Use enum class for multi_send_endlevel_start

This commit is contained in:
Kp 2016-11-12 18:10:09 +00:00
parent 7a0a20d455
commit 36f23e8d60
4 changed files with 16 additions and 13 deletions

View file

@ -494,17 +494,20 @@ void multi_do_frame(void);
#ifdef dsx
namespace dsx {
enum class multi_endlevel_type : bool
{
normal,
#if defined(DXX_BUILD_DESCENT_I)
void multi_send_endlevel_start(bool);
secret,
#endif
};
#if defined(DXX_BUILD_DESCENT_I)
void multi_send_endlevel_start(multi_endlevel_type);
#elif defined(DXX_BUILD_DESCENT_II)
void multi_send_endlevel_start();
static inline void multi_send_endlevel_start(bool secret)
static inline void multi_send_endlevel_start(multi_endlevel_type)
{
#ifdef DXX_HAVE_BUILTIN_CONSTANT_P
if (!dxx_builtin_constant_p(!!secret) || secret)
DXX_ALWAYS_ERROR_FUNCTION(multi_send_endlevel_start_with_secret, "secret not supported in Descent II");
#endif
(void)secret;
multi_send_endlevel_start();
}
#endif

View file

@ -322,7 +322,7 @@ void start_endlevel_sequence()
get_local_plrobj().ctype.player_info.homing_object_dist = -F1_0; // Turn off homing sound.
if (Game_mode & GM_MULTI) {
multi_send_endlevel_start(0);
multi_send_endlevel_start(multi_endlevel_type::normal);
multi_do_protocol_frame(1, 1);
}
@ -412,7 +412,7 @@ void start_endlevel_sequence()
}
if (Game_mode & GM_MULTI) {
multi_send_endlevel_start(0);
multi_send_endlevel_start(multi_endlevel_type::normal);
multi_do_protocol_frame(1, 1);
}
#ifndef NDEBUG

View file

@ -1941,7 +1941,7 @@ static void multi_do_escape(const ubyte *buf)
const char *txt;
int connected;
#if defined(DXX_BUILD_DESCENT_I)
if (buf[2])
if (buf[2] == static_cast<uint8_t>(multi_endlevel_type::secret))
{
txt = TXT_HAS_FOUND_SECRET;
connected = CONNECT_FOUND_SECRET;
@ -2577,7 +2577,7 @@ void multi_send_markers()
#endif
#if defined(DXX_BUILD_DESCENT_I)
void multi_send_endlevel_start(const bool secret)
void multi_send_endlevel_start(const multi_endlevel_type secret)
#elif defined(DXX_BUILD_DESCENT_II)
void multi_send_endlevel_start()
#endif
@ -2585,7 +2585,7 @@ void multi_send_endlevel_start()
array<uint8_t, DXX_MP_SIZE_ENDLEVEL_START> buf;
buf[1] = Player_num;
#if defined(DXX_BUILD_DESCENT_I)
buf[2] = secret;
buf[2] = static_cast<uint8_t>(secret);
#endif
multi_send_data<MULTI_ENDLEVEL_START>(buf.data(), buf.size(), 2);

View file

@ -302,7 +302,7 @@ int check_trigger_sub(object &plrobj, const trgnum_t trigger_num, int pnum,int s
Newdemo_state = ND_STATE_PAUSED;
if (Game_mode & GM_MULTI)
multi_send_endlevel_start(1);
multi_send_endlevel_start(multi_endlevel_type::secret);
if (Game_mode & GM_NETWORK)
multi_do_protocol_frame(1, 1);
PlayerFinishedLevel(1); //1 means go to secret level