Skip to content

Commit

Permalink
Fixed Maxwell World cat model not rotating properly or at all.
Browse files Browse the repository at this point in the history
  • Loading branch information
StereoBucket committed Nov 30, 2024
1 parent d3ac829 commit 70f38f9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
17 changes: 14 additions & 3 deletions GSChaos/CFeatureMaxwell.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
Expand Down Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions GSChaos/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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--)
{
Expand Down
2 changes: 1 addition & 1 deletion GSChaos/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Binary file modified gamedir/chaos/maxwell/dingus.mdl
Binary file not shown.

0 comments on commit 70f38f9

Please sign in to comment.