===============
*/
static void Mod_Print (void);
+static void Mod_Precache (void);
void Mod_Init (void)
{
Mod_BrushInit();
Mod_SpriteInit();
Cmd_AddCommand ("modellist", Mod_Print);
+ Cmd_AddCommand ("modelprecache", Mod_Precache);
}
void Mod_RenderInit(void)
Loads a model
==================
*/
-static model_t *Mod_LoadModel (model_t *mod, qboolean crash, qboolean checkdisk, qboolean isworldmodel)
+static model_t *Mod_LoadModel(model_t *mod, qboolean crash, qboolean checkdisk, qboolean isworldmodel)
{
+ int num;
unsigned int crc;
void *buf;
// LordHavoc: unload the existing model in this slot (if there is one)
Mod_UnloadModel(mod);
mod->isworldmodel = isworldmodel;
- mod->needload = false;
mod->used = true;
mod->crc = crc;
- // errors can prevent the corresponding mod->error = false;
- mod->error = true;
+ // errors can prevent the corresponding mod->needload = false;
+ mod->needload = true;
// all models use memory, so allocate a memory pool
mod->mempool = Mem_AllocPool(mod->name);
mod->texturepool = R_AllocTexturePool();
// call the apropriate loader
- if (!memcmp(buf, "IDPO" , 4)) Mod_LoadQ1AliasModel(mod, buf);
- else if (!memcmp(buf, "IDP2" , 4)) Mod_LoadQ2AliasModel(mod, buf);
- else if (!memcmp(buf, "IDP3" , 4)) Mod_LoadQ3AliasModel(mod, buf);
- else if (!memcmp(buf, "ZYMOTIC" , 7)) Mod_LoadZymoticModel(mod, buf);
- else if (!memcmp(buf, "IDSP" , 4)) Mod_LoadSpriteModel (mod, buf);
- else Mod_LoadBrushModel (mod, buf);
+ num = LittleLong(*((int *)buf));
+ if (!memcmp(buf, "IDPO", 4)) Mod_IDP0_Load(mod, buf);
+ else if (!memcmp(buf, "IDP2", 4)) Mod_IDP2_Load(mod, buf);
+ else if (!memcmp(buf, "IDP3", 4)) Mod_IDP3_Load(mod, buf);
+ else if (!memcmp(buf, "IDSP", 4)) Mod_IDSP_Load(mod, buf);
+ else if (!memcmp(buf, "IBSP", 4)) Mod_IBSP_Load(mod, buf);
+ else if (!memcmp(buf, "ZYMOTICMODEL", 12)) Mod_ZYMOTICMODEL_Load(mod, buf);
+ else if (strlen(mod->name) >= 4 && !strcmp(mod->name - 4, ".map")) Mod_MAP_Load(mod, buf);
+ else if (num == BSPVERSION || num == 30) Mod_Q1BSP_Load(mod, buf);
+ else Host_Error("Mod_LoadModel: model \"%s\" is of unknown/unsupported type\n", mod->name);
Mem_Free(buf);
// no errors occurred
- mod->error = false;
+ mod->needload = false;
return mod;
}
-void Mod_CheckLoaded (model_t *mod)
+void Mod_CheckLoaded(model_t *mod)
{
if (mod)
{
Mod_ClearAll
===================
*/
-void Mod_ClearAll (void)
+void Mod_ClearAll(void)
{
}
-void Mod_ClearErrorModels (void)
-{
- int i;
- model_t *mod;
-
- for (i = 0, mod = mod_known;i < MAX_MOD_KNOWN;i++, mod++)
- if (mod->error)
- Mod_FreeModel(mod);
-}
-
void Mod_ClearUsed(void)
{
int i;
==================
*/
-model_t *Mod_FindName (const char *name)
+model_t *Mod_FindName(const char *name)
{
int i;
model_t *mod, *freemod;
==================
*/
-void Mod_TouchModel (const char *name)
+void Mod_TouchModel(const char *name)
{
model_t *mod;
- mod = Mod_FindName (name);
+ mod = Mod_FindName(name);
mod->used = true;
}
Loads in a model for the given name
==================
*/
-model_t *Mod_ForName (const char *name, qboolean crash, qboolean checkdisk, qboolean isworldmodel)
+model_t *Mod_ForName(const char *name, qboolean crash, qboolean checkdisk, qboolean isworldmodel)
{
- return Mod_LoadModel (Mod_FindName (name), crash, checkdisk, isworldmodel);
+ return Mod_LoadModel(Mod_FindName(name), crash, checkdisk, isworldmodel);
}
qbyte *mod_base;
Mod_Print
================
*/
-static void Mod_Print (void)
+static void Mod_Print(void)
{
int i;
model_t *mod;
Con_Printf ("%4iK %s\n", mod->mempool ? (mod->mempool->totalsize + 1023) / 1024 : 0, mod->name);
}
+/*
+================
+Mod_Precache
+================
+*/
+static void Mod_Precache(void)
+{
+ if (Cmd_Argc() == 2)
+ Mod_ForName(Cmd_Argv(1), false, true, cl.worldmodel && !strcasecmp(Cmd_Argv(1), cl.worldmodel->name));
+ else
+ Con_Printf("usage: modelprecache <filename>\n");
+}
+
int Mod_FindTriangleWithEdge(const int *elements, int numtriangles, int start, int end, int ignore)
{
int i, match, count;
*/
}
-void Mod_ShadowMesh_AddMesh(mempool_t *mempool, shadowmesh_t *mesh, int numverts, float *verts, int numtris, int *elements)
+void Mod_ShadowMesh_AddMesh(mempool_t *mempool, shadowmesh_t *mesh, float *verts, int numtris, int *elements)
{
int i;
for (i = 0;i < numtris;i++, elements += 3)
}
static int detailtexturecycle = 0;
-int Mod_LoadSkinFrame (skinframe_t *skinframe, char *basename, int textureflags, int loadpantsandshirt, int usedetailtexture, int loadglowtexture)
+int Mod_LoadSkinFrame(skinframe_t *skinframe, char *basename, int textureflags, int loadpantsandshirt, int usedetailtexture, int loadglowtexture)
{
imageskin_t s;
memset(skinframe, 0, sizeof(*skinframe));
return true;
}
-int Mod_LoadSkinFrame_Internal (skinframe_t *skinframe, char *basename, int textureflags, int loadpantsandshirt, int usedetailtexture, int loadglowtexture, qbyte *skindata, int width, int height)
+int Mod_LoadSkinFrame_Internal(skinframe_t *skinframe, char *basename, int textureflags, int loadpantsandshirt, int usedetailtexture, int loadglowtexture, qbyte *skindata, int width, int height)
{
qbyte *temp1, *temp2;
memset(skinframe, 0, sizeof(*skinframe));