Nextmap: replace len hardcoded content by charsmax and sizeof
This commit is contained in:
parent
8071b895d2
commit
cff3ab867a
|
@ -74,11 +74,11 @@ public server_changelevel() {
|
|||
|
||||
// Check if the cvar "amx_nextmap" has changed since the map loaded as it overrides the min/max settings.
|
||||
new szCvarNextMap[32]
|
||||
get_cvar_string("amx_nextmap", szCvarNextMap, 31)
|
||||
get_cvar_string("amx_nextmap", szCvarNextMap, charsmax(szCvarNextMap))
|
||||
if ( !equal(szCvarNextMap, g_mapCycle[g_nextPos][NAME]) ) {
|
||||
if (ValidMap(szCvarNextMap)) {
|
||||
if (g_changeMapDelay)
|
||||
set_task(INFO_READ_TIME, "changeMap", 0, szCvarNextMap, 32)
|
||||
set_task(INFO_READ_TIME, "changeMap", 0, szCvarNextMap, sizeof(szCvarNextMap))
|
||||
else
|
||||
changeMap(szCvarNextMap)
|
||||
return BLOCK_ONCE
|
||||
|
@ -89,7 +89,7 @@ public server_changelevel() {
|
|||
getNextValidMap(szNextMap)
|
||||
if (ValidMap(szNextMap)) {
|
||||
if (g_changeMapDelay)
|
||||
set_task(INFO_READ_TIME, "changeMap", 0, szNextMap, 32)
|
||||
set_task(INFO_READ_TIME, "changeMap", 0, szNextMap, sizeof(szNextMap))
|
||||
else
|
||||
changeMap(szNextMap)
|
||||
} else
|
||||
|
@ -134,7 +134,7 @@ public getNextValidMap(szNextMap[]) {
|
|||
(g_mapCycle[startPos][MIN] <= g_numPlayers) ? "many" : "few", g_mapCycle[startPos][NAME], g_mapCycle[g_nextPos][NAME])
|
||||
|
||||
new szPos[8]
|
||||
num_to_str(g_nextPos, szPos, 7)
|
||||
num_to_str(g_nextPos, szPos, charsmax(szPos))
|
||||
set_localinfo("amx_nextmap_pos", szPos)
|
||||
set_cvar_string("amx_nextmap", g_mapCycle[g_nextPos][NAME])
|
||||
g_changeMapDelay = true
|
||||
|
@ -143,7 +143,7 @@ public getNextValidMap(szNextMap[]) {
|
|||
|
||||
public voteMap() {
|
||||
new szVoteMap[128]
|
||||
read_data(2, szVoteMap, 127) // "YO | Cheesy Peteza executed votemap 2 (co_angst 1/5)"
|
||||
read_data(2, szVoteMap, charsmax(szVoteMap)) // "YO | Cheesy Peteza executed votemap 2 (co_angst 1/5)"
|
||||
|
||||
new start, end, szData[64]
|
||||
for (new i; i<strlen(szVoteMap); ++i) {
|
||||
|
@ -155,10 +155,10 @@ public voteMap() {
|
|||
szData[j++] = szVoteMap[i] // "co_angst 1/5"
|
||||
}
|
||||
szData[j] = 0
|
||||
replace(szData, 63, "/", " ") // "co_angst 1 5"
|
||||
replace(szData, charsmax(szData), "/", " ") // "co_angst 1 5"
|
||||
|
||||
new szMapName[32], szVote1[3], szVote2[3], iVote1, iVote2
|
||||
parse(szData, szMapName, 31, szVote1, 2, szVote2, 2)
|
||||
parse(szData, szMapName, charsmax(szMapName), szVote1, charsmax(szVote1), szVote2, charsmax(szVote2))
|
||||
iVote1 = str_to_num(szVote1)
|
||||
iVote2 = str_to_num(szVote2)
|
||||
|
||||
|
@ -171,11 +171,11 @@ public voteMap() {
|
|||
|
||||
findNextMap() {
|
||||
new szPos[8]
|
||||
get_localinfo("amx_nextmap_pos", szPos, 7)
|
||||
get_localinfo("amx_nextmap_pos", szPos, charsmax(szPos))
|
||||
new pos = str_to_num(szPos)
|
||||
|
||||
new curmap[32]
|
||||
get_mapname(curmap, 31)
|
||||
get_mapname(curmap, charsmax(curmap))
|
||||
if ( equal(g_mapCycle[pos][NAME], curmap) ) {
|
||||
g_nextPos = pos + 1
|
||||
if (g_nextPos == g_numMaps)
|
||||
|
@ -191,29 +191,29 @@ findNextMap() {
|
|||
}
|
||||
}
|
||||
set_cvar_string("amx_nextmap", g_mapCycle[g_nextPos][NAME])
|
||||
num_to_str(g_nextPos, szPos, 7)
|
||||
num_to_str(g_nextPos, szPos, charsmax(szPos))
|
||||
set_localinfo("amx_nextmap_pos", szPos)
|
||||
}
|
||||
|
||||
readMapCycle() {
|
||||
new szMapCycleFile[32]
|
||||
get_cvar_string("mapcyclefile", szMapCycleFile, 31)
|
||||
get_cvar_string("mapcyclefile", szMapCycleFile, charsmax(szMapCycleFile))
|
||||
|
||||
new length, line = 0
|
||||
new szBuffer[64], szMapName[32], szMapPlayerNum[32]
|
||||
if ( file_exists(szMapCycleFile) ) {
|
||||
while( read_file(szMapCycleFile, line++, szBuffer, 63, length) ) { // ns_lost "\minplayers\16\maxplayers\32\"
|
||||
parse(szBuffer, szMapName, 31, szMapPlayerNum, 31)
|
||||
while( read_file(szMapCycleFile, line++, szBuffer, charsmax(szBuffer), length) ) { // ns_lost "\minplayers\16\maxplayers\32\"
|
||||
parse(szBuffer, szMapName, charsmax(szMapName), szMapPlayerNum, charsmax(szMapPlayerNum))
|
||||
if ( !isalpha(szMapName[0]) || !ValidMap(szMapName) ) continue
|
||||
|
||||
copy(g_mapCycle[g_numMaps][NAME], 31, szMapName)
|
||||
copy(g_mapCycle[g_numMaps][NAME], charsmax(g_mapCycle[][NAME]), szMapName)
|
||||
|
||||
for (new i; i<strlen(szMapPlayerNum); ++i) { // " minplayers 16 maxplayers 32 "
|
||||
if (szMapPlayerNum[i] == '\')
|
||||
szMapPlayerNum[i] = ' '
|
||||
}
|
||||
new szKey1[11], szKey2[11], szValue1[3], szValue2[3]
|
||||
parse(szMapPlayerNum, szKey1, 10, szValue1, 2, szKey2, 10, szValue2, 2)
|
||||
parse(szMapPlayerNum, szKey1, charsmax(szKey1), szValue1, charsmax(szValue1), szKey2, charsmax(szKey2), szValue2, charsmax(szValue2))
|
||||
if (equal(szKey1, "minplayers"))
|
||||
g_mapCycle[g_numMaps][MIN] = clamp(str_to_num(szValue1), 0, 32)
|
||||
if (equal(szKey2, "maxplayers"))
|
||||
|
@ -231,18 +231,18 @@ public roundEnded() {
|
|||
|
||||
public sayNextMap(){
|
||||
new szName[32]
|
||||
get_cvar_string("amx_nextmap", szName, 31)
|
||||
get_cvar_string("amx_nextmap", szName, charsmax(szName))
|
||||
client_print(0, print_chat, "Next Map: %s", szName)
|
||||
}
|
||||
|
||||
public sayNextMapTimeLeft(){
|
||||
new szName[32], szText[128]
|
||||
get_cvar_string("amx_nextmap", szName, 31)
|
||||
get_cvar_string("amx_nextmap", szName, charsmax(szName))
|
||||
format(szText, 64, "Next Map: %s", szName)
|
||||
|
||||
if (get_cvar_float("mp_timelimit")) {
|
||||
new a = get_timeleft()
|
||||
format(szText, 127, "%s Time Left: %d:%02d", szText, (a / 60) , (a % 60) )
|
||||
format(szText, charsmax(szText), "%s Time Left: %d:%02d", szText, (a / 60) , (a % 60) )
|
||||
}
|
||||
client_print(0, print_chat, "%s", szText)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user