Added amb311 - mapcycle file now ignores .bsp extension

This commit is contained in:
Steve Dudenhoeffer 2007-05-20 15:03:26 +00:00
parent 66feed1d2b
commit 079606c143
4 changed files with 128 additions and 11 deletions

View File

@ -188,7 +188,7 @@ public voteNextmap()
g_selected = true g_selected = true
new menu[512], a, mkeys = (1<<SELECTMAPS + 1) new menu[512], a, mkeys = (1<<SELECTMAPS + 1)
new tempmap[32];
new pos = format(menu, 511, g_coloredMenus ? "\y%L:\w^n^n" : "%L:^n^n", LANG_SERVER, "CHOOSE_NEXTM") new pos = format(menu, 511, g_coloredMenus ? "\y%L:\w^n^n" : "%L:^n^n", LANG_SERVER, "CHOOSE_NEXTM")
new dmax = (g_mapNums > SELECTMAPS) ? SELECTMAPS : g_mapNums new dmax = (g_mapNums > SELECTMAPS) ? SELECTMAPS : g_mapNums
@ -200,8 +200,7 @@ public voteNextmap()
if (++a >= g_mapNums) a = 0 if (++a >= g_mapNums) a = 0
g_nextName[g_mapVoteNum] = a g_nextName[g_mapVoteNum] = a
ArrayGetString(g_mapName, a, tempmap, charsof(tempmap)); pos += format(menu[pos], 511, "%d. %S^n", g_mapVoteNum + 1, ArrayGetStringHandle(g_mapName, a));
pos += format(menu[pos], 511, "%d. %s^n", g_mapVoteNum + 1, tempmap);
mkeys |= (1<<g_mapVoteNum) mkeys |= (1<<g_mapVoteNum)
g_voteCount[g_mapVoteNum] = 0 g_voteCount[g_mapVoteNum] = 0
} }
@ -229,6 +228,35 @@ public voteNextmap()
client_cmd(0, "spk Gman/Gman_Choose2") client_cmd(0, "spk Gman/Gman_Choose2")
log_amx("Vote: Voting for the nextmap started") log_amx("Vote: Voting for the nextmap started")
} }
stock bool:ValidMap(mapname[])
{
if ( is_map_valid(mapname) )
{
return true;
}
// If the is_map_valid check failed, check the end of the string
new len = strlen(mapname) - 4;
// The mapname was too short to possibly house the .bsp extension
if (len < 0)
{
return false;
}
if ( equali(mapname[len], ".bsp") )
{
// If the ending was .bsp, then cut it off.
// the string is byref'ed, so this copies back to the loaded text.
mapname[len] = '^0';
// recheck
if ( is_map_valid(mapname) )
{
return true;
}
}
return false;
}
loadSettings(filename[]) loadSettings(filename[])
{ {
@ -254,7 +282,7 @@ loadSettings(filename[])
if (szText[0] != ';' && if (szText[0] != ';' &&
is_map_valid(szText) && ValidMap(szText) &&
!equali(szText, g_lastMap) && !equali(szText, g_lastMap) &&
!equali(szText, currentMap)) !equali(szText, currentMap))
{ {

View File

@ -73,7 +73,7 @@ getNextMapName(szArg[], iMax)
{ {
new len = get_cvar_string("amx_nextmap", szArg, iMax) new len = get_cvar_string("amx_nextmap", szArg, iMax)
if (is_map_valid(szArg)) return len if (ValidMap(szArg)) return len
len = copy(szArg, iMax, g_nextMap) len = copy(szArg, iMax, g_nextMap)
set_cvar_string("amx_nextmap", g_nextMap) set_cvar_string("amx_nextmap", g_nextMap)
@ -119,6 +119,36 @@ public changeMap()
new g_warning[] = "WARNING: Couldn't find a valid map or the file doesn't exist (file ^"%s^")" new g_warning[] = "WARNING: Couldn't find a valid map or the file doesn't exist (file ^"%s^")"
stock bool:ValidMap(mapname[])
{
if ( is_map_valid(mapname) )
{
return true;
}
// If the is_map_valid check failed, check the end of the string
new len = strlen(mapname) - 4;
// The mapname was too short to possibly house the .bsp extension
if (len < 0)
{
return false;
}
if ( equali(mapname[len], ".bsp") )
{
// If the ending was .bsp, then cut it off.
// the string is byref'ed, so this copies back to the loaded text.
mapname[len] = '^0';
// recheck
if ( is_map_valid(mapname) )
{
return true;
}
}
return false;
}
#if defined OBEY_MAPCYCLE #if defined OBEY_MAPCYCLE
readMapCycle(szFileName[], szNext[], iNext) readMapCycle(szFileName[], szNext[], iNext)
{ {
@ -129,7 +159,8 @@ readMapCycle(szFileName[], szNext[], iNext)
{ {
while (read_file(szFileName, i++, szBuffer, 31, b)) while (read_file(szFileName, i++, szBuffer, 31, b))
{ {
if (!isalnum(szBuffer[0]) || !is_map_valid(szBuffer)) continue if (!isalnum(szBuffer[0]) || !ValidMap(szBuffer)) continue
if (!iMaps) if (!iMaps)
copy(szFirst, 31, szBuffer) copy(szFirst, 31, szBuffer)
@ -167,7 +198,7 @@ readMapCycle(szFileName[], szNext[], iNext)
{ {
while (read_file(szFileName, i++, szBuffer, 31, b)) while (read_file(szFileName, i++, szBuffer, 31, b))
{ {
if (!isalnum(szBuffer[0]) || !is_map_valid(szBuffer)) continue if (!isalnum(szBuffer[0]) || !ValidMap(szBuffer)) continue
if (!iMaps) if (!iMaps)
{ {

View File

@ -148,6 +148,35 @@ public voteNextmap(){
client_cmd(0,"spk Gman/Gman_Choose2") client_cmd(0,"spk Gman/Gman_Choose2")
log_amx("Vote: Voting for the nextmap started") log_amx("Vote: Voting for the nextmap started")
} }
stock bool:ValidMap(mapname[])
{
if ( is_map_valid(mapname) )
{
return true;
}
// If the is_map_valid check failed, check the end of the string
new len = strlen(mapname) - 4;
// The mapname was too short to possibly house the .bsp extension
if (len < 0)
{
return false;
}
if ( equali(mapname[len], ".bsp") )
{
// If the ending was .bsp, then cut it off.
// the string is byref'ed, so this copies back to the loaded text.
mapname[len] = '^0';
// recheck
if ( is_map_valid(mapname) )
{
return true;
}
}
return false;
}
loadSettings(filename[]) loadSettings(filename[])
{ {
@ -162,7 +191,7 @@ loadSettings(filename[])
{ {
if ( szText[0] != ';' if ( szText[0] != ';'
&& parse(szText, g_mapName[g_mapNums] ,31 ) && parse(szText, g_mapName[g_mapNums] ,31 )
&& is_map_valid( g_mapName[g_mapNums] ) && ValidMap( g_mapName[g_mapNums] )
&& !equali( g_mapName[g_mapNums] ,g_lastMap) && !equali( g_mapName[g_mapNums] ,g_lastMap)
&& !equali( g_mapName[g_mapNums] ,currentMap) ) && !equali( g_mapName[g_mapNums] ,currentMap) )
++g_mapNums ++g_mapNums

View File

@ -59,6 +59,35 @@ public plugin_init() {
readMapCycle() readMapCycle()
findNextMap() findNextMap()
} }
stock bool:ValidMap(mapname[])
{
if ( is_map_valid(mapname) )
{
return true;
}
// If the is_map_valid check failed, check the end of the string
new len = strlen(mapname) - 4;
// The mapname was too short to possibly house the .bsp extension
if (len < 0)
{
return false;
}
if ( equali(mapname[len], ".bsp") )
{
// If the ending was .bsp, then cut it off.
// the string is byref'ed, so this copies back to the loaded text.
mapname[len] = '^0';
// recheck
if ( is_map_valid(mapname) )
{
return true;
}
}
return false;
}
public server_changelevel() { public server_changelevel() {
if (g_mapChanging) if (g_mapChanging)
@ -68,7 +97,7 @@ public server_changelevel() {
new szCvarNextMap[32] new szCvarNextMap[32]
get_cvar_string("amx_nextmap", szCvarNextMap, 31) get_cvar_string("amx_nextmap", szCvarNextMap, 31)
if ( !equal(szCvarNextMap, g_mapCycle[g_nextPos][NAME]) ) { if ( !equal(szCvarNextMap, g_mapCycle[g_nextPos][NAME]) ) {
if (is_map_valid(szCvarNextMap)) { if (ValidMap(szCvarNextMap)) {
if (g_changeMapDelay) if (g_changeMapDelay)
set_task(INFO_READ_TIME, "changeMap", 0, szCvarNextMap, 32) set_task(INFO_READ_TIME, "changeMap", 0, szCvarNextMap, 32)
else else
@ -79,7 +108,7 @@ public server_changelevel() {
new szNextMap[32] new szNextMap[32]
getNextValidMap(szNextMap) getNextValidMap(szNextMap)
if (is_map_valid(szNextMap)) { if (ValidMap(szNextMap)) {
if (g_changeMapDelay) if (g_changeMapDelay)
set_task(INFO_READ_TIME, "changeMap", 0, szNextMap, 32) set_task(INFO_READ_TIME, "changeMap", 0, szNextMap, 32)
else else
@ -196,7 +225,7 @@ readMapCycle() {
if ( file_exists(szMapCycleFile) ) { if ( file_exists(szMapCycleFile) ) {
while( read_file(szMapCycleFile, line++, szBuffer, 63, length) ) { // ns_lost "\minplayers\16\maxplayers\32\" while( read_file(szMapCycleFile, line++, szBuffer, 63, length) ) { // ns_lost "\minplayers\16\maxplayers\32\"
parse(szBuffer, szMapName, 31, szMapPlayerNum, 31) parse(szBuffer, szMapName, 31, szMapPlayerNum, 31)
if ( !isalpha(szMapName[0]) || !is_map_valid(szMapName) ) continue if ( !isalpha(szMapName[0]) || !ValidMap(szMapName) ) continue
copy(g_mapCycle[g_numMaps][NAME], 31, szMapName) copy(g_mapCycle[g_numMaps][NAME], 31, szMapName)