Changed signed char to unsigned char in block packets, so we can receive height up to 255
Blocks placed above 128 limit don't become obsidian anymore. This was due to the cChunk::MakeIndex() function return 0 when outside of bounds, it now returns an 'error constant' git-svn-id: http://mc-server.googlecode.com/svn/trunk@356 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
ad89cf88ba
commit
fb7c60ec11
@ -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);
|
||||
|
@ -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 */
|
||||
|
@ -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>
|
||||
|
@ -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);
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user