summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/Bindings.cpp16
-rw-r--r--source/Bindings.h2
-rw-r--r--source/Defines.h13
-rw-r--r--source/Matrix4f.h2
-rw-r--r--source/cChunk.cpp25
-rw-r--r--source/cChunk.h3
-rw-r--r--source/cClientHandle.cpp10
-rw-r--r--source/packets/cPacket_BlockChange.h2
-rw-r--r--source/packets/cPacket_BlockPlace.h2
9 files changed, 47 insertions, 28 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index 5622503a4..6368dc156 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 03/01/12 18:04:42.
+** Generated automatically by tolua++-1.0.92 on 03/04/12 14:40:53.
*/
#ifndef __cplusplus
@@ -2558,7 +2558,7 @@ static int tolua_AllToLua_AddDirection00(lua_State* tolua_S)
#endif
{
int a_X = ((int) tolua_tonumber(tolua_S,1,0));
- char a_Y = ((char) tolua_tonumber(tolua_S,2,0));
+ unsigned char a_Y = ((unsigned char) tolua_tonumber(tolua_S,2,0));
int a_Z = ((int) tolua_tonumber(tolua_S,3,0));
char a_Direction = ((char) tolua_tonumber(tolua_S,4,0));
bool a_bInverse = ((bool) tolua_toboolean(tolua_S,5,false));
@@ -16617,8 +16617,8 @@ static int tolua_set_cPacket_BlockPlace_m_PosX(lua_State* tolua_S)
#endif //#ifndef TOLUA_DISABLE
/* get function: m_PosY of class cPacket_BlockPlace */
-#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockPlace_m_PosY
-static int tolua_get_cPacket_BlockPlace_m_PosY(lua_State* tolua_S)
+#ifndef TOLUA_DISABLE_tolua_get_cPacket_BlockPlace_unsigned_m_PosY
+static int tolua_get_cPacket_BlockPlace_unsigned_m_PosY(lua_State* tolua_S)
{
cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
@@ -16630,8 +16630,8 @@ static int tolua_get_cPacket_BlockPlace_m_PosY(lua_State* tolua_S)
#endif //#ifndef TOLUA_DISABLE
/* set function: m_PosY of class cPacket_BlockPlace */
-#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockPlace_m_PosY
-static int tolua_set_cPacket_BlockPlace_m_PosY(lua_State* tolua_S)
+#ifndef TOLUA_DISABLE_tolua_set_cPacket_BlockPlace_unsigned_m_PosY
+static int tolua_set_cPacket_BlockPlace_unsigned_m_PosY(lua_State* tolua_S)
{
cPacket_BlockPlace* self = (cPacket_BlockPlace*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
@@ -16640,7 +16640,7 @@ static int tolua_set_cPacket_BlockPlace_m_PosY(lua_State* tolua_S)
if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
#endif
- self->m_PosY = ((char) tolua_tonumber(tolua_S,2,0))
+ self->m_PosY = ((unsigned char) tolua_tonumber(tolua_S,2,0))
;
return 0;
}
@@ -17977,7 +17977,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_cclass(tolua_S,"cPacket_BlockPlace","cPacket_BlockPlace","cPacket",NULL);
tolua_beginmodule(tolua_S,"cPacket_BlockPlace");
tolua_variable(tolua_S,"m_PosX",tolua_get_cPacket_BlockPlace_m_PosX,tolua_set_cPacket_BlockPlace_m_PosX);
- tolua_variable(tolua_S,"m_PosY",tolua_get_cPacket_BlockPlace_m_PosY,tolua_set_cPacket_BlockPlace_m_PosY);
+ tolua_variable(tolua_S,"m_PosY",tolua_get_cPacket_BlockPlace_unsigned_m_PosY,tolua_set_cPacket_BlockPlace_unsigned_m_PosY);
tolua_variable(tolua_S,"m_PosZ",tolua_get_cPacket_BlockPlace_m_PosZ,tolua_set_cPacket_BlockPlace_m_PosZ);
tolua_variable(tolua_S,"m_Direction",tolua_get_cPacket_BlockPlace_m_Direction,tolua_set_cPacket_BlockPlace_m_Direction);
tolua_variable(tolua_S,"m_ItemType",tolua_get_cPacket_BlockPlace_m_ItemType,tolua_set_cPacket_BlockPlace_m_ItemType);
diff --git a/source/Bindings.h b/source/Bindings.h
index b76eea990..eb2915d3f 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 03/01/12 18:04:42.
+** Generated automatically by tolua++-1.0.92 on 03/04/12 14:40:54.
*/
/* Exported function */
diff --git a/source/Defines.h b/source/Defines.h
index dcf4f0e0c..bd35ec3f4 100644
--- a/source/Defines.h
+++ b/source/Defines.h
@@ -55,8 +55,8 @@ inline bool IsBlockLava(char a_BlockID)
return (a_BlockID == E_BLOCK_LAVA || a_BlockID == E_BLOCK_STATIONARY_LAVA);
}
-inline void AddDirection( int & a_X, char & a_Y, int & a_Z, char a_Direction, bool a_bInverse = false ) //tolua_export
-{//tolua_export
+inline void AddDirection( int & a_X, int & a_Y, int & a_Z, char a_Direction, bool a_bInverse = false )
+{
if( !a_bInverse )
{
switch( a_Direction )
@@ -105,6 +105,15 @@ inline void AddDirection( int & a_X, char & a_Y, int & a_Z, char a_Direction, bo
break;
};
}
+}
+
+inline void AddDirection( int & a_X, unsigned char & a_Y, int & a_Z, char a_Direction, bool a_bInverse = false ) //tolua_export
+{//tolua_export
+ int Y = a_Y;
+ AddDirection( a_X, Y, a_Z, a_Direction, a_bInverse );
+ if( Y < 0 ) a_Y = 0;
+ else if( Y > 255 ) a_Y = 255;
+ else a_Y = (unsigned char)Y;
}//tolua_export
#include <math.h>
diff --git a/source/Matrix4f.h b/source/Matrix4f.h
index 8d92f6e44..131208099 100644
--- a/source/Matrix4f.h
+++ b/source/Matrix4f.h
@@ -108,4 +108,4 @@ public:
cell[10] = a_Z.z;
}
float cell[16];
-};
+};
diff --git a/source/cChunk.cpp b/source/cChunk.cpp
index c6813d90b..a622a5148 100644
--- a/source/cChunk.cpp
+++ b/source/cChunk.cpp
@@ -469,7 +469,7 @@ void cChunk::Tick(float a_Dt, MTRand & a_TickRandom)
char Dir = cTorch::MetaDataToDirection( GetLight( m_BlockMeta, X, Y, Z ) );
LOG("MetaData: %i", Dir );
int XX = X + m_PosX*c_ChunkWidth;
- char YY = (char)Y;
+ int YY = Y + m_PosY*c_ChunkHeight;
int ZZ = Z + m_PosZ*c_ChunkWidth;
AddDirection( XX, YY, ZZ, Dir, true );
if( m_World->GetBlock( XX, YY, ZZ ) == E_BLOCK_AIR )
@@ -492,7 +492,7 @@ void cChunk::Tick(float a_Dt, MTRand & a_TickRandom)
{
char Dir = cLadder::MetaDataToDirection( GetLight( m_BlockMeta, X, Y, Z ) );
int XX = X + m_PosX*c_ChunkWidth;
- char YY = (char)Y;
+ int YY = Y + m_PosY*c_ChunkHeight;
int ZZ = Z + m_PosZ*c_ChunkWidth;
AddDirection( XX, YY, ZZ, Dir, true );
if( m_World->GetBlock( XX, YY, ZZ ) == E_BLOCK_AIR )
@@ -905,7 +905,7 @@ void cChunk::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_Block
{
if (a_BlockType != E_BLOCK_AIR)
{
- m_HeightMap[a_X + a_Z * c_ChunkWidth] = a_Y;
+ m_HeightMap[a_X + a_Z * c_ChunkWidth] = (unsigned char)a_Y;
}
else
{
@@ -913,7 +913,7 @@ void cChunk::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_Block
{
if (m_BlockData[MakeIndex(a_X, y, a_Z)] != E_BLOCK_AIR)
{
- m_HeightMap[a_X + a_Z * c_ChunkWidth] = y;
+ m_HeightMap[a_X + a_Z * c_ChunkWidth] = (unsigned char)y;
break;
}
} // for y - column in m_BlockData
@@ -1001,7 +1001,7 @@ void cChunk::FastSetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_B
{
if (a_BlockType != E_BLOCK_AIR)
{
- m_HeightMap[a_X + a_Z * c_ChunkWidth] = a_Y;
+ m_HeightMap[a_X + a_Z * c_ChunkWidth] = (unsigned char)a_Y;
}
else
{
@@ -1009,7 +1009,7 @@ void cChunk::FastSetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_B
{
if (m_BlockData[MakeIndex(a_X, y, a_Z)] != E_BLOCK_AIR)
{
- m_HeightMap[a_X + a_Z * c_ChunkWidth] = y;
+ m_HeightMap[a_X + a_Z * c_ChunkWidth] = (unsigned char)y;
break;
}
} // for y - column in m_BlockData
@@ -1026,7 +1026,11 @@ void cChunk::SendBlockTo( int a_X, int a_Y, int a_Z, cClientHandle* a_Client )
if( a_Client == 0 )
{
cCSLock Lock(m_CSBlockLists);
- m_PendingSendBlocks.push_back( MakeIndex( a_X, a_Y, a_Z ) );
+ unsigned int index = MakeIndex( a_X, a_Y, a_Z );
+ if( index != INDEX_OUT_OF_RANGE )
+ {
+ m_PendingSendBlocks.push_back( MakeIndex( a_X, a_Y, a_Z ) );
+ }
return;
}
@@ -1039,8 +1043,11 @@ void cChunk::SendBlockTo( int a_X, int a_Y, int a_Z, cClientHandle* a_Client )
BlockChange.m_PosX = a_X + m_PosX*c_ChunkWidth;
BlockChange.m_PosY = (char)(a_Y + m_PosY*c_ChunkHeight);
BlockChange.m_PosZ = a_Z + m_PosZ*c_ChunkWidth;
- BlockChange.m_BlockType = m_BlockType[ index ];
- BlockChange.m_BlockMeta = GetLight( m_BlockMeta, index );
+ if( index != INDEX_OUT_OF_RANGE )
+ {
+ BlockChange.m_BlockType = m_BlockType[ index ];
+ BlockChange.m_BlockMeta = GetLight( m_BlockMeta, index );
+ } // else it's both 0
a_Client->Send( BlockChange );
break;
}
diff --git a/source/cChunk.h b/source/cChunk.h
index cbf3b3b85..0759b79f0 100644
--- a/source/cChunk.h
+++ b/source/cChunk.h
@@ -214,13 +214,14 @@ public:
void PositionToWorldPosition(int a_ChunkX, int a_ChunkY, int a_ChunkZ, int & a_X, int & a_Y, int & a_Z);
Vector3i PositionToWorldPosition( const Vector3i & a_InChunkPos );
+ static const unsigned int INDEX_OUT_OF_RANGE = 0xffffffff;
inline static unsigned int MakeIndex(int x, int y, int z )
{
if( x < c_ChunkWidth && x > -1 && y < c_ChunkHeight && y > -1 && z < c_ChunkWidth && z > -1 )
{
return y + (z * c_ChunkHeight) + (x * c_ChunkHeight * c_ChunkWidth);
}
- return 0;
+ return INDEX_OUT_OF_RANGE;
}
inline void MarkDirty(void)
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp
index 9f054aec2..f27ca9e61 100644
--- a/source/cClientHandle.cpp
+++ b/source/cClientHandle.cpp
@@ -823,16 +823,18 @@ void cClientHandle::HandleBlockDig(cPacket_BlockDig * a_Packet)
return;
}
- int pX = a_Packet->m_PosX, pY = a_Packet->m_PosY, pZ = a_Packet->m_PosZ;
+ int pX = a_Packet->m_PosX;
+ unsigned char pY = a_Packet->m_PosY;
+ int pZ = a_Packet->m_PosZ;
- AddDirection(pX, (char &) pY, pZ, a_Packet->m_Direction);
+ AddDirection(pX, pY, pZ, a_Packet->m_Direction);
char PossibleBlock = World->GetBlock(pX, pY, pZ);
if (PossibleBlock == E_BLOCK_FIRE)
{
a_Packet->m_PosX = pX;
- a_Packet->m_PosY = (char)pY;
+ a_Packet->m_PosY = pY;
a_Packet->m_PosZ = pZ;
bBroken = true;
}
@@ -1299,7 +1301,7 @@ void cClientHandle::HandleBlockPlace(cPacket_BlockPlace * a_Packet)
else if (IsValidBlock(a_Packet->m_ItemType))
{
int X = a_Packet->m_PosX;
- char Y = a_Packet->m_PosY;
+ int Y = a_Packet->m_PosY;
int Z = a_Packet->m_PosZ;
AddDirection(X, Y, Z, a_Packet->m_Direction);
diff --git a/source/packets/cPacket_BlockChange.h b/source/packets/cPacket_BlockChange.h
index 0477dc9c9..a0b3c8843 100644
--- a/source/packets/cPacket_BlockChange.h
+++ b/source/packets/cPacket_BlockChange.h
@@ -18,7 +18,7 @@ public:
virtual void Serialize(AString & a_Data) const override;
int m_PosX;
- char m_PosY;
+ unsigned char m_PosY;
int m_PosZ;
char m_BlockType;
char m_BlockMeta;
diff --git a/source/packets/cPacket_BlockPlace.h b/source/packets/cPacket_BlockPlace.h
index 74bf63d28..9fa2fbbce 100644
--- a/source/packets/cPacket_BlockPlace.h
+++ b/source/packets/cPacket_BlockPlace.h
@@ -24,7 +24,7 @@ public:
virtual int Parse(const char * a_Data, int a_Size) override;
int m_PosX; //tolua_export
- char m_PosY; //tolua_export
+ unsigned char m_PosY; //tolua_export
int m_PosZ; //tolua_export
char m_Direction; //tolua_export