summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/animatedsprite.cpp6
-rw-r--r--src/animatedsprite.h1
-rw-r--r--src/net/loginhandler.cpp3
-rw-r--r--src/net/network.cpp14
-rw-r--r--src/player.cpp11
-rw-r--r--src/player.h24
6 files changed, 42 insertions, 17 deletions
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp
index d1201042..8f9c0600 100644
--- a/src/animatedsprite.cpp
+++ b/src/animatedsprite.cpp
@@ -34,7 +34,8 @@ AnimatedSprite::AnimatedSprite(const std::string& animationFile, int variant):
mAction(NULL),
mDirection(DIRECTION_DOWN),
mLastTime(0),
- mSpeed(1.0f)
+ mSpeed(1.0f),
+ mAnimationFile(animationFile)
{
int size;
ResourceManager *resman = ResourceManager::getInstance();
@@ -249,7 +250,8 @@ AnimatedSprite::play(SpriteAction action, int time)
if (i == mActions.end())
{
- logger->log("Warning: no action \"%u\" defined!", action);
+ //logger->log("Warning: no action %u defined for \"%s\"!",
+ // action, mAnimationFile.c_str());
mAction = NULL;
return;
}
diff --git a/src/animatedsprite.h b/src/animatedsprite.h
index 89394d6c..b73bdb5c 100644
--- a/src/animatedsprite.h
+++ b/src/animatedsprite.h
@@ -173,6 +173,7 @@ class AnimatedSprite
SpriteDirection mDirection;
int mLastTime;
float mSpeed;
+ std::string mAnimationFile;
};
#endif
diff --git a/src/net/loginhandler.cpp b/src/net/loginhandler.cpp
index ebc8f535..324c33cd 100644
--- a/src/net/loginhandler.cpp
+++ b/src/net/loginhandler.cpp
@@ -52,8 +52,7 @@ void LoginHandler::handleMessage(MessageIn *msg)
// Successful login
if (errMsg == ERRMSG_OK)
{
- unsigned char charNumber;
- charNumber = msg->readByte();
+ unsigned char charNumber = msg->readByte();
printf("Account has %i characters:\n", charNumber);
for (unsigned int i = 0; i < charNumber; i++) {
// Create a temp empty player to show up in character
diff --git a/src/net/network.cpp b/src/net/network.cpp
index f18cf412..dcfbc8f1 100644
--- a/src/net/network.cpp
+++ b/src/net/network.cpp
@@ -146,12 +146,16 @@ void Network::dispatchMessages()
MessageHandlerIterator iter = mMessageHandlers.find(msg.getId());
- printf("Received packet: %x\n", msg.getId());
-
- if (iter != mMessageHandlers.end())
+ if (iter != mMessageHandlers.end()) {
+ logger->log("Received packet %x (%i B)",
+ msg.getId(), msg.getLength());
iter->second->handleMessage(&msg);
- else
- logger->log("Unhandled packet: %x", msg.getId());
+ }
+ else {
+ logger->log("Unhandled packet %x (%i B)",
+ msg.getId(), msg.getLength());
+ }
+
mIncomingPackets.pop();
// Clean up the packet now that we're done using it.
enet_packet_destroy(packet);
diff --git a/src/player.cpp b/src/player.cpp
index 3fe608c7..b864dd0e 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -26,6 +26,7 @@
#include "animatedsprite.h"
#include "game.h"
#include "graphics.h"
+#include "log.h"
#include "utils/tostring.h"
@@ -85,6 +86,13 @@ Player::drawName(Graphics *graphics, Sint32 offsetX, Sint32 offsetY)
void
Player::setSex(Uint8 sex)
{
+ // Players can only be male or female
+ if (sex > 1)
+ {
+ logger->log("Warning: unsupported gender %i, assuming male.", sex);
+ sex = 0;
+ }
+
if (sex != mSex)
{
delete mSprites[BASE_SPRITE];
@@ -98,8 +106,9 @@ Player::setSex(Uint8 sex)
mSprites[BASE_SPRITE] = new AnimatedSprite(
"graphics/sprites/player_female_base.xml", 0);
}
+
+ Being::setSex(sex);
}
- Being::setSex(sex);
}
void
diff --git a/src/player.h b/src/player.h
index 15e7f655..5ff0509f 100644
--- a/src/player.h
+++ b/src/player.h
@@ -35,21 +35,31 @@ class AnimatedSprite;
class Player : public Being
{
public:
+ /**
+ * Constructor.
+ */
Player(Uint32 id, Uint16 job, Map *map);
- virtual void logic();
+ virtual void
+ logic();
- virtual Type getType() const;
+ virtual Type
+ getType() const;
- virtual void drawName(Graphics *graphics, Sint32 offsetX, Sint32 offsetY);
+ virtual void
+ drawName(Graphics *graphics, Sint32 offsetX, Sint32 offsetY);
- virtual void setSex(Uint8 sex);
+ virtual void
+ setSex(Uint8 sex);
- virtual void setHairColor(Uint16 color);
+ virtual void
+ setHairColor(Uint16 color);
- virtual void setHairStyle(Uint16 style);
+ virtual void
+ setHairStyle(Uint16 style);
- virtual void setVisibleEquipment(Uint8 slot, Uint8 id);
+ virtual void
+ setVisibleEquipment(Uint8 slot, Uint8 id);
};
#endif