Skip to content

Commit be17b54

Browse files
committed
doom lua: dump overruns too
1 parent 77a1231 commit be17b54

3 files changed

Lines changed: 107 additions & 24 deletions

File tree

Assets/Lua/Doom/doom.lua

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -320,17 +320,15 @@ end
320320
local function draw_grid()
321321
if not (ShowMap and ShowGrid) then return end
322322

323-
if InterceptsInfo == InterceptsState.OVERFLOW then
324-
BlockmapWidth = Globals.bmapwidth
325-
BlockmapOrigin = {
326-
x = Globals.bmaporgx,
327-
y = Globals.bmaporgy
328-
}
329-
BlockmapEnd = {
330-
x = BlockmapOrigin.x + BlockmapWidth * GRID_SIZE * FRACUNIT,
331-
y = BlockmapOrigin.y + Globals.bmapheight * GRID_SIZE * FRACUNIT
332-
}
333-
end
323+
BlockmapWidth = Globals.bmapwidth
324+
BlockmapOrigin = {
325+
x = Globals.bmaporgx,
326+
y = Globals.bmaporgy
327+
}
328+
BlockmapEnd = {
329+
x = BlockmapOrigin.x + BlockmapWidth * GRID_SIZE * FRACUNIT,
330+
y = BlockmapOrigin.y + Globals.bmapheight * GRID_SIZE * FRACUNIT
331+
}
334332

335333
if BlockmapWidth ~= 0 then
336334
local size = GRID_SIZE * FRACUNIT
@@ -513,6 +511,15 @@ local function make_buttons()
513511
print("Intercepts in blocks =")
514512
print(dump(Intercepts))
515513
Intercepts = {}
514+
515+
if InterceptsInfo == InterceptsState.OVERFLOW then
516+
print("")
517+
print("InterceptsOverruns in blocks =")
518+
print(dump(InterceptsOverruns))
519+
InterceptsOverruns = {}
520+
end
521+
522+
InterceptsInfo = InterceptsState.NONE
516523
end)
517524
end
518525

Assets/Lua/Doom/doom.misc.lua

