Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement API function "Host_Pause" #1039

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 22 additions & 32 deletions rehlds/engine/host_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions rehlds/engine/host_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions rehlds/public/rehlds/rehlds_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)();
Expand Down
1 change: 1 addition & 0 deletions rehlds/rehlds/rehlds_api_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down