Client: Added Entities_RendererRestarted, giving entity classes a chance

to reload their assets. env_glow and prop_rope support in this commit.
This commit is contained in:
Marco Cawthorne 2021-06-27 09:55:48 +02:00
parent 9cb23f381b
commit 88e5084f38
6 changed files with 54 additions and 10 deletions

View file

@ -78,3 +78,12 @@ Entities_ParseLump(void)
return (0);
}
void
Entities_RendererRestarted(void)
{
for (entity b = world; (b = findfloat(b, ::isCSQC, TRUE));) {
CBaseEntity pf = (CBaseEntity) b;
pf.RendererRestarted();
}
}

View file

@ -138,6 +138,7 @@ CSQC_RendererRestarted(string rstr)
Decal_Reload();
FX_Init();
Sky_Update(TRUE);
Entities_RendererRestarted();
}
/* this is so that profile_csqc reports more accurate statistics as to

View file

@ -39,8 +39,22 @@ class env_glow:CBaseEntity
void(void) env_glow;
virtual float() predraw;
virtual void(string, string) SpawnKey;
virtual void(void) RendererRestarted;
};
void
env_glow::RendererRestarted(void)
{
if (!model && m_strSprite) {
precache_pic(m_strSprite);
m_vecSize = drawgetimagesize(m_strSprite) / 2;
} else {
precache_model(model);
m_strSprite = spriteframe(model, 0, 0.0f);
m_vecSize = drawgetimagesize(m_strSprite) / 2;
}
}
float
env_glow::predraw(void)
{
@ -52,8 +66,12 @@ env_glow::predraw(void)
pSeat = &g_seats[s];
vecPlayer = pSeat->m_vecPredictedOrigin;
#warning "FTE broke this completely, in Half-Life BSP, partially in Q3 BSP, consult engine guru"
/* FIXME: READ ABOVE WARNING */
#if 0
if (checkpvs(vecPlayer, this) == FALSE)
return (PREDRAW_NEXT);
#endif
other = world;
traceline(this.origin, vecPlayer, MOVE_OTHERONLY, this);
@ -121,15 +139,12 @@ env_glow::SpawnKey(string strField, string strKey)
switch (strField) {
case "material":
case "shader":
model = __NULL__;
m_strSprite = strKey;
precache_pic(m_strSprite);
m_vecSize = drawgetimagesize(m_strSprite) / 2;
break;
case "sprite":
case "model":
precache_model(strKey);
m_strSprite = sprintf("%s_0.tga", strKey);
m_vecSize = drawgetimagesize(m_strSprite) / 2;
model = strKey;
break;
case "scale":
m_flScale = stof(strKey);
@ -160,4 +175,5 @@ env_glow::env_glow(void)
setorigin(this, origin);
effects &= ~EF_NOSHADOW;
Init();
RendererRestarted();
}

View file

@ -47,6 +47,7 @@ class prop_rope:CBaseEntity
void(void) prop_rope;
virtual float() predraw;
virtual void(string, string) SpawnKey;
virtual void(void) RendererRestarted;
#ifndef ROPE_RIBBON
virtual void(vector, vector, int) draw_segment;
@ -54,7 +55,8 @@ class prop_rope:CBaseEntity
};
#ifndef ROPE_RIBBON
void prop_rope::draw_segment(vector start, vector end, int flip)
void
prop_rope::draw_segment(vector start, vector end, int flip)
{
vector fsize = [2,2];
vector lit1 = /*[0.1,0.1,0.1] */ getlight(start) / 255;
@ -105,7 +107,8 @@ void prop_rope::draw_segment(vector start, vector end, int flip)
}
#endif
float prop_rope::predraw(void)
float
prop_rope::predraw(void)
{
vector pos1;
vector pos2;
@ -205,7 +208,8 @@ float prop_rope::predraw(void)
return (PREDRAW_NEXT);
}
void prop_rope::SpawnKey(string strField, string strKey)
void
prop_rope::SpawnKey(string strField, string strKey)
{
switch (strField) {
case "sag":
@ -216,7 +220,6 @@ void prop_rope::SpawnKey(string strField, string strKey)
break;
case "shader":
m_strShader = strKey;
precache_pic(m_strShader);
break;
case "swingfactor":
m_flSwingFactor = stof(strKey);
@ -226,7 +229,14 @@ void prop_rope::SpawnKey(string strField, string strKey)
}
}
void prop_rope::prop_rope(void)
void
prop_rope::RendererRestarted(void)
{
precache_pic(m_strShader);
}
void
prop_rope::prop_rope(void)
{
m_flSwingFactor = random();
m_flSag = 15.0f;
@ -234,4 +244,5 @@ void prop_rope::prop_rope(void)
m_strShader = "textures/props/wire_default";
drawmask = MASK_ENGINE;
Init();
RendererRestarted();
}

View file

@ -37,6 +37,7 @@ class CBaseEntity
virtual float(void) predraw;
virtual void(void) postdraw;
virtual void(void) MakeStatic;
virtual void(void) RendererRestarted;
#endif
#ifdef SERVER

View file

@ -23,6 +23,12 @@ string __fullspawndata;
string Sentences_GetSamples(string);
string Sentences_ProcessSample(string);
void
CBaseEntity::RendererRestarted(void)
{
};
#ifdef GS_RENDERFX
void
CBaseEntity::RenderFXPass(void)