aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
authorNer'zhul <nerzhul@users.noreply.github.com>2016-10-30 14:53:26 +0100
committerGitHub <noreply@github.com>2016-10-30 14:53:26 +0100
commit9d25242c5c1411d692254cf910345d51c9a24fa3 (patch)
treeedec8475b32562379d463757e77031bdc994e971 /src/script/lua_api
parentd43326021a9a7def27773ed1f7ec01992ed3abf6 (diff)
downloadminetest-9d25242c5c1411d692254cf910345d51c9a24fa3.tar.gz
minetest-9d25242c5c1411d692254cf910345d51c9a24fa3.tar.bz2
minetest-9d25242c5c1411d692254cf910345d51c9a24fa3.zip
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
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/l_object.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index 23994181c..cf124f17c 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -1013,11 +1013,11 @@ int ObjectRef::l_get_look_dir(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
- RemotePlayer *player = getplayer(ref);
- if (player == NULL) return 0;
+ PlayerSAO* co = getplayersao(ref);
+ if (co == NULL) return 0;
// Do it
- float pitch = player->getRadPitchDep();
- float yaw = player->getRadYawDep();
+ float pitch = co->getRadPitchDep();
+ float yaw = co->getRadYawDep();
v3f v(cos(pitch)*cos(yaw), sin(pitch), cos(pitch)*sin(yaw));
push_v3f(L, v);
return 1;
@@ -1033,10 +1033,10 @@ int ObjectRef::l_get_look_pitch(lua_State *L)
"Deprecated call to get_look_pitch, use get_look_vertical instead");
ObjectRef *ref = checkobject(L, 1);
- RemotePlayer *player = getplayer(ref);
- if (player == NULL) return 0;
+ PlayerSAO* co = getplayersao(ref);
+ if (co == NULL) return 0;
// Do it
- lua_pushnumber(L, player->getRadPitchDep());
+ lua_pushnumber(L, co->getRadPitchDep());
return 1;
}
@@ -1050,10 +1050,10 @@ int ObjectRef::l_get_look_yaw(lua_State *L)
"Deprecated call to get_look_yaw, use get_look_horizontal instead");
ObjectRef *ref = checkobject(L, 1);
- RemotePlayer *player = getplayer(ref);
- if (player == NULL) return 0;
+ PlayerSAO* co = getplayersao(ref);
+ if (co == NULL) return 0;
// Do it
- lua_pushnumber(L, player->getRadYawDep());
+ lua_pushnumber(L, co->getRadYawDep());
return 1;
}
@@ -1062,10 +1062,10 @@ int ObjectRef::l_get_look_vertical(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
- RemotePlayer *player = getplayer(ref);
- if (player == NULL) return 0;
+ PlayerSAO* co = getplayersao(ref);
+ if (co == NULL) return 0;
// Do it
- lua_pushnumber(L, player->getRadPitch());
+ lua_pushnumber(L, co->getRadPitch());
return 1;
}
@@ -1074,10 +1074,10 @@ int ObjectRef::l_get_look_horizontal(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
- RemotePlayer *player = getplayer(ref);
- if (player == NULL) return 0;
+ PlayerSAO* co = getplayersao(ref);
+ if (co == NULL) return 0;
// Do it
- lua_pushnumber(L, player->getRadYaw());
+ lua_pushnumber(L, co->getRadYaw());
return 1;
}