summaryrefslogtreecommitdiff
path: root/src/player.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-05-02 14:43:40 -0600
committerJared Adams <jaxad0127@gmail.com>2010-05-06 22:21:57 -0600
commit9baedc27191c82bbf1fedee2a7e738bc5b267c0e (patch)
treef0986c6839d1e79b402d5d4ec36e4994741955ea /src/player.cpp
parent844e9a7a72faca6a212e788a3adc45e17f41dca6 (diff)
downloadmana-9baedc27191c82bbf1fedee2a7e738bc5b267c0e.tar.gz
mana-9baedc27191c82bbf1fedee2a7e738bc5b267c0e.tar.bz2
mana-9baedc27191c82bbf1fedee2a7e738bc5b267c0e.tar.xz
mana-9baedc27191c82bbf1fedee2a7e738bc5b267c0e.zip
Add support for floor item sprites
This commit adds a sprite hierarchy (Sprite->ImageSprite,AnimatedSprite,CompundSprite; CompoundSprite,Actor->ActorSprite;ActorSprite->Being,FloorItem) to collect common functionailty into new base classes which will make other Mantis tickets easier to do. Also allows monsters to use particle effects. Reviewed-by: Bertram
Diffstat (limited to 'src/player.cpp')
-rw-r--r--src/player.cpp32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/player.cpp b/src/player.cpp
index 1f706cb8..10c4c500 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -43,23 +43,20 @@
#include "utils/stringutils.h"
-Player::Player(int id, int subtype, Map *map, bool isNPC):
+Player::Player(int id, int subtype, Map *map):
Being(id, subtype, map),
mGender(GENDER_UNSPECIFIED),
mParty(NULL),
mIsGM(false)
{
- if (!isNPC)
+ for (int i = 0; i < Net::getCharHandler()->maxSprite(); i++)
{
- for (int i = 0; i < Net::getCharHandler()->maxSprite(); i++)
- {
- mSprites.push_back(NULL);
- mSpriteIDs.push_back(0);
- mSpriteColors.push_back("");
- }
-
- setSubtype(subtype);
+ push_back(NULL);
+ mSpriteIDs.push_back(0);
+ mSpriteColors.push_back("");
}
+
+ setSubtype(subtype);
mShowName = config.getValue("visiblenames", 1);
config.addListener("visiblenames", this);
@@ -151,7 +148,7 @@ void Player::setGender(Gender gender)
mGender = gender;
// Reload all subsprites
- for (unsigned int i = 0; i < mSprites.size(); i++)
+ for (unsigned int i = 0; i < size(); i++)
{
if (mSpriteIDs.at(i) != 0)
setSprite(i, mSpriteIDs.at(i), mSpriteColors.at(i));
@@ -169,16 +166,13 @@ void Player::setGM(bool gm)
void Player::setSprite(int slot, int id, const std::string &color,
bool isWeapon)
{
- if (getType() == NPC)
- return;
-
assert(slot < Net::getCharHandler()->maxSprite());
// id = 0 means unequip
if (id == 0)
{
- delete mSprites[slot];
- mSprites[slot] = NULL;
+ delete at(slot);
+ at(slot) = NULL;
if (isWeapon)
mEquippedWeapon = NULL;
@@ -200,10 +194,10 @@ void Player::setSprite(int slot, int id, const std::string &color,
if (equipmentSprite)
equipmentSprite->setDirection(getSpriteDirection());
- if (mSprites[slot])
- delete mSprites[slot];
+ if (at(slot))
+ delete at(slot);
- mSprites[slot] = equipmentSprite;
+ at(slot) = equipmentSprite;
if (isWeapon)
mEquippedWeapon = &ItemDB::get(id);