14 Commits

Author SHA1 Message Date
Not
13aeceeedd use TOL_SP and TOL_COOP as indicators of nuked race, battle maps 2022-05-20 19:49:49 +02:00
Not
7b28cd0777 verify the map in changelevel isn't a battle map 2022-05-20 19:32:32 +02:00
Not
ec982d10c3 display more map info on findmap 2022-05-20 19:09:27 +02:00
Not
f3ec32384a use ascii arithmetic to find letter values 2022-05-20 17:35:04 +02:00
Not
07dca46c92 force change level, enforce race mode 2022-05-20 17:17:12 +02:00
Not
14645dbc90 Merge branch 'lonsfor-patch-1' 2022-05-12 12:17:36 +02:00
Not
6c7cdf34b9 set players afkTime before enabling antiAFK 2022-05-12 12:14:48 +02:00
23a8373230 only look for scoreTable once 2022-04-30 23:11:52 +02:00
14f8769d93 dont do an iteration when the player is already known 2022-04-30 22:56:19 +02:00
5080672f7a Update 'leaderboard.lua' 2022-04-30 22:49:28 +02:00
5790a3c020 Dont iterate players if afk is disabled 2022-04-30 21:30:34 +02:00
e3c870eefd Prevent overflow of minutes 2022-04-30 21:00:55 +02:00
41b152ccf6 add VoteThinker hook 2022-04-30 20:55:38 +02:00
de63c4b2be Mmove local cv_teamchange to the top scope
No need to constantly look up the cvar when it can be saved
2022-04-30 20:52:42 +02:00

View File

