summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2008-10-23 11:46:21 +0000
committerIra Rice <irarice@gmail.com>2008-10-23 11:46:21 +0000
commit7a88c394584cb02cec8d1d7eb70ac2020e033d41 (patch)
treed19c75ea94072c9b54abb0c679a9bf6984b485c4
parente57f4ec64f53091dd254c2ee2db9592d30a5af0b (diff)
downloadmana-7a88c394584cb02cec8d1d7eb70ac2020e033d41.tar.gz
mana-7a88c394584cb02cec8d1d7eb70ac2020e033d41.tar.bz2
mana-7a88c394584cb02cec8d1d7eb70ac2020e033d41.tar.xz
mana-7a88c394584cb02cec8d1d7eb70ac2020e033d41.zip
Cleaned up ColorDB code so that it loads with all other databases, as
well as fixed color cycling.
-rw-r--r--src/gui/char_select.cpp9
-rw-r--r--src/localplayer.cpp1
-rw-r--r--src/main.cpp3
-rw-r--r--src/player.cpp1
-rw-r--r--src/resources/colordb.cpp3
5 files changed, 9 insertions, 8 deletions
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index 628ab35f..b83f98de 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -257,7 +257,6 @@ CharCreateDialog::CharCreateDialog(Window *parent, int slot, Network *network,
mPlayer = new Player(0, 0, NULL);
mPlayer->setGender(gender);
- ColorDB::load();
int numberOfHairColors = ColorDB::size();
printf("%d\n", numberOfHairColors);
@@ -344,16 +343,16 @@ CharCreateDialog::action(const gcn::ActionEvent &event)
scheduleDelete();
}
else if (event.getId() == "nextcolor") {
- mPlayer->setHairStyle(-1, mPlayer->getHairColor() + 1);
+ mPlayer->setHairStyle(mPlayer->getHairStyle(), (mPlayer->getHairColor() + 1) % numberOfColors);
}
else if (event.getId() == "prevcolor") {
- mPlayer->setHairStyle(-1, mPlayer->getHairColor() + numberOfColors - 1);
+ mPlayer->setHairStyle(mPlayer->getHairStyle(), (mPlayer->getHairColor() + numberOfColors - 1) % numberOfColors);
}
else if (event.getId() == "nextstyle") {
- mPlayer->setHairStyle(mPlayer->getHairStyle() + 1, -1);
+ mPlayer->setHairStyle(mPlayer->getHairStyle() + 1, mPlayer->getHairColor());
}
else if (event.getId() == "prevstyle") {
- mPlayer->setHairStyle(mPlayer->getHairStyle() + NR_HAIR_STYLES - 1, -1);
+ mPlayer->setHairStyle(mPlayer->getHairStyle() + NR_HAIR_STYLES - 1, mPlayer->getHairColor());
}
}
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index d83bd254..66d37ddf 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -54,7 +54,6 @@ LocalPlayer::LocalPlayer(Uint32 id, Uint16 job, Map *map):
mInventory(new Inventory(INVENTORY_SIZE)),
mStorage(new Inventory(STORAGE_SIZE))
{
- ColorDB::load();
}
LocalPlayer::~LocalPlayer()
diff --git a/src/main.cpp b/src/main.cpp
index 3755ad03..b92a4b2d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -81,6 +81,7 @@
#include "net/messageout.h"
#include "net/network.h"
+#include "resources/colordb.h"
#include "resources/image.h"
#include "resources/itemdb.h"
#include "resources/monsterdb.h"
@@ -421,6 +422,7 @@ void exit_engine()
sound.close();
// Unload XML databases
+ ColorDB::unload();
ItemDB::unload();
MonsterDB::unload();
NPCDB::unload();
@@ -838,6 +840,7 @@ int main(int argc, char *argv[])
false);
// Load XML databases
+ ColorDB::load();
ItemDB::load();
MonsterDB::load();
NPCDB::load();
diff --git a/src/player.cpp b/src/player.cpp
index 4025f8f4..37badcdc 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -44,7 +44,6 @@ Player::Player(int id, int job, Map *map):
{
mName = 0;
mIsGM = false;
- ColorDB::load();
}
Player::~Player()
diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp
index f738b471..caa1fbda 100644
--- a/src/resources/colordb.cpp
+++ b/src/resources/colordb.cpp
@@ -98,7 +98,8 @@ void ColorDB::unload()
std::string& ColorDB::get(int id)
{
- assert(mLoaded);
+ if(!mLoaded)
+ load();
ColorIterator i = mColors.find(id);