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

PlayerSAO/LocalPlayer refactor: (#4612)

* Create UnitSAO, a common part between PlayerSAO & LuaEntitySAO
* Move breath to PlayerSAO & LocalPlayer
* Migrate m_yaw from (Remote)Player & LuaEntitySAO to UnitSAO
* Migrate m_yaw from Player to LocalPlayer for client
* Move some functions outside of player class to PlayerSAO/RemotePlayer or LocalPlayer depending on which class needs it
* Move pitch to LocalPlayer & PlayerSAO
* Move m_position from Player to LocalPlayer
* Move camera_barely_in_ceiling to LocalPlayer as it's used only there
* use PlayerSAO::m_base_position for Server side positions
* remove a unused variable
* ServerActiveObject::setPos now uses const ref
* use ServerEnv::loadPlayer unconditionnaly as it creates RemotePlayer only if it's not already loaded
* Move hp from Player to LocalPlayer
* Move m_hp from LuaEntitySAO to UnitSAO
* Use m_hp from PlayerSAO/UnitSAO instead of RemotePlayer
This commit is contained in:
Ner'zhul 2016-10-30 14:53:26 +01:00 committed by GitHub
parent d43326021a
commit 9d25242c5c
18 changed files with 353 additions and 335 deletions

View file

@ -29,7 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "environment.h"
#include "map.h"
#include "emerge.h"
#include "serverobject.h" // TODO this is used for cleanup of only
#include "content_sao.h" // TODO this is used for cleanup of only
#include "log.h"
#include "util/srp.h"
@ -82,6 +82,10 @@ void RemoteClient::GetNextBlocks (
if (player == NULL)
return;
PlayerSAO *sao = player->getPlayerSAO();
if (sao == NULL)
return;
// Won't send anything if already sending
if(m_blocks_sending.size() >= g_settings->getU16
("max_simultaneous_block_sends_per_client"))
@ -90,7 +94,7 @@ void RemoteClient::GetNextBlocks (
return;
}
v3f playerpos = player->getPosition();
v3f playerpos = sao->getBasePosition();
v3f playerspeed = player->getSpeed();
v3f playerspeeddir(0,0,0);
if(playerspeed.getLength() > 1.0*BS)
@ -103,10 +107,10 @@ void RemoteClient::GetNextBlocks (
v3s16 center = getNodeBlockPos(center_nodepos);
// Camera position and direction
v3f camera_pos = player->getEyePosition();
v3f camera_pos = sao->getEyePosition();
v3f camera_dir = v3f(0,0,1);
camera_dir.rotateYZBy(player->getPitch());
camera_dir.rotateXZBy(player->getYaw());
camera_dir.rotateYZBy(sao->getPitch());
camera_dir.rotateXZBy(sao->getYaw());
/*infostream<<"camera_dir=("<<camera_dir.X<<","<<camera_dir.Y<<","
<<camera_dir.Z<<")"<<std::endl;*/