From ad10b8718fe337fb2dab8d0315cb6ba338479e75 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sat, 30 Mar 2013 21:03:56 +0000 Subject: [PATCH] ChunkDesc: Extended the interface, RelCuboid functions now take either a cCuboid or a set of 6 coords. git-svn-id: http://mc-server.googlecode.com/svn/trunk@1330 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/Bindings.cpp | 116 ++++++++++++++++++++++++++++---- source/Bindings.h | 2 +- source/Generating/ChunkDesc.cpp | 39 +++++++---- source/Generating/ChunkDesc.h | 48 +++++++++++-- 4 files changed, 171 insertions(+), 34 deletions(-) diff --git a/source/Bindings.cpp b/source/Bindings.cpp index ed5c1580..10188441 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/29/13 21:47:35. +** Generated automatically by tolua++-1.0.92 on 03/30/13 20:10:21. */ #ifndef __cplusplus @@ -21627,6 +21627,52 @@ static int tolua_AllToLua_cChunkDesc_GetMaxHeight00(lua_State* tolua_S) static int tolua_AllToLua_cChunkDesc_FillRelCuboid00(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_BlockType = (( unsigned char) tolua_tonumber(tolua_S,8,0)); + unsigned char a_BlockMeta = (( unsigned char) tolua_tonumber(tolua_S,9,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'FillRelCuboid'", NULL); +#endif + { + self->FillRelCuboid(a_MinX,a_MaxX,a_MinY,a_MaxY,a_MinZ,a_MaxZ,a_BlockType,a_BlockMeta); + } + } + return 0; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'FillRelCuboid'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: FillRelCuboid of class cChunkDesc */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cChunkDesc_FillRelCuboid01 +static int tolua_AllToLua_cChunkDesc_FillRelCuboid01(lua_State* tolua_S) +{ tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cChunkDesc",0,&tolua_err) || @@ -21637,7 +21683,6 @@ static int tolua_AllToLua_cChunkDesc_FillRelCuboid00(lua_State* tolua_S) ) goto tolua_lerror; else -#endif { cChunkDesc* self = (cChunkDesc*) tolua_tousertype(tolua_S,1,0); const cCuboid* a_RelCuboid = ((const cCuboid*) tolua_tousertype(tolua_S,2,0)); @@ -21651,11 +21696,8 @@ static int tolua_AllToLua_cChunkDesc_FillRelCuboid00(lua_State* tolua_S) } } return 0; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'FillRelCuboid'.",&tolua_err); - return 0; -#endif +tolua_lerror: + return tolua_AllToLua_cChunkDesc_FillRelCuboid00(tolua_S); } #endif //#ifndef TOLUA_DISABLE @@ -21664,6 +21706,56 @@ static int tolua_AllToLua_cChunkDesc_FillRelCuboid00(lua_State* tolua_S) static int tolua_AllToLua_cChunkDesc_ReplaceRelCuboid00(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_isnumber(tolua_S,10,0,&tolua_err) || + !tolua_isnumber(tolua_S,11,0,&tolua_err) || + !tolua_isnoobj(tolua_S,12,&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_SrcType = (( unsigned char) tolua_tonumber(tolua_S,8,0)); + unsigned char a_SrcMeta = (( unsigned char) tolua_tonumber(tolua_S,9,0)); + unsigned char a_DstType = (( unsigned char) tolua_tonumber(tolua_S,10,0)); + unsigned char a_DstMeta = (( unsigned char) tolua_tonumber(tolua_S,11,0)); +#ifndef TOLUA_RELEASE + if (!self) tolua_error(tolua_S,"invalid 'self' in function 'ReplaceRelCuboid'", NULL); +#endif + { + self->ReplaceRelCuboid(a_MinX,a_MaxX,a_MinY,a_MaxY,a_MinZ,a_MaxZ,a_SrcType,a_SrcMeta,a_DstType,a_DstMeta); + } + } + return 0; +#ifndef TOLUA_RELEASE + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'ReplaceRelCuboid'.",&tolua_err); + return 0; +#endif +} +#endif //#ifndef TOLUA_DISABLE + +/* method: ReplaceRelCuboid of class cChunkDesc */ +#ifndef TOLUA_DISABLE_tolua_AllToLua_cChunkDesc_ReplaceRelCuboid01 +static int tolua_AllToLua_cChunkDesc_ReplaceRelCuboid01(lua_State* tolua_S) +{ tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"cChunkDesc",0,&tolua_err) || @@ -21676,7 +21768,6 @@ static int tolua_AllToLua_cChunkDesc_ReplaceRelCuboid00(lua_State* tolua_S) ) goto tolua_lerror; else -#endif { cChunkDesc* self = (cChunkDesc*) tolua_tousertype(tolua_S,1,0); const cCuboid* a_RelCuboid = ((const cCuboid*) tolua_tousertype(tolua_S,2,0)); @@ -21692,11 +21783,8 @@ static int tolua_AllToLua_cChunkDesc_ReplaceRelCuboid00(lua_State* tolua_S) } } return 0; -#ifndef TOLUA_RELEASE - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'ReplaceRelCuboid'.",&tolua_err); - return 0; -#endif +tolua_lerror: + return tolua_AllToLua_cChunkDesc_ReplaceRelCuboid00(tolua_S); } #endif //#ifndef TOLUA_DISABLE @@ -23846,7 +23934,9 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S) tolua_function(tolua_S,"ReadBlockArea",tolua_AllToLua_cChunkDesc_ReadBlockArea00); tolua_function(tolua_S,"GetMaxHeight",tolua_AllToLua_cChunkDesc_GetMaxHeight00); tolua_function(tolua_S,"FillRelCuboid",tolua_AllToLua_cChunkDesc_FillRelCuboid00); + 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_endmodule(tolua_S); #ifdef __cplusplus tolua_cclass(tolua_S,"cCraftingGrid","cCraftingGrid","",tolua_collect_cCraftingGrid); diff --git a/source/Bindings.h b/source/Bindings.h index 1f8d02ca..34826441 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/29/13 21:47:36. +** Generated automatically by tolua++-1.0.92 on 03/30/13 20:10:22. */ /* Exported function */ diff --git a/source/Generating/ChunkDesc.cpp b/source/Generating/ChunkDesc.cpp index 4a1272ff..bd1abdea 100644 --- a/source/Generating/ChunkDesc.cpp +++ b/source/Generating/ChunkDesc.cpp @@ -383,14 +383,19 @@ HEIGHTTYPE cChunkDesc::GetMaxHeight(void) const -void cChunkDesc::FillRelCuboid(const cCuboid & a_RelCuboid, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) +void cChunkDesc::FillRelCuboid( + int a_MinX, int a_MaxX, + int a_MinY, int a_MaxY, + int a_MinZ, int a_MaxZ, + BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta +) { - int MinX = std::max(a_RelCuboid.p1.x, 0); - int MinY = std::max(a_RelCuboid.p1.y, 0); - int MinZ = std::max(a_RelCuboid.p1.z, 0); - int MaxX = std::min(a_RelCuboid.p2.x, cChunkDef::Width - 1); - int MaxY = std::min(a_RelCuboid.p2.y, cChunkDef::Height - 1); - int MaxZ = std::min(a_RelCuboid.p2.z, cChunkDef::Width - 1); + 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++) { @@ -408,14 +413,20 @@ void cChunkDesc::FillRelCuboid(const cCuboid & a_RelCuboid, BLOCKTYPE a_BlockTyp -void cChunkDesc::ReplaceRelCuboid(const cCuboid & a_RelCuboid, BLOCKTYPE a_SrcType, NIBBLETYPE a_SrcMeta, BLOCKTYPE a_DstType, NIBBLETYPE a_DstMeta) +void cChunkDesc::ReplaceRelCuboid( + int a_MinX, int a_MaxX, + int a_MinY, int a_MaxY, + int a_MinZ, int a_MaxZ, + BLOCKTYPE a_SrcType, NIBBLETYPE a_SrcMeta, + BLOCKTYPE a_DstType, NIBBLETYPE a_DstMeta +) { - int MinX = std::max(a_RelCuboid.p1.x, 0); - int MinY = std::max(a_RelCuboid.p1.y, 0); - int MinZ = std::max(a_RelCuboid.p1.z, 0); - int MaxX = std::min(a_RelCuboid.p2.x, cChunkDef::Width - 1); - int MaxY = std::min(a_RelCuboid.p2.y, cChunkDef::Height - 1); - int MaxZ = std::min(a_RelCuboid.p2.z, cChunkDef::Width - 1); + 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++) { diff --git a/source/Generating/ChunkDesc.h b/source/Generating/ChunkDesc.h index d4b0c4d9..a73a175a 100644 --- a/source/Generating/ChunkDesc.h +++ b/source/Generating/ChunkDesc.h @@ -9,8 +9,9 @@ #pragma once -#include "../ChunkDef.h" #include "../BlockArea.h" +#include "../ChunkDef.h" +#include "../Cuboid.h" @@ -19,9 +20,6 @@ // fwd: ../BlockArea.h class cBlockArea; -// fwd: ../Cuboid.h -class cCuboid; - @@ -80,11 +78,49 @@ public: HEIGHTTYPE GetMaxHeight(void) const; /// Fills the relative cuboid with specified block; allows cuboid out of range of this chunk - void FillRelCuboid(const cCuboid & a_RelCuboid, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); + void FillRelCuboid( + int a_MinX, int a_MaxX, + int a_MinY, int a_MaxY, + int a_MinZ, int a_MaxZ, + BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta + ); + + /// Fills the relative cuboid with specified block; allows cuboid out of range of this chunk + void FillRelCuboid(const cCuboid & a_RelCuboid, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) + { + FillRelCuboid( + 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_BlockType, a_BlockMeta + ); + } /// Replaces the specified src blocks in the cuboid by the dst blocks; allows cuboid out of range of this chunk - void ReplaceRelCuboid(const cCuboid & a_RelCuboid, BLOCKTYPE a_SrcType, NIBBLETYPE a_SrcMeta, BLOCKTYPE a_DstType, NIBBLETYPE a_DstMeta); + void ReplaceRelCuboid( + int a_MinX, int a_MaxX, + int a_MinY, int a_MaxY, + int a_MinZ, int a_MaxZ, + BLOCKTYPE a_SrcType, NIBBLETYPE a_SrcMeta, + BLOCKTYPE a_DstType, NIBBLETYPE a_DstMeta + ); + /// Replaces the specified src blocks in the cuboid by the dst blocks; allows cuboid out of range of this chunk + void ReplaceRelCuboid( + const cCuboid & a_RelCuboid, + BLOCKTYPE a_SrcType, NIBBLETYPE a_SrcMeta, + BLOCKTYPE a_DstType, NIBBLETYPE a_DstMeta + ) + { + ReplaceRelCuboid( + 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_SrcType, a_SrcMeta, + a_DstType, a_DstMeta + ); + } + // tolua_end