14 for(
size_t i = 0; i < s.size(); ++i)
if(s[i] >=
'A' && s[i] <=
'Z') s[i] = (char)(s[i] -
'A' +
'a');
21 size_t lSlash = asPath.find_last_of(
"/\\");
22 std::string s = lSlash == std::string::npos ? asPath : asPath.substr(lSlash + 1);
24 if(s.size() < 4 || s.compare(s.size() - 4, 4,
".map") != 0) s +=
".map";
30 for(
size_t i = 0; i < avList.size(); ++i)
if(avList[i] == asX)
return;
31 avList.push_back(asX);
35inline std::vector<std::string>
LuxPreloadNextMaps(
const std::string& asScript,
const std::string& asMapXml,
const std::string& asCurrentMap)
37 std::vector<std::string> vOut;
39 const char* vKeys[2] = {
"ChangeMap(\"",
"Name=\"MapFile\" Value=\"" };
40 const std::string* vTexts[2] = { &asScript, &asMapXml };
41 for(
int k = 0; k < 2; ++k)
43 const std::string& s = *vTexts[k];
44 std::string sKey = vKeys[k];
45 for(
size_t i = s.find(sKey); i != std::string::npos; i = s.find(sKey, i + 1))
47 size_t a = i + sKey.size(), b = s.find(
'"', a);
48 if(b == std::string::npos || b == a)
continue;
59 std::vector<std::string> vOut;
60 std::string sKey =
"<File Id=\"";
61 for(
size_t i = asMapXml.find(sKey); i != std::string::npos; i = asMapXml.find(sKey, i + 1))
63 size_t p = asMapXml.find(
"Path=\"", i);
64 size_t lEnd = asMapXml.find(
'>', i);
65 if(p == std::string::npos || p > lEnd)
continue;
67 size_t q = asMapXml.find(
'"', p);
68 if(q == std::string::npos)
continue;
69 std::string sPath = asMapXml.substr(p, q - p);
70 size_t lSlash = sPath.find_last_of(
"/\\");
71 if(lSlash == std::string::npos)
continue;
81 const char* vExt[] = {
".msh",
".mat",
".dds",
".ent",
".anm",
".tga",
".png",
".jpg" };
82 for(
int i = 0; i < 8; ++i)
84 size_t n = std::string(vExt[i]).size();
85 if(s.size() > n && s.compare(s.size() - n, n, vExt[i]) == 0)
return true;
std::string LuxPreloadMapName(const std::string &asPath)
"E:/svn/maps/02_Mansion_02" -> "02_mansion_02.map"
std::vector< std::string > LuxPreloadNextMaps(const std::string &asScript, const std::string &asMapXml, const std::string &asCurrentMap)
Maps reachable from here: the script's ChangeMap("...") calls and level doors' MapFile values.
std::string LuxPreloadLower(std::string s)
void LuxPreloadAddUnique(std::vector< std::string > &avList, const std::string &asX)
bool LuxPreloadWanted(const std::string &asFile)
Files worth warming in those folders (models, materials, textures, entity and animation data).
std::vector< std::string > LuxPreloadIndexFolders(const std::string &asMapXml)
Folders of the files a map uses (its FileIndex: static objects, entities, decals),...