From 9d5448e162121ee6360d68cacd85d101d000d7e3 Mon Sep 17 00:00:00 2001 From: richard Date: Fri, 4 Dec 2009 00:44:46 +0100 Subject: [PATCH] Cleaned up model precaching. --- src/zr/models.inc | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/zr/models.inc b/src/zr/models.inc index 5bfa7ff..ebc79ae 100644 --- a/src/zr/models.inc +++ b/src/zr/models.inc @@ -207,11 +207,7 @@ ModelsLoad() strcopy(buffer, sizeof(buffer), path); Format(buffer, sizeof(buffer), "%s%s", buffer, file); - // Precache model file and add to downloads table. - PrecacheModel(buffer, true); AddFileToDownloadsTable(buffer); - - // Increment file counter for the current model. downloadCount++; } @@ -224,7 +220,6 @@ ModelsLoad() } else { - // Increment model counter. ModelCount++; } } while (KvGotoNextKey(kvModels)); @@ -237,6 +232,9 @@ ModelsLoad() LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Models, "Config Validation", "Missing public model in \"%s\". There must be at least one public model.", modelPath); } + // Precache models. + ModelsPrecache(); + // Log model validation info. LogEvent(false, LogType_Normal, LOG_CORE_EVENTS, LogModule_Models, "Config Validation", "Successful: %d | Unsuccessful: %d", ModelCount, failedCount); @@ -254,6 +252,21 @@ public ModelsOnConfigReload(ConfigFile:config) ModelsLoad(); } +/** + * Precaches all models. + */ +ModelsPrecache() +{ + decl String:file[PLATFORM_MAX_PATH]; + + // Loop through all models, build full path and cache them. + for (new model = 0; model < ModelCount; model++) + { + ModelsGetFullPath(model, file, sizeof(file)); + PrecacheModel(file); + } +} + /** * Returns a random model index according to the specified filter settings. *