Compare commits

...

5 Commits

View File

@ -371,19 +371,37 @@ local function findMap(player, ...)
return return
end end
local hell = "\x85HELL"
local tol = {
[TOL_SP] = "\x81Race\x80", -- Nuked race maps
[TOL_COOP] = "\x8D\Battle\x80", -- Nuked battle maps
[TOL_RACE] = "\x88Race\x80",
[TOL_MATCH] = "\x87\Battle\x80"
}
local lvltype, map
for i = 1, #mapheaderinfo do for i = 1, #mapheaderinfo do
local map = mapheaderinfo[i] map = mapheaderinfo[i]
if map == nil then if map == nil then
continue continue
end end
if map.lvlttl:lower():find(search:lower()) then if map.lvlttl:lower():find(search:lower()) then
-- Only care for up to TOL_MATCH (0x10)
lvltype = tol[map.typeoflevel & 0x1F] or map.typeoflevel
-- If not battle print numlaps
lvltype = (map.typeoflevel & (TOL_MATCH | TOL_COOP) and lvltype) or string.format("%s \x82%-2d\x80", lvltype, map.numlaps)
CONS_Printf( CONS_Printf(
player, player,
string.format( string.format(
"%s - %s", "%s %-9s %-25s - %s\t%s",
G_BuildMapName(i), G_BuildMapName(i),
map.lvlttl lvltype,
map.lvlttl,
map.subttl,
(map.menuflags & LF2_HIDEINMENU and hell) or ""
) )
) )
end end
@ -395,8 +413,6 @@ local function mapNotExists(player, map)
CONS_Printf(player, string.format("Map doesn't exist: %s", map:upper())) CONS_Printf(player, string.format("Map doesn't exist: %s", map:upper()))
end end
local ALPH = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
local function changelevel(player, ...) local function changelevel(player, ...)
if not doyoudare(player) then if not doyoudare(player) then
return return
@ -418,6 +434,8 @@ local function changelevel(player, ...)
end end
local mapnum = 0 local mapnum = 0
local A = string.byte("A")
if tonumber(p) != nil then if tonumber(p) != nil then
-- Non extended map numbers -- Non extended map numbers
if tonumber(q) == nil then if tonumber(q) == nil then
@ -427,11 +445,12 @@ local function changelevel(player, ...)
mapnum = tonumber(p) * 10 + tonumber(q) mapnum = tonumber(p) * 10 + tonumber(q)
else else
--Extended map numbers --Extended map numbers
p = ALPH:find(p) - 1 p = string.byte(p) - A
local qn = tonumber(q) local qn = tonumber(q)
if qn == nil then if qn == nil then
qn = ALPH:find(q) + 9 qn = string.byte(q) - A + 10
end end
mapnum = 36 * p + qn + 100 mapnum = 36 * p + qn + 100
end end
@ -440,6 +459,12 @@ local function changelevel(player, ...)
return return
end end
-- Verify valid race level
if not (mapheaderinfo[mapnum].typeoflevel & (TOL_SP | TOL_RACE)) then
CONS_Printf(player, "Battle maps are not supported")
return
end
nextMap = G_BuildMapName(mapnum) nextMap = G_BuildMapName(mapnum)
end end
COM_AddCommand("changelevel", changelevel) COM_AddCommand("changelevel", changelevel)
@ -1152,11 +1177,13 @@ local function getGamer()
end end
end end
local function changeMap()
COM_BufInsertText(server, "map " + nextMap + " -force -gametype race")
nextMap = nil
end
local function think() local function think()
if nextMap then if nextMap then changeMap() end
COM_BufInsertText(server, "map " + nextMap)
nextMap = nil
end
if disable then if disable then
if AntiAFK then if AntiAFK then
@ -1309,10 +1336,7 @@ end
addHook("ThinkFrame", think) addHook("ThinkFrame", think)
local function interThink() local function interThink()
if nextMap then if nextMap then changeMap() end
COM_BufInsertText(server, "map " + nextMap)
nextMap = nil
end
if not cv_teamchange then if not cv_teamchange then
cv_teamchange = CV_FindVar("allowteamchange") cv_teamchange = CV_FindVar("allowteamchange")