From 65c6ce593b5eabf13e92b03352e4b429d0d797b0 Mon Sep 17 00:00:00 2001 From: s1lent Date: Tue, 22 May 2018 19:09:21 +0700 Subject: [PATCH] Bugfix: Prevent to pre-cache same local models twice and more (Affects #612) --- rehlds/engine/pr_cmds.cpp | 2 -- rehlds/engine/pr_cmds.h | 1 + rehlds/engine/pr_edict.cpp | 32 ++++++++++++++++++-------------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/rehlds/engine/pr_cmds.cpp b/rehlds/engine/pr_cmds.cpp index 89f7587..b3f1fac 100644 --- a/rehlds/engine/pr_cmds.cpp +++ b/rehlds/engine/pr_cmds.cpp @@ -1345,7 +1345,6 @@ void EXT_FUNC EV_SV_Playback(int flags, int clientindex, unsigned short eventind EV_Playback(flags,pEdict, eventindex, delay, origin, angles, fparam1, fparam2, iparam1, iparam2, bparam1, bparam2); } -#ifdef REHLDS_FIXES int SV_LookupModelIndex(const char *name) { if (!name || !name[0]) @@ -1369,7 +1368,6 @@ int SV_LookupModelIndex(const char *name) return 0; } -#endif // REHLDS_FIXES int EXT_FUNC PF_precache_model_I(const char *s) { diff --git a/rehlds/engine/pr_cmds.h b/rehlds/engine/pr_cmds.h index ee209b2..e7c20bc 100644 --- a/rehlds/engine/pr_cmds.h +++ b/rehlds/engine/pr_cmds.h @@ -79,6 +79,7 @@ void PF_setsize_I(edict_t *e, const float *rgflMin, const float *rgflMax); void PF_setmodel_I(edict_t *e, const char *m); int PF_modelindex(const char *pstr); int ModelFrames(int modelIndex); +int SV_LookupModelIndex(const char *name); void PF_bprint(char *s); void PF_sprint(char *s, int entnum); void ServerPrint(const char *szMsg); diff --git a/rehlds/engine/pr_edict.cpp b/rehlds/engine/pr_edict.cpp index 94a02ac..ba39bda 100644 --- a/rehlds/engine/pr_edict.cpp +++ b/rehlds/engine/pr_edict.cpp @@ -271,26 +271,30 @@ char *ED_ParseEdict(char *data, edict_t *ent) // local model? if (com_token[0] == '*') { - // find empty slot - int i; - for (i = 0; i < MAX_MODELS; i++) + // make sure that local model not pre-cached yet + if (!SV_LookupModelIndex(com_token)) { - if (!g_psv.model_precache[i]) - break; - } + // find empty slot + int i; + for (i = 0; i < MAX_MODELS; i++) + { + if (!g_psv.model_precache[i]) + break; + } - int index = Q_atoi(com_token + 1); + int index = Q_atoi(com_token + 1); - g_psv.model_precache[i] = localmodels[index]; - g_psv.models[i] = Mod_ForName(localmodels[index], FALSE, FALSE); - g_psv.model_precache_flags[i] |= RES_FATALIFMISSING; + g_psv.model_precache[i] = localmodels[index]; + g_psv.models[i] = Mod_ForName(localmodels[index], FALSE, FALSE); + g_psv.model_precache_flags[i] |= RES_FATALIFMISSING; #ifdef REHLDS_OPT_PEDANTIC - { - int __itmp = i; - g_rehlds_sv.modelsMap.put(g_psv.model_precache[i], __itmp); - } + { + int __itmp = i; + g_rehlds_sv.modelsMap.put(g_psv.model_precache[i], __itmp); + } #endif + } } } #endif