11local system = require (" client.src.system" )
22local DebugSettings = require (" client.src.debug.DebugSettings" )
3+ local logger = require (" common.lib.logger" )
34--- @diagnostic disable : duplicate-set-field
45
56-- Put any local development changes you need in here that you don't want commited.
@@ -38,58 +39,71 @@ function developerTools.processArgs(args)
3839 GAME_UPDATER = require (" updater.gameUpdater" )
3940 else
4041 for match in string.gmatch (value , " user%-id=(.*)" ) do
41- CUSTOM_USER_ID = match
42+ developerTools . customUserID = match
4243 end
4344 for match in string.gmatch (value , " username=(.*)" ) do
44- CUSTOM_USERNAME = match
45+ developerTools . customUsername = match
4546 end
4647 end
4748 end
4849end
4950
50- local realId
51- local realName
51+ local realId = nil
52+ local realName = nil
53+
54+ function developerTools .wrapUsernameConfig (customUsername )
55+ assert (customUsername )
5256
53- function developerTools .wrapConfig ()
5457 local read = readConfigFile
5558 local write = write_conf_file
5659
5760 readConfigFile = function (c )
5861 --- @type UserConfig
5962 c = read (c )
6063 realName = c .name
61- c .name = CUSTOM_USERNAME or realName
64+ logger .debug (" Original username was " .. realName )
65+ c .name = customUsername
66+ logger .debug (" Overwriting name to custom username: " .. c .name )
6267 end
6368
6469 write_conf_file = function ()
65- if config .name == CUSTOM_USERNAME then
70+ if config .name == customUsername then
71+ assert (realName )
6672 config .name = realName
6773 end
6874 write ()
69- config .name = CUSTOM_USERNAME or realName
75+ config .name = customUsername
7076 end
7177end
7278
73- function developerTools .wrapPersistence ()
74- local save = require (" client.src.save" )
79+ function developerTools .wrapUserIDRead (customUserID )
80+ assert (customUserID )
81+
82+ logger .debug (" Overwriting userID with command line argument" )
7583
84+ local save = require (" client.src.save" )
7685 local readId = save .read_user_id_file
7786 save .read_user_id_file = function (serverIP )
7887 realId = readId (serverIP )
79- return CUSTOM_USER_ID or realId
88+ return customUserID
8089 end
8190
8291 local writeId = save .write_user_id_file
8392 save .write_user_id_file = function (userID , serverIP )
84- if userID == CUSTOM_USER_ID then
93+ if userID == customUserID then
8594 userID = realId
8695 end
96+ assert (userID ~= nil )
8797 writeId (userID , serverIP )
8898 end
8999end
90100
91101developerTools .processArgs (arg )
92- developerTools .wrapConfig ()
93- developerTools .wrapPersistence ()
102+ if developerTools .customUsername then
103+ developerTools .wrapUsernameConfig (developerTools .customUsername )
104+ end
105+ if developerTools .customUserID then
106+ developerTools .wrapUserIDRead (developerTools .customUserID )
107+ end
94108
95109return developerTools
0 commit comments