From 2dc9a0c724dafde4a4858060268f3bec1b7cb720 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Fri, 2 Dec 2011 11:16:51 +0200 Subject: [PATCH] Fix player double damage --- src/client.cpp | 4 +++- src/environment.cpp | 3 +++ src/environment.h | 1 + src/server.cpp | 2 ++ src/serverremoteplayer.cpp | 4 ++-- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index d264713e..d092c6a1 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -566,7 +566,9 @@ void Client::step(float dtime) if(m_ignore_damage_timer <= 0) { u8 damage = event.player_damage.amount; - sendDamage(damage); + + if(event.player_damage.send_to_server) + sendDamage(damage); // Add to ClientEvent queue ClientEvent event; diff --git a/src/environment.cpp b/src/environment.cpp index ce81a194..67ea05cf 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -1920,6 +1920,7 @@ void ClientEnvironment::step(float dtime) ClientEnvEvent event; event.type = CEE_PLAYER_DAMAGE; event.player_damage.amount = damage; + event.player_damage.send_to_server = true; m_client_event_queue.push_back(event); } } @@ -1953,6 +1954,7 @@ void ClientEnvironment::step(float dtime) ClientEnvEvent event; event.type = CEE_PLAYER_DAMAGE; event.player_damage.amount = damage_per_second; + event.player_damage.send_to_server = true; m_client_event_queue.push_back(event); } } @@ -2205,6 +2207,7 @@ void ClientEnvironment::damageLocalPlayer(u8 damage, bool handle_hp) ClientEnvEvent event; event.type = CEE_PLAYER_DAMAGE; event.player_damage.amount = damage; + event.player_damage.send_to_server = handle_hp; m_client_event_queue.push_back(event); } diff --git a/src/environment.h b/src/environment.h index 2cdfb4b4..7759d43a 100644 --- a/src/environment.h +++ b/src/environment.h @@ -368,6 +368,7 @@ struct ClientEnvEvent } none; struct{ u8 amount; + bool send_to_server; } player_damage; }; }; diff --git a/src/server.cpp b/src/server.cpp index 361be9ef..f12fd261 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2128,6 +2128,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) // Add PlayerSAO player->m_removed = false; + player->setId(0); m_env->addActiveObject(player); /* @@ -2887,6 +2888,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) <getPosition()/BS)<m_removed = false; + srp->setId(0); m_env->addActiveObject(srp); } else if(command == TOSERVER_INTERACT) diff --git a/src/serverremoteplayer.cpp b/src/serverremoteplayer.cpp index ceb46c4e..c5033da5 100644 --- a/src/serverremoteplayer.cpp +++ b/src/serverremoteplayer.cpp @@ -142,8 +142,8 @@ void ServerRemotePlayer::punch(ServerActiveObject *puncher, // "Material" properties of a player MaterialProperties mp; mp.diggability = DIGGABLE_NORMAL; - mp.crackiness = -1.0; - mp.cuttability = 1.0; + mp.crackiness = -0.5; + mp.cuttability = 0.5; ToolDiggingProperties tp; puncher->getWieldDiggingProperties(&tp);