mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-07 10:28:26 +00:00
move some more things into maps-folder-stocks.inc
This commit is contained in:
parent
76988a509b
commit
1946de926b
@ -35,22 +35,22 @@ stock bool WriteNavMesh(const char[] map, bool skipExistsCheck = false)
|
||||
if (file != null)
|
||||
{
|
||||
static int defaultNavMesh[205] = {
|
||||
0xCE, 0xFA, 0xED, 0xFE, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x58, 0xF6, 0x01, 0x00,
|
||||
0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x80, 0xED, 0xC3, 0x00, 0x00, 0x48, 0x42, 0xFF, 0x1F, 0x00, 0x42, 0x00, 0x00, 0x48, 0xC2,
|
||||
0x00, 0x80, 0xED, 0x43, 0xFF, 0x1F, 0x00, 0x42, 0xFF, 0x1F, 0x00, 0x42, 0xFF, 0x1F, 0x00, 0x42,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xE7, 0xC3, 0x00, 0x00, 0x7A, 0x42, 0xFF, 0x1F, 0x00,
|
||||
0x42, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7A, 0xC2, 0x00, 0x00, 0x7A, 0x42, 0xFF, 0x1F,
|
||||
0x00, 0x42, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7A, 0xC2, 0x00, 0x40, 0xE7, 0x43, 0xFF,
|
||||
0x1F, 0x00, 0x42, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x40, 0xE7, 0xC3, 0x00, 0x40, 0xE7, 0x43,
|
||||
0xFF, 0x1F, 0x00, 0x42, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x42, 0x00, 0x00, 0xF0, 0x42, 0x00, 0x00, 0x80, 0x3F, 0x00,
|
||||
0x00, 0x80, 0x3F, 0x00, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x80, 0x3F, 0x01, 0x00, 0x00, 0x00, 0x01,
|
||||
0xCE, 0xFA, 0xED, 0xFE, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x58, 0xF6, 0x01, 0x00,
|
||||
0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x80, 0xED, 0xC3, 0x00, 0x00, 0x48, 0x42, 0xFF, 0x1F, 0x00, 0x42, 0x00, 0x00, 0x48, 0xC2,
|
||||
0x00, 0x80, 0xED, 0x43, 0xFF, 0x1F, 0x00, 0x42, 0xFF, 0x1F, 0x00, 0x42, 0xFF, 0x1F, 0x00, 0x42,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xE7, 0xC3, 0x00, 0x00, 0x7A, 0x42, 0xFF, 0x1F, 0x00,
|
||||
0x42, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7A, 0xC2, 0x00, 0x00, 0x7A, 0x42, 0xFF, 0x1F,
|
||||
0x00, 0x42, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7A, 0xC2, 0x00, 0x40, 0xE7, 0x43, 0xFF,
|
||||
0x1F, 0x00, 0x42, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x40, 0xE7, 0xC3, 0x00, 0x40, 0xE7, 0x43,
|
||||
0xFF, 0x1F, 0x00, 0x42, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x42, 0x00, 0x00, 0xF0, 0x42, 0x00, 0x00, 0x80, 0x3F, 0x00,
|
||||
0x00, 0x80, 0x3F, 0x00, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x80, 0x3F, 0x01, 0x00, 0x00, 0x00, 0x01,
|
||||
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
file.Write(defaultNavMesh, 205, 1);
|
||||
file.Write(defaultNavMesh, sizeof(defaultNavMesh), 1);
|
||||
delete file;
|
||||
}
|
||||
|
||||
@ -60,6 +60,103 @@ stock bool WriteNavMesh(const char[] map, bool skipExistsCheck = false)
|
||||
return false;
|
||||
}
|
||||
|
||||
stock bool WriteNavMeshBz2(const char[] map, bool skipExistsCheck = false)
|
||||
{
|
||||
char sTempMap[PLATFORM_MAX_PATH];
|
||||
FormatEx(sTempMap, PLATFORM_MAX_PATH, "maps/%s.nav.bz2", map);
|
||||
|
||||
if (skipExistsCheck || !FileExists(sTempMap))
|
||||
{
|
||||
File file = OpenFile(sTempMap, "wb");
|
||||
|
||||
if (file != null)
|
||||
{
|
||||
static int defaultNavMeshBz2[132/4] = {
|
||||
0x39685A42, 0x26594131, 0xB8955953, 0x0000B354,
|
||||
0xFEC56E4E, 0x80004004, 0x0040D800, 0x40100040,
|
||||
0x00011800, 0xA0114182, 0xA7127200, 0x915133AA,
|
||||
0x04B501A0, 0x64A03285, 0x31190D0D, 0x96F2A658,
|
||||
0x864651CE, 0xA93468D3, 0xD269C634, 0x66EE82B6,
|
||||
0x3B1D4103, 0xD4BE309C, 0x58DF5463, 0xC0076E1B,
|
||||
0x346C6DC1, 0x8B9FD47B, 0x0385015D, 0x3B260D99,
|
||||
0xF43C28F0, 0xD071CFB3, 0xC95DFC92, 0x4242E114,
|
||||
0xCC52E156
|
||||
};
|
||||
|
||||
file.Write(defaultNavMeshBz2, sizeof(defaultNavMeshBz2), 4);
|
||||
delete file;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
stock void CreateAllNavFiles()
|
||||
{
|
||||
StringMap mapList = new StringMap();
|
||||
DirectoryListing dir = OpenDirectory("maps", true);
|
||||
|
||||
if (dir == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char fileName[PLATFORM_MAX_PATH];
|
||||
FileType type;
|
||||
|
||||
// Loop through maps folder.
|
||||
// If .bsp, mark as need .nav
|
||||
// If .nav, mark as have .nav
|
||||
while (dir.GetNext(fileName, sizeof(fileName), type))
|
||||
{
|
||||
if (type != FileType_File)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int length = strlen(fileName);
|
||||
|
||||
if (length < 5 || fileName[length-4] != '.') // a.bsp
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fileName[length-3] == 'b' && fileName[length-2] == 's' && fileName[length-1] == 'p')
|
||||
{
|
||||
fileName[length-4] = 0;
|
||||
mapList.SetValue(fileName, false, false); // note: false for 'replace'
|
||||
}
|
||||
else if (fileName[length-3] == 'n' && fileName[length-2] == 'a' && fileName[length-1] == 'v')
|
||||
{
|
||||
fileName[length-4] = 0;
|
||||
mapList.SetValue(fileName, true, true); // note: true for 'replace'
|
||||
}
|
||||
}
|
||||
|
||||
delete dir;
|
||||
|
||||
// StringMap shenanigans are used so we don't call FileExists() 2000 times
|
||||
StringMapSnapshot snapshot = mapList.Snapshot();
|
||||
|
||||
for (int i = 0; i < snapshot.Length; i++)
|
||||
{
|
||||
snapshot.GetKey(i, fileName, sizeof(fileName));
|
||||
|
||||
bool hasNAV = false;
|
||||
mapList.GetValue(fileName, hasNAV);
|
||||
|
||||
if (!hasNAV)
|
||||
{
|
||||
WriteNavMesh(fileName, true);
|
||||
}
|
||||
}
|
||||
|
||||
delete snapshot;
|
||||
delete mapList;
|
||||
}
|
||||
|
||||
stock bool ReadMapsFolderHandler(const char path[PLATFORM_MAX_PATH], bool is_stringmap, Handle data, bool lowercase, bool display, bool iter_subfolders, bool use_valve_fs, char[][] exclude_prefixes, int exclude_count)
|
||||
{
|
||||
bool first_iteration = StrEqual(path, "maps");
|
||||
|
||||
@ -1505,70 +1505,6 @@ bool LoadStyling()
|
||||
return true;
|
||||
}
|
||||
|
||||
void CreateAllNavFiles()
|
||||
{
|
||||
StringMap mapList = new StringMap();
|
||||
DirectoryListing dir = OpenDirectory("maps", true);
|
||||
|
||||
if (dir == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char fileName[PLATFORM_MAX_PATH];
|
||||
FileType type;
|
||||
|
||||
// Loop through maps folder.
|
||||
// If .bsp, mark as need .nav
|
||||
// If .nav, mark as have .nav
|
||||
while (dir.GetNext(fileName, sizeof(fileName), type))
|
||||
{
|
||||
if (type != FileType_File)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int length = strlen(fileName);
|
||||
|
||||
if (length < 5 || fileName[length-4] != '.') // a.bsp
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fileName[length-3] == 'b' && fileName[length-2] == 's' && fileName[length-1] == 'p')
|
||||
{
|
||||
fileName[length-4] = 0;
|
||||
mapList.SetValue(fileName, false, false); // note: false for 'replace'
|
||||
}
|
||||
else if (fileName[length-3] == 'n' && fileName[length-2] == 'a' && fileName[length-1] == 'v')
|
||||
{
|
||||
fileName[length-4] = 0;
|
||||
mapList.SetValue(fileName, true, true); // note: true for 'replace'
|
||||
}
|
||||
}
|
||||
|
||||
delete dir;
|
||||
|
||||
// StringMap shenanigans are used so we don't call FileExists() 2000 times
|
||||
StringMapSnapshot snapshot = mapList.Snapshot();
|
||||
|
||||
for (int i = 0; i < snapshot.Length; i++)
|
||||
{
|
||||
snapshot.GetKey(i, fileName, sizeof(fileName));
|
||||
|
||||
bool hasNAV = false;
|
||||
mapList.GetValue(fileName, hasNAV);
|
||||
|
||||
if (!hasNAV)
|
||||
{
|
||||
WriteNavMesh(fileName, true);
|
||||
}
|
||||
}
|
||||
|
||||
delete snapshot;
|
||||
delete mapList;
|
||||
}
|
||||
|
||||
public void OnMapStart()
|
||||
{
|
||||
if (!LoadStyling())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user