Skip to content

Commit

Permalink
Removed various string comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
gymnast86 committed Apr 9, 2021
1 parent 7cbdf81 commit 3fd91cf
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 13 deletions.
5 changes: 5 additions & 0 deletions code/src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ typedef enum {
EXCLUDE,
} ExcludeLocationSetting;

typedef enum {
TRICK_DISABLED,
TRICK_ENABLED,
} LogicTrickSetting;

typedef enum {
DAMAGEMULTIPLIER_HALF,
DAMAGEMULTIPLIER_DEFAULT,
Expand Down
4 changes: 2 additions & 2 deletions source/fill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,14 @@ static std::vector<ItemLocation*> GetAccessibleLocations(std::vector<ItemLocatio
}
}
//Triforce has been found, seed is beatable, nothing else in this or future spheres matters
else if (location->GetPlacedItem().GetName() == "Triforce") {
else if (location->GetPlacedItem() == I_Triforce) {
sphere.clear();
sphere.push_back(location);
playthroughBeatable = true;
}
}
//All we care about is if the game is beatable, used to pare down playthrough
else if (mode == CHECK_BEATABLE && location->GetPlacedItem().GetName() == "Triforce") {
else if (mode == CHECK_BEATABLE && location->GetPlacedItem() == I_Triforce) {
playthroughBeatable = true;
return {}; //Return early for efficiency
}
Expand Down
9 changes: 6 additions & 3 deletions source/location_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2045,9 +2045,12 @@ namespace Exits { //name, scene, hint, events, locations, exits

Exit SpiritTemple_ChildClimb = Exit("Child Spirit Temple Climb", "Spirit Temple", "", NO_DAY_NIGHT_CYCLE, {}, {
//Locations
ItemLocationPairing(&SpiritTemple_ChildClimbNorthChest, []{return HasProjectile("Both") || ((SmallKeys(SpiritTempleKeys, 3) || (SmallKeys(SpiritTempleKeys, 2) && BombchusInLogic && !ShuffleDungeonEntrances)) && CanUse(CanUseItem::Silver_Gauntlets) && HasProjectile("Adult")) || (SmallKeys(SpiritTempleKeys, 5) && IsChild && HasProjectile("Child"));}),
ItemLocationPairing(&SpiritTemple_ChildClimbEastChest, []{return HasProjectile("Both") || ((SmallKeys(SpiritTempleKeys, 3) || (SmallKeys(SpiritTempleKeys, 2) && BombchusInLogic && !ShuffleDungeonEntrances)) && CanUse(CanUseItem::Silver_Gauntlets) && HasProjectile("Adult")) || (SmallKeys(SpiritTempleKeys, 5) && IsChild && HasProjectile("Child"));}),
ItemLocationPairing(&SpiritTemple_GS_SunOnFloorRoom, []{return HasProjectile("Both") || CanUse(CanUseItem::Dins_Fire) || ((DamageMultiplier.IsNot(DAMAGEMULTIPLIER_OHKO) || Fairy || CanUse(CanUseItem::Nayrus_Love)) && (Sticks || KokiriSword || HasProjectile("Child"))) || (IsChild && SmallKeys(SpiritTempleKeys, 5) && HasProjectile("Child")) || ((SmallKeys(SpiritTempleKeys, 3) || (SmallKeys(SpiritTempleKeys, 2) && BombchusInLogic && !ShuffleDungeonEntrances)) && CanUse(CanUseItem::Silver_Gauntlets) && (HasProjectile("Adult") || DamageMultiplier.IsNot(DAMAGEMULTIPLIER_OHKO) || Fairy || CanUse(CanUseItem::Nayrus_Love)));}),
ItemLocationPairing(&SpiritTemple_ChildClimbNorthChest, []{return HasProjectile(HasProjectileAge::Both) || ((SmallKeys(SpiritTempleKeys, 3) || (SmallKeys(SpiritTempleKeys, 2) && BombchusInLogic && !ShuffleDungeonEntrances)) && CanUse(CanUseItem::Silver_Gauntlets) && HasProjectile(HasProjectileAge::Adult)) || (SmallKeys(SpiritTempleKeys, 5) && IsChild && HasProjectile(HasProjectileAge::Child));}),
ItemLocationPairing(&SpiritTemple_ChildClimbEastChest, []{return HasProjectile(HasProjectileAge::Both) || ((SmallKeys(SpiritTempleKeys, 3) || (SmallKeys(SpiritTempleKeys, 2) && BombchusInLogic && !ShuffleDungeonEntrances)) && CanUse(CanUseItem::Silver_Gauntlets) && HasProjectile(HasProjectileAge::Adult)) || (SmallKeys(SpiritTempleKeys, 5) && IsChild && HasProjectile(HasProjectileAge::Child));}),
ItemLocationPairing(&SpiritTemple_GS_SunOnFloorRoom, []{return HasProjectile(HasProjectileAge::Both) || CanUse(CanUseItem::Dins_Fire) ||
((DamageMultiplier.IsNot(DAMAGEMULTIPLIER_OHKO) || Fairy || CanUse(CanUseItem::Nayrus_Love)) && (Sticks || KokiriSword || HasProjectile(HasProjectileAge::Child))) ||
(IsChild && SmallKeys(SpiritTempleKeys, 5) && HasProjectile(HasProjectileAge::Child)) ||
((SmallKeys(SpiritTempleKeys, 3) || (SmallKeys(SpiritTempleKeys, 2) && BombchusInLogic && !ShuffleDungeonEntrances)) && CanUse(CanUseItem::Silver_Gauntlets) && (HasProjectile(HasProjectileAge::Adult) || DamageMultiplier.IsNot(DAMAGEMULTIPLIER_OHKO) || Fairy || CanUse(CanUseItem::Nayrus_Love)));}),
}, {
//Exits
ExitPairing::Both(&SpiritTemple_CentralChamber, []{return HasExplosives;}),
Expand Down
10 changes: 5 additions & 5 deletions source/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,12 @@ namespace Logic {
(IsChildItem(itemName) && HasItem(itemName) && IsChild);
}

bool HasProjectile(std::string_view age) {
bool HasProjectile(HasProjectileAge age) {
return HasExplosives ||
(age == "Child" && (Slingshot || Boomerang)) ||
(age == "Adult" && (Hookshot || Bow )) ||
(age == "Both" && (Slingshot || Boomerang) && (Hookshot || Bow)) ||
(age == "Either" && (Slingshot || Boomerang || Hookshot || Bow));
(age == HasProjectileAge::Child && (Slingshot || Boomerang)) ||
(age == HasProjectileAge::Adult && (Hookshot || Bow )) ||
(age == HasProjectileAge::Both && (Slingshot || Boomerang) && (Hookshot || Bow)) ||
(age == HasProjectileAge::Either && (Slingshot || Boomerang || Hookshot || Bow));
}

//Updates all logic helpers. Should be called whenever a non-helper is changed
Expand Down
9 changes: 8 additions & 1 deletion source/logic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,17 @@ namespace Logic {
Light_Arrows,
};

enum class HasProjectileAge {
Adult,
Child,
Both,
Either,
};

extern void UpdateHelpers();
extern bool CanPlay(bool song);
extern bool CanUse(CanUseItem itemName);
extern bool HasProjectile(std::string_view age);
extern bool HasProjectile(HasProjectileAge age);
extern bool SmallKeys(u8 dungeonKeyCount, u8 requiredAmount);
extern bool EventsUpdated();
extern void LogicReset();
Expand Down
4 changes: 2 additions & 2 deletions source/spoiler_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static void WriteSettings() {
//List Excluded Locations
logtxt += "\nExcluded Locations:\n";
for (auto& l : Settings::excludeLocationsOptions) {
if (l->GetSelectedOptionText() == "Exclude") {
if (l->GetSelectedOptionIndex() == EXCLUDE) {
std::string name = l->GetName().data();

//get rid of newline characters if necessary
Expand All @@ -137,7 +137,7 @@ static void WriteSettings() {
//List Enabled Tricks
logtxt += "\nEnabled Tricks:\n";
for (auto& l : Settings::detailedLogicOptions) {
if (l->GetSelectedOptionText() == "Enabled" && l->IsCategory(OptionCategory::Setting)) {
if (l->GetSelectedOptionIndex() == TRICK_ENABLED && l->IsCategory(OptionCategory::Setting)) {
std::string name = l->GetName().data();

//get rid of newline characters if necessary
Expand Down

0 comments on commit 3fd91cf

Please sign in to comment.