forked from Kolyah35/minecraft-pe-0.6.1
all was broken :\
This commit is contained in:
@@ -278,8 +278,8 @@ void Level::tickTiles() {
|
||||
for (int i = 0; i < pollChunkOffsetsSize; i += 2) {
|
||||
const int xp = xx + pollChunkOffsets[i];
|
||||
const int zp = zz + pollChunkOffsets[i+1];
|
||||
if (xp >= 0 && xp < CHUNK_CACHE_WIDTH &&
|
||||
zp >= 0 && zp < CHUNK_CACHE_WIDTH)
|
||||
if (xp >= 0 && xp < LevelConstants::CHUNK_CACHE_WIDTH &&
|
||||
zp >= 0 && zp < LevelConstants::CHUNK_CACHE_WIDTH)
|
||||
_chunksToPoll.insert(ChunkPos(xp, zp));
|
||||
}
|
||||
}
|
||||
@@ -428,17 +428,17 @@ bool Level::findPath(Path* path, Entity* from, int xBest, int yBest, int zBest,
|
||||
/*protected*/
|
||||
void Level::setInitialSpawn() {
|
||||
isFindingSpawn = true;
|
||||
int xSpawn = CHUNK_CACHE_WIDTH * CHUNK_WIDTH / 2; // (Level.MAX_LEVEL_SIZE - 100) * 0;
|
||||
int xSpawn = LevelConstants::CHUNK_CACHE_WIDTH * LevelConstants::CHUNK_WIDTH / 2; // (Level.MAX_LEVEL_SIZE - 100) * 0;
|
||||
int ySpawn = 64;
|
||||
int zSpawn = CHUNK_CACHE_WIDTH * CHUNK_DEPTH / 2; // (Level.MAX_LEVEL_SIZE - 100) * 0;
|
||||
int zSpawn = LevelConstants::CHUNK_CACHE_WIDTH * LevelConstants::CHUNK_DEPTH / 2; // (Level.MAX_LEVEL_SIZE - 100) * 0;
|
||||
while (!dimension->isValidSpawn(xSpawn, zSpawn)) {
|
||||
xSpawn += random.nextInt(32) - random.nextInt(32);
|
||||
zSpawn += random.nextInt(32) - random.nextInt(32);
|
||||
|
||||
if (xSpawn < 4) xSpawn += 32;
|
||||
if (xSpawn >= LEVEL_WIDTH-4) xSpawn -= 32;
|
||||
if (xSpawn >= LevelConstants::LEVEL_WIDTH-4) xSpawn -= 32;
|
||||
if (zSpawn < 4) zSpawn += 32;
|
||||
if (zSpawn >= LEVEL_DEPTH-4) zSpawn -= 32;
|
||||
if (zSpawn >= LevelConstants::LEVEL_DEPTH-4) zSpawn -= 32;
|
||||
}
|
||||
levelData.setSpawn(xSpawn, ySpawn, zSpawn);
|
||||
isFindingSpawn = false;
|
||||
@@ -456,9 +456,9 @@ void Level::validateSpawn() {
|
||||
zSpawn += random.nextInt(8) - random.nextInt(8);
|
||||
|
||||
if (xSpawn < 4) xSpawn += 8;
|
||||
if (xSpawn >= LEVEL_WIDTH-4) xSpawn -= 8;
|
||||
if (xSpawn >= LevelConstants::LEVEL_WIDTH-4) xSpawn -= 8;
|
||||
if (zSpawn < 4) zSpawn += 8;
|
||||
if (zSpawn >= LEVEL_DEPTH-4) zSpawn -= 8;
|
||||
if (zSpawn >= LevelConstants::LEVEL_DEPTH-4) zSpawn -= 8;
|
||||
}
|
||||
levelData.setXSpawn(xSpawn);
|
||||
levelData.setZSpawn(zSpawn);
|
||||
@@ -944,7 +944,7 @@ HitResult Level::clip(const Vec3& A, const Vec3& b, bool liquid /*= false*/, boo
|
||||
if (solidOnly && tile != NULL && tile->getAABB(this, xTile0, yTile0, zTile0) == NULL) {
|
||||
// No collision
|
||||
} else if (t > 0 && tile->mayPick(data, liquid)) {
|
||||
if(xTile0 >= 0 && zTile0 >= 0 && xTile0 < LEVEL_WIDTH && zTile0 < LEVEL_WIDTH) {
|
||||
if(xTile0 >= 0 && zTile0 >= 0 && xTile0 < LevelConstants::LEVEL_WIDTH && zTile0 < LevelConstants::LEVEL_WIDTH) {
|
||||
HitResult r = tile->clip(this, xTile0, yTile0, zTile0, a, b);
|
||||
if (r.isHit()) return r;
|
||||
}
|
||||
@@ -2222,9 +2222,9 @@ void Level::setNightMode( bool isNightMode ) {
|
||||
}
|
||||
|
||||
bool Level::inRange( int x, int y, int z ) {
|
||||
return x >= 0 && x < LEVEL_WIDTH
|
||||
&& y >= 0 && y < LEVEL_HEIGHT
|
||||
&& z >= 0 && z < LEVEL_DEPTH;
|
||||
return x >= 0 && x < LevelConstants::LEVEL_WIDTH
|
||||
&& y >= 0 && y < LevelConstants::LEVEL_HEIGHT
|
||||
&& z >= 0 && z < LevelConstants::LEVEL_DEPTH;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -67,8 +67,8 @@ class Level: public LevelSource
|
||||
|
||||
public:
|
||||
static const int MAX_LEVEL_SIZE = 32000000;
|
||||
static const short DEPTH = LEVEL_HEIGHT;
|
||||
static const short SEA_LEVEL = DEPTH / 2 - 1;
|
||||
const short DEPTH = LevelConstants::LEVEL_HEIGHT;
|
||||
const short SEA_LEVEL = DEPTH / 2 - 1;
|
||||
|
||||
static const int MAX_BRIGHTNESS = 15;
|
||||
static const int TICKS_PER_DAY = SharedConstants::TicksPerSecond * 60 * 16;// SharedConstants::TicksPerSecond * 60 * 12; // ORG:20*60*20
|
||||
|
||||
7
src/world/level/LevelConstants.cpp
Normal file
7
src/world/level/LevelConstants.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include "LevelConstants.h"
|
||||
|
||||
int LevelConstants::LEVEL_HEIGHT = 128;
|
||||
int LevelConstants::CHUNK_WIDTH = 16; // in blocks
|
||||
int LevelConstants::CHUNK_DEPTH = 16;
|
||||
int LevelConstants::CHUNK_COLUMNS = LevelConstants::CHUNK_WIDTH * LevelConstants::CHUNK_DEPTH;
|
||||
int LevelConstants::CHUNK_BLOCK_COUNT = LevelConstants::CHUNK_COLUMNS * LevelConstants::LEVEL_HEIGHT;
|
||||
@@ -1,10 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
const int LEVEL_HEIGHT = 128;
|
||||
int CHUNK_CACHE_WIDTH = 16; // in chunks
|
||||
const int CHUNK_WIDTH = 16; // in blocks
|
||||
const int CHUNK_DEPTH = 16;
|
||||
int LEVEL_WIDTH = CHUNK_CACHE_WIDTH * CHUNK_WIDTH;
|
||||
int LEVEL_DEPTH = CHUNK_CACHE_WIDTH * CHUNK_DEPTH;
|
||||
const int CHUNK_COLUMNS = CHUNK_WIDTH * CHUNK_DEPTH;
|
||||
const int CHUNK_BLOCK_COUNT = CHUNK_COLUMNS * LEVEL_HEIGHT;
|
||||
class LevelConstants {
|
||||
public:
|
||||
static int CHUNK_CACHE_WIDTH; // in chunks
|
||||
static int LEVEL_WIDTH;
|
||||
static int LEVEL_DEPTH;
|
||||
|
||||
static int LEVEL_HEIGHT;
|
||||
static int CHUNK_WIDTH; // in blocks
|
||||
static int CHUNK_DEPTH;
|
||||
static int CHUNK_COLUMNS;
|
||||
static int CHUNK_BLOCK_COUNT;
|
||||
};
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "../LevelConstants.h"
|
||||
|
||||
class ChunkCache: public ChunkSource {
|
||||
//static const int CHUNK_CACHE_WIDTH = CHUNK_CACHE_WIDTH; // WAS 32;
|
||||
//static const int LevelConstants::CHUNK_CACHE_WIDTH = LevelConstants::CHUNK_CACHE_WIDTH; // WAS 32;
|
||||
static const int MAX_SAVES = 2;
|
||||
public:
|
||||
ChunkCache(Level* level_, ChunkStorage* storage_, ChunkSource* source_)
|
||||
@@ -25,14 +25,14 @@ public:
|
||||
//emptyChunk = new EmptyLevelChunk(level_, emptyChunkBlocks, 0, 0);
|
||||
emptyChunk = new EmptyLevelChunk(level_, NULL, 0, 0);
|
||||
|
||||
chunks = (LevelChunk *)malloc(CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH);
|
||||
chunks = (LevelChunk *)malloc(LevelConstants::CHUNK_CACHE_WIDTH * LevelConstants::CHUNK_CACHE_WIDTH);
|
||||
}
|
||||
|
||||
~ChunkCache() {
|
||||
delete source;
|
||||
delete emptyChunk;
|
||||
|
||||
for (int i = 0; i < CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH; i++)
|
||||
for (int i = 0; i < LevelConstants::CHUNK_CACHE_WIDTH * LevelConstants::CHUNK_CACHE_WIDTH; i++)
|
||||
{
|
||||
if (&chunks[i])
|
||||
{
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
}
|
||||
|
||||
bool fits(int x, int z) {
|
||||
return (x >= 0 && z >= 0 && x < CHUNK_CACHE_WIDTH && z < CHUNK_CACHE_WIDTH);
|
||||
return (x >= 0 && z >= 0 && x < LevelConstants::CHUNK_CACHE_WIDTH && z < LevelConstants::CHUNK_CACHE_WIDTH);
|
||||
}
|
||||
|
||||
bool hasChunk(int x, int z) {
|
||||
@@ -53,9 +53,9 @@ public:
|
||||
if (x == xLast && z == zLast && last != NULL) {
|
||||
return true;
|
||||
}
|
||||
int xs = x & (CHUNK_CACHE_WIDTH - 1);
|
||||
int zs = z & (CHUNK_CACHE_WIDTH - 1);
|
||||
int slot = xs + zs * CHUNK_CACHE_WIDTH;
|
||||
int xs = x & (LevelConstants::CHUNK_CACHE_WIDTH - 1);
|
||||
int zs = z & (LevelConstants::CHUNK_CACHE_WIDTH - 1);
|
||||
int slot = xs + zs * LevelConstants::CHUNK_CACHE_WIDTH;
|
||||
return &chunks[slot] != NULL && (&chunks[slot] == emptyChunk || chunks[slot].isAt(x, z));
|
||||
}
|
||||
|
||||
@@ -72,9 +72,9 @@ public:
|
||||
}
|
||||
if (!fits(x, z)) return emptyChunk;
|
||||
//if (!level->isFindingSpawn && !fits(x, z)) return emptyChunk;
|
||||
int xs = x & (CHUNK_CACHE_WIDTH - 1);
|
||||
int zs = z & (CHUNK_CACHE_WIDTH - 1);
|
||||
int slot = xs + zs * CHUNK_CACHE_WIDTH;
|
||||
int xs = x & (LevelConstants::CHUNK_CACHE_WIDTH - 1);
|
||||
int zs = z & (LevelConstants::CHUNK_CACHE_WIDTH - 1);
|
||||
int slot = xs + zs * LevelConstants::CHUNK_CACHE_WIDTH;
|
||||
if (!hasChunk(x, z)) {
|
||||
if (&chunks[slot] != NULL) {
|
||||
chunks[slot].unload();
|
||||
@@ -200,8 +200,8 @@ public:
|
||||
void saveAll(bool onlyUnsaved) {
|
||||
if (storage != NULL) {
|
||||
std::vector<LevelChunk*> chunks;
|
||||
for (int z = 0; z < CHUNK_CACHE_WIDTH; ++z)
|
||||
for (int x = 0; x < CHUNK_CACHE_WIDTH; ++x) {
|
||||
for (int z = 0; z < LevelConstants::CHUNK_CACHE_WIDTH; ++z)
|
||||
for (int x = 0; x < LevelConstants::CHUNK_CACHE_WIDTH; ++x) {
|
||||
LevelChunk* chunk = level->getChunk(x, z);
|
||||
if (!onlyUnsaved || chunk->shouldSave(false))
|
||||
chunks.push_back( chunk );
|
||||
@@ -212,7 +212,7 @@ public:
|
||||
private:
|
||||
LevelChunk* load(int x, int z) {
|
||||
if (storage == NULL) return emptyChunk;
|
||||
if (x < 0 || x >= CHUNK_CACHE_WIDTH || z < 0 || z >= CHUNK_CACHE_WIDTH)
|
||||
if (x < 0 || x >= LevelConstants::CHUNK_CACHE_WIDTH || z < 0 || z >= LevelConstants::CHUNK_CACHE_WIDTH)
|
||||
{
|
||||
return emptyChunk;
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ LevelChunk::LevelChunk( Level* level, int x, int z )
|
||||
: level(level),
|
||||
x(x),
|
||||
z(z),
|
||||
xt(x * CHUNK_WIDTH),
|
||||
zt(z * CHUNK_DEPTH)
|
||||
xt(x * LevelConstants::CHUNK_WIDTH),
|
||||
zt(z * LevelConstants::CHUNK_DEPTH)
|
||||
{
|
||||
init();
|
||||
}
|
||||
@@ -27,8 +27,8 @@ LevelChunk::LevelChunk( Level* level, unsigned char* blocks, int x, int z )
|
||||
: level(level),
|
||||
x(x),
|
||||
z(z),
|
||||
xt(x * CHUNK_WIDTH),
|
||||
zt(z * CHUNK_DEPTH),
|
||||
xt(x * LevelConstants::CHUNK_WIDTH),
|
||||
zt(z * LevelConstants::CHUNK_DEPTH),
|
||||
blocks(blocks),
|
||||
data(ChunkBlockCount),
|
||||
skyLight(ChunkBlockCount),
|
||||
@@ -45,6 +45,9 @@ LevelChunk::~LevelChunk()
|
||||
|
||||
void LevelChunk::init()
|
||||
{
|
||||
heightmap = (char*)malloc(LevelConstants::CHUNK_COLUMNS * sizeof(char));
|
||||
updateMap = (unsigned char*)malloc(LevelConstants::CHUNK_COLUMNS * sizeof(unsigned char));
|
||||
|
||||
terrainPopulated = false;
|
||||
dontSave = false;
|
||||
unsaved = false;
|
||||
|
||||
@@ -106,9 +106,9 @@ private:
|
||||
void recalcHeight(int x, int yStart, int z);
|
||||
public:
|
||||
static bool touchedSky;
|
||||
static const int ChunkBlockCount = CHUNK_BLOCK_COUNT;
|
||||
static const int ChunkSize = ChunkBlockCount;
|
||||
static const int UpdateMapBitShift = 4; // power of (LEVEL_HEIGHT / 8) == 16
|
||||
const int ChunkBlockCount = LevelConstants::CHUNK_BLOCK_COUNT;
|
||||
const int ChunkSize = ChunkBlockCount;
|
||||
static const int UpdateMapBitShift = 4; // power of (LevelConstants::LEVEL_HEIGHT / 8) == 16
|
||||
|
||||
int blocksLength; // ? needed or not? (i.e. are all chunks the same size?)
|
||||
|
||||
@@ -118,8 +118,8 @@ public:
|
||||
DataLayer skyLight;
|
||||
DataLayer blockLight;
|
||||
|
||||
char heightmap[CHUNK_COLUMNS];
|
||||
unsigned char updateMap[CHUNK_COLUMNS]; // marks regions within block columns that have been modified
|
||||
char* heightmap; // [LevelConstants::CHUNK_COLUMNS]
|
||||
unsigned char* updateMap; // marks regions within block columns that have been modified [LevelConstants::CHUNK_COLUMNS]
|
||||
int minHeight;
|
||||
|
||||
int x, z;
|
||||
|
||||
@@ -64,7 +64,7 @@ RandomLevelSource::~RandomLevelSource() {
|
||||
/*public*/
|
||||
void RandomLevelSource::prepareHeights(int xOffs, int zOffs, unsigned char* blocks, /*Biome*/void* biomes, float* temperatures) {
|
||||
|
||||
int xChunks = 16 / CHUNK_WIDTH;
|
||||
int xChunks = 16 / LevelConstants::CHUNK_WIDTH;
|
||||
int waterHeight = Level::DEPTH - 64;
|
||||
|
||||
int xSize = xChunks + 1;
|
||||
@@ -87,23 +87,23 @@ void RandomLevelSource::prepareHeights(int xOffs, int zOffs, unsigned char* bloc
|
||||
float s3a = (buffer[((xc + 1) * zSize + (zc + 1)) * ySize + (yc + 1)] - s3) * yStep;
|
||||
|
||||
for (int y = 0; y < CHUNK_HEIGHT; y++) {
|
||||
float xStep = 1 / (float) CHUNK_WIDTH;
|
||||
float xStep = 1 / (float) LevelConstants::CHUNK_WIDTH;
|
||||
|
||||
float _s0 = s0;
|
||||
float _s1 = s1;
|
||||
float _s0a = (s2 - s0) * xStep;
|
||||
float _s1a = (s3 - s1) * xStep;
|
||||
|
||||
for (int x = 0; x < CHUNK_WIDTH; x++) {
|
||||
int offs = (x + xc * CHUNK_WIDTH) << 11 | (0 + zc * CHUNK_WIDTH) << 7 | (yc * CHUNK_HEIGHT + y);
|
||||
for (int x = 0; x < LevelConstants::CHUNK_WIDTH; x++) {
|
||||
int offs = (x + xc * LevelConstants::CHUNK_WIDTH) << 11 | (0 + zc * LevelConstants::CHUNK_WIDTH) << 7 | (yc * CHUNK_HEIGHT + y);
|
||||
int step = 1 << 7;
|
||||
float zStep = 1 / (float) CHUNK_WIDTH;
|
||||
float zStep = 1 / (float) LevelConstants::CHUNK_WIDTH;
|
||||
|
||||
float val = _s0;
|
||||
float vala = (_s1 - _s0) * zStep;
|
||||
for (int z = 0; z < CHUNK_WIDTH; z++) {
|
||||
// + (zc * CHUNK_WIDTH + z)];
|
||||
float temp = temperatures[(xc * CHUNK_WIDTH + x) * 16 + (zc * CHUNK_WIDTH + z)];
|
||||
for (int z = 0; z < LevelConstants::CHUNK_WIDTH; z++) {
|
||||
// + (zc * LevelConstants::CHUNK_WIDTH + z)];
|
||||
float temp = temperatures[(xc * LevelConstants::CHUNK_WIDTH + x) * 16 + (zc * LevelConstants::CHUNK_WIDTH + z)];
|
||||
int tileId = 0;
|
||||
if (yc * CHUNK_HEIGHT + y < waterHeight) {
|
||||
if (temp < SNOW_CUTOFF && yc * CHUNK_HEIGHT + y >= waterHeight - 1) {
|
||||
|
||||
@@ -343,8 +343,8 @@ bool ExternalFileLevelStorage::readPlayerData(const std::string& filename, Level
|
||||
Vec3& pos = dest.playerData.pos;
|
||||
if (pos.x < 0.5f) pos.x = 0.5f;
|
||||
if (pos.z < 0.5f) pos.z = 0.5f;
|
||||
if (pos.x > (LEVEL_WIDTH - 0.5f)) pos.x = LEVEL_WIDTH - 0.5f;
|
||||
if (pos.z > (LEVEL_DEPTH - 0.5f)) pos.z = LEVEL_DEPTH - 0.5f;
|
||||
if (pos.x > (LevelConstants::LEVEL_WIDTH - 0.5f)) pos.x = LevelConstants::LEVEL_WIDTH - 0.5f;
|
||||
if (pos.z > (LevelConstants::LEVEL_DEPTH - 0.5f)) pos.z = LevelConstants::LEVEL_DEPTH - 0.5f;
|
||||
if (pos.y < 0) pos.y = 64;
|
||||
|
||||
dest.playerDataVersion = version;
|
||||
@@ -362,14 +362,14 @@ void ExternalFileLevelStorage::tick()
|
||||
LOGI("Saving level...\n");
|
||||
|
||||
// look for chunks that needs to be saved
|
||||
for (int z = 0; z < CHUNK_CACHE_WIDTH; z++)
|
||||
for (int z = 0; z < LevelConstants::CHUNK_CACHE_WIDTH; z++)
|
||||
{
|
||||
for (int x = 0; x < CHUNK_CACHE_WIDTH; x++)
|
||||
for (int x = 0; x < LevelConstants::CHUNK_CACHE_WIDTH; x++)
|
||||
{
|
||||
LevelChunk* chunk = level->getChunk(x, z);
|
||||
if (chunk && chunk->unsaved)
|
||||
{
|
||||
int pos = x + z * CHUNK_CACHE_WIDTH;
|
||||
int pos = x + z * LevelConstants::CHUNK_CACHE_WIDTH;
|
||||
UnsavedChunkList::iterator prev = unsavedChunkList.begin();
|
||||
for ( ; prev != unsavedChunkList.end(); ++prev)
|
||||
{
|
||||
@@ -415,13 +415,13 @@ void ExternalFileLevelStorage::save(Level* level, LevelChunk* levelChunk)
|
||||
|
||||
// Write chunk
|
||||
RakNet::BitStream chunkData;
|
||||
chunkData.Write((const char*)levelChunk->getBlockData(), CHUNK_BLOCK_COUNT);
|
||||
chunkData.Write((const char*)levelChunk->data.data, CHUNK_BLOCK_COUNT / 2);
|
||||
chunkData.Write((const char*)levelChunk->getBlockData(), LevelConstants::CHUNK_BLOCK_COUNT);
|
||||
chunkData.Write((const char*)levelChunk->data.data, LevelConstants::CHUNK_BLOCK_COUNT / 2);
|
||||
|
||||
chunkData.Write((const char*)levelChunk->skyLight.data, CHUNK_BLOCK_COUNT / 2);
|
||||
chunkData.Write((const char*)levelChunk->blockLight.data, CHUNK_BLOCK_COUNT / 2);
|
||||
chunkData.Write((const char*)levelChunk->skyLight.data, LevelConstants::CHUNK_BLOCK_COUNT / 2);
|
||||
chunkData.Write((const char*)levelChunk->blockLight.data, LevelConstants::CHUNK_BLOCK_COUNT / 2);
|
||||
|
||||
chunkData.Write((const char*)levelChunk->updateMap, CHUNK_COLUMNS);
|
||||
chunkData.Write((const char*)levelChunk->updateMap, LevelConstants::CHUNK_COLUMNS);
|
||||
|
||||
regionFile->writeChunk(levelChunk->x, levelChunk->z, chunkData);
|
||||
|
||||
@@ -453,16 +453,16 @@ LevelChunk* ExternalFileLevelStorage::load(Level* level, int x, int z)
|
||||
|
||||
chunkData->ResetReadPointer();
|
||||
|
||||
unsigned char* blockIds = new unsigned char[CHUNK_BLOCK_COUNT];
|
||||
chunkData->Read((char*)blockIds, CHUNK_BLOCK_COUNT);
|
||||
unsigned char* blockIds = new unsigned char[LevelConstants::CHUNK_BLOCK_COUNT];
|
||||
chunkData->Read((char*)blockIds, LevelConstants::CHUNK_BLOCK_COUNT);
|
||||
|
||||
LevelChunk* levelChunk = new LevelChunk(level, blockIds, x, z);
|
||||
chunkData->Read((char*)levelChunk->data.data, CHUNK_BLOCK_COUNT / 2);
|
||||
chunkData->Read((char*)levelChunk->data.data, LevelConstants::CHUNK_BLOCK_COUNT / 2);
|
||||
if (loadedStorageVersion >= ChunkVersion_Light) {
|
||||
chunkData->Read((char*)levelChunk->skyLight.data, CHUNK_BLOCK_COUNT / 2);
|
||||
chunkData->Read((char*)levelChunk->blockLight.data, CHUNK_BLOCK_COUNT / 2);
|
||||
chunkData->Read((char*)levelChunk->skyLight.data, LevelConstants::CHUNK_BLOCK_COUNT / 2);
|
||||
chunkData->Read((char*)levelChunk->blockLight.data, LevelConstants::CHUNK_BLOCK_COUNT / 2);
|
||||
}
|
||||
chunkData->Read((char*)levelChunk->updateMap, CHUNK_COLUMNS);
|
||||
chunkData->Read((char*)levelChunk->updateMap, LevelConstants::CHUNK_COLUMNS);
|
||||
// This will be difficult to maintain.. Storage version could be per chunk
|
||||
// too (but probably better to just read all -> write all, so that all
|
||||
// chunks got same version anyway)
|
||||
@@ -485,7 +485,7 @@ LevelChunk* ExternalFileLevelStorage::load(Level* level, int x, int z)
|
||||
//bool dbg = (x == 7 && z == 9);
|
||||
|
||||
//int t = 0;
|
||||
//for (int i = 0; i < CHUNK_COLUMNS; ++i) {
|
||||
//for (int i = 0; i < LevelConstants::CHUNK_COLUMNS; ++i) {
|
||||
// char bits = levelChunk->updateMap[i];
|
||||
// t += (bits != 0);
|
||||
// int xx = x * 16 + i%16;
|
||||
|
||||
@@ -47,7 +47,7 @@ bool Mushroom::mayPlaceOn( int tile ) {
|
||||
}
|
||||
|
||||
bool Mushroom::canSurvive( Level* level, int x, int y, int z ) {
|
||||
if (y < 0 || y >= LEVEL_HEIGHT/*Level::maxBuildHeight*/)
|
||||
if (y < 0 || y >= LevelConstants::LEVEL_HEIGHT/*Level::maxBuildHeight*/)
|
||||
return false;
|
||||
|
||||
int below = level->getTile(x, y - 1, z);
|
||||
|
||||
@@ -53,7 +53,7 @@ bool NetherReactor::canSpawnStartNetherReactor( Level* level, int x, int y, int
|
||||
if(!allPlayersCloseToReactor(level, x, y, z)) {
|
||||
player->displayClientMessage("All players need to be close to the reactor.");
|
||||
return false;
|
||||
} else if(y > LEVEL_HEIGHT - 28) {
|
||||
} else if(y > LevelConstants::LEVEL_HEIGHT - 28) {
|
||||
player->displayClientMessage("The nether reactor needs to be built lower down.");
|
||||
return false;
|
||||
} else if(y < 2) {
|
||||
|
||||
@@ -130,7 +130,7 @@ Vec3 NetherReactorTileEntity::getSpawnPosition( float minDistance, float varible
|
||||
void NetherReactorTileEntity::spawnEnemy() {
|
||||
Mob* mob = MobFactory::CreateMob(MobTypes::PigZombie, level);
|
||||
Vec3 enemyPosition = getSpawnPosition(3, 4, -1);
|
||||
while(enemyPosition.x < 0 || enemyPosition.z < 0 || enemyPosition.x >= LEVEL_WIDTH || enemyPosition.z >= LEVEL_DEPTH) {
|
||||
while(enemyPosition.x < 0 || enemyPosition.z < 0 || enemyPosition.x >= LevelConstants::LEVEL_WIDTH || enemyPosition.z >= LevelConstants::LEVEL_DEPTH) {
|
||||
enemyPosition = getSpawnPosition(3, 4, -1);
|
||||
}
|
||||
MobSpawner::addMob(level, mob, enemyPosition.x, enemyPosition.y, enemyPosition.z, 0, 0, true);
|
||||
@@ -140,7 +140,7 @@ void NetherReactorTileEntity::spawnEnemy() {
|
||||
|
||||
void NetherReactorTileEntity::spawnItem() {
|
||||
Vec3 itemPosition= getSpawnPosition(3, 4, -1);
|
||||
while(itemPosition.x < 0 || itemPosition.z < 0 || itemPosition.x >= LEVEL_WIDTH || itemPosition.z >= LEVEL_DEPTH) {
|
||||
while(itemPosition.x < 0 || itemPosition.z < 0 || itemPosition.x >= LevelConstants::LEVEL_WIDTH || itemPosition.z >= LevelConstants::LEVEL_DEPTH) {
|
||||
itemPosition = getSpawnPosition(3, 4, -1);
|
||||
}
|
||||
ItemEntity* item = new ItemEntity(level, itemPosition.x, itemPosition.y, itemPosition.z, getSpawnItem());
|
||||
|
||||
Reference in New Issue
Block a user