Skip to content

Commit

Permalink
OTRGlobals cleanup (HarbourMasters#4251)
Browse files Browse the repository at this point in the history
* Remove unused headers

* Move all "ResourceMgr_" functions to a new file

* Don't transitively include SaveManager

* Move cvar prefixes to a new header

* Add missing includes

* Update OTRGlobals.cpp

* Fix build

* Address review

* Fix some of the errors

* Update gameplaystats.h

* Update z_en_in.c

* Hopefully fix the linux issues

* Fix Linux issues for real this time, I checked

* Update ResourceManagerHelpers.cpp

* Update z_obj_mure2.c

* Post-merge fixes

* Fix build (hopefully)

* Post-merge fixes

* Update z_file_nameset_PAL.c

* cleanup some unnecessary headers (#7)

---------

Co-authored-by: Archez <[email protected]>
  • Loading branch information
Pepe20129 and Archez authored Nov 19, 2024
1 parent 70f3dfa commit 9bed5af
Show file tree
Hide file tree
Showing 258 changed files with 989 additions and 639 deletions.
2 changes: 1 addition & 1 deletion soh/include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "functions.h"
#include "variables.h"
#include "macros.h"
#include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#include "soh/Enhancements/gameconsole.h"
#include "soh/Enhancements/gameplaystats.h"
#include <libultraship/bridge.h>
Expand Down
1 change: 1 addition & 0 deletions soh/soh/Enhancements/audio/AudioCollection.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "AudioCollection.h"
#include "sequence.h"
#include "sfx.h"
#include "soh/cvar_prefixes.h"
#include <vector>
#include <utils/StringHelper.h>
#include <libultraship/bridge.h>
Expand Down
5 changes: 3 additions & 2 deletions soh/soh/Enhancements/audio/AudioEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
#include <libultraship/libultraship.h>
#include <functions.h>
#include "../randomizer/3drando/random.hpp"
#include "../../OTRGlobals.h"
#include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#include <utils/StringHelper.h>
#include "../../UIWidgets.hpp"
#include "soh/UIWidgets.hpp"
#include "AudioCollection.h"
#include "soh/Enhancements/game-interactor/GameInteractor.h"

Expand Down
1 change: 1 addition & 0 deletions soh/soh/Enhancements/bootcommands.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <stdarg.h>
#include <z64.h>
#include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"

uint8_t gLoadFileSelect = 0, gSkipLogoTest = 0;

Expand Down
1 change: 1 addition & 0 deletions soh/soh/Enhancements/controls/InputViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "libultraship/libultra/controller.h"
#include "Context.h"
#include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#ifndef IMGUI_DEFINE_MATH_OPERATORS
#define IMGUI_DEFINE_MATH_OPERATORS
#endif
Expand Down
1 change: 1 addition & 0 deletions soh/soh/Enhancements/controls/SohInputEditorWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "soh/OTRGlobals.h"
#include "../../UIWidgets.hpp"
#include "z64.h"
#include "soh/cvar_prefixes.h"
#ifndef __WIIU__
#include "controller/controldevice/controller/mapping/sdl/SDLAxisDirectionToButtonMapping.h"
#endif
Expand Down
5 changes: 2 additions & 3 deletions soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@

#include "soh/UIWidgets.hpp"
#include "soh/OTRGlobals.h"
#include "soh/ResourceManagerHelpers.h"

extern "C" {
#include <z64.h>
#include "macros.h"
#include "soh/cvar_prefixes.h"
extern PlayState* gPlayState;
#include "objects/object_link_boy/object_link_boy.h"
#include "objects/object_link_child/object_link_child.h"
Expand Down Expand Up @@ -48,9 +50,6 @@ extern PlayState* gPlayState;
#include "objects/object_gjyo_objects/object_gjyo_objects.h"
#include "textures/nintendo_rogo_static/nintendo_rogo_static.h"
#include "objects/object_gi_rabit_mask/object_gi_rabit_mask.h"
void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction);
void ResourceMgr_PatchGfxCopyCommandByName(const char* path, const char* patchName, int destinationIndex, int sourceIndex);
void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName);
u8 Randomizer_GetSettingValue(RandomizerSettingKey randoSettingKey);
}

