1
0
mirror of https://github.com/moparisthebest/minetest synced 2024-12-23 08:08:47 -05:00

Fix player double damage

This commit is contained in:
Perttu Ahola 2011-12-02 11:16:51 +02:00
parent c357985135
commit 2dc9a0c724
5 changed files with 11 additions and 3 deletions

View 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;

View 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);
}

View File

@ -368,6 +368,7 @@ struct ClientEnvEvent
} none;
struct{
u8 amount;
bool send_to_server;
} player_damage;
};
};

View 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)

View 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);