summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2006-11-30 21:01:26 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2006-11-30 21:01:26 +0000
commit30aa32025d3406920330390b97001ade27e4343a (patch)
treee3512dc59c0513c090b3c1af2f3d24e92dae9255
parentc24f9a6ec94e42ae47546c3e93794abb2956d3c1 (diff)
downloadmana-30aa32025d3406920330390b97001ade27e4343a.tar.gz
mana-30aa32025d3406920330390b97001ade27e4343a.tar.bz2
mana-30aa32025d3406920330390b97001ade27e4343a.tar.xz
mana-30aa32025d3406920330390b97001ade27e4343a.zip
Some optimizations to setSex, setWeapon and handling of player update messages.
-rw-r--r--ChangeLog30
-rw-r--r--src/net/beinghandler.cpp10
-rw-r--r--src/player.cpp31
3 files changed, 48 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index 5fe346c4..1e028784 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,21 +1,37 @@
+2006-11-30 Bjørn Lindeijer <bjorn@lindeijer.nl>
+
+ * data/maps/Makefile.am: Fixed small trailing slash issue.
+ * src/player.cpp: Optimized setSex and setWeapon by first loading the
+ new sprite and then deleting the old one (prevents potentially
+ unnecessary reload).
+ * src/net/beinghandler.cpp: Optimized handling of player walk
+ messages, by first setting the gender right and then setting the
+ equipment. Gets rid of reload of complete equipment in the case of
+ female.
+
2006-11-30 Eugenio Favalli <elvenprogrammer@gmail.com>
* The Mana World.dev, tmw.cbp: Updated project files.
+2006-11-29 Bjørn Lindeijer <bjorn@lindeijer.nl>
+
+ * src/monster.cpp: Small fix to resource path.
+
2006-11-29 Philipp Sehmisch <tmw@crushnet.org>
- * src/resources/equipment.h: Made getSprite return a constant reference
+ * src/resources/equipment.h: Made getSprite return a constant
+ reference.
* src/resources/monsterdb.cpp, src/resources/monsterdb.h,
src/resources/monsterinfo.cpp, src/resources/monsterinfo.h,
src/Makefile.AM, src/CMakeLists.txt, src/main.cpp:
Added the MonsterDB namespace that reads the monsters.xml
and maps monster IDs to names, sprite definitions and sound effects.
- * src/monster.cpp: Get sprite definition filenames from MonsterDB
- * src/engine.cpp: Show monster name when targeting a monster
+ * src/monster.cpp: Get sprite definition filenames from MonsterDB.
+ * src/engine.cpp: Show monster name when targeting a monster.
* data/monsters.xml, data/graphics/sprites/Makefile.AM,
data/graphics/sprites/CMakeLists.txt, data/graphics/sprites/monster*:
- Renamed all monster sprites to more associative names
- (whew, we got to train some monkeys for tasks like that)
+ Renamed all monster sprites to more associative names (whew, we got to
+ train some monkeys for tasks like that).
2006-11-27 Bjørn Lindeijer <bjorn@lindeijer.nl>
@@ -23,8 +39,8 @@
2006-11-27 Philipp Sehmisch <tmw@crushnet.org>
- * src/log.cpp, src/util/wingettimeofday.h:
- Added implementation of gettimeofday() for windows machines.
+ * src/log.cpp, src/util/wingettimeofday.h: Added implementation of
+ gettimeofday() for windows machines.
2006-11-26 Bjørn Lindeijer <bjorn@lindeijer.nl>
diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp
index 4fcf2105..67d04ee4 100644
--- a/src/net/beinghandler.cpp
+++ b/src/net/beinghandler.cpp
@@ -62,6 +62,7 @@ void BeingHandler::handleMessage(MessageIn *msg)
{
Uint32 id;
Uint16 job, speed;
+ Uint16 headBottom, headTop, headMid;
Sint16 param1;
Sint8 type;
Being *srcBeing, *dstBeing;
@@ -315,15 +316,15 @@ void BeingHandler::handleMessage(MessageIn *msg)
dstBeing->setHairStyle(msg->readInt16());
dstBeing->setWeaponById(msg->readInt16()); // item id 1
msg->readInt16(); // item id 2
- dstBeing->setVisibleEquipment(3, msg->readInt16()); // head bottom
+ headBottom = msg->readInt16();
if (msg->getId() == SMSG_PLAYER_MOVE)
{
msg->readInt32(); // server tick
}
- dstBeing->setVisibleEquipment(4, msg->readInt16()); // head top
- dstBeing->setVisibleEquipment(5, msg->readInt16()); // head mid
+ headTop = msg->readInt16();
+ headMid = msg->readInt16();
dstBeing->setHairColor(msg->readInt16());
msg->readInt16(); // unknown
msg->readInt16(); // head dir
@@ -332,6 +333,9 @@ void BeingHandler::handleMessage(MessageIn *msg)
msg->readInt16(); // manner
msg->readInt8(); // karma
dstBeing->setSex(1 - msg->readInt8()); // sex
+ dstBeing->setVisibleEquipment(3, headBottom);
+ dstBeing->setVisibleEquipment(4, headTop);
+ dstBeing->setVisibleEquipment(5, headMid);
if (msg->getId() == SMSG_PLAYER_MOVE)
{
diff --git a/src/player.cpp b/src/player.cpp
index cd6986b3..533d88fa 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -89,28 +89,31 @@ Player::setSex(Uint8 sex)
{
if (sex != mSex)
{
- //reload base sprite
- delete mSprites[BASE_SPRITE];
+ // Reload base sprite
+ AnimatedSprite *newBaseSprite;
if (sex == 0)
{
- mSprites[BASE_SPRITE] = new AnimatedSprite(
+ newBaseSprite = new AnimatedSprite(
"graphics/sprites/player_male_base.xml");
}
else
{
- mSprites[BASE_SPRITE] = new AnimatedSprite(
+ newBaseSprite = new AnimatedSprite(
"graphics/sprites/player_female_base.xml");
}
+ delete mSprites[BASE_SPRITE];
+ mSprites[BASE_SPRITE] = newBaseSprite;
- //reload equipment
+ // Reload equipment
for (int i=1; i<VECTOREND_SPRITE ; i++)
{
if (i != HAIR_SPRITE && mEquipmentSpriteIDs.at(i) != 0)
{
- delete mSprites[i];
- mSprites[i] = new AnimatedSprite(
+ AnimatedSprite *newEqSprite = new AnimatedSprite(
"graphics/sprites/" + EquipmentDB::get(
mEquipmentSpriteIDs.at(i))->getSprite(sex));
+ delete mSprites[i];
+ mSprites[i] = newEqSprite;
}
}
}
@@ -124,28 +127,30 @@ Player::setWeapon(Uint16 weapon)
{
if (weapon != mWeapon)
{
- delete mSprites[WEAPON_SPRITE];
- mSprites[WEAPON_SPRITE] = NULL;
+ AnimatedSprite *newWeaponSprite = NULL;
switch (weapon)
{
case 0:
- mSprites[WEAPON_SPRITE] =
+ newWeaponSprite =
new AnimatedSprite("graphics/sprites/weapon-fist.xml");
break;
case 1:
- mSprites[WEAPON_SPRITE] =
+ newWeaponSprite =
new AnimatedSprite("graphics/sprites/weapon-dagger.xml");
break;
case 2:
- mSprites[WEAPON_SPRITE] =
+ newWeaponSprite =
new AnimatedSprite("graphics/sprites/weapon-bow.xml");
break;
case 3:
- mSprites[WEAPON_SPRITE] =
+ newWeaponSprite =
new AnimatedSprite("graphics/sprites/weapon-scythe.xml");
break;
}
+
+ delete mSprites[WEAPON_SPRITE];
+ mSprites[WEAPON_SPRITE] = newWeaponSprite;
}
Being::setWeapon(weapon);
}