diff --git a/sfse/GameEvents.h b/sfse/GameEvents.h index 8eb8339..82a5c9f 100644 --- a/sfse/GameEvents.h +++ b/sfse/GameEvents.h @@ -687,12 +687,12 @@ struct TESExitBleedoutEvent {}; struct TESExitFurnitureEvent {}; struct TESFormDeleteEvent { - u32 formId; //00 + u32 formId; // 00 }; struct TESFormIDRemapEvent { - u32 oldID; //00 - u32 newID; //04 + u32 oldID; // 00 + u32 newID; // 04 }; struct TESFurnitureEvent {}; struct TESGrabReleaseEvent {}; diff --git a/sfse/Hooks_Serialization.cpp b/sfse/Hooks_Serialization.cpp index 301c9f2..a81ec1b 100644 --- a/sfse/Hooks_Serialization.cpp +++ b/sfse/Hooks_Serialization.cpp @@ -36,7 +36,9 @@ void SaveGame_Hook(BGSSaveLoadGame* a_this, void* a_unk1, void* a_unk2, const ch { Serialization::SetSaveName(a_name, true); PluginManager::dispatchMessage(0, SFSEMessagingInterface::kMessage_PreSaveGame, (void*)a_name, (u32)strlen(a_name), NULL); + SaveGame_Original(a_this, a_unk1, a_unk2, a_name); + PluginManager::dispatchMessage(0, SFSEMessagingInterface::kMessage_PostSaveGame, (void*)a_name, (u32)strlen(a_name), NULL); Serialization::SetSaveName(NULL); } @@ -46,7 +48,9 @@ bool LoadGame_Hook(BGSSaveLoadGame* a_this, const char* a_name, void* a_unk1, vo Serialization::SetSaveName(a_name, false); Serialization::HandleBeginLoad(); PluginManager::dispatchMessage(0, SFSEMessagingInterface::kMessage_PreLoadGame, (void*)a_name, (u32)strlen(a_name), NULL); + bool result = LoadGame_Original(a_this, a_name, a_unk1, a_unk2); + PluginManager::dispatchMessage(0, SFSEMessagingInterface::kMessage_PostLoadGame, (void*)a_name, (u32)strlen(a_name), NULL); Serialization::HandleEndLoad(); Serialization::SetSaveName(NULL); @@ -83,23 +87,23 @@ bool VM_LoadGame_Hook(void* a_this, void* a_storage, void* a_handleReaderWriter, void Hooks_Serialization_Apply() { - //write call hooks for SaveGame, LoadGame & DeleteSaveFile + // write call hooks for SaveGame, LoadGame & DeleteSaveFile g_branchTrampoline.write5Call(SaveGame_Call.getUIntPtr(), (uintptr_t)SaveGame_Hook); g_branchTrampoline.write5Call(LoadGame_Call.getUIntPtr(), (uintptr_t)LoadGame_Hook); g_branchTrampoline.write5Call(DeleteSaveFile_Call.getUIntPtr(), (uintptr_t)DeleteSaveFile_Hook); - //get pointers to IVMSaveLoadInterface vfunc entries + // get pointers to IVMSaveLoadInterface vfunc entries uintptr_t VM_SaveGame_VFunc = VirtualMachine_IVMSaveLoadInterface_VTable.getUIntPtr() + (0x1 * 0x8); uintptr_t VM_LoadGame_VFunc = VirtualMachine_IVMSaveLoadInterface_VTable.getUIntPtr() + (0x2 * 0x8); uintptr_t VM_DropAllRunningData_VFunc = VirtualMachine_IVMSaveLoadInterface_VTable.getUIntPtr() + (0x7 * 0x8); - //save original vfuncs + // save original vfuncs VM_SaveGame_Original = *reinterpret_cast<_VM_SaveGame*>(VM_SaveGame_VFunc); VM_LoadGame_Original = *reinterpret_cast<_VM_LoadGame*>(VM_LoadGame_VFunc); VM_DropAllRunningData_Original = *reinterpret_cast<_VM_DropAllRunningData*>(VM_DropAllRunningData_VFunc); - //overwrite vfuncs + // overwrite vfuncs safeWrite64(VM_SaveGame_VFunc, (uintptr_t)VM_SaveGame_Hook); safeWrite64(VM_LoadGame_VFunc, (uintptr_t)VM_LoadGame_Hook); safeWrite64(VM_DropAllRunningData_VFunc, (uintptr_t)VM_DropAllRunningData_Hook); -} \ No newline at end of file +} diff --git a/sfse/Hooks_Serialization.h b/sfse/Hooks_Serialization.h index 77c6057..2ac6d01 100644 --- a/sfse/Hooks_Serialization.h +++ b/sfse/Hooks_Serialization.h @@ -1,3 +1,3 @@ #pragma once -void Hooks_Serialization_Apply(); \ No newline at end of file +void Hooks_Serialization_Apply(); diff --git a/sfse/Serialization.cpp b/sfse/Serialization.cpp index 40f7b10..5de0641 100644 --- a/sfse/Serialization.cpp +++ b/sfse/Serialization.cpp @@ -146,26 +146,26 @@ namespace Serialization { _MESSAGE("RevertGlobalData"); - //TODO: add implementation for revert callbacks. + // TODO: add implementation for revert callbacks. } void HandleSaveGlobalData() { _MESSAGE("SaveGlobalData"); - //TODO: add implementation for serialization & save callbacks. + // TODO: add implementation for serialization & save callbacks. } void HandleLoadGlobalData() { _MESSAGE("LoadGlobalData"); - //TODO: add implementation for deserialization & load callbacks. + // TODO: add implementation for deserialization & load callbacks. } void HandleDeleteSave(std::string filePath) { - //check if old file is gone + // check if old file is gone FileStream saveFile; if (!saveFile.open(filePath.c_str())) { @@ -179,4 +179,4 @@ namespace Serialization _MESSAGE("skipped delete of co-save for file %s", filePath.c_str()); } } -} \ No newline at end of file +} diff --git a/sfse/Serialization.h b/sfse/Serialization.h index c56e574..74bdaab 100644 --- a/sfse/Serialization.h +++ b/sfse/Serialization.h @@ -14,4 +14,4 @@ namespace Serialization void HandleLoadGlobalData(); void HandleDeleteSave(std::string filePath); -} \ No newline at end of file +}