diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-02-05 22:45:45 +0100 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-02-05 22:50:18 +0100 |
commit | ca6ef58b1ee8521e4b940ee4883dee714960e413 (patch) | |
tree | 8532add455224b07c07a759e3d906f50c0695888 /src/WorldStorage/WSSAnvil.cpp | |
parent | Merge pull request #2972 from marvinkopf/PlayerAutoComplete (diff) | |
download | cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.gz cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.bz2 cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.lz cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.xz cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.tar.zst cuberite-ca6ef58b1ee8521e4b940ee4883dee714960e413.zip |
Diffstat (limited to 'src/WorldStorage/WSSAnvil.cpp')
-rwxr-xr-x | src/WorldStorage/WSSAnvil.cpp | 240 |
1 files changed, 120 insertions, 120 deletions
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index 385a3a3ca..4fc855589 100755 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -110,7 +110,7 @@ cWSSAnvil::cWSSAnvil(cWorld * a_World, int a_CompressionFactor) : Writer.AddString("LevelName", a_World->GetName()); Writer.EndCompound(); Writer.Finish(); - + gzFile gz = gzopen((FILE_IO_PREFIX + fnam).c_str(), "wb"); if (gz != nullptr) { @@ -145,7 +145,7 @@ bool cWSSAnvil::LoadChunk(const cChunkCoords & a_Chunk) // The reason for failure is already printed in GetChunkData() return false; } - + return LoadChunkFromData(a_Chunk, ChunkData); } @@ -166,7 +166,7 @@ bool cWSSAnvil::SaveChunk(const cChunkCoords & a_Chunk) LOGWARNING("Cannot store chunk [%d, %d] data", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ); return false; } - + // Everything successful return true; } @@ -266,7 +266,7 @@ cWSSAnvil::cMCAFile * cWSSAnvil::LoadMCAFile(const cChunkCoords & a_Chunk) ASSERT(a_Chunk.m_ChunkZ - RegionZ * 32 >= 0); ASSERT(a_Chunk.m_ChunkX - RegionX * 32 < 32); ASSERT(a_Chunk.m_ChunkZ - RegionZ * 32 < 32); - + // Is it already cached? for (cMCAFiles::iterator itr = m_Files.begin(); itr != m_Files.end(); ++itr) { @@ -282,7 +282,7 @@ cWSSAnvil::cMCAFile * cWSSAnvil::LoadMCAFile(const cChunkCoords & a_Chunk) return f; } } - + // Load it anew: AString FileName; Printf(FileName, "%s%cregion", m_World->GetName().c_str(), cFile::PathSeparator); @@ -294,7 +294,7 @@ cWSSAnvil::cMCAFile * cWSSAnvil::LoadMCAFile(const cChunkCoords & a_Chunk) return nullptr; } m_Files.push_front(f); - + // If there are too many MCA files cached, delete the last one used: if (m_Files.size() > MAX_MCA_FILES) { @@ -319,7 +319,7 @@ bool cWSSAnvil::LoadChunkFromData(const cChunkCoords & a_Chunk, const AString & ChunkLoadFailed(a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, "InflateString() failed", a_Data); return false; } - + // Parse the NBT data: cParsedNBT NBT(Uncompressed.data(), Uncompressed.size()); if (!NBT.IsValid()) @@ -346,7 +346,7 @@ bool cWSSAnvil::SaveChunkToData(const cChunkCoords & a_Chunk, AString & a_Data) return false; } Writer.Finish(); - + CompressString(Writer.GetResult().data(), Writer.GetResult().size(), a_Data, m_CompressionFactor); return true; } @@ -362,12 +362,12 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT cChunkDef::BlockNibbles MetaData; cChunkDef::BlockNibbles BlockLight; cChunkDef::BlockNibbles SkyLight; - + memset(BlockTypes, E_BLOCK_AIR, sizeof(BlockTypes)); memset(MetaData, 0, sizeof(MetaData)); memset(SkyLight, 0xff, sizeof(SkyLight)); // By default, data not present in the NBT means air, which means full skylight memset(BlockLight, 0x00, sizeof(BlockLight)); - + // Load the blockdata, blocklight and skylight: int Level = a_NBT.FindChildByName(0, "Level"); if (Level < 0) @@ -405,7 +405,7 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT CopyNBTData(a_NBT, Child, "SkyLight", reinterpret_cast<char *>(&(SkyLight[y * 2048])), 2048); CopyNBTData(a_NBT, Child, "BlockLight", reinterpret_cast<char *>(&(BlockLight[y * 2048])), 2048); } // for itr - LevelSections[] - + // Load the biomes from NBT, if present and valid. First try MCS-style, then Vanilla-style: cChunkDef::BiomeMap BiomeMap; cChunkDef::BiomeMap * Biomes = LoadBiomeMapFromNBT(&BiomeMap, a_NBT, a_NBT.FindChildByName(Level, "MCSBiomes")); @@ -414,15 +414,15 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT // MCS-style biomes not available, load vanilla-style: Biomes = LoadVanillaBiomeMapFromNBT(&BiomeMap, a_NBT, a_NBT.FindChildByName(Level, "Biomes")); } - + // Load the entities from NBT: cEntityList Entities; cBlockEntityList BlockEntities; LoadEntitiesFromNBT (Entities, a_NBT, a_NBT.FindChildByName(Level, "Entities")); LoadBlockEntitiesFromNBT(BlockEntities, a_NBT, a_NBT.FindChildByName(Level, "TileEntities"), BlockTypes, MetaData); - + bool IsLightValid = (a_NBT.FindChildByName(Level, "MCSIsLightValid") > 0); - + /* // Uncomment this block for really cool stuff :) // DEBUG magic: Invert the underground, so that we can see the MC generator in action :) @@ -458,7 +458,7 @@ bool cWSSAnvil::LoadChunkFromNBT(const cChunkCoords & a_Chunk, const cParsedNBT } } // for y //*/ - + cSetChunkDataPtr SetChunkData(new cSetChunkData( a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, BlockTypes, MetaData, @@ -501,7 +501,7 @@ bool cWSSAnvil::SaveChunkToNBT(const cChunkCoords & a_Chunk, cFastNBTWriter & a_ return false; } Serializer.Finish(); // Close NBT tags - + // Save biomes, both MCS (IntArray) and MC-vanilla (ByteArray): if (Serializer.m_BiomesAreValid) { @@ -535,7 +535,7 @@ bool cWSSAnvil::SaveChunkToNBT(const cChunkCoords & a_Chunk, cFastNBTWriter & a_ a_Writer.EndCompound(); } a_Writer.EndList(); // "Sections" - + // Store the information that the lighting is valid. // For compatibility reason, the default is "invalid" (missing) - this means older data is re-lighted upon loading. if (Serializer.IsLightValid()) @@ -545,10 +545,10 @@ bool cWSSAnvil::SaveChunkToNBT(const cChunkCoords & a_Chunk, cFastNBTWriter & a_ // Save the world age to the chunk data. Required by vanilla and mcedit. a_Writer.AddLong("LastUpdate", m_World->GetWorldAge()); - + // Store the flag that the chunk has all the ores, trees, dungeons etc. MCS chunks are always complete. a_Writer.AddByte("TerrainPopulated", 1); - + a_Writer.EndCompound(); // "Level" return true; } @@ -619,7 +619,7 @@ void cWSSAnvil::LoadEntitiesFromNBT(cEntityList & a_Entities, const cParsedNBT & { return; } - + for (int Child = a_NBT.GetFirstChild(a_TagIdx); Child != -1; Child = a_NBT.GetNextSibling(Child)) { if (a_NBT.GetType(Child) != TAG_Compound) @@ -645,7 +645,7 @@ void cWSSAnvil::LoadBlockEntitiesFromNBT(cBlockEntityList & a_BlockEntities, con { return; } - + for (int Child = a_NBT.GetFirstChild(a_TagIdx); Child != -1; Child = a_NBT.GetNextSibling(Child)) { if (a_NBT.GetType(Child) != TAG_Compound) @@ -761,19 +761,19 @@ bool cWSSAnvil::LoadItemFromNBT(cItem & a_Item, const cParsedNBT & a_NBT, int a_ a_Item.Empty(); return true; } - + int Damage = a_NBT.FindChildByName(a_TagIdx, "Damage"); if ((Damage > 0) && (a_NBT.GetType(Damage) == TAG_Short)) { a_Item.m_ItemDamage = a_NBT.GetShort(Damage); } - + int Count = a_NBT.FindChildByName(a_TagIdx, "Count"); if ((Count > 0) && (a_NBT.GetType(Count) == TAG_Byte)) { a_Item.m_ItemCount = static_cast<char>(a_NBT.GetByte(Count)); } - + // Find the "tag" tag, used for enchantments and other extra data int TagTag = a_NBT.FindChildByName(a_TagIdx, "tag"); if (TagTag <= 0) @@ -819,7 +819,7 @@ bool cWSSAnvil::LoadItemFromNBT(cItem & a_Item, const cParsedNBT & a_NBT, int a_ { cFireworkItem::ParseFromNBT(a_Item.m_FireworkItem, a_NBT, FireworksTag, static_cast<ENUM_ITEM_ID>(a_Item.m_ItemType)); } - + return true; } @@ -1134,7 +1134,7 @@ cBlockEntity * cWSSAnvil::LoadFurnaceFromNBT(const cParsedNBT & a_NBT, int a_Tag { return nullptr; // Make it an empty furnace - the chunk loader will provide an empty cFurnaceEntity for this } - + std::unique_ptr<cFurnaceEntity> Furnace = cpp14::make_unique<cFurnaceEntity>(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, m_World); Furnace->SetLoading(true); @@ -1152,7 +1152,7 @@ cBlockEntity * cWSSAnvil::LoadFurnaceFromNBT(const cParsedNBT & a_NBT, int a_Tag Furnace->SetSlot(a_NBT.GetByte(Slot), Item); } } // for itr - ItemDefs[] - + // Load burn time: int BurnTime = a_NBT.FindChildByName(a_TagIdx, "BurnTime"); if (BurnTime >= 0) @@ -1161,7 +1161,7 @@ cBlockEntity * cWSSAnvil::LoadFurnaceFromNBT(const cParsedNBT & a_NBT, int a_Tag // Anvil doesn't store the time that the fuel can burn. We simply "reset" the current value to be the 100% Furnace->SetBurnTimes(bt, 0); } - + // Load cook time: int CookTime = a_NBT.FindChildByName(a_TagIdx, "CookTime"); if (CookTime >= 0) @@ -1741,9 +1741,9 @@ void cWSSAnvil::LoadMinecartFFromNBT(cEntityList & a_Entities, const cParsedNBT { return; } - + // TODO: Load the Push and Fuel tags - + a_Entities.push_back(Minecart.release()); } @@ -1758,7 +1758,7 @@ void cWSSAnvil::LoadMinecartTFromNBT(cEntityList & a_Entities, const cParsedNBT { return; } - + // TODO: Everything to do with TNT carts a_Entities.push_back(Minecart.release()); @@ -1775,7 +1775,7 @@ void cWSSAnvil::LoadMinecartHFromNBT(cEntityList & a_Entities, const cParsedNBT { return; } - + // TODO: Everything to do with hopper carts a_Entities.push_back(Minecart.release()); @@ -1798,13 +1798,13 @@ void cWSSAnvil::LoadPickupFromNBT(cEntityList & a_Entities, const cParsedNBT & a { return; } - + std::unique_ptr<cPickup> Pickup = cpp14::make_unique<cPickup>(0, 0, 0, Item, false); // Pickup delay doesn't matter, just say false if (!LoadEntityBaseFromNBT(*Pickup.get(), a_NBT, a_TagIdx)) { return; } - + // Load age: int Age = a_NBT.FindChildByName(a_TagIdx, "Age"); if (Age > 0) @@ -1826,14 +1826,14 @@ void cWSSAnvil::LoadTNTFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB { return; } - + // Load Fuse Ticks: int FuseTicks = a_NBT.FindChildByName(a_TagIdx, "Fuse"); if (FuseTicks > 0) { TNT->SetFuseTicks(static_cast<int>(a_NBT.GetByte(FuseTicks))); } - + a_Entities.push_back(TNT.release()); } @@ -1911,7 +1911,7 @@ void cWSSAnvil::LoadItemFrameFromNBT(cEntityList & a_Entities, const cParsedNBT { return; } - + std::unique_ptr<cItemFrame> ItemFrame = cpp14::make_unique<cItemFrame>(BLOCK_FACE_NONE, 0.0, 0.0, 0.0); if (!LoadEntityBaseFromNBT(*ItemFrame.get(), a_NBT, a_TagIdx)) { @@ -1920,14 +1920,14 @@ void cWSSAnvil::LoadItemFrameFromNBT(cEntityList & a_Entities, const cParsedNBT ItemFrame->SetItem(Item); LoadHangingFromNBT(*ItemFrame.get(), a_NBT, a_TagIdx); - + // Load Rotation: int Rotation = a_NBT.FindChildByName(a_TagIdx, "ItemRotation"); if (Rotation > 0) { ItemFrame->SetItemRotation(static_cast<Byte>(a_NBT.GetByte(Rotation))); } - + a_Entities.push_back(ItemFrame.release()); } @@ -1965,7 +1965,7 @@ void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ { return; } - + // Load pickup state: int PickupIdx = a_NBT.FindChildByName(a_TagIdx, "pickup"); if ((PickupIdx > 0) && (a_NBT.GetType(PickupIdx) == TAG_Byte)) @@ -1981,14 +1981,14 @@ void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ Arrow->SetPickupState((a_NBT.GetByte(PlayerIdx) == 0) ? cArrowEntity::psNoPickup : cArrowEntity::psInSurvivalOrCreative); } } - + // Load damage: int DamageIdx = a_NBT.FindChildByName(a_TagIdx, "damage"); if ((DamageIdx > 0) && (a_NBT.GetType(DamageIdx) == TAG_Double)) { Arrow->SetDamageCoeff(a_NBT.GetDouble(DamageIdx)); } - + // Load block hit: int InBlockXIdx = a_NBT.FindChildByName(a_TagIdx, "xTile"); int InBlockYIdx = a_NBT.FindChildByName(a_TagIdx, "yTile"); @@ -2020,7 +2020,7 @@ void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ } } } - + // Store the new arrow in the entities list: a_Entities.push_back(Arrow.release()); } @@ -2035,15 +2035,15 @@ void cWSSAnvil::LoadSplashPotionFromNBT(cEntityList & a_Entities, const cParsedN { return; } - + int EffectDuration = a_NBT.FindChildByName(a_TagIdx, "EffectDuration"); int EffectIntensity = a_NBT.FindChildByName(a_TagIdx, "EffectIntensity"); int EffectDistanceModifier = a_NBT.FindChildByName(a_TagIdx, "EffectDistanceModifier"); - + SplashPotion->SetEntityEffectType(static_cast<cEntityEffect::eType>(a_NBT.FindChildByName(a_TagIdx, "EffectType"))); SplashPotion->SetEntityEffect(cEntityEffect(EffectDuration, static_cast<Int16>(EffectIntensity), EffectDistanceModifier)); SplashPotion->SetPotionColor(a_NBT.FindChildByName(a_TagIdx, "PotionName")); - + // Store the new splash potion in the entities list: a_Entities.push_back(SplashPotion.release()); } @@ -2059,7 +2059,7 @@ void cWSSAnvil::LoadSnowballFromNBT(cEntityList & a_Entities, const cParsedNBT & { return; } - + // Store the new snowball in the entities list: a_Entities.push_back(Snowball.release()); } @@ -2075,7 +2075,7 @@ void cWSSAnvil::LoadEggFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB { return; } - + // Store the new egg in the entities list: a_Entities.push_back(Egg.release()); } @@ -2091,7 +2091,7 @@ void cWSSAnvil::LoadFireballFromNBT(cEntityList & a_Entities, const cParsedNBT & { return; } - + // Store the new fireball in the entities list: a_Entities.push_back(Fireball.release()); } @@ -2107,7 +2107,7 @@ void cWSSAnvil::LoadFireChargeFromNBT(cEntityList & a_Entities, const cParsedNBT { return; } - + // Store the new FireCharge in the entities list: a_Entities.push_back(FireCharge.release()); } @@ -2123,7 +2123,7 @@ void cWSSAnvil::LoadThrownEnderpearlFromNBT(cEntityList & a_Entities, const cPar { return; } - + // Store the new enderpearl in the entities list: a_Entities.push_back(Enderpearl.release()); } @@ -2139,7 +2139,7 @@ void cWSSAnvil::LoadBatFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -2159,7 +2159,7 @@ void cWSSAnvil::LoadBlazeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -2179,7 +2179,7 @@ void cWSSAnvil::LoadCaveSpiderFromNBT(cEntityList & a_Entities, const cParsedNBT { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -2199,7 +2199,7 @@ void cWSSAnvil::LoadChickenFromNBT(cEntityList & a_Entities, const cParsedNBT & { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -2219,7 +2219,7 @@ void cWSSAnvil::LoadCowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -2239,7 +2239,7 @@ void cWSSAnvil::LoadCreeperFromNBT(cEntityList & a_Entities, const cParsedNBT & { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -2259,7 +2259,7 @@ void cWSSAnvil::LoadEnderDragonFromNBT(cEntityList & a_Entities, const cParsedNB { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -2319,7 +2319,7 @@ void cWSSAnvil::LoadGiantFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -2339,7 +2339,7 @@ void cWSSAnvil::LoadGuardianFromNBT(cEntityList & a_Entities, const cParsedNBT & { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -2372,12 +2372,12 @@ void cWSSAnvil::LoadHorseFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; } - + int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age"); if (AgeableIdx > 0) { @@ -2390,7 +2390,7 @@ void cWSSAnvil::LoadHorseFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ } Monster->SetAge(Age); } - + a_Entities.push_back(Monster.release()); } @@ -2405,7 +2405,7 @@ void cWSSAnvil::LoadIronGolemFromNBT(cEntityList & a_Entities, const cParsedNBT { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -2434,7 +2434,7 @@ void cWSSAnvil::LoadMagmaCubeFromNBT(cEntityList & a_Entities, const cParsedNBT { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -2454,7 +2454,7 @@ void cWSSAnvil::LoadMooshroomFromNBT(cEntityList & a_Entities, const cParsedNBT { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -2474,7 +2474,7 @@ void cWSSAnvil::LoadOcelotFromNBT(cEntityList & a_Entities, const cParsedNBT & a { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -2492,7 +2492,7 @@ void cWSSAnvil::LoadOcelotFromNBT(cEntityList & a_Entities, const cParsedNBT & a } Monster->SetAge(Age); } - + a_Entities.push_back(Monster.release()); } @@ -2507,12 +2507,12 @@ void cWSSAnvil::LoadPigFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; } - + int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age"); if (AgeableIdx > 0) { @@ -2525,7 +2525,7 @@ void cWSSAnvil::LoadPigFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB } Monster->SetAge(Age); } - + a_Entities.push_back(Monster.release()); } @@ -2551,12 +2551,12 @@ void cWSSAnvil::LoadRabbitFromNBT(cEntityList & a_Entities, const cParsedNBT & a { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; } - + int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age"); if (AgeableIdx > 0) { @@ -2569,7 +2569,7 @@ void cWSSAnvil::LoadRabbitFromNBT(cEntityList & a_Entities, const cParsedNBT & a } Monster->SetAge(Age); } - + a_Entities.push_back(Monster.release()); } @@ -2591,7 +2591,7 @@ void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -2602,7 +2602,7 @@ void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ { Monster->SetSheared(a_NBT.GetByte(ShearedIdx) != 0); } - + int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age"); if (AgeableIdx > 0) { @@ -2615,7 +2615,7 @@ void cWSSAnvil::LoadSheepFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ } Monster->SetAge(Age); } - + a_Entities.push_back(Monster.release()); } @@ -2630,7 +2630,7 @@ void cWSSAnvil::LoadSilverfishFromNBT(cEntityList & a_Entities, const cParsedNBT { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -2658,7 +2658,7 @@ void cWSSAnvil::LoadSkeletonFromNBT(cEntityList & a_Entities, const cParsedNBT & { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -2687,7 +2687,7 @@ void cWSSAnvil::LoadSlimeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -2707,7 +2707,7 @@ void cWSSAnvil::LoadSnowGolemFromNBT(cEntityList & a_Entities, const cParsedNBT { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -2727,7 +2727,7 @@ void cWSSAnvil::LoadSpiderFromNBT(cEntityList & a_Entities, const cParsedNBT & a { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -2747,7 +2747,7 @@ void cWSSAnvil::LoadSquidFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -2775,12 +2775,12 @@ void cWSSAnvil::LoadVillagerFromNBT(cEntityList & a_Entities, const cParsedNBT & { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; } - + int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age"); if (AgeableIdx > 0) { @@ -2793,8 +2793,8 @@ void cWSSAnvil::LoadVillagerFromNBT(cEntityList & a_Entities, const cParsedNBT & } Monster->SetAge(Age); } - - + + a_Entities.push_back(Monster.release()); } @@ -2809,7 +2809,7 @@ void cWSSAnvil::LoadWitchFromNBT(cEntityList & a_Entities, const cParsedNBT & a_ { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -2829,7 +2829,7 @@ void cWSSAnvil::LoadWitherFromNBT(cEntityList & a_Entities, const cParsedNBT & a { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; @@ -2859,7 +2859,7 @@ void cWSSAnvil::LoadWolfFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N { return; } - + LoadWolfOwner(*Monster.get(), a_NBT, a_TagIdx); int SittingIdx = a_NBT.FindChildByName(a_TagIdx, "Sitting"); @@ -2894,7 +2894,7 @@ void cWSSAnvil::LoadWolfFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N } } } - + int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age"); if (AgeableIdx > 0) { @@ -2907,7 +2907,7 @@ void cWSSAnvil::LoadWolfFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N } Monster->SetAge(Age); } - + a_Entities.push_back(Monster.release()); } @@ -2930,12 +2930,12 @@ void cWSSAnvil::LoadZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a { return; } - + if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx)) { return; } - + int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age"); if (AgeableIdx > 0) { @@ -2948,7 +2948,7 @@ void cWSSAnvil::LoadZombieFromNBT(cEntityList & a_Entities, const cParsedNBT & a } Monster->SetAge(Age); } - + a_Entities.push_back(Monster.release()); } @@ -2968,7 +2968,7 @@ void cWSSAnvil::LoadPigZombieFromNBT(cEntityList & a_Entities, const cParsedNBT { return; } - + int AgeableIdx = a_NBT.FindChildByName(a_TagIdx, "Age"); if (AgeableIdx > 0) { @@ -2981,7 +2981,7 @@ void cWSSAnvil::LoadPigZombieFromNBT(cEntityList & a_Entities, const cParsedNBT } Monster->SetAge(Age); } - + a_Entities.push_back(Monster.release()); } @@ -3008,7 +3008,7 @@ void cWSSAnvil::LoadWolfOwner(cWolf & a_Wolf, const cParsedNBT & a_NBT, int a_Ta // There is no owner, bail out: return; } - + // Convert name to UUID, if needed: if (OwnerUUID.empty()) { @@ -3026,7 +3026,7 @@ void cWSSAnvil::LoadWolfOwner(cWolf & a_Wolf, const cParsedNBT & a_NBT, int a_Ta // Normalize the UUID: OwnerUUID = cMojangAPI::MakeUUIDShort(OwnerUUID); } - + // Convert UUID to name, if needed: if (OwnerName.empty()) { @@ -3038,7 +3038,7 @@ void cWSSAnvil::LoadWolfOwner(cWolf & a_Wolf, const cParsedNBT & a_NBT, int a_Ta return; } } - + a_Wolf.SetOwner(OwnerName, OwnerUUID); a_Wolf.SetIsTame(true); } @@ -3055,7 +3055,7 @@ bool cWSSAnvil::LoadEntityBaseFromNBT(cEntity & a_Entity, const cParsedNBT & a_N return false; } a_Entity.SetPosition(Pos[0], Pos[1], Pos[2]); - + double Speed[3]; if (!LoadDoublesListFromNBT(Speed, 3, a_NBT, a_NBT.FindChildByName(a_TagIdx, "Motion"))) { @@ -3065,7 +3065,7 @@ bool cWSSAnvil::LoadEntityBaseFromNBT(cEntity & a_Entity, const cParsedNBT & a_N Speed[2] = 0; } a_Entity.SetSpeed(Speed[0], Speed[1], Speed[2]); - + double Rotation[3]; if (!LoadDoublesListFromNBT(Rotation, 2, a_NBT, a_NBT.FindChildByName(a_TagIdx, "Rotation"))) { @@ -3079,7 +3079,7 @@ bool cWSSAnvil::LoadEntityBaseFromNBT(cEntity & a_Entity, const cParsedNBT & a_N // Load health: int Health = a_NBT.FindChildByName(a_TagIdx, "Health"); a_Entity.SetHealth(Health > 0 ? a_NBT.GetShort(Health) : a_Entity.GetMaxHealth()); - + return true; } @@ -3133,7 +3133,7 @@ bool cWSSAnvil::LoadProjectileBaseFromNBT(cProjectileEntity & a_Entity, const cP { return false; } - + bool IsInGround = false; int InGroundIdx = a_NBT.FindChildByName(a_TagIdx, "inGround"); if (InGroundIdx > 0) @@ -3141,7 +3141,7 @@ bool cWSSAnvil::LoadProjectileBaseFromNBT(cProjectileEntity & a_Entity, const cP IsInGround = (a_NBT.GetByte(InGroundIdx) != 0); } a_Entity.SetIsInGround(IsInGround); - + return true; } @@ -3230,13 +3230,13 @@ cWSSAnvil::cMCAFile::cMCAFile(cWSSAnvil & a_ParentSchema, const AString & a_File bool cWSSAnvil::cMCAFile::OpenFile(bool a_IsForReading) { bool writeOutNeeded = false; - + if (m_File.IsOpen()) { // Already open return true; } - + if (a_IsForReading) { if (!cFile::Exists(m_FileName)) @@ -3245,13 +3245,13 @@ bool cWSSAnvil::cMCAFile::OpenFile(bool a_IsForReading) return false; } } - + if (!m_File.Open(m_FileName, cFile::fmReadWrite)) { // The file failed to open return false; } - + // Load the header: if (m_File.Read(m_Header, sizeof(m_Header)) != sizeof(m_Header)) { @@ -3269,7 +3269,7 @@ bool cWSSAnvil::cMCAFile::OpenFile(bool a_IsForReading) memset(m_TimeStamps, 0, sizeof(m_TimeStamps)); writeOutNeeded = true; } - + if (writeOutNeeded) { m_File.Seek(0); @@ -3296,7 +3296,7 @@ bool cWSSAnvil::cMCAFile::GetChunkData(const cChunkCoords & a_Chunk, AString & a { return false; } - + int LocalX = a_Chunk.m_ChunkX % 32; if (LocalX < 0) { @@ -3313,9 +3313,9 @@ bool cWSSAnvil::cMCAFile::GetChunkData(const cChunkCoords & a_Chunk, AString & a { return false; } - + m_File.Seek(static_cast<int>(ChunkOffset * 4096)); - + UInt32 ChunkSize = 0; if (m_File.Read(&ChunkSize, 4) != 4) { @@ -3337,7 +3337,7 @@ bool cWSSAnvil::cMCAFile::GetChunkData(const cChunkCoords & a_Chunk, AString & a return false; } ChunkSize--; - + a_Data = m_File.Read(ChunkSize); if (a_Data.size() != ChunkSize) { @@ -3376,7 +3376,7 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri { LocalZ = 32 + LocalZ; } - + unsigned ChunkSector = FindFreeLocation(LocalX, LocalZ, a_Data); // Store the chunk data: @@ -3398,7 +3398,7 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri LOGWARNING("Cannot save chunk [%d, %d], writing(3) data to file \"%s\" failed", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, GetFileName().c_str()); return false; } - + // Add padding to 4K boundary: size_t BytesWritten = a_Data.size() + MCA_CHUNK_HEADER_LENGTH; if (BytesWritten % 4096 != 0) @@ -3406,7 +3406,7 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri static const char Padding[4095] = {0}; m_File.Write(Padding, 4096 - (BytesWritten % 4096)); } - + // Store the header: ChunkSize = (static_cast<u_long>(a_Data.size()) + MCA_CHUNK_HEADER_LENGTH + 4095) / 4096; // Round data size up to nearest 4KB sector, make it a sector number if (ChunkSize > 255) @@ -3416,7 +3416,7 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri ); return false; } - + // Store the header info in the table m_Header[LocalX + 32 * LocalZ] = htonl((ChunkSector << 8) | ChunkSize); @@ -3438,7 +3438,7 @@ bool cWSSAnvil::cMCAFile::SetChunkData(const cChunkCoords & a_Chunk, const AStri LOGWARNING("Cannot save chunk [%d, %d], writing timestamps to file \"%s\" failed", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, GetFileName().c_str()); return false; } - + return true; } @@ -3455,7 +3455,7 @@ unsigned cWSSAnvil::cMCAFile::FindFreeLocation(int a_LocalX, int a_LocalZ, const { return ChunkLocation >> 8; } - + // Doesn't fit, append to the end of file (we're wasting a lot of space, TODO: fix this later) unsigned MaxLocation = 2 << 8; // Minimum sector is #2 - after the headers for (size_t i = 0; i < ARRAYCOUNT(m_Header); i++) |