Skip to content

Commit ecbf235

Browse files
committed
Add player queue
1 parent 2b4dcef commit ecbf235

File tree

2 files changed

+321
-34
lines changed

2 files changed

+321
-34
lines changed

Northgard_aa.CT

+161-17
Large diffs are not rendered by default.

main.lua

+160-17
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
--
44

55
local hashlinkVersion = -1
6+
local memoContent = {}
7+
local memoPlayers = {}
8+
local function_list = {}
9+
local queueMembers = {}
10+
local changeAddr = -1
11+
local changeAddr1 = -1
12+
local changeAddr2 = -1
13+
local changeAddr3 = -1
614

715
function convertAddressToScanData(address)
816
local addr = tonumber(address, 16)
@@ -194,11 +202,11 @@ local function attachToProcess()
194202
return false
195203
end
196204
end
205+
197206
return false
198207
end
199208

200-
function getChangeAddress(function_address)
201-
209+
function UpdateFunctionList()
202210
local hlboot_address, error = findHlbootdatAddress()
203211
if not hlboot_address then
204212
showMessage(error)
@@ -212,8 +220,12 @@ function getChangeAddress(function_address)
212220
end
213221

214222
local nfunctions = getHashlinkNfunctions(structure_address)
215-
local function_list = getListOfFunctions(structure_address, nfunctions)
223+
function_list = getListOfFunctions(structure_address, nfunctions)
216224

225+
UDF1.CEEdit1.Text = "Function list updated"
226+
end
227+
228+
function getChangeAddress(function_address)
217229
-- fn setCheckedJoin@26175 (ui.win.LobbyFinderWaiting, bool) -> void (7 regs, 12 ops)
218230
local function_address = function_list[26175 + 1]
219231
local MOV_OFFSET = 0xf
@@ -222,15 +234,8 @@ function getChangeAddress(function_address)
222234
return change_addr
223235
end
224236

225-
local changeAddr = -1
226-
227237
function UDF1_CECheckbox1Change(sender)
228238
if sender.Checked then
229-
if not attachToProcess() then
230-
UDF1.CEEdit1.Text = "Not attached to Northgard.exe"
231-
return
232-
end
233-
234239
changeAddr = getChangeAddress(function_address)
235240
if changeAddr == -1 then
236241
UDF1.CEEdit1.Text = "Failed to find change address"
@@ -243,10 +248,10 @@ function UDF1_CECheckbox1Change(sender)
243248
writeShortInteger(varAddr, 1)
244249
debug_continueFromBreakpoint(co_run)
245250
end)
246-
UDF1.CEEdit1.Text = "Successfully set breakpoint at " .. string.format("%X", changeAddr)
251+
UDF1.CEEdit1.Text = "Auto accept enabled"
247252
else
248253
debug_removeBreakpoint(changeAddr)
249-
UDF1.CEEdit1.Text = "Removed breakpoint at " .. string.format("%X", changeAddr)
254+
UDF1.CEEdit1.Text = "Auto accept disabled"
250255
end
251256
end
252257

@@ -255,16 +260,154 @@ function FormShow(sender)
255260
UDF1.Position = poScreenCenter
256261
end
257262

258-
function FormCreate(sender)
259-
changeAddr = -1
260-
end
261-
262263
function CloseClick(sender)
263264
if changeAddr ~= -1 then
264265
debug_removeBreakpoint(changeAddr)
265266
end
267+
if changeAddr1 ~= -1 then
268+
debug_removeBreakpoint(changeAddr1)
269+
end
270+
if changeAddr2 ~= -1 then
271+
debug_removeBreakpoint(changeAddr2)
272+
end
273+
if changeAddr3 ~= -1 then
274+
debug_removeBreakpoint(changeAddr3)
275+
end
266276
closeCE()
267277
return caFree
268278
end
269279

