summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--src/being.cpp10
-rw-r--r--src/being.h2
-rw-r--r--src/game.cpp24
4 files changed, 18 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index 8e7f6752..e08b558e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2005-09-14 Björn Steinbrink <B.Steinbrink@gmx.de>
+ * src/being.cpp, src/being.h, src/game.cpp: Made Being::setDamage
+ accept a short instead of a string.
* src/game.cpp, src/game.h, src/gui/char_select.cpp: Converted
map_path from char array to std::string.
diff --git a/src/being.cpp b/src/being.cpp
index 3fdc2f2b..4ba88a33 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -233,9 +233,15 @@ void Being::setSpeech(const std::string &text, int time)
showSpeech = true;
}
-void Being::setDamage(const std::string &text, int time)
+void Being::setDamage(short amount, int time)
{
- damage = text;
+ if (!amount) {
+ damage = "miss";
+ } else {
+ std::stringstream damageString;
+ damageString << amount;
+ damage = damageString.str();
+ }
damage_time = tick_time;
showDamage = true;
}
diff --git a/src/being.h b/src/being.h
index 98aaeb80..9c853c32 100644
--- a/src/being.h
+++ b/src/being.h
@@ -125,7 +125,7 @@ class Being
* @param text The text that should appear.
* @param time The amount of time the text should stay in milliseconds.
*/
- void setDamage(const std::string &text, int time);
+ void setDamage(short amount, int time);
/**
* Returns the name of the being.
diff --git a/src/game.cpp b/src/game.cpp
index b3801bfd..2fb79ef7 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -23,8 +23,6 @@
#include "game.h"
-#include <sstream>
-
#include <guichan/sdl/sdlinput.hpp>
#include "being.h"
@@ -1564,28 +1562,21 @@ void do_parse()
{
Being *srcBeing = findNode(msg.readLong());
Being *dstBeing = findNode(msg.readLong());
- msg.readLong(); // server tick
- msg.readLong(); // src speed
- msg.readLong(); // dst speed
+// msg.readLong(); // server tick
+// msg.readLong(); // src speed
+// msg.readLong(); // dst speed
+ msg.skip(12);
short param1 = msg.readShort();
- msg.readShort(); // param 2
+ msg.skip(2); // param 2
char type = msg.readByte();
- msg.readShort(); // param 3
+ msg.skip(2); // param 3
switch (type)
{
case 0: // Damage
if (dstBeing == NULL) break;
- if (param1 == 0) {
- // Yellow
- dstBeing->setDamage("miss", SPEECH_TIME);
- } else {
- // Blue for monster, red for player
- std::stringstream ss;
- ss << param1;
- dstBeing->setDamage(ss.str(), SPEECH_TIME);
- }
+ dstBeing->setDamage(param1, SPEECH_TIME);
if (srcBeing != NULL &&
srcBeing != player_node)
@@ -1594,7 +1585,6 @@ void do_parse()
srcBeing->action = Being::ATTACK;
srcBeing->frame = 0;
srcBeing->walk_time = tick_time;
- srcBeing->frame = 0;
}
break;