1
0
Fork 0

Fixed a few gcc pedantic warnings; made BLOCKTYPE an unsigned char type.

git-svn-id: http://mc-server.googlecode.com/svn/trunk@711 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2012-08-03 11:53:11 +00:00
parent f85f83df7f
commit 2a72c5c838
23 changed files with 338 additions and 125 deletions

View File

@ -30,8 +30,8 @@ CCE_OPTIONS = -s -x c -O3
LNK_OPTIONS = -lstdc++ -pthread -O3
BUILDDIR = build/release/
else
CC_OPTIONS = -s -ggdb -D_DEBUG
CCE_OPTIONS = -s -x c -ggdb -D_DEBUG
CC_OPTIONS = -s -ggdb -D_DEBUG -Wall -Wextra -pedantic -ansi -Wno-long-long
CCE_OPTIONS = -s -x c -ggdb -D_DEBUG -Wall -Wextra -pedantic -ansi -Wno-long-long
LNK_OPTIONS = -lstdc++ -pthread -ggdb
BUILDDIR = build/debug/
endif

View File

@ -48,8 +48,8 @@ public:
http_request()
: s_( 0 )
, authentication_given_(false)
, content_length_( 0 )
, authentication_given_(false)
{}
Socket* s_;

View File

@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 07/29/12 13:49:55.
** Generated automatically by tolua++-1.0.92 on 08/03/12 10:35:41.
*/
#ifndef __cplusplus
@ -2572,7 +2572,7 @@ static int tolua_AllToLua_BlockStringToType00(lua_State* tolua_S)
{
const AString a_BlockTypeString = ((const AString) tolua_tocppstring(tolua_S,1,0));
{
char tolua_ret = ( char) BlockStringToType(a_BlockTypeString);
unsigned char tolua_ret = ( unsigned char) BlockStringToType(a_BlockTypeString);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
tolua_pushcppstring(tolua_S,(const char*)a_BlockTypeString);
}
@ -8035,7 +8035,7 @@ static int tolua_AllToLua_cPlugin_OnBlockToPickup00(lua_State* tolua_S)
#endif
{
cPlugin* self = (cPlugin*) tolua_tousertype(tolua_S,1,0);
char a_BlockType = (( char) tolua_tonumber(tolua_S,2,0));
unsigned char a_BlockType = (( unsigned char) tolua_tonumber(tolua_S,2,0));
unsigned char a_BlockMeta = (( unsigned char) tolua_tonumber(tolua_S,3,0));
const cPlayer* a_Player = ((const cPlayer*) tolua_tousertype(tolua_S,4,0));
const cItem* a_EquippedItem = ((const cItem*) tolua_tousertype(tolua_S,5,0));
@ -8671,7 +8671,7 @@ public:
return ( bool ) cPlugin:: OnPostCrafting(a_Player,a_Grid,a_Recipe);
};
};
bool OnBlockToPickup( char a_BlockType, unsigned char a_BlockMeta, const cPlayer* a_Player, const cItem& a_EquippedItem, cItems& a_Pickups) {
bool OnBlockToPickup( unsigned char a_BlockType, unsigned char a_BlockMeta, const cPlayer* a_Player, const cItem& a_EquippedItem, cItems& a_Pickups) {
if (push_method("OnBlockToPickup", tolua_AllToLua_cPlugin_OnBlockToPickup00)) {
tolua_pushnumber(lua_state, (lua_Number)a_BlockType);
tolua_pushnumber(lua_state, (lua_Number)a_BlockMeta);
@ -8788,7 +8788,7 @@ public:
bool cPlugin__OnPostCrafting( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) {
return ( bool )cPlugin::OnPostCrafting(a_Player,a_Grid,a_Recipe);
};
bool cPlugin__OnBlockToPickup( char a_BlockType, unsigned char a_BlockMeta, const cPlayer* a_Player, const cItem& a_EquippedItem, cItems& a_Pickups) {
bool cPlugin__OnBlockToPickup( unsigned char a_BlockType, unsigned char a_BlockMeta, const cPlayer* a_Player, const cItem& a_EquippedItem, cItems& a_Pickups) {
return ( bool )cPlugin::OnBlockToPickup(a_BlockType,a_BlockMeta,a_Player,a_EquippedItem,a_Pickups);
};
bool cPlugin__OnWeatherChanged( cWorld* a_World) {
@ -9499,7 +9499,7 @@ static int tolua_AllToLua_Lua__cPlugin_cPlugin__OnBlockToPickup00(lua_State* tol
#endif
{
Lua__cPlugin* self = (Lua__cPlugin*) tolua_tousertype(tolua_S,1,0);
char a_BlockType = ((char) tolua_tonumber(tolua_S,2,0));
unsigned char a_BlockType = ((unsigned char) tolua_tonumber(tolua_S,2,0));
unsigned char a_BlockMeta = ((unsigned char) tolua_tonumber(tolua_S,3,0));
const cPlayer* a_Player = ((const cPlayer*) tolua_tousertype(tolua_S,4,0));
const cItem* a_EquippedItem = ((const cItem*) tolua_tousertype(tolua_S,5,0));
@ -10096,7 +10096,7 @@ public:
return ( bool ) cPlugin_NewLua:: OnPostCrafting(a_Player,a_Grid,a_Recipe);
};
};
bool OnBlockToPickup( char a_BlockType, unsigned char a_BlockMeta, const cPlayer* a_Player, const cItem& a_EquippedItem, cItems& a_Pickups) {
bool OnBlockToPickup( unsigned char a_BlockType, unsigned char a_BlockMeta, const cPlayer* a_Player, const cItem& a_EquippedItem, cItems& a_Pickups) {
if (push_method("OnBlockToPickup", tolua_AllToLua_cPlugin_OnBlockToPickup00)) {
tolua_pushnumber(lua_state, (lua_Number)a_BlockType);
tolua_pushnumber(lua_state, (lua_Number)a_BlockMeta);
@ -10216,7 +10216,7 @@ public:
bool cPlugin_NewLua__OnPostCrafting( const cPlayer* a_Player, const cCraftingGrid* a_Grid, cCraftingRecipe* a_Recipe) {
return ( bool )cPlugin_NewLua::OnPostCrafting(a_Player,a_Grid,a_Recipe);
};
bool cPlugin_NewLua__OnBlockToPickup( char a_BlockType, unsigned char a_BlockMeta, const cPlayer* a_Player, const cItem& a_EquippedItem, cItems& a_Pickups) {
bool cPlugin_NewLua__OnBlockToPickup( unsigned char a_BlockType, unsigned char a_BlockMeta, const cPlayer* a_Player, const cItem& a_EquippedItem, cItems& a_Pickups) {
return ( bool )cPlugin_NewLua::OnBlockToPickup(a_BlockType,a_BlockMeta,a_Player,a_EquippedItem,a_Pickups);
};
bool cPlugin_NewLua__OnWeatherChanged( cWorld* a_World) {
@ -10888,8 +10888,8 @@ static int tolua_AllToLua_cWorld_SetBlock00(lua_State* tolua_S)
int a_X = ((int) tolua_tonumber(tolua_S,2,0));
int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
int a_Z = ((int) tolua_tonumber(tolua_S,4,0));
char a_BlockType = ((char) tolua_tonumber(tolua_S,5,0));
char a_BlockMeta = ((char) tolua_tonumber(tolua_S,6,0));
unsigned char a_BlockType = (( unsigned char) tolua_tonumber(tolua_S,5,0));
unsigned char a_BlockMeta = (( unsigned char) tolua_tonumber(tolua_S,6,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetBlock'", NULL);
#endif
@ -10929,8 +10929,8 @@ static int tolua_AllToLua_cWorld_FastSetBlock00(lua_State* tolua_S)
int a_X = ((int) tolua_tonumber(tolua_S,2,0));
int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
int a_Z = ((int) tolua_tonumber(tolua_S,4,0));
char a_BlockType = ((char) tolua_tonumber(tolua_S,5,0));
char a_BlockMeta = ((char) tolua_tonumber(tolua_S,6,0));
unsigned char a_BlockType = (( unsigned char) tolua_tonumber(tolua_S,5,0));
unsigned char a_BlockMeta = (( unsigned char) tolua_tonumber(tolua_S,6,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'FastSetBlock'", NULL);
#endif
@ -10972,7 +10972,7 @@ static int tolua_AllToLua_cWorld_GetBlock00(lua_State* tolua_S)
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetBlock'", NULL);
#endif
{
char tolua_ret = (char) self->GetBlock(a_X,a_Y,a_Z);
unsigned char tolua_ret = ( unsigned char) self->GetBlock(a_X,a_Y,a_Z);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
@ -11004,7 +11004,7 @@ static int tolua_AllToLua_cWorld_GetBlock01(lua_State* tolua_S)
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetBlock'", NULL);
#endif
{
char tolua_ret = (char) self->GetBlock(*a_Pos);
unsigned char tolua_ret = ( unsigned char) self->GetBlock(*a_Pos);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
@ -11039,7 +11039,7 @@ static int tolua_AllToLua_cWorld_GetBlockMeta00(lua_State* tolua_S)
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetBlockMeta'", NULL);
#endif
{
char tolua_ret = (char) self->GetBlockMeta(a_X,a_Y,a_Z);
unsigned char tolua_ret = ( unsigned char) self->GetBlockMeta(a_X,a_Y,a_Z);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
@ -11071,7 +11071,7 @@ static int tolua_AllToLua_cWorld_GetBlockMeta01(lua_State* tolua_S)
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetBlockMeta'", NULL);
#endif
{
char tolua_ret = (char) self->GetBlockMeta(*a_Pos);
unsigned char tolua_ret = ( unsigned char) self->GetBlockMeta(*a_Pos);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
@ -11103,7 +11103,7 @@ static int tolua_AllToLua_cWorld_SetBlockMeta00(lua_State* tolua_S)
int a_X = ((int) tolua_tonumber(tolua_S,2,0));
int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
int a_Z = ((int) tolua_tonumber(tolua_S,4,0));
char a_MetaData = ((char) tolua_tonumber(tolua_S,5,0));
unsigned char a_MetaData = (( unsigned char) tolua_tonumber(tolua_S,5,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetBlockMeta'", NULL);
#endif
@ -11136,7 +11136,7 @@ static int tolua_AllToLua_cWorld_SetBlockMeta01(lua_State* tolua_S)
{
cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
const Vector3i* a_Pos = ((const Vector3i*) tolua_tousertype(tolua_S,2,0));
char a_MetaData = ((char) tolua_tonumber(tolua_S,3,0));
unsigned char a_MetaData = (( unsigned char) tolua_tonumber(tolua_S,3,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetBlockMeta'", NULL);
#endif
@ -11175,7 +11175,7 @@ static int tolua_AllToLua_cWorld_GetBlockSkyLight00(lua_State* tolua_S)
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetBlockSkyLight'", NULL);
#endif
{
char tolua_ret = (char) self->GetBlockSkyLight(a_X,a_Y,a_Z);
unsigned char tolua_ret = ( unsigned char) self->GetBlockSkyLight(a_X,a_Y,a_Z);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
@ -11211,8 +11211,8 @@ static int tolua_AllToLua_cWorld_GetBlockTypeMeta00(lua_State* tolua_S)
int a_BlockX = ((int) tolua_tonumber(tolua_S,2,0));
int a_BlockY = ((int) tolua_tonumber(tolua_S,3,0));
int a_BlockZ = ((int) tolua_tonumber(tolua_S,4,0));
char a_BlockType = ((char) tolua_tonumber(tolua_S,5,0));
unsigned char a_BlockMeta = ((unsigned char) tolua_tonumber(tolua_S,6,0));
unsigned char a_BlockType = (( unsigned char) tolua_tonumber(tolua_S,5,0));
unsigned char a_BlockMeta = (( unsigned char) tolua_tonumber(tolua_S,6,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetBlockTypeMeta'", NULL);
#endif
@ -18121,7 +18121,7 @@ static int tolua_AllToLua_cBlockArea_SetRelBlockType00(lua_State* tolua_S)
int a_RelX = ((int) tolua_tonumber(tolua_S,2,0));
int a_RelY = ((int) tolua_tonumber(tolua_S,3,0));
int a_RelZ = ((int) tolua_tonumber(tolua_S,4,0));
char a_BlockType = (( char) tolua_tonumber(tolua_S,5,0));
unsigned char a_BlockType = (( unsigned char) tolua_tonumber(tolua_S,5,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetRelBlockType'", NULL);
#endif
@ -18160,7 +18160,7 @@ static int tolua_AllToLua_cBlockArea_SetBlockType00(lua_State* tolua_S)
int a_BlockX = ((int) tolua_tonumber(tolua_S,2,0));
int a_BlockY = ((int) tolua_tonumber(tolua_S,3,0));
int a_BlockZ = ((int) tolua_tonumber(tolua_S,4,0));
char a_BlockType = (( char) tolua_tonumber(tolua_S,5,0));
unsigned char a_BlockType = (( unsigned char) tolua_tonumber(tolua_S,5,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetBlockType'", NULL);
#endif
@ -18436,7 +18436,7 @@ static int tolua_AllToLua_cBlockArea_GetRelBlockType00(lua_State* tolua_S)
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetRelBlockType'", NULL);
#endif
{
char tolua_ret = ( char) self->GetRelBlockType(a_RelX,a_RelY,a_RelZ);
unsigned char tolua_ret = ( unsigned char) self->GetRelBlockType(a_RelX,a_RelY,a_RelZ);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
@ -18474,7 +18474,7 @@ static int tolua_AllToLua_cBlockArea_GetBlockType00(lua_State* tolua_S)
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetBlockType'", NULL);
#endif
{
char tolua_ret = ( char) self->GetBlockType(a_BlockX,a_BlockY,a_BlockZ);
unsigned char tolua_ret = ( unsigned char) self->GetBlockType(a_BlockX,a_BlockY,a_BlockZ);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
@ -21348,7 +21348,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_BLOCK_TRIPWIRE_HOOK",E_BLOCK_TRIPWIRE_HOOK);
tolua_constant(tolua_S,"E_BLOCK_TRIPWIRE",E_BLOCK_TRIPWIRE);
tolua_constant(tolua_S,"E_BLOCK_EMERALD_BLOCK",E_BLOCK_EMERALD_BLOCK);
tolua_constant(tolua_S,"E_BLOCK_",E_BLOCK_);
tolua_constant(tolua_S,"E_ITEM_EMPTY",E_ITEM_EMPTY);
tolua_constant(tolua_S,"E_ITEM_STONE",E_ITEM_STONE);
tolua_constant(tolua_S,"E_ITEM_GRASS",E_ITEM_GRASS);

View File

@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 07/29/12 13:49:56.
** Generated automatically by tolua++-1.0.92 on 08/03/12 10:35:42.
*/
/* Exported function */

View File

@ -149,8 +149,7 @@ enum ENUM_BLOCK_ID
E_BLOCK_ENDER_CHEST = 130,
E_BLOCK_TRIPWIRE_HOOK = 131,
E_BLOCK_TRIPWIRE = 132,
E_BLOCK_EMERALD_BLOCK = 133,
E_BLOCK_ = 121,
E_BLOCK_EMERALD_BLOCK = 133
};
//tolua_end
@ -440,7 +439,7 @@ enum ENUM_ITEM_ID
E_ITEM_STAL_DISC = 2263,
E_ITEM_STRAD_DISC = 2264,
E_ITEM_WARD_DISC = 2265,
E_ITEM_11_DISC = 2266,
E_ITEM_11_DISC = 2266
};
@ -540,7 +539,7 @@ enum
E_BLOCK_WOODEN_STEP_APPLE = 0,
E_BLOCK_WOODEN_STEP_CONIFER = 1,
E_BLOCK_WOODEN_STEP_BIRCH = 2,
E_BLOCK_WOODEN_STEP_JUNGLE = 3,
E_BLOCK_WOODEN_STEP_JUNGLE = 3
} ;
@ -603,7 +602,7 @@ enum
E_META_SPAWN_EGG_OCELOT = 98,
E_META_SPAWN_EGG_VILLAGER = 120,
E_META_SPAWN_EGG_SNOW_GOLEM = 97,
E_META_SPAWN_EGG_IRON_GOLEM = 99,
E_META_SPAWN_EGG_IRON_GOLEM = 99
} ;
//tolua_end

View File

@ -44,7 +44,7 @@ typedef std::list<cBlockEntity *> cBlockEntityList;
// tolua_begin
/// The datatype used by blockdata
typedef char BLOCKTYPE;
typedef unsigned char BLOCKTYPE;
/// The datatype used by nibbledata (meta, light, skylight)
typedef unsigned char NIBBLETYPE;
@ -94,7 +94,7 @@ enum EMCSBiome
// Automatically capture the maximum biome value into biMaxBiome:
biNumBiomes, // True number of biomes, since they are zero-based
biMaxBiome = biNumBiomes - 1, // The maximum biome value
biMaxBiome = biNumBiomes - 1 // The maximum biome value
} ;
// tolua_end
@ -316,34 +316,34 @@ public:
(only in processes where multiple chunks can be processed, such as cWorld::ForEachChunkInRect()).
If false is returned, the chunk is skipped.
*/
virtual bool Coords(int a_ChunkX, int a_ChunkZ) { return true; };
virtual bool Coords(int a_ChunkX, int a_ChunkZ) { UNUSED(a_ChunkX); UNUSED(a_ChunkZ); return true; };
/// Called once to provide heightmap data
virtual void HeightMap(const cChunkDef::HeightMap * a_HeightMap) {};
virtual void HeightMap(const cChunkDef::HeightMap * a_HeightMap) {UNUSED(a_HeightMap); };
/// Called once to provide biome data
virtual void BiomeData (const cChunkDef::BiomeMap * a_BiomeMap) {};
virtual void BiomeData (const cChunkDef::BiomeMap * a_BiomeMap) {UNUSED(a_BiomeMap); };
/// Called once to export block types
virtual void BlockTypes (const BLOCKTYPE * a_Type) {};
virtual void BlockTypes (const BLOCKTYPE * a_Type) {UNUSED(a_Type); };
/// Called once to export block meta
virtual void BlockMeta (const NIBBLETYPE * a_Meta) {};
virtual void BlockMeta (const NIBBLETYPE * a_Meta) {UNUSED(a_Meta); };
/// Called once to let know if the chunk lighting is valid. Return value is used to control if BlockLight() and BlockSkyLight() are called next (if true)
virtual bool LightIsValid(bool a_IsLightValid) {return true; };
virtual bool LightIsValid(bool a_IsLightValid) {UNUSED(a_IsLightValid); return true; };
/// Called once to export block light
virtual void BlockLight (const NIBBLETYPE * a_Meta) {};
virtual void BlockLight (const NIBBLETYPE * a_BlockLight) {UNUSED(a_BlockLight); };
/// Called once to export sky light
virtual void BlockSkyLight(const NIBBLETYPE * a_Meta) {};
virtual void BlockSkyLight(const NIBBLETYPE * a_SkyLight) {UNUSED(a_SkyLight); };
/// Called for each entity in the chunk
virtual void Entity(cEntity * a_Entity) {};
virtual void Entity(cEntity * a_Entity) {UNUSED(a_Entity); };
/// Called for each blockentity in the chunk
virtual void BlockEntity(cBlockEntity * a_Entity) {};
virtual void BlockEntity(cBlockEntity * a_Entity) {UNUSED(a_Entity); };
} ;
@ -357,8 +357,8 @@ class cChunkDataCollector :
{
public:
// Must be char instead of BLOCKTYPE or NIBBLETYPE, because it houses both.
char m_BlockData[cChunkDef::BlockDataSize];
// Must be unsigned char instead of BLOCKTYPE or NIBBLETYPE, because it houses both.
unsigned char m_BlockData[cChunkDef::BlockDataSize];
protected:
@ -458,8 +458,8 @@ struct sSetBlock
sSetBlock( int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ); // absolute block position
sSetBlock(int a_ChunkX, int a_ChunkZ, int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) :
ChunkX(a_ChunkX), ChunkZ(a_ChunkZ),
x(a_X), y(a_Y), z(a_Z),
ChunkX(a_ChunkX), ChunkZ(a_ChunkZ),
BlockType(a_BlockType),
BlockMeta(a_BlockMeta)
{}

View File

@ -223,7 +223,7 @@ void cChunkSender::SendChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cClientHa
return;
}
cPacket_PreChunk PreChunk(a_ChunkX, a_ChunkZ, true);
cPacket_MapChunk MapChunk(a_ChunkX, a_ChunkY, a_ChunkZ, m_BlockData, m_BiomeMap);
cPacket_MapChunk MapChunk(a_ChunkX, a_ChunkY, a_ChunkZ, (BLOCKTYPE *)m_BlockData, m_BiomeMap);
// Send:
if (a_Client == NULL)

View File

@ -289,9 +289,9 @@ inline bool BlockRequiresSpecialTool(BLOCKTYPE a_BlockID)
//tolua_begin
enum eGameMode
{
eGameMode_NotSet = -1,
eGameMode_Survival = 0,
eGameMode_Creative = 1,
eGameMode_NotSet = -1,
eGameMode_Survival = 0,
eGameMode_Creative = 1
};
@ -300,10 +300,9 @@ enum eGameMode
enum eWeather
{
eWeather_Sunny = 0,
eWeather_Rain = 1,
eWeather_ThunderStorm = 2,
eWeather_Sunny = 0,
eWeather_Rain = 1,
eWeather_ThunderStorm = 2
};

View File

@ -80,6 +80,8 @@ typedef short Int16;
TypeName(const TypeName &); \
void operator=(const TypeName &)
// A macro that is used to mark unused function parameters, to avoid pedantic warnings in gcc
#define UNUSED(X) (void)(X)

View File

@ -1,5 +1,10 @@
#pragma once
//tolua_begin
enum ENUM_PACKET_ID
{
@ -56,6 +61,10 @@ enum ENUM_PACKET_ID
E_PLAYER_LIST_ITEM = 0xC9,
E_PLAYER_ABILITIES = 0xca, // since 1.2.4, protocol version 29
E_PING = 0xfe,
E_DISCONNECT = 0xff,
};
E_DISCONNECT = 0xff
} ;
//tolua_end

View File

@ -27,7 +27,7 @@ public:
cJsonChunkSerializer(void);
Json::Value & GetRoot (void) {return m_Root; }
BLOCKTYPE * GetBlockData(void) {return m_BlockData; }
BLOCKTYPE * GetBlockData(void) {return (BLOCKTYPE *)m_BlockData; }
bool HasJsonData (void) const {return m_HasJsonData; }
protected:

View File

@ -606,7 +606,7 @@ BLOCKTYPE cChunkMap::GetBlockSkyLight(int a_X, int a_Y, int a_Z)
void cChunkMap::SetBlockMeta(int a_X, int a_Y, int a_Z, char a_BlockMeta)
void cChunkMap::SetBlockMeta(int a_X, int a_Y, int a_Z, NIBBLETYPE a_BlockMeta)
{
int ChunkX, ChunkZ;
cChunkDef::AbsoluteToRelative( a_X, a_Y, a_Z, ChunkX, ChunkZ );

View File

@ -49,9 +49,9 @@ public:
/// The mode in which to open the file
enum EMode
{
fmRead, // Read-only. If the file doesn't exist, object will not be valid
fmWrite, // Write-only. If the file already exists, it will be overwritten
fmReadWrite, // Read/write. If the file already exists, it will be left intact; writing will overwrite the data from the beginning
fmRead, // Read-only. If the file doesn't exist, object will not be valid
fmWrite, // Write-only. If the file already exists, it will be overwritten
fmReadWrite // Read/write. If the file already exists, it will be left intact; writing will overwrite the data from the beginning
} ;
/// Simple constructor - creates an unopened file object, use Open() to open / create a real file

View File

@ -6,7 +6,7 @@
namespace Json
{
class Value;
};
}

View File

@ -20,7 +20,7 @@ struct TakeDamageInfo //tolua_export
class cPawn : public cEntity //tolua_export
{ //tolua_export
public:
CLASS_PROTOTYPE();
CLASS_PROTOTYPE()
cPawn();
virtual ~cPawn();

View File

@ -23,7 +23,8 @@ class cPlayer : public cPawn //tolua_export
{ //tolua_export
public:
typedef cPawn super;
CLASS_PROTOTYPE();
CLASS_PROTOTYPE()
cPlayer(cClientHandle * a_Client, const AString & a_PlayerName);
virtual ~cPlayer();

View File

@ -24,57 +24,253 @@ cPlugin::~cPlugin()
// return false;
// }
void cPlugin::Tick(float a_Dt)
{
(void)a_Dt;
UNUSED(a_Dt);
}
bool cPlugin::OnBlockPlace( cPacket_BlockPlace* a_PacketData, cPlayer* a_Player )
bool cPlugin::OnBlockPlace(cPacket_BlockPlace * a_PacketData, cPlayer * a_Player)
{
(void)a_PacketData;
(void)a_Player;
UNUSED(a_PacketData);
UNUSED(a_Player);
return false;
}
bool cPlugin::OnCollectItem( cPickup* a_Pickup, cPlayer* a_Player )
bool cPlugin::OnBlockDig(cPacket_BlockDig * a_PacketData, cPlayer * a_Player, cItem * a_PickupItem)
{
(void)a_Pickup;
(void)a_Player;
UNUSED(a_PacketData);
UNUSED(a_Player);
UNUSED(a_PickupItem);
return false;
}
bool cPlugin::OnDisconnect(const AString & a_Reason, cPlayer* a_Player )
bool cPlugin::OnCollectItem(cPickup * a_Pickup, cPlayer * a_Player)
{
(void)a_Reason;
(void)a_Player;
UNUSED(a_Pickup);
UNUSED(a_Player);
return false;
}
bool cPlugin::OnChat( const char* a_Chat, cPlayer* a_Player )
bool cPlugin::OnDisconnect(const AString & a_Reason, cPlayer * a_Player)
{
(void)a_Chat;
(void)a_Player;
UNUSED(a_Reason);
UNUSED(a_Player);
return false;
}
bool cPlugin::OnLogin( cPacket_Login* a_PacketData )
bool cPlugin::OnChat(const char * a_Chat, cPlayer * a_Player)
{
(void)a_PacketData;
UNUSED(a_Chat);
UNUSED(a_Player);
return false;
}
void cPlugin::OnPlayerSpawn( cPlayer* a_Player )
{
(void)a_Player;
}
bool cPlugin::OnPlayerJoin( cPlayer* a_Player )
bool cPlugin::OnLogin(cPacket_Login * a_PacketData)
{
(void)a_Player;
UNUSED(a_PacketData);
return false;
}
void cPlugin::AddCommand( std::string & a_Command, std::string & a_Description, std::string & a_Permission )
void cPlugin::OnPlayerSpawn(cPlayer * a_Player)
{
UNUSED(a_Player);
}
bool cPlugin::OnPlayerJoin(cPlayer * a_Player)
{
UNUSED(a_Player);
return false;
}
void cPlugin::OnPlayerMove(cPlayer * a_Player)
{
UNUSED(a_Player);
}
void cPlugin::OnTakeDamage(cPawn * a_Pawn, TakeDamageInfo * a_TakeDamageInfo)
{
UNUSED(a_Pawn);
UNUSED(a_TakeDamageInfo);
}
bool cPlugin::OnKilled(cPawn * a_Killed, cEntity * a_Killer)
{
UNUSED(a_Killed);
UNUSED(a_Killer);
return false;
}
void cPlugin::OnChunkGenerated(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
{
UNUSED(a_World);
UNUSED(a_ChunkX);
UNUSED(a_ChunkZ);
}
bool cPlugin::OnChunkGenerating(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk * a_pLuaChunk)
{
UNUSED(a_World);
UNUSED(a_ChunkX);
UNUSED(a_ChunkZ);
UNUSED(a_pLuaChunk);
return false;
}
bool cPlugin::OnPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
{
UNUSED(a_Player);
UNUSED(a_Grid);
UNUSED(a_Recipe);
return false;
}
bool cPlugin::OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
{
UNUSED(a_Player);
UNUSED(a_Grid);
UNUSED(a_Recipe);
return false;
}
bool cPlugin::OnPostCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
{
UNUSED(a_Player);
UNUSED(a_Grid);
UNUSED(a_Recipe);
return false;
}
bool cPlugin::OnBlockToPickup(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, const cPlayer * a_Player, const cItem & a_EquippedItem, cItems & a_Pickups)
{
UNUSED(a_BlockType);
UNUSED(a_BlockMeta);
UNUSED(a_Player);
UNUSED(a_EquippedItem);
UNUSED(a_Pickups);
return false;
}
bool cPlugin::OnWeatherChanged(cWorld * a_World)
{
UNUSED(a_World);
return false;
}
bool cPlugin::OnUpdatingSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4)
{
UNUSED(a_World);
UNUSED(a_BlockX);
UNUSED(a_BlockY);
UNUSED(a_BlockZ);
UNUSED(a_Line1);
UNUSED(a_Line2);
UNUSED(a_Line3);
UNUSED(a_Line4);
return false;
}
bool cPlugin::OnUpdatedSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4)
{
UNUSED(a_World);
UNUSED(a_BlockX);
UNUSED(a_BlockY);
UNUSED(a_BlockZ);
UNUSED(a_Line1);
UNUSED(a_Line2);
UNUSED(a_Line3);
UNUSED(a_Line4);
return false;
}
void cPlugin::AddCommand(const AString & a_Command, const AString & a_Description, const AString & a_Permission)
{
CommandStruct Command;
Command.Command = a_Command;
@ -82,3 +278,7 @@ void cPlugin::AddCommand( std::string & a_Command, std::string & a_Description,
Command.Permission = a_Permission;
m_Commands.push_back( Command );
}

View File

@ -51,23 +51,23 @@ public:
virtual bool OnCollectItem (cPickup* a_Pickup, cPlayer* a_Player );
virtual bool OnDisconnect (const AString & a_Reason, cPlayer * a_Player );
virtual bool OnBlockPlace (cPacket_BlockPlace* a_PacketData, cPlayer* a_Player );
virtual bool OnBlockDig (cPacket_BlockDig * a_PacketData, cPlayer* a_Player, cItem* a_PickupItem ) { (void)a_PacketData; (void)a_Player; (void)a_PickupItem; return false; }
virtual bool OnBlockDig (cPacket_BlockDig * a_PacketData, cPlayer * a_Player, cItem * a_PickupItem);
virtual bool OnChat (const char * a_Chat, cPlayer* a_Player );
virtual bool OnLogin (cPacket_Login* a_PacketData );
virtual void OnPlayerSpawn (cPlayer* a_Player );
virtual bool OnPlayerJoin (cPlayer* a_Player );
virtual void OnPlayerMove (cPlayer* a_Player ) { (void)a_Player; }
virtual void OnTakeDamage (cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo ) { (void)a_Pawn; (void)a_TakeDamageInfo; }
virtual bool OnKilled (cPawn* a_Killed, cEntity* a_Killer ) { (void)a_Killed; (void)a_Killer; return false; }
virtual void OnChunkGenerated (cWorld * a_World, int a_ChunkX, int a_ChunkZ) {}
virtual bool OnChunkGenerating (cWorld * a_Wordl, int a_ChunkX, int a_ChunkZ, cLuaChunk * a_pLuaChunk ) { return false; }
virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) {return false; }
virtual bool OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) {return false; }
virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) {return false; }
virtual bool OnBlockToPickup (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, const cPlayer * a_Player, const cItem & a_EquippedItem, cItems & a_Pickups) {return false; }
virtual bool OnWeatherChanged (cWorld * a_World) {return false; }
virtual bool OnUpdatingSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4) {return false; }
virtual bool OnUpdatedSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4) {return false; }
virtual void OnPlayerMove (cPlayer* a_Player );
virtual void OnTakeDamage (cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo );
virtual bool OnKilled (cPawn* a_Killed, cEntity* a_Killer );
virtual void OnChunkGenerated (cWorld * a_World, int a_ChunkX, int a_ChunkZ);
virtual bool OnChunkGenerating (cWorld * a_World, int a_ChunkX, int a_ChunkZ, cLuaChunk * a_pLuaChunk);
virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
virtual bool OnCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
virtual bool OnBlockToPickup (BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, const cPlayer * a_Player, const cItem & a_EquippedItem, cItems & a_Pickups);
virtual bool OnWeatherChanged (cWorld * a_World);
virtual bool OnUpdatingSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4);
virtual bool OnUpdatedSign (cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4);
// Accessors
const char* GetName() const { return m_Name.c_str(); }
@ -83,8 +83,9 @@ public:
std::string Permission;
};
void AddCommand( std::string & a_Command, std::string & a_Description, std::string & a_Permission );
void AddCommand(const AString & a_Command, const AString & a_Description, const AString & a_Permission);
// tolua_end
typedef bool (FuncCommandHandler)( std::string & a_Command, std::vector< std::string > & a_Split );
void BindCommand( FuncCommandHandler* a_Function, std::string & a_Command ); // >> EXPORTED IN MANUALBINDINGS <<
const std::vector< CommandStruct > & GetCommands() const { return m_Commands; } // >> EXPORTED IN MANUALBINDINGS <<

View File

@ -34,7 +34,7 @@ cSocket::~cSocket()
cSocket::operator const cSocket::xSocket() const
cSocket::operator cSocket::xSocket() const
{
return m_Socket;
}

View File

@ -28,7 +28,7 @@ public:
bool IsValid(void) const;
void CloseSocket();
operator const xSocket() const;
operator xSocket() const;
xSocket GetSocket() const;
bool operator == (const cSocket & a_Other) {return m_Socket == a_Other.m_Socket; }

View File

@ -465,7 +465,7 @@ void cWorld::Tick(float a_Dt)
{
if ((*itr)->IsDestroyed())
{
LOG("Destroying entity #%i", (*itr)->GetUniqueID());
LOGD("Destroying entity #%i", (*itr)->GetUniqueID());
cEntity * RemoveMe = *itr;
itr = m_AllEntities.erase( itr );
m_RemoveEntityQueue.push_back( RemoveMe );
@ -1032,7 +1032,7 @@ int cWorld::GetBiomeAt (int a_BlockX, int a_BlockZ)
void cWorld::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta )
void cWorld::SetBlock( int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta )
{
if(a_BlockType == E_BLOCK_AIR)
{
@ -1048,7 +1048,7 @@ void cWorld::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_Block
void cWorld::FastSetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta )
void cWorld::FastSetBlock( int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta )
{
cCSLock Lock(m_CSFastSetBlock);
m_FastSetBlockQueue.push_back(sSetBlock(a_X, a_Y, a_Z, a_BlockType, a_BlockMeta));
@ -1058,7 +1058,7 @@ void cWorld::FastSetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_B
char cWorld::GetBlock(int a_X, int a_Y, int a_Z)
BLOCKTYPE cWorld::GetBlock(int a_X, int a_Y, int a_Z)
{
// First check if it isn't queued in the m_FastSetBlockQueue:
{
@ -1083,7 +1083,7 @@ char cWorld::GetBlock(int a_X, int a_Y, int a_Z)
char cWorld::GetBlockMeta( int a_X, int a_Y, int a_Z )
NIBBLETYPE cWorld::GetBlockMeta( int a_X, int a_Y, int a_Z )
{
// First check if it isn't queued in the m_FastSetBlockQueue:
{
@ -1104,7 +1104,7 @@ char cWorld::GetBlockMeta( int a_X, int a_Y, int a_Z )
void cWorld::SetBlockMeta( int a_X, int a_Y, int a_Z, char a_MetaData )
void cWorld::SetBlockMeta( int a_X, int a_Y, int a_Z, NIBBLETYPE a_MetaData )
{
m_ChunkMap->SetBlockMeta(a_X, a_Y, a_Z, a_MetaData);
}
@ -1113,7 +1113,7 @@ void cWorld::SetBlockMeta( int a_X, int a_Y, int a_Z, char a_MetaData )
char cWorld::GetBlockSkyLight( int a_X, int a_Y, int a_Z )
NIBBLETYPE cWorld::GetBlockSkyLight( int a_X, int a_Y, int a_Z )
{
return m_ChunkMap->GetBlockSkyLight(a_X, a_Y, a_Z);
}
@ -1122,7 +1122,7 @@ char cWorld::GetBlockSkyLight( int a_X, int a_Y, int a_Z )
void cWorld::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, char & a_BlockType, unsigned char & a_BlockMeta)
void cWorld::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
{
m_ChunkMap->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, (BLOCKTYPE &)a_BlockType, (NIBBLETYPE &)a_BlockMeta);
}

View File

@ -214,17 +214,17 @@ public:
/// Calls the callback for each chunk in the coords specified (all cords are inclusive). Returns true if all chunks have been processed successfully
bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback);
void SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta ); //tolua_export
void FastSetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta ); //tolua_export
char GetBlock( int a_X, int a_Y, int a_Z ); //tolua_export
char GetBlock( const Vector3i & a_Pos ) { return GetBlock( a_Pos.x, a_Pos.y, a_Pos.z ); } //tolua_export
char GetBlockMeta( int a_X, int a_Y, int a_Z ); //tolua_export
char GetBlockMeta( const Vector3i & a_Pos ) { return GetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z ); } //tolua_export
void SetBlockMeta( int a_X, int a_Y, int a_Z, char a_MetaData ); //tolua_export
void SetBlockMeta( const Vector3i & a_Pos, char a_MetaData ) { SetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z, a_MetaData ); } //tolua_export
char GetBlockSkyLight( int a_X, int a_Y, int a_Z ); //tolua_export
// TODO: char GetBlockActualLight(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export
void GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, char & a_BlockType, unsigned char & a_BlockMeta); // tolua_export
void SetBlock (int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ); //tolua_export
void FastSetBlock (int a_X, int a_Y, int a_Z, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta ); //tolua_export
BLOCKTYPE GetBlock(int a_X, int a_Y, int a_Z ); //tolua_export
BLOCKTYPE GetBlock(const Vector3i & a_Pos ) { return GetBlock( a_Pos.x, a_Pos.y, a_Pos.z ); } //tolua_export
NIBBLETYPE GetBlockMeta(int a_X, int a_Y, int a_Z ); //tolua_export
NIBBLETYPE GetBlockMeta(const Vector3i & a_Pos ) { return GetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z ); } //tolua_export
void SetBlockMeta(int a_X, int a_Y, int a_Z, NIBBLETYPE a_MetaData ); //tolua_export
void SetBlockMeta(const Vector3i & a_Pos, NIBBLETYPE a_MetaData ) { SetBlockMeta( a_Pos.x, a_Pos.y, a_Pos.z, a_MetaData ); } //tolua_export
NIBBLETYPE GetBlockSkyLight( int a_X, int a_Y, int a_Z ); //tolua_export
// TODO: NIBBLETYPE GetBlockActualLight(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export
void GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta); // tolua_export
/// Spawns item pickups for each item in the list. May compress pickups if too many entities:
void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed = 1.0);

View File

@ -41,6 +41,8 @@ public:
/// Called to parse the packet. Packet type has already been read and the correct packet type created. Return the number of characters processed, PACKET_INCOMPLETE for incomplete data, PACKET_ERROR for error
virtual int Parse(const char * a_Data, int a_Size)
{
UNUSED(a_Data);
UNUSED(a_Size);
LOGERROR("Undefined Parse function for packet type 0x%x\n", m_PacketID );
ASSERT(!"Undefined Parse function");
return -1;
@ -49,6 +51,7 @@ public:
/// Called to serialize the packet into a string. Append all packet data to a_Data, including the packet type!
virtual void Serialize(AString & a_Data) const
{
UNUSED(a_Data);
LOGERROR("Undefined Serialize function for packet type 0x%x\n", m_PacketID );
ASSERT(!"Undefined Serialize function");
}