summaryrefslogtreecommitdiffstats
path: root/src/Bindings/ManualBindings_World.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2020-04-14 16:43:21 +0200
committerGitHub <noreply@github.com>2020-04-14 16:43:21 +0200
commitc9a9b3c9d0d4fed0b02d9935923bfd7dcbc45d1e (patch)
tree7d7ba1d772d1f4994773f325046a4e6229c91d16 /src/Bindings/ManualBindings_World.cpp
parentPressure plate sounds and delay (#4643) (diff)
downloadcuberite-c9a9b3c9d0d4fed0b02d9935923bfd7dcbc45d1e.tar
cuberite-c9a9b3c9d0d4fed0b02d9935923bfd7dcbc45d1e.tar.gz
cuberite-c9a9b3c9d0d4fed0b02d9935923bfd7dcbc45d1e.tar.bz2
cuberite-c9a9b3c9d0d4fed0b02d9935923bfd7dcbc45d1e.tar.lz
cuberite-c9a9b3c9d0d4fed0b02d9935923bfd7dcbc45d1e.tar.xz
cuberite-c9a9b3c9d0d4fed0b02d9935923bfd7dcbc45d1e.tar.zst
cuberite-c9a9b3c9d0d4fed0b02d9935923bfd7dcbc45d1e.zip
Diffstat (limited to 'src/Bindings/ManualBindings_World.cpp')
-rw-r--r--src/Bindings/ManualBindings_World.cpp26
1 files changed, 7 insertions, 19 deletions
diff --git a/src/Bindings/ManualBindings_World.cpp b/src/Bindings/ManualBindings_World.cpp
index 7b072e435..cfefb4f7a 100644
--- a/src/Bindings/ManualBindings_World.cpp
+++ b/src/Bindings/ManualBindings_World.cpp
@@ -39,10 +39,8 @@ static bool CheckParamVectorOr3Numbers(cLuaState & L, const char * a_VectorName,
template <typename T>
static bool GetStackVectorOr3Numbers(cLuaState & L, int a_Index, Vector3<T> & a_Return)
{
- Vector3<T> * UserType;
- if (L.GetStackValue(a_Index, UserType))
+ if (L.GetStackValue(a_Index, a_Return))
{
- a_Return = *UserType;
return true;
}
return L.GetStackValues(a_Index, a_Return.x, a_Return.y, a_Return.z);
@@ -367,10 +365,10 @@ static int tolua_cWorld_DoExplosionAt(lua_State * tolua_S)
case esBed:
{
// esBed receives a Vector3i SourceData param:
- Vector3i * pos = nullptr;
+ Vector3i pos;
L.GetStackValue(8, pos);
SourceType = esBed;
- SourceData = pos;
+ SourceData = &pos;
break;
}
@@ -481,24 +479,19 @@ static int tolua_cWorld_DoWithNearestPlayer(lua_State * tolua_S)
// Get parameters:
cWorld * Self;
- Vector3d * Position;
+ Vector3d Position;
double RangeLimit;
cLuaState::cRef FnRef;
bool CheckLineOfSight = true, IgnoreSpectators = true; // Defaults for the optional params
L.GetStackValues(1, Self, Position, RangeLimit, FnRef, CheckLineOfSight, IgnoreSpectators);
- if (Position == nullptr)
- {
- return L.ApiParamError("Expected a non-nil Vector3d for parameter #2");
- }
-
if (!FnRef.IsValid())
{
return L.ApiParamError("Expected a valid callback function for parameter #3");
}
// Call the function:
- bool res = Self->DoWithNearestPlayer(*Position, RangeLimit, [&](cPlayer & a_Player)
+ bool res = Self->DoWithNearestPlayer(Position, RangeLimit, [&](cPlayer & a_Player)
{
bool ret = false;
L.Call(FnRef, &a_Player, cLuaState::Return, ret);
@@ -895,7 +888,7 @@ static int tolua_cWorld_SpawnSplitExperienceOrbs(lua_State* tolua_S)
}
cWorld * self = nullptr;
- Vector3d * Position = nullptr;
+ Vector3d Position;
int Reward;
L.GetStackValues(1, self, Position, Reward);
if (self == nullptr)
@@ -903,14 +896,9 @@ static int tolua_cWorld_SpawnSplitExperienceOrbs(lua_State* tolua_S)
tolua_error(tolua_S, "Invalid 'self' in function 'SpawnSplitExperienceOrbs'", nullptr);
return 0;
}
- if (Position == nullptr)
- {
- tolua_error(tolua_S, "Error in function 'SpawnSplitExperienceOrbs' arg #2. Value must not be nil.", nullptr);
- return 0;
- }
// Execute and push result:
- L.Push(self->SpawnExperienceOrb(Position->x, Position->y, Position->z, Reward));
+ L.Push(self->SpawnExperienceOrb(Position, Reward));
return 1;
}