@@ -21,7 +21,7 @@ local rws = memory.read_s16_le
2121local rbs = memory .read_s8
2222local text = gui .text
2323local box = gui .drawBox
24- local line = gui .drawLine
24+ local drawline = gui .drawLine
2525-- local text = gui.pixelText -- INSANELY SLOW
2626
2727-- TOP LEVEL VARIABLES
@@ -131,25 +131,20 @@ local function iterate_players()
131131 local total_itemcount = 0
132132 local total_secretcount = 0
133133 local stats = " HP Armr Kill Item Secr\n "
134- for i = 1 , dsda .MAX_PLAYERS do
135- local addr = dsda .PLAYER_SIZE * (i - 1 )
136- local mobj = rl (addr + PlayerOffsets .mobj , " Players" )
134+ for addr , player in pairs (dsda .player .items ) do
135+ playercount = playercount + 1
136+ local health = rls (addr + PlayerOffsets .health , " Players" )
137+ local armor = rls (addr + PlayerOffsets .armorpoints1 , " Players" )
138+ local killcount = rls (addr + PlayerOffsets .killcount , " Players" )
139+ local itemcount = rls (addr + PlayerOffsets .itemcount , " Players" )
140+ local secretcount = rls (addr + PlayerOffsets .secretcount , " Players" )
137141
138- if mobj ~= NULL_OBJECT then
139- playercount = playercount + 1
140- local health = rls (addr + PlayerOffsets .health , " Players" )
141- local armor = rls (addr + PlayerOffsets .armorpoints1 , " Players" )
142- local killcount = rls (addr + PlayerOffsets .killcount , " Players" )
143- local itemcount = rls (addr + PlayerOffsets .itemcount , " Players" )
144- local secretcount = rls (addr + PlayerOffsets .secretcount , " Players" )
142+ total_killcount = total_killcount + killcount
143+ total_itemcount = total_itemcount + itemcount
144+ total_secretcount = total_secretcount + secretcount
145145
146- total_killcount = total_killcount + killcount
147- total_itemcount = total_itemcount + itemcount
148- total_secretcount = total_secretcount + secretcount
149-
150- stats = string.format (" %s P%i %4i %4i %4i %4i %4i\n " ,
151- stats , i , health , armor , killcount , itemcount , secretcount )
152- end
146+ stats = string.format (" %s P%i %4i %4i %4i %4i %4i\n " ,
147+ stats , playercount , health , armor , killcount , itemcount , secretcount )
153148 end
154149 if playercount > 1 then
155150 stats = string.format (" %s %-12s %4i %4i %4i\n " , stats , " All" , total_killcount , total_itemcount , total_secretcount )
@@ -185,58 +180,42 @@ local function iterate()
185180 end
186181 end
187182
188- for i = 0 , 100000 do
189- local addr = i * dsda .LINE_SIZE
190- if addr > 0xFFFFFF then break end
191-
192- local id = rl (addr , " Lines" ) & 0xFFFFFFFF
193- if id == OUT_OF_BOUNDS then break end
194-
195- if id ~= NULL_OBJECT then
196- local special = rws (addr + LineOffsets .special , " Lines" )
197- local v1 = { x = rls (addr + LineOffsets .v1_x , " Lines" ),
198- y = - rls (addr + LineOffsets .v1_y , " Lines" ) }
199- local v2 = { x = rls (addr + LineOffsets .v2_x , " Lines" ),
200- y = - rls (addr + LineOffsets .v2_y , " Lines" ) }
183+ for addr , line in pairs (dsda .line .items ) do
184+ local special = rws (addr + LineOffsets .special , " Lines" )
185+ local v1 = { x = rls (addr + LineOffsets .v1_x , " Lines" ),
186+ y = - rls (addr + LineOffsets .v1_y , " Lines" ) }
187+ local v2 = { x = rls (addr + LineOffsets .v2_x , " Lines" ),
188+ y = - rls (addr + LineOffsets .v2_y , " Lines" ) }
201189
202- local color
203- if special ~= 0 then color = 0xffcc00ff end
190+ local color
191+ if special ~= 0 then color = 0xffcc00ff end
204192
205- line (
206- mapify_x (v1 .x ),
207- mapify_y (v1 .y ),
208- mapify_x (v2 .x ),
209- mapify_y (v2 .y ),
210- color or 0xffcccccc )
211- end
193+ drawline (
194+ mapify_x (v1 .x ),
195+ mapify_y (v1 .y ),
196+ mapify_x (v2 .x ),
197+ mapify_y (v2 .y ),
198+ color or 0xffcccccc )
212199 end
213200end
214201
215202local function init_objects ()
216- for i = 0 , 100000 do
217- local addr = i * dsda .MOBJ_SIZE
218- if addr > 0xFFFFFF then break end
219-
220- local thinker = rl (addr , " Things" ) & 0xFFFFFFFF -- just to check if mobj is there
221- if thinker == OUT_OF_BOUNDS then break end
222-
223- if thinker ~= NULL_OBJECT then
224- local x = rls (addr + MobjOffsets .x , " Things" ) / 0xffff
225- local y = rls (addr + MobjOffsets .y , " Things" ) / 0xffff * - 1
226- local type = rl (addr + MobjOffsets .type , " Things" )
227-
228- -- print(string.format("%d %f %f %02X", index, x, y, type))
229- type = MobjType [type ]
230- if type
231- and not string.find (type , " MISC" )
232- then
233- if x < OB .left then OB .left = x end
234- if x > OB .right then OB .right = x end
235- if y < OB .top then OB .top = y end
236- if y > OB .bottom then OB .bottom = y end
237- -- cache the Objects we need
238- table.insert (Objects , addr )
239- end
203+ for addr , mobj in pairs (dsda .mobj .items ) do
204+ local x = rls (addr + MobjOffsets .x , " Things" ) / 0xffff
205+ local y = rls (addr + MobjOffsets .y , " Things" ) / 0xffff * - 1
206+ local type = rl (addr + MobjOffsets .type , " Things" )
207+
208+ -- print(string.format("%d %f %f %02X", index, x, y, type))
209+ type = MobjType [type ]
210+ if type
211+ and not string.find (type , " MISC" )
212+ then
213+ if x < OB .left then OB .left = x end
214+ if x > OB .right then OB .right = x end
215+ if y < OB .top then OB .top = y end
216+ if y > OB .bottom then OB .bottom = y end
217+ -- cache the Objects we need
218+ table.insert (Objects , addr )
240219 end
241220 end
242221end
0 commit comments