diff options
| author | Loki Rautio <lokirautio@gmail.com> | 2026-03-07 21:12:22 -0600 |
|---|---|---|
| committer | Loki Rautio <lokirautio@gmail.com> | 2026-03-07 21:12:22 -0600 |
| commit | 087b7e7abfe81dd7f0fdcdea36ac9f245950df1a (patch) | |
| tree | 69454763e73ca764af4e682d3573080b13138a0e /Minecraft.World/VillagePieces.cpp | |
| parent | a9be52c41a02d207233199e98898fe7483d7e817 (diff) | |
Revert "Project modernization (#630)"
This code was not tested and breaks in Release builds, reverting to restore
functionality of the nightly. All in-game menus do not work and generating
a world crashes.
This reverts commit a9be52c41a02d207233199e98898fe7483d7e817.
Diffstat (limited to 'Minecraft.World/VillagePieces.cpp')
| -rw-r--r-- | Minecraft.World/VillagePieces.cpp | 120 |
1 files changed, 60 insertions, 60 deletions
diff --git a/Minecraft.World/VillagePieces.cpp b/Minecraft.World/VillagePieces.cpp index dcd765e0..1737d6e0 100644 --- a/Minecraft.World/VillagePieces.cpp +++ b/Minecraft.World/VillagePieces.cpp @@ -101,7 +101,7 @@ int VillagePieces::updatePieceWeight(list<PieceWeight *> *currentPieces) VillagePieces::VillagePiece *VillagePieces::findAndCreatePieceFactory(StartPiece *startPiece, VillagePieces::PieceWeight *piece, list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth) { VillagePieces::EPieceClass pieceClass = piece->pieceClass; - VillagePiece *villagePiece = nullptr; + VillagePiece *villagePiece = NULL; if (pieceClass == VillagePieces::EPieceClass_SimpleHouse) { @@ -148,7 +148,7 @@ VillagePieces::VillagePiece *VillagePieces::generatePieceFromSmallDoor(StartPiec int totalWeight = updatePieceWeight(startPiece->pieceSet); if (totalWeight <= 0) { - return nullptr; + return NULL; } int numAttempts = 0; @@ -168,7 +168,7 @@ VillagePieces::VillagePiece *VillagePieces::generatePieceFromSmallDoor(StartPiec } VillagePiece *villagePiece = findAndCreatePieceFactory(startPiece, piece, pieces, random, footX, footY, footZ, direction, depth); - if (villagePiece != nullptr) + if (villagePiece != NULL) { piece->placeCount++; startPiece->previousPiece = piece; @@ -186,29 +186,29 @@ VillagePieces::VillagePiece *VillagePieces::generatePieceFromSmallDoor(StartPiec // attempt to place a light post instead { BoundingBox *box = LightPost::findPieceBox(startPiece, pieces, random, footX, footY, footZ, direction); - if (box != nullptr) + if (box != NULL) { return new LightPost(startPiece, depth, random, box, direction); } delete box; } - return nullptr; + return NULL; } StructurePiece *VillagePieces::generateAndAddPiece(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth) { if (depth > MAX_DEPTH) { - return nullptr; + return NULL; } if (abs(footX - startPiece->getBoundingBox()->x0) > 7 * 16 || abs(footZ - startPiece->getBoundingBox()->z0) > 7 * 16) { - return nullptr; + return NULL; } StructurePiece *newPiece = generatePieceFromSmallDoor(startPiece, pieces, random, footX, footY, footZ, direction, depth + 1); - if (newPiece != nullptr) + if (newPiece != NULL) { int x = (newPiece->boundingBox->x0 + newPiece->boundingBox->x1) / 2; int z = (newPiece->boundingBox->z0 + newPiece->boundingBox->z1) / 2; @@ -223,22 +223,22 @@ StructurePiece *VillagePieces::generateAndAddPiece(StartPiece *startPiece, list< } delete newPiece; } - return nullptr; + return NULL; } StructurePiece *VillagePieces::generateAndAddRoadPiece(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int footX, int footY, int footZ, int direction, int depth) { if (depth > BASE_ROAD_DEPTH + startPiece->villageSize) { - return nullptr; + return NULL; } if (abs(footX - startPiece->getBoundingBox()->x0) > 7 * 16 || abs(footZ - startPiece->getBoundingBox()->z0) > 7 * 16) { - return nullptr; + return NULL; } BoundingBox *box = StraightRoad::findPieceBox(startPiece, pieces, random, footX, footY, footZ, direction); - if (box != nullptr && box->y0 > LOWEST_Y_POSITION) + if (box != NULL && box->y0 > LOWEST_Y_POSITION) { StructurePiece *newPiece = new StraightRoad(startPiece, depth, random, box, direction); int x = (newPiece->boundingBox->x0 + newPiece->boundingBox->x1) / 2; @@ -255,12 +255,12 @@ StructurePiece *VillagePieces::generateAndAddRoadPiece(StartPiece *startPiece, l // 4J Stu - The dtor for newPiece will destroy box delete newPiece; } - else if(box != nullptr) + else if(box != NULL) { delete box; } - return nullptr; + return NULL; } VillagePieces::VillagePiece::VillagePiece() @@ -268,7 +268,7 @@ VillagePieces::VillagePiece::VillagePiece() heightPosition = -1; spawnedVillagerCount = 0; isDesertVillage = false; - startPiece = nullptr; + startPiece = NULL; // for reflection } @@ -278,7 +278,7 @@ VillagePieces::VillagePiece::VillagePiece(StartPiece *startPiece, int genDepth) isDesertVillage = false; spawnedVillagerCount = 0; this->startPiece = startPiece; - if (startPiece != nullptr) + if (startPiece != NULL) { this->isDesertVillage = startPiece->isDesertVillage; } @@ -311,7 +311,7 @@ StructurePiece *VillagePieces::VillagePiece::generateHouseNorthernLeft(StartPiec case Direction::EAST: return generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 + zOff, boundingBox->y0 + yOff, boundingBox->z0 - 1, Direction::NORTH, getGenDepth()); } - return nullptr; + return NULL; } StructurePiece *VillagePieces::VillagePiece::generateHouseNorthernRight(StartPiece *startPiece, list<StructurePiece *> *pieces, Random *random, int yOff, int zOff) @@ -327,7 +327,7 @@ StructurePiece *VillagePieces::VillagePiece::generateHouseNorthernRight(StartPie case Direction::EAST: return generateAndAddPiece(startPiece, pieces, random, boundingBox->x0 + zOff, boundingBox->y0 + yOff, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth()); } - return nullptr; + return NULL; } int VillagePieces::VillagePiece::getAverageGroundHeight(Level *level, BoundingBox *chunkBB) @@ -357,7 +357,7 @@ bool VillagePieces::VillagePiece::isOkBox(BoundingBox *box, StartPiece *startRoo { bool bIsOk = false; - if(box != nullptr) + if(box != NULL) { if( box->y0 > LOWEST_Y_POSITION ) bIsOk = true; @@ -391,7 +391,7 @@ void VillagePieces::VillagePiece::spawnVillagers(Level *level, BoundingBox *chun { spawnedVillagerCount++; - shared_ptr<Villager> villager = std::make_shared<Villager>(level, getVillagerProfession(i)); + shared_ptr<Villager> villager = shared_ptr<Villager>(new Villager(level, getVillagerProfession(i))); villager->moveTo(worldX + 0.5, worldY, worldZ + 0.5, 0, 0); level->addEntity(villager); } @@ -512,10 +512,10 @@ VillagePieces::Well::Well(StartPiece *startPiece, int genDepth, Random *random, void VillagePieces::Well::addChildren(StructurePiece *startPiece, list<StructurePiece *> *pieces, Random *random) { - generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x0 - 1, boundingBox->y1 - 4, boundingBox->z0 + 1, Direction::WEST, getGenDepth()); - generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x1 + 1, boundingBox->y1 - 4, boundingBox->z0 + 1, Direction::EAST, getGenDepth()); - generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x0 + 1, boundingBox->y1 - 4, boundingBox->z0 - 1, Direction::NORTH, getGenDepth()); - generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x0 + 1, boundingBox->y1 - 4, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth()); + generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x0 - 1, boundingBox->y1 - 4, boundingBox->z0 + 1, Direction::WEST, getGenDepth()); + generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x1 + 1, boundingBox->y1 - 4, boundingBox->z0 + 1, Direction::EAST, getGenDepth()); + generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x0 + 1, boundingBox->y1 - 4, boundingBox->z0 - 1, Direction::NORTH, getGenDepth()); + generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x0 + 1, boundingBox->y1 - 4, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth()); } bool VillagePieces::Well::postProcess(Level *level, Random *random, BoundingBox *chunkBB) @@ -569,10 +569,10 @@ VillagePieces::StartPiece::StartPiece() // for reflection } -VillagePieces::StartPiece::StartPiece(BiomeSource *biomeSource, int genDepth, Random *random, int west, int north, list<PieceWeight *> *pieceSet, int villageSize, Level *level) : Well(nullptr, 0, random, west, north) +VillagePieces::StartPiece::StartPiece(BiomeSource *biomeSource, int genDepth, Random *random, int west, int north, list<PieceWeight *> *pieceSet, int villageSize, Level *level) : Well(NULL, 0, random, west, north) { isLibraryAdded = false; // 4J - added initialiser - previousPiece = nullptr; // 4J - added initialiser + previousPiece = NULL; // 4J - added initialiser this->biomeSource = biomeSource; this->pieceSet = pieceSet; this->villageSize = villageSize; @@ -628,8 +628,8 @@ void VillagePieces::StraightRoad::addChildren(StructurePiece *startPiece, list<S int depth = random->nextInt(5); while (depth < length - 8) { - StructurePiece *piece = generateHouseNorthernLeft(static_cast<StartPiece *>(startPiece), pieces, random, 0, depth); - if (piece != nullptr) + StructurePiece *piece = generateHouseNorthernLeft((StartPiece *) startPiece, pieces, random, 0, depth); + if (piece != NULL) { depth += Math::_max(piece->boundingBox->getXSpan(), piece->boundingBox->getZSpan()); hasHouses = true; @@ -641,8 +641,8 @@ void VillagePieces::StraightRoad::addChildren(StructurePiece *startPiece, list<S depth = random->nextInt(5); while (depth < length - 8) { - StructurePiece *piece = generateHouseNorthernRight(static_cast<StartPiece *>(startPiece), pieces, random, 0, depth); - if (piece != nullptr) + StructurePiece *piece = generateHouseNorthernRight((StartPiece *) startPiece, pieces, random, 0, depth); + if (piece != NULL) { depth += Math::_max(piece->boundingBox->getXSpan(), piece->boundingBox->getZSpan()); hasHouses = true; @@ -655,16 +655,16 @@ void VillagePieces::StraightRoad::addChildren(StructurePiece *startPiece, list<S switch (orientation) { case Direction::NORTH: - generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x0 - 1, boundingBox->y0, boundingBox->z0, Direction::WEST, getGenDepth()); + generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x0 - 1, boundingBox->y0, boundingBox->z0, Direction::WEST, getGenDepth()); break; case Direction::SOUTH: - generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x0 - 1, boundingBox->y0, boundingBox->z1 - 2, Direction::WEST, getGenDepth()); + generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x0 - 1, boundingBox->y0, boundingBox->z1 - 2, Direction::WEST, getGenDepth()); break; case Direction::EAST: - generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x1 - 2, boundingBox->y0, boundingBox->z0 - 1, Direction::NORTH, getGenDepth()); + generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x1 - 2, boundingBox->y0, boundingBox->z0 - 1, Direction::NORTH, getGenDepth()); break; case Direction::WEST: - generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x0, boundingBox->y0, boundingBox->z0 - 1, Direction::NORTH, getGenDepth()); + generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x0, boundingBox->y0, boundingBox->z0 - 1, Direction::NORTH, getGenDepth()); break; } } @@ -673,16 +673,16 @@ void VillagePieces::StraightRoad::addChildren(StructurePiece *startPiece, list<S switch (orientation) { case Direction::NORTH: - generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x1 + 1, boundingBox->y0, boundingBox->z0, Direction::EAST, getGenDepth()); + generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x1 + 1, boundingBox->y0, boundingBox->z0, Direction::EAST, getGenDepth()); break; case Direction::SOUTH: - generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x1 + 1, boundingBox->y0, boundingBox->z1 - 2, Direction::EAST, getGenDepth()); + generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x1 + 1, boundingBox->y0, boundingBox->z1 - 2, Direction::EAST, getGenDepth()); break; case Direction::EAST: - generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x1 - 2, boundingBox->y0, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth()); + generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x1 - 2, boundingBox->y0, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth()); break; case Direction::WEST: - generateAndAddRoadPiece(static_cast<StartPiece *>(startPiece), pieces, random, boundingBox->x0, boundingBox->y0, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth()); + generateAndAddRoadPiece((StartPiece *) startPiece, pieces, random, boundingBox->x0, boundingBox->y0, boundingBox->z1 + 1, Direction::SOUTH, getGenDepth()); break; } } @@ -696,7 +696,7 @@ BoundingBox *VillagePieces::StraightRoad::findPieceBox(StartPiece *startPiece, l { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, 3, length, direction); - if (isOkBox(box, startPiece) && StructurePiece::findCollisionPiece(pieces, box) == nullptr) + if (isOkBox(box, startPiece) && StructurePiece::findCollisionPiece(pieces, box) == NULL) { return box; } @@ -704,7 +704,7 @@ BoundingBox *VillagePieces::StraightRoad::findPieceBox(StartPiece *startPiece, l length -= 7; } - return nullptr; + return NULL; } bool VillagePieces::StraightRoad::postProcess(Level *level, Random *random, BoundingBox *chunkBB) @@ -753,10 +753,10 @@ VillagePieces::SimpleHouse *VillagePieces::SimpleHouse::createPiece(StartPiece * { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { delete box; - return nullptr; + return NULL; } return new SimpleHouse(startPiece, genDepth, random, box, direction); @@ -880,10 +880,10 @@ VillagePieces::SmallTemple *VillagePieces::SmallTemple::createPiece(StartPiece * { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { delete box; - return nullptr; + return NULL; } return new SmallTemple(startPiece, genDepth, random, box, direction); @@ -1022,10 +1022,10 @@ VillagePieces::BookHouse *VillagePieces::BookHouse::createPiece(StartPiece *star { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { delete box; - return nullptr; + return NULL; } return new BookHouse(startPiece, genDepth, random, box, direction); @@ -1178,10 +1178,10 @@ VillagePieces::SmallHut *VillagePieces::SmallHut::createPiece(StartPiece *startP { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { delete box; - return nullptr; + return NULL; } return new SmallHut(startPiece, genDepth, random, box, direction); @@ -1284,10 +1284,10 @@ VillagePieces::PigHouse *VillagePieces::PigHouse::createPiece(StartPiece *startP BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { delete box; - return nullptr; + return NULL; } return new PigHouse(startPiece, genDepth, random, box, direction); @@ -1429,10 +1429,10 @@ VillagePieces::TwoRoomHouse *VillagePieces::TwoRoomHouse::createPiece(StartPiece { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { delete box; - return nullptr; + return NULL; } return new TwoRoomHouse(startPiece, genDepth, random, box, direction); @@ -1619,10 +1619,10 @@ VillagePieces::Smithy *VillagePieces::Smithy::createPiece(StartPiece *startPiece { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { delete box; - return nullptr; + return NULL; } return new Smithy(startPiece, genDepth, random, box, direction); @@ -1790,10 +1790,10 @@ VillagePieces::Farmland *VillagePieces::Farmland::createPiece(StartPiece *startP { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { delete box; - return nullptr; + return NULL; } return new Farmland(startPiece, genDepth, random, box, direction); @@ -1902,10 +1902,10 @@ VillagePieces::DoubleFarmland *VillagePieces::DoubleFarmland::createPiece(StartP { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { delete box; - return nullptr; + return NULL; } return new DoubleFarmland(startPiece, genDepth, random, box, direction); @@ -1983,10 +1983,10 @@ BoundingBox *VillagePieces::LightPost::findPieceBox(StartPiece *startPiece, list { BoundingBox *box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, width, height, depth, direction); - if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != nullptr) + if (!isOkBox(box, startPiece) || StructurePiece::findCollisionPiece(pieces, box) != NULL) { delete box; - return nullptr; + return NULL; } return box; |
