1
0
Fork 0
mirror of https://github.com/notwa/mm synced 2024-11-05 03:29:02 -08:00

note unloaded actors; cleanup

This commit is contained in:
Connor Olding 2015-03-18 22:19:25 -07:00
parent 1b5a0694ed
commit 4e656e336b

View file

@ -17,10 +17,19 @@ else
damage_names = require "damage names" damage_names = require "damage names"
end end
function sort_by_key(t)
local sorted = {}
local i = 1
for k, v in pairs(t) do
sorted[i] = {k=k, v=v}
i = i + 1
end
table.sort(sorted, function(a, b) return a.k < b.k end)
return sorted
end
function T(x, y, s, color, pos) function T(x, y, s, color, pos)
color = color or "white" gui.text(10*x + 2, 16*y + 4, s, nil, color or "white", pos or "bottomright")
pos = pos or "bottomright"
gui.text(10*x + 2, 16*y + 4, s, nil, color, pos)
end end
function T_BR(x, y, s, color) T(x, y, s, color, "bottomright") end function T_BR(x, y, s, color) T(x, y, s, color, "bottomright") end
@ -102,10 +111,9 @@ function update_input()
old_ctrl = ctrl old_ctrl = ctrl
end end
local seen = {} local seen_once = {}
local seen_strs = {} local seen_strs = {}
local seen_strs_sorted = {} local seen_strs_sorted = {}
local last_any = 0
local focus_at = 2 local focus_at = 2
local focus_ai = 0 local focus_ai = 0
@ -115,17 +123,13 @@ local stupid = addrs.actor_counts[0].addr - 0x8
while true do while true do
local any = 0 local any = 0
local game_count = 0
local counts = nil local counts = nil
local seen = {}
update_input() update_input()
if pressed.left then if pressed.left then focus_ai = focus_ai - 1 end
focus_ai = focus_ai - 1 if pressed.right then focus_ai = focus_ai + 1 end
end
if pressed.right then
focus_ai = focus_ai + 1
end
if pressed.down then if pressed.down then
-- follow Link again -- follow Link again
focus_at = 2 focus_at = 2
@ -144,7 +148,7 @@ while true do
T_BR(0, 1, ("sum:%3i"):format(any)) T_BR(0, 1, ("sum:%3i"):format(any))
if addrs.actor_count then if addrs.actor_count then
game_count = R1(addrs.actor_count.addr) local game_count = R1(addrs.actor_count.addr)
if game_count ~= any then if game_count ~= any then
T_BR(8, 1, "mismatch!", "red") T_BR(8, 1, "mismatch!", "red")
end end
@ -152,14 +156,14 @@ while true do
end end
if any == 0 then if any == 0 then
seen = {} if #seen_strs_sorted > 0 then
seen_strs = {}
seen_strs_sorted = {}
if last_any ~= any then
print() print()
print("# actors wiped #") print("# actors wiped #")
print() print()
end end
seen_once = {}
seen_strs = {}
seen_strs_sorted = {}
else else
while focus_ai < 0 do while focus_ai < 0 do
focus_at = (focus_at - 1) % 12 focus_at = (focus_at - 1) % 12
@ -172,11 +176,14 @@ while true do
end end
local focus_link = focus_at == 2 and focus_ai == 0 local focus_link = focus_at == 2 and focus_ai == 0
local needs_update = false local needs_update = false
for at, ai, addr in iter_actors(counts) do for at, ai, addr in iter_actors(counts) do
local num = R2(addr + actor_t.num.addr) local num = R2(addr + actor_t.num.addr)
local name = actor_names[num] local name = actor_names[num]
local focus_this = at == focus_at and ai == focus_ai
seen[num] = true
if not name then if not name then
name = "NEW" name = "NEW"
@ -184,8 +191,8 @@ while true do
print(("\t[0x%03X]=\"NEW\","):format(num)) print(("\t[0x%03X]=\"NEW\","):format(num))
end end
if not seen[num] then if not seen_once[num] then
seen[num] = true seen_once[num] = true
needs_update = true needs_update = true
local str local str
if name:sub(1,1) == "?" then if name:sub(1,1) == "?" then
@ -197,8 +204,6 @@ while true do
print(str) print(str)
end end
local focus_this = at == focus_at and ai == focus_ai
if focus_this and not focus_link then if focus_this and not focus_link then
T_BL(0, 2, ('type: %02X'):format(at)) T_BL(0, 2, ('type: %02X'):format(at))
T_BL(0, 1, ('index: %02X'):format(ai)) T_BL(0, 1, ('index: %02X'):format(ai))
@ -243,26 +248,14 @@ while true do
end end
end end
last_any = any
function sort_by_key(t)
local sorted = {}
local i = 1
for k, v in pairs(seen_strs) do
sorted[i] = {k=k, v=v}
i = i + 1
end
table.sort(sorted, function(a, b) return a.k < b.k end)
return sorted
end
if needs_update then if needs_update then
seen_strs_sorted = sort_by_key(seen_strs) seen_strs_sorted = sort_by_key(seen_strs)
end end
if focus_link then if focus_link then
for i, t in ipairs(seen_strs_sorted) do for i, t in ipairs(seen_strs_sorted) do
T_TL(0, i - 1, t.v) local color = seen[t.k] and 'white' or 'orange'
T_TL(0, i - 1, t.v, color)
end end
end end