diff options
| author | Eblo <7004497+Eblo@users.noreply.github.com> | 2025-10-30 20:26:35 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-30 20:26:35 -0400 |
| commit | 8c9e6dca046941bebcb5d68170c686388e2596dd (patch) | |
| tree | 3bc7a36ca82c3c80f3c706b0275003f675a595e1 /mm/2s2h/Rando/ActorBehavior/ActorBehavior.cpp | |
| parent | 04cf7fbf0200db67946a430f6a5ef10289cb965d (diff) | |
Convert to ObjectExtension (#1299)
* Replace ActorExtension with ObjectExtension
* We only need cassert here, not all of LUS
* Expose ObjectExtension_Free to C++
* Remove unneeded vector include
Diffstat (limited to 'mm/2s2h/Rando/ActorBehavior/ActorBehavior.cpp')
| -rw-r--r-- | mm/2s2h/Rando/ActorBehavior/ActorBehavior.cpp | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/mm/2s2h/Rando/ActorBehavior/ActorBehavior.cpp b/mm/2s2h/Rando/ActorBehavior/ActorBehavior.cpp index af100a565..80a31b9b2 100644 --- a/mm/2s2h/Rando/ActorBehavior/ActorBehavior.cpp +++ b/mm/2s2h/Rando/ActorBehavior/ActorBehavior.cpp @@ -1,11 +1,16 @@ #include "ActorBehavior.h" #include <libultraship/bridge/consolevariablebridge.h> -#include "2s2h/ActorExtension/ActorExtension.h" +#include "2s2h/ObjectExtension/ObjectExtension.h" extern "C" { #include "variables.h" } +struct ActorRandoCheckId { + RandoCheckId randoCheckId = RC_UNKNOWN; +}; +static ObjectExtension::Register<ActorRandoCheckId> ActorRandoCheckIdRegister; + // This is kind of a catch-all for things that are simple enough to not need their own file. void MiscVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_list optionalArg) { switch (id) { @@ -28,32 +33,17 @@ void MiscVanillaBehaviorHandler(GIVanillaBehavior id, bool* should, va_list opti } } -ActorExtensionId randoCheckIdActorExt = 0; - RandoCheckId Rando::ActorBehavior::GetActorRandoCheckId(Actor* actor) { - RandoCheckId* actorRandoCheckId = (RandoCheckId*)ActorExtension_Get(actor, randoCheckIdActorExt); - if (actorRandoCheckId == NULL) { - return RC_UNKNOWN; - } - - return *actorRandoCheckId; + const ActorRandoCheckId* actorRandoCheckId = ObjectExtension::GetInstance().Get<ActorRandoCheckId>(actor); + return actorRandoCheckId != nullptr ? actorRandoCheckId->randoCheckId : RC_UNKNOWN; } -void Rando::ActorBehavior::SetActorRandoCheckId(Actor* actor, RandoCheckId rc) { - RandoCheckId* actorRandoCheckId = (RandoCheckId*)ActorExtension_Get(actor, randoCheckIdActorExt); - - if (actorRandoCheckId == NULL) { - assert(false); - } else { - *actorRandoCheckId = rc; - } +void Rando::ActorBehavior::SetActorRandoCheckId(const Actor* actor, RandoCheckId rc) { + ObjectExtension::GetInstance().Set<ActorRandoCheckId>(actor, ActorRandoCheckId{ rc }); } // Entry point for the module, run once on game boot void Rando::ActorBehavior::Init() { - if (randoCheckIdActorExt == 0) { - randoCheckIdActorExt = ActorExtension_CreateForAll(sizeof(RandoCheckId)); - } } void Rando::ActorBehavior::OnFileLoad() { |
