diff options
| author | qwasdrizzel <145519042+qwasdrizzel@users.noreply.github.com> | 2026-03-16 21:44:26 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-16 21:44:26 -0500 |
| commit | ce739f6045ec72127491286ea3f3f21e537c1b55 (patch) | |
| tree | f33bd42a47c1b4a7b2153a7fb77127ee3b407db9 /Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp | |
| parent | 255a18fe8e9b57377975f82e2b227afe2a12eda0 (diff) | |
| parent | 5a59f5d146b43811dde6a5a0245ee9875d7b5cd1 (diff) | |
Merge branch 'smartcmd:main' into main
Diffstat (limited to 'Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp')
| -rw-r--r-- | Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp b/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp index 01a8119e..c261e0cd 100644 --- a/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp +++ b/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp @@ -16,18 +16,18 @@ ConsoleSchematicFile::ConsoleSchematicFile() { m_xSize = m_ySize = m_zSize = 0; m_refCount = 1; - m_data.data = NULL; + m_data.data = nullptr; } ConsoleSchematicFile::~ConsoleSchematicFile() { app.DebugPrintf("Deleting schematic file\n"); - if(m_data.data != NULL) delete [] m_data.data; + if(m_data.data != nullptr) delete [] m_data.data; } void ConsoleSchematicFile::save(DataOutputStream *dos) { - if(dos != NULL) + if(dos != nullptr) { dos->writeInt(XBOX_SCHEMATIC_CURRENT_VERSION); @@ -38,7 +38,7 @@ void ConsoleSchematicFile::save(DataOutputStream *dos) dos->writeInt(m_zSize); byteArray ba(new BYTE[ m_data.length ], m_data.length); - Compression::getCompression()->CompressLZXRLE( ba.data, &ba.length, + Compression::getCompression()->CompressLZXRLE( ba.data, &ba.length, m_data.data, m_data.length); dos->writeInt(ba.length); @@ -52,7 +52,7 @@ void ConsoleSchematicFile::save(DataOutputStream *dos) void ConsoleSchematicFile::load(DataInputStream *dis) { - if(dis != NULL) + if(dis != nullptr) { // VERSION CHECK // int version = dis->readInt(); @@ -61,7 +61,7 @@ void ConsoleSchematicFile::load(DataInputStream *dis) if (version > XBOX_SCHEMATIC_ORIGINAL_VERSION) // Or later versions { - compressionType = (Compression::ECompressionTypes)dis->readByte(); + compressionType = static_cast<Compression::ECompressionTypes>(dis->readByte()); } if (version > XBOX_SCHEMATIC_CURRENT_VERSION) @@ -71,14 +71,14 @@ void ConsoleSchematicFile::load(DataInputStream *dis) m_ySize = dis->readInt(); m_zSize = dis->readInt(); - int compressedSize = dis->readInt(); + int compressedSize = dis->readInt(); byteArray compressedBuffer(compressedSize); dis->readFully(compressedBuffer); - if(m_data.data != NULL) + if(m_data.data != nullptr) { delete [] m_data.data; - m_data.data = NULL; + m_data.data = nullptr; } if(compressionType == Compression::eCompressionType_None) @@ -111,17 +111,17 @@ void ConsoleSchematicFile::load(DataInputStream *dis) // READ TAGS // CompoundTag *tag = NbtIo::read(dis); ListTag<CompoundTag> *tileEntityTags = (ListTag<CompoundTag> *) tag->getList(L"TileEntities"); - if (tileEntityTags != NULL) + if (tileEntityTags != nullptr) { for (int i = 0; i < tileEntityTags->size(); i++) { CompoundTag *teTag = tileEntityTags->get(i); shared_ptr<TileEntity> te = TileEntity::loadStatic(teTag); - if(te == NULL) + if(te == nullptr) { #ifndef _CONTENT_PACKAGE - app.DebugPrintf("ConsoleSchematicFile has read a NULL tile entity\n"); + app.DebugPrintf("ConsoleSchematicFile has read a nullptr tile entity\n"); __debugbreak(); #endif } @@ -132,7 +132,7 @@ void ConsoleSchematicFile::load(DataInputStream *dis) } } ListTag<CompoundTag> *entityTags = (ListTag<CompoundTag> *) tag->getList(L"Entities"); - if (entityTags != NULL) + if (entityTags != nullptr) { for (int i = 0; i < entityTags->size(); i++) { @@ -145,15 +145,15 @@ void ConsoleSchematicFile::load(DataInputStream *dis) double z = pos->get(2)->data; if( type == eTYPE_PAINTING || type == eTYPE_ITEM_FRAME ) - { - x = ((IntTag *) eTag->get(L"TileX") )->data; - y = ((IntTag *) eTag->get(L"TileY") )->data; - z = ((IntTag *) eTag->get(L"TileZ") )->data; - } + { + x = static_cast<IntTag *>(eTag->get(L"TileX"))->data; + y = static_cast<IntTag *>(eTag->get(L"TileY"))->data; + z = static_cast<IntTag *>(eTag->get(L"TileZ"))->data; + } #ifdef _DEBUG //app.DebugPrintf(1,"Loaded entity type %d at (%f,%f,%f)\n",(int)type,x,y,z); #endif - m_entities.push_back( pair<Vec3 *, CompoundTag *>(Vec3::newPermanent(x,y,z),(CompoundTag *)eTag->copy())); + m_entities.push_back( pair<Vec3 *, CompoundTag *>(Vec3::newPermanent(x,y,z),static_cast<CompoundTag *>(eTag->copy()))); } } delete tag; @@ -178,23 +178,23 @@ void ConsoleSchematicFile::save_tags(DataOutputStream *dos) tag->put(L"Entities", entityTags); for (auto& it : m_entities ) - entityTags->add( (CompoundTag *)(it).second->copy() ); + entityTags->add( static_cast<CompoundTag *>((it).second->copy()) ); NbtIo::write(tag,dos); delete tag; } -__int64 ConsoleSchematicFile::applyBlocksAndData(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot) +int64_t ConsoleSchematicFile::applyBlocksAndData(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot) { - int xStart = static_cast<int>(std::fmax<double>(destinationBox->x0, (double)chunk->x*16)); - int xEnd = static_cast<int>(std::fmin<double>(destinationBox->x1, (double)((xStart >> 4) << 4) + 16)); + int xStart = static_cast<int>(std::fmax<double>(destinationBox->x0, static_cast<double>(chunk->x)*16)); + int xEnd = static_cast<int>(std::fmin<double>(destinationBox->x1, static_cast<double>((xStart >> 4) << 4) + 16)); int yStart = destinationBox->y0; int yEnd = destinationBox->y1; if(yEnd > Level::maxBuildHeight) yEnd = Level::maxBuildHeight; - int zStart = static_cast<int>(std::fmax<double>(destinationBox->z0, (double)chunk->z * 16)); - int zEnd = static_cast<int>(std::fmin<double>(destinationBox->z1, (double)((zStart >> 4) << 4) + 16)); + int zStart = static_cast<int>(std::fmax<double>(destinationBox->z0, static_cast<double>(chunk->z) * 16)); + int zEnd = static_cast<int>(std::fmin<double>(destinationBox->z1, static_cast<double>((zStart >> 4) << 4) + 16)); #ifdef _DEBUG app.DebugPrintf("Range is (%d,%d,%d) to (%d,%d,%d)\n",xStart,yStart,zStart,xEnd-1,yEnd-1,zEnd-1); @@ -281,7 +281,7 @@ __int64 ConsoleSchematicFile::applyBlocksAndData(LevelChunk *chunk, AABB *chunkB // blockData[i] = Tile::endStone_Id; // } //} - + PIXBeginNamedEvent(0,"Setting Block data"); chunk->setBlockData(blockData); PIXEndNamedEvent(); @@ -323,7 +323,7 @@ __int64 ConsoleSchematicFile::applyBlocksAndData(LevelChunk *chunk, AABB *chunkB // At the point that this is called, we have all the neighbouring chunks loaded in (and generally post-processed, apart from this lighting pass), so // we can do the sort of lighting that might propagate out of the chunk. -__int64 ConsoleSchematicFile::applyLighting(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot) +int64_t ConsoleSchematicFile::applyLighting(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot) { int xStart = max(destinationBox->x0, (double)chunk->x*16); int xEnd = min(destinationBox->x1, (double)((xStart>>4)<<4) + 16); @@ -442,9 +442,9 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk *chunk, AABB *chunkBox, Vec3 *pos = Vec3::newTemp(targetX,targetY,targetZ); if( chunkBox->containsIncludingLowerBound(pos) ) { - shared_ptr<TileEntity> teCopy = chunk->getTileEntity( (int)targetX & 15, (int)targetY & 15, (int)targetZ & 15 ); + shared_ptr<TileEntity> teCopy = chunk->getTileEntity( static_cast<int>(targetX) & 15, static_cast<int>(targetY) & 15, static_cast<int>(targetZ) & 15 ); - if ( teCopy != NULL ) + if ( teCopy != nullptr ) { CompoundTag *teData = new CompoundTag(); te->save(teData); @@ -478,7 +478,7 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk *chunk, AABB *chunkBox, for (auto it = m_entities.begin(); it != m_entities.end();) { Vec3 *source = it->first; - + double targetX = source->x; double targetY = source->y + destinationBox->y0; double targetZ = source->z; @@ -493,12 +493,12 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk *chunk, AABB *chunkBox, } CompoundTag *eTag = it->second; - shared_ptr<Entity> e = EntityIO::loadStatic(eTag, NULL); + shared_ptr<Entity> e = EntityIO::loadStatic(eTag, nullptr); if( e->GetType() == eTYPE_PAINTING ) { shared_ptr<Painting> painting = dynamic_pointer_cast<Painting>(e); - + double tileX = painting->xTile; double tileZ = painting->zTile; schematicCoordToChunkCoord(destinationBox, painting->xTile, painting->zTile, rot, tileX, tileZ); @@ -511,7 +511,7 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk *chunk, AABB *chunkBox, else if( e->GetType() == eTYPE_ITEM_FRAME ) { shared_ptr<ItemFrame> frame = dynamic_pointer_cast<ItemFrame>(e); - + double tileX = frame->xTile; double tileZ = frame->zTile; schematicCoordToChunkCoord(destinationBox, frame->xTile, frame->zTile, rot, tileX, tileZ); @@ -559,7 +559,7 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l zStart-=1; else if(zStart < 0 && zStart%2 !=0) zStart-=1; - + // We want the end to be odd to have a total size that is even if(xEnd > 0 && xEnd%2 == 0) xEnd+=1; @@ -582,18 +582,18 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l app.DebugPrintf("Generating schematic file for area (%d,%d,%d) to (%d,%d,%d), %dx%dx%d\n",xStart,yStart,zStart,xEnd,yEnd,zEnd,xSize,ySize,zSize); - if(dos != NULL) dos->writeInt(XBOX_SCHEMATIC_CURRENT_VERSION); + if(dos != nullptr) dos->writeInt(XBOX_SCHEMATIC_CURRENT_VERSION); - if(dos != NULL) dos->writeByte(compressionType); + if(dos != nullptr) dos->writeByte(compressionType); //Write xSize - if(dos != NULL) dos->writeInt(xSize); + if(dos != nullptr) dos->writeInt(xSize); //Write ySize - if(dos != NULL) dos->writeInt(ySize); + if(dos != nullptr) dos->writeInt(ySize); //Write zSize - if(dos != NULL) dos->writeInt(zSize); + if(dos != nullptr) dos->writeInt(zSize); //byteArray rawBuffer = level->getBlocksAndData(xStart, yStart, zStart, xSize, ySize, zSize, false); int xRowSize = ySize * zSize; @@ -613,7 +613,7 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l // Every x is a whole row for(int xPos = xStart; xPos < xStart + xSize; ++xPos) - { + { int xc = xPos >> 4; int x0 = xPos - xc * 16; @@ -622,7 +622,7 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l if (x1 > 16) x1 = 16; for(int zPos = zStart; zPos < zStart + zSize;) - { + { int zc = zPos >> 4; int z0 = zStart - zc * 16; @@ -660,8 +660,8 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l delete [] result.data; byteArray buffer = byteArray(ucTemp,inputSize); - if(dos != NULL) dos->writeInt(inputSize); - if(dos != NULL) dos->write(buffer); + if(dos != nullptr) dos->writeInt(inputSize); + if(dos != nullptr) dos->write(buffer); delete [] buffer.data; CompoundTag tag; @@ -713,11 +713,11 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l } // 4J-JEV: Changed to check for instances of minecarts and hangingEntities instead of just eTYPE_PAINTING, eTYPE_ITEM_FRAME and eTYPE_MINECART - if (mobCanBeSaved || e->instanceof(eTYPE_MINECART) || e->GetType() == eTYPE_BOAT || e->instanceof(eTYPE_HANGING_ENTITY)) + if (mobCanBeSaved || e->instanceof(eTYPE_MINECART) || e->GetType() == eTYPE_BOAT || e->instanceof(eTYPE_HANGING_ENTITY)) { CompoundTag *eTag = new CompoundTag(); if( e->save(eTag) ) - { + { ListTag<DoubleTag> *pos = (ListTag<DoubleTag> *) eTag->getList(L"Pos"); pos->get(0)->data -= xStart; @@ -726,9 +726,9 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l if( e->instanceof(eTYPE_HANGING_ENTITY) ) { - ((IntTag *) eTag->get(L"TileX") )->data -= xStart; - ((IntTag *) eTag->get(L"TileY") )->data -= yStart; - ((IntTag *) eTag->get(L"TileZ") )->data -= zStart; + static_cast<IntTag *>(eTag->get(L"TileX"))->data -= xStart; + static_cast<IntTag *>(eTag->get(L"TileY"))->data -= yStart; + static_cast<IntTag *>(eTag->get(L"TileZ"))->data -= zStart; } entitiesTag->add(eTag); @@ -738,7 +738,7 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l tag.put(L"Entities", entitiesTag); - if(dos != NULL) NbtIo::write(&tag,dos); + if(dos != nullptr) NbtIo::write(&tag,dos); } void ConsoleSchematicFile::getBlocksAndData(LevelChunk *chunk, byteArray *data, int x0, int y0, int z0, int x1, int y1, int z1, int &blocksP, int &dataP, int &blockLightP, int &skyLightP) @@ -766,7 +766,7 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk *chunk, byteArray *data, // skyLightP += skyLightData.length; // return; //} - + bool bHasLower, bHasUpper; bHasLower = bHasUpper = false; int lowerY0, lowerY1, upperY0, upperY1; |
