summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/client.cpp17
-rw-r--r--src/client/client.h6
-rw-r--r--src/client/clientenvironment.cpp4
-rw-r--r--src/client/clientenvironment.h4
-rw-r--r--src/client/content_cao.cpp7
-rw-r--r--src/client/content_cao.h2
-rw-r--r--src/client/hud.cpp19
7 files changed, 14 insertions, 45 deletions
diff --git a/src/client/client.cpp b/src/client/client.cpp
index 3ba69333a..41893fcba 100644
--- a/src/client/client.cpp
+++ b/src/client/client.cpp
@@ -437,7 +437,7 @@ void Client::step(float dtime)
ClientEnvEvent envEvent = m_env.getClientEnvEvent();
if (envEvent.type == CEE_PLAYER_DAMAGE) {
- u8 damage = envEvent.player_damage.amount;
+ u16 damage = envEvent.player_damage.amount;
if (envEvent.player_damage.send_to_server)
sendDamage(damage);
@@ -1213,9 +1213,9 @@ void Client::sendChangePassword(const std::string &oldpassword,
}
-void Client::sendDamage(u8 damage)
+void Client::sendDamage(u16 damage)
{
- NetworkPacket pkt(TOSERVER_DAMAGE, sizeof(u8));
+ NetworkPacket pkt(TOSERVER_DAMAGE, sizeof(u16));
pkt << damage;
Send(&pkt);
}
@@ -1515,17 +1515,6 @@ void Client::typeChatMessage(const std::wstring &message)
// Send to others
sendChatMessage(message);
-
- // Show locally
- if (message[0] != L'/') {
- // compatibility code
- if (m_proto_ver < 29) {
- LocalPlayer *player = m_env.getLocalPlayer();
- assert(player);
- std::wstring name = narrow_to_wide(player->getName());
- pushToChatQueue(new ChatMessage(CHATMESSAGE_TYPE_NORMAL, message, name));
- }
- }
}
void Client::addUpdateMeshTask(v3s16 p, bool ack_to_server, bool urgent)
diff --git a/src/client/client.h b/src/client/client.h
index ef700e477..60735f665 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -243,7 +243,7 @@ public:
void clearOutChatQueue();
void sendChangePassword(const std::string &oldpassword,
const std::string &newpassword);
- void sendDamage(u8 damage);
+ void sendDamage(u16 damage);
void sendRespawn();
void sendReady();
@@ -342,7 +342,7 @@ public:
bool mediaReceived()
{ return !m_media_downloader; }
- u8 getProtoVersion()
+ u16 getProtoVersion()
{ return m_proto_ver; }
bool connectedToServer();
@@ -504,7 +504,7 @@ private:
// and aren't accurate. We simply just don't know, because
// the server didn't send the version back then.
// If 0, server init hasn't been received yet.
- u8 m_proto_ver = 0;
+ u16 m_proto_ver = 0;
u16 m_playeritem = 0;
bool m_inventory_updated = false;
diff --git a/src/client/clientenvironment.cpp b/src/client/clientenvironment.cpp
index 1783e8961..a788c93c2 100644
--- a/src/client/clientenvironment.cpp
+++ b/src/client/clientenvironment.cpp
@@ -228,7 +228,7 @@ void ClientEnvironment::step(float dtime)
float speed = pre_factor * speed_diff.getLength();
if (speed > tolerance && !player_immortal) {
f32 damage_f = (speed - tolerance) / BS * post_factor;
- u8 damage = (u8)MYMIN(damage_f + 0.5, 255);
+ u16 damage = (u16)MYMIN(damage_f + 0.5, U16_MAX);
if (damage != 0) {
damageLocalPlayer(damage, true);
m_client->getEventManager()->put(
@@ -419,7 +419,7 @@ void ClientEnvironment::processActiveObjectMessage(u16 id, const std::string &da
Callbacks for activeobjects
*/
-void ClientEnvironment::damageLocalPlayer(u8 damage, bool handle_hp)
+void ClientEnvironment::damageLocalPlayer(u16 damage, bool handle_hp)
{
LocalPlayer *lplayer = getLocalPlayer();
assert(lplayer);
diff --git a/src/client/clientenvironment.h b/src/client/clientenvironment.h
index d167902d1..4fa3f4848 100644
--- a/src/client/clientenvironment.h
+++ b/src/client/clientenvironment.h
@@ -53,7 +53,7 @@ struct ClientEnvEvent
//struct{
//} none;
struct{
- u8 amount;
+ u16 amount;
bool send_to_server;
} player_damage;
};
@@ -115,7 +115,7 @@ public:
Callbacks for activeobjects
*/
- void damageLocalPlayer(u8 damage, bool handle_hp=true);
+ void damageLocalPlayer(u16 damage, bool handle_hp=true);
/*
Client likes to call these
diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp
index 6112edaff..8643b5824 100644
--- a/src/client/content_cao.cpp
+++ b/src/client/content_cao.cpp
@@ -371,7 +371,7 @@ void GenericCAO::processInitData(const std::string &data)
m_id = readU16(is);
m_position = readV3F32(is);
m_rotation = readV3F32(is);
- m_hp = readS16(is);
+ m_hp = readU16(is);
const u8 num_messages = readU8(is);
for (int i = 0; i < num_messages; i++) {
@@ -1508,11 +1508,10 @@ void GenericCAO::processMessage(const std::string &data)
updateAttachments();
} else if (cmd == GENERIC_CMD_PUNCHED) {
- /*s16 damage =*/ readS16(is);
- s16 result_hp = readS16(is);
+ u16 result_hp = readU16(is);
// Use this instead of the send damage to not interfere with prediction
- s16 damage = m_hp - result_hp;
+ s32 damage = (s32)m_hp - (s32)result_hp;
m_hp = result_hp;
diff --git a/src/client/content_cao.h b/src/client/content_cao.h
index 4627800ee..3ce628d30 100644
--- a/src/client/content_cao.h
+++ b/src/client/content_cao.h
@@ -88,7 +88,7 @@ private:
v3f m_velocity;
v3f m_acceleration;
v3f m_rotation;
- s16 m_hp = 1;
+ u16 m_hp = 1;
SmoothTranslator<v3f> pos_translator;
SmoothTranslatorWrappedv3f rot_translator;
// Spritesheet/animation stuff
diff --git a/src/client/hud.cpp b/src/client/hud.cpp
index fffe85e1d..1a2287a13 100644
--- a/src/client/hud.cpp
+++ b/src/client/hud.cpp
@@ -475,25 +475,6 @@ void Hud::drawHotbar(u16 playeritem) {
hotbar_itemcount / 2, mainlist, playeritem + 1, 0);
}
}
-
- //////////////////////////// compatibility code to be removed //////////////
- // this is ugly as hell but there's no other way to keep compatibility to
- // old servers
- if ((player->hud_flags & HUD_FLAG_HEALTHBAR_VISIBLE)) {
- drawStatbar(v2s32(floor(0.5 * (float)m_screensize.X + 0.5),
- floor(1 * (float) m_screensize.Y + 0.5)),
- HUD_CORNER_UPPER, 0, "heart.png",
- player->hp, v2s32((-10*24)-25,-(48+24+10)), v2s32(24,24));
- }
-
- if ((player->hud_flags & HUD_FLAG_BREATHBAR_VISIBLE) &&
- (player->getBreath() < 11)) {
- drawStatbar(v2s32(floor(0.5 * (float)m_screensize.X + 0.5),
- floor(1 * (float) m_screensize.Y + 0.5)),
- HUD_CORNER_UPPER, 0, "bubble.png",
- player->getBreath(), v2s32(25,-(48+24+10)), v2s32(24,24));
- }
- ////////////////////////////////////////////////////////////////////////////
}