Skip to content

Commit 9d25242

Browse files
authoredOct 30, 2016
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
1 parent d433260 commit 9d25242

18 files changed

+353
-335
lines changed
 

‎src/clientiface.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2929
#include "environment.h"
3030
#include "map.h"
3131
#include "emerge.h"
32-
#include "serverobject.h" // TODO this is used for cleanup of only
32+
#include "content_sao.h" // TODO this is used for cleanup of only
3333
#include "log.h"
3434
#include "util/srp.h"
3535

@@ -82,6 +82,10 @@ void RemoteClient::GetNextBlocks (
8282
if (player == NULL)
8383
return;
8484

85+
PlayerSAO *sao = player->getPlayerSAO();
86+
if (sao == NULL)
87+
return;
88+
8589
// Won't send anything if already sending
8690
if(m_blocks_sending.size() >= g_settings->getU16
8791
("max_simultaneous_block_sends_per_client"))
@@ -90,7 +94,7 @@ void RemoteClient::GetNextBlocks (
9094
return;
9195
}
9296

93-
v3f playerpos = player->getPosition();
97+
v3f playerpos = sao->getBasePosition();
9498
v3f playerspeed = player->getSpeed();
9599
v3f playerspeeddir(0,0,0);
96100
if(playerspeed.getLength() > 1.0*BS)
@@ -103,10 +107,10 @@ void RemoteClient::GetNextBlocks (
103107
v3s16 center = getNodeBlockPos(center_nodepos);
104108

105109
// Camera position and direction
106-
v3f camera_pos = player->getEyePosition();
110+
v3f camera_pos = sao->getEyePosition();
107111
v3f camera_dir = v3f(0,0,1);
108-
camera_dir.rotateYZBy(player->getPitch());
109-
camera_dir.rotateXZBy(player->getYaw());
112+
camera_dir.rotateYZBy(sao->getPitch());
113+
camera_dir.rotateXZBy(sao->getYaw());
110114

111115
/*infostream<<"camera_dir=("<<camera_dir.X<<","<<camera_dir.Y<<","
112116
<<camera_dir.Z<<")"<<std::endl;*/

‎src/collision.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
367367
#endif
368368
{
369369
ServerEnvironment *s_env = dynamic_cast<ServerEnvironment*>(env);
370-
if (s_env != 0) {
370+
if (s_env != NULL) {
371371
f32 distance = speed_f->getLength();
372372
std::vector<u16> s_objects;
373373
s_env->getObjectsInsideRadius(s_objects, *pos_f, distance * 1.5);

0 commit comments

Comments
 (0)
Please sign in to comment.