Fix player double damage
authorPerttu Ahola <celeron55@gmail.com>
Fri, 2 Dec 2011 09:16:51 +0000 (11:16 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Fri, 2 Dec 2011 09:16:51 +0000 (11:16 +0200)
src/client.cpp
src/environment.cpp
src/environment.h
src/server.cpp
src/serverremoteplayer.cpp

index d264713e237410728d7b731d2f0dc02201956288..d092c6a10ceb00b4277c8c3690fecb688e7fc113 100644 (file)
@@ -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;
index ce81a1941a94e95b44646366fa7ced3e8be68b0a..67ea05cf60e83e9df021c594acd1559bfbca5f43 100644 (file)
@@ -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);
 }
 
index 2cdfb4b4858404e8f0f2fffbb4057bf9b93195e8..7759d43afb6598351c613bd5b1ccc9dd22552e2d 100644 (file)
@@ -368,6 +368,7 @@ struct ClientEnvEvent
                } none;
                struct{
                        u8 amount;
+                       bool send_to_server;
                } player_damage;
        };
 };
index 361be9efde7f7d36892c673c95a5d8a5d9531ccd..f12fd261e8bc9965cc00640dd69f2a47e0c7b0f3 100644 (file)
@@ -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)
                                <<PP(player->getPosition()/BS)<<std::endl;
                
                srp->m_removed = false;
+               srp->setId(0);
                m_env->addActiveObject(srp);
        }
        else if(command == TOSERVER_INTERACT)
index ceb46c4ee62d4eec006a2438709b281d9ae218e5..c5033da50fec906733b50b6f7d773e5d1430268c 100644 (file)
@@ -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);