Expand Down
7 changes: 2 additions & 5 deletions soh/soh/Enhancements/cosmetics/authenticGfxPatches.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <libultraship/bridge.h>
#include <string>
#include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#include "soh/ResourceManagerHelpers.h"

extern "C" {
#include <libultraship/libultra.h>
Expand All @@ -9,11 +11,6 @@ extern "C" {
#include "objects/object_gi_soldout/object_gi_soldout.h"
#include "objects/object_ik/object_ik.h"
#include "objects/object_link_child/object_link_child.h"

uint32_t ResourceMgr_GameHasMasterQuest();
uint32_t ResourceMgr_GameHasOriginal();
void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction);
void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName);
}

typedef struct {
Expand Down
1 change: 1 addition & 0 deletions soh/soh/Enhancements/debugconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <vector>
#include <string>
#include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#include <soh/Enhancements/item-tables/ItemTableManager.h>
#include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "soh/Enhancements/cosmetics/CosmeticsEditor.h"
Expand Down
1 change: 1 addition & 0 deletions soh/soh/Enhancements/debugger/MessageViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "../custom-message/CustomMessageManager.h"
#include "functions.h"
#include "macros.h"
#include "soh/cvar_prefixes.h"
#include "message_data_static.h"
#include "variables.h"
#include "soh/util.h"
Expand Down
1 change: 1 addition & 0 deletions soh/soh/Enhancements/debugger/actorViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <libultraship/bridge.h>
#include <libultraship/libultraship.h>
#include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"

extern "C" {
#include <z64.h>
Expand Down
1 change: 1 addition & 0 deletions soh/soh/Enhancements/debugger/colViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ extern "C" {
#include "variables.h"
#include "functions.h"
#include "macros.h"
#include "soh/cvar_prefixes.h"
extern PlayState* gPlayState;
}

Expand Down
1 change: 1 addition & 0 deletions soh/soh/Enhancements/debugger/debugSaveEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extern "C" {
#include "variables.h"
#include "functions.h"
#include "macros.h"
#include "soh/cvar_prefixes.h"
#include "soh/Enhancements/randomizer/adult_trade_shuffle.h"
extern PlayState* gPlayState;

Expand Down
1 change: 1 addition & 0 deletions soh/soh/Enhancements/debugger/valueViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ extern "C" {
#include "variables.h"
#include "functions.h"
#include "macros.h"
#include "soh/cvar_prefixes.h"
extern PlayState* gPlayState;
void GfxPrint_SetColor(GfxPrint* printer, u32 r, u32 g, u32 b, u32 a);
void GfxPrint_SetPos(GfxPrint* printer, s32 x, s32 y);
Expand Down
4 changes: 2 additions & 2 deletions soh/soh/Enhancements/enemyrandomizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
#include "soh/Enhancements/enhancementTypes.h"
#include "variables.h"
#include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#include "soh/ResourceManagerHelpers.h"

extern "C" {
#include <z64.h>
}

extern "C" uint32_t ResourceMgr_IsSceneMasterQuest(s16 sceneNum);

const char* enemyCVarList[] = {
CVAR_ENHANCEMENT("RandomizedEnemyList.Armos"), CVAR_ENHANCEMENT("RandomizedEnemyList.Arwing"),
CVAR_ENHANCEMENT("RandomizedEnemyList.BabyDodongo"), CVAR_ENHANCEMENT("RandomizedEnemyList.Bari"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
extern "C" {
#include "variables.h"
#include "macros.h"
#include "soh/cvar_prefixes.h"
#include "functions.h"
extern PlayState* gPlayState;
}
Expand Down
3 changes: 1 addition & 2 deletions soh/soh/Enhancements/gameplaystats.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
extern "C" {
#include "gameplaystats.h"
}
#include "gameplaystatswindow.h"

#include "soh/SaveManager.h"
#include "functions.h"
#include "macros.h"
#include "soh/cvar_prefixes.h"
#include "../UIWidgets.hpp"
#include "soh/util.h"

Expand Down
13 changes: 12 additions & 1 deletion soh/soh/Enhancements/gameplaystats.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
#pragma once

#include "soh/cvar_prefixes.h"
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif
uint64_t GetUnixTimestamp(void);
char* GameplayStats_GetCurrentTime();
#ifdef __cplusplus
};
#endif

// When using RTA timing
// get the diff since the save was created,
// unless the game is complete in which we use the defeated ganon timestamp
Expand All @@ -17,7 +29,6 @@
gSaveContext.sohStats.sceneTimer)

void InitStatTracker();
char* GameplayStats_GetCurrentTime();

typedef enum {
// 0x00 to 0x9B (0 to 155) used for getting items,
Expand Down
7 changes: 4 additions & 3 deletions soh/soh/Enhancements/mods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include "game-interactor/GameInteractor.h"
#include "tts/tts.h"
#include "soh/OTRGlobals.h"
#include "soh/SaveManager.h"
#include "soh/ResourceManagerHelpers.h"
#include "soh/Enhancements/boss-rush/BossRushTypes.h"
#include "soh/Enhancements/boss-rush/BossRush.h"
#include "soh/Enhancements/enhancementTypes.h"
#include "soh/Enhancements/randomizer/3drando/random.hpp"
Expand Down Expand Up @@ -41,17 +44,15 @@ extern "C" {
#include <z64.h>
#include "align_asset_macro.h"
#include "macros.h"
#include "soh/cvar_prefixes.h"
#include "functions.h"
#include "variables.h"
#include "functions.h"
#include "src/overlays/actors/ovl_En_Door/z_en_door.h"
void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction);
void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName);

extern SaveContext gSaveContext;
extern PlayState* gPlayState;
extern void Overlay_DisplayText(float duration, const char* text);
uint32_t ResourceMgr_IsSceneMasterQuest(s16 sceneNum);
}

// GreyScaleEndDlist
Expand Down
1 change: 1 addition & 0 deletions soh/soh/Enhancements/nametag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
extern "C" {
#include "z64.h"
#include "macros.h"
#include "soh/cvar_prefixes.h"
#include "functions.h"
#include "variables.h"
#include "textures/message_static/message_static.h"
Expand Down
1 change: 1 addition & 0 deletions soh/soh/Enhancements/presets.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "soh/Enhancements/randomizer/randomizerTypes.h"
#include "soh/Enhancements/enhancementTypes.h"
#include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"

enum PresetEntryType {
PRESET_ENTRY_TYPE_S32,
Expand Down
1 change: 1 addition & 0 deletions soh/soh/Enhancements/randomizer/3drando/playthrough.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "soh/Enhancements/randomizer/randomizerTypes.h"
#include "variables.h"
#include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#include "../option.h"
#include "soh/Enhancements/debugger/performanceTimer.h"

Expand Down
1 change: 1 addition & 0 deletions soh/soh/Enhancements/randomizer/3drando/rando_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <Context.h>
#include <libultraship/libultra/types.h>
#include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"

void RandoMain::GenerateRando(std::set<RandomizerCheck> excludedLocations, std::set<RandomizerTrick> enabledTricks,
std::string seedString) {
Expand Down
1 change: 1 addition & 0 deletions soh/soh/Enhancements/randomizer/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "functions.h"
#include "variables.h"
#include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#include "randomizerTypes.h"
#include <array>
#include "objects/object_gi_key/object_gi_key.h"
Expand Down
4 changes: 3 additions & 1 deletion soh/soh/Enhancements/randomizer/hook_handlers.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <libultraship/bridge.h>
#include "soh/OTRGlobals.h"
#include "soh/ResourceManagerHelpers.h"
#include "soh/Enhancements/enhancementTypes.h"
#include "soh/Enhancements/custom-message/CustomMessageTypes.h"
#include "soh/Enhancements/item-tables/ItemTableManager.h"
Expand All @@ -10,6 +11,7 @@
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#include "soh/ImGuiUtils.h"
#include "soh/Notification/Notification.h"
#include "soh/SaveManager.h"

extern "C" {
#include "macros.h"
Expand Down Expand Up @@ -1834,7 +1836,7 @@ void RandomizerOnActorInitHandler(void* actorRef) {
if (
actor->id == ACTOR_OBJ_OSHIHIKI &&
LINK_IS_CHILD &&
IsGameMasterQuest() &&
ResourceMgr_IsGameMasterQuest() &&
gPlayState->sceneNum == SCENE_SPIRIT_TEMPLE && actor->room == 6 && // Spirit Temple silver block hallway
actor->params == 0x9C7 // Silver block that is marked as in the hole
) {
Expand Down
7 changes: 3 additions & 4 deletions soh/soh/Enhancements/randomizer/randomizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#include <textures/icon_item_24_static/icon_item_24_static.h>
#include "3drando/rando_main.hpp"
#include "3drando/random.hpp"
#include "3drando/custom_messages.hpp"
#include "soh/ResourceManagerHelpers.h"
#include "soh/UIWidgets.hpp"
#include "3drando/custom_messages.hpp"
#include "../../UIWidgets.hpp"
#ifndef IMGUI_DEFINE_MATH_OPERATORS
#define IMGUI_DEFINE_MATH_OPERATORS
Expand Down Expand Up @@ -41,9 +43,6 @@
#include "fishsanity.h"
#include "randomizerTypes.h"

extern "C" uint32_t ResourceMgr_IsGameMasterQuest();
extern "C" uint32_t ResourceMgr_IsSceneMasterQuest(s16 sceneNum);

extern std::map<RandomizerCheckArea, std::string> rcAreaNames;

using json = nlohmann::json;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <libultraship/bridge.h>
#include "z64.h"
#include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#include "fishsanity.h"

std::map<RandomizerCheckArea, std::string> rcAreaNames = {
Expand Down
8 changes: 5 additions & 3 deletions soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
#include "randomizer_entrance_tracker.h"
#include "randomizer_item_tracker.h"
#include "randomizerTypes.h"
#include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#include "soh/SaveManager.h"
#include "soh/ResourceManagerHelpers.h"
#include "soh/UIWidgets.hpp"
#include "dungeon.h"
#include "../../OTRGlobals.h"
#include "../../UIWidgets.hpp"
#include "3drando/location_access.hpp"

#include <string>
Expand All @@ -24,7 +27,6 @@ extern "C" {
#include "macros.h"
extern PlayState* gPlayState;
}
extern "C" uint32_t ResourceMgr_IsSceneMasterQuest(s16 sceneNum);
extern "C" GetItemEntry ItemTable_RetrieveEntry(s16 modIndex, s16 getItemID);

extern std::vector<ItemTrackerItem> dungeonRewardStones;
Expand Down
2 changes: 2 additions & 0 deletions soh/soh/Enhancements/randomizer/randomizer_entrance.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include "randomizer_entrance.h"
#include "randomizer_grotto.h"
#include "soh/OTRGlobals.h"
#include "soh/SaveManager.h"
#include <string.h>

#include "global.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "randomizer_entrance_tracker.h"
#include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#include "soh/UIWidgets.hpp"

#include <map>
Expand Down
1 change: 1 addition & 0 deletions soh/soh/Enhancements/randomizer/randomizer_grotto.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

#include "randomizer_grotto.h"
#include "soh/OTRGlobals.h"

#include "global.h"

Expand Down
10 changes: 6 additions & 4 deletions soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#include "randomizer_item_tracker.h"
#include "../../util.h"
#include "../../OTRGlobals.h"
#include "../../UIWidgets.hpp"
#include "soh/util.h"
#include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
#include "soh/SaveManager.h"
#include "soh/ResourceManagerHelpers.h"
#include "soh/UIWidgets.hpp"
#include "randomizerTypes.h"

#include <map>
Expand All @@ -22,7 +25,6 @@ extern PlayState* gPlayState;
#include "textures/icon_item_static/icon_item_static.h"
#include "textures/icon_item_24_static/icon_item_24_static.h"
}
extern "C" uint32_t ResourceMgr_IsSceneMasterQuest(s16 sceneNum);

void DrawEquip(ItemTrackerItem item);
void DrawItem(ItemTrackerItem item);
Expand Down
Loading

0 comments on commit 9bed5af

Please sign in to comment.