@@ -149,6 +149,7 @@ func handle_override_cfg() -> void:
149149func handle_injection () -> void :
150150 var is_embedded : bool = not FileAccess .file_exists (path .pck )
151151 var injection_path : String = path .exe if is_embedded else path .pck
152+ var file_extension := injection_path .get_extension ()
152153
153154 ModLoaderSetupLog .debug ("Start injection" , LOG_NAME )
154155 # Create temp dir
@@ -173,61 +174,52 @@ func handle_injection() -> void:
173174 # Save the global class cache config file
174175 combined_global_script_class_cache_file .save (path .temp_global_script_class_cache_path )
175176
176- inject (injection_path )
177+ inject (injection_path , is_embedded )
177178
178179 # Rename vanilla
179- if not is_embedded :
180- DirAccess .rename_absolute (
181- path .pck ,
182- path .pck .trim_suffix ("%s .pck" % file_name .pck ).path_join (
183- "%s -vanilla.pck" % file_name .pck
184- )
185- )
186- ModLoaderSetupLog .debug (
187- (
188- 'Renamed "%s " to "%s "'
189- % [
190- path .pck ,
191- path .pck .trim_suffix ("%s .pck" % file_name .pck ).path_join (
192- "%s -vanilla.pck" % file_name .pck
193- )
194- ]
195- ),
196- LOG_NAME
197- )
198- # Rename modded
199- DirAccess .rename_absolute (
200- path .game_base_dir .path_join ("%s -modded.pck" % file_name .pck ),
201- "%s .pck" % path .game_base_dir .path_join (file_name .pck )
202- )
203- ModLoaderSetupLog .debug (
204- (
205- 'Renamed "%s " to "%s "'
206- % [
207- path .game_base_dir .path_join ("%s -modded.pck" % file_name .pck ),
208- "%s .pck" % path .game_base_dir .path_join (file_name .pck )
209- ]
210- ),
211- LOG_NAME
212- )
180+ var modded_path := "%s -modded.%s " % [injection_path .get_basename (), file_extension ]
181+ var vanilla_path := "%s -vanilla.%s " % [injection_path .get_basename (), file_extension ]
182+
183+ DirAccess .rename_absolute (injection_path , vanilla_path )
184+ ModLoaderSetupLog .debug ('Renamed "%s " to "%s "' % [injection_path , vanilla_path ], LOG_NAME )
213185
214- # clean_up()
186+ # Rename modded
187+ DirAccess .rename_absolute (modded_path , injection_path )
188+ ModLoaderSetupLog .debug ('Renamed "%s " to "%s "' % [modded_path , injection_path ], LOG_NAME )
189+
190+ clean_up ()
215191
216192
217193# Add modified binary to the pck
218- func inject (injection_path : String ) -> void :
219- var arguments := [
220- "--pck-patch=%s " % injection_path ,
221- "--patch-file=%s =%s " % [path .temp_project_binary_path , path .project_binary_path_internal ],
194+ func inject (injection_path : String , is_embedded := false ) -> void :
195+ var arguments := []
196+ arguments .push_back ("--pck-patch=%s " % injection_path )
197+ if is_embedded :
198+ arguments .push_back ("--embed=%s " % injection_path )
199+ arguments .push_back (
200+ "--patch-file=%s =%s " % [path .temp_project_binary_path , path .project_binary_path_internal ]
201+ )
202+ arguments .push_back (
222203 (
223204 "--patch-file=%s =%s "
224205 % [
225206 path .temp_global_script_class_cache_path ,
226207 path .global_script_class_cache_path_internal
227208 ]
228- ),
229- "--output=%s " % path .game_base_dir .path_join ("%s -modded.pck" % file_name .pck ),
230- ]
209+ )
210+ )
211+ arguments .push_back (
212+ (
213+ "--output=%s "
214+ % path .game_base_dir .path_join (
215+ (
216+ "%s -modded.%s "
217+ % [file_name [injection_path .get_extension ()], injection_path .get_extension ()]
218+ )
219+ )
220+ )
221+ )
222+
231223 # For unknown reasons the output only displays a single "[" - so only the executed arguments are logged.
232224 ModLoaderSetupLog .debug ("Injection started: %s %s " % [path .gdre , arguments ], LOG_NAME )
233225 var output := []
0 commit comments