Skip to content

Commit e79abc8

Browse files
authored
Merge pull request #70 from Justin99x/master
Fix TPS Regression From New Character Fix
2 parents 9cd681d + 83e1896 commit e79abc8

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/save_options/hooks.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,24 @@ def save_game(_1: UObject, args: WrappedStruct, _3: Any, _4: BoundFunction) -> N
120120
save_options.options.any_option_changed = False
121121

122122

123-
@hook("WillowGame.WillowPlayerController:FinishSaveGameLoad", immediately_enable=True)
124-
def end_load_game(_1: UObject, args: WrappedStruct, _3: Any, _4: BoundFunction) -> None: # noqa: D103
125-
# We hook this to send data back to any registered mod save options. This gets called when
126-
# loading character in main menu also. No callback here because the timing of when this is
127-
# called doesn't make much sense to do anything with it. See hook on LoadPlayerSaveGame.
128-
129-
# Often we'll load a save from a character with no save data. We'll set all save options
130-
# to default first to cover for any missing data.
123+
@hook("WillowGame.WillowPlayerController:LoadGame", immediately_enable=True)
124+
def load_game(*_: Any) -> None: # noqa: D103
125+
# We hook this to set all options to default whenever a new character is loaded. This covers
126+
# both new characters and existing. Characters with existing save options will have their
127+
# options set in the EndLoadGame hook.
131128
for mod_save_options in registered_save_options.values():
132129
for save_option in mod_save_options.values():
133130
set_option_to_default(save_option)
134131

135-
save_game = args.SaveGame
132+
133+
@hook("WillowGame.WillowSaveGameManager:EndLoadGame", Type.POST, immediately_enable=True)
134+
def end_load_game(_1: UObject, _2: WrappedStruct, ret: Any, _4: BoundFunction) -> None: # noqa: D103
135+
# We hook this to send data back to any registered mod save options. This gets called when
136+
# loading character in main menu also. No callback here because the timing of when this is
137+
# called doesn't make much sense to do anything with it. See hook on LoadPlayerSaveGame.
138+
139+
# This function returns the new save game object, so use a post hook and grab it from `ret`
140+
save_game = ret
136141
if not save_game:
137142
return
138143
extracted_save_data = _extract_save_data(save_game.UnloadableDlcLockoutList)

0 commit comments

Comments
 (0)