mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Send Breath packet on event, don't check it at each AsyncRunStep
This commit is contained in:
parent
64ff966bae
commit
7e56637ed0
@ -718,7 +718,6 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_,
|
|||||||
// public
|
// public
|
||||||
m_moved(false),
|
m_moved(false),
|
||||||
m_inventory_not_sent(false),
|
m_inventory_not_sent(false),
|
||||||
m_breath_not_sent(false),
|
|
||||||
m_wielded_item_not_sent(false),
|
m_wielded_item_not_sent(false),
|
||||||
m_physics_override_speed(1),
|
m_physics_override_speed(1),
|
||||||
m_physics_override_jump(1),
|
m_physics_override_jump(1),
|
||||||
|
@ -318,7 +318,6 @@ public:
|
|||||||
// Some flags used by Server
|
// Some flags used by Server
|
||||||
bool m_moved;
|
bool m_moved;
|
||||||
bool m_inventory_not_sent;
|
bool m_inventory_not_sent;
|
||||||
bool m_breath_not_sent;
|
|
||||||
bool m_wielded_item_not_sent;
|
bool m_wielded_item_not_sent;
|
||||||
|
|
||||||
float m_physics_override_speed;
|
float m_physics_override_speed;
|
||||||
|
@ -922,7 +922,7 @@ void Server::handleCommand_Breath(NetworkPacket* pkt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
playersao->setBreath(breath);
|
playersao->setBreath(breath);
|
||||||
m_script->player_event(playersao,"breath_changed");
|
SendPlayerBreath(pkt->getPeerId());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::handleCommand_Password(NetworkPacket* pkt)
|
void Server::handleCommand_Password(NetworkPacket* pkt)
|
||||||
|
@ -812,7 +812,11 @@ int ObjectRef::l_set_breath(lua_State *L)
|
|||||||
u16 breath = luaL_checknumber(L, 2);
|
u16 breath = luaL_checknumber(L, 2);
|
||||||
// Do it
|
// Do it
|
||||||
co->setBreath(breath);
|
co->setBreath(breath);
|
||||||
co->m_breath_not_sent = true;
|
|
||||||
|
// If the object is a player sent the breath to client
|
||||||
|
if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER)
|
||||||
|
getServer(L)->SendPlayerBreath(((PlayerSAO*)co)->getPeerID());
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -604,20 +604,15 @@ void Server::AsyncRunStep(bool initial_step)
|
|||||||
if(playersao == NULL)
|
if(playersao == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
|
||||||
Send player breath if changed
|
if(playersao->m_moved) {
|
||||||
*/
|
SendMovePlayer(*i);
|
||||||
if(playersao->m_breath_not_sent) {
|
playersao->m_moved = false;
|
||||||
SendPlayerBreath(*i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Send player inventories if necessary
|
Send player inventories if necessary
|
||||||
*/
|
*/
|
||||||
if(playersao->m_moved) {
|
|
||||||
SendMovePlayer(*i);
|
|
||||||
playersao->m_moved = false;
|
|
||||||
}
|
|
||||||
if(playersao->m_inventory_not_sent) {
|
if(playersao->m_inventory_not_sent) {
|
||||||
UpdateCrafting(*i);
|
UpdateCrafting(*i);
|
||||||
SendInventory(*i);
|
SendInventory(*i);
|
||||||
@ -1892,8 +1887,8 @@ void Server::SendPlayerBreath(u16 peer_id)
|
|||||||
DSTACK(__FUNCTION_NAME);
|
DSTACK(__FUNCTION_NAME);
|
||||||
PlayerSAO *playersao = getPlayerSAO(peer_id);
|
PlayerSAO *playersao = getPlayerSAO(peer_id);
|
||||||
assert(playersao);
|
assert(playersao);
|
||||||
playersao->m_breath_not_sent = false;
|
|
||||||
m_script->player_event(playersao,"breath_changed");
|
m_script->player_event(playersao, "breath_changed");
|
||||||
SendBreath(peer_id, playersao->getBreath());
|
SendBreath(peer_id, playersao->getBreath());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2604,6 +2599,7 @@ void Server::RespawnPlayer(u16 peer_id)
|
|||||||
playersao->setBreath(PLAYER_MAX_BREATH);
|
playersao->setBreath(PLAYER_MAX_BREATH);
|
||||||
|
|
||||||
SendPlayerHP(peer_id);
|
SendPlayerHP(peer_id);
|
||||||
|
SendPlayerBreath(peer_id);
|
||||||
|
|
||||||
bool repositioned = m_script->on_respawnplayer(playersao);
|
bool repositioned = m_script->on_respawnplayer(playersao);
|
||||||
if(!repositioned){
|
if(!repositioned){
|
||||||
|
@ -373,6 +373,8 @@ public:
|
|||||||
std::string* vers_string);
|
std::string* vers_string);
|
||||||
|
|
||||||
void SendPlayerHPOrDie(u16 peer_id, bool die) { die ? DiePlayer(peer_id) : SendPlayerHP(peer_id); }
|
void SendPlayerHPOrDie(u16 peer_id, bool die) { die ? DiePlayer(peer_id) : SendPlayerHP(peer_id); }
|
||||||
|
void SendPlayerBreath(u16 peer_id);
|
||||||
|
|
||||||
// Bind address
|
// Bind address
|
||||||
Address m_bind_addr;
|
Address m_bind_addr;
|
||||||
|
|
||||||
@ -397,7 +399,7 @@ private:
|
|||||||
void SendChatMessage(u16 peer_id, const std::wstring &message);
|
void SendChatMessage(u16 peer_id, const std::wstring &message);
|
||||||
void SendTimeOfDay(u16 peer_id, u16 time, f32 time_speed);
|
void SendTimeOfDay(u16 peer_id, u16 time, f32 time_speed);
|
||||||
void SendPlayerHP(u16 peer_id);
|
void SendPlayerHP(u16 peer_id);
|
||||||
void SendPlayerBreath(u16 peer_id);
|
|
||||||
void SendMovePlayer(u16 peer_id);
|
void SendMovePlayer(u16 peer_id);
|
||||||
void SendLocalPlayerAnimations(u16 peer_id, v2s32 animation_frames[4], f32 animation_speed);
|
void SendLocalPlayerAnimations(u16 peer_id, v2s32 animation_frames[4], f32 animation_speed);
|
||||||
void SendEyeOffset(u16 peer_id, v3f first, v3f third);
|
void SendEyeOffset(u16 peer_id, v3f first, v3f third);
|
||||||
|
Loading…
Reference in New Issue
Block a user