Skip to content

Commit

Permalink
fix: getting the project in a compilable state
Browse files Browse the repository at this point in the history
  • Loading branch information
MutterPedro committed Nov 15, 2023
1 parent 46191d1 commit 138e8c8
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 3 deletions.
3 changes: 3 additions & 0 deletions include/libs/item/ItemAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "libs/item/itemenums.h"
#include "libs/util/datastructures/CustomLuaAttribute.h"

#include <map>
#include <unordered_map>

typedef std::unordered_map<std::string, CustomLuaAttribute> CustomAttributeMap;
Expand Down Expand Up @@ -95,6 +96,8 @@ class ItemAttributes
ITEM_ATTRIBUTE_WRITER | ITEM_ATTRIBUTE_NAME | ITEM_ATTRIBUTE_ARTICLE |
ITEM_ATTRIBUTE_PLURALNAME;

const static std::string& EMPTY_STRING;

public:
ItemAttributes() = default;

Expand Down
2 changes: 1 addition & 1 deletion include/libs/item/ReflectAttribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct Reflect
uint16_t percent = 0;
uint16_t chance = 0;

static Reflect UNDEFINED;
static const Reflect UNDEFINED;
};

#endif
6 changes: 6 additions & 0 deletions include/libs/util/tools/pugicast.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ inline unsigned int cast(const char* str)
return static_cast<unsigned int>(cast<unsigned long>(str));
}

template <>
inline bool cast(const char* str)
{
return cast<int>(str) == 1 || strcmp(str, "true") == 1;
}

} // namespace pugi

#endif // FS_PUGICAST_H
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ set(peronium_SRC
${CMAKE_CURRENT_LIST_DIR}/libs/util/tools/random.cpp
${CMAKE_CURRENT_LIST_DIR}/libs/util/tools/strings.cpp
${CMAKE_CURRENT_LIST_DIR}/libs/util/tools/xml.cpp
${CMAKE_CURRENT_LIST_DIR}/libs/util/otb/OTBLoadable.cpp
${CMAKE_CURRENT_LIST_DIR}/libs/item/itemmaps.cpp
${CMAKE_CURRENT_LIST_DIR}/libs/item/Item.cpp
${CMAKE_CURRENT_LIST_DIR}/libs/item/ItemAttributes.cpp
Expand Down
8 changes: 6 additions & 2 deletions src/libs/item/ItemAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

#include <iostream>

const Reflect Reflect::UNDEFINED;

const std::string& ItemAttributes::EMPTY_STRING = "";

bool ItemAttributes::equals(const ItemAttributes& other) const
{
if (attributeBits != other.attributeBits) {
Expand Down Expand Up @@ -87,12 +91,12 @@ const std::string& ItemAttributes::getStrAttr(ItemAttrTypes type) const
if (!isStrAttrType(type)) {
std::cout << "Warning: trying to get non-string attribute: " << type << std::endl;

return "";
return EMPTY_STRING;
}

const Attribute* attr = getExistingAttr(type);
if (!attr) {
return "";
return EMPTY_STRING;
}
return *attr->value.string;
}
Expand Down
4 changes: 4 additions & 0 deletions src/libs/item/ItemType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ ItemType* ItemType::loadFromXMLNode(pugi::xml_node node, bool reloading)
return Items::getInstance().getItemType(fromId);
}
}

return this;
}

void ItemType::setField(const std::string& element, ConditionDamage* cd)
Expand Down Expand Up @@ -526,6 +528,8 @@ ConditionDamage* ConditionDamageBuilder::loadFromXMLNode(pugi::xml_node node, bo

return this->conditionDamage.release();
}

return this->conditionDamage.release();
}

void ItemType::setWorth(uint64_t amount)
Expand Down
2 changes: 2 additions & 0 deletions src/libs/item/Items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
extern MoveEvents* g_moveEvents;
extern Weapons* g_weapons;

CurrencyMap Items::currencyItems = {};

bool Items::load(const OTBNode& node, PropStream stream)
{
uint32_t flags;
Expand Down

0 comments on commit 138e8c8

Please sign in to comment.