2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-27 07:05:43 +03:00

Implement API function "Host_Pause"

This commit is contained in:
h0mev 2024-07-19 02:26:27 +08:00
parent 9c1e84328e
commit 4966eadca1
4 changed files with 25 additions and 32 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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)();

View File

@ -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,