Fix an issue with a stray Rando::Context shared_ptr hanging around. (#4259)

* Fix an issue with a stray Rando::Context shared_ptr hanging around.

* Fixes accidental leftover from when I found this bug on another branch

* Properly reset randoContext on every save load, not just after save creation
This commit is contained in:
Christopher Leggett 2024-08-10 17:07:03 -04:00 committed by GitHub
parent 483dbea330
commit 91d1e5970d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 10 additions and 4 deletions

View File

@ -240,12 +240,12 @@ bool HasAccessTo(const RandomizerRegion area) {
return areaTable[area].HasAccess(); return areaTable[area].HasAccess();
} }
std::shared_ptr<Rando::Context> randoCtx; Rando::Context* randoCtx;
std::shared_ptr<Rando::Logic> logic; std::shared_ptr<Rando::Logic> logic;
void AreaTable_Init() { void AreaTable_Init() {
using namespace Rando; using namespace Rando;
randoCtx = Context::GetInstance(); randoCtx = Context::GetInstance().get();
logic = randoCtx->GetLogic(); logic = randoCtx->GetLogic();
grottoEvents = { grottoEvents = {
EventAccess(&logic->GossipStoneFairy, { [] { return logic->GossipStoneFairy || logic->CanSummonGossipFairy; } }), EventAccess(&logic->GossipStoneFairy, { [] { return logic->GossipStoneFairy || logic->CanSummonGossipFairy; } }),

View File

@ -12,7 +12,7 @@
typedef bool (*ConditionFn)(); typedef bool (*ConditionFn)();
// I hate this but every alternative I can think of right now is worse // I hate this but every alternative I can think of right now is worse
extern std::shared_ptr<Rando::Context> randoCtx; extern Rando::Context* randoCtx;
extern std::shared_ptr<Rando::Logic> logic; extern std::shared_ptr<Rando::Logic> logic;
class EventAccess { class EventAccess {

View File

@ -235,6 +235,11 @@ Entrance* Entrance::AssumeReachable() {
return assumed; return assumed;
} }
EntranceShuffler::EntranceShuffler() {
playthroughEntrances = {};
entranceOverrides = {};
}
bool EntranceShuffler::HasNoRandomEntrances() { bool EntranceShuffler::HasNoRandomEntrances() {
return mNoRandomEntrances; return mNoRandomEntrances;
} }

View File

@ -115,6 +115,7 @@ using EntrancePools = std::map<EntranceType, std::vector<Entrance*>>;
class EntranceShuffler { class EntranceShuffler {
public: public:
EntranceShuffler();
std::array<EntranceOverride, ENTRANCE_OVERRIDES_MAX_COUNT> entranceOverrides; std::array<EntranceOverride, ENTRANCE_OVERRIDES_MAX_COUNT> entranceOverrides;
std::vector<std::list<Entrance*>> playthroughEntrances; std::vector<std::list<Entrance*>> playthroughEntrances;
bool HasNoRandomEntrances(); bool HasNoRandomEntrances();

View File

@ -2841,7 +2841,7 @@ extern "C" void Save_SaveGlobal(void) {
} }
extern "C" void Save_LoadFile(void) { extern "C" void Save_LoadFile(void) {
if (gSaveContext.questId == QUEST_RANDOMIZER) { if (SaveManager::Instance->fileMetaInfo[gSaveContext.fileNum].randoSave) {
// Reset rando context for rando saves. // Reset rando context for rando saves.
OTRGlobals::Instance->gRandoContext.reset(); OTRGlobals::Instance->gRandoContext.reset();
OTRGlobals::Instance->gRandoContext = Rando::Context::CreateInstance(); OTRGlobals::Instance->gRandoContext = Rando::Context::CreateInstance();