Skip to content

Commit

Permalink
minor style fixes for #33
Browse files Browse the repository at this point in the history
  • Loading branch information
ianpatt committed Jul 30, 2024
1 parent 0bf744a commit b4d6727
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
6 changes: 3 additions & 3 deletions sfse/GameEvents.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
Expand Down
14 changes: 9 additions & 5 deletions sfse/Hooks_Serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion sfse/Hooks_Serialization.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#pragma once

void Hooks_Serialization_Apply();
void Hooks_Serialization_Apply();
10 changes: 5 additions & 5 deletions sfse/Serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
{
Expand All @@ -179,4 +179,4 @@ namespace Serialization
_MESSAGE("skipped delete of co-save for file %s", filePath.c_str());
}
}
}
}
2 changes: 1 addition & 1 deletion sfse/Serialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ namespace Serialization
void HandleLoadGlobalData();

void HandleDeleteSave(std::string filePath);
}
}

0 comments on commit b4d6727

Please sign in to comment.