Skip to content

Commit

Permalink
Implement CVar sv_usercmd_custom_random_seed
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyShorokhov committed Jun 11, 2021
1 parent b4ae19f commit 8746fdc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions rehlds/engine/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ extern cvar_t sv_rehlds_local_gametime;
extern cvar_t sv_rehlds_send_mapcycle;
extern cvar_t sv_rehlds_maxclients_from_single_ip;
extern cvar_t sv_use_entity_file;
extern cvar_t sv_usercmd_custom_random_seed;
#endif
extern int sv_playermodel;

Expand Down
2 changes: 2 additions & 0 deletions rehlds/engine/sv_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ cvar_t sv_rehlds_local_gametime = {"sv_rehlds_local_gametime", "0", 0, 0.0f, nul
cvar_t sv_rehlds_send_mapcycle = { "sv_rehlds_send_mapcycle", "0", 0, 0.0f, nullptr };
cvar_t sv_rehlds_maxclients_from_single_ip = { "sv_rehlds_maxclients_from_single_ip", "5", 0, 5.0f, nullptr };
cvar_t sv_use_entity_file = { "sv_use_entity_file", "0", 0, 0.0f, nullptr };
cvar_t sv_usercmd_custom_random_seed = { "sv_usercmd_custom_random_seed", "0", 0, 0.0f, nullptr };
#endif

delta_t *SV_LookupDelta(char *name)
Expand Down Expand Up @@ -8017,6 +8018,7 @@ void SV_Init(void)
Cvar_RegisterVariable(&sv_rehlds_send_mapcycle);
Cvar_RegisterVariable(&sv_rehlds_maxclients_from_single_ip);
Cvar_RegisterVariable(&sv_use_entity_file);
Cvar_RegisterVariable(&sv_usercmd_custom_random_seed);
#endif

for (int i = 0; i < MAX_MODELS; i++)
Expand Down
5 changes: 5 additions & 0 deletions rehlds/engine/sv_user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,11 @@ void SV_RunCmd(usercmd_t *ucmd, int random_seed)
if (!host_client->fakeclient)
SV_SetupMove(host_client);

#ifdef REHLDS_FIXES
if (sv_usercmd_custom_random_seed.value)
random_seed = int(Sys_FloatTime() * 1000.0);
#endif

gEntityInterface.pfnCmdStart(sv_player, ucmd, random_seed);
frametime = float(ucmd->msec * 0.001);
host_client->svtimebase = frametime + host_client->svtimebase;
Expand Down

0 comments on commit 8746fdc

Please sign in to comment.