From 02403b142a14b1271c4f5bb2e9d279daa023b6e6 Mon Sep 17 00:00:00 2001 From: Ethan Adams Date: Thu, 27 Feb 2025 13:46:10 -0500 Subject: [PATCH] Decided to just implement auto it reload since it feels better on the player end. Also added much needed logging for tileset loading --- YuppleMayham/src/gameplay/weapons/weapon.cpp | 3 ++- YuppleMayham/src/utility/xmlloader.cpp | 21 ++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/YuppleMayham/src/gameplay/weapons/weapon.cpp b/YuppleMayham/src/gameplay/weapons/weapon.cpp index 76878c3..120d8bc 100644 --- a/YuppleMayham/src/gameplay/weapons/weapon.cpp +++ b/YuppleMayham/src/gameplay/weapons/weapon.cpp @@ -94,7 +94,8 @@ bool Weapon::shoot() sol::error err = result; std::cerr << "lua error: " << err.what() << std::endl; } - weaponMag -= 1; + // auto reload + if ((weaponMag -= 1) <= 0) reload(); } } else if (weaponMag <= 0) reload(); diff --git a/YuppleMayham/src/utility/xmlloader.cpp b/YuppleMayham/src/utility/xmlloader.cpp index adc8de2..e3ecee9 100644 --- a/YuppleMayham/src/utility/xmlloader.cpp +++ b/YuppleMayham/src/utility/xmlloader.cpp @@ -440,12 +440,21 @@ bool XMLLoader::loadTile(tinyxml2::XMLElement* tileElement, TileSetData::TileDat Notice we just return true if there is no property, we can just safely default to walkable = true */ tinyxml2::XMLElement* properties = tileElement->FirstChildElement("properties"); - if (properties == NULL) - return true; - tinyxml2::XMLElement* propWalk = properties->FirstChildElement("property"); - if (propWalk == NULL || !propWalk->Attribute("name", "walkable")) - return true; - propWalk->QueryBoolAttribute("value", &tileData.walkable); + if (properties == NULL) { + LOG(WARN, "No properties found on tile id: {} assuming defaults", tileData.id); + } else { + tinyxml2::XMLElement* propWalk = properties->FirstChildElement("property"); + if (propWalk == NULL) { + LOG(WARN, "No walkable propery found on tile id: {} assuming walkable", tileData.id); + } else { + for (auto& prop = propWalk; prop != NULL; prop = prop->NextSiblingElement()) { + if (prop->Attribute("name", "walkable")) { + prop->QueryBoolAttribute("value", &tileData.walkable); + break; + } + } + } + } } tileData.type = tileType;