本文整理汇总了C++中cBlockArea类的典型用法代码示例。如果您正苦于以下问题:C++ cBlockArea类的具体用法?C++ cBlockArea怎么用?C++ cBlockArea使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了cBlockArea类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: LOGWARNING
void cBlockArea::CopyTo(cBlockArea & a_Into) const
{
if (&a_Into == this)
{
LOGWARNING("Trying to copy a cBlockArea into self, ignoring.");
return;
}
a_Into.Clear();
a_Into.SetSize(m_Size.x, m_Size.y, m_Size.z, GetDataTypes());
a_Into.m_Origin = m_Origin;
size_t BlockCount = GetBlockCount();
if (HasBlockTypes())
{
memcpy(a_Into.m_BlockTypes, m_BlockTypes, BlockCount * sizeof(BLOCKTYPE));
}
if (HasBlockMetas())
{
memcpy(a_Into.m_BlockMetas, m_BlockMetas, BlockCount * sizeof(NIBBLETYPE));
}
if (HasBlockLights())
{
memcpy(a_Into.m_BlockLight, m_BlockLight, BlockCount * sizeof(NIBBLETYPE));
}
if (HasBlockSkyLights())
{
memcpy(a_Into.m_BlockSkyLight, m_BlockSkyLight, BlockCount * sizeof(NIBBLETYPE));
}
}
开发者ID:Dam63,项目名称:MCServer,代码行数:29,代码来源:BlockArea.cpp
示例2: m_Size
cPrefab::cPrefab(const cBlockArea & a_Image) :
m_Size(a_Image.GetSize()),
m_AllowedRotations(0),
m_MergeStrategy(cBlockArea::msOverwrite),
m_ExtendFloorStrategy(efsNone),
m_DefaultWeight(1),
m_AddWeightIfSame(0),
m_MoveToGround(false)
{
m_HitBox.p1.Set(0, 0, 0);
m_HitBox.p2.Set(m_Size.x - 1, m_Size.y - 1, m_Size.z - 1);
m_BlockArea[0].CopyFrom(a_Image);
}
开发者ID:UltraCoderRU,项目名称:MCServer,代码行数:13,代码来源:Prefab.cpp
示例3: Merge
void cBlockArea::Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy)
{
const NIBBLETYPE * SrcMetas = a_Src.GetBlockMetas();
NIBBLETYPE * DstMetas = m_BlockMetas;
bool IsDummyMetas = ((SrcMetas == NULL) || (DstMetas == NULL));
if (IsDummyMetas)
{
MergeByStrategy<false>(a_Src, a_RelX, a_RelY, a_RelZ, a_Strategy, SrcMetas, DstMetas);
}
else
{
MergeByStrategy<true>(a_Src, a_RelX, a_RelY, a_RelZ, a_Strategy, SrcMetas, DstMetas);
}
}
开发者ID:Kortak,项目名称:MCServer,代码行数:17,代码来源:BlockArea.cpp
示例4: SaveToSchematicNBT
AString cSchematicFileSerializer::SaveToSchematicNBT(const cBlockArea & a_BlockArea)
{
cFastNBTWriter Writer("Schematic");
Writer.AddShort("Width", static_cast<Int16>(a_BlockArea.m_Size.x));
Writer.AddShort("Height", static_cast<Int16>(a_BlockArea.m_Size.y));
Writer.AddShort("Length", static_cast<Int16>(a_BlockArea.m_Size.z));
Writer.AddString("Materials", "Alpha");
if (a_BlockArea.HasBlockTypes())
{
Writer.AddByteArray("Blocks", reinterpret_cast<const char *>(a_BlockArea.GetBlockTypes()), a_BlockArea.GetBlockCount());
}
else
{
AString Dummy(a_BlockArea.GetBlockCount(), 0);
Writer.AddByteArray("Blocks", Dummy.data(), Dummy.size());
}
if (a_BlockArea.HasBlockMetas())
{
Writer.AddByteArray("Data", reinterpret_cast<const char *>(a_BlockArea.GetBlockMetas()), a_BlockArea.GetBlockCount());
}
else
{
AString Dummy(a_BlockArea.GetBlockCount(), 0);
Writer.AddByteArray("Data", Dummy.data(), Dummy.size());
}
Writer.AddInt("WEOffsetX", a_BlockArea.m_WEOffset.x);
Writer.AddInt("WEOffsetY", a_BlockArea.m_WEOffset.y);
Writer.AddInt("WEOffsetZ", a_BlockArea.m_WEOffset.z);
// TODO: Save entities and block entities
Writer.BeginList("Entities", TAG_Compound);
Writer.EndList();
Writer.BeginList("TileEntities", TAG_Compound);
Writer.EndList();
Writer.Finish();
return Writer.GetResult();
}
开发者ID:ThuGie,项目名称:MCServer,代码行数:39,代码来源:SchematicFileSerializer.cpp
示例5: Merge
void cBlockArea::Merge(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy)
{
// Block types are compulsory, block metas are voluntary
if (!HasBlockTypes() || !a_Src.HasBlockTypes())
{
LOGWARNING("%s: cannot merge because one of the areas doesn't have blocktypes.", __FUNCTION__);
return;
}
// Dst is *this, Src is a_Src
int SrcOffX = std::max(0, -a_RelX); // Offset in Src where to start reading
int DstOffX = std::max(0, a_RelX); // Offset in Dst where to start writing
int SizeX = std::min(a_Src.GetSizeX() - SrcOffX, GetSizeX() - DstOffX); // How many blocks to copy
int SrcOffY = std::max(0, -a_RelY); // Offset in Src where to start reading
int DstOffY = std::max(0, a_RelY); // Offset in Dst where to start writing
int SizeY = std::min(a_Src.GetSizeY() - SrcOffY, GetSizeY() - DstOffY); // How many blocks to copy
int SrcOffZ = std::max(0, -a_RelZ); // Offset in Src where to start reading
int DstOffZ = std::max(0, a_RelZ); // Offset in Dst where to start writing
int SizeZ = std::min(a_Src.GetSizeZ() - SrcOffZ, GetSizeZ() - DstOffZ); // How many blocks to copy
const NIBBLETYPE * SrcMetas = a_Src.GetBlockMetas();
NIBBLETYPE * DstMetas = m_BlockMetas;
bool IsDummyMetas = ((SrcMetas == NULL) || (DstMetas == NULL));
if (IsDummyMetas)
{
SrcMetas = new NIBBLETYPE[a_Src.GetBlockCount()];
DstMetas = new NIBBLETYPE[GetBlockCount()];
}
switch (a_Strategy)
{
case msOverwrite:
{
InternalMergeBlocks(
m_BlockTypes, a_Src.GetBlockTypes(),
DstMetas, SrcMetas,
SizeX, SizeY, SizeZ,
SrcOffX, SrcOffY, SrcOffZ,
DstOffX, DstOffY, DstOffZ,
a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
m_SizeX, m_SizeY, m_SizeZ,
MergeCombinatorOverwrite
);
break;
} // case msOverwrite
case msFillAir:
{
InternalMergeBlocks(
m_BlockTypes, a_Src.GetBlockTypes(),
DstMetas, SrcMetas,
SizeX, SizeY, SizeZ,
SrcOffX, SrcOffY, SrcOffZ,
DstOffX, DstOffY, DstOffZ,
a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
m_SizeX, m_SizeY, m_SizeZ,
MergeCombinatorFillAir
);
break;
} // case msFillAir
case msImprint:
{
InternalMergeBlocks(
m_BlockTypes, a_Src.GetBlockTypes(),
DstMetas, SrcMetas,
SizeX, SizeY, SizeZ,
SrcOffX, SrcOffY, SrcOffZ,
DstOffX, DstOffY, DstOffZ,
a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
m_SizeX, m_SizeY, m_SizeZ,
MergeCombinatorImprint
);
break;
} // case msImprint
case msLake:
{
InternalMergeBlocks(
m_BlockTypes, a_Src.GetBlockTypes(),
DstMetas, SrcMetas,
SizeX, SizeY, SizeZ,
SrcOffX, SrcOffY, SrcOffZ,
DstOffX, DstOffY, DstOffZ,
a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
m_SizeX, m_SizeY, m_SizeZ,
MergeCombinatorLake
);
break;
} // case msLake
default:
{
LOGWARNING("Unknown block area merge strategy: %d", a_Strategy);
ASSERT(!"Unknown block area merge strategy");
break;
}
//.........这里部分代码省略.........
开发者ID:Hillvith,项目名称:MCServer,代码行数:101,代码来源:BlockArea.cpp
示例6: CopyFrom
void cBlockArea::CopyFrom(const cBlockArea & a_From)
{
a_From.CopyTo(*this);
}
开发者ID:Hillvith,项目名称:MCServer,代码行数:4,代码来源:BlockArea.cpp
示例7: LOGWARNING
void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ)
{
// Normalize the coords:
if (a_MinRelX > a_MaxRelX)
{
std::swap(a_MinRelX, a_MaxRelX);
}
if (a_MinRelY > a_MaxRelY)
{
std::swap(a_MinRelY, a_MaxRelY);
}
if (a_MinRelZ > a_MaxRelZ)
{
std::swap(a_MinRelZ, a_MaxRelZ);
}
// Include the Max coords:
a_MaxRelX += 1;
a_MaxRelY += 1;
a_MaxRelZ += 1;
// Check coords validity:
if (a_MinRelX < 0)
{
LOGWARNING("%s: MinRelX less than zero, adjusting to zero", __FUNCTION__);
a_MinRelX = 0;
}
else if (a_MinRelX >= cChunkDef::Width)
{
LOGWARNING("%s: MinRelX more than chunk width, adjusting to chunk width", __FUNCTION__);
a_MinRelX = cChunkDef::Width - 1;
}
if (a_MaxRelX < 0)
{
LOGWARNING("%s: MaxRelX less than zero, adjusting to zero", __FUNCTION__);
a_MaxRelX = 0;
}
else if (a_MaxRelX > cChunkDef::Width)
{
LOGWARNING("%s: MaxRelX more than chunk width, adjusting to chunk width", __FUNCTION__);
a_MaxRelX = cChunkDef::Width;
}
if (a_MinRelY < 0)
{
LOGWARNING("%s: MinRelY less than zero, adjusting to zero", __FUNCTION__);
a_MinRelY = 0;
}
else if (a_MinRelY >= cChunkDef::Height)
{
LOGWARNING("%s: MinRelY more than chunk height, adjusting to chunk height", __FUNCTION__);
a_MinRelY = cChunkDef::Height - 1;
}
if (a_MaxRelY < 0)
{
LOGWARNING("%s: MaxRelY less than zero, adjusting to zero", __FUNCTION__);
a_MaxRelY = 0;
}
else if (a_MaxRelY > cChunkDef::Height)
{
LOGWARNING("%s: MaxRelY more than chunk height, adjusting to chunk height", __FUNCTION__);
a_MaxRelY = cChunkDef::Height;
}
if (a_MinRelZ < 0)
{
LOGWARNING("%s: MinRelZ less than zero, adjusting to zero", __FUNCTION__);
a_MinRelZ = 0;
}
else if (a_MinRelZ >= cChunkDef::Width)
{
LOGWARNING("%s: MinRelZ more than chunk width, adjusting to chunk width", __FUNCTION__);
a_MinRelZ = cChunkDef::Width - 1;
}
if (a_MaxRelZ < 0)
{
LOGWARNING("%s: MaxRelZ less than zero, adjusting to zero", __FUNCTION__);
a_MaxRelZ = 0;
}
else if (a_MaxRelZ > cChunkDef::Width)
{
LOGWARNING("%s: MaxRelZ more than chunk width, adjusting to chunk width", __FUNCTION__);
a_MaxRelZ = cChunkDef::Width;
}
// Prepare the block area:
int SizeX = a_MaxRelX - a_MinRelX;
int SizeY = a_MaxRelY - a_MinRelY;
int SizeZ = a_MaxRelZ - a_MinRelZ;
a_Dest.Clear();
a_Dest.m_Origin.x = m_ChunkX * cChunkDef::Width + a_MinRelX;
a_Dest.m_Origin.y = a_MinRelY;
a_Dest.m_Origin.z = m_ChunkZ * cChunkDef::Width + a_MinRelZ;
a_Dest.SetSize(SizeX, SizeY, SizeZ, cBlockArea::baTypes | cBlockArea::baMetas);
for (int y = 0; y < SizeY; y++)
{
int CDY = a_MinRelY + y;
for (int z = 0; z < SizeZ; z++)
{
//.........这里部分代码省略.........
开发者ID:ThuGie,项目名称:MCServer,代码行数:101,代码来源:ChunkDesc.cpp
示例8: LOGWARNING
void cBlockArea::MergeByStrategy(const cBlockArea & a_Src, int a_RelX, int a_RelY, int a_RelZ, eMergeStrategy a_Strategy, const NIBBLETYPE * SrcMetas, NIBBLETYPE * DstMetas)
{
// Block types are compulsory, block metas are voluntary
if (!HasBlockTypes() || !a_Src.HasBlockTypes())
{
LOGWARNING("%s: cannot merge because one of the areas doesn't have blocktypes.", __FUNCTION__);
return;
}
// Dst is *this, Src is a_Src
int SrcOffX = std::max(0, -a_RelX); // Offset in Src where to start reading
int DstOffX = std::max(0, a_RelX); // Offset in Dst where to start writing
int SizeX = std::min(a_Src.GetSizeX() - SrcOffX, GetSizeX() - DstOffX); // How many blocks to copy
int SrcOffY = std::max(0, -a_RelY); // Offset in Src where to start reading
int DstOffY = std::max(0, a_RelY); // Offset in Dst where to start writing
int SizeY = std::min(a_Src.GetSizeY() - SrcOffY, GetSizeY() - DstOffY); // How many blocks to copy
int SrcOffZ = std::max(0, -a_RelZ); // Offset in Src where to start reading
int DstOffZ = std::max(0, a_RelZ); // Offset in Dst where to start writing
int SizeZ = std::min(a_Src.GetSizeZ() - SrcOffZ, GetSizeZ() - DstOffZ); // How many blocks to copy
switch (a_Strategy)
{
case cBlockArea::msOverwrite:
{
InternalMergeBlocks<MetasValid, MergeCombinatorOverwrite<MetasValid> >(
m_BlockTypes, a_Src.GetBlockTypes(),
DstMetas, SrcMetas,
SizeX, SizeY, SizeZ,
SrcOffX, SrcOffY, SrcOffZ,
DstOffX, DstOffY, DstOffZ,
a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
m_Size.x, m_Size.y, m_Size.z
);
return;
} // case msOverwrite
case cBlockArea::msFillAir:
{
InternalMergeBlocks<MetasValid, MergeCombinatorFillAir<MetasValid> >(
m_BlockTypes, a_Src.GetBlockTypes(),
DstMetas, SrcMetas,
SizeX, SizeY, SizeZ,
SrcOffX, SrcOffY, SrcOffZ,
DstOffX, DstOffY, DstOffZ,
a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
m_Size.x, m_Size.y, m_Size.z
);
return;
} // case msFillAir
case cBlockArea::msImprint:
{
InternalMergeBlocks<MetasValid, MergeCombinatorImprint<MetasValid> >(
m_BlockTypes, a_Src.GetBlockTypes(),
DstMetas, SrcMetas,
SizeX, SizeY, SizeZ,
SrcOffX, SrcOffY, SrcOffZ,
DstOffX, DstOffY, DstOffZ,
a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
m_Size.x, m_Size.y, m_Size.z
);
return;
} // case msImprint
case cBlockArea::msLake:
{
InternalMergeBlocks<MetasValid, MergeCombinatorLake<MetasValid> >(
m_BlockTypes, a_Src.GetBlockTypes(),
DstMetas, SrcMetas,
SizeX, SizeY, SizeZ,
SrcOffX, SrcOffY, SrcOffZ,
DstOffX, DstOffY, DstOffZ,
a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
m_Size.x, m_Size.y, m_Size.z
);
return;
} // case msLake
case cBlockArea::msSpongePrint:
{
InternalMergeBlocks<MetasValid, MergeCombinatorSpongePrint<MetasValid> >(
m_BlockTypes, a_Src.GetBlockTypes(),
DstMetas, SrcMetas,
SizeX, SizeY, SizeZ,
SrcOffX, SrcOffY, SrcOffZ,
DstOffX, DstOffY, DstOffZ,
a_Src.GetSizeX(), a_Src.GetSizeY(), a_Src.GetSizeZ(),
m_Size.x, m_Size.y, m_Size.z
);
return;
} // case msSpongePrint
case cBlockArea::msDifference:
{
InternalMergeBlocks<MetasValid, MergeCombinatorDifference<MetasValid> >(
m_BlockTypes, a_Src.GetBlockTypes(),
DstMetas, SrcMetas,
SizeX, SizeY, SizeZ,
//.........这里部分代码省略.........
开发者ID:Kortak,项目名称:MCServer,代码行数:101,代码来源:BlockArea.cpp
示例9: LOG
bool cSchematicFileSerializer::LoadFromSchematicNBT(cBlockArea & a_BlockArea, cParsedNBT & a_NBT)
{
int TMaterials = a_NBT.FindChildByName(a_NBT.GetRoot(), "Materials");
if ((TMaterials > 0) && (a_NBT.GetType(TMaterials) == TAG_String))
{
AString Materials = a_NBT.GetString(TMaterials);
if (Materials.compare("Alpha") != 0)
{
LOG("Materials tag is present and \"%s\" instead of \"Alpha\". Possibly a wrong-format schematic file.", Materials.c_str());
return false;
}
}
int TSizeX = a_NBT.FindChildByName(a_NBT.GetRoot(), "Width");
int TSizeY = a_NBT.FindChildByName(a_NBT.GetRoot(), "Height");
int TSizeZ = a_NBT.FindChildByName(a_NBT.GetRoot(), "Length");
if (
(TSizeX < 0) || (TSizeY < 0) || (TSizeZ < 0) ||
(a_NBT.GetType(TSizeX) != TAG_Short) ||
(a_NBT.GetType(TSizeY) != TAG_Short) ||
(a_NBT.GetType(TSizeZ) != TAG_Short)
)
{
LOG("Dimensions are missing from the schematic file (%d, %d, %d), (%d, %d, %d)",
TSizeX, TSizeY, TSizeZ,
(TSizeX >= 0) ? a_NBT.GetType(TSizeX) : -1,
(TSizeY >= 0) ? a_NBT.GetType(TSizeY) : -1,
(TSizeZ >= 0) ? a_NBT.GetType(TSizeZ) : -1
);
return false;
}
int SizeX = a_NBT.GetShort(TSizeX);
int SizeY = a_NBT.GetShort(TSizeY);
int SizeZ = a_NBT.GetShort(TSizeZ);
if ((SizeX < 1) || (SizeX > 65535) || (SizeY < 1) || (SizeY > cChunkDef::Height) || (SizeZ < 1) || (SizeZ > 65535))
{
LOG("Dimensions are invalid in the schematic file: %d, %d, %d", SizeX, SizeY, SizeZ);
return false;
}
int TBlockTypes = a_NBT.FindChildByName(a_NBT.GetRoot(), "Blocks");
int TBlockMetas = a_NBT.FindChildByName(a_NBT.GetRoot(), "Data");
if ((TBlockTypes < 0) || (a_NBT.GetType(TBlockTypes) != TAG_ByteArray))
{
LOG("BlockTypes are invalid in the schematic file: %d", TBlockTypes);
return false;
}
bool AreMetasPresent = (TBlockMetas > 0) && (a_NBT.GetType(TBlockMetas) == TAG_ByteArray);
a_BlockArea.Clear();
a_BlockArea.SetSize(SizeX, SizeY, SizeZ, AreMetasPresent ? (cBlockArea::baTypes | cBlockArea::baMetas) : cBlockArea::baTypes);
int TOffsetX = a_NBT.FindChildByName(a_NBT.GetRoot(), "WEOffsetX");
int TOffsetY = a_NBT.FindChildByName(a_NBT.GetRoot(), "WEOffsetY");
int TOffsetZ = a_NBT.FindChildByName(a_NBT.GetRoot(), "WEOffsetZ");
if (
(TOffsetX < 0) || (TOffsetY < 0) || (TOffsetZ < 0) ||
(a_NBT.GetType(TOffsetX) != TAG_Int) ||
(a_NBT.GetType(TOffsetY) != TAG_Int) ||
(a_NBT.GetType(TOffsetZ) != TAG_Int)
)
{
// Not every schematic file has an offset, so we shoudn't give a warn message.
a_BlockArea.SetWEOffset(0, 0, 0);
}
else
{
a_BlockArea.SetWEOffset(a_NBT.GetInt(TOffsetX), a_NBT.GetInt(TOffsetY), a_NBT.GetInt(TOffsetZ));
}
// Copy the block types and metas:
size_t NumTypeBytes = a_BlockArea.GetBlockCount();
if (a_NBT.GetDataLength(TBlockTypes) < NumTypeBytes)
{
LOG("BlockTypes truncated in the schematic file (exp %u, got %u bytes). Loading partial.",
static_cast<unsigned>(NumTypeBytes), static_cast<unsigned>(a_NBT.GetDataLength(TBlockTypes))
);
NumTypeBytes = a_NBT.GetDataLength(TBlockTypes);
}
memcpy(a_BlockArea.GetBlockTypes(), a_NBT.GetData(TBlockTypes), NumTypeBytes);
if (AreMetasPresent)
{
size_t NumMetaBytes = a_BlockArea.GetBlockCount();
if (a_NBT.GetDataLength(TBlockMetas) < NumMetaBytes)
{
LOG("BlockMetas truncated in the schematic file (exp %u, got %u bytes). Loading partial.",
static_cast<unsigned>(NumMetaBytes), static_cast<unsigned>(a_NBT.GetDataLength(TBlockMetas))
);
NumMetaBytes = a_NBT.GetDataLength(TBlockMetas);
}
memcpy(a_BlockArea.GetBlockMetas(), a_NBT.GetData(TBlockMetas), NumMetaBytes);
}
return true;
}
开发者ID:ThuGie,项目名称:MCServer,代码行数:97,代码来源:SchematicFileSerializer.cpp
注:本文中的cBlockArea类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论