summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-06-21 20:18:38 +0300
committerAndrei Karas <akaras@inbox.ru>2016-06-21 21:45:47 +0300
commit95227e7c07251c8f59164050543c3c134aff238f (patch)
tree1b45789ca770f7251a557281da22892923470a68 /src
parentae351c43eca44c532404deb9f10bf3e4b97406bf (diff)
downloadplus-95227e7c07251c8f59164050543c3c134aff238f.tar.gz
plus-95227e7c07251c8f59164050543c3c134aff238f.tar.bz2
plus-95227e7c07251c8f59164050543c3c134aff238f.tar.xz
plus-95227e7c07251c8f59164050543c3c134aff238f.zip
Add support for items with cards in charcreation.xml
Diffstat (limited to 'src')
-rw-r--r--src/being/being.cpp14
-rw-r--r--src/being/being.h6
-rw-r--r--src/game.cpp3
-rw-r--r--src/gui/windows/charcreatedialog.cpp10
-rw-r--r--src/resources/beingslot.cpp1
-rw-r--r--src/resources/beingslot.h2
-rw-r--r--src/resources/db/chardb.cpp18
-rw-r--r--src/resources/db/chardb.h4
8 files changed, 50 insertions, 8 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 618922fa3..4c750f5c8 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -3156,6 +3156,12 @@ void Being::setHairColor(const unsigned int slot,
}
}
+void Being::setSpriteSlot(const unsigned int slot,
+ const BeingSlot &beingSlot)
+{
+ mSlots[slot] = beingSlot;
+}
+
void Being::dumpSprites() const restrict2
{
std::vector<BeingSlot>::const_iterator it1 = mSlots.begin();
@@ -4429,6 +4435,14 @@ int Being::getSpriteID(const int slot) const restrict2
return mSlots[slot].spriteId;
}
+const BeingSlot &Being::getSpriteSlot(const int slot) const restrict2
+{
+ if (slot < 0 || CAST_SIZE(slot) >= mSlots.size())
+ return *emptyBeingSlot;
+
+ return mSlots[slot];
+}
+
ItemColor Being::getSpriteColor(const int slot) const restrict2
{
if (slot < 0 || CAST_SIZE(slot) >= mSlots.size())
diff --git a/src/being/being.h b/src/being/being.h
index 376c180d5..bf05d091b 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -842,6 +842,9 @@ class Being notfinal : public ActorSprite,
int getSpriteID(const int slot) const restrict2 A_WARN_UNUSED;
+ const BeingSlot &getSpriteSlot(const int slot) const
+ restrict2 A_WARN_UNUSED;
+
ItemColor getSpriteColor(const int slot) const restrict2 A_WARN_UNUSED;
void setHairStyle(const unsigned int slot,
@@ -853,6 +856,9 @@ class Being notfinal : public ActorSprite,
void setHairColor(const ItemColor color) restrict2 noexcept2
{ mHairColor = color; }
+ void setSpriteSlot(const unsigned int slot,
+ const BeingSlot &beingSlot);
+
ItemColor getHairColor() const noexcept2 A_WARN_UNUSED
{ return mHairColor; }
diff --git a/src/game.cpp b/src/game.cpp
index e6da61255..84f76308c 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -107,6 +107,7 @@
#include "net/packetcounters.h"
#include "net/serverfeatures.h"
+#include "resources/beingslot.h"
#include "resources/delayedmanager.h"
#include "resources/imagewriter.h"
#include "resources/mapreader.h"
@@ -402,6 +403,8 @@ Game::Game() :
viewport->setSize(mainGraphics->mWidth, mainGraphics->mHeight);
PlayerInfo::clear();
+ emptyBeingSlot = new BeingSlot;
+
BasicContainer2 *const top = static_cast<BasicContainer2*>(gui->getTop());
if (top)
top->add(viewport);
diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp
index af23b6b28..d8b6aad74 100644
--- a/src/gui/windows/charcreatedialog.cpp
+++ b/src/gui/windows/charcreatedialog.cpp
@@ -149,15 +149,17 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
setContentSize(w, h);
mPlayer->setGender(Gender::MALE);
- const std::vector<int> &items = CharDB::getDefaultItems();
+ const std::vector<BeingSlot> &items = CharDB::getDefaultItems();
int i = 1;
- for (std::vector<int>::const_iterator it = items.begin(),
+ for (std::vector<BeingSlot>::const_iterator it = items.begin(),
it_fend = items.end();
it != it_fend;
++ it, i ++)
{
- mPlayer->setSpriteId(i,
- *it);
+ const BeingSlot &beingSlot = *it;
+ mPlayer->setSpriteCards(i,
+ beingSlot.spriteId,
+ beingSlot.cardsId);
}
if (!maxHairColor)
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<int> mDefaultItems;
+ std::vector<BeingSlot> 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<int> &CharDB::getDefaultItems()
+const std::vector<BeingSlot> &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 <vector>
/**
@@ -67,7 +69,7 @@ namespace CharDB
unsigned getMaxRace() A_WARN_UNUSED;
- const std::vector<int> &getDefaultItems() A_WARN_UNUSED;
+ const std::vector<BeingSlot> &getDefaultItems() A_WARN_UNUSED;
} // namespace CharDB
#endif // RESOURCES_DB_CHARDB_H