From e581d6e0937cda49a65ef6086bd9c3c94a44351f Mon Sep 17 00:00:00 2001 From: havoc Date: Sun, 21 Jan 2007 11:53:08 +0000 Subject: [PATCH] added some comments in Mod_LoadModel git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6713 d7cf8633-e32d-0410-b094-e92efae38249 --- model_shared.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/model_shared.c b/model_shared.c index a613449e..5e8d7f1d 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; -- 2.39.2