summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Bindings/LuaState.cpp18
-rw-r--r--src/Bindings/LuaState.h1
-rw-r--r--src/Bindings/ManualBindings.cpp4
-rw-r--r--src/Broadcaster.cpp2
-rw-r--r--src/Chunk.cpp2
-rw-r--r--src/Mobs/Monster.cpp22
-rw-r--r--src/Tracer.cpp6
-rw-r--r--src/Vector3.h12
8 files changed, 41 insertions, 26 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index 28bf87091..c96ab083a 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -979,6 +979,18 @@ void cLuaState::GetStackValue(int a_StackPos, double & a_ReturnedVal)
+void cLuaState::GetStackValue(int a_StackPos, float & a_ReturnedVal)
+{
+ if (lua_isnumber(m_LuaState, a_StackPos))
+ {
+ a_ReturnedVal = static_cast<float>(tolua_tonumber(m_LuaState, a_StackPos, a_ReturnedVal));
+ }
+}
+
+
+
+
+
void cLuaState::GetStackValue(int a_StackPos, eWeather & a_ReturnedVal)
{
if (!lua_isnumber(m_LuaState, a_StackPos))
@@ -1415,7 +1427,7 @@ bool cLuaState::CheckParamFunctionOrNil(int a_StartParam, int a_EndParam)
bool cLuaState::CheckParamEnd(int a_Param)
{
tolua_Error tolua_err;
- if (tolua_isnoobj(m_LuaState, a_Param, &tolua_err))
+ if (tolua_isnoobj(m_LuaState, a_Param, &tolua_err) == 1)
{
return true;
}
@@ -1437,7 +1449,7 @@ bool cLuaState::IsParamUserType(int a_Param, AString a_UserType)
ASSERT(IsValid());
tolua_Error tolua_err;
- return tolua_isusertype(m_LuaState, a_Param, a_UserType.c_str(), 0, &tolua_err);
+ return (tolua_isusertype(m_LuaState, a_Param, a_UserType.c_str(), 0, &tolua_err) == 1);
}
@@ -1449,7 +1461,7 @@ bool cLuaState::IsParamNumber(int a_Param)
ASSERT(IsValid());
tolua_Error tolua_err;
- return tolua_isnumber(m_LuaState, a_Param, 0, &tolua_err);
+ return (tolua_isnumber(m_LuaState, a_Param, 0, &tolua_err) == 1);
}
diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h
index 3f2e828f3..4377ed5d0 100644
--- a/src/Bindings/LuaState.h
+++ b/src/Bindings/LuaState.h
@@ -251,6 +251,7 @@ public:
void GetStackValue(int a_StackPos, bool & a_Value);
void GetStackValue(int a_StackPos, cRef & a_Ref);
void GetStackValue(int a_StackPos, double & a_Value);
+ void GetStackValue(int a_StackPos, float & a_ReturnedVal);
void GetStackValue(int a_StackPos, eWeather & a_Value);
void GetStackValue(int a_StackPos, int & a_Value);
void GetStackValue(int a_StackPos, pBlockArea & a_Value);
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index 10f5ecb94..9b3c1555d 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -2036,8 +2036,8 @@ static int tolua_cWorld_BroadcastParticleEffect(lua_State * tolua_S)
// Read the params:
cWorld * World = nullptr;
AString Name;
- double PosX, PosY, PosZ, OffX, OffY, OffZ;
- double ParticleData;
+ float PosX, PosY, PosZ, OffX, OffY, OffZ;
+ float ParticleData;
int ParticleAmmount;
L.GetStackValues(1, World, Name, PosX, PosY, PosZ, OffX, OffY, OffZ, ParticleData, ParticleAmmount);
if (World == nullptr)
diff --git a/src/Broadcaster.cpp b/src/Broadcaster.cpp
index 7f2b65d09..594d12208 100644
--- a/src/Broadcaster.cpp
+++ b/src/Broadcaster.cpp
@@ -15,7 +15,7 @@ void cBroadcaster::BroadcastParticleEffect(const AString & a_ParticleName, const
m_World->DoWithChunkAt(a_Src,
[=](cChunk & a_Chunk) -> bool
{
- for (auto&& client : a_Chunk.GetAllClients())
+ for (auto && client : a_Chunk.GetAllClients())
{
if (client == a_Exclude)
{
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index ed5a1b12a..7d5f54373 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -1827,7 +1827,7 @@ bool cChunk::SetSignLines(int a_PosX, int a_PosY, int a_PosZ, const AString & a_
)
{
MarkDirty();
- (reinterpret_cast<cSignEntity *>(*itr))->SetLines(a_Line1, a_Line2, a_Line3, a_Line4);
+ reinterpret_cast<cSignEntity *>(*itr)->SetLines(a_Line1, a_Line2, a_Line3, a_Line4);
m_World->BroadcastBlockEntity(a_PosX, a_PosY, a_PosZ);
return true;
}
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 3d3fdfb64..f3f8c6b24 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -261,7 +261,7 @@ void cMonster::MoveToWayPoint(cChunk & a_Chunk)
bool cMonster::EnsureProperDestination(cChunk & a_Chunk)
{
- cChunk * Chunk = a_Chunk.GetNeighborChunk(m_FinalDestination.x, m_FinalDestination.z);
+ cChunk * Chunk = a_Chunk.GetNeighborChunk(FloorC(m_FinalDestination.x), FloorC(m_FinalDestination.z));
BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta;
@@ -270,13 +270,13 @@ bool cMonster::EnsureProperDestination(cChunk & a_Chunk)
return false;
}
- int RelX = m_FinalDestination.x - Chunk->GetPosX() * cChunkDef::Width;
- int RelZ = m_FinalDestination.z - Chunk->GetPosZ() * cChunkDef::Width;
+ int RelX = FloorC(m_FinalDestination.x) - Chunk->GetPosX() * cChunkDef::Width;
+ int RelZ = FloorC(m_FinalDestination.z) - Chunk->GetPosZ() * cChunkDef::Width;
// If destination in the air, go down to the lowest air block.
while (m_FinalDestination.y > 0)
{
- Chunk->GetBlockTypeMeta(RelX, m_FinalDestination.y - 1, RelZ, BlockType, BlockMeta);
+ Chunk->GetBlockTypeMeta(RelX, FloorC(m_FinalDestination.y) - 1, RelZ, BlockType, BlockMeta);
if (cBlockInfo::IsSolid(BlockType))
{
break;
@@ -290,7 +290,7 @@ bool cMonster::EnsureProperDestination(cChunk & a_Chunk)
bool InWater = false;
while (m_FinalDestination.y < cChunkDef::Height)
{
- Chunk->GetBlockTypeMeta(RelX, m_FinalDestination.y, RelZ, BlockType, BlockMeta);
+ Chunk->GetBlockTypeMeta(RelX, FloorC(m_FinalDestination.y), RelZ, BlockType, BlockMeta);
if (BlockType == E_BLOCK_STATIONARY_WATER)
{
InWater = true;
@@ -1172,17 +1172,19 @@ void cMonster::HandleDaylightBurning(cChunk & a_Chunk, bool WouldBurn)
bool cMonster::WouldBurnAt(Vector3d a_Location, cChunk & a_Chunk)
{
- cChunk * Chunk = a_Chunk.GetNeighborChunk(FloorC(m_NextWayPointPosition.x), FloorC(m_NextWayPointPosition.z));
+ cChunk * Chunk = a_Chunk.GetNeighborChunk(FloorC(a_Location.x), FloorC(a_Location.z));
if ((Chunk == nullptr) || (!Chunk->IsValid()))
{
return false;
}
- int RelX = FloorC(a_Location.x) - a_Chunk.GetPosX() * cChunkDef::Width;
+
+ int RelX = FloorC(a_Location.x) - Chunk->GetPosX() * cChunkDef::Width;
int RelY = FloorC(a_Location.y);
- int RelZ = FloorC(a_Location.z) - a_Chunk.GetPosZ() * cChunkDef::Width;
+ int RelZ = FloorC(a_Location.z) - Chunk->GetPosZ() * cChunkDef::Width;
+
if (
- (a_Chunk.GetSkyLight(RelX, RelY, RelZ) == 15) && // In the daylight
- (a_Chunk.GetBlock(RelX, RelY, RelZ) != E_BLOCK_SOULSAND) && // Not on soulsand
+ (Chunk->GetSkyLight(RelX, RelY, RelZ) == 15) && // In the daylight
+ (Chunk->GetBlock(RelX, RelY, RelZ) != E_BLOCK_SOULSAND) && // Not on soulsand
(GetWorld()->GetTimeOfDay() < (12000 + 1000)) && // It is nighttime
GetWorld()->IsWeatherSunnyAt(POSX_TOINT, POSZ_TOINT) // Not raining
)
diff --git a/src/Tracer.cpp b/src/Tracer.cpp
index b6b0fd634..5fdaff15d 100644
--- a/src/Tracer.cpp
+++ b/src/Tracer.cpp
@@ -56,13 +56,13 @@ int cTracer::SigNum(float a_Num)
{
if (a_Num < 0.f)
{
- return -1.f;
+ return -1;
}
if (a_Num > 0.f)
{
- return 1.f;
+ return 1;
}
- return 0.f;
+ return 0;
}
diff --git a/src/Vector3.h b/src/Vector3.h
index f051ce2d2..346bc1bbb 100644
--- a/src/Vector3.h
+++ b/src/Vector3.h
@@ -81,14 +81,14 @@ public:
inline bool HasNonZeroLength(void) const
{
#ifdef __clang__
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wfloat-equal"
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wfloat-equal"
#endif
return ((x != 0) || (y != 0) || (z != 0));
#ifdef __clang__
- #pragma clang diagnostic pop
+ #pragma clang diagnostic pop
#endif
}
@@ -137,14 +137,14 @@ public:
// To perform EPS-based comparison, use the EqualsEps() function
#ifdef __clang__
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wfloat-equal"
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wfloat-equal"
#endif
return !((x != a_Rhs.x) || (y != a_Rhs.y) || (z != a_Rhs.z));
#ifdef __clang__
- #pragma clang diagnostic pop
+ #pragma clang diagnostic pop
#endif
}