summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-07-28 22:55:09 +0200
committermadmaxoft <github@xoft.cz>2013-07-28 22:55:09 +0200
commit3bf4130e3fc05f84cf7be7e33656f3e29f0fe12c (patch)
tree2294350370ff68bfe9c778ef1296506f1a6b0ff0
parentIgnoring all items beginning with "world". (diff)
downloadcuberite-3bf4130e3fc05f84cf7be7e33656f3e29f0fe12c.tar
cuberite-3bf4130e3fc05f84cf7be7e33656f3e29f0fe12c.tar.gz
cuberite-3bf4130e3fc05f84cf7be7e33656f3e29f0fe12c.tar.bz2
cuberite-3bf4130e3fc05f84cf7be7e33656f3e29f0fe12c.tar.lz
cuberite-3bf4130e3fc05f84cf7be7e33656f3e29f0fe12c.tar.xz
cuberite-3bf4130e3fc05f84cf7be7e33656f3e29f0fe12c.tar.zst
cuberite-3bf4130e3fc05f84cf7be7e33656f3e29f0fe12c.zip
Diffstat (limited to '')
-rw-r--r--source/Bindings.cpp309
-rw-r--r--source/Bindings.h2
-rw-r--r--source/ClientHandle.cpp5
-rw-r--r--source/Defines.h4
-rw-r--r--source/Player.cpp2
-rw-r--r--source/Player.h40
6 files changed, 263 insertions, 99 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index fd85abba9..68710a743 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 07/26/13 21:48:46.
+** Generated automatically by tolua++-1.0.92 on 07/28/13 22:51:46.
*/
#ifndef __cplusplus
@@ -8439,194 +8439,162 @@ static int tolua_AllToLua_cPlayer_GetGameMode00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
-/* method: GetIP of class cPlayer */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetIP00
-static int tolua_AllToLua_cPlayer_GetIP00(lua_State* tolua_S)
+/* method: SetGameMode of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_SetGameMode00
+static int tolua_AllToLua_cPlayer_SetGameMode00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,2,&tolua_err)
+ !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+ eGameMode a_GameMode = ((eGameMode) (int) tolua_tonumber(tolua_S,2,0));
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetIP'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetGameMode'", NULL);
#endif
{
- std::string tolua_ret = (std::string) self->GetIP();
- tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ self->SetGameMode(a_GameMode);
}
}
- return 1;
+ return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'GetIP'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'SetGameMode'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: GetLastBlockActionTime of class cPlayer */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetLastBlockActionTime00
-static int tolua_AllToLua_cPlayer_GetLastBlockActionTime00(lua_State* tolua_S)
+/* method: IsGameModeCreative of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_IsGameModeCreative00
+static int tolua_AllToLua_cPlayer_IsGameModeCreative00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,1,"const cPlayer",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+ const cPlayer* self = (const cPlayer*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetLastBlockActionTime'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsGameModeCreative'", NULL);
#endif
{
- float tolua_ret = (float) self->GetLastBlockActionTime();
- tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ bool tolua_ret = (bool) self->IsGameModeCreative();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'GetLastBlockActionTime'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'IsGameModeCreative'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: GetLastBlockActionCnt of class cPlayer */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetLastBlockActionCnt00
-static int tolua_AllToLua_cPlayer_GetLastBlockActionCnt00(lua_State* tolua_S)
+/* method: IsGameModeSurvival of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_IsGameModeSurvival00
+static int tolua_AllToLua_cPlayer_IsGameModeSurvival00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,1,"const cPlayer",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+ const cPlayer* self = (const cPlayer*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetLastBlockActionCnt'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsGameModeSurvival'", NULL);
#endif
{
- int tolua_ret = (int) self->GetLastBlockActionCnt();
- tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ bool tolua_ret = (bool) self->IsGameModeSurvival();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'GetLastBlockActionCnt'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'IsGameModeSurvival'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: SetLastBlockActionCnt of class cPlayer */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_SetLastBlockActionCnt00
-static int tolua_AllToLua_cPlayer_SetLastBlockActionCnt00(lua_State* tolua_S)
+/* method: IsGameModeAdventure of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_IsGameModeAdventure00
+static int tolua_AllToLua_cPlayer_IsGameModeAdventure00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
- !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,3,&tolua_err)
- )
- goto tolua_lerror;
- else
-#endif
- {
- cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
- int tolua_var_1 = ((int) tolua_tonumber(tolua_S,2,0));
-#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetLastBlockActionCnt'", NULL);
-#endif
- {
- self->SetLastBlockActionCnt(tolua_var_1);
- }
- }
- return 0;
-#ifndef TOLUA_RELEASE
- tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'SetLastBlockActionCnt'.",&tolua_err);
- return 0;
-#endif
-}
-#endif //#ifndef TOLUA_DISABLE
-
-/* method: SetLastBlockActionTime of class cPlayer */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_SetLastBlockActionTime00
-static int tolua_AllToLua_cPlayer_SetLastBlockActionTime00(lua_State* tolua_S)
-{
-#ifndef TOLUA_RELEASE
- tolua_Error tolua_err;
- if (
- !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,1,"const cPlayer",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
+ const cPlayer* self = (const cPlayer*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetLastBlockActionTime'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsGameModeAdventure'", NULL);
#endif
{
- self->SetLastBlockActionTime();
+ bool tolua_ret = (bool) self->IsGameModeAdventure();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
}
}
- return 0;
+ return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'SetLastBlockActionTime'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'IsGameModeAdventure'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
-/* method: SetGameMode of class cPlayer */
-#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_SetGameMode00
-static int tolua_AllToLua_cPlayer_SetGameMode00(lua_State* tolua_S)
+/* method: GetIP of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetIP00
+static int tolua_AllToLua_cPlayer_GetIP00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
- !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,3,&tolua_err)
+ !tolua_isusertype(tolua_S,1,"const cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
- eGameMode a_GameMode = ((eGameMode) (int) tolua_tonumber(tolua_S,2,0));
+ const cPlayer* self = (const cPlayer*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
- if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetGameMode'", NULL);
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetIP'", NULL);
#endif
{
- self->SetGameMode(a_GameMode);
+ AString tolua_ret = (AString) self->GetIP();
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
}
}
- return 0;
+ return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
- tolua_error(tolua_S,"#ferror in function 'SetGameMode'.",&tolua_err);
+ tolua_error(tolua_S,"#ferror in function 'GetIP'.",&tolua_err);
return 0;
#endif
}
@@ -9334,6 +9302,38 @@ static int tolua_AllToLua_cPlayer_GetFoodPoisonedTicksRemaining00(lua_State* tol
}
#endif //#ifndef TOLUA_DISABLE
+/* method: IsSatiated of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_IsSatiated00
+static int tolua_AllToLua_cPlayer_IsSatiated00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cPlayer* self = (const cPlayer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsSatiated'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->IsSatiated();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsSatiated'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: SetFoodLevel of class cPlayer */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_SetFoodLevel00
static int tolua_AllToLua_cPlayer_SetFoodLevel00(lua_State* tolua_S)
@@ -9601,6 +9601,38 @@ static int tolua_AllToLua_cPlayer_FoodPoison00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: IsEating of class cPlayer */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_IsEating00
+static int tolua_AllToLua_cPlayer_IsEating00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cPlayer",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cPlayer* self = (const cPlayer*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsEating'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->IsEating();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsEating'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: Respawn of class cPlayer */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_Respawn00
static int tolua_AllToLua_cPlayer_Respawn00(lua_State* tolua_S)
@@ -11375,6 +11407,102 @@ static int tolua_AllToLua_cWorld_GetGameMode00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: IsGameModeCreative of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_IsGameModeCreative00
+static int tolua_AllToLua_cWorld_IsGameModeCreative00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cWorld",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cWorld* self = (const cWorld*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsGameModeCreative'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->IsGameModeCreative();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsGameModeCreative'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: IsGameModeSurvival of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_IsGameModeSurvival00
+static int tolua_AllToLua_cWorld_IsGameModeSurvival00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cWorld",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cWorld* self = (const cWorld*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsGameModeSurvival'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->IsGameModeSurvival();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsGameModeSurvival'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
+/* method: IsGameModeAdventure of class cWorld */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_IsGameModeAdventure00
+static int tolua_AllToLua_cWorld_IsGameModeAdventure00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cWorld",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cWorld* self = (const cWorld*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'IsGameModeAdventure'", NULL);
+#endif
+ {
+ bool tolua_ret = (bool) self->IsGameModeAdventure();
+ tolua_pushboolean(tolua_S,(bool)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'IsGameModeAdventure'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: IsPVPEnabled of class cWorld */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_IsPVPEnabled00
static int tolua_AllToLua_cWorld_IsPVPEnabled00(lua_State* tolua_S)
@@ -28665,6 +28793,8 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"gmSurvival",gmSurvival);
tolua_constant(tolua_S,"gmCreative",gmCreative);
tolua_constant(tolua_S,"gmAdventure",gmAdventure);
+ tolua_constant(tolua_S,"gmMax",gmMax);
+ tolua_constant(tolua_S,"gmMin",gmMin);
tolua_constant(tolua_S,"eWeather_Sunny",eWeather_Sunny);
tolua_constant(tolua_S,"eWeather_Rain",eWeather_Rain);
tolua_constant(tolua_S,"eWeather_ThunderStorm",eWeather_ThunderStorm);
@@ -28892,6 +29022,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_beginmodule(tolua_S,"cPlayer");
tolua_constant(tolua_S,"MAX_HEALTH",cPlayer::MAX_HEALTH);
tolua_constant(tolua_S,"MAX_FOOD_LEVEL",cPlayer::MAX_FOOD_LEVEL);
+ tolua_constant(tolua_S,"EATING_TICKS",cPlayer::EATING_TICKS);
tolua_function(tolua_S,"Initialize",tolua_AllToLua_cPlayer_Initialize00);
tolua_function(tolua_S,"GetEyeHeight",tolua_AllToLua_cPlayer_GetEyeHeight00);
tolua_function(tolua_S,"GetEyePosition",tolua_AllToLua_cPlayer_GetEyePosition00);
@@ -28900,12 +29031,11 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"GetInventory",tolua_AllToLua_cPlayer_GetInventory00);
tolua_function(tolua_S,"GetEquippedItem",tolua_AllToLua_cPlayer_GetEquippedItem00);
tolua_function(tolua_S,"GetGameMode",tolua_AllToLua_cPlayer_GetGameMode00);
- tolua_function(tolua_S,"GetIP",tolua_AllToLua_cPlayer_GetIP00);
- tolua_function(tolua_S,"GetLastBlockActionTime",tolua_AllToLua_cPlayer_GetLastBlockActionTime00);
- tolua_function(tolua_S,"GetLastBlockActionCnt",tolua_AllToLua_cPlayer_GetLastBlockActionCnt00);
- tolua_function(tolua_S,"SetLastBlockActionCnt",tolua_AllToLua_cPlayer_SetLastBlockActionCnt00);
- tolua_function(tolua_S,"SetLastBlockActionTime",tolua_AllToLua_cPlayer_SetLastBlockActionTime00);
tolua_function(tolua_S,"SetGameMode",tolua_AllToLua_cPlayer_SetGameMode00);
+ tolua_function(tolua_S,"IsGameModeCreative",tolua_AllToLua_cPlayer_IsGameModeCreative00);
+ tolua_function(tolua_S,"IsGameModeSurvival",tolua_AllToLua_cPlayer_IsGameModeSurvival00);
+ tolua_function(tolua_S,"IsGameModeAdventure",tolua_AllToLua_cPlayer_IsGameModeAdventure00);
+ tolua_function(tolua_S,"GetIP",tolua_AllToLua_cPlayer_GetIP00);
tolua_function(tolua_S,"MoveTo",tolua_AllToLua_cPlayer_MoveTo00);
tolua_function(tolua_S,"GetWindow",tolua_AllToLua_cPlayer_GetWindow00);
tolua_function(tolua_S,"CloseWindow",tolua_AllToLua_cPlayer_CloseWindow00);
@@ -28927,6 +29057,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"GetFoodTickTimer",tolua_AllToLua_cPlayer_GetFoodTickTimer00);
tolua_function(tolua_S,"GetFoodExhaustionLevel",tolua_AllToLua_cPlayer_GetFoodExhaustionLevel00);
tolua_function(tolua_S,"GetFoodPoisonedTicksRemaining",tolua_AllToLua_cPlayer_GetFoodPoisonedTicksRemaining00);
+ tolua_function(tolua_S,"IsSatiated",tolua_AllToLua_cPlayer_IsSatiated00);
tolua_function(tolua_S,"SetFoodLevel",tolua_AllToLua_cPlayer_SetFoodLevel00);
tolua_function(tolua_S,"SetFoodSaturationLevel",tolua_AllToLua_cPlayer_SetFoodSaturationLevel00);
tolua_function(tolua_S,"SetFoodTickTimer",tolua_AllToLua_cPlayer_SetFoodTickTimer00);
@@ -28935,6 +29066,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"Feed",tolua_AllToLua_cPlayer_Feed00);
tolua_function(tolua_S,"AddFoodExhaustion",tolua_AllToLua_cPlayer_AddFoodExhaustion00);
tolua_function(tolua_S,"FoodPoison",tolua_AllToLua_cPlayer_FoodPoison00);
+ tolua_function(tolua_S,"IsEating",tolua_AllToLua_cPlayer_IsEating00);
tolua_function(tolua_S,"Respawn",tolua_AllToLua_cPlayer_Respawn00);
tolua_function(tolua_S,"SetVisible",tolua_AllToLua_cPlayer_SetVisible00);
tolua_function(tolua_S,"IsVisible",tolua_AllToLua_cPlayer_IsVisible00);
@@ -29037,6 +29169,9 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"SetTimeOfDay",tolua_AllToLua_cWorld_SetTimeOfDay00);
tolua_function(tolua_S,"SetWorldTime",tolua_AllToLua_cWorld_SetWorldTime00);
tolua_function(tolua_S,"GetGameMode",tolua_AllToLua_cWorld_GetGameMode00);
+ tolua_function(tolua_S,"IsGameModeCreative",tolua_AllToLua_cWorld_IsGameModeCreative00);
+ tolua_function(tolua_S,"IsGameModeSurvival",tolua_AllToLua_cWorld_IsGameModeSurvival00);
+ tolua_function(tolua_S,"IsGameModeAdventure",tolua_AllToLua_cWorld_IsGameModeAdventure00);
tolua_function(tolua_S,"IsPVPEnabled",tolua_AllToLua_cWorld_IsPVPEnabled00);
tolua_function(tolua_S,"IsDeepSnowEnabled",tolua_AllToLua_cWorld_IsDeepSnowEnabled00);
tolua_function(tolua_S,"GetDimension",tolua_AllToLua_cWorld_GetDimension00);
diff --git a/source/Bindings.h b/source/Bindings.h
index c21612525..7341c6587 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 07/26/13 21:48:46.
+** Generated automatically by tolua++-1.0.92 on 07/28/13 22:51:47.
*/
/* Exported function */
diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp
index a15facc6e..d66e47d32 100644
--- a/source/ClientHandle.cpp
+++ b/source/ClientHandle.cpp
@@ -801,6 +801,11 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, c
}
else if (ItemHandler->IsFood())
{
+ if (m_Player->IsSatiated())
+ {
+ // The player is satiated, they cannot eat
+ return;
+ }
m_Player->StartEating();
if (PlgMgr->CallHookPlayerEating(*m_Player))
{
diff --git a/source/Defines.h b/source/Defines.h
index f52050a9b..94e618eb0 100644
--- a/source/Defines.h
+++ b/source/Defines.h
@@ -116,6 +116,10 @@ enum eGameMode
gmSurvival = eGameMode_Survival,
gmCreative = eGameMode_Creative,
gmAdventure = eGameMode_Adventure,
+
+ // These two are used to check GameMode for validity when converting from integers.
+ gmMax, // Gets automatically assigned
+ gmMin = 0,
} ;
diff --git a/source/Player.cpp b/source/Player.cpp
index c177b8cf4..c90f3c99c 100644
--- a/source/Player.cpp
+++ b/source/Player.cpp
@@ -705,7 +705,7 @@ void cPlayer::SetLastBlockActionCnt( int a_LastBlockActionCnt )
void cPlayer::SetGameMode(eGameMode a_GameMode)
{
- if ((a_GameMode >= 3) || (a_GameMode < 0))
+ if ((a_GameMode >= gmMin) || (a_GameMode < gmMax))
{
LOGWARNING("%s: Setting invalid gamemode: %d", GetName().c_str(), a_GameMode);
return;
diff --git a/source/Player.h b/source/Player.h
index 093c35b44..eea8c1596 100644
--- a/source/Player.h
+++ b/source/Player.h
@@ -66,7 +66,7 @@ public:
double GetEyeHeight(void) const; // tolua_export
Vector3d GetEyePosition(void) const; // tolua_export
inline bool IsOnGround(void) const {return m_bTouchGround; } // tolua_export
- inline const double GetStance(void) const { return GetPosY() + 1.62; } // tolua_export // TODO: Proper stance when crouching etc.
+ inline const double GetStance(void) const { return GetPosY() + 1.62; } // tolua_export // TODO: Proper stance when crouching etc.
inline cInventory & GetInventory(void) { return m_Inventory; } // tolua_export
inline const cInventory & GetInventory(void) const { return m_Inventory; }
@@ -74,9 +74,17 @@ public:
virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ) override;
+ // tolua_begin
+
/// Returns the current gamemode. Partly OBSOLETE, you should use IsGameModeXXX() functions wherever applicable
- eGameMode GetGameMode(void) const { return m_GameMode; } // tolua_export
+ eGameMode GetGameMode(void) const { return m_GameMode; }
+ /** Sets the gamemode for the player.
+ The gamemode may be gmNotSet, in that case the player inherits the world's gamemode.
+ Updates the gamemode on the client (sends the packet)
+ */
+ void SetGameMode(eGameMode a_GameMode);
+
/// Returns true if the player is in Creative mode, either explicitly, or by inheriting from current world
bool IsGameModeCreative(void) const;
@@ -86,17 +94,22 @@ public:
/// Returns true if the player is in Adventure mode, either explicitly, or by inheriting from current world
bool IsGameModeAdventure(void) const;
- std::string GetIP() { return m_IP; } // tolua_export
- float GetLastBlockActionTime() { return m_LastBlockActionTime; } // tolua_export
- int GetLastBlockActionCnt() { return m_LastBlockActionCnt; } // tolua_export
- void SetLastBlockActionCnt( int ); // tolua_export
- void SetLastBlockActionTime(); // tolua_export
- void SetGameMode( eGameMode a_GameMode ); // tolua_export
- void LoginSetGameMode( eGameMode a_GameMode );
+ AString GetIP(void) const { return m_IP; } // tolua_export
+
+ // tolua_end
+
void SetIP(const AString & a_IP);
+ float GetLastBlockActionTime() { return m_LastBlockActionTime; }
+ int GetLastBlockActionCnt() { return m_LastBlockActionCnt; }
+ void SetLastBlockActionCnt( int );
+ void SetLastBlockActionTime();
+
+ // Sets the current gamemode, doesn't check validity, doesn't send update packets to client
+ void LoginSetGameMode(eGameMode a_GameMode);
+
/// Tries to move to a new position, with collision checks and stuff
- virtual void MoveTo( const Vector3d & a_NewPos ); // tolua_export
+ virtual void MoveTo( const Vector3d & a_NewPos ); // tolua_export
cWindow * GetWindow(void) { return m_CurrentWindow; } // tolua_export
const cWindow * GetWindow(void) const { return m_CurrentWindow; }
@@ -148,6 +161,9 @@ public:
double GetFoodExhaustionLevel (void) const { return m_FoodExhaustionLevel; }
int GetFoodPoisonedTicksRemaining(void) const { return m_FoodPoisonedTicksRemaining; }
+ /// Returns true if the player is satiated, i. e. their foodlevel is at the max and they cannot eat anymore
+ bool IsSatiated(void) const { return (m_FoodLevel >= MAX_FOOD_LEVEL); }
+
void SetFoodLevel (int a_FoodLevel);
void SetFoodSaturationLevel (double a_FoodSaturationLevel);
void SetFoodTickTimer (int a_FoodTickTimer);
@@ -163,6 +179,9 @@ public:
/// Starts the food poisoning for the specified amount of ticks; if already foodpoisoned, sets FoodPoisonedTicksRemaining to the larger of the two
void FoodPoison(int a_NumTicks);
+ /// Returns true if the player is currently in the process of eating the currently equipped item
+ bool IsEating(void) const { return (m_EatingFinishTick >= 0); }
+
// tolua_end
/// Starts eating the currently equipped item. Resets the eating timer and sends the proper animation packet
@@ -235,6 +254,7 @@ public:
// cEntity overrides:
virtual bool IsCrouched (void) const { return m_IsCrouched; }
virtual bool IsSprinting(void) const { return m_IsSprinting; }
+ virtual bool IsRclking (void) const { return IsEating(); }
protected:
typedef std::map< std::string, bool > PermissionMap;