diff --git a/rehlds/engine/host_cmd.cpp b/rehlds/engine/host_cmd.cpp index 79996ab3..7a298c00 100644 --- a/rehlds/engine/host_cmd.cpp +++ b/rehlds/engine/host_cmd.cpp @@ -2808,6 +2808,26 @@ void Host_Kill_f(void) gEntityInterface.pfnClientKill(sv_player); } +void EXT_FUNC Host_Pause_api(bool setPause) +{ + g_psv.paused = setPause; +#ifdef REHLDS_FIXES + for (int i = 0; i < g_psvs.maxclients; i++) + { + if (g_psvs.clients[i].fakeclient) + continue; + if (!g_psvs.clients[i].connected) + continue; + + MSG_WriteByte(&g_psvs.clients[i].netchan.message, svc_setpause); + MSG_WriteByte(&g_psvs.clients[i].netchan.message, g_psv.paused); + } +#else // REHLDS_FIXES + MSG_WriteByte(&g_psv.reliable_datagram, svc_setpause); + MSG_WriteByte(&g_psv.reliable_datagram, g_psv.paused); +#endif // REHLDS_FIXES +} + void Host_TogglePause_f(void) { if (cmd_source == src_command) @@ -2857,22 +2877,7 @@ void Host_Pause_f(void) if (!pausable.value) return; - g_psv.paused = TRUE; -#ifdef REHLDS_FIXES - for (int i = 0; i < g_psvs.maxclients; i++) - { - if (g_psvs.clients[i].fakeclient) - continue; - if (!g_psvs.clients[i].connected) - continue; - - MSG_WriteByte(&g_psvs.clients[i].netchan.message, svc_setpause); - MSG_WriteByte(&g_psvs.clients[i].netchan.message, g_psv.paused); - } -#else // REHLDS_FIXES - MSG_WriteByte(&g_psv.reliable_datagram, svc_setpause); - MSG_WriteByte(&g_psv.reliable_datagram, g_psv.paused); -#endif // REHLDS_FIXES + Host_Pause_api(true); } void Host_Unpause_f(void) @@ -2888,22 +2893,7 @@ void Host_Unpause_f(void) if (!pausable.value) return; - g_psv.paused = FALSE; -#ifdef REHLDS_FIXES - for (int i = 0; i < g_psvs.maxclients; i++) - { - if (g_psvs.clients[i].fakeclient) - continue; - if (!g_psvs.clients[i].connected) - continue; - - MSG_WriteByte(&g_psvs.clients[i].netchan.message, svc_setpause); - MSG_WriteByte(&g_psvs.clients[i].netchan.message, g_psv.paused); - } -#else // REHLDS_FIXES - MSG_WriteByte(&g_psv.reliable_datagram, svc_setpause); - MSG_WriteByte(&g_psv.reliable_datagram, g_psv.paused); -#endif // REHLDS_FIXES + Host_Pause_api(false); } void Host_Interp_f(void) diff --git a/rehlds/engine/host_cmd.h b/rehlds/engine/host_cmd.h index 162c7977..8b6531e5 100644 --- a/rehlds/engine/host_cmd.h +++ b/rehlds/engine/host_cmd.h @@ -169,6 +169,7 @@ void Host_Kill_f(void); void Host_TogglePause_f(void); void Host_Pause_f(void); void Host_Unpause_f(void); +void Host_Pause_api(bool setPause); void Host_Interp_f(void); void Host_NextDemo(void); void Host_Startdemos_f(void); diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index 743e47d2..971ffaef 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/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/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index 62a39207..6af6bb20 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -518,6 +518,7 @@ RehldsFuncs_t g_RehldsApiFuncs = &RemoveExtDll_api, &RemoveCvarListener_api, &GetEntityInit_api, + &Host_Pause_api, &MSG_ReadChar_api, &MSG_ReadByte_api, &MSG_ReadLong_api,