From 36f23e8d60dd7337ab60fcc6799c53eb2528e299 Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 12 Nov 2016 18:10:09 +0000 Subject: [PATCH] Use enum class for multi_send_endlevel_start --- common/main/multi.h | 17 ++++++++++------- similar/main/endlevel.cpp | 4 ++-- similar/main/multi.cpp | 6 +++--- similar/main/switch.cpp | 2 +- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/common/main/multi.h b/common/main/multi.h index 386458f26..023ab219a 100644 --- a/common/main/multi.h +++ b/common/main/multi.h @@ -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 diff --git a/similar/main/endlevel.cpp b/similar/main/endlevel.cpp index 1851066f4..1b665e3cc 100644 --- a/similar/main/endlevel.cpp +++ b/similar/main/endlevel.cpp @@ -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 diff --git a/similar/main/multi.cpp b/similar/main/multi.cpp index 41010a443..ae1e08a26 100644 --- a/similar/main/multi.cpp +++ b/similar/main/multi.cpp @@ -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(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 buf; buf[1] = Player_num; #if defined(DXX_BUILD_DESCENT_I) - buf[2] = secret; + buf[2] = static_cast(secret); #endif multi_send_data(buf.data(), buf.size(), 2); diff --git a/similar/main/switch.cpp b/similar/main/switch.cpp index 3b86d57fe..e95d66b1e 100644 --- a/similar/main/switch.cpp +++ b/similar/main/switch.cpp @@ -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