Hello.
I've got the following code in my tp2 to patch saved games:
GET_DIRECTORY_ARRAY save_dir ~%USER_DIRECTORY%/save~ ~~
ACTION_PHP_EACH save_dir AS from => to BEGIN
ACTION_IF FILE_EXISTS ~%to%/baldur.sav~ AND FILE_EXISTS ~%to%/baldur.gam~ BEGIN
PRINT ~Updating saved game %to% ...~
COPY ~%to%/baldur.sav~ ~%to%~
EDIT_SAV_FILE 1 BEGIN
SPRINT file ~%SAV_FILE%~
PATCH_IF ((~%file%~ STRING_MATCHES_REGEXP ~^.*\.are$~)=0) BEGIN
READ_LONG 0x54 "actors_off"
READ_SHORT 0x58 "actors_cnt"
FOR (cnt=0; cnt<"%actors_cnt%"; cnt=cnt+1) BEGIN
READ_LONG ("%actors_off%"+0x110*cnt+0x30) "old"
SPRINTF old ~%x~ (old) //%~
PATCH_IF (VARIABLE_IS_SET $cd_animation_map(~%old%~)) BEGIN
TEXT_SPRINT new $cd_animation_map(~%old%~)
PATCH_IF (NOT ~%old%~ STRING_EQUAL_CASE ~%new%~) BEGIN
PATCH_PRINT ~Patching %file%: cre animation %old% => %new%~
WRITE_LONG ("%actors_off%"+0x110*cnt+0x30) "new"
END
END
READ_BYTE ("%actors_off%"+0x110*cnt+0x28) "actors_flags"
PATCH_IF (~%actors_flags%~ BAND BIT0) BEGIN
END ELSE BEGIN //CRE attached
READ_LONG ("%actors_off%"+0x110*cnt+0x88) "actors_emb_off"
PATCH_IF (actors_emb_off != 0) BEGIN
READ_LONG ("%actors_emb_off%"+0x28) "old"
SPRINTF old ~%x~ (old) //%~
PATCH_IF (VARIABLE_IS_SET $cd_animation_map(~%old%~)) BEGIN
TEXT_SPRINT new $cd_animation_map(~%old%~)
PATCH_IF (NOT ~%old%~ STRING_EQUAL_CASE ~%new%~) BEGIN
PATCH_PRINT ~Patching %file%: attached cre animation %old% => %new%~
WRITE_LONG ("%actors_emb_off%"+0x28) "new"
END
END
END
END
END
END
END
BUT_ONLY
COPY ~%to%/baldur.gam~ ~%to%~
READ_LONG 0x20 party_off
READ_LONG 0x24 party_cnt
FOR (cnt=0; cnt<"%party_cnt%"; cnt=cnt+1) BEGIN
READ_LONG ("%party_off%"+0x160*cnt+0x04) "cre_off"
READ_LONG ("%cre_off%"+0x28) "old"
SPRINTF old ~%x~ (old) //%~
PATCH_IF (VARIABLE_IS_SET $cd_animation_map(~%old%~)) BEGIN
TEXT_SPRINT new $cd_animation_map(~%old%~)
PATCH_IF (NOT ~%old%~ STRING_EQUAL_CASE ~%new%~) BEGIN
PATCH_PRINT ~Patching GAM file: party cre animation %old% => %new%~
WRITE_LONG ("%cre_off%"+0x28) "new"
END
END
END
BUT_ONLY
END
END
It works perfectly on BG:EE and BGII:EE, but fails to patch Siege of Dragonspear saves as they are stored in a different folder called "sodsave". I would like to change my code so that it checks whether "sodsave" exists and, if it does, it runs the patching routine for that folder as well; if it doesn't, it only runs the routine for "save".
My WeiDU is way rusty as it's been over a year since the last time I've written any. Could any of you lend a hand?