From e7ece41ba06056f665f9cbaef5aecb1c0007c073 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 19 May 2023 08:04:22 +0300 Subject: [PATCH] engine: common: move model cvars to static allocation --- engine/common/mod_bmodel.c | 2 +- engine/common/mod_local.h | 6 +++--- engine/common/mod_studio.c | 4 ++-- engine/common/model.c | 14 +++++++------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/engine/common/mod_bmodel.c b/engine/common/mod_bmodel.c index 8c63462c..34276857 100644 --- a/engine/common/mod_bmodel.c +++ b/engine/common/mod_bmodel.c @@ -2051,7 +2051,7 @@ static void Mod_LoadTextureData( dbspmodel_t *bmod, int textureIndex ) // 2. Internal from map // Try WAD texture (force while r_wadtextures is 1) - if(( r_wadtextures->value && bmod->wadlist.count > 0 ) || mipTex->offsets[0] <= 0 ) + if(( r_wadtextures.value && bmod->wadlist.count > 0 ) || mipTex->offsets[0] <= 0 ) { char texpath[MAX_VA_STRING]; int wadIndex = Mod_FindTextureInWadList( &bmod->wadlist, mipTex->name, texpath, sizeof( texpath )); diff --git a/engine/common/mod_local.h b/engine/common/mod_local.h index f02d5a0d..40a34ce4 100644 --- a/engine/common/mod_local.h +++ b/engine/common/mod_local.h @@ -119,9 +119,9 @@ typedef struct world_static_s extern world_static_t world; extern poolhandle_t com_studiocache; extern model_t *loadmodel; -extern convar_t *mod_studiocache; -extern convar_t *r_wadtextures; -extern convar_t *r_showhull; +extern convar_t mod_studiocache; +extern convar_t r_wadtextures; +extern convar_t r_showhull; // // model.c diff --git a/engine/common/mod_studio.c b/engine/common/mod_studio.c index 4886fd33..21f0e2db 100644 --- a/engine/common/mod_studio.c +++ b/engine/common/mod_studio.c @@ -239,7 +239,7 @@ hull_t *Mod_HullForStudio( model_t *model, float frame, int sequence, vec3_t ang bSkipShield = false; *numhitboxes = 0; // assume error - if( mod_studiocache->value ) + if( mod_studiocache.value ) { bonecache = Mod_CheckStudioCache( model, frame, sequence, angles, origin, size, pcontroller, pblending ); @@ -286,7 +286,7 @@ hull_t *Mod_HullForStudio( model_t *model, float frame, int sequence, vec3_t ang // tell trace code about hitbox count *numhitboxes = (bSkipShield) ? (mod_studiohdr->numhitboxes - 1) : (mod_studiohdr->numhitboxes); - if( mod_studiocache->value ) + if( mod_studiocache.value ) Mod_AddToStudioCache( frame, sequence, angles, origin, size, pcontroller, pblending, model, studio_hull, *numhitboxes ); return studio_hull; diff --git a/engine/common/model.c b/engine/common/model.c index ad8e80ca..9b5f02d5 100644 --- a/engine/common/model.c +++ b/engine/common/model.c @@ -28,9 +28,9 @@ static model_info_t mod_crcinfo[MAX_MODELS]; static model_t mod_known[MAX_MODELS]; static int mod_numknown = 0; poolhandle_t com_studiocache; // cache for submodels -convar_t *mod_studiocache; -convar_t *r_wadtextures; -convar_t *r_showhull; +CVAR_DEFINE( mod_studiocache, "r_studiocache", "1", FCVAR_ARCHIVE, "enables studio cache for speedup tracing hitboxes" ); +CVAR_DEFINE_AUTO( r_wadtextures, "0", 0, "completely ignore textures in the bsp-file if enabled" ); +CVAR_DEFINE_AUTO( r_showhull, "0", 0, "draw collision hulls 1-3" ); model_t *loadmodel; /* @@ -134,9 +134,9 @@ Mod_Init void Mod_Init( void ) { com_studiocache = Mem_AllocPool( "Studio Cache" ); - mod_studiocache = Cvar_Get( "r_studiocache", "1", FCVAR_ARCHIVE, "enables studio cache for speedup tracing hitboxes" ); - r_wadtextures = Cvar_Get( "r_wadtextures", "0", 0, "completely ignore textures in the bsp-file if enabled" ); - r_showhull = Cvar_Get( "r_showhull", "0", 0, "draw collision hulls 1-3" ); + Cvar_RegisterVariable( &mod_studiocache ); + Cvar_RegisterVariable( &r_wadtextures ); + Cvar_RegisterVariable( &r_showhull ); Cmd_AddCommand( "mapstats", Mod_PrintWorldStats_f, "show stats for currently loaded map" ); Cmd_AddCommand( "modellist", Mod_Modellist_f, "display loaded models list" ); @@ -403,7 +403,7 @@ static void Mod_PurgeStudioCache( void ) int i; // refresh hull data - SetBits( r_showhull->flags, FCVAR_CHANGED ); + SetBits( r_showhull.flags, FCVAR_CHANGED ); #if !XASH_DEDICATED Mod_ReleaseHullPolygons(); #endif