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/RandomLevelSource.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/RandomLevelSource.cpp')
| -rw-r--r-- | Minecraft.World/RandomLevelSource.cpp | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/Minecraft.World/RandomLevelSource.cpp b/Minecraft.World/RandomLevelSource.cpp index a0e7a94b..ae06c1f8 100644 --- a/Minecraft.World/RandomLevelSource.cpp +++ b/Minecraft.World/RandomLevelSource.cpp @@ -58,8 +58,8 @@ RandomLevelSource::RandomLevelSource(Level *level, int64_t seed, bool generateSt } else { - floatingIslandScale = nullptr; - floatingIslandNoise = nullptr; + floatingIslandScale = NULL; + floatingIslandNoise = NULL; } forestNoise = new PerlinNoise(random, 8); @@ -93,7 +93,7 @@ RandomLevelSource::~RandomLevelSource() delete forestNoise; - if( pows.data != nullptr ) delete [] pows.data; + if( pows.data != NULL ) delete [] pows.data; } @@ -187,7 +187,7 @@ float RandomLevelSource::getHeightFalloff(int xxx, int zzz, int* pEMin) if( emin < falloffStart ) { int falloff = falloffStart - emin; - comp = (static_cast<float>(falloff) / static_cast<float>(falloffStart) ) * falloffMax; + comp = ((float)falloff / (float)falloffStart ) * falloffMax; } *pEMin = emin; return comp; @@ -267,7 +267,7 @@ void RandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks) { for (int yc = 0; yc < yChunks; yc++) { - double yStep = 1 / static_cast<double>(CHUNK_HEIGHT); + double yStep = 1 / (double) CHUNK_HEIGHT; double s0 = buffer[((xc + 0) * zSize + (zc + 0)) * ySize + (yc + 0)]; double s1 = buffer[((xc + 0) * zSize + (zc + 1)) * ySize + (yc + 0)]; double s2 = buffer[((xc + 1) * zSize + (zc + 0)) * ySize + (yc + 0)]; @@ -280,7 +280,7 @@ void RandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks) for (int y = 0; y < CHUNK_HEIGHT; y++) { - double xStep = 1 / static_cast<double>(CHUNK_WIDTH); + double xStep = 1 / (double) CHUNK_WIDTH; double _s0 = s0; double _s1 = s1; @@ -292,7 +292,7 @@ void RandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks) int offs = (x + xc * CHUNK_WIDTH) << Level::genDepthBitsPlusFour | (0 + zc * CHUNK_WIDTH) << Level::genDepthBits | (yc * CHUNK_HEIGHT + y); int step = 1 << Level::genDepthBits; offs -= step; - double zStep = 1 / static_cast<double>(CHUNK_WIDTH); + double zStep = 1 / (double) CHUNK_WIDTH; double val = _s0; double vala = (_s1 - _s0) * zStep; @@ -315,11 +315,11 @@ void RandomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks) // 4J - this comparison used to just be with 0.0f but is now varied by block above if ((val += vala) > comp) { - tileId = static_cast<byte>(Tile::stone_Id); + tileId = (byte) Tile::stone_Id; } else if (yc * CHUNK_HEIGHT + y < waterHeight) { - tileId = static_cast<byte>(Tile::calmWater_Id); + tileId = (byte) Tile::calmWater_Id; } // 4J - more extra code to make sure that the column at the edge of the world is just water & rock, to match the infinite sea that @@ -377,7 +377,7 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi { Biome *b = biomes[z + x * 16]; float temp = b->getTemperature(); - int runDepth = static_cast<int>(depthBuffer[x + z * 16] / 3 + 3 + random->nextDouble() * 0.25); + int runDepth = (int) (depthBuffer[x + z * 16] / 3 + 3 + random->nextDouble() * 0.25); int run = -1; @@ -385,7 +385,7 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi byte material = b->material; LevelGenerationOptions *lgo = app.getLevelGenerationOptions(); - if(lgo != nullptr) + if(lgo != NULL) { lgo->getBiomeOverride(b->id,material,top); } @@ -397,7 +397,7 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi if (y <= 1 + random->nextInt(2)) // 4J - changed to make the bedrock not have bits you can get stuck in // if (y <= 0 + random->nextInt(5)) { - blocks[offs] = static_cast<byte>(Tile::unbreakable_Id); + blocks[offs] = (byte) Tile::unbreakable_Id; } else { @@ -414,13 +414,13 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi if (runDepth <= 0) { top = 0; - material = static_cast<byte>(Tile::stone_Id); + material = (byte) Tile::stone_Id; } else if (y >= waterHeight - 4 && y <= waterHeight + 1) { top = b->topMaterial; material = b->material; - if(lgo != nullptr) + if(lgo != NULL) { lgo->getBiomeOverride(b->id,material,top); } @@ -428,8 +428,8 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi if (y < waterHeight && top == 0) { - if (temp < 0.15f) top = static_cast<byte>(Tile::ice_Id); - else top = static_cast<byte>(Tile::calmWater_Id); + if (temp < 0.15f) top = (byte) Tile::ice_Id; + else top = (byte) Tile::calmWater_Id; } run = runDepth; @@ -445,7 +445,7 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi if (run == 0 && material == Tile::sand_Id) { run = random->nextInt(4); - material = static_cast<byte>(Tile::sandStone_Id); + material = (byte) Tile::sandStone_Id; } } } @@ -469,7 +469,7 @@ LevelChunk *RandomLevelSource::getChunk(int xOffs, int zOffs) // 4J - now allocating this with a physical alloc & bypassing general memory management so that it will get cleanly freed int blocksSize = Level::genDepth * 16 * 16; - byte *tileData = static_cast<byte *>(XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, PAGE_READWRITE)); + byte *tileData = (byte *)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, PAGE_READWRITE); XMemSet128(tileData,0,blocksSize); byteArray blocks = byteArray(tileData,blocksSize); // byteArray blocks = byteArray(16 * level->depth * 16); @@ -525,11 +525,11 @@ void RandomLevelSource::lightChunk(LevelChunk *lc) doubleArray RandomLevelSource::getHeights(doubleArray buffer, int x, int y, int z, int xSize, int ySize, int zSize, BiomeArray& biomes) { - if (buffer.data == nullptr) + if (buffer.data == NULL) { buffer = doubleArray(xSize * ySize * zSize); } - if (pows.data == nullptr) + if (pows.data == NULL) { pows = floatArray(5 * 5); for (int xb = -2; xb <= 2; xb++) @@ -882,9 +882,9 @@ wstring RandomLevelSource::gatherStats() vector<Biome::MobSpawnerData *> *RandomLevelSource::getMobsAt(MobCategory *mobCategory, int x, int y, int z) { Biome *biome = level->getBiome(x, z); - if (biome == nullptr) + if (biome == NULL) { - return nullptr; + return NULL; } if (mobCategory == MobCategory::monster && scatteredFeature->isSwamphut(x, y, z)) { @@ -895,20 +895,20 @@ vector<Biome::MobSpawnerData *> *RandomLevelSource::getMobsAt(MobCategory *mobCa TilePos *RandomLevelSource::findNearestMapFeature(Level *level, const wstring& featureName, int x, int y, int z) { - if (LargeFeature::STRONGHOLD == featureName && strongholdFeature != nullptr) + if (LargeFeature::STRONGHOLD == featureName && strongholdFeature != NULL) { return strongholdFeature->getNearestGeneratedFeature(level, x, y, z); } - return nullptr; + return NULL; } void RandomLevelSource::recreateLogicStructuresForChunk(int chunkX, int chunkZ) { if (generateStructures) { - mineShaftFeature->apply(this, level, chunkX, chunkZ, byteArray()); - villageFeature->apply(this, level, chunkX, chunkZ, byteArray()); - strongholdFeature->apply(this, level, chunkX, chunkZ, byteArray()); - scatteredFeature->apply(this, level, chunkX, chunkZ, byteArray()); + mineShaftFeature->apply(this, level, chunkX, chunkZ, NULL); + villageFeature->apply(this, level, chunkX, chunkZ, NULL); + strongholdFeature->apply(this, level, chunkX, chunkZ, NULL); + scatteredFeature->apply(this, level, chunkX, chunkZ, NULL); } }
\ No newline at end of file |
