Only update overworld entities while the overworld scene is active

Entities (and the player's pause-to-open-game-menu handling with them)
previously kept updating every frame regardless of the active scene,
matching an existing TODO in rpgUpdate(). Gating the entity loop itself
means the game menu (and any other entity-driven input) naturally can't
trigger mid-battle or before the initial scene hands off to the
overworld, without needing a scene check at each individual call site.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-04 20:54:58 -05:00
parent e2a9442aa6
commit 1ddc298a74
+12 -6
View File
@@ -19,6 +19,7 @@
#include "assert/assert.h" #include "assert/assert.h"
#include "save/save.h" #include "save/save.h"
#include "error/error.h" #include "error/error.h"
#include "scene/scene.h"
#include "ui/rpg/uiemoji.h" #include "ui/rpg/uiemoji.h"
#include "rpg/story/storyflag.h" #include "rpg/story/storyflag.h"
@@ -80,12 +81,17 @@ errorret_t rpgUpdate(void) {
// TODO: Do not update if the scene is not the map scene? // TODO: Do not update if the scene is not the map scene?
errorChain(mapUpdate()); errorChain(mapUpdate());
// Update overworld ents. // Update overworld ents - only while actually in the overworld. Entities
entity_t *ent = &ENTITIES[0]; // (the player among them) keep existing across scene changes, but their
do { // input/movement/animation logic doesn't make sense to run mid-battle or
if(ent->type == ENTITY_TYPE_NULL) continue; // before the initial scene has handed off to the overworld.
entityUpdate(ent); if(SCENE.current == SCENE_TYPE_OVERWORLD) {
} while(++ent < &ENTITIES[ENTITY_COUNT]); entity_t *ent = &ENTITIES[0];
do {
if(ent->type == ENTITY_TYPE_NULL) continue;
entityUpdate(ent);
} while(++ent < &ENTITIES[ENTITY_COUNT]);
}
cutsceneSystemUpdate(); cutsceneSystemUpdate();
errorChain(rpgCameraUpdate()); errorChain(rpgCameraUpdate());