1
0

Merge branch 'master' into warnings

This commit is contained in:
Tycho 2014-03-08 07:13:45 -08:00
commit c3758112cc
10 changed files with 108 additions and 25 deletions

View File

@ -162,7 +162,7 @@ g_APIDesc =
RotateCW = { Params = "", Return = "", Notes = "Rotates the block area around the Y axis, clockwise (north -> east). Modifies blocks' metas (if present) to match." }, RotateCW = { Params = "", Return = "", Notes = "Rotates the block area around the Y axis, clockwise (north -> east). Modifies blocks' metas (if present) to match." },
RotateCWNoMeta = { Params = "", Return = "", Notes = "Rotates the block area around the Y axis, clockwise (north -> east). Doesn't modify blocks' metas." }, RotateCWNoMeta = { Params = "", Return = "", Notes = "Rotates the block area around the Y axis, clockwise (north -> east). Doesn't modify blocks' metas." },
SaveToSchematicFile = { Params = "FileName", Return = "", Notes = "Saves the current contents to a schematic file. Returns true if successful." }, SaveToSchematicFile = { Params = "FileName", Return = "", Notes = "Saves the current contents to a schematic file. Returns true if successful." },
SaveToSchematicString = { Params = "", Return = "string", Notes = "Saves the current contents to a string (in a .schematic file format). Returns the data if successful, empty string if failed." }, SaveToSchematicString = { Params = "", Return = "string", Notes = "Saves the current contents to a string (in a .schematic file format). Returns the data if successful, nil if failed." },
SetBlockLight = { Params = "BlockX, BlockY, BlockZ, BlockLight", Return = "", Notes = "Sets the blocklight at the specified absolute coords" }, SetBlockLight = { Params = "BlockX, BlockY, BlockZ, BlockLight", Return = "", Notes = "Sets the blocklight at the specified absolute coords" },
SetBlockMeta = { Params = "BlockX, BlockY, BlockZ, BlockMeta", Return = "", Notes = "Sets the block meta at the specified absolute coords" }, SetBlockMeta = { Params = "BlockX, BlockY, BlockZ, BlockMeta", Return = "", Notes = "Sets the block meta at the specified absolute coords" },
SetBlockSkyLight = { Params = "BlockX, BlockY, BlockZ, SkyLight", Return = "", Notes = "Sets the skylight at the specified absolute coords" }, SetBlockSkyLight = { Params = "BlockX, BlockY, BlockZ, SkyLight", Return = "", Notes = "Sets the skylight at the specified absolute coords" },

View File

@ -2563,9 +2563,13 @@ static int tolua_cBlockArea_SaveToSchematicString(lua_State * tolua_S)
return 0; return 0;
} }
AString Data = cSchematicFileSerializer::SaveToSchematicString(*self); AString Data;
L.Push(Data); if (cSchematicFileSerializer::SaveToSchematicString(*self, Data))
return 1; {
L.Push(Data);
return 1;
}
return 0;
} }

View File

@ -271,6 +271,11 @@ void cBlockInfo::Initialize(void)
ms_Info[E_BLOCK_VINES ].m_IsSnowable = false; ms_Info[E_BLOCK_VINES ].m_IsSnowable = false;
ms_Info[E_BLOCK_WALLSIGN ].m_IsSnowable = false; ms_Info[E_BLOCK_WALLSIGN ].m_IsSnowable = false;
ms_Info[E_BLOCK_WATER ].m_IsSnowable = false; ms_Info[E_BLOCK_WATER ].m_IsSnowable = false;
ms_Info[E_BLOCK_RAIL ].m_IsSnowable = false;
ms_Info[E_BLOCK_ACTIVATOR_RAIL ].m_IsSnowable = false;
ms_Info[E_BLOCK_POWERED_RAIL ].m_IsSnowable = false;
ms_Info[E_BLOCK_DETECTOR_RAIL ].m_IsSnowable = false;
ms_Info[E_BLOCK_COBWEB ].m_IsSnowable = false;
// Blocks that don't drop without a special tool: // Blocks that don't drop without a special tool:
@ -309,6 +314,10 @@ void cBlockInfo::Initialize(void)
ms_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_RequiresSpecialTool = true; ms_Info[E_BLOCK_STONE_PRESSURE_PLATE].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_STONE_SLAB ].m_RequiresSpecialTool = true; ms_Info[E_BLOCK_STONE_SLAB ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_VINES ].m_RequiresSpecialTool = true; ms_Info[E_BLOCK_VINES ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_FURNACE ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_LIT_FURNACE ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_ANVIL ].m_RequiresSpecialTool = true;
ms_Info[E_BLOCK_ENCHANTMENT_TABLE ].m_RequiresSpecialTool = true;
// Nonsolid blocks: // Nonsolid blocks:

