Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/game/interaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,6 @@ u32 interact_star_or_key(struct MarioState *m, UNUSED u32 interactType, struct O
m->interactObj = o;
m->usedObj = o;

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

Expand Down
1 change: 1 addition & 0 deletions src/game/level_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,7 @@ s32 play_mode_paused(void) {
if (gDebugLevelSelect) {
fade_into_special_warp(-9, 1);
} else {
CALL_EVENT(ExitLevel, gMenuOptSelectIndex);
initiate_warp(LEVEL_CASTLE, 1, 0x1F, 0);
fade_into_special_warp(0, 0);
gSavedCourseNum = COURSE_NONE;
Expand Down
4 changes: 2 additions & 2 deletions src/game/save_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ static void restore_save_file_data(s32 fileIndex, s32 srcSlot) {
}

void save_file_do_save(s32 fileIndex) {
CALL(SaveFileDoSave, fileIndex);

CALL_EVENT(OnGameFileSave, fileIndex);
CALL(SaveFileDoSave, fileIndex);

if (gSaveFileModified) {
// Compute checksum
add_save_block_signature(&gSaveBuffer.files[fileIndex][0],
Expand Down
4 changes: 3 additions & 1 deletion src/port/Rando/CheckTracker/CheckTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ void DrawCheckTrackerList() {
ImGui::BeginGroup();
ImGui::Image(textureId, ImVec2(16.0f * checkTrackerScale, 16.0f * checkTrackerScale));
ImGui::TableNextColumn();
ImGui::TextColored(checkTextColor, Rando::StaticData::Checks[entry.randoCheckId].name);
ImGui::TextColored(
checkTextColor,
convertEnumToReadableName(Rando::StaticData::Checks[entry.randoCheckId].name).c_str());
if (randoSaveCheck.obtained) {
ImGui::SameLine();
RandoItemId randoItemId = Rando::StaticData::GetShuffledRandoItem(entry.randoCheckId);
Expand Down
3 changes: 2 additions & 1 deletion src/port/Rando/CustomItem/CustomItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ void CustomItem::ObjectCollected(int16_t type, struct MarioState* mario, struct
if (shuffled.randoCheckId == object->unused1) {
previousCheckState = shuffled.obtained;
shuffled.obtained = true;
RANDO_SAVE_CHECKS(selectedFileNum)[shuffled.randoCheckId].obtained = true;
}
}

Expand Down Expand Up @@ -127,6 +126,8 @@ void CustomItem::ObjectCollected(int16_t type, struct MarioState* mario, struct
object->activeFlags = ACTIVE_FLAG_DEACTIVATED;
object->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE;
obj_mark_for_deletion(object);

save_file_do_save(selectedFileNum);
}

void CustomItem::SetBehavior(struct Object* object, u32 modelId, RandoCheckId randoCheckId, RandoAct randoAct) {
Expand Down
4 changes: 2 additions & 2 deletions src/port/Rando/GhostshipMenuRando.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ void GhostshipMenu::AddMenuRando() {
.CVar(CVAR_RANDOMIZER_SETTING("GenerateLog"))
.RaceDisable(false)
.Options(CheckboxOptions().Tooltip("Generates a Spoiler Log in the randomizer folder.").DefaultValue(true));
// TODO: populate combobox with existing spoiler logs
AddWidget(path, "Load Existing Spoiler Log", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_RANDOMIZER_SETTING("UseExistingLog"))
.RaceDisable(false)
Expand All @@ -52,7 +51,8 @@ void GhostshipMenu::AddMenuRando() {
});
AddWidget(path, "Available Spoiler Logs", WIDGET_CUSTOM).CustomFunction([](WidgetInfo& info) {
ImGui::BeginDisabled(!CVarGetInteger(CVAR_RANDOMIZER_SETTING("UseExistingLog"), 0));
if (UIWidgets::CVarCombobox("Seed", CVAR_RANDOMIZER_SETTING("SpoilerFileIndex"), Rando::Spoiler::spoilerLogs)) {
if (UIWidgets::CVarCombobox("Seed", CVAR_RANDOMIZER_SETTING("SpoilerFileIndex"), Rando::Spoiler::spoilerLogs,
{ .color = WIDGET_COLOR })) {
if (CVarGetInteger(CVAR_RANDOMIZER_SETTING("SpoilerFileIndex"), 0) == 0) {
CVarSetString(CVAR_RANDOMIZER_SETTING("SpoilerFile"), "");
} else {
Expand Down
2 changes: 0 additions & 2 deletions src/port/Rando/Logic/GeneratePools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ void GenerateShuffleList() {
}

RandoItemType randoItemType = Rando::StaticData::Items[randoCheckData.randoItemId].randoItemType;

// TODO: Swap to RANDO_SAVE_OPTIONS once Save File is converted to JSON
if (randoItemType == RITYPE_COIN_BLUE &&
CVarGetInteger(Rando::StaticData::Options[RO_SHUFFLE_COINS_BLUE].cvar, 0) == RO_GENERIC_OFF) {
continue;
Expand Down
38 changes: 34 additions & 4 deletions src/port/Rando/MiscBehavior/MiscBehavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,29 @@ void Rando::MiscBehavior::Init() {
if (!IS_RANDO(selectedFileNum)) {
return;
}
SPDLOG_INFO("currentLevel: {}", std::to_string(currentEntrance));
SPDLOG_INFO("Source: {}", std::to_string(ev->sourceWarpNode));
SPDLOG_INFO("Current Destination: {}", std::to_string(ev->warpNode->destLevel));

// TODO: Death Exits
SPDLOG_INFO("Source Warp: {}", std::to_string(ev->sourceWarpNode));
SPDLOG_INFO("Prev Entrance: {}", std::to_string(currentEntrance));
SPDLOG_INFO("Current Level: {}", std::to_string(gCurrLevelNum));
SPDLOG_INFO("Destination: {}", std::to_string(ev->warpNode->destLevel));

// Skip inter-level area changes.
if (gCurrLevelNum == ev->warpNode->destLevel) {
return;
}

// Skip Bowser Arena entrances for now, plan on adding these in later.
if (ev->warpNode->destLevel == LEVEL_BOWSER_1 || ev->warpNode->destLevel == LEVEL_BOWSER_2 ||
ev->warpNode->destLevel == LEVEL_BOWSER_3) {
currentEntrance = RE_UNKNOWN;
return;
}

// Skip entering the Castle Courtyard from the Castle Interior.
if (currentEntrance == RE_UNKNOWN && ev->warpNode->destLevel == LEVEL_CASTLE_COURTYARD) {
return;
}

if (ev->sourceWarpNode > 0 && currentEntrance != RE_UNKNOWN) {
Rando::StaticData::RandoStaticEntrance randoStaticEntrance = Rando::StaticData::Entrances[currentEntrance];

Expand Down Expand Up @@ -76,6 +94,7 @@ void Rando::MiscBehavior::Init() {
for (auto& entrance : Rando::Logic::shuffledEntrances) {
if (entrance.randoEntranceId == randoEntranceId) {
entrance.found = true;
save_file_do_save(selectedFileNum);
}
}
currentEntrance = randoEntranceId;
Expand All @@ -84,4 +103,15 @@ void Rando::MiscBehavior::Init() {
}
}
});

REGISTER_LISTENER(ExitLevel, EVENT_PRIORITY_NORMAL, [](IEvent* event) {
ExitLevel* ev = (ExitLevel*)event;
if (!IS_RANDO(selectedFileNum)) {
return;
}

if (ev->menuOption == MENU_OPT_EXIT_COURSE) {
currentEntrance = RE_UNKNOWN;
}
});
}
8 changes: 2 additions & 6 deletions src/port/Rando/MiscBehavior/OnFileSave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ void Rando::MiscBehavior::OnFileSave() {
}

for (auto& check : Rando::Logic::shuffledPool) {
RandoSaveCheck randoSaveCheck;
randoSaveCheck.randoItemId = check.randoItemId;
randoSaveCheck.randoAct = check.randoAct;
randoSaveCheck.obtained = check.obtained;

RANDO_SAVE_CHECKS(selectedFileNum)[check.randoCheckId] = randoSaveCheck;
RANDO_SAVE_CHECKS(selectedFileNum)[check.randoCheckId].obtained = check.obtained;
RANDO_SAVE_CHECKS(selectedFileNum)[check.randoCheckId].skipped = check.skipped;
}

for (auto& entrance : Rando::Logic::shuffledEntrances) {
Expand Down
9 changes: 8 additions & 1 deletion src/port/Rando/ObjectBehavior/Star.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ extern std::map<RandoCheckId, struct Object*> spawnedRandoObjects;
void Rando::ObjectBehavior::ModifyStarBehavior(bool* shouldCancel, struct Object* obj) {
if (obj->unused1 != RC_UNKNOWN) {
if (Rando::Logic::IsBlueSwitchActivated((RandoCheckId)obj->unused1)) {
obj->header.gfx.node.flags = spawnedRandoObjects.at((RandoCheckId)obj->unused1)->header.gfx.node.flags;
for (auto& spawned : spawnedRandoObjects) {
if (spawned.second == obj) {
obj->header.gfx.node.flags =
spawnedRandoObjects.at((RandoCheckId)obj->unused1)->header.gfx.node.flags;
break;
}
}

obj->oIntangibleTimer = -1;
if (CVarGetInteger("gEnhancements.StarNoExit", 0)) {
obj->oInteractionSubtype |= INT_SUBTYPE_NO_EXIT;
Expand Down
2 changes: 1 addition & 1 deletion src/port/ShipUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ std::map<int16_t, std::string> levelIdList = {
{ LEVEL_COTMC, "Cavern of the Metal Cap" },
{ LEVEL_TOTWC, "Tower of the Wing Cap" },
{ LEVEL_VCUTM, "Vanish Cap Under the Moat" },
{ LEVEL_WMOTR, "Winged Mario over the Rainbow" },
{ LEVEL_WMOTR, "Wing Mario over the Rainbow" },
{ LEVEL_SA, "Secret Aquarium" },
};

Expand Down
4 changes: 2 additions & 2 deletions src/port/ShipUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ extern u32 finalSeed;
uint32_t Ship_Hash(std::string str);

void LoadGuiTextures();
extern int16_t Ship_GetCourseByLevel(int16_t levelId);
extern std::array<const char*, 10> digitList;
extern std::map<int16_t, std::string> levelIdList;
extern std::string convertEnumToReadableName(const std::string& input);

extern "C" {
#endif

bool Ship_IsCStringEmpty(const char* str);
std::string convertEnumToReadableName(const std::string& input);
int16_t Ship_GetCourseByLevel(int16_t levelId);

#ifdef __cplusplus
}
Expand Down
6 changes: 3 additions & 3 deletions src/port/game/GeoLayoutParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ struct GraphNodeEntry {
GraphNodeFunc function;
};

#define FUNC(f) \
GraphNodeEntry { \
#f, reinterpret_cast<GraphNodeFunc>(f) \
#define FUNC(f) \
GraphNodeEntry { \
#f, reinterpret_cast < GraphNodeFunc>(f) \
}

std::unordered_map<uint32_t, GraphNodeEntry> mUSFunctionTable = {
Expand Down
4 changes: 4 additions & 0 deletions src/port/hooks/list/PlayerEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ DEFINE_EVENT(ChangeLevel,
int32_t* delayedWarpArg;
);

DEFINE_EVENT(ExitLevel,
int16_t menuOption;
);

DEFINE_EVENT(OnGameFileLoad,
s32 fileNum;
);
Expand Down
1 change: 1 addition & 0 deletions src/port/mods/PortEnhancements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ void PortEnhancements_Register() {
REGISTER_EVENT(ModifyRedCoinCount);
REGISTER_EVENT(ModifyObjectVisibility);
REGISTER_EVENT(ChangeLevel);
REGISTER_EVENT(ExitLevel);
REGISTER_EVENT(OnGameFileLoad);
REGISTER_EVENT(OnGameFileSave);

Expand Down
7 changes: 4 additions & 3 deletions src/port/ui/ObjectViewer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "ObjectViewer.h"

#ifndef __APPLE__
#ifdef _WIN32
#include <windows.h>
#include <dbghelp.h>
#else
#include <dlfcn.h>
Expand Down Expand Up @@ -38,9 +39,9 @@ const char* GetFunctionName(const uintptr_t addr) {

DWORD64 displacement = 0;

if (SymFromAddr(GetCurrentProcess(), dwAddress, &displacement, pSymbol)) {
if (SymFromAddr(GetCurrentProcess(), addr, &displacement, pSymbol)) {
functionNameCache[addr] = pSymbol->Name;
return functionNameCache[addr];
return functionNameCache[addr].c_str();
}
#else
Dl_info info;
Expand Down
Loading