Skip to content

Commit

Permalink
rename isBattle -> context
Browse files Browse the repository at this point in the history
  • Loading branch information
z64a committed Sep 30, 2024
1 parent c767b44 commit a6d9583
Show file tree
Hide file tree
Showing 41 changed files with 146 additions and 146 deletions.
2 changes: 1 addition & 1 deletion include/common_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@ typedef struct GameStatus {
/* 0x06A */ s8 demoStickX;
/* 0x06B */ s8 demoStickY;
/* 0x06C */ s32 mainScriptID;
/* 0x070 */ s8 isBattle;
/* 0x070 */ s8 context;
/* 0x071 */ s8 demoState; // see DemoState enum
/* 0x072 */ s8 nextDemoScene; /* which part of the demo to play next */
/* 0x073 */ u8 contBitPattern;
Expand Down
8 changes: 4 additions & 4 deletions include/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -3526,10 +3526,10 @@ enum EffectGfxDataFlags {

#include "move_enum.h"

enum MainState{
MAIN_STATE_WORLD = 0,
MAIN_STATE_BATTLE = 1,
MAIN_STATE_PAUSE = 2,
enum GameContext {
CONTEXT_WORLD = 0,
CONTEXT_BATTLE = 1,
CONTEXT_PAUSE = 2,
};

enum DemoState {
Expand Down
6 changes: 3 additions & 3 deletions src/111f0_len_860.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void state_step_enter_world(void) {
break;
}

gGameStatusPtr->isBattle = MAIN_STATE_WORLD;
gGameStatusPtr->context = CONTEXT_WORLD;
gGameStatusPtr->debugScripts = DEBUG_SCRIPTS_NONE;

if (!gLoadedFromFileSelect) {
Expand Down Expand Up @@ -155,7 +155,7 @@ void state_step_change_map(void) {
if (gMapTransitionStateTime != 0) {
gMapTransitionStateTime--;
} else {
gGameStatusPtr->isBattle = MAIN_STATE_WORLD;
gGameStatusPtr->context = CONTEXT_WORLD;
gGameStatusPtr->debugScripts = DEBUG_SCRIPTS_NONE;
load_map_by_IDs(gGameStatusPtr->areaID, gGameStatusPtr->mapID, LOAD_FROM_MAP);
set_time_freeze_mode(TIME_FREEZE_NORMAL);
Expand Down Expand Up @@ -230,7 +230,7 @@ void state_step_game_over(void) {
if (gMapTransitionStateTime != 0) {
gMapTransitionStateTime--;
} else {
gGameStatusPtr->isBattle = MAIN_STATE_WORLD;
gGameStatusPtr->context = CONTEXT_WORLD;
gGameStatusPtr->debugScripts = DEBUG_SCRIPTS_NONE;
load_map_by_IDs(gGameStatusPtr->areaID, gGameStatusPtr->mapID, LOAD_FROM_MAP);
nuContRmbForceStopEnd();
Expand Down
4 changes: 2 additions & 2 deletions src/77480.c
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ void check_for_pulse_stone(void) {
return;
}

if (gGameStatusPtr->areaID != AREA_SBK || gGameStatusPtr->isBattle != MAIN_STATE_WORLD) {
if (gGameStatusPtr->areaID != AREA_SBK || gGameStatusPtr->context != CONTEXT_WORLD) {
return;
}

Expand Down Expand Up @@ -1318,7 +1318,7 @@ void clear_interact_prompt(void) {
void update_partner_timers(void) {
PlayerData* playerData = &gPlayerData;

if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
if (gGameStatusPtr->context == CONTEXT_WORLD) {
s32 i;

for (i = 1; i < ARRAY_COUNT(playerData->partnerUnlockedTime); i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/8a860_len_3f30.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void destroy_popup_menu(void) {
gPopupMenu->popupType == POPUP_TYPE_TRADE_FOR_BADGE ||
gPopupMenu->popupType == POPUP_TYPE_UPGRADE_PARTNER ||
gPopupMenu->popupType == POPUP_TYPE_USE_KEY
) && gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
) && gGameStatusPtr->context == CONTEXT_WORLD) {
if (!PopupMenu_WasStatusBarIgnoringChanges) {
status_bar_respond_to_changes();
}
Expand Down
16 changes: 8 additions & 8 deletions src/animator.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void free_animator_nodes(AnimatorNode* root) {
void clear_animator_list(void) {
s32 i;

if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
if (gGameStatusPtr->context == CONTEXT_WORLD) {
gCurrentAnimMeshListPtr = &D_801539C0;
for (i = 0; i < ARRAY_COUNT(D_801533C0); i++) {
D_801533C0[i].ttl = -1;
Expand Down Expand Up @@ -212,7 +212,7 @@ void clear_animator_list(void) {
}

void reset_animator_list(void) {
if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
if (gGameStatusPtr->context == CONTEXT_WORLD) {
gCurrentAnimMeshListPtr = &D_801539C0;
} else {
gCurrentAnimMeshListPtr = &D_80153A00;
Expand Down Expand Up @@ -311,7 +311,7 @@ s32 create_model_animator(s16* animPos) {
animator->staticNodeIDs[j] = j + 1;
}

if (gGameStatusPtr->isBattle != MAIN_STATE_WORLD) {
if (gGameStatusPtr->context != CONTEXT_WORLD) {
i |= BATTLE_ID_BIT;
}
return i;
Expand Down Expand Up @@ -351,7 +351,7 @@ s32 create_mesh_animator(s16* animPos, s16* animBuffer) {
animator->staticNodeIDs[j] = j + 1;
}

if (gGameStatusPtr->isBattle != MAIN_STATE_WORLD) {
if (gGameStatusPtr->context != CONTEXT_WORLD) {
i |= BATTLE_ID_BIT;
}
return i;
Expand Down Expand Up @@ -434,7 +434,7 @@ void update_model_animator(s32 animatorID) {
s32 temp;
s32 i;

if (gGameStatusPtr->isBattle != MAIN_STATE_WORLD && !(animatorID & BATTLE_ID_BIT)) {
if (gGameStatusPtr->context != CONTEXT_WORLD && !(animatorID & BATTLE_ID_BIT)) {
return;
}

Expand Down Expand Up @@ -498,7 +498,7 @@ void update_model_animator_with_transform(s32 animatorID, Mtx* mtx) {
s32 temp;
s32 i;

if (gGameStatusPtr->isBattle != MAIN_STATE_WORLD && !(animatorID & BATTLE_ID_BIT)) {
if (gGameStatusPtr->context != CONTEXT_WORLD && !(animatorID & BATTLE_ID_BIT)) {
return;
}

Expand Down Expand Up @@ -717,7 +717,7 @@ void render_animated_model(s32 animatorID, Mtx* rootTransform) {
RenderTask rt;
RenderTask* rtPtr = &rt;

if (gGameStatusPtr->isBattle != MAIN_STATE_WORLD && !(animatorID & BATTLE_ID_BIT)) {
if (gGameStatusPtr->context != CONTEXT_WORLD && !(animatorID & BATTLE_ID_BIT)) {
return;
}

Expand Down Expand Up @@ -747,7 +747,7 @@ void render_animated_model_with_vertices(s32 animatorID, Mtx* rootTransform, s32
RenderTask rt;
RenderTask* rtPtr = &rt;

if (gGameStatusPtr->isBattle != MAIN_STATE_WORLD && !(animatorID & BATTLE_ID_BIT)) {
if (gGameStatusPtr->context != CONTEXT_WORLD && !(animatorID & BATTLE_ID_BIT)) {
return;
}

Expand Down
6 changes: 3 additions & 3 deletions src/audio/sfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ void sfx_clear_sounds(void) {

// name might be incorrect?
void sfx_clear_env_sounds(s16 playSounds) {
if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
if (gGameStatusPtr->context == CONTEXT_WORLD) {
gCurrentEnvSounds = wEnvSounds;
} else {
gCurrentEnvSounds = bEnvSounds;
Expand Down Expand Up @@ -362,7 +362,7 @@ void sfx_stop_env_sounds(void) {
SoundInstance* sound;
s32 i;

if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
if (gGameStatusPtr->context == CONTEXT_WORLD) {
gCurrentEnvSounds = wEnvSounds;
} else {
gCurrentEnvSounds = bEnvSounds;
Expand Down Expand Up @@ -619,7 +619,7 @@ void sfx_compute_spatialized_sound_params_ignore_depth(f32 x, f32 y, f32 z, s16*
*volume = 1;
}

if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
if (gGameStatusPtr->context == CONTEXT_WORLD) {
// 25/75 at screen edge
*pan = (screenX * 0.2f) + 32.0f;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/battle/battle.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void load_demo_battle(u32 index) {
gGameStatusPtr->demoBattleFlags = 0;
gGameStatusPtr->areaID = 0;
gGameStatusPtr->mapID = 0;
gGameStatusPtr->isBattle = MAIN_STATE_WORLD;
gGameStatusPtr->context = CONTEXT_WORLD;

general_heap_create();
clear_worker_list();
Expand Down
10 changes: 5 additions & 5 deletions src/effects.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void update_effects(void) {
if (effectInstance != NULL && (effectInstance->flags & FX_INSTANCE_FLAG_ENABLED)) {
effectInstance->graphics->flags &= ~FX_GRAPHICS_CAN_FREE;

if (gGameStatusPtr->isBattle != MAIN_STATE_WORLD) {
if (gGameStatusPtr->context != CONTEXT_WORLD) {
if (effectInstance->flags & FX_INSTANCE_FLAG_BATTLE) {
effectInstance->graphics->update(effectInstance);
effectInstance->flags |= FX_INSTANCE_FLAG_HAS_UPDATED;
Expand Down Expand Up @@ -116,7 +116,7 @@ void render_effects_world(void) {
if (effectInstance != NULL) {
if (effectInstance->flags & FX_INSTANCE_FLAG_ENABLED) {
if (effectInstance->flags & FX_INSTANCE_FLAG_HAS_UPDATED) {
if (gGameStatusPtr->isBattle != MAIN_STATE_WORLD) {
if (gGameStatusPtr->context != CONTEXT_WORLD) {
if (effectInstance->flags & FX_INSTANCE_FLAG_BATTLE) {
effectInstance->graphics->renderWorld(effectInstance);
}
Expand All @@ -143,11 +143,11 @@ void render_effects_UI(void) {
if (effectInstance->flags & FX_INSTANCE_FLAG_HAS_UPDATED) {
void (*renderUI)(EffectInstance* effect);

if (gGameStatusPtr->isBattle != MAIN_STATE_WORLD && !(effectInstance->flags & FX_INSTANCE_FLAG_BATTLE)) {
if (gGameStatusPtr->context != CONTEXT_WORLD && !(effectInstance->flags & FX_INSTANCE_FLAG_BATTLE)) {
continue;
}

if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD && effectInstance->flags & FX_INSTANCE_FLAG_BATTLE) {
if (gGameStatusPtr->context == CONTEXT_WORLD && effectInstance->flags & FX_INSTANCE_FLAG_BATTLE) {
continue;
}

Expand Down Expand Up @@ -243,7 +243,7 @@ EffectInstance* create_effect_instance(EffectBlueprint* effectBp) {
effectBp->init(newEffectInst);
}

if (gGameStatusPtr->isBattle != MAIN_STATE_WORLD) {
if (gGameStatusPtr->context != CONTEXT_WORLD) {
newEffectInst->flags |= FX_INSTANCE_FLAG_BATTLE;
}
return newEffectInst;
Expand Down
2 changes: 1 addition & 1 deletion src/effects/fire_breath.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void fire_breath_render(EffectInstance* effect) {
renderTask.appendGfx = fire_breath_appendGfx;
renderTask.appendGfxArg = effect;

if (gGameStatusPtr->isBattle == MAIN_STATE_BATTLE) {
if (gGameStatusPtr->context == CONTEXT_BATTLE) {
renderTask.dist = data->pos.z + 1000.0f;
} else {
renderTask.dist = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/effects/lightning.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ EffectInstance* lightning_main(
s32 effectArg0;

load_effect(EFFECT_FLASHING_BOX_SHOCKWAVE);
if (gGameStatusPtr->isBattle == MAIN_STATE_BATTLE) {
if (gGameStatusPtr->context == CONTEXT_BATTLE) {
effectArg0 = FX_SHOCK_OVERLAY_LIGHTNING_BATTLE;
} else {
effectArg0 = FX_SHOCK_OVERLAY_LIGHTNING_WORLD;
Expand Down
2 changes: 1 addition & 1 deletion src/effects/lightning_bolt.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void lightning_bolt_render(EffectInstance *effect) {

renderTask.appendGfx = lightning_bolt_appendGfx;
renderTask.appendGfxArg = effect;
if (gGameStatusPtr->isBattle == MAIN_STATE_BATTLE) {
if (gGameStatusPtr->context == CONTEXT_BATTLE) {
renderTask.dist = data->tipPos.z + 1000.0f;
} else {
renderTask.dist = 10;
Expand Down
2 changes: 1 addition & 1 deletion src/effects/star.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void star_update(EffectInstance* effect) {
load_effect(EFFECT_LANDING_DUST);
landing_dust_main(0, data->pos.x, data->pos.y - 5.0f, data->pos.z, 0.0f);

if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
if (gGameStatusPtr->context == CONTEXT_WORLD) {
sfx_play_sound_at_position(SOUND_SEQ_SHOOTING_STAR_BOUNCE, SOUND_SPACE_DEFAULT, data->pos.x, data->pos.y, data->pos.z);
}

Expand Down
30 changes: 15 additions & 15 deletions src/entity.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ void render_entities(void) {
Entity* entity = get_entity_by_index(i);

if (entity != NULL) {
if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
if (gGameStatusPtr->context == CONTEXT_WORLD) {
if (gEntityHideMode != ENTITY_HIDE_MODE_0 &&
!(entity->flags & ENTITY_FLAG_IGNORE_DISTANCE_CULLING) &&
dist2D(gPlayerStatusPtr->pos.x,
Expand Down Expand Up @@ -541,7 +541,7 @@ Shadow* get_shadow_by_index(s32 index) {
EntityList* get_entity_list(void) {
EntityList* ret;

if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
if (gGameStatusPtr->context == CONTEXT_WORLD) {
ret = &gWorldEntityList;
} else {
ret = &gBattleEntityList;
Expand All @@ -552,7 +552,7 @@ EntityList* get_entity_list(void) {
ShadowList* get_shadow_list(void) {
ShadowList* ret;

if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
if (gGameStatusPtr->context == CONTEXT_WORLD) {
ret = &gWorldShadowList;
} else {
ret = &gBattleShadowList;
Expand Down Expand Up @@ -795,7 +795,7 @@ void clear_entity_data(b32 arg0) {
entity_updateCounter = 0;
D_80151304 = 0;

if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
if (gGameStatusPtr->context == CONTEXT_WORLD) {
gEntityHideMode = ENTITY_HIDE_MODE_0;
}

Expand All @@ -807,7 +807,7 @@ void clear_entity_data(b32 arg0) {
}
D_8014AFB0 = 255;

if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
if (gGameStatusPtr->context == CONTEXT_WORLD) {
wEntityDataLoadedSize = 0;
for (i = 0; i < MAX_ENTITIES; i++) {
wEntityBlueprint[i] = NULL;
Expand All @@ -819,7 +819,7 @@ void clear_entity_data(b32 arg0) {
}
}

if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
if (gGameStatusPtr->context == CONTEXT_WORLD) {
gEntityHeapBottom = WORLD_ENTITY_HEAP_BOTTOM;
gEntityHeapBase = WORLD_ENTITY_HEAP_BASE;
} else {
Expand All @@ -840,7 +840,7 @@ void clear_entity_data(b32 arg0) {
}

void init_entity_data(void) {
if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
if (gGameStatusPtr->context == CONTEXT_WORLD) {
gEntityHeapBottom = WORLD_ENTITY_HEAP_BOTTOM;
gEntityHeapBase = WORLD_ENTITY_HEAP_BASE;
reload_world_entity_data();
Expand Down Expand Up @@ -957,7 +957,7 @@ s32 is_entity_data_loaded(Entity* entity, EntityBlueprint* blueprint, s32* loade
*loadedEnd = 0;
ret = FALSE;

if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
if (gGameStatusPtr->context == CONTEXT_WORLD) {
blueprints = wEntityBlueprint;
} else {
blueprints = bEntityBlueprint;
Expand Down Expand Up @@ -1016,7 +1016,7 @@ void load_simple_entity_data(Entity* entity, EntityBlueprint* bp, s32 listIndex)
s32 totalSize;

entity->vertexSegment = 0xA;
if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
if (gGameStatusPtr->context == CONTEXT_WORLD) {
totalSize = wEntityDataLoadedSize;
} else {
totalSize = bEntityDataLoadedSize;
Expand All @@ -1038,7 +1038,7 @@ void load_simple_entity_data(Entity* entity, EntityBlueprint* bp, s32 listIndex)
get_entity_type(entity->listIndex);
}

if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
if (gGameStatusPtr->context == CONTEXT_WORLD) {
wEntityDataLoadedSize = totalSize;
} else {
bEntityDataLoadedSize = totalSize;
Expand Down Expand Up @@ -1091,7 +1091,7 @@ void load_split_entity_data(Entity* entity, EntityBlueprint* entityData, s32 lis
animBaseAddr = (void*)(gEntityHeapBottom + specialSize * 4 + dma1size * 4);
swizzlePointers = TRUE;
} else if (is_entity_data_loaded(entity, entityData, &loadedStart, &loadedEnd)) {
if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
if (gGameStatusPtr->context == CONTEXT_WORLD) {
totalLoaded = wEntityDataLoadedSize;
} else {
totalLoaded = bEntityDataLoadedSize;
Expand All @@ -1116,7 +1116,7 @@ void load_split_entity_data(Entity* entity, EntityBlueprint* entityData, s32 lis
totalLoaded += dma2size_2;
get_entity_type(entity->listIndex);

if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
if (gGameStatusPtr->context == CONTEXT_WORLD) {
wEntityDataLoadedSize = totalLoaded;
} else {
bEntityDataLoadedSize = totalLoaded;
Expand Down Expand Up @@ -1688,7 +1688,7 @@ s32 entity_raycast_down(f32* x, f32* y, f32* z, f32* hitYaw, f32* hitPitch, f32*
}

void set_standard_shadow_scale(Shadow* shadow, f32 height) {
if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
if (gGameStatusPtr->context == CONTEXT_WORLD) {
shadow->scale.x = 0.13 - (height / 2600.0f);
} else {
shadow->scale.x = 0.12 - (height / 3600.0f);
Expand All @@ -1701,7 +1701,7 @@ void set_standard_shadow_scale(Shadow* shadow, f32 height) {
}

void set_npc_shadow_scale(Shadow* shadow, f32 height, f32 npcRadius) {
if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
if (gGameStatusPtr->context == CONTEXT_WORLD) {
shadow->scale.x = 0.13 - (height / 2600.0f);
} else {
shadow->scale.x = 0.12 - (height / 3600.0f);
Expand All @@ -1722,7 +1722,7 @@ void set_peach_shadow_scale(Shadow* shadow, f32 scale) {
PlayerStatus* playerStatus = &gPlayerStatus;
f32 phi_f2 = 0.12f;

if (gGameStatusPtr->isBattle == MAIN_STATE_WORLD) {
if (gGameStatusPtr->context == CONTEXT_WORLD) {
switch (playerStatus->anim) {
case ANIM_Peach2_Carried:
case ANIM_Peach2_Thrown:
Expand Down
Loading

0 comments on commit a6d9583

Please sign in to comment.