#include <common/monsters/_mod.qh>
#endif
+bool autocvar_g_mapinfo_arena_compat = true;
+
#ifdef MENUQC
#define WARN_COND false
#else
mapMins = '0 0 0';
mapMaxs = '0 0 0';
+ // try for a .arena or .defi file if no .mapinfo exists
+ bool isdefi = false;
+ string arena_fn = _MapInfo_FindArenaFile(pFilename, ".arena");
+ int arena_fh = fopen(arena_fn, FILE_READ);
+ if(arena_fh < 0)
+ {
+ isdefi = true;
+ arena_fn = _MapInfo_FindArenaFile(pFilename, ".defi");
+ arena_fh = fopen(arena_fn, FILE_READ);
+ }
+ if(arena_fh >= 0)
+ {
+ _MapInfo_ParseArena(arena_fn, arena_fh, pFilename, NULL, isdefi, true);
+ fclose(arena_fh);
+ }
+
for (;;)
{
if (!((s = fgets(fh))))
return false;
}
-bool _MapInfo_ParseArena(string arena_filename, int fh, string pFilename, Gametype pGametypeToSet, bool isdefi)
+bool _MapInfo_ParseArena(string arena_filename, int fh, string pFilename, Gametype pGametypeToSet, bool isdefi, bool isgenerator)
{
// NOTE: .arena files can hold more than 1 map's information!
// to handle this, we're going to store gathered information in local variables and save it if we encounter the correct map name
if(stored_Map_title != "")
MapInfo_Map_title = stored_Map_title;
MapInfo_Map_author = stored_Map_author;
- FOREACH(Gametypes, it.m_flags & stored_supportedGametypes,
+ if(isgenerator)
+ MapInfo_Map_supportedGametypes = stored_supportedGametypes;
+ else
{
- _MapInfo_Map_ApplyGametype ("", pGametypeToSet, it, true);
- });
+ FOREACH(Gametypes, it.m_flags & stored_supportedGametypes,
+ {
+ _MapInfo_Map_ApplyGametype ("", pGametypeToSet, it, true);
+ });
+ }
return true; // no need to continue through the file, we have our map!
}
else
#endif
string _MapInfo_FindArenaFile(string pFilename, string extension)
{
- string base_pack = whichpack(strcat("maps/", pFilename, ".bsp"));
string fallback = strcat("scripts/", pFilename, extension);
+ if(!checkextension("DP_QC_FS_SEARCH_PACKFILE"))
+ return fallback;
+ string base_pack = whichpack(strcat("maps/", pFilename, ".bsp"));
if(base_pack == "") // this map isn't packaged!
return fallback;
- int glob = search_begin(strcat("scripts/*", extension), true, true);
+ int glob = search_packfile_begin(strcat("scripts/*", extension), true, true, base_pack);
if(glob < 0)
return fallback;
int n = search_getsize(glob);
for(int j = 0; j < n; ++j)
{
string file = search_getfilename(glob, j);
- if(whichpack(file) != base_pack)
- continue; // not in the same pk3!
int fh = fopen(file, FILE_READ);
if(fh < 0)
fh = fopen(fn, FILE_READ);
if(fh < 0)
{
- bool isdefi = false;
- // try for a .arena or .defi file if no .mapinfo exists
- fn = _MapInfo_FindArenaFile(pFilename, ".arena");
- fh = fopen(fn, FILE_READ);
- if(fh < 0)
+ if(autocvar_g_mapinfo_arena_compat)
{
- isdefi = true;
- fn = _MapInfo_FindArenaFile(pFilename, ".defi");
+ // try for .arena or .defi files if no .mapinfo exists
+ bool isdefi = false;
+ fn = _MapInfo_FindArenaFile(pFilename, ".arena");
fh = fopen(fn, FILE_READ);
- }
- if(fh >= 0)
- {
- _MapInfo_Map_Reset();
- if(_MapInfo_ParseArena(fn, fh, pFilename, pGametypeToSet, isdefi))
- goto mapinfo_handled; // skip generation
+ if(fh < 0)
+ {
+ isdefi = true;
+ fn = _MapInfo_FindArenaFile(pFilename, ".defi");
+ fh = fopen(fn, FILE_READ);
+ }
+ if(fh >= 0)
+ {
+ _MapInfo_Map_Reset();
+ if(_MapInfo_ParseArena(fn, fh, pFilename, pGametypeToSet, isdefi, false))
+ goto mapinfo_handled; // skip generation
+ }
}
fn = strcat("maps/autogenerated/", pFilename, ".mapinfo");