Skip to content

Commit dfd60c8

Browse files
authored
[Rando] Fixes to ObjectViewer (HarbourMasters#147)
* Its Wingardia, not WingARDia.. pfft * Fix Bowser Arena entrance and exit. * Fix some level entrances and Star issues * Update for inter-level area changes. * Remove TODO comments that are done. * Fix pause exit not resetting previous entrance * clang * Fix linux build 1 * fix linux 2 * Fix Object Viewer for Windows * modify ifdef * clang
1 parent daac189 commit dfd60c8

16 files changed

Lines changed: 69 additions & 29 deletions

File tree

src/game/interaction.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,6 @@ u32 interact_star_or_key(struct MarioState *m, UNUSED u32 interactType, struct O
809809
m->interactObj = o;
810810
m->usedObj = o;
811811

812-
// TODO: Set starIndex data in RandoStaticCheck.
813812
starIndex = (o->oBehParams >> 24) & 0x1F;
814813
save_file_collect_star_or_key(m->numCoins, starIndex);
815814

src/game/level_update.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,7 @@ s32 play_mode_paused(void) {
10211021
if (gDebugLevelSelect) {
10221022
fade_into_special_warp(-9, 1);
10231023
} else {
1024+
CALL_EVENT(ExitLevel, gMenuOptSelectIndex);
10241025
initiate_warp(LEVEL_CASTLE, 1, 0x1F, 0);
10251026
fade_into_special_warp(0, 0);
10261027
gSavedCourseNum = COURSE_NONE;

src/game/save_file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ static void restore_save_file_data(s32 fileIndex, s32 srcSlot) {
261261
}
262262

263263
void save_file_do_save(s32 fileIndex) {
264-
CALL(SaveFileDoSave, fileIndex);
265-
266264
CALL_EVENT(OnGameFileSave, fileIndex);
265+
CALL(SaveFileDoSave, fileIndex);
266+
267267
if (gSaveFileModified) {
268268
// Compute checksum
269269
add_save_block_signature(&gSaveBuffer.files[fileIndex][0],

src/port/Rando/CheckTracker/CheckTracker.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ void DrawCheckTrackerList() {
8787
ImGui::BeginGroup();
8888
ImGui::Image(textureId, ImVec2(16.0f * checkTrackerScale, 16.0f * checkTrackerScale));
8989
ImGui::TableNextColumn();
90-
ImGui::TextColored(checkTextColor, Rando::StaticData::Checks[entry.randoCheckId].name);
90+
ImGui::TextColored(
91+
checkTextColor,
92+
convertEnumToReadableName(Rando::StaticData::Checks[entry.randoCheckId].name).c_str());
9193
if (randoSaveCheck.obtained) {
9294
ImGui::SameLine();
9395
RandoItemId randoItemId = Rando::StaticData::GetShuffledRandoItem(entry.randoCheckId);

src/port/Rando/CustomItem/CustomItem.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ void CustomItem::ObjectCollected(int16_t type, struct MarioState* mario, struct
5353
if (shuffled.randoCheckId == object->unused1) {
5454
previousCheckState = shuffled.obtained;
5555
shuffled.obtained = true;
56-
RANDO_SAVE_CHECKS(selectedFileNum)[shuffled.randoCheckId].obtained = true;
5756
}
5857
}
5958

@@ -127,6 +126,8 @@ void CustomItem::ObjectCollected(int16_t type, struct MarioState* mario, struct
127126
object->activeFlags = ACTIVE_FLAG_DEACTIVATED;
128127
object->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE;
129128
obj_mark_for_deletion(object);
129+
130+
save_file_do_save(selectedFileNum);
130131
}
131132

132133
void CustomItem::SetBehavior(struct Object* object, u32 modelId, RandoCheckId randoCheckId, RandoAct randoAct) {

src/port/Rando/GhostshipMenuRando.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ void GhostshipMenu::AddMenuRando() {
4242
.CVar(CVAR_RANDOMIZER_SETTING("GenerateLog"))
4343
.RaceDisable(false)
4444
.Options(CheckboxOptions().Tooltip("Generates a Spoiler Log in the randomizer folder.").DefaultValue(true));
45-
// TODO: populate combobox with existing spoiler logs
4645
AddWidget(path, "Load Existing Spoiler Log", WIDGET_CVAR_CHECKBOX)
4746
.CVar(CVAR_RANDOMIZER_SETTING("UseExistingLog"))
4847
.RaceDisable(false)
@@ -52,7 +51,8 @@ void GhostshipMenu::AddMenuRando() {
5251
});
5352
AddWidget(path, "Available Spoiler Logs", WIDGET_CUSTOM).CustomFunction([](WidgetInfo& info) {
5453
ImGui::BeginDisabled(!CVarGetInteger(CVAR_RANDOMIZER_SETTING("UseExistingLog"), 0));
55-
if (UIWidgets::CVarCombobox("Seed", CVAR_RANDOMIZER_SETTING("SpoilerFileIndex"), Rando::Spoiler::spoilerLogs)) {
54+
if (UIWidgets::CVarCombobox("Seed", CVAR_RANDOMIZER_SETTING("SpoilerFileIndex"), Rando::Spoiler::spoilerLogs,
55+
{ .color = WIDGET_COLOR })) {
5656
if (CVarGetInteger(CVAR_RANDOMIZER_SETTING("SpoilerFileIndex"), 0) == 0) {
5757
CVarSetString(CVAR_RANDOMIZER_SETTING("SpoilerFile"), "");
5858
} else {

src/port/Rando/Logic/GeneratePools.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ void GenerateShuffleList() {
111111
}
112112

113113
RandoItemType randoItemType = Rando::StaticData::Items[randoCheckData.randoItemId].randoItemType;
114-
115-
// TODO: Swap to RANDO_SAVE_OPTIONS once Save File is converted to JSON
116114
if (randoItemType == RITYPE_COIN_BLUE &&
117115
CVarGetInteger(Rando::StaticData::Options[RO_SHUFFLE_COINS_BLUE].cvar, 0) == RO_GENERIC_OFF) {
118116
continue;

src/port/Rando/MiscBehavior/MiscBehavior.cpp

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,29 @@ void Rando::MiscBehavior::Init() {
4242
if (!IS_RANDO(selectedFileNum)) {
4343
return;
4444
}
45-
SPDLOG_INFO("currentLevel: {}", std::to_string(currentEntrance));
46-
SPDLOG_INFO("Source: {}", std::to_string(ev->sourceWarpNode));
47-
SPDLOG_INFO("Current Destination: {}", std::to_string(ev->warpNode->destLevel));
4845

49-
// TODO: Death Exits
46+
SPDLOG_INFO("Source Warp: {}", std::to_string(ev->sourceWarpNode));
47+
SPDLOG_INFO("Prev Entrance: {}", std::to_string(currentEntrance));
48+
SPDLOG_INFO("Current Level: {}", std::to_string(gCurrLevelNum));
49+
SPDLOG_INFO("Destination: {}", std::to_string(ev->warpNode->destLevel));
50+
51+
// Skip inter-level area changes.
52+
if (gCurrLevelNum == ev->warpNode->destLevel) {
53+
return;
54+
}
55+
56+
// Skip Bowser Arena entrances for now, plan on adding these in later.
57+
if (ev->warpNode->destLevel == LEVEL_BOWSER_1 || ev->warpNode->destLevel == LEVEL_BOWSER_2 ||
58+
ev->warpNode->destLevel == LEVEL_BOWSER_3) {
59+
currentEntrance = RE_UNKNOWN;
60+
return;
61+
}
62+
63+
// Skip entering the Castle Courtyard from the Castle Interior.
64+
if (currentEntrance == RE_UNKNOWN && ev->warpNode->destLevel == LEVEL_CASTLE_COURTYARD) {
65+
return;
66+
}
67+
5068
if (ev->sourceWarpNode > 0 && currentEntrance != RE_UNKNOWN) {
5169
Rando::StaticData::RandoStaticEntrance randoStaticEntrance = Rando::StaticData::Entrances[currentEntrance];
5270

@@ -76,6 +94,7 @@ void Rando::MiscBehavior::Init() {
7694
for (auto& entrance : Rando::Logic::shuffledEntrances) {
7795
if (entrance.randoEntranceId == randoEntranceId) {
7896
entrance.found = true;
97+
save_file_do_save(selectedFileNum);
7998
}
8099
}
81100
currentEntrance = randoEntranceId;
@@ -84,4 +103,15 @@ void Rando::MiscBehavior::Init() {
84103
}
85104
}
86105
});
106+
107+
REGISTER_LISTENER(ExitLevel, EVENT_PRIORITY_NORMAL, [](IEvent* event) {
108+
ExitLevel* ev = (ExitLevel*)event;
109+
if (!IS_RANDO(selectedFileNum)) {
110+
return;
111+
}
112+
113+
if (ev->menuOption == MENU_OPT_EXIT_COURSE) {
114+
currentEntrance = RE_UNKNOWN;
115+
}
116+
});
87117
}

src/port/Rando/MiscBehavior/OnFileSave.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@ void Rando::MiscBehavior::OnFileSave() {
1212
}
1313

1414
for (auto& check : Rando::Logic::shuffledPool) {
15-
RandoSaveCheck randoSaveCheck;
16-
randoSaveCheck.randoItemId = check.randoItemId;
17-
randoSaveCheck.randoAct = check.randoAct;
18-
randoSaveCheck.obtained = check.obtained;
19-
20-
RANDO_SAVE_CHECKS(selectedFileNum)[check.randoCheckId] = randoSaveCheck;
15+
RANDO_SAVE_CHECKS(selectedFileNum)[check.randoCheckId].obtained = check.obtained;
16+
RANDO_SAVE_CHECKS(selectedFileNum)[check.randoCheckId].skipped = check.skipped;
2117
}
2218

2319
for (auto& entrance : Rando::Logic::shuffledEntrances) {

src/port/Rando/ObjectBehavior/Star.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@ extern std::map<RandoCheckId, struct Object*> spawnedRandoObjects;
1111
void Rando::ObjectBehavior::ModifyStarBehavior(bool* shouldCancel, struct Object* obj) {
1212
if (obj->unused1 != RC_UNKNOWN) {
1313
if (Rando::Logic::IsBlueSwitchActivated((RandoCheckId)obj->unused1)) {
14-
obj->header.gfx.node.flags = spawnedRandoObjects.at((RandoCheckId)obj->unused1)->header.gfx.node.flags;
14+
for (auto& spawned : spawnedRandoObjects) {
15+
if (spawned.second == obj) {
16+
obj->header.gfx.node.flags =
17+
spawnedRandoObjects.at((RandoCheckId)obj->unused1)->header.gfx.node.flags;
18+
break;
19+
}
20+
}
21+
1522
obj->oIntangibleTimer = -1;
1623
if (CVarGetInteger("gEnhancements.StarNoExit", 0)) {
1724
obj->oInteractionSubtype |= INT_SUBTYPE_NO_EXIT;

0 commit comments

Comments
 (0)