270-
UDF1.show()
280+
-- logLobbyInfo@29519
281+
function getLogAddress1()
282+
local FUNCTION_OFFSET = 2026
283+
local function_address = function_list[29519 + 1]
284+
return function_address + FUNCTION_OFFSET
285+
end
286+
287+
-- logUserJoined@29520
288+
function getLogAddress2()
289+
local FUNCTION_OFFSET = 28
290+
local function_address = function_list[29520 + 1]
291+
return function_address + FUNCTION_OFFSET
292+
end
293+
294+
-- logUserLeft@29521
295+
function getLogAddress3()
296+
local FUNCTION_OFFSET = 28
297+
local function_address = function_list[29521 + 1]
298+
return function_address + FUNCTION_OFFSET
299+
end
300+
301+
function parsePlayerInfo(logData)
302+
-- Extract player name and ID from formats like:
303+
-- "PlayerName(SomeID)" or "PlayerName(SomeID)(TeamX)"
304+
local name, id = logData:match("([^(]+)%(([^)]+)%)")
305+
return name, id
306+
end
307+
308+
function getLogData()
309+
local LOG_OFFSET = 8
310+
local logAddr = readPointer(RAX + LOG_OFFSET)
311+
local logData = readString(logAddr, 2000, true)
312+
logData = logData:gsub(" ", "")
313+
logData = logData:gsub("\t", "")
314+
return logData
315+
end
316+
317+
function updateQueueDisplay()
318+
UDF1.CEMemo1.Lines.Clear()
319+
for player, _ in pairs(queueMembers) do
320+
UDF1.CEMemo1.Lines.Add(player)
321+
end
322+
end
323+
324+
function UDF1_CECheckbox2Change(sender)
325+
if sender.Checked then
326+
queueMembers = {} -- Reset queue members list
327+
328+
changeAddr1 = getLogAddress1()
329+
if changeAddr1 == -1 then
330+
UDF1.CEEdit1.Text = "Failed to find `logLobbyInfo` address"
331+
return
332+
end
333+
334+
changeAddr2 = getLogAddress2()
335+
if changeAddr2 == -1 then
336+
UDF1.CEEdit1.Text = "Failed to find `logUserJoined` address"
337+
return
338+
end
339+
340+
changeAddr3 = getLogAddress3()
341+
if changeAddr3 == -1 then
342+
UDF1.CEEdit1.Text = "Failed to find `logUserLeft` address"
343+
return
344+
end
345+
346+
debug_setBreakpoint(changeAddr1, function()
347+
local logData = getLogData()
348+
-- Clear previous queue state when new lobby info arrives
349+
queueMembers = {}
350+
-- Process each line
351+
for line in logData:gmatch("[^\r\n]+") do
352+
if line ~= "Members:" then
353+
local name, id = parsePlayerInfo(line)
354+
if name and id then
355+
queueMembers[name] = id
356+
end
357+
end
358+
end
359+
updateQueueDisplay()
360+
debug_continueFromBreakpoint(co_run)
361+
end)
362+
363+
debug_setBreakpoint(changeAddr2, function()
364+
local logData = getLogData()
365+
local name, id = parsePlayerInfo(logData)
366+
if name and id then
367+
queueMembers[name] = id
368+
updateQueueDisplay()
369+
end
370+
debug_continueFromBreakpoint(co_run)
371+
end)
372+
373+
debug_setBreakpoint(changeAddr3, function()
374+
local logData = getLogData()
375+
local name = parsePlayerInfo(logData)
376+
if name then
377+
queueMembers[name] = nil
378+
updateQueueDisplay()
379+
end
380+
debug_continueFromBreakpoint(co_run)
381+
end)
382+
383+
UDF1.CEEdit1.Text = "Tracking queue enabled"
384+
else
385+
debug_removeBreakpoint(changeAddr1)
386+
debug_removeBreakpoint(changeAddr2)
387+
debug_removeBreakpoint(changeAddr3)
388+
UDF1.CEEdit1.Text = "Tracking queue disabled"
389+
end
390+
end
391+
392+
function ClearEverything()
393+
UDF1.CEMemo1.Lines.Clear()
394+
UDF1.CEEdit1.Text = ""
395+
UDF1.CECheckbox1.Checked = false
396+
UDF1.CECheckbox2.Checked = false
397+
end
398+
399+
function UDF1_CECustomButton1Click(sender)
400+
ClearEverything()
401+
402+
if not attachToProcess() then
403+
UDF1.CEEdit1.Text = "Not attached to Northgard.exe"
404+
return
405+
end
406+
407+
UpdateFunctionList()
408+
UDF1.CEEdit1.Text = "Data updated"
409+
end
410+
411+
412+
UDF1.show()
413+
ClearEverything()

0 commit comments

Comments
 (0)