本文整理汇总了C++中Loader::GetWord方法的典型用法代码示例。如果您正苦于以下问题:C++ Loader::GetWord方法的具体用法?C++ Loader::GetWord怎么用?C++ Loader::GetWord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Loader
的用法示例。
在下文中一共展示了Loader::GetWord方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Load
/**
* Load a voxel stack from the save game file.
* @param ldr Input stream to read.
*/
void VoxelStack::Load(Loader &ldr)
{
this->Clear();
uint32 version = ldr.OpenBlock("VSTK");
if (version >= 1 && version <= 3) {
int16 base = ldr.GetWord();
uint16 height = ldr.GetWord();
uint8 owner = ldr.GetByte();
if (base < 0 || base + height > WORLD_Z_SIZE || owner >= OWN_COUNT) {
ldr.SetFailMessage("Incorrect voxel stack size");
} else {
this->base = base;
this->height = height;
this->owner = (TileOwner)owner;
delete[] this->voxels;
this->voxels = (height > 0) ? MakeNewVoxels(height) : nullptr;
for (uint i = 0; i < height; i++) this->voxels[i].Load(ldr, version);
/* In version 3 of VSTK, the fences of the lowest corner of steep slopes have moved from the top voxel to the base voxel. */
if (version < 3) {
static const uint16 low_fences_mask[4] = { // Mask for getting the low fences.
(0xf << (4 * EDGE_SE)) | (0xf << (4 * EDGE_SW)), // ISL_TOP_STEEP_NORTH
(0xf << (4 * EDGE_SW)) | (0xf << (4 * EDGE_NW)), // ISL_TOP_STEEP_EAST
(0xf << (4 * EDGE_NW)) | (0xf << (4 * EDGE_NE)), // ISL_TOP_STEEP_SOUTH
(0xf << (4 * EDGE_NE)) | (0xf << (4 * EDGE_SE)), // ISL_TOP_STEEP_WEST
};
for (uint i = 0; i < height; i++) {
if (this->voxels[i].GetGroundType() == GTP_INVALID) continue;
if (!IsImplodedSteepSlopeTop(this->voxels[i].GetGroundSlope())) continue;
uint16 mask = low_fences_mask[this->voxels[i].GetGroundSlope() - ISL_TOP_STEEP_NORTH];
/* Take out the fences of the top voxel that should be in the base voxel.
* Make the low fences in the high voxel invalid. */
uint16 fences = this->voxels[i].GetFences();
uint16 lower_fences = fences & mask;
uint16 high_invalid = ALL_INVALID_FENCES & mask;
mask ^= 0xffff;
this->voxels[i].SetFences(high_invalid | (fences & mask));
/* Fix low fences. */
fences = this->voxels[i + 1].GetFences();
this->voxels[i + 1].SetFences(lower_fences | (fences & mask));
break; // Only one steep ground slope in a voxel stack at most.
}
}
}
}
ldr.CloseBlock();
}
示例2: Load
/**
* Load guests from the save game.
* @param ldr Input stream to read.
*/
void Guests::Load(Loader &ldr)
{
uint32 version = ldr.OpenBlock("GSTS");
if (version == 1) {
this->start_voxel.x = ldr.GetWord();
this->start_voxel.y = ldr.GetWord();
this->daily_frac = ldr.GetWord();
this->next_daily_index = ldr.GetWord();
this->free_idx = ldr.GetLong();
uint active_guest_count = ldr.GetLong();
for (uint i = 0; i < active_guest_count; i++) {
Guest *g = this->block.Get(ldr.GetWord());
g->Load(ldr);
}
} else {
ldr.SetFailMessage("Incorrect version of Guests block.");
}
ldr.CloseBlock();
}