Skip to content

Commit

Permalink
CChaosFeature::VidInit, Nightvision crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ScriptedSnark committed Nov 15, 2024
1 parent 3cd312b commit 2202c61
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions GSChaos/CChaosFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ void CChaosFeature::V_CalcRefdef(struct ref_params_s* pparams)
;
}

void CChaosFeature::VidInit()
{
;
}

bool CChaosFeature::IsActive()
{
return m_bActivated;
Expand Down
1 change: 1 addition & 0 deletions GSChaos/CChaosFeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class CChaosFeature
virtual void PM_Move(struct playermove_s* ppmove, qboolean server);
virtual void Vote(const std::string& user, const std::string& msg);
virtual void V_CalcRefdef(struct ref_params_s* pparams);
virtual void VidInit();
virtual bool IsActive();
virtual double GetDuration();
virtual bool UseCustomDuration();
Expand Down
5 changes: 5 additions & 0 deletions GSChaos/CFeatureNightvision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ void CFeatureNightvision::Draw()
m_iFrame++;
}

void CFeatureNightvision::VidInit()
{
m_nvSprite = LoadSprite("../chaos/of_nv_b.spr");
}

const char* CFeatureNightvision::GetFeatureName()
{
return "Nightvision";
Expand Down
1 change: 1 addition & 0 deletions GSChaos/CFeatureNightvision.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class CFeatureNightvision : public CChaosFeature
void ActivateFeature() override;
void DeactivateFeature() override;
void Draw() override;
void VidInit() override;
const char* GetFeatureName() override;
double GetDuration() override;
bool UseCustomDuration() override;
Expand Down
16 changes: 16 additions & 0 deletions GSChaos/GSChaos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
typedef void (*__wassert)(wchar_t const* _Message, wchar_t const* _File, unsigned _Line);
__wassert ORIG_wassert = NULL;

typedef int (*_HUD_VidInit)(void);
typedef void (*_HUD_Frame)(double time);
typedef int (*_HUD_Redraw)(float time, int intermission);
typedef void (*_V_CalcRefdef)(struct ref_params_s* pparams);
typedef void (*_HUD_CreateEntities)(void);
typedef int (*_HUD_AddEntity)(int type, struct cl_entity_s* ent, const char* modelname);
typedef void (*_CL_CreateMove)(float frametime, struct usercmd_s* cmd, int active);

_HUD_VidInit ORIG_HUD_VidInit = NULL;
_HUD_Frame ORIG_HUD_Frame = NULL;
_HUD_Redraw ORIG_HUD_Redraw = NULL;
_V_CalcRefdef ORIG_V_CalcRefdef = NULL;
Expand Down Expand Up @@ -297,6 +299,18 @@ void DisableFog()
glDisable(GL_FOG);
}

int HOOKED_HUD_VidInit(void)
{
int res = ORIG_HUD_VidInit();

for (CChaosFeature* i : gChaosFeatures)
{
i->VidInit();
}

return res;
}

void HOOKED_HUD_Frame(double time)
{
static bool initialized = false;
Expand Down Expand Up @@ -575,11 +589,13 @@ void HookClient()

int status;

Find(Client, HUD_VidInit);
Find(Client, HUD_Frame);
Find(Client, HUD_Redraw);
Find(Client, V_CalcRefdef);
Find(Client, HUD_AddEntity);
Find(Client, CL_CreateMove);
CreateHook(Client, HUD_VidInit);
CreateHook(Client, HUD_Frame);
CreateHook(Client, HUD_Redraw);
CreateHook(Client, V_CalcRefdef);
Expand Down

0 comments on commit 2202c61

Please sign in to comment.