From ed68b47457e6a9e97acec9380adb5d7dd746cce7 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Mon, 1 Nov 2010 17:36:20 +0000 Subject: [PATCH 1/1] mapinfo: put the autogenerated files in an autogenerated/ subdir of maps/ --- qcsrc/common/mapinfo.qc | 119 +++++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 56 deletions(-) diff --git a/qcsrc/common/mapinfo.qc b/qcsrc/common/mapinfo.qc index 43a05b1c0a..33889827e3 100644 --- a/qcsrc/common/mapinfo.qc +++ b/qcsrc/common/mapinfo.qc @@ -231,7 +231,7 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp } if(fh < 0) return 0; - print("Analyzing ", fn, " to generate initial mapinfo; please edit that file later\n"); + print("Analyzing ", fn, " to generate initial mapinfo\n"); inWorldspawn = 2; MapInfo_Map_flags = 0; @@ -804,69 +804,76 @@ float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametype fh = fopen(fn, FILE_READ); if(fh < 0) { - if(!pAllowGenerate) - return 0; - _MapInfo_Map_Reset(); - r = _MapInfo_Generate(pFilename); - if(!r) - return 0; - fh = fopen(fn, FILE_WRITE); - fputs(fh, strcat("title ", MapInfo_Map_title, "\n")); - fputs(fh, strcat("description ", MapInfo_Map_description, "\n")); - fputs(fh, strcat("author ", MapInfo_Map_author, "\n")); - if(_MapInfo_Map_worldspawn_music != "") + fn = strcat("maps/autogenerated/", pFilename, ".mapinfo"); + fh = fopen(fn, FILE_READ); + if(fh < 0) { - if( - substring(_MapInfo_Map_worldspawn_music, strlen(_MapInfo_Map_worldspawn_music) - 4, 4) == ".wav" - || - substring(_MapInfo_Map_worldspawn_music, strlen(_MapInfo_Map_worldspawn_music) - 4, 4) == ".ogg" - ) - fputs(fh, strcat("cdtrack ", substring(_MapInfo_Map_worldspawn_music, 0, strlen(_MapInfo_Map_worldspawn_music) - 4), "\n")); + if(!pAllowGenerate) + return 0; + _MapInfo_Map_Reset(); + r = _MapInfo_Generate(pFilename); + if(!r) + return 0; + fh = fopen(fn, FILE_WRITE); + fputs(fh, strcat("title ", MapInfo_Map_title, "\n")); + fputs(fh, strcat("description ", MapInfo_Map_description, "\n")); + fputs(fh, strcat("author ", MapInfo_Map_author, "\n")); + if(_MapInfo_Map_worldspawn_music != "") + { + if( + substring(_MapInfo_Map_worldspawn_music, strlen(_MapInfo_Map_worldspawn_music) - 4, 4) == ".wav" + || + substring(_MapInfo_Map_worldspawn_music, strlen(_MapInfo_Map_worldspawn_music) - 4, 4) == ".ogg" + ) + fputs(fh, strcat("cdtrack ", substring(_MapInfo_Map_worldspawn_music, 0, strlen(_MapInfo_Map_worldspawn_music) - 4), "\n")); + else + fputs(fh, strcat("cdtrack ", _MapInfo_Map_worldspawn_music, "\n")); + } else - fputs(fh, strcat("cdtrack ", _MapInfo_Map_worldspawn_music, "\n")); - } - else - { - n = tokenize_console(cvar_string("g_cdtracks_remaplist")); - s = strcat(" ", cvar_string("g_cdtracks_dontusebydefault"), " "); - for(;;) { - i = floor(random() * n); - if(strstrofs(s, strcat(" ", argv(i), " "), 0) < 0) - break; + n = tokenize_console(cvar_string("g_cdtracks_remaplist")); + s = strcat(" ", cvar_string("g_cdtracks_dontusebydefault"), " "); + for(;;) + { + i = floor(random() * n); + if(strstrofs(s, strcat(" ", argv(i), " "), 0) < 0) + break; + } + fputs(fh, strcat("cdtrack ", ftos(i + 1), "\n")); } - fputs(fh, strcat("cdtrack ", ftos(i + 1), "\n")); - } - if(MapInfo_Map_supportedFeatures & MAPINFO_FEATURE_WEAPONS) - fputs(fh, "has weapons\n"); - else - fputs(fh, "// uncomment this if you added weapon pickups: has weapons\n"); - if(MapInfo_Map_flags & MAPINFO_FLAG_FRUSTRATING) - fputs(fh, "frustrating\n"); + if(MapInfo_Map_supportedFeatures & MAPINFO_FEATURE_WEAPONS) + fputs(fh, "has weapons\n"); + else + fputs(fh, "// uncomment this if you added weapon pickups: has weapons\n"); + if(MapInfo_Map_flags & MAPINFO_FLAG_FRUSTRATING) + fputs(fh, "frustrating\n"); - for(i = 1; i <= MapInfo_Map_supportedGametypes; i *= 2) - if(MapInfo_Map_supportedGametypes & i) - fputs(fh, sprintf("gametype %s // defaults: %s\n", MapInfo_Type_ToString(i), _MapInfo_GetDefaultEx(i))); + for(i = 1; i <= MapInfo_Map_supportedGametypes; i *= 2) + if(MapInfo_Map_supportedGametypes & i) + fputs(fh, sprintf("gametype %s // defaults: %s\n", MapInfo_Type_ToString(i), _MapInfo_GetDefaultEx(i))); - fh2 = fopen(strcat("scripts/", pFilename, ".arena"), FILE_READ); - if(fh2 >= 0) - { - fclose(fh2); - fputs(fh, "settemp_for_type all sv_q3acompat_machineshotgunswap 1\n"); - } + fh2 = fopen(strcat("scripts/", pFilename, ".arena"), FILE_READ); + if(fh2 >= 0) + { + fclose(fh2); + fputs(fh, "settemp_for_type all sv_q3acompat_machineshotgunswap 1\n"); + } - fputs(fh, "// optional: fog density red green blue alpha mindist maxdist\n"); - fputs(fh, "// optional: settemp_for_type (all|gametypename) cvarname value\n"); - fputs(fh, "// optional: clientsettemp_for_type (all|gametypename) cvarname value\n"); - fputs(fh, "// optional: size mins_x mins_y mins_z maxs_x maxs_y maxs_z\n"); - fputs(fh, "// optional: hidden\n"); + fputs(fh, "// optional: fog density red green blue alpha mindist maxdist\n"); + fputs(fh, "// optional: settemp_for_type (all|gametypename) cvarname value\n"); + fputs(fh, "// optional: clientsettemp_for_type (all|gametypename) cvarname value\n"); + fputs(fh, "// optional: size mins_x mins_y mins_z maxs_x maxs_y maxs_z\n"); + fputs(fh, "// optional: hidden\n"); - fclose(fh); - r = 2; - // return r; - fh = fopen(fn, FILE_READ); - if(fh < 0) - error("... but I just wrote it!"); + fclose(fh); + r = 2; + // return r; + fh = fopen(fn, FILE_READ); + if(fh < 0) + error("... but I just wrote it!"); + } + + print("WARNING: autogenerated mapinfo file ", fn, " has been loaded; please edit that file and move it to maps/", pFilename, ".mapinfo\n"); } _MapInfo_Map_Reset(); -- 2.39.2