mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-18 22:51:50 +00:00
LunaCON: for gamevar-already-defined warnings/errors, show old location.
Synthesis, BUILD_LUNATIC! Got the build? Good synthesis. git-svn-id: https://svn.eduke32.com/eduke32@4153 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
25081fb459
commit
4dcd167c7a
2 changed files with 36 additions and 13 deletions
|
@ -5,6 +5,7 @@ Helixhorned <contact: Duke4.net forums>
|
||||||
:numbered:
|
:numbered:
|
||||||
:icons:
|
:icons:
|
||||||
:toc:
|
:toc:
|
||||||
|
:toclevels: 3
|
||||||
|
|
||||||
:language: lua
|
:language: lua
|
||||||
|
|
||||||
|
@ -1932,7 +1933,8 @@ The `fs` module -- virtual file system facilities
|
||||||
|
|
||||||
[red]*DRAFT*
|
[red]*DRAFT*
|
||||||
|
|
||||||
===== `files = fs.listpath(path, mask)`
|
[float]
|
||||||
|
==== `files = fs.listpath(path, mask)`
|
||||||
|
|
||||||
Lists file names matching a wildcard `mask` which can be found under `path`.
|
Lists file names matching a wildcard `mask` which can be found under `path`.
|
||||||
|
|
||||||
|
|
|
@ -735,6 +735,11 @@ local g_labeltype = {}
|
||||||
local g_labelspecial = {} -- [<label>] = true
|
local g_labelspecial = {} -- [<label>] = true
|
||||||
local g_labelloc = {} -- [<label>] = { filename, linenum, colnum }
|
local g_labelloc = {} -- [<label>] = { filename, linenum, colnum }
|
||||||
|
|
||||||
|
-- Get location table for use in continued warning/error reporting.
|
||||||
|
local function getLocation()
|
||||||
|
return { g_filename, getlinecol(g_lastkwpos) }
|
||||||
|
end
|
||||||
|
|
||||||
function reset.labels()
|
function reset.labels()
|
||||||
g_badids = {}
|
g_badids = {}
|
||||||
|
|
||||||
|
@ -842,9 +847,10 @@ function check.sysvar_def_attempt(identifier)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local Define = {}
|
|
||||||
function Define.inform_olddef_location(identifier, iserr) -- XXX: too much locals
|
local inform = {}
|
||||||
local loc = g_labelloc[identifier]
|
|
||||||
|
function inform.common(loc, iserr)
|
||||||
if (loc) then
|
if (loc) then
|
||||||
contprintf(iserr, "Old definition is at %s %d:%d",
|
contprintf(iserr, "Old definition is at %s %d:%d",
|
||||||
loc[1], loc[2], loc[3])
|
loc[1], loc[2], loc[3])
|
||||||
|
@ -853,6 +859,17 @@ function Define.inform_olddef_location(identifier, iserr) -- XXX: too much loca
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function inform.olddef_location(identifier, iserr)
|
||||||
|
inform.common(g_labelloc[identifier], iserr)
|
||||||
|
end
|
||||||
|
|
||||||
|
function inform.oldgv_location(identifier, iserr)
|
||||||
|
inform.common(g_gamevar[identifier].loc, iserr)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local Define = {}
|
||||||
|
|
||||||
function Define.label(identifier, num)
|
function Define.label(identifier, num)
|
||||||
if (check.sysvar_def_attempt(identifier)) then
|
if (check.sysvar_def_attempt(identifier)) then
|
||||||
return
|
return
|
||||||
|
@ -865,20 +882,21 @@ function Define.label(identifier, num)
|
||||||
if (oldtype ~= LABEL.NUMBER) then
|
if (oldtype ~= LABEL.NUMBER) then
|
||||||
errprintf("Refusing to overwrite `%s' label \"%s\" with a `define'd number.",
|
errprintf("Refusing to overwrite `%s' label \"%s\" with a `define'd number.",
|
||||||
LABEL[oldtype], identifier)
|
LABEL[oldtype], identifier)
|
||||||
Define.inform_olddef_location(identifier, true)
|
inform.olddef_location(identifier, true)
|
||||||
else
|
else
|
||||||
-- conl.labels[...]: don't warn for wrong PROJ_ redefinitions
|
-- conl.labels[...]: don't warn for wrong PROJ_ redefinitions
|
||||||
if (g_warn["not-redefined"]) then
|
if (g_warn["not-redefined"]) then
|
||||||
if (oldval ~= num and conl.PROJ[identifier]==nil) then
|
if (oldval ~= num and conl.PROJ[identifier]==nil) then
|
||||||
warnprintf("Label \"%s\" not redefined with new value %d (old: %d).",
|
warnprintf("Label \"%s\" not redefined with new value %d (old: %d).",
|
||||||
identifier, num, oldval)
|
identifier, num, oldval)
|
||||||
Define.inform_olddef_location(identifier, false)
|
inform.olddef_location(identifier, false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if (g_gamevar[identifier]) then
|
if (g_gamevar[identifier]) then
|
||||||
warnprintf("symbol `%s' already used for game variable", identifier)
|
warnprintf("symbol `%s' already used for game variable", identifier)
|
||||||
|
inform.oldgv_location(identifier, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (ffi and g_dyntilei and (num>=0 and num<C.MAXTILES)) then
|
if (ffi and g_dyntilei and (num>=0 and num<C.MAXTILES)) then
|
||||||
|
@ -889,7 +907,7 @@ function Define.label(identifier, num)
|
||||||
-- New definition of a label
|
-- New definition of a label
|
||||||
g_labeldef[identifier] = num
|
g_labeldef[identifier] = num
|
||||||
g_labeltype[identifier] = LABEL.NUMBER
|
g_labeltype[identifier] = LABEL.NUMBER
|
||||||
g_labelloc[identifier] = { g_filename, getlinecol(g_lastkwpos) }
|
g_labelloc[identifier] = getLocation()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -952,11 +970,11 @@ function Define.composite(labeltype, identifier, ...)
|
||||||
if (oldtype ~= labeltype) then
|
if (oldtype ~= labeltype) then
|
||||||
errprintf("Refusing to overwrite `%s' label \"%s\" with a `%s' value.",
|
errprintf("Refusing to overwrite `%s' label \"%s\" with a `%s' value.",
|
||||||
LABEL[oldtype], identifier, LABEL[labeltype])
|
LABEL[oldtype], identifier, LABEL[labeltype])
|
||||||
Define.inform_olddef_location(identifier, true)
|
inform.olddef_location(identifier, true)
|
||||||
else
|
else
|
||||||
warnprintf("Duplicate `%s' definition of \"%s\" ignored.",
|
warnprintf("Duplicate `%s' definition of \"%s\" ignored.",
|
||||||
LABEL[labeltype], identifier)
|
LABEL[labeltype], identifier)
|
||||||
Define.inform_olddef_location(identifier, false)
|
inform.olddef_location(identifier, false)
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -1009,7 +1027,7 @@ function Define.composite(labeltype, identifier, ...)
|
||||||
|
|
||||||
g_labeldef[identifier] = refcode
|
g_labeldef[identifier] = refcode
|
||||||
g_labeltype[identifier] = labeltype
|
g_labeltype[identifier] = labeltype
|
||||||
g_labelloc[identifier] = { g_filename, getlinecol(g_lastkwpos) }
|
g_labelloc[identifier] = getLocation()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -1405,6 +1423,7 @@ function Cmd.gamearray(identifier, initsize)
|
||||||
|
|
||||||
if (g_gamevar[identifier]) then
|
if (g_gamevar[identifier]) then
|
||||||
warnprintf("symbol `%s' already used for game variable", identifier)
|
warnprintf("symbol `%s' already used for game variable", identifier)
|
||||||
|
inform.oldgv_location(identifier, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
local ga = { name=mangle_name(identifier, "A"), size=initsize }
|
local ga = { name=mangle_name(identifier, "A"), size=initsize }
|
||||||
|
@ -1494,9 +1513,11 @@ function Cmd.gamevar(identifier, initval, flags)
|
||||||
end
|
end
|
||||||
|
|
||||||
errprintf("duplicate definition of gamevar `%s' has different flags", identifier)
|
errprintf("duplicate definition of gamevar `%s' has different flags", identifier)
|
||||||
|
inform.oldgv_location(identifier, true)
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
warnprintf("duplicate definition of gamevar `%s' ignored", identifier)
|
warnprintf("duplicate definition of gamevar `%s' ignored", identifier)
|
||||||
|
inform.oldgv_location(identifier, false)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1504,7 +1525,7 @@ function Cmd.gamevar(identifier, initval, flags)
|
||||||
local ltype = g_labeltype[identifier]
|
local ltype = g_labeltype[identifier]
|
||||||
if (ltype ~= nil) then
|
if (ltype ~= nil) then
|
||||||
warnprintf("Symbol `%s' already used for a defined %s.", identifier, LABEL[ltype])
|
warnprintf("Symbol `%s' already used for a defined %s.", identifier, LABEL[ltype])
|
||||||
Define.inform_olddef_location(identifier, false)
|
inform.olddef_location(identifier, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (isSessionVar) then
|
if (isSessionVar) then
|
||||||
|
@ -1516,12 +1537,12 @@ function Cmd.gamevar(identifier, initval, flags)
|
||||||
|
|
||||||
-- Declare new session gamevar.
|
-- Declare new session gamevar.
|
||||||
g_gamevar[identifier] = { name=format("_gv._sessionVar[%d]", g_numSessionVars),
|
g_gamevar[identifier] = { name=format("_gv._sessionVar[%d]", g_numSessionVars),
|
||||||
flags=flags }
|
flags=flags, loc=getLocation() }
|
||||||
g_numSessionVars = g_numSessionVars+1
|
g_numSessionVars = g_numSessionVars+1
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local gv = { name=mangle_name(identifier, "V"), flags=flags }
|
local gv = { name=mangle_name(identifier, "V"), flags=flags, loc=getLocation() }
|
||||||
g_gamevar[identifier] = gv
|
g_gamevar[identifier] = gv
|
||||||
|
|
||||||
if (storeWithSavegames) then
|
if (storeWithSavegames) then
|
||||||
|
|
Loading…
Reference in a new issue