View File

@ -146,6 +146,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_NETHER_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType); case E_BLOCK_NETHER_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType);
case E_BLOCK_NETHER_PORTAL: return new cBlockPortalHandler (a_BlockType); case E_BLOCK_NETHER_PORTAL: return new cBlockPortalHandler (a_BlockType);
case E_BLOCK_NETHER_WART: return new cBlockNetherWartHandler (a_BlockType); case E_BLOCK_NETHER_WART: return new cBlockNetherWartHandler (a_BlockType);
case E_BLOCK_NETHER_QUARTZ_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_NEW_LEAVES: return new cBlockNewLeavesHandler (a_BlockType); case E_BLOCK_NEW_LEAVES: return new cBlockNewLeavesHandler (a_BlockType);
case E_BLOCK_NEW_LOG: return new cBlockSidewaysHandler (a_BlockType); case E_BLOCK_NEW_LOG: return new cBlockSidewaysHandler (a_BlockType);
case E_BLOCK_NOTE_BLOCK: return new cBlockNoteHandler (a_BlockType); case E_BLOCK_NOTE_BLOCK: return new cBlockNoteHandler (a_BlockType);

View File

@ -19,17 +19,13 @@ public:
{ {
switch(m_ItemType) switch(m_ItemType)
{ {
case E_ITEM_WOODEN_PICKAXE: case E_ITEM_WOODEN_PICKAXE: return 1;
case E_ITEM_GOLD_PICKAXE: case E_ITEM_GOLD_PICKAXE: return 1;
return 1; case E_ITEM_STONE_PICKAXE: return 2;
case E_ITEM_STONE_PICKAXE: case E_ITEM_IRON_PICKAXE: return 3;
return 2; case E_ITEM_DIAMOND_PICKAXE: return 4;
case E_ITEM_IRON_PICKAXE:
return 3; default: return 0;
case E_ITEM_DIAMOND_PICKAXE:
return 4;
default:
return 0;
} }
} }
@ -61,6 +57,10 @@ public:
return PickaxeLevel() >= 2; return PickaxeLevel() >= 2;
} }
case E_BLOCK_ANVIL:
case E_BLOCK_ENCHANTMENT_TABLE:
case E_BLOCK_FURNACE:
case E_BLOCK_LIT_FURNACE:
case E_BLOCK_COAL_ORE: case E_BLOCK_COAL_ORE:
case E_BLOCK_STONE: case E_BLOCK_STONE:
case E_BLOCK_COBBLESTONE: case E_BLOCK_COBBLESTONE:

View File

@ -54,14 +54,23 @@ void cFloodyFluidSimulator::SimulateBlock(cChunk * a_Chunk, int a_RelX, int a_Re
a_Chunk->GetMeta(a_RelX, a_RelY, a_RelZ) a_Chunk->GetMeta(a_RelX, a_RelY, a_RelZ)
); );
NIBBLETYPE MyMeta = a_Chunk->GetMeta(a_RelX, a_RelY, a_RelZ); BLOCKTYPE MyBlock; NIBBLETYPE MyMeta;
if (!IsAnyFluidBlock(a_Chunk->GetBlock(a_RelX, a_RelY, a_RelZ))) a_Chunk->GetBlockTypeMeta(a_RelX, a_RelY, a_RelZ, MyBlock, MyMeta);
if (!IsAnyFluidBlock(MyBlock))
{ {
// Can happen - if a block is scheduled for simulating and gets replaced in the meantime. // Can happen - if a block is scheduled for simulating and gets replaced in the meantime.
FLOG(" BadBlockType exit"); FLOG(" BadBlockType exit");
return; return;
} }
// When in contact with water, lava should harden
if (HardenBlock(a_Chunk, a_RelX, a_RelY, a_RelZ, MyBlock, MyMeta))
{
// Block was changed, bail out
return;
}
if (MyMeta != 0) if (MyMeta != 0)
{ {
// Source blocks aren't checked for tributaries, others are. // Source blocks aren't checked for tributaries, others are.
@ -309,6 +318,8 @@ void cFloodyFluidSimulator::SpreadToNeighbor(cChunk * a_NearChunk, int a_RelX, i
a_NewMeta a_NewMeta
); );
a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, m_FluidBlock, a_NewMeta); a_NearChunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, m_FluidBlock, a_NewMeta);
HardenBlock(a_NearChunk, a_RelX, a_RelY, a_RelZ, m_FluidBlock, a_NewMeta);
} }
@ -361,3 +372,56 @@ bool cFloodyFluidSimulator::CheckNeighborsForSource(cChunk * a_Chunk, int a_RelX
bool cFloodyFluidSimulator::HardenBlock(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta)
{
// Only lava blocks can harden
if (!IsBlockLava(a_BlockType))
{
return false;
}
bool ShouldHarden = false;
BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta;
static const Vector3i Coords[] =
{
Vector3i( 1, 0, 0),
Vector3i(-1, 0, 0),
Vector3i( 0, 0, 1),
Vector3i( 0, 0, -1),
};
for (size_t i = 0; i < ARRAYCOUNT(Coords); i++)
{
if (!a_Chunk->UnboundedRelGetBlock(a_RelX + Coords[i].x, a_RelY, a_RelZ + Coords[i].z, BlockType, BlockMeta))
{
continue;
}
if (IsBlockWater(BlockType))
{
ShouldHarden = true;
}
} // for i - Coords[]
if (ShouldHarden)
{
if (a_Meta == 0)
{
// Source lava block
a_Chunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_OBSIDIAN, 0);
return true;
}
// Ignore last lava level
else if (a_Meta <= 4)
{
a_Chunk->UnboundedRelSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_COBBLESTONE, 0);
return true;
}
}
return false;
}

