Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nerzhul committed Oct 30, 2016
1 parent d433260 commit 9d25242
Show file tree
Hide file tree
Showing 18 changed files with 353 additions and 335 deletions.
14 changes: 9 additions & 5 deletions src/clientiface.cpp
Expand Up @@ -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"

Expand Down Expand Up @@ -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"))
Expand All @@ -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)
Expand All @@ -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;*/
Expand Down
2 changes: 1 addition & 1 deletion src/collision.cpp
Expand Up @@ -367,7 +367,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
#endif
{
ServerEnvironment *s_env = dynamic_cast<ServerEnvironment*>(env);
if (s_env != 0) {
if (s_env != NULL) {
f32 distance = speed_f->getLength();
std::vector<u16> s_objects;
s_env->getObjectsInsideRadius(s_objects, *pos_f, distance * 1.5);
Expand Down

0 comments on commit 9d25242

Please sign in to comment.