From 13c1fd09c48ab8319b3f7e01f8703ff9eebd8bfd Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Wed, 18 Feb 2009 15:08:17 +1300 Subject: [PATCH] Added custom gamedata file parsing (bug 3644, r=dvander) --- core/GameConfigs.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/core/GameConfigs.cpp b/core/GameConfigs.cpp index 54d9e665..169dcef2 100644 --- a/core/GameConfigs.cpp +++ b/core/GameConfigs.cpp @@ -747,6 +747,44 @@ bool CGameConfig::Reparse(char *error, size_t maxlength) } } + /* Parse the contents of the 'custom' directory */ + g_SourceMod.BuildPath(Path_SM, path, sizeof(path), "gamedata/%s/custom"); + IDirectory *customDir = g_LibSys.OpenDirectory(path); + + if (!customDir) + { + return true; + } + + while (customDir->MoreFiles()) + { + if (!customDir->IsEntryFile()) + { + customDir->NextEntry(); + continue; + } + + const char *curFile = customDir->GetEntryName(); + + /* Only allow .txt files */ + int len = strlen(curFile); + if (len > 4 && strcmp(curFile[len-4], ".txt") != 0) + { + customDir->NextEntry(); + continue; + } + + UTIL_Format(path, sizeof(path), "%s/custom/%s", m_File, curFile); + if (!EnterFile(path, error, maxlength)) + { + g_LibSys->CloseDirectory(customDir); + return false; + } + + customDir->NextEntry(); + } + + g_LibSys->CloseDirectory(customDir); return true; }