1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

Improved Player Physics

This commit is contained in:
MirceaKitsune 2013-02-08 22:54:01 +02:00 committed by darkrose
parent 86b906d015
commit df3c925b3c
10 changed files with 295 additions and 109 deletions

View file

@ -2344,6 +2344,9 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
infostream<<"Server: Sending content to "
<<getPlayerName(peer_id)<<std::endl;
// Send player movement settings
SendMovement(m_con, peer_id);
// Send item definitions
SendItemDef(m_con, peer_id, m_itemdef);
@ -3534,6 +3537,32 @@ void Server::deletingPeer(con::Peer *peer, bool timeout)
Static send methods
*/
void Server::SendMovement(con::Connection &con, u16 peer_id)
{
DSTACK(__FUNCTION_NAME);
std::ostringstream os(std::ios_base::binary);
writeU16(os, TOCLIENT_MOVEMENT);
writeF1000(os, g_settings->getFloat("movement_acceleration_default"));
writeF1000(os, g_settings->getFloat("movement_acceleration_air"));
writeF1000(os, g_settings->getFloat("movement_acceleration_fast"));
writeF1000(os, g_settings->getFloat("movement_speed_walk"));
writeF1000(os, g_settings->getFloat("movement_speed_crouch"));
writeF1000(os, g_settings->getFloat("movement_speed_fast"));
writeF1000(os, g_settings->getFloat("movement_speed_climb"));
writeF1000(os, g_settings->getFloat("movement_speed_jump"));
writeF1000(os, g_settings->getFloat("movement_liquid_fluidity"));
writeF1000(os, g_settings->getFloat("movement_liquid_fluidity_smooth"));
writeF1000(os, g_settings->getFloat("movement_liquid_sink"));
writeF1000(os, g_settings->getFloat("movement_gravity"));
// Make data buffer
std::string s = os.str();
SharedBuffer<u8> data((u8*)s.c_str(), s.size());
// Send as reliable
con.Send(peer_id, 0, data, true);
}
void Server::SendHP(con::Connection &con, u16 peer_id, u8 hp)
{
DSTACK(__FUNCTION_NAME);