Gate debugging functions added

This commit is contained in:
2026-01-01 23:43:22 -05:00
parent 9e47e04adb
commit 0906603e58
3 changed files with 34 additions and 16 deletions

View File

@ -144,7 +144,7 @@ else
end
-- Initialize modules
utils.init(config, gate)
utils.init(config, gate, chatBox)
display.init(mon, config, addresses, utils, localGateAddress)
handlers.init(config, gate, mon, utils, display, events)
@ -159,13 +159,6 @@ if transceiver and config.enableGDO and config.irisPassword then
end
end
-- Helper function for chatbox debugging
local function debugChat(message)
if config.enableChatboxDebug and chatBox then
chatBox.sendMessageToPlayer("[SGC] " .. message, config.chatboxDebugPlayer)
end
end
-- Ensure gate starts disconnected
gate.disconnectStargate()
@ -263,12 +256,12 @@ local function HandleIncomingPasswordRequest(password)
utils.log("Correct password received, opening iris")
utils.openIris()
utils.sendPasswordResponse(true)
debugChat("Sent: IRIS_OPEN")
utils.debug("Sent: IRIS_OPEN")
return true
else
utils.log("Incorrect password received")
utils.sendPasswordResponse(false)
debugChat("Sent: IRIS_DENIED")
utils.debug("Sent: IRIS_DENIED")
return false
end
end
@ -469,7 +462,7 @@ local function handleIncomingWormhole()
-- Send version message to remote gate
sleep(0.5) -- Brief delay to ensure connection is stable
utils.sendVersionMessage()
debugChat("Sent: SGCS_V" .. config.programVersion)
utils.debug("Sent: SGCS_V" .. config.programVersion)
-- Handle iris
if config.autoCloseIrisOnIncoming then
@ -483,7 +476,7 @@ local function handleIncomingWormhole()
-- Send password request if iris is closed and password system is enabled
if config.irisPassword and config.enableMessaging then
utils.sendPasswordRequest()
debugChat("Sent: IRIS_PASSWORD_REQUIRED")
utils.debug("Sent: IRIS_PASSWORD_REQUIRED")
end
end
end
@ -507,7 +500,7 @@ local function handleIncomingWormhole()
elseif (result == 3) then
-- Received a message
local message = state.lastReceivedMessage
debugChat("Received: " .. tostring(message))
utils.debug("Received: " .. tostring(message))
-- Check if it's a password attempt (don't log passwords in plaintext)
if message:sub(1, 14) == "IRIS_PASSWORD:" then
@ -748,7 +741,7 @@ local function handleOutgoingDial()
-- DEBUG: Print all messages received
print("DEBUG: Message received: " .. tostring(message))
utils.log("DEBUG: Message received: " .. tostring(message))
debugChat("Received: " .. tostring(message))
utils.debug("Received: " .. tostring(message))
if message and message:sub(1, 6) == "SGCS_V" then
state.remoteHasComputer = true
@ -807,7 +800,7 @@ local function handleOutgoingDial()
local password = HandlePasswordEntry()
utils.sendPasswordAttempt(password)
debugChat("Sent: IRIS_PASSWORD:" .. password)
utils.debug("Sent: IRIS_PASSWORD:" .. password)
-- Wait for response
local function WaitForResponse()