@ -12,6 +12,8 @@ local splits = {}
local PATCH = nil
local help = true
local EncoreInitial = nil
local cv_teamchange
local scoreTable
-- Tracks if stats have been written or not
local StatTrack = false
@ -81,11 +83,24 @@ local cv_gui = CV_RegisterVar({
PossibleValue = {Off = GUI_OFF, Splits = GUI_SPLITS, On = GUI_ON}
})
local cv_afk = CV_RegisterVar({
local AntiAFK = true
CV_RegisterVar({
name = "lb_afk",
defaultvalue = 1,
flags = CV_NETVAR,
PossibleValue = CV_OnOff
flags = CV_NETVAR | CV_CALL,
PossibleValue = CV_OnOff,
func = function(v)
-- Set players afkTime and toggle AntiAFK
if v.value then
for p in players.iterate do
p.afkTime = leveltime
end
AntiAFK = true
else
AntiAFK = false
end
end
})
local cv_enable = CV_RegisterVar({
@ -239,7 +254,7 @@ if f then
flags = tonumber(t[7])
end
local scoreTable = getScoreTable(tonumber(t[1]), flags) or {}
scoreTable = getScoreTable(tonumber(t[1]), flags) or {}
local spl = {}
if t[6] != nil then
@ -356,19 +371,37 @@ local function findMap(player, ...)
return
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
local map = mapheaderinfo[i]
map = mapheaderinfo[i]
if map == nil then
continue
end
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(
player,
string.format(
"%s - %s",
"%s %-9s %-25s - %s\t%s",
G_BuildMapName(i),
map.lvlttl
lvltype,
map.lvlttl,
map.subttl,
(map.menuflags & LF2_HIDEINMENU and hell) or ""
)
)
end
@ -380,8 +413,6 @@ local function mapNotExists(player, map)
CONS_Printf(player, string.format("Map doesn't exist: %s", map:upper()))
end
local ALPH = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
local function changelevel(player, ...)
if not doyoudare(player) then
return
@ -403,6 +434,8 @@ local function changelevel(player, ...)
end
local mapnum = 0
local A = string.byte("A")
if tonumber(p) != nil then
-- Non extended map numbers
if tonumber(q) == nil then
@ -412,11 +445,12 @@ local function changelevel(player, ...)
mapnum = tonumber(p) * 10 + tonumber(q)
else
--Extended map numbers
p = ALPH:find(p) - 1
p = string.byte(p) - A
local qn = tonumber(q)
if qn == nil then
qn = ALPH:find(q) + 9
qn = string.byte(q) - A + 10
end
mapnum = 36 * p + qn + 100
end
@ -425,6 +459,12 @@ local function changelevel(player, ...)
return
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)
end
COM_AddCommand("changelevel", changelevel)
@ -660,7 +700,7 @@ function ticsToTime(tics, pure)
return string.format(
"%d:%02d:%02d",
G_TicsToMinutes(tics),
G_TicsToMinutes(tics, true),
G_TicsToSeconds(tics),
G_TicsToCentiseconds(tics)
)
@ -907,10 +947,10 @@ local function drawScroll(v, player, scoreTable, gui)
local x = 10
if #scoreTable >= 10 then
x = x + 8
end
if #scoreTable >= 100 then
x = x + 8
end
end
local y = FixedInt(scrollY)
@ -961,8 +1001,6 @@ local function drawScoreboard(v, player)
cachePatches(v)
local scoreTable = getScoreTable(gamemap, Flags)
local gui = cv_gui.value
if leveltime < START_TIME or player.exiting or player.lives == 0 then
gui = GUI_ON
@ -1009,7 +1047,7 @@ end
-- Find location of player and scroll to it
function scroll_to(player)
local m = getScoreTable(gamemap, Flags) or {}
local m = scoreTable or {}
scrollToPos = 2
for pos, score in ipairs(m) do
@ -1038,7 +1076,8 @@ local function writeStats()
end
local function saveTime(player)
local scoreTable = getScoreTable(gamemap, Flags) or {}
scoreTable = $ or {}
local pskin = skins[player.mo.skin]
local newscore = score_t(
@ -1138,14 +1177,17 @@ local function getGamer()
end
end
local function think()
if nextMap then
COM_BufInsertText(server, "map " + nextMap)
local function changeMap()
COM_BufInsertText(server, "map " + nextMap + " -force -gametype race")
nextMap = nil
end
local function think()
if nextMap then changeMap() end
if disable then
if cv_afk.value and ingame() > 1 then
if AntiAFK then
if ingame() > 1 then
for p in players.iterate do
if p.valid and not p.spectator and not p.exiting and p.lives > 0 then
if p.cmd.buttons then
@ -1170,6 +1212,7 @@ local function think()
end
end
end
end
help = true
return
@ -1217,14 +1260,14 @@ local function think()
end
if clearcheats then
clearcheats = false
for p in players.iterate do
p.SPBAKARTBIG = false
p.SPBAjustice = false
p.SPBAshutup = false
for q in players.iterate do
q.SPBAKARTBIG = false
q.SPBAjustice = false
q.SPBAshutup = false
end
end
for p in players.iterate do
if not p.spectator then
if p then
if p.SPBAKARTBIG then
Flags = $ | F_SPBBIG
end
@ -1232,14 +1275,19 @@ local function think()
Flags = $ | F_SPBJUS
end
end
end
end
if not (Flags & F_SPBATK) then
hud.enable("freeplay")
end
end
local cv_teamchange = CV_FindVar("allowteamchange")
scoreTable = getScoreTable(gamemap, Flags)
if not cv_teamchange then
cv_teamchange = CV_FindVar("allowteamchange")
end
if p then
-- Scroll controller
-- Spectators can't input buttons so let the gamer do it
@ -1288,15 +1336,18 @@ end
addHook("ThinkFrame", think)
local function interThink()
if nextMap then
COM_BufInsertText(server, "map " + nextMap)
nextMap = nil
if nextMap then changeMap() end
if not cv_teamchange then
cv_teamchange = CV_FindVar("allowteamchange")
end
if not CV_FindVar("allowteamchange").value then
if not cv_teamchange.value then
allowJoin(true)
end
end
addHook("IntermissionThinker", interThink)
addHook("VoteThinker", interThink)
-- Returns the values clamed between min, max
function clamp(min_v, v, max_v)