r5sdk/r5dev/engine/gl_model_private.h
Kawe Mazidjatari 3cb4976c23 Start or 'mdl/error.rmdl' fallback implementation (see description)
In 'datacache/mdlcache.cpp' the function 'CMDLCache::FindMDL' attempts to find 'mdl/error.rmdl' and assigns the studiohdr and handle to the members of CMDLFallback.

In 'CMDLCache::FindUncachedMDL' we check if a model exists, if a model does not exist, we replace the studiohdr with the one of error.rmdl we stored in the CMDLFallback structure.

This does actually work (on the dedicated server it doesn't crash at all!), but on the client it crashes when trying to gather props (right before rendering), setting the ConVar* 'old_gather_props' does interesting things (check IDA around this ConVar*). setting this to 1 causes it to crash in another CMDLCache method when trying to deref something in the global cache pool.

This method is easy to rebuild. I will do this soon and attempt to return error.rmdl parts from here as well if results are null (this might actually just work).

Leaving 'old_gather_props' to 0 causes it to crash in the middle of the function which is supposed to gather the props the 'new' way.

The gather props functions are kind of daunting

NOTE: Currently only confirmed to work somewhat properly on the dedicated server for prop_static. prop_dynamic is unconfirmed. And (almost?) works on the client.
2022-04-29 05:30:06 +02:00

69 lines
1.7 KiB
C

//=============================================================================//
//
// Purpose:
//
// $Workfile: $
// $Date: $
// $NoKeywords: $
//=============================================================================//
#include "vpc/keyvalues.h"
#include "mathlib/vector.h"
#include "common/qlimits.h"
#include "datacache/imdlcache.h"
#include "public/include/model_types.h"
#ifndef DEDICATED
#include "game/client/enginesprite.h"
#endif // !DEDICATED
typedef int FileNameHandle_t; // 4 bytes in r5, void* originally.
struct brushdata_t // !! UNCONFIRMED !!
{
void* pShared; // worldbrushdata_t
int firstmodelsurface;
int nummodelsurfaces;
// track the union of all lightstyles on this brush. That way we can avoid
// searching all faces if the lightstyle hasn't changed since the last update
int nLightstyleLastComputedFrame;
unsigned short nLightstyleIndex; // g_ModelLoader actually holds the allocated data here
unsigned short nLightstyleCount;
unsigned short renderHandle;
unsigned short firstnode;
};
#ifndef DEDICATED
struct spritedata_t // !! UNCONFIRMED !!
{
int numframes;
int width;
int height;
CEngineSprite* sprite;
};
#endif // !DEDICATED
struct model_t // !! CONFIRMED !!
{
FileNameHandle_t fnHandle;
char szPathName[MAX_OSPATH];
int nLoadFlags; // mark loaded/not loaded
int nServerCount; // marked at load
modtype_t type;
int flags; // MODELFLAG_???
// volume occupied by the model graphics
Vector3 mins, maxs;
float radius;
KeyValues* m_pKeyValues;
union
{
brushdata_t brush;
MDLHandle_t studio;
#ifndef DEDICATED
spritedata_t sprite;
#endif // !DEDICATED
};
};