View File

@ -47,6 +47,12 @@ protected:
/** Checks if there are enough neighbors to create a source at the coords specified; turns into source and returns true if so. */ /** Checks if there are enough neighbors to create a source at the coords specified; turns into source and returns true if so. */
bool CheckNeighborsForSource(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ); bool CheckNeighborsForSource(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ);
/** Checks if the specified block should harden (Water/Lava interaction) and if so, converts it to a suitable block.
*
* Returns whether the block was changed or not.
*/
bool HardenBlock(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta);
/** Spread water to neighbors. /** Spread water to neighbors.
* *
* May be overridden to provide more sophisticated algorithms. * May be overridden to provide more sophisticated algorithms.

View File

@ -86,7 +86,7 @@ int cVanillaFluidSimulator::CalculateFlowCost(cChunk * a_Chunk, int a_RelX, int
{ {
return Cost; return Cost;
} }
if (!IsPassableForFluid(BlockType)) if (!IsPassableForFluid(BlockType) && !IsBlockLiquid(BlockType))
{ {
return Cost; return Cost;
} }
@ -96,7 +96,7 @@ int cVanillaFluidSimulator::CalculateFlowCost(cChunk * a_Chunk, int a_RelX, int
{ {
return Cost; return Cost;
} }
if (IsPassableForFluid(BlockType)) if (IsPassableForFluid(BlockType) || IsBlockLiquid(BlockType))
{ {
// Path found, exit // Path found, exit
return a_Iteration; return a_Iteration;

View File

@ -103,7 +103,7 @@ bool cSchematicFileSerializer::SaveToSchematicFile(const cBlockArea & a_BlockAre
AString cSchematicFileSerializer::SaveToSchematicString(const cBlockArea & a_BlockArea) bool cSchematicFileSerializer::SaveToSchematicString(const cBlockArea & a_BlockArea, AString & a_Out)
{ {
// Serialize into NBT data: // Serialize into NBT data:
AString NBT = SaveToSchematicNBT(a_BlockArea); AString NBT = SaveToSchematicNBT(a_BlockArea);
@ -114,14 +114,13 @@ AString cSchematicFileSerializer::SaveToSchematicString(const cBlockArea & a_Blo
} }
// Gzip the data: // Gzip the data:
AString Compressed; int res = CompressStringGZIP(NBT.data(), NBT.size(), a_Out);
int res = CompressStringGZIP(NBT.data(), NBT.size(), Compressed);
if (res != Z_OK) if (res != Z_OK)
{ {
LOG("%s: Cannot Gzip the area data NBT representation: %d", __FUNCTION__, res); LOG("%s: Cannot Gzip the area data NBT representation: %d", __FUNCTION__, res);
return false; return false;
} }
return Compressed; return true;
} }

View File

@ -36,8 +36,8 @@ public:
static bool SaveToSchematicFile(const cBlockArea & a_BlockArea, const AString & a_FileName); static bool SaveToSchematicFile(const cBlockArea & a_BlockArea, const AString & a_FileName);
/** Saves the area into a string containing the .schematic file data. /** Saves the area into a string containing the .schematic file data.
Returns the data, or empty string if failed. */ Returns true if successful, false on failure. The data is stored into a_Out. */
static AString SaveToSchematicString(const cBlockArea & a_BlockArea); static bool SaveToSchematicString(const cBlockArea & a_BlockArea, AString & a_Out);
private: private:
/** Loads the area from a schematic file uncompressed and parsed into a NBT tree. /** Loads the area from a schematic file uncompressed and parsed into a NBT tree.