Skip to content

Commit 3fe8317

Browse files
committed
doom lua: print correct rng seed depending on complevel
boom+ only uses rng.seed[], anything before only uses rndtable[]
1 parent f588942 commit 3fe8317

2 files changed

Lines changed: 45 additions & 51 deletions

File tree

Assets/Lua/Doom/doom.lua

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,6 @@ local function iterate()
348348
if texts.sector then text(10, TextPosY.Sector, texts.sector, 0xff00ffff) end
349349
end
350350

351-
local function cycle_log_types(isUse)
352-
if isUse
353-
then LineUseLog = (LineUseLog + 1) % (LineLogType.ALL + 1)
354-
else LineCrossLog = (LineCrossLog + 1) % (LineLogType.ALL + 1)
355-
end
356-
end
357-
358351
local function make_buttons()
359352
local w = PADDING_WIDTH
360353

@@ -372,22 +365,13 @@ local function make_buttons()
372365
elseif LineCrossLog == LineLogType.ALL then crossName = "ALL"
373366
end
374367

375-
make_button(w+5, 26,"Log Use "..useName, function() cycle_log_types(true ) end)
376-
make_button(w+5, 52,"Log Cross "..crossName,function() cycle_log_types(false) end)
377-
make_button(w+5, 78,"Log RNG " .. (RNGLog and "ON" or "OFF"), prandom_toggle)
378-
make_button(w+5,104,(ShowMap and "Hide" or "Show") .. " Map ",map_toggle )
379-
make_button(w+5,130,"Reset View", reset_view )
380-
make_button(w+5,156,"Hilite " .. (Hilite and "ON " or "OFF"), hilite_toggle )
381-
make_button(w+5,182,"Follow " .. (Follow and "ON " or "OFF"), follow_toggle )
382-
383-
--[[--
384-
make_button(10, -40, "+", function() zoom( 1) end)
385-
make_button(10, -10, "-", function() zoom(-1) end)
386-
make_button(40, -24, "<", pan_left )
387-
make_button(64, -40, "^", pan_up )
388-
make_button(64, -10, "v", pan_down )
389-
make_button(88, -24, ">", pan_right)
390-
--]]--
368+
make_button(w+5, 26, "Log Use "..useName, function() cycle_log_types(true ) end)
369+
make_button(w+5, 52, "Log Cross "..crossName, function() cycle_log_types(false) end)
370+
make_button(w+5, 78, "Log RNG " ..(RNGLog and "ON" or "OFF"), prandom_toggle)
371+
make_button(w+5, 104, (ShowMap and "Hide" or "Show").." Map ", map_toggle )
372+
make_button(w+5, 130, "Reset View", reset_view )
373+
make_button(w+5, 156, "Hilite " ..(Hilite and "ON " or "OFF"), hilite_toggle )
374+
make_button(w+5, 182, "Follow " ..(Follow and "ON " or "OFF"), follow_toggle )
391375

392376
Input = input.get()
393377

@@ -472,17 +456,21 @@ end
472456
doom.on_prandom(function(info)
473457
if not RNGLog then return end
474458

475-
local tic = Globals.gametic - 1
459+
local seed = ""
476460

477-
if tic < 0 then tic = 0 end
461+
if Globals.compatibility_level >= 7 then
462+
seed = string.format("%010u",
463+
Globals.rng.seed[PRANDOM_ALL_IN_ONE+1]
464+
)
465+
else
466+
seed = string.format("%03d",
467+
memory.readbyte(memory.read_u32_le(symbols.rndtable) + Globals.rng.rndindex)
468+
)
469+
end
478470

479471
table.insert(PRandomInfo, string.format(
480-
"%d (%d): #%03d %010u %s",
481-
tic,
482-
#PRandomInfo,
483-
Globals.rng.rndindex,
484-
Globals.rng.seed[PRANDOM_ALL_IN_ONE],
485-
info
472+
"%d (%d): #%03d %s %s",
473+
Globals.gametic, #PRandomInfo+1, Globals.rng.rndindex, seed, info
486474
))
487475
end)
488476

Assets/Lua/Doom/doom.misc.lua

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,29 @@ MapPrefs = {
151151
}
152152

153153

154-
--gui.defaultPixelFont("fceux")
155154
gui.use_surface("client")
156155
client.SetClientExtraPadding(PADDING_WIDTH, 0, 0, 0)
157156

158157

158+
-- TOGGLES
159+
160+
function follow_toggle()
161+
Follow = not Follow
162+
end
163+
164+
function hilite_toggle()
165+
Hilite = not Hilite
166+
end
167+
168+
function map_toggle()
169+
ShowMap = not ShowMap
170+
end
171+
172+
function prandom_toggle()
173+
RNGLog = not RNGLog
174+
end
175+
176+
159177
-- GAME/SCREEN CODECS
160178

161179
function decode_x(coord)
@@ -452,6 +470,13 @@ function check_press(key)
452470
return Input[key] and not LastInput[key]
453471
end
454472

473+
function cycle_log_types(isUse)
474+
if isUse
475+
then LineUseLog = (LineUseLog + 1) % (LineLogType.ALL + 1)
476+
else LineCrossLog = (LineCrossLog + 1) % (LineLogType.ALL + 1)
477+
end
478+
end
479+
455480

456481
-- MATH
457482

@@ -786,25 +811,6 @@ function freeze_gui()
786811
end
787812

788813

789-
-- TOGGLES
790-
791-
function follow_toggle()
792-
Follow = not Follow
793-
end
794-
795-
function hilite_toggle()
796-
Hilite = not Hilite
797-
end
798-
799-
function map_toggle()
800-
ShowMap = not ShowMap
801-
end
802-
803-
function prandom_toggle()
804-
RNGLog = not RNGLog
805-
end
806-
807-
808814
-- MISC
809815

810816
function suppress_click_input()

0 commit comments

Comments
 (0)