mirror of
https://github.com/notwa/mm
synced 2024-11-05 02:59:03 -08:00
a little refactoring
This commit is contained in:
parent
c64292bc29
commit
aafdcfae69
1 changed files with 33 additions and 42 deletions
|
@ -1,22 +1,17 @@
|
||||||
require "boilerplate"
|
require "boilerplate"
|
||||||
require "addrs.init"
|
require "addrs.init"
|
||||||
|
|
||||||
|
-- check for errors in the actor linked lists
|
||||||
|
local validate = true
|
||||||
|
|
||||||
-- bizhawk lua has some nasty memory leaks at the moment,
|
-- bizhawk lua has some nasty memory leaks at the moment,
|
||||||
-- so instead of creating an object every time,
|
-- so instead of creating an object every time,
|
||||||
-- using a template to offset from will do for now.
|
-- using a template to offset from will do for now.
|
||||||
local actor_t = Actor(0)
|
local actor_t = Actor(0)
|
||||||
|
|
||||||
-- check for errors in the actor linked lists
|
local suffix = oot and " oot" or ""
|
||||||
local validate = true
|
local actor_names = require( "actor names"..suffix)
|
||||||
|
local damage_names = require("damage names"..suffix)
|
||||||
local actor_names, damage_names
|
|
||||||
if oot then
|
|
||||||
actor_names = require "actor names oot"
|
|
||||||
damage_names = require "damage names oot"
|
|
||||||
else
|
|
||||||
actor_names = require "actor names"
|
|
||||||
damage_names = require "damage names"
|
|
||||||
end
|
|
||||||
|
|
||||||
function sort_by_key(t)
|
function sort_by_key(t)
|
||||||
local sorted = {}
|
local sorted = {}
|
||||||
|
@ -159,19 +154,8 @@ function wipe()
|
||||||
seen_strs_sorted = {}
|
seen_strs_sorted = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
local function run()
|
local function run(now)
|
||||||
local now = emu.framecount()
|
local game_counts = nil
|
||||||
if now < before then wait = 2 end
|
|
||||||
before = now
|
|
||||||
if wait > 0 then
|
|
||||||
-- prevent script from lagging reversing
|
|
||||||
wait = wait - 1
|
|
||||||
if wait == 0 then wipe() end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local any = 0
|
|
||||||
local counts = nil
|
|
||||||
local seen = {}
|
local seen = {}
|
||||||
local cursor, target
|
local cursor, target
|
||||||
|
|
||||||
|
@ -186,29 +170,23 @@ local function run()
|
||||||
end
|
end
|
||||||
|
|
||||||
if R4(stupid) ~= 0 then
|
if R4(stupid) ~= 0 then
|
||||||
T_BR(0, 14, "stupid", "red")
|
T_BR(0, 0, "stupid", "red")
|
||||||
any = 0
|
return
|
||||||
else
|
end
|
||||||
counts = count_actors()
|
|
||||||
|
game_counts = count_actors()
|
||||||
|
local any = 0
|
||||||
for i = 0, 11 do
|
for i = 0, 11 do
|
||||||
any = any + counts[i]
|
any = any + game_counts[i]
|
||||||
T_BR(0, 13 - i, ("#%2i: %2i"):format(i, counts[i]))
|
T_BR(0, 13 - i, ("#%2i: %2i"):format(i, game_counts[i]))
|
||||||
end
|
end
|
||||||
T_BR(0, 1, ("sum:%3i"):format(any))
|
T_BR(0, 1, ("sum:%3i"):format(any))
|
||||||
|
|
||||||
if addrs.actor_count then
|
|
||||||
local game_count = R1(addrs.actor_count.addr)
|
|
||||||
if game_count ~= any then
|
|
||||||
T_BR(8, 1, "mismatch!", "red")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local actors_by_type = {[0]={},{},{},{},{},{},{},{},{},{},{},{}} -- 12
|
local actors_by_type = {[0]={},{},{},{},{},{},{},{},{},{},{},{}} -- 12
|
||||||
local new_counts = {[0]=0,0,0,0,0,0,0,0,0,0,0,0} -- 12
|
local new_counts = {[0]=0,0,0,0,0,0,0,0,0,0,0,0} -- 12
|
||||||
if any > 0 then
|
if any > 0 then
|
||||||
any = 0
|
any = 0
|
||||||
for at, ai, addr in iter_actors(counts) do
|
for at, ai, addr in iter_actors(game_counts) do
|
||||||
actors_by_type[at][ai] = addr
|
actors_by_type[at][ai] = addr
|
||||||
new_counts[at] = new_counts[at] + 1
|
new_counts[at] = new_counts[at] + 1
|
||||||
any = any + 1
|
any = any + 1
|
||||||
|
@ -334,8 +312,21 @@ local function run()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function runwrap(now)
|
||||||
|
if now < before then wait = 2 end
|
||||||
|
before = now
|
||||||
|
if wait > 0 then
|
||||||
|
-- prevent script from lagging reversing
|
||||||
|
wait = wait - 1
|
||||||
|
if wait == 0 then wipe() end
|
||||||
|
else
|
||||||
|
run(now)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
event.onloadstate(wipe, 'actor wipe')
|
event.onloadstate(wipe, 'actor wipe')
|
||||||
while true do
|
while true do
|
||||||
run()
|
local now = emu.framecount()
|
||||||
|
runwrap(now)
|
||||||
emu.frameadvance()
|
emu.frameadvance()
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue