summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Dubé <serprex@users.noreply.github.com>2026-03-23 16:27:20 +0000
committerGitHub <noreply@github.com>2026-03-23 16:27:20 +0000
commitc439d6213780df715feb6c7773d6f39bad2107a9 (patch)
tree45e97f2faafcb1bfd5d609764475b241919be85b
parent2cfb0f73dc993c3d3d19e84aea92954408632cc8 (diff)
Enemy rando: don't mutate ActorEntry (#6400)
-rw-r--r--soh/soh/Enhancements/ExtraModes/EnemyRandomizer.cpp19
-rw-r--r--soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h2
-rw-r--r--soh/src/code/z_actor.c2
3 files changed, 15 insertions, 8 deletions
diff --git a/soh/soh/Enhancements/ExtraModes/EnemyRandomizer.cpp b/soh/soh/Enhancements/ExtraModes/EnemyRandomizer.cpp
index e7b93484f..e3d311535 100644
--- a/soh/soh/Enhancements/ExtraModes/EnemyRandomizer.cpp
+++ b/soh/soh/Enhancements/ExtraModes/EnemyRandomizer.cpp
@@ -5,12 +5,10 @@
#include "soh/Enhancements/enhancementTypes.h"
#include "soh/ObjectExtension/ObjectExtension.h"
#include "variables.h"
-#include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#include "soh/ResourceManagerHelpers.h"
#include "soh/SohGui/MenuTypes.h"
#include "soh/SohGui/SohMenu.h"
-#include "soh/SohGui/SohGui.hpp"
extern "C" {
#include <z64.h>
@@ -627,11 +625,20 @@ void RegisterEnemyRandomizer() {
ActorContext* actorCtx = va_arg(args, ActorContext*);
ActorEntry* actorEntry = va_arg(args, ActorEntry*);
PlayState* play = va_arg(args, PlayState*);
- Actor* actor = va_arg(args, Actor*);
+ Actor** actor = va_arg(args, Actor**);
- if (!GetRandomizedEnemy(play, &actorEntry->id, &actorEntry->pos.x, &actorEntry->pos.y, &actorEntry->pos.z,
- &actorEntry->rot.x, &actorEntry->rot.y, &actorEntry->rot.z, &actorEntry->params)) {
- *should = false;
+ s16 actorId = actorEntry->id;
+ s16 posX = actorEntry->pos.x;
+ s16 posY = actorEntry->pos.y;
+ s16 posZ = actorEntry->pos.z;
+ s16 rotX = actorEntry->rot.x;
+ s16 rotY = actorEntry->rot.y;
+ s16 rotZ = actorEntry->rot.z;
+ s16 params = actorEntry->params;
+
+ *should = false;
+ if (GetRandomizedEnemy(play, &actorId, &posX, &posY, &posZ, &rotX, &rotY, &rotZ, &params)) {
+ *actor = Actor_Spawn(actorCtx, play, actorId, posX, posY, posZ, rotX, rotY, rotZ, params);
}
});
diff --git a/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h b/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h
index 2065c929d..aae11fe86 100644
--- a/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h
+++ b/soh/soh/Enhancements/game-interactor/vanilla-behavior/GIVanillaBehavior.h
@@ -2663,7 +2663,7 @@ typedef enum {
// - `*ActorContext`
// - `*ActorEntry`
// - `*PlayState`
- // - `*Actor`
+ // - `**Actor`
VB_SPAWN_ACTOR_ENTRY,
// #### `result`
diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c
index e999788a4..f0ca7c0cd 100644
--- a/soh/src/code/z_actor.c
+++ b/soh/src/code/z_actor.c
@@ -3471,7 +3471,7 @@ Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, PlayStat
gMapLoading = 1;
Actor* ret;
- if (GameInteractor_Should(VB_SPAWN_ACTOR_ENTRY, true, actorCtx, actorEntry, play, ret)) {
+ if (GameInteractor_Should(VB_SPAWN_ACTOR_ENTRY, true, actorCtx, actorEntry, play, &ret)) {
ret = Actor_Spawn(actorCtx, play, actorEntry->id, actorEntry->pos.x, actorEntry->pos.y, actorEntry->pos.z,
actorEntry->rot.x, actorEntry->rot.y, actorEntry->rot.z, actorEntry->params);
}