summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-05-02 10:10:37 +0200
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-05-02 10:11:19 +0200
commit679d830d0ba6ecbcd698b1ff2625144d08314b9e (patch)
tree24e5c1ea5fa6f11165d726cd345726fd3dae8fdd
parent35108f09f64835a8d02c5bfb2ec62426ab83bd59 (diff)
parenta6b11834f227b8edbfb39633380806480fd2a2c5 (diff)
downloadmana-679d830d0ba6ecbcd698b1ff2625144d08314b9e.tar.gz
mana-679d830d0ba6ecbcd698b1ff2625144d08314b9e.tar.bz2
mana-679d830d0ba6ecbcd698b1ff2625144d08314b9e.tar.xz
mana-679d830d0ba6ecbcd698b1ff2625144d08314b9e.zip
Merge branch 'master' into lpc2012
This merge reverts change 3b22c2cf170c877904dcef5a4af03ac360bd0581. Conflicts: src/gui/charcreatedialog.cpp src/net/manaserv/manaserv_protocol.h
-rw-r--r--mana.files7
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/client.cpp3
-rw-r--r--src/gui/charcreatedialog.cpp127
-rw-r--r--src/gui/charcreatedialog.h10
-rw-r--r--src/gui/ministatuswindow.cpp2
-rw-r--r--src/gui/skilldialog.cpp3
-rw-r--r--src/net/manaserv/charhandler.cpp9
-rw-r--r--src/net/manaserv/generalhandler.cpp5
-rw-r--r--src/net/manaserv/manaserv_protocol.h2
-rw-r--r--src/net/manaserv/playerhandler.cpp6
-rw-r--r--src/net/tmwa/charserverhandler.cpp26
-rw-r--r--src/net/tmwa/charserverhandler.h11
-rw-r--r--src/net/tmwa/generalhandler.cpp19
-rw-r--r--src/resources/attributes.cpp (renamed from src/net/manaserv/attributes.cpp)19
-rw-r--r--src/resources/attributes.h (renamed from src/net/manaserv/attributes.h)10
-rw-r--r--src/resources/chardb.cpp132
-rw-r--r--src/resources/chardb.h48
-rw-r--r--src/resources/specialdb.cpp3
-rw-r--r--src/resources/theme.cpp2
-rw-r--r--src/utils/xml.h4
21 files changed, 346 insertions, 108 deletions
diff --git a/mana.files b/mana.files
index 1819ce29..0871367e 100644
--- a/mana.files
+++ b/mana.files
@@ -18,7 +18,8 @@ data/help/index.txt
data/help/support.txt
data/help/windows.txt
data/icons/CMakeLists.txt
-docs/FAQ.txt
+data/sfx/CMakeLists.txt
+data/sfx/system/CMakeLists.txt
docs/HACKING.txt
docs/example.mana
docs/items.txt
@@ -342,8 +343,6 @@ src/net/logindata.h
src/net/loginhandler.h
src/net/manaserv/adminhandler.cpp
src/net/manaserv/adminhandler.h
-src/net/manaserv/attributes.cpp
-src/net/manaserv/attributes.h
src/net/manaserv/beinghandler.cpp
src/net/manaserv/beinghandler.h
src/net/manaserv/buysellhandler.cpp
@@ -470,6 +469,8 @@ src/resources/ambientlayer.cpp
src/resources/ambientlayer.h
src/resources/animation.cpp
src/resources/animation.h
+src/resources/attributes.cpp
+src/resources/attributes.h
src/resources/beinginfo.cpp
src/resources/beinginfo.h
src/resources/dye.cpp
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 74da785a..8ce230ea 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -367,8 +367,12 @@ SET(SRCS
resources/ambientlayer.h
resources/animation.cpp
resources/animation.h
+ resources/attributes.cpp
+ resources/attributes.h
resources/beinginfo.cpp
resources/beinginfo.h
+ resources/chardb.cpp
+ resources/chardb.h
resources/dye.cpp
resources/dye.h
resources/emotedb.cpp
@@ -595,8 +599,6 @@ SET(SRCS_TMWA
SET(SRCS_MANA
net/manaserv/adminhandler.cpp
net/manaserv/adminhandler.h
- net/manaserv/attributes.cpp
- net/manaserv/attributes.h
net/manaserv/beinghandler.cpp
net/manaserv/beinghandler.h
net/manaserv/buysellhandler.cpp
diff --git a/src/client.cpp b/src/client.cpp
index 16c43f19..88a2a523 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -64,6 +64,7 @@
#include "net/net.h"
#include "net/worldinfo.h"
+#include "resources/chardb.h"
#include "resources/hairdb.h"
#include "resources/emotedb.h"
#include "resources/image.h"
@@ -451,6 +452,7 @@ Client::~Client()
SDL_RemoveTimer(mSecondsCounterId);
// Unload XML databases
+ CharDB::unload();
hairDB.unload();
EmoteDB::unload();
delete itemDb;
@@ -762,6 +764,7 @@ int Client::exec()
Event::trigger(Event::ClientChannel, Event::LoadingDatabases);
// Load XML databases
+ CharDB::load();
hairDB.load();
switch (Net::getNetworkType())
{
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp
index 931735f8..a7e76989 100644
--- a/src/gui/charcreatedialog.cpp
+++ b/src/gui/charcreatedialog.cpp
@@ -41,6 +41,7 @@
#include "net/charhandler.h"
#include "net/net.h"
+#include "resources/chardb.h"
#include "resources/hairdb.h"
#include "utils/gettext.h"
@@ -56,6 +57,10 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
mPlayer = new Being(0, ActorSprite::PLAYER, 0, NULL);
mPlayer->setGender(GENDER_MALE);
+ const std::vector<int> &items = CharDB::getDefaultItems();
+ for (size_t i = 0; i < items.size(); ++i)
+ mPlayer->setSprite(i + 1, items.at(i));
+
mHairStylesIds = hairDB.getHairStyleIds(
Net::getCharHandler()->getCharCreateMaxHairStyleId());
mHairStyleId = rand() * mHairStylesIds.size() / RAND_MAX;
@@ -101,8 +106,11 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
mNameField->setActionEventId("create");
mNameField->addActionListener(this);
+ mAttributesLeft = new Label(
+ strprintf(_("Please distribute %d points"), 99));
+
int w = 200;
- int h = 160;
+ int h = 330;
setContentSize(w, h);
mPlayerBox->setDimension(gcn::Rectangle(80, 30, 110, 85));
mNameLabel->setPosition(5, 5);
@@ -114,6 +122,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
mPrevHairStyleButton->setPosition(90, 64);
mNextHairStyleButton->setPosition(165, 64);
mHairStyleLabel->setPosition(5, 70);
+ mAttributesLeft->setPosition(15, 280);
updateSliders();
mCancelButton->setPosition(
w - 5 - mCancelButton->getWidth(),
@@ -134,6 +143,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
add(mNextHairStyleButton);
add(mPrevHairStyleButton);
add(mHairStyleLabel);
+ add(mAttributesLeft);
add(mCreateButton);
add(mCancelButton);
@@ -164,12 +174,6 @@ void CharCreateDialog::action(const gcn::ActionEvent &event)
// Attempt to create the character
mCreateButton->setEnabled(false);
- std::vector<int> atts;
- for (unsigned i = 0; i < mAttributeSlider.size(); i++)
- {
- atts.push_back((int) mAttributeSlider[i]->getValue());
- }
-
int characterSlot = mSlot;
// On Manaserv, the slots start at 1, so we offset them.
if (Net::getNetworkType() == ServerInfo::MANASERV)
@@ -182,7 +186,8 @@ void CharCreateDialog::action(const gcn::ActionEvent &event)
0 : mHairColorsIds.at(mHairColorId);
Net::getCharHandler()->newCharacter(getName(), characterSlot,
mFemale->isSelected(),
- hairStyle, hairColor, atts);
+ hairStyle, hairColor,
+ mAttributes);
}
else
{
@@ -192,7 +197,9 @@ void CharCreateDialog::action(const gcn::ActionEvent &event)
}
}
else if (event.getId() == "cancel")
+ {
scheduleDelete();
+ }
else if (event.getId() == "nextcolor")
{
++mHairColorId;
@@ -235,19 +242,24 @@ std::string CharCreateDialog::getName() const
void CharCreateDialog::updateSliders()
{
- if (Net::getNetworkType() == ServerInfo::MANASERV)
- return;
+ int distributedPoints = 0;
+ // Update captions and synchronize values
for (unsigned i = 0; i < mAttributeSlider.size(); i++)
{
- // Update captions
- mAttributeValue[i]->setCaption(
- toString((int) (mAttributeSlider[i]->getValue())));
- mAttributeValue[i]->adjustSize();
+ gcn::Slider *slider = mAttributeSlider[i];
+ gcn::Label *valueLabel = mAttributeValue[i];
+ int value = static_cast<int>(slider->getValue());
+
+ valueLabel->setCaption(toString(value));
+ valueLabel->adjustSize();
+
+ mAttributes[i] = value;
+ distributedPoints += value;
}
// Update distributed points
- int pointsLeft = mMaxPoints - getDistributedPoints();
+ int pointsLeft = mMaxPoints - distributedPoints;
if (pointsLeft == 0)
{
mAttributesLeft->setCaption(_("Character stats OK"));
@@ -276,20 +288,9 @@ void CharCreateDialog::unlock()
mCreateButton->setEnabled(true);
}
-int CharCreateDialog::getDistributedPoints() const
-{
- int points = 0;
-
- for (unsigned i = 0; i < mAttributeSlider.size(); i++)
- {
- points += (int) mAttributeSlider[i]->getValue();
- }
- return points;
-}
-
void CharCreateDialog::setAttributes(const std::vector<std::string> &labels,
- unsigned int available, unsigned int min,
- unsigned int max)
+ unsigned available, unsigned min,
+ unsigned max)
{
mMaxPoints = available;
@@ -303,34 +304,57 @@ void CharCreateDialog::setAttributes(const std::vector<std::string> &labels,
delete mAttributeValue[i];
}
- mAttributeLabel.resize(labels.size());
- mAttributeSlider.resize(labels.size());
- mAttributeValue.resize(labels.size());
+ mAttributeLabel.clear();
+ mAttributeSlider.clear();
+ mAttributeValue.clear();
+
+ mAttributes.resize(labels.size(), min);
int w = 200;
- int h = 330;
+ int h = 190;
- for (unsigned i = 0; i < labels.size(); i++)
+ // No attribute sliders when they can not be adapted by the user
+ if (min == max)
{
- mAttributeLabel[i] = new Label(labels[i]);
- mAttributeLabel[i]->setWidth(70);
- mAttributeLabel[i]->setPosition(5, 140 + i*20);
- add(mAttributeLabel[i]);
-
- mAttributeSlider[i] = new Slider(min, max);
- mAttributeSlider[i]->setDimension(gcn::Rectangle(75, 140 + i * 20,
- 100, 10));
- mAttributeSlider[i]->setActionEventId("statslider");
- mAttributeSlider[i]->addActionListener(this);
- add(mAttributeSlider[i]);
-
- mAttributeValue[i] = new Label(toString(min));
- mAttributeValue[i]->setPosition(180, 140 + i*20);
- add(mAttributeValue[i]);
+ mAttributesLeft->setVisible(false);
+ mCreateButton->setEnabled(true);
}
+ else
+ {
+ h += 20 * labels.size() + 20;
- mAttributesLeft->setPosition(15, 280);
- updateSliders();
+ mAttributeLabel.resize(labels.size());
+ mAttributeSlider.resize(labels.size());
+ mAttributeValue.resize(labels.size());
+
+ for (unsigned i = 0; i < labels.size(); i++)
+ {
+ const int y = 140 + i * 20;
+
+ Label *attributeLabel = new Label(labels[i]);
+ attributeLabel->setWidth(70);
+ attributeLabel->setPosition(5, y);
+ add(attributeLabel);
+
+ Slider *attributeSlider = new Slider(min, max);
+ attributeSlider->setDimension(gcn::Rectangle(75, y, 100, 10));
+ attributeSlider->setActionEventId("statslider");
+ attributeSlider->addActionListener(this);
+ add(attributeSlider);
+
+ Label *attributeValue = new Label(toString(min));
+ attributeValue->setPosition(180, y);
+ add(attributeValue);
+
+ mAttributeLabel[i] = attributeLabel;
+ mAttributeSlider[i] = attributeSlider;
+ mAttributeValue[i] = attributeValue;
+ }
+
+ mAttributesLeft->setVisible(true);
+ mAttributesLeft->setPosition(15, h - 50);
+ updateSliders();
+ }
mCancelButton->setPosition(
w - 5 - mCancelButton->getWidth(),
@@ -338,6 +362,9 @@ void CharCreateDialog::setAttributes(const std::vector<std::string> &labels,
mCreateButton->setPosition(
mCancelButton->getX() - 5 - mCreateButton->getWidth(),
h - 5 - mCancelButton->getHeight());
+
+ setContentSize(w, h);
+ center();
}
void CharCreateDialog::setFixedGender(bool fixed, Gender gender)
diff --git a/src/gui/charcreatedialog.h b/src/gui/charcreatedialog.h
index 7548bbff..9f49f6c5 100644
--- a/src/gui/charcreatedialog.h
+++ b/src/gui/charcreatedialog.h
@@ -58,14 +58,12 @@ class CharCreateDialog : public Window, public gcn::ActionListener
void unlock();
void setAttributes(const std::vector<std::string> &labels,
- unsigned int available,
- unsigned int min, unsigned int max);
+ unsigned available,
+ unsigned min, unsigned max);
void setFixedGender(bool fixed, Gender gender = GENDER_FEMALE);
private:
- int getDistributedPoints() const;
-
void updateSliders();
/**
@@ -94,13 +92,13 @@ class CharCreateDialog : public Window, public gcn::ActionListener
gcn::RadioButton *mMale;
gcn::RadioButton *mFemale;
+ std::vector<int> mAttributes;
std::vector<gcn::Slider*> mAttributeSlider;
std::vector<gcn::Label*> mAttributeLabel;
std::vector<gcn::Label*> mAttributeValue;
gcn::Label *mAttributesLeft;
- int mMaxPoints;
- int mUsedPoints;
+ unsigned mMaxPoints;
gcn::Button *mCreateButton;
gcn::Button *mCancelButton;
diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp
index ac0ae5d7..e050563f 100644
--- a/src/gui/ministatuswindow.cpp
+++ b/src/gui/ministatuswindow.cpp
@@ -162,8 +162,6 @@ void MiniStatusWindow::event(Event::Channel channel,
AnimatedSprite *sprite = effect->getIcon();
- typedef std::vector<int> IntMap;
-
if (!sprite)
{
// delete sprite, if necessary
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 98db3cc1..fb5067a5 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -352,7 +352,8 @@ void SkillDialog::loadSkills()
for_each_xml_child_node(set, root)
{
- if (xmlStrEqual(set->name, BAD_CAST "set"))
+ if (xmlStrEqual(set->name, BAD_CAST "set") ||
+ xmlStrEqual(set->name, BAD_CAST "skill-set"))
{
setCount++;
setName = XML::getProperty(set, "name", strprintf(_("Skill Set %d"), setCount));
diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp
index 32b3feb5..ece8e108 100644
--- a/src/net/manaserv/charhandler.cpp
+++ b/src/net/manaserv/charhandler.cpp
@@ -1,7 +1,7 @@
/*
* The Mana Client
* Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2012 The Mana Developers
+ * Copyright (C) 2009-2013 The Mana Developers
*
* This file is part of The Mana Client.
*
@@ -39,8 +39,8 @@
#include "net/manaserv/messagein.h"
#include "net/manaserv/messageout.h"
#include "net/manaserv/manaserv_protocol.h"
-#include "net/manaserv/attributes.h"
+#include "resources/attributes.h"
#include "resources/hairdb.h"
#include "utils/dtor.h"
@@ -290,6 +290,11 @@ void CharHandler::setCharCreateDialog(CharCreateDialog *window)
if (!mCharCreateDialog)
return;
+
+ mCharCreateDialog->setAttributes(Attributes::getLabels(),
+ Attributes::getCreationPoints(),
+ Attributes::getAttributeMinimum(),
+ Attributes::getAttributeMaximum());
}
void CharHandler::requestCharacters()
diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp
index d1fa41fe..c6b2af18 100644
--- a/src/net/manaserv/generalhandler.cpp
+++ b/src/net/manaserv/generalhandler.cpp
@@ -1,7 +1,7 @@
/*
* The Mana Client
* Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2012 The Mana Developers
+ * Copyright (C) 2009-2013 The Mana Developers
*
* This file is part of The Mana Client.
*
@@ -47,9 +47,10 @@
#include "net/manaserv/partyhandler.h"
#include "net/manaserv/playerhandler.h"
#include "net/manaserv/specialhandler.h"
-#include "net/manaserv/attributes.h"
#include "net/manaserv/tradehandler.h"
+#include "resources/attributes.h"
+
#include "utils/gettext.h"
#include <list>
diff --git a/src/net/manaserv/manaserv_protocol.h b/src/net/manaserv/manaserv_protocol.h
index 7b35f278..760fe655 100644
--- a/src/net/manaserv/manaserv_protocol.h
+++ b/src/net/manaserv/manaserv_protocol.h
@@ -25,7 +25,7 @@
namespace ManaServ {
enum {
- PROTOCOL_VERSION = 2,
+ PROTOCOL_VERSION = 3,
SUPPORTED_DB_VERSION = 21
};
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index 484e551a..c1f78f67 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -1,7 +1,7 @@
/*
* The Mana Client
* Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2012 The Mana Developers
+ * Copyright (C) 2009-2013 The Mana Developers
*
* This file is part of The Mana Client.
*
@@ -20,7 +20,6 @@
*/
#include "net/manaserv/playerhandler.h"
-#include "net/manaserv/beinghandler.h"
#include "client.h"
#include "effectmanager.h"
@@ -43,7 +42,8 @@
#include "net/manaserv/messagein.h"
#include "net/manaserv/messageout.h"
#include "net/manaserv/manaserv_protocol.h"
-#include "net/manaserv/attributes.h"
+
+#include "resources/attributes.h"
/**
* Max. distance in tiles we are willing to scroll after a teleport;
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
index ce193821..7c5f5c88 100644
--- a/src/net/tmwa/charserverhandler.cpp
+++ b/src/net/tmwa/charserverhandler.cpp
@@ -38,6 +38,8 @@
#include "net/tmwa/network.h"
#include "net/tmwa/protocol.h"
+#include "resources/attributes.h"
+#include "resources/chardb.h"
#include "resources/hairdb.h"
#include "utils/dtor.h"
@@ -278,7 +280,17 @@ void CharServerHandler::setCharCreateDialog(CharCreateDialog *window)
const Token &token =
static_cast<LoginHandler*>(Net::getLoginHandler())->getToken();
- mCharCreateDialog->setAttributes(attributes, 30, 1, 9);
+ unsigned minStat = CharDB::getMinStat();
+ if (minStat == 0)
+ minStat = Attributes::getAttributeMinimum();
+ unsigned maxStat = CharDB::getMaxStat();
+ if (maxStat == 0)
+ maxStat = Attributes::getAttributeMaximum();
+ unsigned sumStat = CharDB::getSumStat();
+ if (sumStat == 0)
+ sumStat = Attributes::getCreationPoints();
+
+ mCharCreateDialog->setAttributes(attributes, sumStat, minStat, maxStat);
mCharCreateDialog->setFixedGender(true, token.sex);
}
@@ -342,6 +354,18 @@ unsigned int CharServerHandler::maxSprite() const
return SPRITE_VECTOREND;
}
+int CharServerHandler::getCharCreateMaxHairColorId() const
+{
+ const int max = CharDB::getMaxHairColor();
+ return max ? max : 11; // default maximum
+}
+
+int CharServerHandler::getCharCreateMaxHairStyleId() const
+{
+ const int max = CharDB::getMaxHairStyle();
+ return max ? max : 19; // default maximum
+}
+
void CharServerHandler::connect()
{
const Token &token =
diff --git a/src/net/tmwa/charserverhandler.h b/src/net/tmwa/charserverhandler.h
index c9f44e0f..7e4fc2d9 100644
--- a/src/net/tmwa/charserverhandler.h
+++ b/src/net/tmwa/charserverhandler.h
@@ -69,15 +69,8 @@ class CharServerHandler : public MessageHandler, public Net::CharHandler
unsigned int maxSprite() const;
- // Must be < 12 at character creation time, but can be higher
- // after that.
- int getCharCreateMaxHairColorId() const
- { return 11; }
-
- // Must be < 20 at character creation time, but can be higher
- // after that.
- int getCharCreateMaxHairStyleId() const
- { return 19; }
+ int getCharCreateMaxHairColorId() const;
+ int getCharCreateMaxHairStyleId() const;
void connect();
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index 6c2bcddb..0ce16691 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -1,7 +1,7 @@
/*
* The Mana Client
* Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2012 The Mana Developers
+ * Copyright (C) 2009-2013 The Mana Developers
*
* This file is part of The Mana Client.
*
@@ -57,11 +57,11 @@
#include "net/tmwa/gui/guildtab.h"
#include "net/tmwa/gui/partytab.h"
+#include "resources/attributes.h"
#include "resources/itemdb.h"
#include "utils/gettext.h"
-#include <assert.h>
#include <list>
extern Net::GeneralHandler *generalHandler;
@@ -108,6 +108,7 @@ GeneralHandler::GeneralHandler():
setStatsList(stats);
+ listen(Event::ClientChannel);
listen(Event::GameChannel);
}
@@ -185,12 +186,17 @@ void GeneralHandler::reload()
static_cast<LoginHandler*>(mLoginHandler.get())->clearWorlds();
static_cast<CharServerHandler*>(mCharHandler.get())->setCharCreateDialog(0);
static_cast<CharServerHandler*>(mCharHandler.get())->setCharSelectDialog(0);
+
+ Attributes::unload();
+ Attributes::load();
}
void GeneralHandler::unload()
{
if (mNetwork)
mNetwork->clearHandlers();
+
+ Attributes::unload();
}
void GeneralHandler::flushNetwork()
@@ -220,7 +226,14 @@ void GeneralHandler::clearHandlers()
void GeneralHandler::event(Event::Channel channel,
const Event &event)
{
- if (channel == Event::GameChannel)
+ if (channel == Event::ClientChannel)
+ {
+ if (event.getType() == Event::LoadingDatabases)
+ {
+ Attributes::load();
+ }
+ }
+ else if (channel == Event::GameChannel)
{
if (event.getType() == Event::GuiWindowsLoaded)
{
diff --git a/src/net/manaserv/attributes.cpp b/src/resources/attributes.cpp
index e754a6a9..c4c67fba 100644
--- a/src/net/manaserv/attributes.cpp
+++ b/src/resources/attributes.cpp
@@ -1,6 +1,6 @@
/*
* The Mana Client
- * Copyright (C) 2010-2012 The Mana Developers
+ * Copyright (C) 2010-2013 The Mana Developers
*
* This file is part of The Mana Client.
*
@@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "net/manaserv/attributes.h"
+#include "resources/attributes.h"
#include "log.h"
#include "playerinfo.h"
@@ -35,11 +35,10 @@
#include <map>
#define DEFAULT_ATTRIBUTESDB_FILE "attributes.xml"
-#define DEFAULT_POINTS 60
+#define DEFAULT_POINTS 30
#define DEFAULT_MIN_PTS 1
-#define DEFAULT_MAX_PTS 20
+#define DEFAULT_MAX_PTS 9
-namespace ManaServ {
namespace Attributes {
typedef struct
@@ -67,9 +66,9 @@ namespace Attributes {
static std::vector<std::string> attributeLabels;
/** Characters creation points. */
- static unsigned int creationPoints = 0;
- static unsigned int attributeMinimum = 0;
- static unsigned int attributeMaximum = 0;
+ static unsigned int creationPoints = DEFAULT_POINTS;
+ static unsigned int attributeMinimum = DEFAULT_MIN_PTS;
+ static unsigned int attributeMaximum = DEFAULT_MAX_PTS;
unsigned int getCreationPoints()
{
@@ -381,8 +380,7 @@ namespace Attributes {
TagMap::const_iterator it, it_end;
for (it = tags.begin(), it_end = tags.end(); it != it_end; ++it)
- dbStats.push_back(ItemStat(it->first,
- it->second));
+ dbStats.push_back(ItemStat(it->first, it->second));
setStatsList(dbStats);
}
@@ -405,4 +403,3 @@ namespace Attributes {
}
} // namespace Attributes
-} // namespace ManaServ
diff --git a/src/net/manaserv/attributes.h b/src/resources/attributes.h
index e004d16c..7124ba94 100644
--- a/src/net/manaserv/attributes.h
+++ b/src/resources/attributes.h
@@ -1,6 +1,6 @@
/*
* The Mana Client
- * Copyright (C) 2010-2012 The Mana Developers
+ * Copyright (C) 2010-2013 The Mana Developers
*
* This file is part of The Mana Client.
*
@@ -18,13 +18,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef NET_MANASERV_ATTRIBUTES_H
-#define NET_MANASERV_ATTRIBUTES_H
+#ifndef RESOURCES_ATTRIBUTES_H
+#define RESOURCES_ATTRIBUTES_H
#include <string>
#include <vector>
-namespace ManaServ {
namespace Attributes {
void load();
@@ -65,6 +64,5 @@ namespace Attributes {
unsigned int getAttributeMaximum();
} // namespace Attributes
-} // namespace ManaServ
-#endif // NET_MANASERV_ATTRIBUTES_H
+#endif // RESOURCES_ATTRIBUTES_H
diff --git a/src/resources/chardb.cpp b/src/resources/chardb.cpp
new file mode 100644
index 00000000..40ecd999
--- /dev/null
+++ b/src/resources/chardb.cpp
@@ -0,0 +1,132 @@
+/*
+ * Character creation settings
+ * Copyright (C) 2011-2013 The ManaPlus Developers
+ * Copyright (C) 2013 The Mana Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "resources/chardb.h"
+
+#include "log.h"
+
+#include "utils/xml.h"
+
+namespace
+{
+ bool mLoaded = false;
+ unsigned mMinHairColor = 0;
+ unsigned mMaxHairColor = 0;
+ unsigned mMinHairStyle = 0;
+ unsigned mMaxHairStyle = 0;
+ unsigned mMinStat = 0;
+ unsigned mMaxStat = 0;
+ unsigned mSumStat = 0;
+ std::vector<int> mDefaultItems;
+}
+
+static void loadMinMax(xmlNodePtr node, unsigned *min, unsigned *max)
+{
+ *min = XML::getProperty(node, "min", 1);
+ *max = XML::getProperty(node, "max", 10);
+}
+
+void CharDB::load()
+{
+ if (mLoaded)
+ unload();
+
+ XML::Document doc("charcreation.xml");
+ xmlNodePtr root = doc.rootNode();
+
+ if (!root || !xmlStrEqual(root->name, BAD_CAST "chars"))
+ {
+ logger->log("CharDB: Failed to parse charcreation.xml.");
+ return;
+ }
+
+ for_each_xml_child_node(node, root)
+ {
+ if (xmlStrEqual(node->name, BAD_CAST "haircolor"))
+ {
+ loadMinMax(node, &mMinHairColor, &mMaxHairColor);
+ }
+ else if (xmlStrEqual(node->name, BAD_CAST "hairstyle"))
+ {
+ loadMinMax(node, &mMinHairStyle, &mMaxHairStyle);
+ }
+ else if (xmlStrEqual(node->name, BAD_CAST "stat"))
+ {
+ loadMinMax(node, &mMinStat, &mMaxStat);
+ mSumStat = XML::getProperty(node, "sum", 0);
+ }
+ else if (xmlStrEqual(node->name, BAD_CAST "item"))
+ {
+ const int id = XML::getProperty(node, "id", 0);
+ if (id > 0)
+ mDefaultItems.push_back(id);
+ }
+ }
+
+ mLoaded = true;
+}
+
+void CharDB::unload()
+{
+ logger->log("Unloading chars database...");
+
+ mLoaded = false;
+}
+
+unsigned CharDB::getMinHairColor()
+{
+ return mMinHairColor;
+}
+
+unsigned CharDB::getMaxHairColor()
+{
+ return mMaxHairColor;
+}
+
+unsigned CharDB::getMinHairStyle()
+{
+ return mMinHairStyle;
+}
+
+unsigned CharDB::getMaxHairStyle()
+{
+ return mMaxHairStyle;
+}
+
+unsigned CharDB::getMinStat()
+{
+ return mMinStat;
+}
+
+unsigned CharDB::getMaxStat()
+{
+ return mMaxStat;
+}
+
+unsigned CharDB::getSumStat()
+{
+ return mSumStat;
+}
+
+const std::vector<int> &CharDB::getDefaultItems()
+{
+ return mDefaultItems;
+}
diff --git a/src/resources/chardb.h b/src/resources/chardb.h
new file mode 100644
index 00000000..10530b26
--- /dev/null
+++ b/src/resources/chardb.h
@@ -0,0 +1,48 @@
+/*
+ * Character creation settings
+ * Copyright (C) 2011-2013 The ManaPlus Developers
+ * Copyright (C) 2013 The Mana Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef RESOURCES_CHARDB_H
+#define RESOURCES_CHARDB_H
+
+#include <vector>
+
+/**
+ * Character creation settings.
+ */
+namespace CharDB
+{
+ void load();
+ void unload();
+
+ unsigned getMinHairColor();
+ unsigned getMaxHairColor();
+
+ unsigned getMinHairStyle();
+ unsigned getMaxHairStyle();
+
+ unsigned getMinStat();
+ unsigned getMaxStat();
+ unsigned getSumStat();
+
+ const std::vector<int> &getDefaultItems();
+}
+
+#endif // RESOURCES_CHARDB_H
diff --git a/src/resources/specialdb.cpp b/src/resources/specialdb.cpp
index 426a1143..c75f4b1b 100644
--- a/src/resources/specialdb.cpp
+++ b/src/resources/specialdb.cpp
@@ -61,7 +61,8 @@ void SpecialDB::load()
for_each_xml_child_node(set, root)
{
- if (xmlStrEqual(set->name, BAD_CAST "set"))
+ if (xmlStrEqual(set->name, BAD_CAST "set") ||
+ xmlStrEqual(set->name, BAD_CAST "special-set"))
{
setName = XML::getProperty(set, "name", "Actions");
diff --git a/src/resources/theme.cpp b/src/resources/theme.cpp
index 036cd4a3..8db05be9 100644
--- a/src/resources/theme.cpp
+++ b/src/resources/theme.cpp
@@ -542,7 +542,7 @@ void Theme::loadColors(std::string file)
if (file == "")
file = defaultThemePath;
- file += "/" COLORS_XML_FILE;
+ file += "/colors.xml";
XML::Document doc(file);
xmlNodePtr root = doc.rootNode();
diff --git a/src/utils/xml.h b/src/utils/xml.h
index 1e007cfd..60355aa6 100644
--- a/src/utils/xml.h
+++ b/src/utils/xml.h
@@ -26,10 +26,6 @@
#include <string>
-// Define commonly used xml file
-#define HAIR_XML_FILE "hair.xml"
-#define COLORS_XML_FILE "colors.xml"
-
/**
* XML helper functions.
*/