Added cCuboid:Assign() and cChunkDesc:FloorRelCuboid()

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1333 0a769ca7-a7f5-676a-18bf-c427514a06d6
master
madmaxoft@gmail.com 2013-03-31 16:22:35 +00:00
parent 387d19a5da
commit 394933fc47
6 changed files with 204 additions and 2 deletions

View File

@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 03/30/13 20:10:21.
** Generated automatically by tolua++-1.0.92 on 03/31/13 18:21:23.
*/
#ifndef __cplusplus
@ -17538,6 +17538,49 @@ tolua_lerror:
}
#endif //#ifndef TOLUA_DISABLE
/* method: Assign of class cCuboid */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cCuboid_Assign00
static int tolua_AllToLua_cCuboid_Assign00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cCuboid",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnumber(tolua_S,3,0,&tolua_err) ||
!tolua_isnumber(tolua_S,4,0,&tolua_err) ||
!tolua_isnumber(tolua_S,5,0,&tolua_err) ||
!tolua_isnumber(tolua_S,6,0,&tolua_err) ||
!tolua_isnumber(tolua_S,7,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,8,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
cCuboid* self = (cCuboid*) tolua_tousertype(tolua_S,1,0);
int a_X1 = ((int) tolua_tonumber(tolua_S,2,0));
int a_Y1 = ((int) tolua_tonumber(tolua_S,3,0));
int a_Z1 = ((int) tolua_tonumber(tolua_S,4,0));
int a_X2 = ((int) tolua_tonumber(tolua_S,5,0));
int a_Y2 = ((int) tolua_tonumber(tolua_S,6,0));
int a_Z2 = ((int) tolua_tonumber(tolua_S,7,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Assign'", NULL);
#endif
{
self->Assign(a_X1,a_Y1,a_Z1,a_X2,a_Y2,a_Z2);
}
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'Assign'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: Sort of class cCuboid */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cCuboid_Sort00
static int tolua_AllToLua_cCuboid_Sort00(lua_State* tolua_S)
@ -21788,6 +21831,85 @@ tolua_lerror:
}
#endif //#ifndef TOLUA_DISABLE
/* method: FloorRelCuboid of class cChunkDesc */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cChunkDesc_FloorRelCuboid00
static int tolua_AllToLua_cChunkDesc_FloorRelCuboid00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cChunkDesc",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnumber(tolua_S,3,0,&tolua_err) ||
!tolua_isnumber(tolua_S,4,0,&tolua_err) ||
!tolua_isnumber(tolua_S,5,0,&tolua_err) ||
!tolua_isnumber(tolua_S,6,0,&tolua_err) ||
!tolua_isnumber(tolua_S,7,0,&tolua_err) ||
!tolua_isnumber(tolua_S,8,0,&tolua_err) ||
!tolua_isnumber(tolua_S,9,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,10,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
cChunkDesc* self = (cChunkDesc*) tolua_tousertype(tolua_S,1,0);
int a_MinX = ((int) tolua_tonumber(tolua_S,2,0));
int a_MaxX = ((int) tolua_tonumber(tolua_S,3,0));
int a_MinY = ((int) tolua_tonumber(tolua_S,4,0));
int a_MaxY = ((int) tolua_tonumber(tolua_S,5,0));
int a_MinZ = ((int) tolua_tonumber(tolua_S,6,0));
int a_MaxZ = ((int) tolua_tonumber(tolua_S,7,0));
unsigned char a_DstType = (( unsigned char) tolua_tonumber(tolua_S,8,0));
unsigned char a_DstMeta = (( unsigned char) tolua_tonumber(tolua_S,9,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'FloorRelCuboid'", NULL);
#endif
{
self->FloorRelCuboid(a_MinX,a_MaxX,a_MinY,a_MaxY,a_MinZ,a_MaxZ,a_DstType,a_DstMeta);
}
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'FloorRelCuboid'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: FloorRelCuboid of class cChunkDesc */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cChunkDesc_FloorRelCuboid01
static int tolua_AllToLua_cChunkDesc_FloorRelCuboid01(lua_State* tolua_S)
{
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cChunkDesc",0,&tolua_err) ||
(tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cCuboid",0,&tolua_err)) ||
!tolua_isnumber(tolua_S,3,0,&tolua_err) ||
!tolua_isnumber(tolua_S,4,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,5,&tolua_err)
)
goto tolua_lerror;
else
{
cChunkDesc* self = (cChunkDesc*) tolua_tousertype(tolua_S,1,0);
const cCuboid* a_RelCuboid = ((const cCuboid*) tolua_tousertype(tolua_S,2,0));
unsigned char a_DstType = (( unsigned char) tolua_tonumber(tolua_S,3,0));
unsigned char a_DstMeta = (( unsigned char) tolua_tonumber(tolua_S,4,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'FloorRelCuboid'", NULL);
#endif
{
self->FloorRelCuboid(*a_RelCuboid,a_DstType,a_DstMeta);
}
}
return 0;
tolua_lerror:
return tolua_AllToLua_cChunkDesc_FloorRelCuboid00(tolua_S);
}
#endif //#ifndef TOLUA_DISABLE
/* method: new of class cCraftingGrid */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cCraftingGrid_new00
static int tolua_AllToLua_cCraftingGrid_new00(lua_State* tolua_S)
@ -23787,6 +23909,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"new",tolua_AllToLua_cCuboid_new04);
tolua_function(tolua_S,"new_local",tolua_AllToLua_cCuboid_new04_local);
tolua_function(tolua_S,".call",tolua_AllToLua_cCuboid_new04_local);
tolua_function(tolua_S,"Assign",tolua_AllToLua_cCuboid_Assign00);
tolua_function(tolua_S,"Sort",tolua_AllToLua_cCuboid_Sort00);
tolua_function(tolua_S,"DifX",tolua_AllToLua_cCuboid_DifX00);
tolua_function(tolua_S,"DifY",tolua_AllToLua_cCuboid_DifY00);
@ -23937,6 +24060,8 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"FillRelCuboid",tolua_AllToLua_cChunkDesc_FillRelCuboid01);
tolua_function(tolua_S,"ReplaceRelCuboid",tolua_AllToLua_cChunkDesc_ReplaceRelCuboid00);
tolua_function(tolua_S,"ReplaceRelCuboid",tolua_AllToLua_cChunkDesc_ReplaceRelCuboid01);
tolua_function(tolua_S,"FloorRelCuboid",tolua_AllToLua_cChunkDesc_FloorRelCuboid00);
tolua_function(tolua_S,"FloorRelCuboid",tolua_AllToLua_cChunkDesc_FloorRelCuboid01);
tolua_endmodule(tolua_S);
#ifdef __cplusplus
tolua_cclass(tolua_S,"cCraftingGrid","cCraftingGrid","",tolua_collect_cCraftingGrid);

View File

@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 03/30/13 20:10:22.
** Generated automatically by tolua++-1.0.92 on 03/31/13 18:21:24.
*/
/* Exported function */

View File

@ -24,6 +24,20 @@ static bool DoIntervalsIntersect(int a_Min1, int a_Max1, int a_Min2, int a_Max2)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cCuboid:
void cCuboid::Assign(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2)
{
p1.x = a_X1;
p1.y = a_Y1;
p1.z = a_Z1;
p2.x = a_X2;
p2.y = a_Y2;
p2.z = a_Z2;
}
void cCuboid::Sort(void)
{
if (p1.x > p2.x)

View File

@ -21,6 +21,8 @@ public:
cCuboid(int a_X1, int a_Y1, int a_Z1) : p1(a_X1, a_Y1, a_Z1), p2(a_X1, a_Y1, a_Z1) {}
cCuboid(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2) : p1(a_X1, a_Y1, a_Z1), p2(a_X2, a_Y2, a_Z2) {}
void Assign(int a_X1, int a_Y1, int a_Z1, int a_X2, int a_Y2, int a_Z2);
void Sort(void);
int DifX(void) const { return p2.x - p1.x; }

View File

@ -450,6 +450,45 @@ void cChunkDesc::ReplaceRelCuboid(
void cChunkDesc::FloorRelCuboid(
int a_MinX, int a_MaxX,
int a_MinY, int a_MaxY,
int a_MinZ, int a_MaxZ,
BLOCKTYPE a_DstType, NIBBLETYPE a_DstMeta
)
{
int MinX = std::max(a_MinX, 0);
int MinY = std::max(a_MinY, 0);
int MinZ = std::max(a_MinZ, 0);
int MaxX = std::min(a_MaxX, cChunkDef::Width - 1);
int MaxY = std::min(a_MaxY, cChunkDef::Height - 1);
int MaxZ = std::min(a_MaxZ, cChunkDef::Width - 1);
for (int y = MinY; y <= MaxY; y++)
{
for (int z = MinZ; z <= MaxZ; z++)
{
for (int x = MinX; x <= MaxX; x++)
{
switch (GetBlockType(x, y, z))
{
case E_BLOCK_AIR:
case E_BLOCK_WATER:
case E_BLOCK_STATIONARY_WATER:
{
SetBlockTypeMeta(x, y, z, a_DstType, a_DstMeta);
break;
}
} // switch (GetBlockType)
} // for x
} // for z
} // for y
}
void cChunkDesc::CompressBlockMetas(cChunkDef::BlockNibbles & a_DestMetas)
{
const NIBBLETYPE * AreaMetas = m_BlockArea.GetBlockMetas();

View File

@ -121,6 +121,28 @@ public:
);
}
/// Replaces the blocks in the cuboid by the dst blocks if they are considered non-floor (air, water); allows cuboid out of range of this chunk
void FloorRelCuboid(
int a_MinX, int a_MaxX,
int a_MinY, int a_MaxY,
int a_MinZ, int a_MaxZ,
BLOCKTYPE a_DstType, NIBBLETYPE a_DstMeta
);
/// Replaces the blocks in the cuboid by the dst blocks if they are considered non-floor (air, water); allows cuboid out of range of this chunk
void FloorRelCuboid(
const cCuboid & a_RelCuboid,
BLOCKTYPE a_DstType, NIBBLETYPE a_DstMeta
)
{
FloorRelCuboid(
a_RelCuboid.p1.x, a_RelCuboid.p2.x,
a_RelCuboid.p1.y, a_RelCuboid.p2.y,
a_RelCuboid.p1.z, a_RelCuboid.p2.z,
a_DstType, a_DstMeta
);
}
// tolua_end