From 89f575c89602ae0cc851f3dcf5deb1e27b52831b Mon Sep 17 00:00:00 2001 From: h0mev Date: Sun, 14 Jul 2024 21:35:33 +0800 Subject: [PATCH 1/6] Add natives about pause --- .../scripting/include/reapi_engine.inc | 16 ++++++++++ .../include/cssdk/engine/rehlds_interfaces.h | 3 ++ reapi/src/natives/natives_misc.cpp | 31 +++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/reapi/extra/amxmodx/scripting/include/reapi_engine.inc b/reapi/extra/amxmodx/scripting/include/reapi_engine.inc index be36a7da..e0583e08 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_engine.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_engine.inc @@ -279,6 +279,22 @@ native rh_get_net_from(output[], len); */ native rh_get_client_connect_time(const index); +/* +* Checks if server paused +* +* @return Returns true if paused, otherwise false. +*/ +native bool:rh_is_paused(); + +/* +* Set server pause state +* +* @param st Pause state, true: server will be paused +* +* @noreturn +*/ +native rh_set_paused(const bool:st); + /* * Checks if a specific entity is fully packed in a given frame for a host client. * diff --git a/reapi/include/cssdk/engine/rehlds_interfaces.h b/reapi/include/cssdk/engine/rehlds_interfaces.h index e2b909fa..8431d1ce 100644 --- a/reapi/include/cssdk/engine/rehlds_interfaces.h +++ b/reapi/include/cssdk/engine/rehlds_interfaces.h @@ -129,4 +129,7 @@ class IRehldsServerData { virtual void SetName(const char* name) = 0; virtual class ISteamGameServer *GetSteamGameServer() = 0; virtual struct netadr_s *GetNetFrom() = 0; + + virtual bool IsPaused() = 0; + virtual void SetPaused(bool state) = 0; }; diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index 50300b99..d34876a7 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -3722,6 +3722,35 @@ cell AMX_NATIVE_CALL rh_is_entity_fullpacked(AMX *amx, cell *params) return FALSE; } +/* +* Checks if server paused +* +* @return Returns true if paused, otherwise false. +* +* native bool:rh_is_paused(); +*/ +cell AMX_NATIVE_CALL rh_is_paused(AMX *amx, cell *params) +{ + return g_RehldsData->IsPaused() ? TRUE : FALSE; +} + +/* +* Set server pause state +* +* @param st pause state +* +* @noreturn +* +* native rh_set_paused(const bool:st); +*/ +cell AMX_NATIVE_CALL rh_set_paused(AMX *amx, cell *params) +{ + enum { arg_count, arg_st }; + g_RehldsData->SetPaused(params[arg_st] != 0); + + return TRUE; +} + AMX_NATIVE_INFO Misc_Natives_RH[] = { { "rh_set_mapname", rh_set_mapname }, @@ -3734,6 +3763,8 @@ AMX_NATIVE_INFO Misc_Natives_RH[] = { "rh_get_realtime", rh_get_realtime }, { "rh_is_entity_fullpacked", rh_is_entity_fullpacked }, { "rh_get_client_connect_time", rh_get_client_connect_time }, + { "rh_is_paused", rh_is_paused }, + { "rh_set_paused", rh_set_paused }, { nullptr, nullptr } }; From 27b8e66d2fc45456663abe8e61916a68db43c6d6 Mon Sep 17 00:00:00 2001 From: h0mev Date: Thu, 18 Jul 2024 22:20:42 +0800 Subject: [PATCH 2/6] Fix crash when g_RehldsData->SetPaused() be called --- reapi/include/cssdk/engine/rehlds_interfaces.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/reapi/include/cssdk/engine/rehlds_interfaces.h b/reapi/include/cssdk/engine/rehlds_interfaces.h index 8431d1ce..57976178 100644 --- a/reapi/include/cssdk/engine/rehlds_interfaces.h +++ b/reapi/include/cssdk/engine/rehlds_interfaces.h @@ -129,6 +129,13 @@ class IRehldsServerData { virtual void SetName(const char* name) = 0; virtual class ISteamGameServer *GetSteamGameServer() = 0; virtual struct netadr_s *GetNetFrom() = 0; + virtual double GetOldTime() = 0; + virtual void SetNetFrom(struct netadr_s *from) = 0; + virtual void SetWorldmapCrc(uint32 crcValue) = 0; + virtual void SetDecalNameNum(int num) = 0; + + virtual bool IsActive() = 0; + virtual void SetActive(bool state) = 0; virtual bool IsPaused() = 0; virtual void SetPaused(bool state) = 0; From 719f2f8f554a6d2a390ef55bec1ef08bf53f28e7 Mon Sep 17 00:00:00 2001 From: h0mev Date: Fri, 19 Jul 2024 02:30:15 +0800 Subject: [PATCH 3/6] host_pause --- .../amxmodx/scripting/include/reapi_engine.inc | 2 +- reapi/include/cssdk/engine/rehlds_api.h | 1 + reapi/src/natives/natives_misc.cpp | 13 +++++++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/reapi/extra/amxmodx/scripting/include/reapi_engine.inc b/reapi/extra/amxmodx/scripting/include/reapi_engine.inc index e0583e08..b2487747 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_engine.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_engine.inc @@ -293,7 +293,7 @@ native bool:rh_is_paused(); * * @noreturn */ -native rh_set_paused(const bool:st); +native rh_set_paused(const bool:st, const bool:host); /* * Checks if a specific entity is fully packed in a given frame for a host client. diff --git a/reapi/include/cssdk/engine/rehlds_api.h b/reapi/include/cssdk/engine/rehlds_api.h index 0444b60c..588acb3a 100644 --- a/reapi/include/cssdk/engine/rehlds_api.h +++ b/reapi/include/cssdk/engine/rehlds_api.h @@ -382,6 +382,7 @@ struct RehldsFuncs_t { void(*RemoveExtDll)(void *hModule); void(*RemoveCvarListener)(const char *var_name, cvar_callback_t func); ENTITYINIT(*GetEntityInit)(char *pszClassName); + void(*Host_Pause)(bool setPause); // Read functions int(*MSG_ReadChar)(); diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index d34876a7..ab03fe53 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -3743,11 +3743,16 @@ cell AMX_NATIVE_CALL rh_is_paused(AMX *amx, cell *params) * * native rh_set_paused(const bool:st); */ -cell AMX_NATIVE_CALL rh_set_paused(AMX *amx, cell *params) +cell AMX_NATIVE_CALL rh_set_pause(AMX *amx, cell *params) { - enum { arg_count, arg_st }; - g_RehldsData->SetPaused(params[arg_st] != 0); + enum { arg_count, arg_st, arg_host }; + bool isPause = params[arg_st] != 0; + g_RehldsData->SetPaused(isPause); + if (params[arg_host] != 0) + { + g_RehldsFuncs->Host_Pause(isPause); + } return TRUE; } @@ -3764,7 +3769,7 @@ AMX_NATIVE_INFO Misc_Natives_RH[] = { "rh_is_entity_fullpacked", rh_is_entity_fullpacked }, { "rh_get_client_connect_time", rh_get_client_connect_time }, { "rh_is_paused", rh_is_paused }, - { "rh_set_paused", rh_set_paused }, + { "rh_set_paused", rh_set_pause }, { nullptr, nullptr } }; From e5b82599c5ea12ab917e60493d9760c61a694452 Mon Sep 17 00:00:00 2001 From: jonathan-up Date: Sat, 20 Jul 2024 03:50:46 +0800 Subject: [PATCH 4/6] Fix doc --- reapi/extra/amxmodx/scripting/include/reapi_engine.inc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/reapi/extra/amxmodx/scripting/include/reapi_engine.inc b/reapi/extra/amxmodx/scripting/include/reapi_engine.inc index b2487747..c9d2068d 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_engine.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_engine.inc @@ -289,11 +289,15 @@ native bool:rh_is_paused(); /* * Set server pause state * -* @param st Pause state, true: server will be paused +* @param st Pause state, true: server will be paused, false: unpause(if paused) +* @param host If it is 1, the native will call 'Host_Pause()' +* +* @note rh_set_paused(true, true) just like set pausable to 1 and execute client command 'pause' +* @note rh_set_paused(true, false) only set g_psv.paused * * @noreturn */ -native rh_set_paused(const bool:st, const bool:host); +native rh_set_pause(const bool:st, const bool:host = true); /* * Checks if a specific entity is fully packed in a given frame for a host client. From 14b3ef4b012949649101ac6ed07f8c3fb9fc2ac6 Mon Sep 17 00:00:00 2001 From: h0mev Date: Sat, 20 Jul 2024 04:17:33 +0800 Subject: [PATCH 5/6] Update natives_misc.cpp --- reapi/src/natives/natives_misc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index ab03fe53..a88397ec 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -3769,7 +3769,7 @@ AMX_NATIVE_INFO Misc_Natives_RH[] = { "rh_is_entity_fullpacked", rh_is_entity_fullpacked }, { "rh_get_client_connect_time", rh_get_client_connect_time }, { "rh_is_paused", rh_is_paused }, - { "rh_set_paused", rh_set_pause }, + { "rh_set_pause", rh_set_pause }, { nullptr, nullptr } }; From 8d0455c3de72c5aa9b42c4688fd069c9ccc2cdf1 Mon Sep 17 00:00:00 2001 From: h0mev Date: Sat, 20 Jul 2024 04:22:38 +0800 Subject: [PATCH 6/6] Update reapi_engine.inc --- reapi/extra/amxmodx/scripting/include/reapi_engine.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/reapi/extra/amxmodx/scripting/include/reapi_engine.inc b/reapi/extra/amxmodx/scripting/include/reapi_engine.inc index c9d2068d..1b182156 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_engine.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_engine.inc @@ -294,6 +294,7 @@ native bool:rh_is_paused(); * * @note rh_set_paused(true, true) just like set pausable to 1 and execute client command 'pause' * @note rh_set_paused(true, false) only set g_psv.paused +* @note It's best not to use rh_set_paused(false, false), bad things will happen * * @noreturn */