mirror of
https://github.com/rehlds/rehlds.git
synced 2024-12-29 08:05:50 +03:00
Fixed saving temporary string in PF_lightstyle_I (#532)
Fixed saving temporary string in PF_lightstyle_I Marked mismatched code (HLTV) Fixed lightstyle copying in ParseSaveTables (SinglePlayer)
This commit is contained in:
parent
ae28ee69b4
commit
2829c7ffde
@ -353,6 +353,13 @@ void World::AddLightStyle(int index, char *style)
|
|||||||
m_System->Printf("WARNING! World::SetLightStyle: style too long (%i).\n", length);
|
m_System->Printf("WARNING! World::SetLightStyle: style too long (%i).\n", length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: code mismatch
|
||||||
|
// Original code:
|
||||||
|
// Q_strncopy(..., 64);
|
||||||
|
// ...[63] = '\0';
|
||||||
|
// Current code:
|
||||||
|
// Q_strncopy(..., 64);
|
||||||
|
// ...[64] = '\0';
|
||||||
Q_strlcpy(m_Lightstyles[index], style);
|
Q_strlcpy(m_Lightstyles[index], style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,6 +251,7 @@ protected:
|
|||||||
entity_state_t m_Instanced_BaseLines[MAX_INSTANCED_BASELINES];
|
entity_state_t m_Instanced_BaseLines[MAX_INSTANCED_BASELINES];
|
||||||
|
|
||||||
int m_MaxInstanced_BaseLine;
|
int m_MaxInstanced_BaseLine;
|
||||||
|
// TODO: wtf, why 65? here should be 64
|
||||||
char m_Lightstyles[MAX_LIGHTSTYLES][65];
|
char m_Lightstyles[MAX_LIGHTSTYLES][65];
|
||||||
|
|
||||||
movevars_t m_MoveVars;
|
movevars_t m_MoveVars;
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#define MAX_LIGHTSTYLE_INDEX_BITS 6
|
#define MAX_LIGHTSTYLE_INDEX_BITS 6
|
||||||
#define MAX_LIGHTSTYLES (1<<MAX_LIGHTSTYLE_INDEX_BITS)
|
#define MAX_LIGHTSTYLES (1<<MAX_LIGHTSTYLE_INDEX_BITS)
|
||||||
|
constexpr auto MAX_LIGHTSTYLE_SIZE = size_t{64};
|
||||||
|
|
||||||
// Resource counts
|
// Resource counts
|
||||||
#define MAX_MODEL_INDEX_BITS 9 // sent as a short
|
#define MAX_MODEL_INDEX_BITS 9 // sent as a short
|
||||||
|
@ -1636,8 +1636,7 @@ SAVERESTOREDATA *SaveGamestate(void)
|
|||||||
if (g_psv.lightstyles[i])
|
if (g_psv.lightstyles[i])
|
||||||
{
|
{
|
||||||
light.index = i;
|
light.index = i;
|
||||||
Q_strncpy(light.style, g_psv.lightstyles[i], 63);
|
Q_strlcpy(light.style, g_psv.lightstyles[i]);
|
||||||
light.style[63] = 0;
|
|
||||||
gEntityInterface.pfnSaveWriteFields(pSaveData, "LIGHTSTYLE", &light, gLightstyleDescription, ARRAYSIZE(gLightstyleDescription));
|
gEntityInterface.pfnSaveWriteFields(pSaveData, "LIGHTSTYLE", &light, gLightstyleDescription, ARRAYSIZE(gLightstyleDescription));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1844,10 +1843,15 @@ void ParseSaveTables(SAVERESTOREDATA *pSaveData, SAVE_HEADER *pHeader, int updat
|
|||||||
gEntityInterface.pfnSaveReadFields(pSaveData, "LIGHTSTYLE", &light, gLightstyleDescription, ARRAYSIZE(gLightstyleDescription));
|
gEntityInterface.pfnSaveReadFields(pSaveData, "LIGHTSTYLE", &light, gLightstyleDescription, ARRAYSIZE(gLightstyleDescription));
|
||||||
if (updateGlobals)
|
if (updateGlobals)
|
||||||
{
|
{
|
||||||
|
#ifdef REHLDS_FIXES
|
||||||
|
Q_strlcpy(g_rehlds_sv.lightstyleBuffers[light.index], light.style);
|
||||||
|
g_psv.lightstyles[light.index] = g_rehlds_sv.lightstyleBuffers[light.index];
|
||||||
|
#else // REHLDS_FIXES
|
||||||
char *val = (char *)Hunk_Alloc(Q_strlen(light.style) + 1);
|
char *val = (char *)Hunk_Alloc(Q_strlen(light.style) + 1);
|
||||||
Q_strncpy(val, light.style, 3);
|
Q_strncpy(val, light.style, ARRAYSIZE(val) - 1);
|
||||||
val[3] = 0;
|
val[ARRAYSIZE(val) - 1] = '\0';
|
||||||
g_psv.lightstyles[light.index] = val;
|
g_psv.lightstyles[light.index] = val;
|
||||||
|
#endif // REHLDS_FIXES
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ typedef struct SAVE_HEADER_s
|
|||||||
typedef struct SAVELIGHTSTYLE_s
|
typedef struct SAVELIGHTSTYLE_s
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
char style[64];
|
char style[MAX_LIGHTSTYLE_SIZE];
|
||||||
} SAVELIGHTSTYLE;
|
} SAVELIGHTSTYLE;
|
||||||
|
|
||||||
typedef struct TITLECOMMENT_s
|
typedef struct TITLECOMMENT_s
|
||||||
|
@ -1711,7 +1711,12 @@ int EXT_FUNC PF_DecalIndex(const char *name)
|
|||||||
|
|
||||||
void EXT_FUNC PF_lightstyle_I(int style, const char *val)
|
void EXT_FUNC PF_lightstyle_I(int style, const char *val)
|
||||||
{
|
{
|
||||||
|
#ifdef REHLDS_FIXES
|
||||||
|
Q_strlcpy(g_rehlds_sv.lightstyleBuffers[style], val);
|
||||||
|
g_psv.lightstyles[style] = g_rehlds_sv.lightstyleBuffers[style];
|
||||||
|
#else // REHLDS_FIXES
|
||||||
g_psv.lightstyles[style] = val;
|
g_psv.lightstyles[style] = val;
|
||||||
|
#endif // REHLDS_FIXES
|
||||||
if (g_psv.state != ss_active)
|
if (g_psv.state != ss_active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -170,6 +170,8 @@ struct rehlds_server_t {
|
|||||||
resource_t resources[RESOURCE_MAX_COUNT];
|
resource_t resources[RESOURCE_MAX_COUNT];
|
||||||
char precachedGenericResourceNames[RESOURCE_MAX_COUNT][MAX_QPATH];
|
char precachedGenericResourceNames[RESOURCE_MAX_COUNT][MAX_QPATH];
|
||||||
size_t precachedGenericResourceCount;
|
size_t precachedGenericResourceCount;
|
||||||
|
|
||||||
|
char lightstyleBuffers[MAX_LIGHTSTYLES][MAX_LIGHTSTYLE_SIZE];
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user