Enemy rando: don't mutate ActorEntry (#6395)

This commit is contained in:
Philip Dubé
2026-03-23 12:41:53 +00:00
committed by GitHub
parent 5f0c0c8e2f
commit ccdd8e63ff
3 changed files with 15 additions and 8 deletions

View File

@@ -5,12 +5,10 @@
#include "soh/Enhancements/enhancementTypes.h" #include "soh/Enhancements/enhancementTypes.h"
#include "soh/ObjectExtension/ObjectExtension.h" #include "soh/ObjectExtension/ObjectExtension.h"
#include "variables.h" #include "variables.h"
#include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h" #include "soh/cvar_prefixes.h"
#include "soh/ResourceManagerHelpers.h" #include "soh/ResourceManagerHelpers.h"
#include "soh/SohGui/MenuTypes.h" #include "soh/SohGui/MenuTypes.h"
#include "soh/SohGui/SohMenu.h" #include "soh/SohGui/SohMenu.h"
#include "soh/SohGui/SohGui.hpp"
extern "C" { extern "C" {
#include <z64.h> #include <z64.h>
@@ -627,11 +625,20 @@ void RegisterEnemyRandomizer() {
ActorContext* actorCtx = va_arg(args, ActorContext*); ActorContext* actorCtx = va_arg(args, ActorContext*);
ActorEntry* actorEntry = va_arg(args, ActorEntry*); ActorEntry* actorEntry = va_arg(args, ActorEntry*);
PlayState* play = va_arg(args, PlayState*); 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, s16 actorId = actorEntry->id;
&actorEntry->rot.x, &actorEntry->rot.y, &actorEntry->rot.z, &actorEntry->params)) { s16 posX = actorEntry->pos.x;
*should = false; 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);
} }
}); });

View File

@@ -2663,7 +2663,7 @@ typedef enum {
// - `*ActorContext` // - `*ActorContext`
// - `*ActorEntry` // - `*ActorEntry`
// - `*PlayState` // - `*PlayState`
// - `*Actor` // - `**Actor`
VB_SPAWN_ACTOR_ENTRY, VB_SPAWN_ACTOR_ENTRY,
// #### `result` // #### `result`

View File

@@ -3471,7 +3471,7 @@ Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, PlayStat
gMapLoading = 1; gMapLoading = 1;
Actor* ret; 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, 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); actorEntry->rot.x, actorEntry->rot.y, actorEntry->rot.z, actorEntry->params);
} }