From 982f598e012be511d5eefc32dee691be1334eb21 Mon Sep 17 00:00:00 2001 From: djevangelia <263709373+djevangelia@users.noreply.github.com> Date: Sat, 8 Aug 2026 22:39:09 +0200 Subject: [PATCH] Savestates, add `sEffectContext` (#7042) --- soh/include/functions.h | 2 +- soh/soh/Enhancements/savestates.cpp | 4 ++++ soh/src/code/z_eff_blure.c | 4 +++- soh/src/code/z_player_lib.c | 6 +++--- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/soh/include/functions.h b/soh/include/functions.h index b74aaa148c..7caab2bb85 100644 --- a/soh/include/functions.h +++ b/soh/include/functions.h @@ -186,7 +186,7 @@ void EnItem00_CustomItemsParticles(Actor* Parent, PlayState* play, GetItemEntry void EnItem00_SetupAction(EnItem00* this, EnItem00ActionFunc actionFunc); void func_8001E5C8(EnItem00* this, PlayState* play); void Item_DropCollectibleRandom(PlayState* play, Actor* fromActor, Vec3f* spawnPos, s16 params); -void EffectBlure_ChangeType(EffectBlure* this, int type); +void EffectBlureShip_ChangeType(EffectBlure* this, int type); void EffectBlure_AddVertex(EffectBlure* this, Vec3f* p1, Vec3f* p2); void EffectBlure_AddSpace(EffectBlure* this); void EffectBlure_Init1(void* thisx, void* initParamsx); diff --git a/soh/soh/Enhancements/savestates.cpp b/soh/soh/Enhancements/savestates.cpp index a7c26c6264..6ea87c1b8a 100644 --- a/soh/soh/Enhancements/savestates.cpp +++ b/soh/soh/Enhancements/savestates.cpp @@ -16,6 +16,7 @@ #include "savestate_serialize.h" extern "C" PlayState* gPlayState; +extern "C" EffectContext sEffectContext; extern "C" void BgDdanKd_SaveState(SaveStateCtx* ctx); extern "C" void BgDodoago_SaveState(SaveStateCtx* ctx); @@ -86,6 +87,7 @@ typedef struct SaveStateInfo { unsigned char audioHeapCopy[AUDIO_HEAP_SIZE]; SaveContext saveContextCopy; + EffectContext effectContextCopy; GameInfo gameInfoCopy; AudioContext audioContextCopy; uint32_t rngSeed; @@ -442,6 +444,7 @@ void SaveState::Save(void) { memcpy(&info->saveContextCopy, &gSaveContext, sizeof(gSaveContext)); memcpy(&info->gameInfoCopy, gGameInfo, sizeof(*gGameInfo)); + memcpy(&info->effectContextCopy, &sEffectContext, sizeof(sEffectContext)); // Various static data SaveOverlayStaticData(); @@ -459,6 +462,7 @@ void SaveState::Load(void) { memcpy(&gSaveContext, &info->saveContextCopy, sizeof(gSaveContext)); memcpy(gGameInfo, &info->gameInfoCopy, sizeof(*gGameInfo)); + memcpy(&sEffectContext, &info->effectContextCopy, sizeof(sEffectContext)); memcpy(gActiveSounds, info->gActiveSoundsCopy, sizeof(gActiveSounds)); memcpy(gSoundBankMuted, &info->gSoundBankMutedCopy, sizeof(info->gSoundBankMutedCopy)); diff --git a/soh/src/code/z_eff_blure.c b/soh/src/code/z_eff_blure.c index 28534cb6bc..56e5951495 100644 --- a/soh/src/code/z_eff_blure.c +++ b/soh/src/code/z_eff_blure.c @@ -73,7 +73,7 @@ void EffectBlure_AddVertex(EffectBlure* this, Vec3f* p1, Vec3f* p2) { } // SoH: dumb doo doo command to change the type of a weapon's blur on the fly. Link's Swords with unique trail colors. -void EffectBlure_ChangeType(EffectBlure* this, int type) { +void EffectBlureShip_ChangeType(EffectBlure* this, int type) { this->trailType = type; } @@ -206,6 +206,7 @@ s32 EffectBlure_Update(void* thisx) { static u8 changed = 0; u8 reset = 0; + // SoH switch (this->trailType) { case TRAIL_TYPE_BOOMERANG: if (CVarGetInteger(CVAR_COSMETIC("Trails.Boomerang.Changed"), 0)) { @@ -322,6 +323,7 @@ s32 EffectBlure_Update(void* thisx) { } } + // Vanilla code from here on if (this == NULL) { return 0; } diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c index fe2f783f0e..bf93c117c1 100644 --- a/soh/src/code/z_player_lib.c +++ b/soh/src/code/z_player_lib.c @@ -1807,7 +1807,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Ve D_80126080.x = this->unk_85C * 5000.0f; func_80090A28(this, sp124); if (this->meleeWeaponState != 0) { - EffectBlure_ChangeType(Effect_GetByIndex(this->meleeWeaponEffectIndex), TRAIL_TYPE_STICK); + EffectBlureShip_ChangeType(Effect_GetByIndex(this->meleeWeaponEffectIndex), TRAIL_TYPE_STICK); func_800906D4(play, this, sp124); } else { Math_Vec3f_Copy(&this->meleeWeaponInfo[0].tip, &sp124[0]); @@ -1829,8 +1829,8 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Ve D_80126080.x = 1500.0f; } else { D_80126080.x = sMeleeWeaponLengths[Player_GetMeleeWeaponHeld(this)]; - EffectBlure_ChangeType(Effect_GetByIndex(this->meleeWeaponEffectIndex), - sSwordTypes[Player_GetMeleeWeaponHeld(this)]); + EffectBlureShip_ChangeType(Effect_GetByIndex(this->meleeWeaponEffectIndex), + sSwordTypes[Player_GetMeleeWeaponHeld(this)]); } func_80090A28(this, spE4);