Skip to content

Commit

Permalink
Change inLogic to static array.
Browse files Browse the repository at this point in the history
  • Loading branch information
Malkierian committed Jul 24, 2024
1 parent ede8c54 commit e8e7e51
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
4 changes: 2 additions & 2 deletions soh/soh/Enhancements/randomizer/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ Item::Item(const RandomizerGet randomizerGet_, Text name_, const ItemType type_,
void Item::ApplyEffect() const {
auto ctx = Rando::Context::GetInstance();
ctx->ApplyItemEffect(StaticData::RetrieveItem(randomizerGet), false);
ctx->GetLogic()->SetInLogic(logicVar, false);
ctx->GetLogic()->SetInLogic(logicVar, true);
ctx->GetLogic()->UpdateHelpers();
}

void Item::UndoEffect() const {
auto ctx = Rando::Context::GetInstance();
ctx->ApplyItemEffect(StaticData::RetrieveItem(randomizerGet), true);
ctx->GetLogic()->SetInLogic(logicVar, true);
ctx->GetLogic()->SetInLogic(logicVar, false);
ctx->GetLogic()->UpdateHelpers();
}

Expand Down
14 changes: 4 additions & 10 deletions soh/soh/Enhancements/randomizer/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,22 +768,16 @@ namespace Rando {
}

bool Logic::GetInLogic(LogicVal logicVar) {
return std::find(inLogic.begin(), inLogic.end(), logicVar) != inLogic.end();
return inLogic[logicVar];
}

void Logic::SetInLogic(LogicVal logicVar, bool remove) {
auto it = std::find(inLogic.begin(), inLogic.end(), logicVar);
if (it == inLogic.end() && !remove) {
inLogic.push_back(logicVar);
}
else if (it != inLogic.end() && remove) {
inLogic.erase(it);
}
void Logic::SetInLogic(LogicVal logicVar, bool value) {
inLogic[logicVar] = value;
}

void Logic::Reset() {
//SPDLOG_INFO("Logic reset.");
ctx->NewSaveContext();
memset(inLogic, false, sizeof(inLogic));
//Settings-dependent variables
IsKeysanity = ctx->GetOption(RSK_KEYSANITY).Is(RO_DUNGEON_ITEM_LOC_ANYWHERE) ||
ctx->GetOption(RSK_KEYSANITY).Is(RO_DUNGEON_ITEM_LOC_ANYWHERE) ||
Expand Down
2 changes: 1 addition & 1 deletion soh/soh/Enhancements/randomizer/logic.h
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,6 @@ class Logic {
static bool IsMagicItem(RandomizerGet item);
static bool IsMagicArrow(RandomizerGet item);
std::shared_ptr<Context> ctx;
std::vector<LogicVal> inLogic;
bool inLogic[LOGIC_MAX];
}; // class Logic
} // namespace Rando
1 change: 1 addition & 0 deletions soh/soh/Enhancements/randomizer/randomizerTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ typedef enum {
LOGIC_OCARINA_C_LEFT_BUTTON,
LOGIC_OCARINA_C_RIGHT_BUTTON,
LOGIC_TRIFORCE_PIECES,
LOGIC_MAX
} LogicVal;

typedef enum {
Expand Down

0 comments on commit e8e7e51

Please sign in to comment.