aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_object.cpp
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2016-10-08 10:38:04 +0200
committerNer'zhul <nerzhul@users.noreply.github.com>2016-10-08 11:36:28 +0200
commit8bcd10b872bc88c6f474913d6efb8d53c50c5ae1 (patch)
tree39a8af0048ed642eddc43c74ab9f736558663e9d /src/script/lua_api/l_object.cpp
parent0264e38bff12a3c6b81231ac1f6cd281179df744 (diff)
downloadminetest-8bcd10b872bc88c6f474913d6efb8d53c50c5ae1.tar.gz
minetest-8bcd10b872bc88c6f474913d6efb8d53c50c5ae1.tar.bz2
minetest-8bcd10b872bc88c6f474913d6efb8d53c50c5ae1.zip
Player/LocalPlayer/RemotePlayer inheritance cleanup (part 1 on X)
* LocalPlayer take ownership of maxHudId as it's the only caller * RemotePlayer take ownership of day night ratio as it's the only user * Pass getPlayerControl as const reference to prevent object copy on each call (perf improvement in ObjectRef::l_get_player_control call) * getPlayerSAO is now only RemotePlayer call * get/setHotbarItemCount is now RemotePlayer owned * Server: Use RemotePlayer instead of Player object on concerned call to properly fix the object type * PlayerSAO now uses RemotePlayer instead of Player because it's only server side * ObjectRef::getplayer also returns RemotePlayer as it's linked with PlayerSAO
Diffstat (limited to 'src/script/lua_api/l_object.cpp')
-rw-r--r--src/script/lua_api/l_object.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index befae4253..4e1a1c159 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -107,7 +107,7 @@ PlayerSAO* ObjectRef::getplayersao(ObjectRef *ref)
return (PlayerSAO*)obj;
}
-Player* ObjectRef::getplayer(ObjectRef *ref)
+RemotePlayer* ObjectRef::getplayer(ObjectRef *ref)
{
PlayerSAO *playersao = getplayersao(ref);
if (playersao == NULL)
@@ -1212,8 +1212,8 @@ int ObjectRef::l_get_player_control(lua_State *L)
lua_pushlstring(L, "", 0);
return 1;
}
- // Do it
- PlayerControl control = player->getPlayerControl();
+
+ const PlayerControl &control = player->getPlayerControl();
lua_newtable(L);
lua_pushboolean(L, control.up);
lua_setfield(L, -2, "up");
@@ -1467,7 +1467,7 @@ int ObjectRef::l_hud_set_flags(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
- Player *player = getplayer(ref);
+ RemotePlayer *player = getplayer(ref);
if (player == NULL)
return 0;
@@ -1519,7 +1519,7 @@ int ObjectRef::l_hud_set_hotbar_itemcount(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
- Player *player = getplayer(ref);
+ RemotePlayer *player = getplayer(ref);
if (player == NULL)
return 0;
@@ -1537,7 +1537,7 @@ int ObjectRef::l_hud_get_hotbar_itemcount(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
- Player *player = getplayer(ref);
+ RemotePlayer *player = getplayer(ref);
if (player == NULL)
return 0;
@@ -1677,7 +1677,7 @@ int ObjectRef::l_override_day_night_ratio(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
- Player *player = getplayer(ref);
+ RemotePlayer *player = getplayer(ref);
if (player == NULL)
return 0;
@@ -1700,7 +1700,7 @@ int ObjectRef::l_get_day_night_ratio(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
- Player *player = getplayer(ref);
+ RemotePlayer *player = getplayer(ref);
if (player == NULL)
return 0;