X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=model_shared.c;h=1edb3fb44504470b95c0e976a8eb59beebb65d3b;hb=14bec1a4c2a0623c08d1e746a023971e311fda36;hp=ad05c4e496f1b6ab1947df4f7270371b56730081;hpb=44813e1c46f6da8f446bafe7d72ba0084aec0f17;p=xonotic%2Fdarkplaces.git diff --git a/model_shared.c b/model_shared.c index ad05c4e4..1edb3fb4 100644 --- a/model_shared.c +++ b/model_shared.c @@ -154,8 +154,16 @@ model_t *Mod_LoadModel(model_t *mod, qboolean crash, qboolean checkdisk, qboolea crc = 0; buf = NULL; + + // even if the model is loaded it still may need reloading... + + // if the model is a worldmodel and is being referred to as a + // non-worldmodel here, then it needs reloading to get rid of the + // submodels if (mod->isworldmodel != isworldmodel) mod->loaded = false; + + // if it is not loaded or checkdisk is true we need to calculate the crc if (!mod->loaded || checkdisk) { if (checkdisk && mod->loaded) @@ -164,13 +172,15 @@ model_t *Mod_LoadModel(model_t *mod, qboolean crash, qboolean checkdisk, qboolea if (buf) { crc = CRC_Block((unsigned char *)buf, filesize); + // we need to reload the model if the crc does not match if (mod->crc != crc) mod->loaded = false; } } + + // if the model is already loaded and checks passed, just return if (mod->loaded) { - // already loaded if (buf) Mem_Free(buf); return mod; @@ -381,7 +391,7 @@ static void Mod_Print(void) Con_Print("Loaded models:\n"); for (i = 0, mod = mod_known;i < mod_numknown;i++, mod++) if (mod->name[0]) - Con_Printf("%4iK %s\n", mod->mempool ? (mod->mempool->totalsize + 1023) / 1024 : 0, mod->name); + Con_Printf("%4iK %s\n", mod->mempool ? (int)((mod->mempool->totalsize + 1023) / 1024) : 0, mod->name); } /* @@ -990,6 +1000,7 @@ int Mod_LoadSkinFrame(skinframe_t *skinframe, const char *basename, int texturef { imageskin_t s; memset(skinframe, 0, sizeof(*skinframe)); + skinframe->base = r_texture_notexture; if (cls.state == ca_dedicated) return false; if (!image_loadskin(&s, basename))