Lines changed: 74 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,14 @@ Tracked = {
149149

150150
-- tables
151151

152-
Players = {}
153-
Config = {}
154-
PRandomInfo = {}
155-
DivLines = {}
156-
MapBlocks = {}
157-
Intercepts = {}
158-
GUITexts = {}
152+
Players = {}
153+
Config = {}
154+
PRandomInfo = {}
155+
DivLines = {}
156+
MapBlocks = {}
157+
Intercepts = {}
158+
InterceptsOverruns = {}
159+
GUITexts = {}
159160
-- map object positions bounds
160161
OB = {
161162
top = math.maxinteger,
@@ -226,6 +227,57 @@ function grid_show()
226227
ShowGrid = not ShowGrid
227228
end
228229

230+
local function fetch_intercept_overruns(limit)
231+
local ret = {}
232+
local list = {
233+
[ 12] = { name = "line_opening.lowfloor", value = Globals.line_opening.lowfloor },
234+
[ 16] = { name = "line_opening.bottom", value = Globals.line_opening.bottom },
235+
[ 20] = { name = "line_opening.top", value = Globals.line_opening.top },
236+
[ 24] = { name = "line_opening.range", value = Globals.line_opening.range },
237+
[160] = { name = "bulletslope", value = Globals.bulletslope },
238+
-- originally nested lists, we keep them as one flat list for simplicity
239+
-- augend is taken from the original, addend is to indicate lua's 1-based lists
240+
[176] = { name = "playerstarts[0].x", value = Globals.playerstarts[0+1].x },
241+
[178] = { name = "playerstarts[0].y", value = Globals.playerstarts[0+1].y },
242+
[180] = { name = "playerstarts[0].angle", value = Globals.playerstarts[0+1].angle },
243+
[182] = { name = "playerstarts[0].type", value = Globals.playerstarts[0+1].type },
244+
[184] = { name = "playerstarts[0].options", value = Globals.playerstarts[0+1].options },
245+
[186] = { name = "playerstarts[1].x", value = Globals.playerstarts[1+1].x },
246+
[188] = { name = "playerstarts[1].y", value = Globals.playerstarts[1+1].y },
247+
[190] = { name = "playerstarts[1].angle", value = Globals.playerstarts[1+1].angle },
248+
[192] = { name = "playerstarts[1].type", value = Globals.playerstarts[1+1].type },
249+
[194] = { name = "playerstarts[1].options", value = Globals.playerstarts[1+1].options },
250+
[196] = { name = "playerstarts[2].x", value = Globals.playerstarts[2+1].x },
251+
[198] = { name = "playerstarts[2].y", value = Globals.playerstarts[2+1].y },
252+
[200] = { name = "playerstarts[2].angle", value = Globals.playerstarts[2+1].angle },
253+
[202] = { name = "playerstarts[2].type", value = Globals.playerstarts[2+1].type },
254+
[204] = { name = "playerstarts[2].options", value = Globals.playerstarts[2+1].options },
255+
[206] = { name = "playerstarts[3].x", value = Globals.playerstarts[3+1].x },
256+
[208] = { name = "playerstarts[3].y", value = Globals.playerstarts[3+1].y },
257+
[210] = { name = "playerstarts[3].angle", value = Globals.playerstarts[3+1].angle },
258+
[212] = { name = "playerstarts[3].type", value = Globals.playerstarts[3+1].type },
259+
[214] = { name = "playerstarts[3].options", value = Globals.playerstarts[3+1].options },
260+
[220] = { name = "bmapwidth", value = Globals.bmapwidth },
261+
[228] = { name = "bmaporgx", value = Globals.bmaporgx },
262+
[232] = { name = "bmaporgy", value = Globals.bmaporgy },
263+
[230] = { name = "bmapheight", value = Globals.bmapheight }
264+
}
265+
266+
for i = 0, 230 do
267+
local source = list[i]
268+
if source and i <= limit then
269+
local item = {
270+
offset = string.format("%d bytes", i),
271+
value = string.format("0x%X", source.value & 0xffffffff),
272+
variable = source.name
273+
}
274+
table.insert(ret, item)
275+
end
276+
end
277+
278+
return ret
279+
end
280+
229281
local function hook_intercepts()
230282
local name = "Intercepts"
231283

@@ -264,6 +316,14 @@ local function hook_intercepts()
264316
)
265317
block = -block -- custom way to indicate overflow
266318
InterceptsInfo = InterceptsState.OVERFLOW
319+
320+
if not InterceptsOverruns[math.abs(block)] then
321+
InterceptsOverruns[math.abs(block)] = {}
322+
end
323+
InterceptsOverruns[math.abs(block)] = fetch_intercept_overruns(
324+
(count - MAXIMUM_INTERCEPTS) * 12
325+
)
326+
267327
client.pause()
268328
else
269329
text = string.format(
@@ -284,7 +344,7 @@ local function hook_intercepts()
284344
local object = {
285345
frac = string.format("0x%08x", intercept.frac),
286346
isaline = string.format("0x%08x", intercept.isaline),
287-
offset = string.format("%d bytes", (i - 1) * 12),
347+
offset = string.format("%d bytes",(i-1-MAXIMUM_INTERCEPTS)*12),
288348
pointer = intercept.d,
289349
block = math.abs(block)
290350
}
@@ -973,11 +1033,12 @@ end
9731033

9741034
function clear_cache()
9751035
reset_view()
976-
Lines = nil
977-
DivLines = {}
978-
MapBlocks = {}
979-
Intercepts = {}
980-
Tracked = {
1036+
Lines = nil
1037+
DivLines = {}
1038+
MapBlocks = {}
1039+
Intercepts = {}
1040+
InterceptsOverruns = {}
1041+
Tracked = {
9811042
[TrackedType.THING ] = TrackedEntity.new("thing" ),
9821043
[TrackedType.LINE ] = TrackedEntity.new("line" ),
9831044
[TrackedType.SECTOR] = TrackedEntity.new("sector")

Assets/Lua/Doom/dsda/structs.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,18 @@ structs.intercept = utils.struct_layout("intercept")
531531
.ptr("d")
532532
.build()
533533

534+
-- line_opening_t https://github.com/TASEmulators/dsda-doom/blob/fe96d105f06a1971b633a07d6468e0f426e1f1d5/prboom2/src/p_maputl.h#L50-L60
535+
structs.line_opening = utils.struct_layout("line_opening")
536+
.s32 ("top")
537+
.s32 ("bottom")
538+
.s32 ("range")
539+
.s32 ("lowfloor")
540+
.ptrto("frontsector", sector)
541+
.ptrto("backsector", sector)
542+
.u32 ("touchmidtex")
543+
.u32 ("abovemidtex")
544+
.build()
545+
534546
structs.globals = utils.global_layout()
535547
.sym ("s32", "gameskill")
536548
.sym ("s32", "gameepisode")
@@ -558,7 +570,9 @@ structs.globals = utils.global_layout()
558570
.sym ("s32", "bmapheight")
559571
.sym ("u32", "intercepts")
560572
.sym ("u32", "intercept_p")
573+
.sym ("s32", "bulletslope")
561574
.sym ("embed", "trace", structs.divline)
575+
.sym ("embed", "line_opening", structs.line_opening)
562576
-- game state
563577
.sym ("bool", "automap_active")
564578
.sym ("s32" , "gameaction")
@@ -573,6 +587,7 @@ structs.globals = utils.global_layout()
573587
.sym ("array", "thinkerclasscap", "embed", 5, structs.thinker)
574588
.sym ("array", "playeringame", "bool", structs.MAX_PLAYERS)
575589
.sym ("array", "players", "embed", structs.MAX_PLAYERS, structs.player)
590+
.sym ("array", "playerstarts", "embed", structs.MAX_PLAYERS^2, structs.mapthing)
576591
.sym ("s32", "thinker_count") -- for mobj_ptrs
577592
.sym ("s32", "numlines")
578593
.symas("ptr", "lines", "lines_ptr")

0 commit comments

Comments
 (0)