* Rename some fields in Level

This commit is contained in:
iProgramInCpp
2023-08-08 11:12:25 +03:00
parent 3447669f04
commit cc2dc9b648
20 changed files with 59 additions and 60 deletions

View File

@@ -212,7 +212,7 @@ bool Minecraft::isOnlineClient()
if (!m_pLevel)
return false;
return m_pLevel->field_11;
return m_pLevel->m_bIsMultiplayer;
}
void Minecraft::handleMouseDown(int type, bool b)

View File

@@ -67,7 +67,7 @@ void ClientSideNetworkHandler::onDisconnect(const RakNet::RakNetGUID& rakGuid)
puts_ignorable("onDisconnect");
if (m_pLevel)
m_pLevel->field_11 = false;
m_pLevel->m_bIsMultiplayer = false;
m_pMinecraft->m_gui.addMessage("Disconnected from server");
}
@@ -91,7 +91,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, StartGa
pStartGamePkt->field_4,
pStartGamePkt->field_8);
m_pLevel->field_11 = true;
m_pLevel->m_bIsMultiplayer = true;
auto pLocalPlayer = new LocalPlayer(m_pMinecraft, m_pLevel, m_pMinecraft->m_pUser, m_pLevel->m_pDimension->field_50);
pLocalPlayer->m_guid = ((RakNet::RakPeer*)m_pServerPeer)->GetMyGUID();

View File

