From ece78ddc8d2bbea147e2ca7d7f2161246c765cdb Mon Sep 17 00:00:00 2001 From: JamBox <8935453+JamesVanBoxtel@users.noreply.github.com> Date: Wed, 12 Nov 2025 18:05:07 -0800 Subject: [PATCH 1/2] Fix username changing We were accidentally overriding the functions even when you didn't have arguments passed in. Now only add them if set, and don't make extra unneeded globals. --- client/src/developer.lua | 48 +++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/client/src/developer.lua b/client/src/developer.lua index 06d51d55..67f73ca3 100644 --- a/client/src/developer.lua +++ b/client/src/developer.lua @@ -1,5 +1,6 @@ local system = require("client.src.system") local DebugSettings = require("client.src.debug.DebugSettings") +local logger = require("common.lib.logger") ---@diagnostic disable: duplicate-set-field -- Put any local development changes you need in here that you don't want commited. @@ -38,19 +39,20 @@ function developerTools.processArgs(args) GAME_UPDATER = require("updater.gameUpdater") else for match in string.gmatch(value, "user%-id=(.*)") do - CUSTOM_USER_ID = match + developerTools.customUserID = match end for match in string.gmatch(value, "username=(.*)") do - CUSTOM_USERNAME = match + developerTools.customUsername = match end end end end -local realId -local realName +local realName = nil + +function developerTools.wrapUsernameConfig(customUsername) + assert(customUsername) -function developerTools.wrapConfig() local read = readConfigFile local write = write_conf_file @@ -58,38 +60,38 @@ function developerTools.wrapConfig() ---@type UserConfig c = read(c) realName = c.name - c.name = CUSTOM_USERNAME or realName + logger.debug("Original username was " .. realName) + c.name = customUsername + logger.debug("Overwriting name to custom username: " .. c.name) end write_conf_file = function() - if config.name == CUSTOM_USERNAME then + if config.name == customUsername then + assert(realName) config.name = realName end write() - config.name = CUSTOM_USERNAME or realName + config.name = customUsername end end -function developerTools.wrapPersistence() - local save = require("client.src.save") +function developerTools.wrapUserIDRead(customUserID) + assert(customUserID) - local readId = save.read_user_id_file - save.read_user_id_file = function(serverIP) - realId = readId(serverIP) - return CUSTOM_USER_ID or realId - end + logger.debug("Overwriting userID with command line argument") - local writeId = save.write_user_id_file - save.write_user_id_file = function(userID, serverIP) - if userID == CUSTOM_USER_ID then - userID = realId - end - writeId(userID, serverIP) + local save = require("client.src.save") + save.read_user_id_file = function(serverIP) + return customUserID end end developerTools.processArgs(arg) -developerTools.wrapConfig() -developerTools.wrapPersistence() +if developerTools.customUsername then + developerTools.wrapUsernameConfig(developerTools.customUsername) +end +if developerTools.customUserID then + developerTools.wrapUserIDRead(developerTools.customUserID) +end return developerTools \ No newline at end of file From e2c65e905f5594889eac18172c02b9e18068ca3f Mon Sep 17 00:00:00 2001 From: JamBox <8935453+JamesVanBoxtel@users.noreply.github.com> Date: Thu, 13 Nov 2025 21:08:10 -0800 Subject: [PATCH 2/2] Restore ID protection --- client/src/developer.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/client/src/developer.lua b/client/src/developer.lua index 67f73ca3..5b034b01 100644 --- a/client/src/developer.lua +++ b/client/src/developer.lua @@ -48,6 +48,7 @@ function developerTools.processArgs(args) end end +local realId = nil local realName = nil function developerTools.wrapUsernameConfig(customUsername) @@ -81,9 +82,20 @@ function developerTools.wrapUserIDRead(customUserID) logger.debug("Overwriting userID with command line argument") local save = require("client.src.save") + local readId = save.read_user_id_file save.read_user_id_file = function(serverIP) + realId = readId(serverIP) return customUserID end + + local writeId = save.write_user_id_file + save.write_user_id_file = function(userID, serverIP) + if userID == customUserID then + userID = realId + end + assert(userID ~= nil) + writeId(userID, serverIP) + end end developerTools.processArgs(arg)