diff --git a/GSChaos/CChaosFeature.cpp b/GSChaos/CChaosFeature.cpp index 91e11e6a..068436fc 100644 --- a/GSChaos/CChaosFeature.cpp +++ b/GSChaos/CChaosFeature.cpp @@ -120,6 +120,11 @@ void CChaosFeature::V_CalcRefdef(struct ref_params_s* pparams) ; } +void CChaosFeature::VidInit() +{ + ; +} + bool CChaosFeature::IsActive() { return m_bActivated; diff --git a/GSChaos/CChaosFeature.h b/GSChaos/CChaosFeature.h index 914a34b3..5d04ba05 100644 --- a/GSChaos/CChaosFeature.h +++ b/GSChaos/CChaosFeature.h @@ -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(); diff --git a/GSChaos/CFeatureNightvision.cpp b/GSChaos/CFeatureNightvision.cpp index 7fa6ebf4..14372243 100644 --- a/GSChaos/CFeatureNightvision.cpp +++ b/GSChaos/CFeatureNightvision.cpp @@ -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"; diff --git a/GSChaos/CFeatureNightvision.h b/GSChaos/CFeatureNightvision.h index 24f55787..be9437b7 100644 --- a/GSChaos/CFeatureNightvision.h +++ b/GSChaos/CFeatureNightvision.h @@ -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; diff --git a/GSChaos/GSChaos.cpp b/GSChaos/GSChaos.cpp index 0f316bc1..976baa8f 100644 --- a/GSChaos/GSChaos.cpp +++ b/GSChaos/GSChaos.cpp @@ -17,6 +17,7 @@ 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); @@ -24,6 +25,7 @@ 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; @@ -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; @@ -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);