summaryrefslogtreecommitdiff
path: root/src/player.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-08-14 12:21:07 -0600
committerJared Adams <jaxad0127@gmail.com>2009-08-14 12:26:38 -0600
commit9d1fbb5a538b3c5a1ba7d5ab55f39033ddb880f1 (patch)
tree88ac95203280fbe994273ede7ec10b1acfbb9b4b /src/player.cpp
parentafc879b5ca185cfd93e604942aac45e76dc3c322 (diff)
downloadmana-9d1fbb5a538b3c5a1ba7d5ab55f39033ddb880f1.tar.gz
mana-9d1fbb5a538b3c5a1ba7d5ab55f39033ddb880f1.tar.bz2
mana-9d1fbb5a538b3c5a1ba7d5ab55f39033ddb880f1.tar.xz
mana-9d1fbb5a538b3c5a1ba7d5ab55f39033ddb880f1.zip
Add functions to more easily work with equipment
Move hair changes back over to them; related server change was reverted. Also move NPCs back over to extending Player. NPCs will have equipment in the future too, but for now, disable that part while we finish the system.
Diffstat (limited to 'src/player.cpp')
-rw-r--r--src/player.cpp41
1 files changed, 28 insertions, 13 deletions
diff --git a/src/player.cpp b/src/player.cpp
index 55888654..288c565d 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -38,16 +38,27 @@
#include "utils/stringutils.h"
-Player::Player(int id, int job, Map *map):
+Player::Player(int id, int job, Map *map, bool isNPC):
Being(id, job, map),
mGender(GENDER_UNSPECIFIED),
- mSpriteIDs(VECTOREND_SPRITE, 0),
- mSpriteColors(VECTOREND_SPRITE, ""),
mIsGM(false),
mInParty(false)
{
- for (int i = 0; i < VECTOREND_SPRITE; i++)
- mSprites.push_back(NULL);
+ if (!isNPC)
+ {
+ for (int i = 0; i < VECTOREND_SPRITE; i++)
+ {
+ mSprites.push_back(NULL);
+ mSpriteIDs.push_back(0);
+ mSpriteColors.push_back("");
+ }
+
+ /* Human base sprite. When implementing different races remove this
+ * line and set the base sprite when setting the race of the player
+ * character.
+ */
+ setSprite(BASE_SPRITE, -100);
+ }
mShowName = config.getValue("visiblenames", 1);
config.addListener("visiblenames", this);
@@ -125,14 +136,8 @@ void Player::setGender(Gender gender)
{
mGender = gender;
- /* Human base sprite. When implementing different races remove this
- * line and set the base sprite when setting the race of the player
- * character.
- */
- setSprite(BASE_SPRITE, -100);
-
// Reload all subsprites
- for (unsigned int i = 1; i < mSprites.size(); i++)
+ for (unsigned int i = 0; i < mSprites.size(); i++)
{
if (mSpriteIDs.at(i) != 0)
setSprite(i, mSpriteIDs.at(i), mSpriteColors.at(i));
@@ -147,7 +152,7 @@ void Player::setGM(bool gm)
updateColors();
}
-void Player::setSprite(int slot, int id, const std::string &color)
+void Player::setSprite(unsigned int slot, int id, const std::string &color)
{
assert(slot >= BASE_SPRITE && slot < VECTOREND_SPRITE);
@@ -193,6 +198,16 @@ void Player::setSprite(int slot, int id, const std::string &color)
mSpriteColors[slot] = color;
}
+void Player::setSpriteID(unsigned int slot, int id)
+{
+ setSprite(slot, id, mSpriteColors[slot]);
+}
+
+void Player::setSpriteColor(unsigned int slot, const std::string &color)
+{
+ setSprite(slot, mSpriteIDs[slot], color);
+}
+
#ifdef TMWSERV_SUPPORT
Guild* Player::addGuild(short guildId, short rights)
{