@@ -664,14 +664,14 @@ void Entity::baseTick()
field_C0 = 0;
m_distanceFallen = 0;
if (m_pLevel->field_11)
if (m_pLevel->m_bIsMultiplayer)
goto label_4;
}
else
{
field_D4 = false;
if (m_pLevel->field_11)
if (m_pLevel->m_bIsMultiplayer)
{
label_4:
field_C0 = 0;

View File

@@ -68,7 +68,7 @@ void FallingTile::tick()
if (!field_7C)
{
if (field_E0 > 100 && !m_pLevel->field_11)
if (field_E0 > 100 && !m_pLevel->m_bIsMultiplayer)
remove();
return;

View File

@@ -308,10 +308,10 @@ bool Mob::isAlive()
bool Mob::hurt(Entity *pAttacker, int damage)
{
if (m_pLevel->field_11)
if (m_pLevel->m_bIsMultiplayer)
return false;
field_AFC = m_pLevel->field_11;
field_AFC = m_pLevel->m_bIsMultiplayer;
if (m_health <= 0)
return false;
@@ -540,7 +540,7 @@ void Mob::die(Entity* pCulprit)
field_B69 = true;
if (!m_pLevel->field_11)
if (!m_pLevel->m_bIsMultiplayer)
dropDeathLoot();
}

View File

@@ -19,7 +19,7 @@ ItemInstance* CameraItem::use(ItemInstance* inst, Level* level, Player* player)
{
#ifndef ORIGINAL_CODE
// prevent players from using this in multiplayer, to prevent a desync of entity IDs
if (level->field_11)
if (level->m_bIsMultiplayer)
return inst;
#endif

View File

@@ -46,7 +46,7 @@ void Explosion::explode()
rayY /= length;
rayZ /= length;
float mult = m_power * (0.7f + 0.6f * m_pLevel->field_38.nextFloat());
float mult = m_power * (0.7f + 0.6f * m_pLevel->m_random.nextFloat());
float posX = m_pos.x;
float posY = m_pos.y;
@@ -134,7 +134,7 @@ void Explosion::explode()
void Explosion::addParticles()
{
m_pLevel->playSound(m_pos.x, m_pos.y, m_pos.z, "random.explode", 4.0f, 0.7f * (1.0f + 0.2f * (m_pLevel->field_38.nextFloat() - m_pLevel->field_38.nextFloat())));
m_pLevel->playSound(m_pos.x, m_pos.y, m_pos.z, "random.explode", 4.0f, 0.7f * (1.0f + 0.2f * (m_pLevel->m_random.nextFloat() - m_pLevel->m_random.nextFloat())));
std::vector<TilePos> vec;
vec.insert(vec.begin(), m_tiles.begin(), m_tiles.end());
@@ -148,9 +148,9 @@ void Explosion::addParticles()
if ((i & 0x7) == 0)
{
float x2, y2, z2, vx, vy, vz, mult;
x2 = float(tp.x) + m_pLevel->field_38.nextFloat();
y2 = float(tp.y) + m_pLevel->field_38.nextFloat();
z2 = float(tp.z) + m_pLevel->field_38.nextFloat();
x2 = float(tp.x) + m_pLevel->m_random.nextFloat();
y2 = float(tp.y) + m_pLevel->m_random.nextFloat();
z2 = float(tp.z) + m_pLevel->m_random.nextFloat();
float dX, dY, dZ;
dX = x2 - m_pos.x;
@@ -166,7 +166,7 @@ void Explosion::addParticles()
// @HUH: Dividing by the inverse is the same as multiplying. Thanks, IDA! :)
float power1 = m_power / (1.0f / dist) + 0.1f;
mult = ((m_pLevel->field_38.nextFloat() * m_pLevel->field_38.nextFloat()) + 0.3f) * (0.5f / power1);
mult = ((m_pLevel->m_random.nextFloat() * m_pLevel->m_random.nextFloat()) + 0.3f) * (0.5f / power1);
m_pLevel->addParticle("explode", (x2 + m_pos.x) / 2, (y2 + m_pos.y) / 2, (z2 + m_pos.z) / 2, vx * mult, vy * mult, vz * mult);
m_pLevel->addParticle("smoke", x2, y2, z2, vx * mult, vy * mult, vz * mult);

View File

@@ -16,13 +16,13 @@
Level::Level(LevelStorage* pStor, const std::string& str, TLong seed, int x, Dimension *pDimension)
{
field_10 = 0;
field_11 = false;
field_12 = 0;
m_bInstantTicking = false;
m_bIsMultiplayer = false;
m_bPostProcessing = false;
m_skyDarken = 0;
field_30 = 0;
m_pDimension = nullptr;
field_A00 = 0;
m_bCalculatingInitialSpawn = false;
m_pChunkSource = nullptr;
m_pLevelStorage = pStor;
field_AA8 = 42184323;
@@ -31,7 +31,7 @@ Level::Level(LevelStorage* pStor, const std::string& str, TLong seed, int x, Dim
field_B08 = 0;
field_B0C = 0;
field_38 = 1; // initialize with a seed of 1
m_random.setSeed(1); // initialize with a seed of 1
LevelData* pData = m_pLevelStorage->prepareLevel(this);
@@ -628,7 +628,7 @@ void Level::sendTileUpdated(int x, int y, int z)
void Level::neighborChanged(int x, int y, int z, TileID tile)
{
if (field_30 || field_11) return;
if (field_30 || m_bIsMultiplayer) return;
Tile* pTile = Tile::tiles[getTile(x, y, z)];
if (pTile)
@@ -984,8 +984,8 @@ void Level::validateSpawn()
// While the spawn isn't valid
do
{
spawnX += (field_38.genrand_int32() % 8) - (field_38.genrand_int32() % 8);
spawnZ += (field_38.genrand_int32() % 8) - (field_38.genrand_int32() % 8);
spawnX += m_random.nextInt(8) - m_random.nextInt(8);
spawnZ += m_random.nextInt(8) - m_random.nextInt(8);
// avoid spawning near world border
if (spawnX < 4) spawnX += 8;
@@ -1074,7 +1074,7 @@ bool Level::addEntity(Entity* pEnt)
//removeEntity(pOldEnt);
}
if (!pEnt->isPlayer() && field_11)
if (!pEnt->isPlayer() && m_bIsMultiplayer)
{
LogMsg("Hey, why are you trying to add an non-player entity in a multiplayer world?");
}
@@ -1142,7 +1142,7 @@ void Level::saveUnsavedChunks()
void Level::setInitialSpawn()
{
field_A00 = true;
m_bCalculatingInitialSpawn = true;
int spawnX = C_MAX_CHUNKS_X * 16 / 2, spawnZ = C_MAX_CHUNKS_Z * 16 / 2;
#ifndef ORIGINAL_CODE
@@ -1154,8 +1154,8 @@ void Level::setInitialSpawn()
if (m_pDimension->isValidSpawn(spawnX, spawnZ))
break;
spawnX += (field_38.genrand_int32() % 32) - (field_38.genrand_int32() % 32);
spawnZ += (field_38.genrand_int32() % 32) - (field_38.genrand_int32() % 32);
spawnX += m_random.nextInt(32) - m_random.nextInt(32);
spawnZ += m_random.nextInt(32) - m_random.nextInt(32);
if (spawnX < 4) spawnX += 32;
if (spawnZ < 4) spawnZ += 32;
@@ -1172,7 +1172,7 @@ void Level::setInitialSpawn()
m_levelData.m_spawnPos.z = spawnZ;
m_levelData.m_spawnPos.y = 64;
field_A00 = false;
m_bCalculatingInitialSpawn = false;
#ifndef ORIGINAL_CODE
return;
@@ -1325,7 +1325,7 @@ void Level::tickPendingTicks(bool b)
{
TileID tile = getTile(t.field_4, t.field_8, t.field_C);
if (tile == t.field_10 && tile > 0)
Tile::tiles[tile]->tick(this, t.field_4, t.field_8, t.field_C, &field_38);
Tile::tiles[tile]->tick(this, t.field_4, t.field_8, t.field_C, &m_random);
}
m_pendingTicks.erase(m_pendingTicks.begin());
@@ -1369,7 +1369,7 @@ void Level::tickTiles()
TileID tile = pChunk->getTile(tileX, tileY, tileZ);
if (Tile::shouldTick[tile])
Tile::tiles[tile]->tick(this, tileX + globX, tileY, tileZ + globZ, &field_38);
Tile::tiles[tile]->tick(this, tileX + globX, tileY, tileZ + globZ, &m_random);
}
}
}
@@ -1846,7 +1846,7 @@ HitResult Level::clip(const Vec3& a, const Vec3& b)
void Level::addToTickNextTick(int a, int b, int c, int d, int delay)
{
TickNextTickData tntd(a, b, c, d);
if (field_10)
if (m_bInstantTicking)
{
// @NOTE: Don't know why this check wasn't just placed at the beginning.
if (!hasChunksAt(a - 8, b - 8, c - 8, a + 8, b + 8, c + 8))
@@ -1854,7 +1854,7 @@ void Level::addToTickNextTick(int a, int b, int c, int d, int delay)
TileID tile = getTile(tntd.field_4, tntd.field_8, tntd.field_C);
if (tile > 0 && tile == tntd.field_10)
Tile::tiles[tntd.field_10]->tick(this, tntd.field_4, tntd.field_8, tntd.field_C, &field_38);
Tile::tiles[tntd.field_10]->tick(this, tntd.field_4, tntd.field_8, tntd.field_C, &m_random);
}
else
{
@@ -1911,9 +1911,9 @@ void Level::animateTick(int x, int y, int z)
for (int i = 0; i < 100; i++)
{
int x1, y1, z1;
x1 = x + (field_38.genrand_int32() & 0xF) - (field_38.genrand_int32() & 0xF);
y1 = y + (field_38.genrand_int32() & 0xF) - (field_38.genrand_int32() & 0xF);
z1 = z + (field_38.genrand_int32() & 0xF) - (field_38.genrand_int32() & 0xF);
x1 = x + m_random.nextInt(16) - m_random.nextInt(16);
y1 = y + m_random.nextInt(16) - m_random.nextInt(16);
z1 = z + m_random.nextInt(16) - m_random.nextInt(16);
TileID tile = getTile(x1, y1, z1);
if (tile > 0)
Tile::tiles[tile]->animateTick(this, x1, y1, z1, &random);

View File

@@ -169,16 +169,16 @@ public:
public:
AABBVector m_aabbs;
uint8_t field_10;
bool field_11;
uint8_t field_12;
bool m_bInstantTicking;
bool m_bIsMultiplayer; // if the level is controlled externally by a server
bool m_bPostProcessing;
EntityVector m_entities;
std::vector<Player*> m_players;
int m_skyDarken;
uint8_t field_30;
Dimension* m_pDimension;
Random field_38;
uint8_t field_A00;
Random m_random;
bool m_bCalculatingInitialSpawn;
std::vector<LevelListener*> m_levelListeners;
ChunkSource* m_pChunkSource;
LevelStorage* m_pLevelStorage;

View File

@@ -638,7 +638,7 @@ bool LevelChunk::setTile(int x, int y, int z, TileID tile)
lightGaps(x, z);
if (tile)
{
if (!m_pLevel->field_11)
if (!m_pLevel->m_bIsMultiplayer)
Tile::tiles[tile]->onPlace(m_pLevel, globalX, y, globalZ);
}
@@ -704,7 +704,7 @@ bool LevelChunk::setTileAndData(int x, int y, int z, TileID tile, int data)
lightGaps(x, z);
if (tile)
{
if (!m_pLevel->field_11)
if (!m_pLevel->m_bIsMultiplayer)
Tile::tiles[tile]->onPlace(m_pLevel, globalX, y, globalZ);
}

View File

@@ -341,8 +341,7 @@ void RandomLevelSource::buildSurfaces(int x, int z, TileID* tiles, Biome** biome
void RandomLevelSource::postProcess(ChunkSource* src, int x, int z)
{
//return;
m_pLevel->field_12 = true;
m_pLevel->m_bPostProcessing = true;
SandTile::instaFall = true;
int x16 = x * 16, z16 = z * 16;
@@ -549,7 +548,7 @@ void RandomLevelSource::postProcess(ChunkSource* src, int x, int z)
}
SandTile::instaFall = false;
m_pLevel->field_12 = false;
m_pLevel->m_bPostProcessing = false;
}
int RandomLevelSource::tick()

View File

@@ -43,8 +43,8 @@ bool SpringFeature::place(Level* level, Random* random, int x, int y, int z)
level->setTile(x, y, z, m_ID);
level->field_10 = true;
level->m_bInstantTicking = true;
Tile::tiles[m_ID]->tick(level, x, y, z, random);
level->field_10 = false;
level->m_bInstantTicking = false;
return true;
}

View File

@@ -51,7 +51,7 @@ int DoorTile::use(Level* level, int x, int y, int z, Player* player)
else
snd = "random.door_close";
level->playSound(float(x) + 0.5f, float(y) + 0.5f, float(z) + 0.5f, snd, 1.0f, 0.9f + 0.1f * level->field_38.nextFloat());
level->playSound(float(x) + 0.5f, float(y) + 0.5f, float(z) + 0.5f, snd, 1.0f, 0.9f + 0.1f * level->m_random.nextFloat());
}
return 1;
@@ -200,7 +200,7 @@ void DoorTile::setOpen(Level* level, int x, int y, int z, bool bOpen)
else
snd = "random.door_close";
level->playSound(float(x) + 0.5f, float(y) + 0.5f, float(z) + 0.5f, snd, 1.0f, 0.9f + 0.1f * level->field_38.nextFloat());
level->playSound(float(x) + 0.5f, float(y) + 0.5f, float(z) + 0.5f, snd, 1.0f, 0.9f + 0.1f * level->m_random.nextFloat());
}
}

View File

@@ -86,7 +86,7 @@ void FarmTile::neighborChanged(Level* level, int x, int y, int z, int a)
void FarmTile::stepOn(Level* level, int x, int y, int z, Entity* pEnt)
{
if (level->field_38.genrand_int32() % 4 == 0)
if (level->m_random.genrand_int32() % 4 == 0)
level->setTile(x, y, z, Tile::dirt->m_ID);
}

View File

@@ -47,7 +47,7 @@ void GrassTile::tick(Level* level, int x, int y, int z, Random* random)
{
// Controls the spread/death of grass.
// It's like a full on automata of sorts. :)
if (level->field_11)
if (level->m_bIsMultiplayer)
return;
if (level->getRawBrightness(x, y + 1, z) <= 3 &&

View File

@@ -78,7 +78,7 @@ void LeafTile::onRemove(Level* level, int x, int y, int z)
void LeafTile::tick(Level* level, int x, int y, int z, Random* random)
{
if (level->field_11)
if (level->m_bIsMultiplayer)
return;
int data = level->getData(x, y, z);

View File

@@ -35,9 +35,9 @@ int RedStoneOreTile::poofParticles(Level* level, int x, int y, int z)
{
for (int i = 0; i < 6; i++)
{
float xo = float(x) + level->field_38.nextFloat();
float yo = float(y) + level->field_38.nextFloat();
float zo = float(z) + level->field_38.nextFloat();
float xo = float(x) + level->m_random.nextFloat();
float yo = float(y) + level->m_random.nextFloat();
float zo = float(z) + level->m_random.nextFloat();
switch (i)
{

View File

@@ -81,7 +81,7 @@ bool SandTile::isFree(Level* level, int x, int y, int z)
void SandTile::tick(Level* level, int x, int y, int z, Random* random)
{
if (level->field_11)
if (level->m_bIsMultiplayer)
return;
checkSlide(level, x, y, z);

View File

@@ -1091,7 +1091,7 @@ void Tile::spawnResources(Level* pLevel, int x, int y, int z, int i)
void Tile::spawnResources(Level* pLevel, int x, int y, int z, int data, float fChance)
{
if (pLevel->field_11)
if (pLevel->m_bIsMultiplayer)
return;
#ifdef TEST_SURVIVAL_MODE

View File

@@ -33,7 +33,7 @@ int TntTile::getTexture(int dir)
void TntTile::destroy(Level* level, int x, int y, int z, int data)
{
// prevent players from using this in multiplayer, to prevent a desync of player IDs
if (level->field_11) return;
if (level->m_bIsMultiplayer) return;
level->addEntity(new PrimedTnt(level, float(x) + 0.5f, float(y) + 0.5f, float(z) + 0.5f));
}
@@ -41,7 +41,7 @@ void TntTile::destroy(Level* level, int x, int y, int z, int data)
void TntTile::wasExploded(Level* level, int x, int y, int z)
{
PrimedTnt* tnt = new PrimedTnt(level, float(x) + 0.5f, float(y) + 0.5f, float(z) + 0.5f);
tnt->m_fuseTimer = level->field_38.nextInt(tnt->m_fuseTimer / 4) + tnt->m_fuseTimer / 8;
tnt->m_fuseTimer = level->m_random.nextInt(tnt->m_fuseTimer / 4) + tnt->m_fuseTimer / 8;
level->addEntity(tnt);
}