Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix permanent items not being placed #751

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion source/fill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,11 @@ int Fill() {
std::vector<ItemKey> remainingAdvancementItems =
FilterAndEraseFromPool(ItemPool, [](const ItemKey i) { return ItemTable(i).IsAdvancement(); });
AssumedFill(remainingAdvancementItems, allLocations, true);

// Then place any remaining non-junk items
// Fast fill as these don't affect logic
std::vector<ItemKey> remainingNonJunkItems =
FilterAndEraseFromPool(ItemPool, [](const ItemKey i) { return !ItemTable(i).IsJunk(); });
FastFill(remainingNonJunkItems, GetAllEmptyLocations(), true);
// Fast fill for the rest of the pool
std::vector<ItemKey> remainingPool = FilterAndEraseFromPool(ItemPool, [](const ItemKey i) { return true; });
FastFill(remainingPool, GetAllEmptyLocations(), false);
Expand Down
2 changes: 1 addition & 1 deletion source/hints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ static std::vector<LocationKey> GetAccessibleGossipStones(const LocationKey hint

static void AddHint(Text hint, const LocationKey gossipStone, const std::vector<u8>& colors = {}) {
// save hints as dummy items for writing to the spoiler log
NewItem(gossipStone, Item{ ITEMTYPE_EVENT, GI_RUPEE_BLUE_LOSE, false, &noVariable, NONE, hint });
NewItem(gossipStone, Item{ ITEMTYPE_EVENT, GI_RUPEE_BLUE_LOSE, ITEMCLASS_NONE, &noVariable, NONE, hint });
Location(gossipStone)->SetPlacedItem(gossipStone);

// create the in game message
Expand Down
20 changes: 10 additions & 10 deletions source/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
#include "settings.hpp"
#include "../code/src/item_override.h"

Item::Item(ItemType type_, int getItemId_, bool advancement_, bool* logicVar_, HintKey hintKey_, u16 price_, Text name_)
: type(type_), getItemId(getItemId_), advancement(advancement_), logicVar(logicVar_), hintKey(hintKey_),
price(price_), name(std::move(name_)) {
Item::Item(ItemType type_, int getItemId_, ItemClass class_, bool* logicVar_, HintKey hintKey_, u16 price_, Text name_)
: type(type_), getItemId(getItemId_), itemClass(class_), logicVar(logicVar_), hintKey(hintKey_), price(price_),
name(std::move(name_)) {
}

Item::Item(ItemType type_, int getItemId_, bool advancement_, u8* logicVar_, HintKey hintKey_, u16 price_, Text name_)
: type(type_), getItemId(getItemId_), advancement(advancement_), logicVar(logicVar_), hintKey(hintKey_),
price(price_), name(std::move(name_)) {
Item::Item(ItemType type_, int getItemId_, ItemClass class_, u8* logicVar_, HintKey hintKey_, u16 price_, Text name_)
: type(type_), getItemId(getItemId_), itemClass(class_), logicVar(logicVar_), hintKey(hintKey_), price(price_),
name(std::move(name_)) {
}

Item::Item(ItemType type_, int getItemId_, bool advancement_, bool* logicVar_, HintKey hintKey_, Text name_)
: Item::Item(type_, getItemId_, advancement_, logicVar_, hintKey_, 0, name_) {
Item::Item(ItemType type_, int getItemId_, ItemClass class_, bool* logicVar_, HintKey hintKey_, Text name_)
: Item::Item(type_, getItemId_, class_, logicVar_, hintKey_, 0, name_) {
}

Item::Item(ItemType type_, int getItemId_, bool advancement_, u8* logicVar_, HintKey hintKey_, Text name_)
: Item::Item(type_, getItemId_, advancement_, logicVar_, hintKey_, 0, name_) {
Item::Item(ItemType type_, int getItemId_, ItemClass class_, u8* logicVar_, HintKey hintKey_, Text name_)
: Item::Item(type_, getItemId_, class_, logicVar_, hintKey_, 0, name_) {
}

Item::~Item() = default;
Expand Down
22 changes: 16 additions & 6 deletions source/item.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,19 @@ enum ItemType {
ITEMTYPE_ENEMY_SOUL,
};

enum ItemClass {
ITEMCLASS_JUNK,
ITEMCLASS_ADVANCEMENT,
ITEMCLASS_NONE,
};

class Item {
public:
Item() = default;
Item(ItemType type_, int getItemId_, bool advancement_, bool* logicVar_, HintKey hintKey_, u16 price_, Text name_);
Item(ItemType type_, int getItemId_, bool advancement_, u8* logicVar_, HintKey hintKey_, u16 price_, Text name_);
Item(ItemType type_, int getItemId_, bool advancement_, bool* logicVar_, HintKey hintKey_, Text name_);
Item(ItemType type_, int getItemId_, bool advancement_, u8* logicVar_, HintKey hintKey_, Text name_);
Item(ItemType type_, int getItemId_, ItemClass class_, bool* logicVar_, HintKey hintKey_, u16 price_, Text name_);
Item(ItemType type_, int getItemId_, ItemClass class_, u8* logicVar_, HintKey hintKey_, u16 price_, Text name_);
Item(ItemType type_, int getItemId_, ItemClass class_, bool* logicVar_, HintKey hintKey_, Text name_);
Item(ItemType type_, int getItemId_, ItemClass class_, u8* logicVar_, HintKey hintKey_, Text name_);
~Item();

void ApplyEffect();
Expand All @@ -46,7 +52,11 @@ class Item {
}

bool IsAdvancement() const {
return advancement;
return itemClass == ITEMCLASS_ADVANCEMENT;
}

bool IsJunk() const {
return itemClass == ITEMCLASS_JUNK;
}

int GetItemID() const {
Expand Down Expand Up @@ -142,7 +152,7 @@ class Item {
private:
ItemType type;
int getItemId;
bool advancement;
ItemClass itemClass;
std::variant<bool*, u8*> logicVar;
HintKey hintKey;
u16 price;
Expand Down
Loading