1
0

Configurable classic composition generator

git-svn-id: http://mc-server.googlecode.com/svn/trunk@575 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
cedeel@gmail.com 2012-06-08 01:56:44 +00:00
parent 52efb5db20
commit 2295c1d7cb
9 changed files with 47 additions and 61 deletions

View File

@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 06/07/12 23:02:08.
** Generated automatically by tolua++-1.0.92 on Fri Jun 8 03:43:28 2012.
*/
#ifndef __cplusplus
@ -13,8 +13,8 @@
/* Exported function */
TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S);
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "tolua_base.h"
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "tolua_base.h"
#include "cTorch.h"
#include "cStairs.h"
#include "cStep.h"

View File

@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 06/07/12 23:02:09.
** Generated automatically by tolua++-1.0.92 on Fri Jun 8 03:43:28 2012.
*/
/* Exported function */

View File

@ -119,10 +119,18 @@ void cCompoGenDebugBiomes::ComposeTerrain(
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cCompoGenClassic:
cCompoGenClassic::cCompoGenClassic(int a_SeaLevel, int a_BeachHeight, int a_BeachDepth) :
cCompoGenClassic::cCompoGenClassic(int a_SeaLevel, int a_BeachHeight, int a_BeachDepth,
BLOCKTYPE a_BlockTop, BLOCKTYPE a_BlockMiddle, BLOCKTYPE a_BlockBottom,
BLOCKTYPE a_BlockBeach, BLOCKTYPE a_BlockBeachBottom, BLOCKTYPE a_BlockSea) :
m_SeaLevel(a_SeaLevel),
m_BeachHeight(a_BeachHeight),
m_BeachDepth(a_BeachDepth)
m_BeachDepth(a_BeachDepth),
m_BlockTop(a_BlockTop),
m_BlockMiddle(a_BlockMiddle),
m_BlockBottom(a_BlockBottom),
m_BlockBeach(a_BlockBeach),
m_BlockBeachBottom(a_BlockBeachBottom),
m_BlockSea(a_BlockSea)
{
}
@ -152,9 +160,9 @@ void cCompoGenClassic::ComposeTerrain(
memset(a_BlockMeta, 0, sizeof(a_BlockMeta));
// The patterns to use for different situations, must be same length!
static const BLOCKTYPE PatternGround[] = {E_BLOCK_GRASS, E_BLOCK_DIRT, E_BLOCK_DIRT, E_BLOCK_DIRT} ;
static const BLOCKTYPE PatternBeach[] = {E_BLOCK_SAND, E_BLOCK_SAND, E_BLOCK_SAND, E_BLOCK_SANDSTONE} ;
static const BLOCKTYPE PatternOcean[] = {E_BLOCK_DIRT, E_BLOCK_DIRT, E_BLOCK_DIRT, E_BLOCK_STONE} ;
static const BLOCKTYPE PatternGround[] = {m_BlockTop, m_BlockMiddle, m_BlockMiddle, m_BlockMiddle} ;
static const BLOCKTYPE PatternBeach[] = {m_BlockBeach, m_BlockBeach, m_BlockBeach, m_BlockBeachBottom} ;
static const BLOCKTYPE PatternOcean[] = {m_BlockMiddle, m_BlockMiddle, m_BlockMiddle, m_BlockBottom} ;
static int PatternLength = ARRAYCOUNT(PatternGround);
ASSERT(ARRAYCOUNT(PatternGround) == ARRAYCOUNT(PatternBeach));
ASSERT(ARRAYCOUNT(PatternGround) == ARRAYCOUNT(PatternOcean));
@ -181,13 +189,13 @@ void cCompoGenClassic::ComposeTerrain(
// Fill water from sealevel down to height (if any):
for (int y = m_SeaLevel; y >= Height; --y)
{
cChunkDef::SetBlock(a_BlockTypes, x, y, z, E_BLOCK_STATIONARY_WATER);
cChunkDef::SetBlock(a_BlockTypes, x, y, z, m_BlockSea);
}
// Fill from height till the bottom:
for (int y = Height; y >= 1; y--)
{
cChunkDef::SetBlock(a_BlockTypes, x, y, z, (Height - y < PatternLength) ? Pattern[Height - y] : E_BLOCK_STONE);
cChunkDef::SetBlock(a_BlockTypes, x, y, z, (Height - y < PatternLength) ? Pattern[Height - y] : m_BlockBottom);
}
// The last layer is always bedrock:

View File

@ -79,13 +79,21 @@ class cCompoGenClassic :
public cTerrainCompositionGen
{
public:
cCompoGenClassic(int a_SeaLevel, int a_BeachHeight, int a_BeachDepth);
cCompoGenClassic(int a_SeaLevel, int a_BeachHeight, int a_BeachDepth,
BLOCKTYPE a_BlockTop, BLOCKTYPE a_BlockMiddle, BLOCKTYPE a_BlockBottom,
BLOCKTYPE a_BlockBeach, BLOCKTYPE a_BlockBeachBottom, BLOCKTYPE a_BlockSea);
protected:
int m_SeaLevel;
int m_BeachHeight;
int m_BeachDepth;
BLOCKTYPE m_BlockTop;
BLOCKTYPE m_BlockMiddle;
BLOCKTYPE m_BlockBottom;
BLOCKTYPE m_BlockBeach;
BLOCKTYPE m_BlockBeachBottom;
BLOCKTYPE m_BlockSea;
// cTerrainCompositionGen overrides:
virtual void ComposeTerrain(

View File

@ -106,24 +106,6 @@ void cChestEntity::SetSlot( int a_Slot, cItem & a_Item )
return false; \
}
bool cChestEntity::LoadFromFile(cFile & f)
{
READ(f, m_PosX);
READ(f, m_PosY);
READ(f, m_PosZ);
unsigned int NumSlots = 0;
READ(f, NumSlots);
for(unsigned int i = 0; i < NumSlots; i++)
{
cItem Item;
READ(f, Item.m_ItemID);
READ(f, Item.m_ItemCount);
READ(f, Item.m_ItemHealth);
SetSlot( i, Item );
}
return true;
}

View File

@ -37,8 +37,6 @@ public:
const cItem * GetSlot( int a_Slot ) const;
void SetSlot( int a_Slot, cItem & a_Item );
OBSOLETE bool LoadFromFile(cFile & a_File); // deprecated format
bool LoadFromJson( const Json::Value& a_Value );
virtual void SaveToJson(Json::Value& a_Value ) override;

View File

@ -224,6 +224,17 @@ void cChunkGenerator::InitHeightGen(cIniFile & a_IniFile)
BLOCKTYPE ResolveBlock(AString BlockType, BLOCKTYPE DefaultBlock)
{
int Block = BlockStringToType(BlockType);
if(Block < 0)
{
LOGWARN("[Generator] Could not parse block value \"%s\". Using default.", BlockType.c_str());
return DefaultBlock;
}
return (BLOCKTYPE) Block;
}
void cChunkGenerator::InitCompositionGen(cIniFile & a_IniFile)
@ -260,7 +271,14 @@ void cChunkGenerator::InitCompositionGen(cIniFile & a_IniFile)
int SeaLevel = a_IniFile.GetValueI("Generator", "ClassicSeaLevel", 60);
int BeachHeight = a_IniFile.GetValueI("Generator", "ClassicBeachHeight", 2);
int BeachDepth = a_IniFile.GetValueI("Generator", "ClassicBeachDepth", 4);
m_CompositionGen = new cCompoGenClassic(SeaLevel, BeachHeight, BeachDepth);
BLOCKTYPE BlockTop = ResolveBlock(a_IniFile.GetValue("Generator", "ClassicBlockTop", "grass"), E_BLOCK_GRASS);
BLOCKTYPE BlockMiddle = ResolveBlock(a_IniFile.GetValue("Generator", "ClassicBlockMiddle", "dirt"), E_BLOCK_DIRT);
BLOCKTYPE BlockBottom = ResolveBlock(a_IniFile.GetValue("Generator", "ClassicBlockBottom", "stone"), E_BLOCK_STONE);
BLOCKTYPE BlockBeach = ResolveBlock(a_IniFile.GetValue("Generator", "ClassicBlockBeach", "sand"), E_BLOCK_SAND);
BLOCKTYPE BlockBeachBottom = ResolveBlock(a_IniFile.GetValue("Generator", "ClassicBlockBeachBottom", "sandstone"), E_BLOCK_SANDSTONE);
BLOCKTYPE BlockSea = ResolveBlock(a_IniFile.GetValue("Generator", "ClassicBlockSea", "9"), E_BLOCK_STATIONARY_WATER);
m_CompositionGen = new cCompoGenClassic(SeaLevel, BeachHeight, BeachDepth, BlockTop, BlockMiddle, BlockBottom, BlockBeach,
BlockBeachBottom, BlockSea);
}
else
{

View File

@ -104,32 +104,6 @@ cPacket * cSignEntity::GetPacket(void)
return false; \
}
bool cSignEntity::LoadFromFile(cFile & f)
{
READ(f, m_PosX);
READ(f, m_PosY);
READ(f, m_PosZ);
for( int i = 0; i < 4; i++ )
{
short Size = 0;
READ(f, Size);
if (Size > 0)
{
char * c_Str = new char[Size];
if (f.Read(c_Str, Size) != Size )
{
LOGERROR("ERROR READING SIGN FROM FILE");
delete [] c_Str;
return false;
}
m_Line[i].assign( c_Str, Size );
delete [] c_Str;
}
}
return true;
}

View File

@ -23,8 +23,6 @@ public:
cSignEntity(ENUM_BLOCK_ID a_BlockType, int a_X, int a_Y, int a_Z, cWorld * a_World);
virtual ~cSignEntity();
OBSOLETE bool LoadFromFile(cFile & a_File); // deprecated format
bool LoadFromJson( const Json::Value& a_Value );
virtual void SaveToJson(Json::Value& a_Value ) override;