From 95227e7c07251c8f59164050543c3c134aff238f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 21 Jun 2016 20:18:38 +0300 Subject: Add support for items with cards in charcreation.xml --- src/resources/beingslot.cpp | 1 + src/resources/beingslot.h | 2 ++ src/resources/db/chardb.cpp | 18 +++++++++++++++--- src/resources/db/chardb.h | 4 +++- 4 files changed, 21 insertions(+), 4 deletions(-) (limited to 'src/resources') diff --git a/src/resources/beingslot.cpp b/src/resources/beingslot.cpp index 624a21553..f739bce67 100644 --- a/src/resources/beingslot.cpp +++ b/src/resources/beingslot.cpp @@ -22,3 +22,4 @@ #include "debug.h" +BeingSlot *emptyBeingSlot = nullptr; diff --git a/src/resources/beingslot.h b/src/resources/beingslot.h index 1d4ef4d55..840fbd2da 100644 --- a/src/resources/beingslot.h +++ b/src/resources/beingslot.h @@ -45,4 +45,6 @@ struct BeingSlot final std::string color; }; +extern BeingSlot *emptyBeingSlot; + #endif // RESOURCES_BEINGSLOT_H diff --git a/src/resources/db/chardb.cpp b/src/resources/db/chardb.cpp index d085f690c..55c97a63f 100644 --- a/src/resources/db/chardb.cpp +++ b/src/resources/db/chardb.cpp @@ -22,6 +22,7 @@ #include "resources/db/chardb.h" #include "configuration.h" +#include "itemcolormanager.h" #include "logger.h" #include "debug.h" @@ -40,7 +41,7 @@ namespace unsigned mMaxLook = 0; unsigned mMinRace = 0; unsigned mMaxRace = 30; - std::vector mDefaultItems; + std::vector mDefaultItems; } // namespace void CharDB::load() @@ -85,7 +86,18 @@ void CharDB::load() { const int id = XML::getProperty(node, "id", 0); if (id > 0) - mDefaultItems.push_back(id); + { + BeingSlot slot; + slot.spriteId = id; + for (int f = 0; f < maxCards; f ++) + { + const std::string cardName = strprintf("card%d", f + 1); + slot.cardsId.cards[f] = XML::getProperty(node, + cardName.c_str(), + 0); + } + mDefaultItems.push_back(slot); + } } else if (xmlNameEqual(node, "race")) { @@ -170,7 +182,7 @@ unsigned CharDB::getMaxRace() return mMaxRace; } -const std::vector &CharDB::getDefaultItems() +const std::vector &CharDB::getDefaultItems() { return mDefaultItems; } diff --git a/src/resources/db/chardb.h b/src/resources/db/chardb.h index d6653547c..6eb1688e2 100644 --- a/src/resources/db/chardb.h +++ b/src/resources/db/chardb.h @@ -24,6 +24,8 @@ #include "utils/xml.h" +#include "resources/beingslot.h" + #include /** @@ -67,7 +69,7 @@ namespace CharDB unsigned getMaxRace() A_WARN_UNUSED; - const std::vector &getDefaultItems() A_WARN_UNUSED; + const std::vector &getDefaultItems() A_WARN_UNUSED; } // namespace CharDB #endif // RESOURCES_DB_CHARDB_H -- cgit v1.2.3-70-g09d2