2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-28 15:45:46 +03:00

Simple entity editor (#694)

Ability to load entites from separate file instead of map content.
Added sv_use_entity_file cvar to toggle entites loading source.
This commit is contained in:
Karaulov 2019-05-07 15:52:00 +03:00 committed by Lev
parent 998f17263e
commit 3f809d018a
2 changed files with 46 additions and 0 deletions

View File

@ -55,6 +55,7 @@ Bugfixed version of rehlds contains an additional cvars:
<li>sv_rehlds_userinfo_transmitted_fields // Userinfo fields only with these keys will be transmitted to clients via network. If not set then all fields will be transmitted (except prefixed with underscore). Each key must be prefixed by backslash, for example "\name\model\*sid\*hltv\bottomcolor\topcolor". See [wiki](https://github.com/dreamstalker/rehlds/wiki/Userinfo-keys) to collect sufficient set of keys for your server. Default: ""
<li>sv_rehlds_attachedentities_playeranimationspeed_fix // Fixes bug with gait animation speed increase when player has some attached entities (aiments). Can cause animation lags when cl_updaterate is low. Default: 0
<li>sv_rehlds_maxclients_from_single_ip // Limit number of connections from the single ip address. Default: 5
<li>sv_use_entity_file // Use custom entity file for a map. Path to an entity file will be "maps/[map name].ent". Default: 0
</ul>
## Commands

View File

@ -203,6 +203,7 @@ cvar_t sv_rehlds_attachedentities_playeranimationspeed_fix = {"sv_rehlds_attache
cvar_t sv_rehlds_local_gametime = {"sv_rehlds_local_gametime", "0", 0, 0.0f, nullptr};
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 };
#endif
delta_t *SV_LookupDelta(char *name)
@ -6126,6 +6127,49 @@ int SV_SpawnServer(qboolean bIsDemo, char *server, char *startspot)
void SV_LoadEntities(void)
{
#ifdef REHLDS_FIXES
if (sv_use_entity_file.value > 0.0f)
{
char name[MAX_PATH];
Q_snprintf(name, sizeof(name), "maps/%s.ent", g_psv.name);
if (!FS_FileExists(name))
{
FILE *f = FS_Open(name, "wb");
if (f)
{
FS_Write(g_psv.worldmodel->entities, Q_strlen(g_psv.worldmodel->entities), 1, f);
FS_Close(f);
}
}
else
{
FILE *f = FS_Open(name, "rb");
if (f)
{
Con_Printf("Using custom entity file: %s\n", name);
unsigned int nFileSize = FS_Size(f);
char *pszInputStream = (char *)Mem_Malloc(nFileSize + 1);
if (!pszInputStream)
{
Sys_Error("%s: Could not allocate space for entity file of %i bytes", __func__, nFileSize + 1);
}
FS_Read(pszInputStream, nFileSize, 1, f);
pszInputStream[nFileSize] = '\0';
ED_LoadFromFile(pszInputStream);
Mem_Free(pszInputStream);
FS_Close(f);
return;
}
}
Con_Printf("Using default entities...\n");
}
#endif // REHLDS_FIXES
ED_LoadFromFile(g_psv.worldmodel->entities);
}
@ -7863,6 +7907,7 @@ void SV_Init(void)
Cvar_RegisterVariable(&sv_rollspeed);
Cvar_RegisterVariable(&sv_rollangle);
Cvar_RegisterVariable(&sv_use_entity_file);
#endif
for (int i = 0; i < MAX_MODELS; i++)