BlockArea writing support (BlockTypes with BlockMeta only)
git-svn-id: http://mc-server.googlecode.com/svn/trunk@933 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "Pickup.h"
|
||||
#include "Chunk.h"
|
||||
#include "Generating/Trees.h" // used in cChunkMap::ReplaceTreeBlocks() for tree block discrimination
|
||||
#include "BlockArea.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <cstdlib> // abs
|
||||
@@ -1493,6 +1494,44 @@ bool cChunkMap::ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinCh
|
||||
|
||||
|
||||
|
||||
bool cChunkMap::WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes)
|
||||
{
|
||||
// Convert block coords to chunks coords:
|
||||
int MinChunkX, MaxChunkX;
|
||||
int MinChunkZ, MaxChunkZ;
|
||||
int MinBlockX = a_MinBlockX;
|
||||
int MinBlockY = a_MinBlockY;
|
||||
int MinBlockZ = a_MinBlockZ;
|
||||
int MaxBlockX = a_MinBlockX + a_Area.GetSizeX();
|
||||
int MaxBlockY = a_MinBlockY + a_Area.GetSizeY();
|
||||
int MaxBlockZ = a_MinBlockZ + a_Area.GetSizeZ();
|
||||
cChunkDef::AbsoluteToRelative(MinBlockX, MinBlockY, MinBlockZ, MinChunkX, MinChunkZ);
|
||||
cChunkDef::AbsoluteToRelative(MaxBlockX, MaxBlockY, MaxBlockZ, MaxChunkX, MaxChunkZ);
|
||||
|
||||
// Iterate over chunks, write data into each:
|
||||
bool Result = true;
|
||||
cCSLock Lock(m_CSLayers);
|
||||
for (int z = MinChunkZ; z <= MaxChunkZ; z++)
|
||||
{
|
||||
for (int x = MinChunkX; x <= MaxChunkX; x++)
|
||||
{
|
||||
cChunkPtr Chunk = GetChunkNoLoad(x, ZERO_CHUNK_Y, z);
|
||||
if ((Chunk == NULL) || (!Chunk->IsValid()))
|
||||
{
|
||||
// Not present / not valid
|
||||
Result = false;
|
||||
continue;
|
||||
}
|
||||
Chunk->WriteBlockArea(a_Area, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_DataTypes);
|
||||
} // for x
|
||||
} // for z
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cChunkMap::GetChunkStats(int & a_NumChunksValid, int & a_NumChunksDirty)
|
||||
{
|
||||
a_NumChunksValid = 0;
|
||||
|
||||
Reference in New Issue
Block a user