From 70f38f9efa9e2addf710736684392dc82185f46e Mon Sep 17 00:00:00 2001 From: StereoBucket <155476679+StereoBucket@users.noreply.github.com> Date: Sat, 30 Nov 2024 03:15:22 +0100 Subject: [PATCH] Fixed Maxwell World cat model not rotating properly or at all. --- GSChaos/CFeatureMaxwell.cpp | 17 ++++++++++++++--- GSChaos/Utils.cpp | 8 ++++---- GSChaos/Utils.h | 2 +- gamedir/chaos/maxwell/dingus.mdl | Bin 314240 -> 312360 bytes 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/GSChaos/CFeatureMaxwell.cpp b/GSChaos/CFeatureMaxwell.cpp index a1c25b3f..b1714b09 100644 --- a/GSChaos/CFeatureMaxwell.cpp +++ b/GSChaos/CFeatureMaxwell.cpp @@ -1,12 +1,15 @@ #include "includes.h" +#include "mathlib.h" #define FRAMECOUNT 86 void CFeatureMaxwell::Init() { - CChaosFeature::Init(); + //CChaosFeature::Init(); frames = new unsigned char* [FRAMECOUNT]; + if (frames == nullptr) + return; // Bit of an ugly way to load but it'll do for now. - loaded = LoadTexturesFromFiles("chaos/maxwell/maxwell", FRAMECOUNT, frames, &width, &height); + loaded = LoadTexturesFromFiles("chaos/maxwell/maxwell", FRAMECOUNT, frames, width, height); m_iMaxwellID = TEXTURE_BASEID + ++g_iTextureCounter; fps = 15; } @@ -46,8 +49,16 @@ void CFeatureMaxwell::HUD_AddEntity(int type, struct cl_entity_s* ent, const cha if (ent->model->type != mod_studio) return; - if (pEngfuncs->hudGetModelByIndex(m_iMaxwellModel)) + if (auto model = pEngfuncs->hudGetModelByIndex(m_iMaxwellModel)) + { + double time = pEngfuncs->GetAbsoluteTime(); ent->model = pEngfuncs->hudGetModelByIndex(m_iMaxwellModel); + // angle makes items rotate too but also makes curstate angle stick + ent->angles.y = anglemod(-time * 72.0) - 180.0f; + ent->curstate.angles.y = ent->angles.y; + // helps stop a small jitter when entities move and change direction. + ent->latched.prevangles.y = ent->angles.y; + } } void CFeatureMaxwell::Restore() diff --git a/GSChaos/Utils.cpp b/GSChaos/Utils.cpp index 9780cbad..b43669bf 100644 --- a/GSChaos/Utils.cpp +++ b/GSChaos/Utils.cpp @@ -421,7 +421,7 @@ bool LoadTextureFromFile(const char* filename, GLuint* out_texture) return true; } -bool LoadTexturesFromFiles(const char* base_filename, byte frames, unsigned char** image_frames, int* image_width, int* image_height) +bool LoadTexturesFromFiles(const char* base_filename, byte frames, unsigned char** image_frames, int& image_width, int& image_height) { if (frames < 1) return false; int cur_image_width = 0; @@ -437,9 +437,9 @@ bool LoadTexturesFromFiles(const char* base_filename, byte frames, unsigned char if (image_data == NULL) return false; image_frames[i] = image_data; - if (*image_width == 0) *image_width = cur_image_width; - if (*image_height == 0) *image_height = cur_image_height; - if (*image_width != cur_image_width || *image_height != cur_image_height) + if (image_width == 0) image_width = cur_image_width; + if (image_height == 0) image_height = cur_image_height; + if (image_width != cur_image_width || image_height != cur_image_height) { for (int j = 0; j > -1; j--) { diff --git a/GSChaos/Utils.h b/GSChaos/Utils.h index 041256ce..d4294496 100644 --- a/GSChaos/Utils.h +++ b/GSChaos/Utils.h @@ -76,7 +76,7 @@ void UTIL_ScreenFade(edict_t* pEntity, const Vector& color, float fadeTime, floa void UTIL_TakeDamage(entvars_t& pevInflictor, float flDamage, int bitsDamageType); void UTIL_HudMessage(edict_t* pEntity, const hudtextparms_t& textparms, const char* pMessage); bool LoadTextureFromFile(const char* filename, GLuint* out_texture); -bool LoadTexturesFromFiles(const char* base_filename, byte frames, unsigned char** image_frames, int* image_width, int* image_height); +bool LoadTexturesFromFiles(const char* base_filename, byte frames, unsigned char** image_frames, int& image_width, int& image_height); float UTIL_Hue2RGB(float p, float q, float t); Vector UTIL_HSL2RGB(Vector _HSL); float UTIL_GetScreenCoord(float flValue); diff --git a/gamedir/chaos/maxwell/dingus.mdl b/gamedir/chaos/maxwell/dingus.mdl index 82c4f4c98618f1f4bd2124f15f9d43a10f606456..66d91f66f505c9d896cc25948dc86bce19a5e35f 100644 GIT binary patch delta 543 z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