diff --git a/source/client/app/Minecraft.cpp b/source/client/app/Minecraft.cpp index 27a162a15..545333d5c 100644 --- a/source/client/app/Minecraft.cpp +++ b/source/client/app/Minecraft.cpp @@ -396,7 +396,7 @@ void Minecraft::handleBuildAction(const BuildActionIntention& action) player->swing(); } - if (!action.isDestroy() && !m_pGameMode->field_8) // from Minecraft::handleMouseDown + if (!action.isDestroy() && !m_pGameMode->m_bInstaBuild) // from Minecraft::handleMouseDown { m_pGameMode->stopDestroyBlock(); } @@ -444,7 +444,7 @@ void Minecraft::handleBuildAction(const BuildActionIntention& action) // @BUG: Hits sometimes pass through fire when done from above //if (extinguished) break; - if (pTile != Tile::unbreakable || (player->field_B94 >= 100 && !m_hitResult.m_bUnk24)) + if (pTile != Tile::unbreakable || (player->m_userType >= 100 && !m_hitResult.m_bUnk24)) { bool destroyed = false; if (action.isDestroyStart()) diff --git a/source/client/gui/screens/SelectWorldScreen.cpp b/source/client/gui/screens/SelectWorldScreen.cpp index 18c54f512..2864633c7 100644 --- a/source/client/gui/screens/SelectWorldScreen.cpp +++ b/source/client/gui/screens/SelectWorldScreen.cpp @@ -150,7 +150,7 @@ void SelectWorldScreen::tick() // @BUG: Use of deallocated memory. SetScreen frees us #ifdef ORIGINAL_CODE - field_130 = 0; + m_walkAnimPos = 0; #endif return; @@ -211,7 +211,7 @@ void SelectWorldScreen::_buttonClicked(Button* pButton) #else m_pMinecraft->platform()->showDialog(AppPlatform::DLG_CREATE_WORLD); m_pMinecraft->platform()->createUserInput(); - field_130 = true; + m_walkAnimPos = true; #endif } diff --git a/source/client/multiplayer/MultiplayerLocalPlayer.cpp b/source/client/multiplayer/MultiplayerLocalPlayer.cpp index 85742cbbf..a6b9c9099 100644 --- a/source/client/multiplayer/MultiplayerLocalPlayer.cpp +++ b/source/client/multiplayer/MultiplayerLocalPlayer.cpp @@ -57,7 +57,7 @@ bool MultiplayerLocalPlayer::hurt(Entity* pAttacker, int damage) } float ang = atan2f(zd, xd); - v020_field_104 = ang * (180.0f / float(M_PI)) - m_rot.x; + m_hurtDir = ang * (180.0f / float(M_PI)) - m_rot.x; knockback(pAttacker, damage, xd, zd); } diff --git a/source/client/network/ClientSideNetworkHandler.cpp b/source/client/network/ClientSideNetworkHandler.cpp index 910e47666..2d26f71fb 100644 --- a/source/client/network/ClientSideNetworkHandler.cpp +++ b/source/client/network/ClientSideNetworkHandler.cpp @@ -145,7 +145,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, StartGa m_pLevel->m_bIsClientSide = true; - MultiplayerLocalPlayer *pLocalPlayer = new MultiplayerLocalPlayer(m_pMinecraft, m_pLevel, m_pMinecraft->m_pUser, settings.m_gameType, m_pLevel->m_pDimension->field_50); + MultiplayerLocalPlayer *pLocalPlayer = new MultiplayerLocalPlayer(m_pMinecraft, m_pLevel, m_pMinecraft->m_pUser, settings.m_gameType, m_pLevel->m_pDimension->m_id); pLocalPlayer->m_guid = ((RakNet::RakPeer*)m_pServerPeer)->GetMyGUID(); pLocalPlayer->m_EntityID = pStartGamePkt->m_entityId; diff --git a/source/client/renderer/GameRenderer.cpp b/source/client/renderer/GameRenderer.cpp index d71fd3d4e..3abbf3d38 100644 --- a/source/client/renderer/GameRenderer.cpp +++ b/source/client/renderer/GameRenderer.cpp @@ -425,7 +425,7 @@ void GameRenderer::bobView(Matrix& matrix, float f) float f1 = Mth::Lerp(player->m_oBob, player->m_bob, f); float f2 = Mth::Lerp(player->m_oTilt, player->m_tilt, f); // @NOTE: Multiplying by M_PI inside of the paren makes it stuttery for some reason? Anyways it works now :) - float f3 = -(player->m_walkDist + (player->m_walkDist - player->field_90) * f) * float(M_PI); + float f3 = -(player->m_walkDist + (player->m_walkDist - player->m_walkDistO) * f) * float(M_PI); float f4 = Mth::sin(f3); float f5 = Mth::cos(f3); float f6 = Mth::cos(f3 - 0.2f); diff --git a/source/client/renderer/entity/MobRenderer.cpp b/source/client/renderer/entity/MobRenderer.cpp index 13d7ba76e..8e589c112 100644 --- a/source/client/renderer/entity/MobRenderer.cpp +++ b/source/client/renderer/entity/MobRenderer.cpp @@ -113,10 +113,10 @@ void MobRenderer::render(const Entity& entity, const Vec3& pos, float rot, float scale(mob, matrix, a); matrix->translate(Vec3(0.0f, -24.0f * fScale - (1.0f / 128.0f), 0.0f)); - float x1 = mob.field_128 + (mob.m_walkAnimSpeed - mob.field_128) * a; + float x1 = mob.m_walkAnimSpeedO + (mob.m_walkAnimSpeed - mob.m_walkAnimSpeedO) * a; if (x1 > 1.0f) x1 = 1.0f; - float x2 = mob.field_130 - mob.m_walkAnimSpeed * (1.0f - a); + float x2 = mob.m_walkAnimPos - mob.m_walkAnimSpeed * (1.0f - a); _setupShaderParameters(entity, a); diff --git a/source/client/renderer/entity/TripodCameraRenderer.cpp b/source/client/renderer/entity/TripodCameraRenderer.cpp index 5855de00f..eb2649ff2 100644 --- a/source/client/renderer/entity/TripodCameraRenderer.cpp +++ b/source/client/renderer/entity/TripodCameraRenderer.cpp @@ -22,10 +22,10 @@ TripodCameraRenderer::TripodCameraRenderer() float TripodCameraRenderer::getFlashTime(const TripodCamera& camera, float f) { - if (camera.field_B90 > 7 || camera.field_B90 < 0) + if (camera.m_countdown > 7 || camera.m_countdown < 0) return -1.0f; - return 0.125f * (float(camera.field_B90) - f); + return 0.125f * (float(camera.m_countdown) - f); } void TripodCameraRenderer::render(const Entity& entity, const Vec3& pos, float rot, float a) diff --git a/source/client/sound/SoundEngine.cpp b/source/client/sound/SoundEngine.cpp index f27a91623..57e13478b 100644 --- a/source/client/sound/SoundEngine.cpp +++ b/source/client/sound/SoundEngine.cpp @@ -184,7 +184,7 @@ void SoundEngine::play(const std::string& name, const Vec3& pos, float volume, f void SoundEngine::playUI(const std::string& name, float volume, float pitch) { - volume *= 0.25F; // present on Java b1.2_02, but not Pocket for some reason + volume *= 0.25f; // present on Java b1.2_02, but not Pocket for some reason float vol = m_pOptions->m_masterVolume.get() * volume; if (vol <= 0.0f) return; diff --git a/source/common/SmoothFloat.cpp b/source/common/SmoothFloat.cpp index 2791526a6..0f6a5dfb8 100644 --- a/source/common/SmoothFloat.cpp +++ b/source/common/SmoothFloat.cpp @@ -9,23 +9,23 @@ #include "SmoothFloat.hpp" SmoothFloat::SmoothFloat() : - field_0(0), - field_4(0), - field_8(0) + m_desiredValue(0), + m_currentValue(0), + m_velocity(0) { } -float SmoothFloat::getNewDeltaValue(float a1, float a2) +float SmoothFloat::getNewDeltaValue(float inputDelta, float speed) { - field_0 += a1; + m_desiredValue += inputDelta; - float v1 = (field_0 - field_4) * a2; - field_8 += 0.5f * (v1 - field_8); + float v1 = (m_desiredValue - m_currentValue) * speed; + m_velocity += 0.5f * (v1 - m_velocity); - if ((v1 > 0.0f && field_8 < v1) || (v1 < 0.0f && field_8 > v1)) - v1 = field_8; + if ((v1 > 0.0f && m_velocity < v1) || (v1 < 0.0f && m_velocity > v1)) + v1 = m_velocity; - field_4 += v1; + m_currentValue += v1; return v1; } diff --git a/source/common/SmoothFloat.hpp b/source/common/SmoothFloat.hpp index 2331608f1..ccccd78a2 100644 --- a/source/common/SmoothFloat.hpp +++ b/source/common/SmoothFloat.hpp @@ -12,11 +12,13 @@ class SmoothFloat { public: SmoothFloat(); - float getNewDeltaValue(float, float); + +public: + float getNewDeltaValue(float inputDelta, float speed); private: - float field_0; - float field_4; - float field_8; + float m_desiredValue; + float m_currentValue; + float m_velocity; }; diff --git a/source/network/packets/StartGamePacket.cpp b/source/network/packets/StartGamePacket.cpp index b27540dd9..5d1ba7a9b 100644 --- a/source/network/packets/StartGamePacket.cpp +++ b/source/network/packets/StartGamePacket.cpp @@ -25,7 +25,7 @@ void StartGamePacket::write(RakNet::BitStream& bs) bs.Write(m_entityId); // probably older, you figure it out #if NETWORK_PROTOCOL_VERSION >= 29 - bs.Write(m_time); + bs.Write(m_lifetime); #endif bs.Write(m_pos.x); bs.Write(m_pos.y); @@ -43,7 +43,7 @@ void StartGamePacket::read(RakNet::BitStream& bs) #endif bs.Read(m_entityId); #if NETWORK_PROTOCOL_VERSION >= 29 - bs.Read(m_time); + bs.Read(m_lifetime); #endif bs.Read(m_pos.x); bs.Read(m_pos.y); diff --git a/source/world/entity/Animal.cpp b/source/world/entity/Animal.cpp index 8719bf4c2..734ce8319 100644 --- a/source/world/entity/Animal.cpp +++ b/source/world/entity/Animal.cpp @@ -79,7 +79,7 @@ float Animal::getWalkTargetValue(const TilePos& pos) const /*bool Animal::hurt(Entity* pCulprit, int damage) { // Run around erratically for three seconds. - field_BA4 = 60; + m_goCrazyTicks = 60; m_pAttackTarget = nullptr; field_BB4 = 0; diff --git a/source/world/entity/Arrow.cpp b/source/world/entity/Arrow.cpp index f01ab25f1..b9f4c7090 100644 --- a/source/world/entity/Arrow.cpp +++ b/source/world/entity/Arrow.cpp @@ -237,7 +237,7 @@ void Arrow::playerTouch(Player* pPlayer) { if (!m_pLevel->m_bIsClientSide) { - // had m_owner == pPlayer, but this logic breaks when loaded from a save, and m_owner is null + // had m_pPlayer == pPlayer, but this logic breaks when loaded from a save, and m_pPlayer is null if (m_bInGround && m_bIsPlayerOwned && m_shakeTime <= 0) { ItemStack arrow(Item::arrow, 1); diff --git a/source/world/entity/Chicken.hpp b/source/world/entity/Chicken.hpp index ecdb15bde..2cf658c94 100644 --- a/source/world/entity/Chicken.hpp +++ b/source/world/entity/Chicken.hpp @@ -22,6 +22,7 @@ class Chicken : public Animal public: Chicken(Level* pLevel); +public: std::string getAmbientSound() const override { return "mob.chicken"; } std::string getDeathSound() const override { return "mob.chickenhurt"; } std::string getHurtSound() const override { return "mob.chickenhurt"; } diff --git a/source/world/entity/Cow.hpp b/source/world/entity/Cow.hpp index 4f8b2b9b1..1a000117d 100644 --- a/source/world/entity/Cow.hpp +++ b/source/world/entity/Cow.hpp @@ -14,6 +14,7 @@ class Cow : public Animal public: Cow(Level* pLevel); +public: std::string getAmbientSound() const override { return "mob.cow"; }; std::string getDeathSound() const override { return "mob.cowhurt"; } std::string getHurtSound() const override { return "mob.cowhurt"; } diff --git a/source/world/entity/Creeper.hpp b/source/world/entity/Creeper.hpp index 22c30658f..fe8478790 100644 --- a/source/world/entity/Creeper.hpp +++ b/source/world/entity/Creeper.hpp @@ -10,6 +10,7 @@ class Creeper : public Monster public: Creeper(Level* pLevel); +public: void tick() override; std::string getHurtSound() const override { return "mob.creeper"; } std::string getDeathSound() const override { return "mob.creeperdeath"; } @@ -18,8 +19,8 @@ class Creeper : public Monster void setSwellDir(int value) { m_entityData.set(DATA_SWELL_DIR, value); } int getDeathLoot() const override { return ITEM_SULPHUR; } - virtual void die(Entity* pCulprit) override; - virtual void checkHurtTarget(Entity*, float) override; + void die(Entity* pCulprit) override; + void checkHurtTarget(Entity*, float) override; private: void _defineEntityData(); diff --git a/source/world/entity/Entity.cpp b/source/world/entity/Entity.cpp index 57841470f..69626c536 100644 --- a/source/world/entity/Entity.cpp +++ b/source/world/entity/Entity.cpp @@ -23,10 +23,7 @@ Random Entity::sharedRandom; void Entity::_init() { m_bInAChunk = false; - field_20 = 0; - field_24 = 0; - field_28 = 0; - field_30 = 1.0f; + m_viewScale = 1.0f; m_dimensionId = DIMENSION_OVERWORLD; m_bBlocksBuilding = false; m_pLevel = nullptr; @@ -44,7 +41,7 @@ void Entity::_init() m_heightOffset = 0.0f; m_bbWidth = 0.6f; m_bbHeight = 1.8f; - field_90 = 0.0f; + m_walkDistO = 0.0f; m_walkDist = 0.0f; m_bMakeStepSound = true; m_ySlideOffset = 0.0f; @@ -470,7 +467,7 @@ void Entity::baseTick() { //@TODO: untangle the gotos - field_90 = m_walkDist; + m_walkDistO = m_walkDist; m_oPos = m_pos; m_tickCount++; m_oRot = m_rot; @@ -728,9 +725,9 @@ float Entity::distanceToSqr(const Vec3& pos) const return m_pos.distanceToSqr(pos); } -int Entity::interactPreventDefault() +bool Entity::interactPreventDefault() const { - return 0; + return false; } bool Entity::interact(Player* player) @@ -778,7 +775,7 @@ bool Entity::shouldRender(Vec3& camPos) const bool Entity::shouldRenderAtSqrDistance(float distSqr) const { - float maxDist = (field_30 * 64.0f) * (((m_hitbox.max.z - m_hitbox.min.z) + (m_hitbox.max.x - m_hitbox.min.x) + (m_hitbox.max.y - m_hitbox.min.y)) / 3.0f); + float maxDist = (m_viewScale * 64.0f) * (((m_hitbox.max.z - m_hitbox.min.z) + (m_hitbox.max.x - m_hitbox.min.x) + (m_hitbox.max.y - m_hitbox.min.y)) / 3.0f); return maxDist * maxDist > distSqr; } diff --git a/source/world/entity/Entity.hpp b/source/world/entity/Entity.hpp index 917eb9832..3780cb7b1 100644 --- a/source/world/entity/Entity.hpp +++ b/source/world/entity/Entity.hpp @@ -162,7 +162,7 @@ class Entity virtual float distanceToSqr(const Vec3& pos) const; virtual float distanceTo(const Vec3& pos) const; virtual float distanceToSqr(const Entity*) const; - virtual int interactPreventDefault(); + virtual bool interactPreventDefault() const; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Woverloaded-virtual" virtual bool interact(Player*); @@ -242,11 +242,8 @@ class Entity bool m_bInAChunk; ChunkPos m_chunkPos; int m_chunkPosY; - int field_20; // unused Vec3? - int field_24; - int field_28; Entity::ID m_EntityID; - float field_30; + float m_viewScale; //TileSource* m_pTileSource; DimensionId m_dimensionId; bool m_bBlocksBuilding; @@ -270,7 +267,7 @@ class Entity float m_heightOffset; float m_bbWidth; float m_bbHeight; - float field_90; + float m_walkDistO; float m_walkDist; Vec3 m_posPrev; float m_ySlideOffset; diff --git a/source/world/entity/FallingTile.cpp b/source/world/entity/FallingTile.cpp index c5987a171..602d84bd1 100644 --- a/source/world/entity/FallingTile.cpp +++ b/source/world/entity/FallingTile.cpp @@ -20,7 +20,7 @@ void FallingTile::_init(Level*, const Vec3& pos, int id) _defineEntityData(); setTile(id); - field_E0 = 0; + m_time = 0; m_bBlocksBuilding = false; setSize(0.98f, 0.98f); m_heightOffset = m_bbHeight * 0.5f; @@ -61,7 +61,7 @@ void FallingTile::tick() remove(); m_oPos = m_pos; - field_E0++; + m_time++; m_vel.y -= 0.04f; move(m_vel); @@ -77,7 +77,7 @@ void FallingTile::tick() if (!m_bOnGround) { - if (field_E0 > 100 && !m_pLevel->m_bIsClientSide) + if (m_time > 100 && !m_pLevel->m_bIsClientSide) { spawnAtLocation(getTile(), 1); remove(); diff --git a/source/world/entity/FallingTile.hpp b/source/world/entity/FallingTile.hpp index cb894f4ab..620e02756 100644 --- a/source/world/entity/FallingTile.hpp +++ b/source/world/entity/FallingTile.hpp @@ -34,6 +34,6 @@ class FallingTile : public Entity Level* getLevel() { return m_pLevel; } public: - int field_E0; + int m_time; }; diff --git a/source/world/entity/Mob.cpp b/source/world/entity/Mob.cpp index 339086332..b09886270 100644 --- a/source/world/entity/Mob.cpp +++ b/source/world/entity/Mob.cpp @@ -30,28 +30,26 @@ void Mob::_init() m_attackTime = 0; m_oTilt = 0.0f; m_tilt = 0.0f; - field_120 = 0; - field_124 = 0; - field_128 = 0.0f; + m_lookTime = 0; + m_modelNum = -1; + m_walkAnimSpeedO = 0.0f; m_walkAnimSpeed = 0.0f; - field_130 = 0.0f; + m_walkAnimPos = 0.0f; m_noActionTime = 0; m_moveVelocity = Vec2::ZERO; m_yRotA = 0.0f; m_bJumping = false; - field_B10 = 0; + m_defaultLookAngle = 0; m_runSpeed = 0.7f; m_flyingFriction = 0.02f; - field_B48 = 0; - field_B4C = 0.0f; - field_B50 = 0.0f; - field_B54 = 0.0f; - field_B58 = 0.0f; + m_deathScore = 0; + m_oRun = 0.0f; + m_run = 0.0f; + m_animStep = 0.0f; + m_animStepO = 0.0f; m_rotOffs = 0.0f; - field_B60 = 1.0f; - field_B64 = 0; - field_B68 = 1; - field_B69 = 0; + m_bobStrength = 1.0f; + m_bDead = false; m_lSteps = 0; m_lPos = Vec3::ZERO; m_lRot = Vec2::ZERO; @@ -71,9 +69,9 @@ Mob::Mob(Level* pLevel) : Entity(pLevel) m_bBlocksBuilding = true; - field_E4 = (Mth::random() + 1.0f) * 0.01f; + m_rotA = (Mth::random() + 1.0f) * 0.01f; setPos(m_pos); - field_E0 = Mth::random() * 12398.0f; + m_timeOffs = Mth::random() * 12398.0f; m_rot.x = float(Mth::random() * M_PI); m_footSize = 0.5f; } @@ -135,7 +133,7 @@ void Mob::tick() yBodyRot = m_yBodyRot; x1 = yBodyRot; - field_B4C = field_B50; + m_oRun = m_run; if (dist > 0.05f) { @@ -160,7 +158,7 @@ void Mob::tick() if (!m_bOnGround) x3 = 0.0f; - field_B50 += (x3 - field_B50) * 0.3f; + m_run += (x3 - m_run) * 0.3f; // Similar to rotlerp @@ -233,7 +231,7 @@ void Mob::tick() while (m_rot.y - m_oRot.y >= 180.0f) m_oRot.y += 360.0f; - field_B54 += x2; + m_animStep += x2; } void Mob::baseTick() @@ -314,7 +312,7 @@ void Mob::baseTick() } } - field_B58 = field_B54; + m_animStepO = m_animStep; m_yBodyRotO = m_yBodyRot; m_oRot = m_rot; @@ -403,11 +401,16 @@ bool Mob::hurt(Entity *pAttacker, int damage) zd = 0.01f * (Mth::random() - Mth::random()); } - float ang = atan2f(zd, xd); - v020_field_104 = ang * (180.0f / float(M_PI)) - m_rot.x; + float ang = Mth::atan2(zd, xd); + m_hurtDir = ang * (180.0f / float(M_PI)) - m_rot.x; knockback(pAttacker, damage, xd, zd); } + else + { + // b1.2, might not be present in PE + m_hurtDir = (Mth::random() * 2.0f) * 180.0f; + } } if (m_health <= 0) @@ -430,9 +433,8 @@ bool Mob::hurt(Entity *pAttacker, int damage) void Mob::animateHurt() { - m_hurtDuration = 10; + m_hurtTime = m_hurtDuration = 10; m_hurtDir = 0; - m_hurtTime = 10; } void Mob::setSize(float rad, float height) @@ -686,10 +688,10 @@ void Mob::travel(const Vec2& pos) void Mob::die(Entity* pCulprit) { - if (pCulprit && field_B48 > 0) - pCulprit->awardKillScore(pCulprit, field_B48); + if (pCulprit && m_deathScore > 0) + pCulprit->awardKillScore(pCulprit, m_deathScore); - field_B69 = true; + m_bDead = true; if (!m_pLevel->m_bIsClientSide) { @@ -710,7 +712,7 @@ bool Mob::canSee(Entity* pEnt) const void Mob::updateWalkAnim() { - field_128 = m_walkAnimSpeed; + m_walkAnimSpeedO = m_walkAnimSpeed; float diffX = m_pos.x - m_oPos.x; float diffZ = m_pos.z - m_oPos.z; @@ -720,7 +722,7 @@ void Mob::updateWalkAnim() spd = 1.0f; m_walkAnimSpeed += (spd - m_walkAnimSpeed) * 0.4f; - field_130 += m_walkAnimSpeed; + m_walkAnimPos += m_walkAnimSpeed; } void Mob::aiStep() @@ -834,7 +836,7 @@ void Mob::updateAi() { m_pEntLookedAt = nearestPlayer; - field_120 = m_random.nextInt(20) + 10; + m_lookTime = m_random.nextInt(20) + 10; } else { @@ -848,10 +850,10 @@ void Mob::updateAi() lookAt(m_pEntLookedAt, 10.0f, getMaxHeadXRot()); // gaze timer - field_120--; + m_lookTime--; // if the entity was removed, or we're too far away, or our gaze timer is up - if (field_120 < 0 || m_pEntLookedAt->m_bRemoved || m_pEntLookedAt->distanceToSqr(this) > 64.0f) + if (m_lookTime < 0 || m_pEntLookedAt->m_bRemoved || m_pEntLookedAt->distanceToSqr(this) > 64.0f) // stop staring m_pEntLookedAt = nullptr; } @@ -860,8 +862,9 @@ void Mob::updateAi() if (m_random.nextFloat() < 0.05f) m_yRotA = (m_random.nextFloat() - 0.5f) * 20.0f; + // oh my god, our X and Y rot are mixed around m_rot.x += m_yRotA; - m_rot.y = field_B10; + m_rot.y = m_defaultLookAngle; } if (isInWater() || isInLava()) diff --git a/source/world/entity/Mob.hpp b/source/world/entity/Mob.hpp index 4ad46de92..ef91d1366 100644 --- a/source/world/entity/Mob.hpp +++ b/source/world/entity/Mob.hpp @@ -99,8 +99,8 @@ class Mob : public Entity public: int m_invulnerableDuration; - float field_E0; - float field_E4; + float m_timeOffs; + float m_rotA; float m_yBodyRot; float m_yBodyRotO; float m_oAttackAnim; @@ -114,39 +114,35 @@ class Mob : public Entity int m_attackTime; float m_oTilt; float m_tilt; - int field_120; - int field_124; - float field_128; + int m_lookTime; + int m_modelNum; + float m_walkAnimSpeedO; float m_walkAnimSpeed; - float field_130; + float m_walkAnimPos; Random m_random; int m_noActionTime; Vec2 m_moveVelocity; float m_yRotA; bool m_bJumping; - float field_B10; + float m_defaultLookAngle; float m_runSpeed; float m_flyingFriction; std::string m_texture; std::string m_class; - int field_B48; - float field_B4C; - float field_B50; - float field_B54; - float field_B58; + int m_deathScore; + float m_oRun; + float m_run; + float m_animStep; + float m_animStepO; float m_rotOffs; - float field_B60; - int field_B64; - char field_B68; - char field_B69; + float m_bobStrength; + bool m_bDead; int m_lSteps; Vec3 m_lPos; Vec2 m_lRot; int m_lastHurt; Entity* m_pEntLookedAt; - float v020_field_104; - bool m_bSwinging; int m_swingTime; }; diff --git a/source/world/entity/MobCategory.cpp b/source/world/entity/MobCategory.cpp index ebcbd7999..1353ab9f8 100644 --- a/source/world/entity/MobCategory.cpp +++ b/source/world/entity/MobCategory.cpp @@ -12,11 +12,11 @@ const MobCategory* MobCategory::all[] = { }; const unsigned int MobCategory::allCount = sizeof(MobCategory::all) / sizeof(MobCategory*); -MobCategory::MobCategory(const EntityCategories& baseType, int unknown, int max, const Material* material, bool friendly) +MobCategory::MobCategory(const EntityCategories& baseType, int min, int max, const Material* material, bool friendly) : m_baseType(baseType) { - m_maxInstancesPerChunk = max; - field_4 = unknown; + m_min = min; + m_max = max; m_pSpawnPositionMaterial = material; m_bIsFriendly = friendly; } diff --git a/source/world/entity/MobCategory.hpp b/source/world/entity/MobCategory.hpp index cda8eb3c9..ceec8f385 100644 --- a/source/world/entity/MobCategory.hpp +++ b/source/world/entity/MobCategory.hpp @@ -13,21 +13,21 @@ class MobCategory static const unsigned int allCount; private: - MobCategory(const EntityCategories&, int, int, const Material*, bool); + MobCategory(const EntityCategories& baseType, int min, int max, const Material* material, bool friendly); public: static void initMobCategories(); public: const EntityCategories& getBaseType() const { return m_baseType; } - int getMaxInstancesPerChunk() const { return m_maxInstancesPerChunk; } + int getMaxInstancesPerChunk() const { return m_max; } const Material* getSpawnPositionMaterial() const { return m_pSpawnPositionMaterial; } bool isFriendly() const { return m_bIsFriendly; } private: EntityCategories m_baseType; - int field_4; - int m_maxInstancesPerChunk; + int m_min; + int m_max; const Material* m_pSpawnPositionMaterial; bool m_bIsFriendly; }; diff --git a/source/world/entity/PathfinderMob.cpp b/source/world/entity/PathfinderMob.cpp index fd8bd36ce..94a3eec11 100644 --- a/source/world/entity/PathfinderMob.cpp +++ b/source/world/entity/PathfinderMob.cpp @@ -14,7 +14,7 @@ PathfinderMob::PathfinderMob(Level* pLevel) : Mob(pLevel) { m_pAttackTarget = nullptr; m_bHoldGround = false; - field_BA4 = 0; + m_goCrazyTicks = 0; } Entity* PathfinderMob::getAttackTarget() @@ -85,7 +85,7 @@ float PathfinderMob::getWalkingSpeedModifier() const { float mod = Mob::getWalkingSpeedModifier(); - if (field_BA4 > 0) + if (m_goCrazyTicks > 0) mod *= 2.0f; return mod; @@ -101,8 +101,8 @@ bool PathfinderMob::canSpawn() void PathfinderMob::updateAi() { - if (field_BA4 > 0) - field_BA4--; + if (m_goCrazyTicks > 0) + m_goCrazyTicks--; m_bHoldGround = shouldHoldGround(); @@ -133,7 +133,7 @@ void PathfinderMob::updateAi() { m_pLevel->findPath(&m_path, this, m_pAttackTarget, 16.0f); } - else if (!m_bHoldGround && ((m_path.empty() && m_random.nextInt(180) == 0) || field_BA4 > 0 || m_random.nextInt(120) == 0)) + else if (!m_bHoldGround && ((m_path.empty() && m_random.nextInt(180) == 0) || m_goCrazyTicks > 0 || m_random.nextInt(120) == 0)) { if (m_noActionTime < 100) findRandomStrollLocation(); diff --git a/source/world/entity/PathfinderMob.hpp b/source/world/entity/PathfinderMob.hpp index 9b0059567..33b8d7b96 100644 --- a/source/world/entity/PathfinderMob.hpp +++ b/source/world/entity/PathfinderMob.hpp @@ -35,6 +35,6 @@ class PathfinderMob : public Mob friend class Animal; Entity* m_pAttackTarget; bool m_bHoldGround; - int field_BA4; + int m_goCrazyTicks; Path m_path; }; diff --git a/source/world/entity/Pig.hpp b/source/world/entity/Pig.hpp index fb1d9ae77..c617da1a6 100644 --- a/source/world/entity/Pig.hpp +++ b/source/world/entity/Pig.hpp @@ -14,6 +14,7 @@ class Pig : public Animal public: Pig(Level* pLevel); +public: std::string getAmbientSound() const override { return "mob.pig"; }; std::string getDeathSound() const override { return "mob.pigdeath"; } std::string getHurtSound() const override { return "mob.pig"; } diff --git a/source/world/entity/Player.cpp b/source/world/entity/Player.cpp index 9c9911036..7f689513d 100644 --- a/source/world/entity/Player.cpp +++ b/source/world/entity/Player.cpp @@ -32,7 +32,7 @@ Player::Player(Level* pLevel, GameType playerGameType) : Mob(pLevel) _init(); m_pDescriptor = &EntityTypeDescriptor::player; m_pInventory = nullptr; - field_B94 = 0; + m_userType = 0; m_name = ""; m_bHasRespawnPos = false; diff --git a/source/world/entity/Player.hpp b/source/world/entity/Player.hpp index 35d7431fb..c75ff8831 100644 --- a/source/world/entity/Player.hpp +++ b/source/world/entity/Player.hpp @@ -122,11 +122,10 @@ class Player : public Mob int32_t m_itemInUseDuration; public: - //TODO Inventory* m_pInventory; InventoryMenu* m_pInventoryMenu; ContainerMenu* m_pContainerMenu; - uint8_t field_B94; + int8_t m_userType; // Classic leftover? possibly for a player rank? int m_jumpTriggerTime; int m_score; float m_oBob; @@ -136,11 +135,8 @@ class Player : public Mob int m_dimension; RakNet::RakNetGUID m_guid; bool m_bFlying; - //TODO TilePos m_respawnPos; - //TODO bool m_bHasRespawnPos; - //TODO bool m_destroyingBlock; }; diff --git a/source/world/entity/PrimedTnt.hpp b/source/world/entity/PrimedTnt.hpp index eb621d094..7a84a8faa 100644 --- a/source/world/entity/PrimedTnt.hpp +++ b/source/world/entity/PrimedTnt.hpp @@ -18,6 +18,7 @@ class PrimedTnt : public Entity PrimedTnt(Level* level) : Entity(level) { _init(); } PrimedTnt(Level* level, const Vec3& pos); +public: float getShadowHeightOffs() const override; bool isPickable() const override; void tick() override; diff --git a/source/world/entity/Rocket.cpp b/source/world/entity/Rocket.cpp index 73ed2ee93..f1a321fe1 100644 --- a/source/world/entity/Rocket.cpp +++ b/source/world/entity/Rocket.cpp @@ -12,8 +12,7 @@ Rocket::Rocket(Level* level, const Vec3& pos) : Entity(level) { - field_B8C = 0; - field_B90 = 80; + m_lifetime = 80; m_renderType = RENDER_ROCKET; m_bBlocksBuilding = true; @@ -37,9 +36,9 @@ bool Rocket::interact(Player* player) return true; } -int Rocket::interactPreventDefault() +bool Rocket::interactPreventDefault() const { - return 1; + return true; } bool Rocket::isPickable() const @@ -60,8 +59,8 @@ void Rocket::tick() move(m_vel); - field_B90--; - if (field_B90 == 0) + m_lifetime--; + if (m_lifetime == 0) { for (int i = 0; i < 100; i++) { diff --git a/source/world/entity/Rocket.hpp b/source/world/entity/Rocket.hpp index 3fb9dd88e..1cef87bcb 100644 --- a/source/world/entity/Rocket.hpp +++ b/source/world/entity/Rocket.hpp @@ -18,15 +18,15 @@ class Rocket : public Entity public: Rocket(Level*, const Vec3& pos); +public: float getShadowHeightOffs() const override; bool interact(Player* player) override; - int interactPreventDefault() override; + bool interactPreventDefault() const override; bool isPickable() const override; bool isPushable() const override; void tick() override; public: - int field_B8C; - int field_B90; + int m_lifetime; }; diff --git a/source/world/entity/Sheep.hpp b/source/world/entity/Sheep.hpp index 6cd8f69bc..d36cfa66a 100644 --- a/source/world/entity/Sheep.hpp +++ b/source/world/entity/Sheep.hpp @@ -30,5 +30,6 @@ class Sheep : public Animal bool isSheared() const; void setSheared(bool); +public: static int getSheepColor(Random&); }; diff --git a/source/world/entity/Skeleton.hpp b/source/world/entity/Skeleton.hpp index 24261de63..a4fc548c4 100644 --- a/source/world/entity/Skeleton.hpp +++ b/source/world/entity/Skeleton.hpp @@ -11,6 +11,7 @@ class Skeleton : public Monster public: Skeleton(Level* pLevel); +public: std::string getAmbientSound() const override { return "mob.skeleton"; } std::string getDeathSound() const override { return "mob.skeletonhurt"; } std::string getHurtSound() const override { return "mob.skeletonhurt"; } diff --git a/source/world/entity/Spider.hpp b/source/world/entity/Spider.hpp index e176275ca..4ecc268ee 100644 --- a/source/world/entity/Spider.hpp +++ b/source/world/entity/Spider.hpp @@ -7,6 +7,7 @@ class Spider : public Monster public: Spider(Level* pLevel); +public: std::string getAmbientSound() const override { return "mob.spider"; } std::string getDeathSound() const override { return "mob.spiderdeath"; } std::string getHurtSound() const override { return "mob.spider"; } diff --git a/source/world/entity/TripodCamera.cpp b/source/world/entity/TripodCamera.cpp index aa193e799..460bdfb9c 100644 --- a/source/world/entity/TripodCamera.cpp +++ b/source/world/entity/TripodCamera.cpp @@ -10,13 +10,14 @@ #include "Player.hpp" #include "world/level/Level.hpp" +#define C_TIMER 80 + TripodCamera::TripodCamera(Level* level, Player* player, const Vec3& pos) : Mob(level) { - field_B8C = 0; - field_B90 = 80; - m_bActive = false; + m_countdown = C_TIMER; + m_bActivated = false; - m_owner = player; + m_pPlayer = player; m_renderType = RENDER_CAMERA; m_oRot = m_rot = player->m_rot; @@ -34,13 +35,13 @@ TripodCamera::TripodCamera(Level* level, Player* player, const Vec3& pos) : Mob( bool TripodCamera::interact(Player* player) { // @BUG-ish: No check for owner? - m_bActive = true; + m_bActivated = true; return true; } -int TripodCamera::interactPreventDefault() +bool TripodCamera::interactPreventDefault() const { - return 1; + return true; } void TripodCamera::tick() @@ -58,26 +59,22 @@ void TripodCamera::tick() m_vel.y *= -0.5f; } - if (!m_bActive) + if (!m_bActivated) return; - field_B90--; - if (field_B90 == 0) + m_countdown--; + if (m_countdown == 0) { remove(); - return; } - - if (field_B90 == 8) + else if (m_countdown == 8) { - m_pLevel->takePicture(this, m_owner); + m_pLevel->takePicture(this, m_pPlayer); m_pLevel->addParticle("explode", Vec3(m_pos.x, m_pos.y + 0.6f, m_pos.z)); m_pLevel->addParticle("explode", Vec3(m_pos.x, m_pos.y + 0.8f, m_pos.z)); m_pLevel->addParticle("explode", Vec3(m_pos.x, m_pos.y + 1.0f, m_pos.z)); - return; } - - if (field_B90 > 8) + else if (m_countdown > 8) { m_pLevel->addParticle("smoke", Vec3(m_pos.x, m_pos.y + 1.0f, m_pos.z)); } diff --git a/source/world/entity/TripodCamera.hpp b/source/world/entity/TripodCamera.hpp index 611b1e412..cdf8ade07 100644 --- a/source/world/entity/TripodCamera.hpp +++ b/source/world/entity/TripodCamera.hpp @@ -20,15 +20,14 @@ class TripodCamera : public Mob float getShadowHeightOffs() const override { return 0.0f; } bool interact(Player* player) override; - int interactPreventDefault() override; + bool interactPreventDefault() const override; bool isPickable() const override { return !m_bRemoved; } bool isPushable() const override { return false; } void tick() override; public: - int field_B8C; - int field_B90; - Player* m_owner; - bool m_bActive; + int m_countdown; + Player* m_pPlayer; + bool m_bActivated; }; diff --git a/source/world/entity/Zombie.hpp b/source/world/entity/Zombie.hpp index 53bd02736..f3c2c43b2 100644 --- a/source/world/entity/Zombie.hpp +++ b/source/world/entity/Zombie.hpp @@ -7,6 +7,7 @@ class Zombie : public Monster public: Zombie(Level* pLevel); +public: std::string getAmbientSound() const override { return "mob.zombie"; } std::string getDeathSound() const override { return "mob.zombiedeath"; } std::string getHurtSound() const override { return "mob.zombiehurt"; } diff --git a/source/world/gamemode/GameMode.cpp b/source/world/gamemode/GameMode.cpp index de4df7e50..ebd400e05 100644 --- a/source/world/gamemode/GameMode.cpp +++ b/source/world/gamemode/GameMode.cpp @@ -13,7 +13,7 @@ GameMode::GameMode(Minecraft* pMinecraft, Level& level) : _level(level), m_pMinecraft(pMinecraft), - field_8(0) + m_bInstaBuild(0) { } @@ -100,7 +100,7 @@ float GameMode::getEntityReachDistance() const LocalPlayer* GameMode::createPlayer(Level* pLevel) { - return new LocalPlayer(m_pMinecraft, pLevel, m_pMinecraft->m_pUser, pLevel->getDefaultGameType(), _level.m_pDimension->field_50); + return new LocalPlayer(m_pMinecraft, pLevel, m_pMinecraft->m_pUser, pLevel->getDefaultGameType(), _level.m_pDimension->m_id); } void GameMode::initPlayer(Player* pPlayer) diff --git a/source/world/gamemode/GameMode.hpp b/source/world/gamemode/GameMode.hpp index 70530a27a..8b0b58bcd 100644 --- a/source/world/gamemode/GameMode.hpp +++ b/source/world/gamemode/GameMode.hpp @@ -50,5 +50,5 @@ class GameMode public: Minecraft* m_pMinecraft; - uint8_t field_8; + uint8_t m_bInstaBuild; }; diff --git a/source/world/inventory/ResultSlot.cpp b/source/world/inventory/ResultSlot.cpp index e031887df..1a8a98a55 100644 --- a/source/world/inventory/ResultSlot.cpp +++ b/source/world/inventory/ResultSlot.cpp @@ -24,11 +24,11 @@ void ResultSlot::onTake(ItemStack& item) { item.onCraftedBy(m_pPlayer, m_pPlayer->m_pLevel); - //if (item.getId() == Tile::craftingTable->m_ID) + //if (item.getId() == Tile::craftingTable->id) // m_pPlayer->awardStat(Achievements::buildWorkBench); //else if (item.getId() == Item::woodPickaxe->getId()) // m_pPlayer->awardStat(Achievements::buildPickaxe); - //else if (item.getId() == Tile::furnace->m_ID) + //else if (item.getId() == Tile::furnace->id) // m_pPlayer->awardStat(Achievements::buildFurnace); //else if (item.getId() == Item::woodHoe->getId()) // m_pPlayer->awardStat(Achievements::buildHoe); diff --git a/source/world/item/AuxTileItem.hpp b/source/world/item/AuxTileItem.hpp index 3cc3a8c93..f6b3cfd0b 100644 --- a/source/world/item/AuxTileItem.hpp +++ b/source/world/item/AuxTileItem.hpp @@ -6,6 +6,8 @@ class AuxTileItem : public TileItem { public: AuxTileItem(int id); + +public: int getIcon(const ItemStack*) const override; TileData getLevelDataForAuxValue(int x) const override; }; diff --git a/source/world/item/BowItem.hpp b/source/world/item/BowItem.hpp index b27f4c929..b6e67a36b 100644 --- a/source/world/item/BowItem.hpp +++ b/source/world/item/BowItem.hpp @@ -7,5 +7,6 @@ class BowItem : public Item public: BowItem(int id); +public: ItemStack* use(ItemStack* inst, Level* level, Mob* user) const override; }; diff --git a/source/world/item/CameraItem.hpp b/source/world/item/CameraItem.hpp index 019d4d526..37979e55d 100644 --- a/source/world/item/CameraItem.hpp +++ b/source/world/item/CameraItem.hpp @@ -14,5 +14,6 @@ class CameraItem : public Item public: CameraItem(int id); +public: ItemStack* use(ItemStack* inst, Level* level, Mob* user) const override; }; diff --git a/source/world/item/ClothItem.hpp b/source/world/item/ClothItem.hpp index ad41e7c3a..131b22a1b 100644 --- a/source/world/item/ClothItem.hpp +++ b/source/world/item/ClothItem.hpp @@ -6,6 +6,8 @@ class ClothItem : public TileItem { public: ClothItem(int id); + +public: std::string getDescriptionId(ItemStack* item) const override; int getIcon(const ItemStack*) const override; TileData getLevelDataForAuxValue(int x) const override; diff --git a/source/world/item/CoalItem.hpp b/source/world/item/CoalItem.hpp index d27c54a99..b79c7d360 100644 --- a/source/world/item/CoalItem.hpp +++ b/source/world/item/CoalItem.hpp @@ -7,6 +7,6 @@ class CoalItem : public Item public: CoalItem(int id); +public: std::string getDescriptionId(ItemStack* inst) const override; - }; diff --git a/source/world/item/DoorItem.hpp b/source/world/item/DoorItem.hpp index d2d903789..cc880c3f0 100644 --- a/source/world/item/DoorItem.hpp +++ b/source/world/item/DoorItem.hpp @@ -14,6 +14,7 @@ class DoorItem : public Item public: DoorItem(int id, Material* pMtl); +public: bool useOn(ItemStack*, Player*, Level*, const TilePos& pos, Facing::Name face) const override; public: diff --git a/source/world/item/DyeColor.hpp b/source/world/item/DyeColor.hpp index 548541098..adeec2103 100644 --- a/source/world/item/DyeColor.hpp +++ b/source/world/item/DyeColor.hpp @@ -8,6 +8,7 @@ class DyeColor BLACK, RED, GREEN, BROWN, BLUE, PURPLE, CYAN, SILVER, GRAY, PINK, LIME, YELLOW, LIGHT_BLUE, MAGENTA, ORANGE, WHITE }; +public: static const char* IDS[]; static const int RGBS[]; }; diff --git a/source/world/item/DyePowderItem.hpp b/source/world/item/DyePowderItem.hpp index f530c51ba..4c09c0544 100644 --- a/source/world/item/DyePowderItem.hpp +++ b/source/world/item/DyePowderItem.hpp @@ -7,6 +7,7 @@ class DyePowderItem : public Item public: DyePowderItem(int); +public: int getIcon(const ItemStack*) const override; std::string getDescriptionId() const override; std::string getDescriptionId(ItemStack*) const override; diff --git a/source/world/item/Inventory.cpp b/source/world/item/Inventory.cpp index e0471397b..4e64e66fd 100644 --- a/source/world/item/Inventory.cpp +++ b/source/world/item/Inventory.cpp @@ -37,9 +37,9 @@ void Inventory::prepareSurvivalInventory() addTestItem(Item::wheat->m_itemID, 64); addTestItem(Item::sugar->m_itemID, 64); addTestItem(Item::camera->m_itemID, 64); - addTestItem(Tile::ladder->m_ID, 64); - addTestItem(Tile::obsidian->m_ID, 64); - addTestItem(Tile::fire->m_ID, 64);*/ + addTestItem(Tile::ladder->id, 64); + addTestItem(Tile::obsidian->id, 64); + addTestItem(Tile::fire->id, 64);*/ #ifdef MOD_POCKET_SURVIVAL diff --git a/source/world/item/RocketItem.hpp b/source/world/item/RocketItem.hpp index d2f86aa9f..6ce631bc0 100644 --- a/source/world/item/RocketItem.hpp +++ b/source/world/item/RocketItem.hpp @@ -14,5 +14,6 @@ class RocketItem : public Item public: RocketItem(int id); +public: bool useOn(ItemStack*, Player*, Level*, const TilePos& pos, Facing::Name face) const override; }; diff --git a/source/world/item/SlabItem.hpp b/source/world/item/SlabItem.hpp index 98f660165..95f88cb98 100644 --- a/source/world/item/SlabItem.hpp +++ b/source/world/item/SlabItem.hpp @@ -6,5 +6,7 @@ class SlabItem : public AuxTileItem { public: SlabItem(int id); + +public: std::string getDescriptionId(ItemStack* item) const override; }; diff --git a/source/world/item/TileItem.hpp b/source/world/item/TileItem.hpp index dd3ce2302..5a135d9b5 100644 --- a/source/world/item/TileItem.hpp +++ b/source/world/item/TileItem.hpp @@ -14,6 +14,7 @@ class TileItem : public Item public: TileItem(int id); +public: std::string getDescriptionId() const override; std::string getDescriptionId(ItemStack*) const override; bool useOn(ItemStack*, Player*, Level*, const TilePos& pos, Facing::Name face) const override; diff --git a/source/world/item/TilePlanterItem.hpp b/source/world/item/TilePlanterItem.hpp index 4e0b7387c..baff23129 100644 --- a/source/world/item/TilePlanterItem.hpp +++ b/source/world/item/TilePlanterItem.hpp @@ -14,6 +14,7 @@ class TilePlanterItem : public Item public: TilePlanterItem(int id, int place); +public: bool useOn(ItemStack*, Player*, Level*, const TilePos& pos, Facing::Name face) const override; public: diff --git a/source/world/item/WeaponItem.hpp b/source/world/item/WeaponItem.hpp index a4a7362ea..cf76d152b 100644 --- a/source/world/item/WeaponItem.hpp +++ b/source/world/item/WeaponItem.hpp @@ -7,6 +7,7 @@ class WeaponItem : public ToolItem public: WeaponItem(int id, Tier& tier); +public: float getDestroySpeed(ItemStack* instance, const Tile* tile) const override; void hurtEnemy(ItemStack* instance, Mob* mob) const override; void mineBlock(ItemStack* instance, const TilePos& pos, Facing::Name face, Mob* mob) const override; diff --git a/source/world/level/Dimension.cpp b/source/world/level/Dimension.cpp index f54372296..458f539ae 100644 --- a/source/world/level/Dimension.cpp +++ b/source/world/level/Dimension.cpp @@ -162,9 +162,9 @@ Dimension::Dimension() m_pLevel = nullptr; m_pBiomeSource = nullptr; m_bFoggy = false; - field_D = false; - field_E = false; - field_50 = 0; + m_bUltraWarm = false; + m_bHasCeiling = false; + m_id = 0; } Dimension::~Dimension() diff --git a/source/world/level/Dimension.hpp b/source/world/level/Dimension.hpp index d518625fb..07742f73a 100644 --- a/source/world/level/Dimension.hpp +++ b/source/world/level/Dimension.hpp @@ -47,10 +47,10 @@ class Dimension Level* m_pLevel; BiomeSource* m_pBiomeSource; bool m_bFoggy; - bool field_D; - bool field_E; + bool m_bUltraWarm; + bool m_bHasCeiling; float m_brightnessRamp[16]; - int field_50; + int m_id; float m_sunriseColor[4]; }; diff --git a/source/world/level/Level.cpp b/source/world/level/Level.cpp index e91a3c8f2..7c1cb488e 100644 --- a/source/world/level/Level.cpp +++ b/source/world/level/Level.cpp @@ -504,7 +504,7 @@ void Level::updateLight(const LightLayer& ll, const TilePos& tilePos1, const Til { static int nUpdateLevels; - if ((m_pDimension->field_E && &ll == &LightLayer::Sky) || !m_bUpdateLights) + if ((m_pDimension->m_bHasCeiling && &ll == &LightLayer::Sky) || !m_bUpdateLights) return; nUpdateLevels++; @@ -556,7 +556,7 @@ void Level::updateLight(const LightLayer& ll, const TilePos& tilePos1, const Til void Level::updateLightIfOtherThan(const LightLayer& ll, const TilePos& tilePos, int bright) { - if (m_pDimension->field_E && &ll == &LightLayer::Sky) + if (m_pDimension->m_bHasCeiling && &ll == &LightLayer::Sky) return; if (!hasChunkAt(tilePos)) @@ -1548,14 +1548,14 @@ void Level::tickPendingTicks(bool b) for (int i = 0; i < size; i++) { const TickNextTickData& t = *m_pendingTicks.begin(); - if (!b && t.m_delay > m_pLevelData->getTime()) + if (!b && t.delay > m_pLevelData->getTime()) break; - if (hasChunksAt(t.field_4 - 8, t.field_4 + 8)) + if (hasChunksAt(t.tilePos - 8, t.tilePos + 8)) { - TileID tile = getTile(t.field_4); - if (tile == t.field_10 && tile > 0) - Tile::tiles[tile]->tick(this, t.field_4, &m_random); + TileID tile = getTile(t.tilePos); + if (tile == t.tileId && tile > 0) + Tile::tiles[tile]->tick(this, t.tilePos, &m_random); } m_pendingTicks.erase(m_pendingTicks.begin()); @@ -1819,9 +1819,9 @@ void Level::addToTickNextTick(const TilePos& tilePos, int d, int delay) if (!hasChunksAt(tilePos, 8)) return; - TileID tile = getTile(tntd.field_4); - if (tile > 0 && tile == tntd.field_10) - Tile::tiles[tntd.field_10]->tick(this, tntd.field_4, &m_random); + TileID tile = getTile(tntd.tilePos); + if (tile > 0 && tile == tntd.tileId) + Tile::tiles[tntd.tileId]->tick(this, tntd.tilePos, &m_random); } else { diff --git a/source/world/level/TickNextTickData.cpp b/source/world/level/TickNextTickData.cpp index 7f4fbfbd1..06ca0bfa2 100644 --- a/source/world/level/TickNextTickData.cpp +++ b/source/world/level/TickNextTickData.cpp @@ -10,40 +10,34 @@ int TickNextTickData::C; -TickNextTickData::TickNextTickData(const TilePos& tilePos, int d) +TickNextTickData::TickNextTickData(const TilePos& tilePos, TileID tileId) + : id(++C) //@NOTE: not C++ + , tilePos(tilePos) + , tileId(tileId) { - m_ID = ++C; //@NOTE: not C++ - field_4 = tilePos; - field_10 = d; - #ifndef ORIGINAL_CODE - m_delay = 0; + delay = 0; #endif } int TickNextTickData::hashCode() const { - return field_10 + ((field_4.y + ((field_4.z + (field_4.x << 10)) << 7)) << 8); + return tileId + ((tilePos.y + ((tilePos.z + (tilePos.x << 10)) << 7)) << 8); } bool TickNextTickData::operator<(const TickNextTickData& other) const { - if (m_delay < other.m_delay) + if (delay < other.delay) return true; - if (m_delay > other.m_delay) + if (delay > other.delay) return false; - return m_ID < other.m_ID; + return id < other.id; } bool TickNextTickData::operator==(const TickNextTickData& other) const { return - field_4 == other.field_4 && - field_10 == other.field_10; -} - -void TickNextTickData::setDelay(int32_t l) -{ - m_delay = l; + tilePos == other.tilePos && + tileId == other.tileId; } diff --git a/source/world/level/TickNextTickData.hpp b/source/world/level/TickNextTickData.hpp index 84804aca6..0222de471 100644 --- a/source/world/level/TickNextTickData.hpp +++ b/source/world/level/TickNextTickData.hpp @@ -9,21 +9,22 @@ #pragma once #include +#include "common/Utils.hpp" #include "world/level/TilePos.hpp" struct TickNextTickData { static int C; - TickNextTickData(const TilePos& tilePos, int d); + TickNextTickData(const TilePos& tilePos, TileID tileId); int hashCode() const; bool operator<(const TickNextTickData& other) const; bool operator==(const TickNextTickData& other) const; - void setDelay(int32_t); + void setDelay(int32_t delay) { this->delay = delay; } - int m_ID; - TilePos field_4; - int field_10; - int32_t m_delay; + int id; + TilePos tilePos; + TileID tileId; + int32_t delay; }; diff --git a/source/world/level/levelgen/chunk/LevelChunk.cpp b/source/world/level/levelgen/chunk/LevelChunk.cpp index e0de339b4..3e36167dd 100644 --- a/source/world/level/levelgen/chunk/LevelChunk.cpp +++ b/source/world/level/levelgen/chunk/LevelChunk.cpp @@ -139,7 +139,7 @@ void LevelChunk::recalcHeightmap() x1 = x2; m_heightMap[MakeHeightMapIndex(pos)] = x2; - if (!m_pLevel->m_pDimension->field_E) + if (!m_pLevel->m_pDimension->m_bHasCeiling) { int x4 = 15; for (int x3 = 127; x3 > 0; x3--) @@ -651,7 +651,7 @@ bool LevelChunk::setTileAndData(const ChunkTilePos& pos, TileID tile, TileData d // update the data value of the block m_tileData.set(pos, data); - if (m_pLevel->m_pDimension->field_E) + if (m_pLevel->m_pDimension->m_bHasCeiling) { m_pLevel->updateLight(LightLayer::Block, tilePos, tilePos); lightGaps(pos); diff --git a/source/world/level/levelgen/chunk/RandomLevelSource.cpp b/source/world/level/levelgen/chunk/RandomLevelSource.cpp index 3f1446049..54fc6bc0e 100644 --- a/source/world/level/levelgen/chunk/RandomLevelSource.cpp +++ b/source/world/level/levelgen/chunk/RandomLevelSource.cpp @@ -89,7 +89,7 @@ LevelChunk* RandomLevelSource::getChunk(const ChunkPos& pos) // @NOTE: Java Edition Beta 1.6 uses the m_largeCaveFeature. #ifdef FEATURE_CAVES - m_largeCaveFeature.apply(this, m_pLevel, pos.x, pos.z, pLevelData, 0); + m_largeCaveFeature.apply(this, m_pLevel, tilePos.x, tilePos.z, pLevelData, 0); #endif return pChunk; @@ -597,7 +597,7 @@ void RandomLevelSource::postProcess(ChunkSource* src, const ChunkPos& pos) TilePos o(m_random.nextInt(16), m_random.nextInt(128), m_random.nextInt(16)); - VegetationFeature(Tile::tallGrass->m_ID, data).place(m_pLevel, &m_random, TilePos(tp.x + 8 + o.x, o.y, tp.z + 8 + o.z)); + VegetationFeature(Tile::tallGrass->id, data).place(m_pLevel, &m_random, TilePos(tp.x + 8 + o.x, o.y, tp.z + 8 + o.z)); } vegetationCount = 0; @@ -610,7 +610,7 @@ void RandomLevelSource::postProcess(ChunkSource* src, const ChunkPos& pos) int xo = m_random.nextInt(16); int yo = m_random.nextInt(128); int zo = m_random.nextInt(16); - VegetationFeature(Tile::deadBush->m_ID, 0, 4).place(m_pLevel, &m_random, TilePos(tp.x + 8 + xo, yo, tp.z + 8 + zo)); + VegetationFeature(Tile::deadBush->id, 0, 4).place(m_pLevel, &m_random, TilePos(tp.x + 8 + xo, yo, tp.z + 8 + zo)); } #endif float* tempBlock = m_pLevel->getBiomeSource()->getTemperatureBlock(tp.x + 8, tp.z + 8, 16, 16); diff --git a/source/world/level/path/BinaryHeap.cpp b/source/world/level/path/BinaryHeap.cpp index 5eed80453..fd1fa6b09 100644 --- a/source/world/level/path/BinaryHeap.cpp +++ b/source/world/level/path/BinaryHeap.cpp @@ -28,7 +28,7 @@ void BinaryHeap::insert(Node* pNode) } m_items[m_count] = pNode; - pNode->field_0 = m_count; + pNode->heapIdx = m_count; m_count++; inlined0(m_count - 1); @@ -39,25 +39,25 @@ void BinaryHeap::inlined0(int num) Node* var2 = m_items[num]; int var4; - for (float var3 = var2->field_C; num > 0; num = var4) { + for (float var3 = var2->f; num > 0; num = var4) { var4 = (num - 1) >> 1; Node* var5 = m_items[var4]; - if (var3 >= var5->field_C) { + if (var3 >= var5->f) { break; } m_items[num] = var5; - var5->field_0 = num; + var5->heapIdx = num; } m_items[num] = var2; - var2->field_0 = num; + var2->heapIdx = num; } void BinaryHeap::downHeap(int num) { Node* var2 = m_items[num]; - float var3 = var2->field_C; + float var3 = var2->f; while (true) { int var4 = 1 + (num << 1); @@ -67,7 +67,7 @@ void BinaryHeap::downHeap(int num) } Node* var6 = m_items[var4]; - float var7 = var6->field_C; + float var7 = var6->f; Node* var8; float var9; if (var5 >= m_count) { @@ -76,7 +76,7 @@ void BinaryHeap::downHeap(int num) } else { var8 = m_items[var5]; - var9 = var8->field_C; + var9 = var8->f; } if (var7 < var9) { @@ -85,7 +85,7 @@ void BinaryHeap::downHeap(int num) } m_items[num] = var6; - var6->field_0 = num; + var6->heapIdx = num; num = var4; } else { @@ -94,11 +94,11 @@ void BinaryHeap::downHeap(int num) } m_items[num] = var8; - var8->field_0 = num; + var8->heapIdx = num; num = var5; } } m_items[num] = var2; - var2->field_0 = num; + var2->heapIdx = num; } diff --git a/source/world/level/path/BinaryHeap.hpp b/source/world/level/path/BinaryHeap.hpp index e0142b685..523b1a6a6 100644 --- a/source/world/level/path/BinaryHeap.hpp +++ b/source/world/level/path/BinaryHeap.hpp @@ -37,7 +37,7 @@ class BinaryHeap if (m_count > 0) downHeap(0); - pNode->field_0 = -1; + pNode->heapIdx = -1; return pNode; } @@ -50,13 +50,13 @@ class BinaryHeap } void setDistance(Node* pNode, float distance) { - float oldDistance = pNode->field_C; - pNode->field_C = distance; + float oldDistance = pNode->f; + pNode->f = distance; if (oldDistance >= distance) - downHeap(pNode->field_0); + downHeap(pNode->heapIdx); else - inlined0(pNode->field_0); + inlined0(pNode->heapIdx); } private: diff --git a/source/world/level/path/Node.cpp b/source/world/level/path/Node.cpp index 5c7cca31f..9d6784c6e 100644 --- a/source/world/level/path/Node.cpp +++ b/source/world/level/path/Node.cpp @@ -10,8 +10,8 @@ float Node::distanceTo(Node* node) { - float dx = float(node->m_tilePos.x) - float(m_tilePos.x); - float dy = float(node->m_tilePos.y) - float(m_tilePos.y); - float dz = float(node->m_tilePos.z) - float(m_tilePos.z); + float dx = float(node->tilePos.x) - float(tilePos.x); + float dy = float(node->tilePos.y) - float(tilePos.y); + float dz = float(node->tilePos.z) - float(tilePos.z); return Mth::sqrt(dx * dx + dy * dy + dz * dz); } diff --git a/source/world/level/path/Node.hpp b/source/world/level/path/Node.hpp index 8225360d9..cfea479dd 100644 --- a/source/world/level/path/Node.hpp +++ b/source/world/level/path/Node.hpp @@ -13,14 +13,14 @@ struct Node { - int field_0; - float field_4; - float field_8; - float field_C; - Node* m_pCameFrom; - TilePos m_tilePos; - bool m_bClosed; - int m_hash; + int heapIdx; + float g; + float h; + float f; + Node* pCameFrom; + TilePos tilePos; + bool bClosed; + int hash; Node() { @@ -29,29 +29,29 @@ struct Node void setPos(const TilePos& tilePos) { - m_tilePos = tilePos; + this->tilePos = tilePos; } void setHash(int index) { - m_hash = index; + hash = index; } void init() { - field_0 = -1; - field_4 = 0.0f; - field_8 = 0.0f; - field_C = 0.0f; - m_pCameFrom = nullptr; - m_tilePos = TilePos(0, 0, 0); - m_bClosed = false; - m_hash = 0; + heapIdx = -1; + g = 0.0f; + h = 0.0f; + f = 0.0f; + pCameFrom = nullptr; + tilePos = TilePos(0, 0, 0); + bClosed = false; + hash = 0; } bool equals(Node* node) { - return m_hash == node->m_hash && m_tilePos == node->m_tilePos; + return hash == node->hash && tilePos == node->tilePos; } float distanceTo(Node* node); diff --git a/source/world/level/path/Path.cpp b/source/world/level/path/Path.cpp index cd7c9bcb1..98ee84a86 100644 --- a/source/world/level/path/Path.cpp +++ b/source/world/level/path/Path.cpp @@ -40,7 +40,7 @@ void Path::setNodes(Node** pNodes, int nodeCount) Vec3 Path::getPos(const Entity& e, int index) { - Vec3 result(m_pNodes[index]->m_tilePos); + Vec3 result(m_pNodes[index]->tilePos); float offset = float(int(e.m_bbWidth + 1.0f)) * 0.5f; // * 0.5f doesn't exist in 0.12.1, but does exist in later versions result.x += offset; result.z += offset; @@ -57,5 +57,5 @@ Vec3 Path::currentPos(const Entity& e) Vec3 Path::currentPos() { - return Vec3(getCurrentNode()->m_tilePos); + return Vec3(getCurrentNode()->tilePos); } diff --git a/source/world/level/path/PathFinder.cpp b/source/world/level/path/PathFinder.cpp index 1a25b4a08..dd8e53553 100644 --- a/source/world/level/path/PathFinder.cpp +++ b/source/world/level/path/PathFinder.cpp @@ -39,15 +39,16 @@ PathFinder::~PathFinder() m_nodeSpillover.clear(); } +// @TODO: return NodeType int PathFinder::isFree(Entity* pEntity, const TilePos& pos, const Node* node) { TilePos tp(pos); - for (tp.x = pos.x; tp.x < pos.x + node->m_tilePos.x; tp.x++) + for (tp.x = pos.x; tp.x < pos.x + node->tilePos.x; tp.x++) { - for (tp.y = pos.y; tp.y < pos.y + node->m_tilePos.y; tp.y++) + for (tp.y = pos.y; tp.y < pos.y + node->tilePos.y; tp.y++) { - for (tp.z = pos.z; tp.z < pos.z + node->m_tilePos.z; tp.z++) + for (tp.z = pos.z; tp.z < pos.z + node->tilePos.z; tp.z++) { TileID id = m_pLevel->getTile(tp); if (id <= 0) @@ -65,12 +66,12 @@ int PathFinder::isFree(Entity* pEntity, const TilePos& pos, const Node* node) } // 0.2.1 - /*if (id == Tile::water->m_ID || id == Tile::calmWater->m_ID) + /*if (id == Tile::water->id || id == Tile::calmWater->id) { if (field_100B9) // offset from 0.7.0 return 3; } - else */if (id == Tile::fence->m_ID/* || id == Tile::fenceGate->m_ID*/) + else */if (id == Tile::fence->m_ID/* || id == Tile::fenceGate->id*/) { return 0; // 1 on 0.2.1 } @@ -150,17 +151,17 @@ Node* PathFinder::getNode(const TilePos& pos) int PathFinder::getNeighbors(Entity* pEntity, Node* node1, const Node* node2, Node* node3, float maxDist) { int nr = 0; - bool isf = isFree(pEntity, node1->m_tilePos.above(), node2) == 1; // this is > 0 on b1.2_02, but == 1 on 0.12.1 + bool isf = isFree(pEntity, node1->tilePos.above(), node2) == 1; // this is > 0 on b1.2_02, but == 1 on 0.12.1 - Node* n1 = getNode(pEntity, node1->m_tilePos.south(), node2, isf); - Node* n2 = getNode(pEntity, node1->m_tilePos.west(), node2, isf); - Node* n3 = getNode(pEntity, node1->m_tilePos.east(), node2, isf); - Node* n4 = getNode(pEntity, node1->m_tilePos.north(), node2, isf); + Node* n1 = getNode(pEntity, node1->tilePos.south(), node2, isf); + Node* n2 = getNode(pEntity, node1->tilePos.west(), node2, isf); + Node* n3 = getNode(pEntity, node1->tilePos.east(), node2, isf); + Node* n4 = getNode(pEntity, node1->tilePos.north(), node2, isf); - if (n1 && !n1->m_bClosed && n1->distanceTo(node3) < maxDist) m_neighbors[nr++] = n1; - if (n2 && !n2->m_bClosed && n2->distanceTo(node3) < maxDist) m_neighbors[nr++] = n2; - if (n3 && !n3->m_bClosed && n3->distanceTo(node3) < maxDist) m_neighbors[nr++] = n3; - if (n4 && !n4->m_bClosed && n4->distanceTo(node3) < maxDist) m_neighbors[nr++] = n4; + if (n1 && !n1->bClosed && n1->distanceTo(node3) < maxDist) m_neighbors[nr++] = n1; + if (n2 && !n2->bClosed && n2->distanceTo(node3) < maxDist) m_neighbors[nr++] = n2; + if (n3 && !n3->bClosed && n3->distanceTo(node3) < maxDist) m_neighbors[nr++] = n3; + if (n4 && !n4->bClosed && n4->distanceTo(node3) < maxDist) m_neighbors[nr++] = n4; return nr; } @@ -172,9 +173,9 @@ bool PathFinder::reconstructPath(Path& path, Node* nodeEnd) int number = 1; Node* temp = nodeEnd; - while (temp->m_pCameFrom) + while (temp->pCameFrom) { - temp = temp->m_pCameFrom; + temp = temp->pCameFrom; number++; } @@ -183,10 +184,10 @@ bool PathFinder::reconstructPath(Path& path, Node* nodeEnd) pathNodes[index--] = nodeEnd; - while (nodeEnd->m_pCameFrom) + while (nodeEnd->pCameFrom) { - pathNodes[index--] = nodeEnd->m_pCameFrom; - nodeEnd = nodeEnd->m_pCameFrom; + pathNodes[index--] = nodeEnd->pCameFrom; + nodeEnd = nodeEnd->pCameFrom; } path.setNodes(pathNodes, number); @@ -197,8 +198,8 @@ bool PathFinder::findPath(Path& path, Entity* pEntity, Node* nodeStart, Node* no { dword_1CD868 = 0; - nodeStart->field_4 = 0; - nodeStart->field_C = nodeStart->field_8 = nodeStart->distanceTo(nodeEnd); + nodeStart->g = 0; + nodeStart->f = nodeStart->h = nodeStart->distanceTo(nodeEnd); m_binaryHeap.clear(); m_binaryHeap.insert(nodeStart); @@ -214,31 +215,31 @@ bool PathFinder::findPath(Path& path, Entity* pEntity, Node* nodeStart, Node* no if (nodep->distanceTo(nodeEnd) > pNode->distanceTo(nodeEnd)) nodep = pNode; - pNode->m_bClosed = true; + pNode->bClosed = true; int numNeighbors = getNeighbors(pEntity, pNode, node3, nodeEnd, fp); for (int i = 0; i < numNeighbors; i++) { Node* otherNode = m_neighbors[i]; - if (!otherNode->m_bClosed) + if (!otherNode->bClosed) { - float dist = pNode->field_4 + pNode->distanceTo(otherNode); - if (otherNode->field_0 < 0 || otherNode->field_4 > dist) + float dist = pNode->g + pNode->distanceTo(otherNode); + if (otherNode->heapIdx < 0 || otherNode->g > dist) { - otherNode->m_pCameFrom = pNode; - otherNode->field_4 = dist; - otherNode->field_8 = otherNode->distanceTo(nodeEnd); + otherNode->pCameFrom = pNode; + otherNode->g = dist; + otherNode->h = otherNode->distanceTo(nodeEnd); - if (otherNode->field_0 < 0) + if (otherNode->heapIdx < 0) { - otherNode->field_C = otherNode->field_4 + otherNode->field_8; + otherNode->f = otherNode->g + otherNode->h; m_binaryHeap.insert(otherNode); } else { // Update distance - m_binaryHeap.setDistance(otherNode, otherNode->field_4 + otherNode->field_8); + m_binaryHeap.setDistance(otherNode, otherNode->g + otherNode->h); } } } diff --git a/source/world/level/path/PathFinder.hpp b/source/world/level/path/PathFinder.hpp index c058fe69c..d41f85b1a 100644 --- a/source/world/level/path/PathFinder.hpp +++ b/source/world/level/path/PathFinder.hpp @@ -53,5 +53,5 @@ class PathFinder std::vector m_nodeSpillover; int m_nodeCount; Node* m_neighbors[NEIGHBORS_SIZE]; - bool m_bEntityIsDoorBreaker; + bool m_bEntityIsDoorBreaker; // was m_bCanBreach, but this is clearer }; diff --git a/source/world/particle/BubbleParticle.cpp b/source/world/particle/BubbleParticle.cpp index 234917b45..96642b64a 100644 --- a/source/world/particle/BubbleParticle.cpp +++ b/source/world/particle/BubbleParticle.cpp @@ -13,14 +13,14 @@ BubbleParticle::BubbleParticle(Level* level, const Vec3& pos, const Vec3& dir) : Particle(level, pos, dir) { m_rCol = m_gCol = m_bCol = 1.0f; - field_DC = PTI_BUBBLE; + m_tex = PTI_BUBBLE; setSize(0.02f, 0.02f); - field_F0 *= 0.2f + 0.6f * sharedRandom.nextFloat(); + m_size *= 0.2f + 0.6f * sharedRandom.nextFloat(); m_vel.x = dir.x * 0.2f + 0.02f * (2.0f * Mth::random() - 1.0f); m_vel.y = dir.y * 0.2f + 0.02f * (2.0f * Mth::random() - 1.0f); m_vel.z = dir.z * 0.2f + 0.02f * (2.0f * Mth::random() - 1.0f); - field_EC = int(8.0f / (Mth::random() * 0.8f + 0.2f)); + m_lifetime = int(8.0f / (Mth::random() * 0.8f + 0.2f)); } void BubbleParticle::tick() @@ -35,7 +35,7 @@ void BubbleParticle::tick() if (m_pLevel->getMaterial(m_pos) != Material::water) remove(); - field_EC--; - if (field_EC <= 0) + m_lifetime--; + if (m_lifetime <= 0) remove(); } diff --git a/source/world/particle/ExplodeParticle.cpp b/source/world/particle/ExplodeParticle.cpp index e5149e29a..daef2b0e7 100644 --- a/source/world/particle/ExplodeParticle.cpp +++ b/source/world/particle/ExplodeParticle.cpp @@ -11,27 +11,25 @@ ExplodeParticle::ExplodeParticle(Level* level, const Vec3& pos, const Vec3& dir) : Particle(level, pos, dir) { - field_104 = 0.0f; - m_vel.x = dir.x + 0.05f * (2.0f * Mth::random() - 1.0f); m_vel.y = dir.y + 0.05f * (2.0f * Mth::random() - 1.0f); m_vel.z = dir.z + 0.05f * (2.0f * Mth::random() - 1.0f); m_rCol = m_gCol = m_bCol = 0.7f + 0.3f * sharedRandom.nextFloat(); - field_F0 = 1.0f + 6.0f * sharedRandom.nextFloat() * sharedRandom.nextFloat(); - field_EC = int(16.0f / (0.2f + 0.8f * sharedRandom.nextFloat())) + 2; + m_size = 1.0f + 6.0f * sharedRandom.nextFloat() * sharedRandom.nextFloat(); + m_lifetime = int(16.0f / (0.2f + 0.8f * sharedRandom.nextFloat())) + 2; } void ExplodeParticle::tick() { m_oPos = m_pos; - field_E8++; - if (field_E8 > field_EC) + m_age++; + if (m_age > m_lifetime) remove(); m_vel.y += 0.004f; - field_DC = -8 * field_E8 / field_EC + 7; + m_tex = -8 * m_age / m_lifetime + 7; move(m_vel); diff --git a/source/world/particle/FlameParticle.cpp b/source/world/particle/FlameParticle.cpp index 39a63d158..5b7428dcd 100644 --- a/source/world/particle/FlameParticle.cpp +++ b/source/world/particle/FlameParticle.cpp @@ -11,7 +11,7 @@ FlameParticle::FlameParticle(Level* level, const Vec3& pos, const Vec3& dir) : Particle(level, pos, dir) { - field_104 = 0.0f; + m_oSize = 0.0f; m_vel = m_vel * 0.01f + dir; @@ -23,10 +23,10 @@ FlameParticle::FlameParticle(Level* level, const Vec3& pos, const Vec3& dir) : sharedRandom.genrand_int32(); sharedRandom.genrand_int32(); - field_104 = field_F0; + m_oSize = m_size; m_rCol = m_gCol = m_bCol = 1.0f; - field_EC = int(8.0f / (0.2f + 0.8f * Mth::random())) + 4; - field_DC = PTI_FLAME; + m_lifetime = int(8.0f / (0.2f + 0.8f * Mth::random())) + 4; + m_tex = PTI_FLAME; } float FlameParticle::getBrightness(float unused) const @@ -38,8 +38,8 @@ void FlameParticle::tick() { m_oPos = m_pos; - field_E8++; - if (field_E8 > field_EC) + m_age++; + if (m_age > m_lifetime) remove(); move(m_vel); @@ -55,7 +55,7 @@ void FlameParticle::tick() void FlameParticle::render(Tesselator& t, float f, float a, float b, float c, float d, float e) { - float mult = float(field_E8 + f) / float(field_EC); - field_F0 = field_104 * (1.0f - 0.5f * mult * mult); + float mult = float(m_age + f) / float(m_lifetime); + m_size = m_oSize * (1.0f - 0.5f * mult * mult); Particle::render(t, f, a, b, c, d, e); } diff --git a/source/world/particle/LavaParticle.cpp b/source/world/particle/LavaParticle.cpp index d76ad60bd..8a29fbf0d 100644 --- a/source/world/particle/LavaParticle.cpp +++ b/source/world/particle/LavaParticle.cpp @@ -12,14 +12,14 @@ LavaParticle::LavaParticle(Level* level, const Vec3& pos) : Particle(level, pos, Vec3::ZERO) { - field_104 = 0.0f; + m_oSize = 0.0f; m_vel *= 0.8f; m_vel.y = sharedRandom.nextFloat() * 0.4f + 0.05f; m_rCol = m_gCol = m_bCol = 1.0f; - field_104 = field_F0 = field_F0 * (0.2f + 2 * sharedRandom.nextFloat()); - field_DC = PTI_LAVA; - field_EC = int(16.0f / (0.2f + 0.8f * Mth::random())); + m_oSize = m_size = m_size * (0.2f + 2 * sharedRandom.nextFloat()); + m_tex = PTI_LAVA; + m_lifetime = int(16.0f / (0.2f + 0.8f * Mth::random())); } float LavaParticle::getBrightness(float unused) const @@ -31,11 +31,11 @@ void LavaParticle::tick() { m_oPos = m_pos; - field_E8++; - if (field_E8 > field_EC) + m_age++; + if (m_age > m_lifetime) remove(); - float a = float(field_E8) / float(field_EC); + float a = float(m_age) / float(m_lifetime); float b = sharedRandom.nextFloat(); if (a < b) { @@ -55,7 +55,7 @@ void LavaParticle::tick() void LavaParticle::render(Tesselator& t, float f, float a, float b, float c, float d, float e) { - float mult = float(field_E8 + f) / float(field_EC); - field_F0 = field_104 * (1.0f - mult * mult); + float mult = float(m_age + f) / float(m_lifetime); + m_size = m_oSize * (1.0f - mult * mult); Particle::render(t, f, a, b, c, d, e); } diff --git a/source/world/particle/Particle.cpp b/source/world/particle/Particle.cpp index 8b276c1db..07118b116 100644 --- a/source/world/particle/Particle.cpp +++ b/source/world/particle/Particle.cpp @@ -12,13 +12,13 @@ float Particle::xOff, Particle::yOff, Particle::zOff; void Particle::_init() { - field_DC = 0; - field_E0 = 0.0f; - field_E4 = 0.0f; - field_E8 = 0; - field_EC = 0; - field_F0 = 0.0f; - field_F4 = 0.0f; + m_tex = 0; + m_uo = 0.0f; + m_vo = 0.0f; + m_age = 0; + m_lifetime = 0; + m_size = 0.0f; + m_gravity = 0.0f; m_rCol = 1.0f; m_gCol = 1.0f; m_bCol = 1.0f; @@ -43,10 +43,10 @@ Particle::Particle(Level* level, const Vec3& pos, const Vec3& dir) : Entity(leve m_vel.y = m_vel.y * mult + 0.1f; m_vel.z *= mult; - field_E0 = 3.0f * sharedRandom.nextFloat(); - field_E4 = 3.0f * sharedRandom.nextFloat(); - field_F0 = 2.0f * (0.5f + 0.5f * sharedRandom.nextFloat()); - field_EC = int(4.0f / (0.1f + 0.9f * sharedRandom.nextFloat())); + m_uo = 3.0f * sharedRandom.nextFloat(); + m_vo = 3.0f * sharedRandom.nextFloat(); + m_size = 2.0f * (0.5f + 0.5f * sharedRandom.nextFloat()); + m_lifetime = int(4.0f / (0.1f + 0.9f * sharedRandom.nextFloat())); } int Particle::getParticleTexture() @@ -57,7 +57,7 @@ int Particle::getParticleTexture() Particle* Particle::scale(float f) { setSize(0.2f * f, 0.2f * f); - field_F0 *= f; + m_size *= f; return this; } @@ -69,11 +69,11 @@ Particle* Particle::setPower(float f) return this; } -void Particle::render(Tesselator& t, float f, float a4, float a5, float a6, float a7, float a8) +void Particle::render(Tesselator& t, float f, float xa, float ya, float za, float xa2, float za2) { constexpr float C_MAGIC_1 = 0.062438f; // @BUG: Slightly bigger than 1/16.0f - int texture = field_DC; + int texture = m_tex; int texX = texture % 16; if (texture < 0) texture += 15; @@ -86,11 +86,11 @@ void Particle::render(Tesselator& t, float f, float a4, float a5, float a6, floa float posZ = Mth::Lerp(m_oPos.z, m_pos.z, f) - zOff; float fBright = m_bIsUnlit ? 1.0f : getBrightness(f); - float sizeX = a4 * field_F0 * 0.1f; - float sizeY = a5 * field_F0 * 0.1f; - float sizeZ = a6 * field_F0 * 0.1f; - float siz2X = a7 * field_F0 * 0.1f; - float siz2Z = a8 * field_F0 * 0.1f; + float sizeX = xa * m_size * 0.1f; + float sizeY = ya * m_size * 0.1f; + float sizeZ = za * m_size * 0.1f; + float siz2X = xa2 * m_size * 0.1f; + float siz2Z = za2 * m_size * 0.1f; t.color(m_rCol * fBright, m_gCol * fBright, m_bCol * fBright); t.vertexUV(posX - sizeX - siz2X, posY - sizeY, posZ - sizeZ - siz2Z, texU_1 + C_MAGIC_1, texV_1 + C_MAGIC_1); @@ -102,11 +102,11 @@ void Particle::render(Tesselator& t, float f, float a4, float a5, float a6, floa void Particle::tick() { m_oPos = m_pos; - field_E8++; - if (field_E8 >= field_EC) + m_age++; + if (m_age >= m_lifetime) remove(); - m_vel.y -= field_F4 * 0.04f; + m_vel.y -= m_gravity * 0.04f; move(m_vel); m_vel *= 0.98f; diff --git a/source/world/particle/Particle.hpp b/source/world/particle/Particle.hpp index 85d4814bc..0f9996e7d 100644 --- a/source/world/particle/Particle.hpp +++ b/source/world/particle/Particle.hpp @@ -34,7 +34,7 @@ class Particle : public Entity Particle() { _init(); } Particle(Level*, const Vec3& pos, const Vec3& dir); - virtual void render(Tesselator&, float, float, float, float, float, float); + virtual void render(Tesselator& t, float f, float xa, float ya, float za, float xa2, float za2); virtual int getParticleTexture(); void tick() override; @@ -45,13 +45,13 @@ class Particle : public Entity Particle* setPower(float); public: - int field_DC; - float field_E0; - float field_E4; - int field_E8; - int field_EC; - float field_F0; - float field_F4; + int m_tex; + float m_uo; + float m_vo; + int m_age; + int m_lifetime; + float m_size; + float m_gravity; float m_rCol; float m_gCol; float m_bCol; @@ -91,7 +91,7 @@ class SmokeParticle : public Particle void render(Tesselator&, float, float, float, float, float, float) override; public: - float field_104; + float m_oSize; }; class RedDustParticle : public Particle @@ -102,7 +102,7 @@ class RedDustParticle : public Particle void render(Tesselator&, float, float, float, float, float, float) override; public: - float field_104; + float m_oSize; }; class ExplodeParticle : public Particle @@ -110,9 +110,6 @@ class ExplodeParticle : public Particle public: ExplodeParticle(Level*, const Vec3& pos, const Vec3& dir); void tick() override; - -public: - float field_104; }; class FlameParticle : public Particle @@ -124,7 +121,7 @@ class FlameParticle : public Particle float getBrightness(float f) const override; public: - float field_104; + float m_oSize; }; class LavaParticle : public Particle @@ -136,5 +133,5 @@ class LavaParticle : public Particle float getBrightness(float f) const override; public: - float field_104; + float m_oSize; }; diff --git a/source/world/particle/RedDustParticle.cpp b/source/world/particle/RedDustParticle.cpp index bae587260..076b32019 100644 --- a/source/world/particle/RedDustParticle.cpp +++ b/source/world/particle/RedDustParticle.cpp @@ -11,7 +11,7 @@ RedDustParticle::RedDustParticle(Level* level, const Vec3& pos, const Vec3& dir) : Particle(level, pos, Vec3::ZERO) { - field_104 = 0.0f; + m_oSize = 0.0f; m_vel = dir + m_vel * 0.1f; @@ -20,21 +20,21 @@ RedDustParticle::RedDustParticle(Level* level, const Vec3& pos, const Vec3& dir) m_gCol = f * dir.y * (Mth::random() * 0.2f + 0.8f); m_bCol = f * dir.z * (Mth::random() * 0.2f + 0.8f); - field_104 = field_F0 = field_F0 * 0.75f; + m_oSize = m_size = m_size * 0.75f; m_bNoPhysics = false; - field_EC = int(8.0f / (0.2f + 0.8f * Mth::random())); + m_lifetime = int(8.0f / (0.2f + 0.8f * Mth::random())); } void RedDustParticle::render(Tesselator& t, float f, float a, float b, float c, float d, float e) { - float mult = 32.0f * (float(field_E8 + f) / float(field_EC)); + float mult = 32.0f * (float(m_age + f) / float(m_lifetime)); if (mult < 0.0f) mult = 0.0f; if (mult > 1.0f) mult = 1.0f; - field_F0 = field_104 * mult; + m_size = m_oSize * mult; Particle::render(t, f, a, b, c, d, e); } @@ -42,12 +42,12 @@ void RedDustParticle::tick() { m_oPos = m_pos; - field_E8++; - if (field_E8 > field_EC) + m_age++; + if (m_age > m_lifetime) remove(); m_vel.y += 0.004f; - field_DC = -8 * field_E8 / field_EC + 7; + m_tex = -8 * m_age / m_lifetime + 7; move(m_vel); diff --git a/source/world/particle/SmokeParticle.cpp b/source/world/particle/SmokeParticle.cpp index 2c781a660..cb058b633 100644 --- a/source/world/particle/SmokeParticle.cpp +++ b/source/world/particle/SmokeParticle.cpp @@ -11,27 +11,27 @@ SmokeParticle::SmokeParticle(Level* level, const Vec3& pos, const Vec3& dir, float a9) : Particle(level, pos, Vec3::ZERO) { - field_104 = 0.0f; + m_oSize = 0.0f; m_vel = dir + m_vel * 0.1f; m_bCol = m_gCol = m_rCol = Mth::random() * 0.5f; - field_104 = field_F0 = field_F0 * 0.75f * a9; + m_oSize = m_size = m_size * 0.75f * a9; m_bNoPhysics = false; - field_EC = int((a9 * 8.0f) / (0.2f + 0.8f * Mth::random())); + m_lifetime = int((a9 * 8.0f) / (0.2f + 0.8f * Mth::random())); } void SmokeParticle::render(Tesselator& t, float f, float a, float b, float c, float d, float e) { - float mult = 32.0f * (float(field_E8 + f) / float(field_EC)); + float mult = 32.0f * (float(m_age + f) / float(m_lifetime)); if (mult < 0.0f) mult = 0.0f; if (mult > 1.0f) mult = 1.0f; - field_F0 = field_104 * mult; + m_size = m_oSize * mult; Particle::render(t, f, a, b, c, d, e); } @@ -39,12 +39,12 @@ void SmokeParticle::tick() { m_oPos = m_pos; - field_E8++; - if (field_E8 > field_EC) + m_age++; + if (m_age > m_lifetime) remove(); m_vel.y += 0.004f; - field_DC = -8 * field_E8 / field_EC + 7; + m_tex = -8 * m_age / m_lifetime + 7; move(m_vel); diff --git a/source/world/particle/TerrainParticle.cpp b/source/world/particle/TerrainParticle.cpp index 3235e2b95..5acfe2561 100644 --- a/source/world/particle/TerrainParticle.cpp +++ b/source/world/particle/TerrainParticle.cpp @@ -12,10 +12,10 @@ void TerrainParticle::_init(Tile* tile) { m_pTile = tile; - field_DC = tile->m_TextureFrame; - field_F4 = tile->field_28; + m_tex = tile->m_TextureFrame; + m_gravity = tile->m_gravity; m_rCol = m_gCol = m_bCol = 0.6f; - field_F0 *= 0.5f; + m_size *= 0.5f; } TerrainParticle::TerrainParticle(Level* level, const Vec3& pos, Tile* tile) : @@ -36,7 +36,7 @@ TerrainParticle* TerrainParticle::init(const TilePos& tilePos, Facing::Name face face = Facing::DOWN; #endif - field_DC = m_pTile->getTexture(m_pLevel, tilePos, face); + m_tex = m_pTile->getTexture(m_pLevel, tilePos, face); if (m_pTile == Tile::grass && face != Facing::UP) return this; @@ -58,24 +58,24 @@ void TerrainParticle::render(Tesselator& t, float f, float a4, float a5, float a { constexpr float C_MAGIC_1 = 0.015609f; // @BUG: Slightly bigger than 1/64.0f - int texture = field_DC; + int texture = m_tex; int texX = texture % 16; if (texture < 0) texture += 15; - float texU_1 = (float(texX) + 0.25f * field_E0) / 16.0f; - float texV_1 = (float(texture >> 4) + 0.25f * field_E4) / 16.0f; + float texU_1 = (float(texX) + 0.25f * m_uo) / 16.0f; + float texV_1 = (float(texture >> 4) + 0.25f * m_vo) / 16.0f; float posX = Mth::Lerp(m_oPos.x, m_pos.x, f) - xOff; float posY = Mth::Lerp(m_oPos.y, m_pos.y, f) - yOff; float posZ = Mth::Lerp(m_oPos.z, m_pos.z, f) - zOff; float fBright = getBrightness(f); - float sizeX = a4 * field_F0 * 0.1f; - float sizeY = a5 * field_F0 * 0.1f; - float sizeZ = a6 * field_F0 * 0.1f; - float siz2X = a7 * field_F0 * 0.1f; - float siz2Z = a8 * field_F0 * 0.1f; + float sizeX = a4 * m_size * 0.1f; + float sizeY = a5 * m_size * 0.1f; + float sizeZ = a6 * m_size * 0.1f; + float siz2X = a7 * m_size * 0.1f; + float siz2Z = a8 * m_size * 0.1f; t.color(m_rCol * fBright, m_gCol * fBright, m_bCol * fBright); t.vertexUV(posX - sizeX - siz2X, posY - sizeY, posZ - sizeZ - siz2Z, texU_1 + C_MAGIC_1, texV_1 + C_MAGIC_1); diff --git a/source/world/tile/BookshelfTile.hpp b/source/world/tile/BookshelfTile.hpp index d3259340c..ffdb8119f 100644 --- a/source/world/tile/BookshelfTile.hpp +++ b/source/world/tile/BookshelfTile.hpp @@ -15,6 +15,7 @@ class BookshelfTile : public Tile public: BookshelfTile(int ID, int texture, Material*); +public: int getTexture(Facing::Name face) const override; int getResource(TileData data, Random* random) const override; int getResourceCount(Random* random) const override; diff --git a/source/world/tile/Bush.hpp b/source/world/tile/Bush.hpp index b4a01b0e3..d23d5b80a 100644 --- a/source/world/tile/Bush.hpp +++ b/source/world/tile/Bush.hpp @@ -15,6 +15,7 @@ class Bush : public Tile public: Bush(TileID id, int texture); +public: bool canSurvive(const Level*, const TilePos& pos) const override; AABB* getAABB(const Level*, const TilePos& pos) override; eRenderShape getRenderShape() const override; @@ -24,5 +25,6 @@ class Bush : public Tile void tick(Level*, const TilePos& pos, Random*) override; void neighborChanged(Level*, const TilePos& pos, TileID tile) override; +public: void checkAlive(Level*, const TilePos& pos); }; diff --git a/source/world/tile/CactusTile.hpp b/source/world/tile/CactusTile.hpp index 485591d50..20a31abff 100644 --- a/source/world/tile/CactusTile.hpp +++ b/source/world/tile/CactusTile.hpp @@ -6,6 +6,8 @@ class CactusTile : public Tile { public: CactusTile(int id, int texture); + +public: AABB* getAABB(const Level* pLevel, const TilePos& pos) override; bool mayPlace(const Level*, const TilePos& pos) const override; bool canSurvive(const Level* level, const TilePos& pos) const override; diff --git a/source/world/tile/ClayTile.hpp b/source/world/tile/ClayTile.hpp index 30830e3cf..e4ad0d18d 100644 --- a/source/world/tile/ClayTile.hpp +++ b/source/world/tile/ClayTile.hpp @@ -15,6 +15,7 @@ class ClayTile : public Tile public: ClayTile(TileID ID, int texture, Material*); +public: int getResource(TileData, Random*) const override; int getResourceCount(Random*) const override; }; diff --git a/source/world/tile/ClothTile.hpp b/source/world/tile/ClothTile.hpp index e2dfc94fe..4eb370a7d 100644 --- a/source/world/tile/ClothTile.hpp +++ b/source/world/tile/ClothTile.hpp @@ -14,8 +14,12 @@ class ClothTile : public Tile { public: ClothTile(int id); + +public: int getTexture(Facing::Name face, TileData data) const override; int getSpawnResourcesAuxValue(int val) const override; + +public: static int getColorFromData(int var0) { return ~var0 & 15; diff --git a/source/world/tile/CraftingTableTile.hpp b/source/world/tile/CraftingTableTile.hpp index 9a685fa5c..41a30127a 100644 --- a/source/world/tile/CraftingTableTile.hpp +++ b/source/world/tile/CraftingTableTile.hpp @@ -6,6 +6,8 @@ class CraftingTableTile : public Tile { public: CraftingTableTile(TileID id); + +public: bool use(Level*, const TilePos& pos, Player*) override; int getTexture(Facing::Name face) const override; }; \ No newline at end of file diff --git a/source/world/tile/DeadBush.hpp b/source/world/tile/DeadBush.hpp index 72d3d5cf5..b7225b1f2 100644 --- a/source/world/tile/DeadBush.hpp +++ b/source/world/tile/DeadBush.hpp @@ -6,6 +6,8 @@ class DeadBush : public Bush { public: DeadBush(int id, int texture); + +public: int getResource(TileData, Random*) const override; bool mayPlace(const Level*, const TilePos& pos) const override; }; diff --git a/source/world/tile/DoorTile.hpp b/source/world/tile/DoorTile.hpp index e0680ae86..778eec2fa 100644 --- a/source/world/tile/DoorTile.hpp +++ b/source/world/tile/DoorTile.hpp @@ -15,6 +15,7 @@ class DoorTile : public Tile public: DoorTile(int ID, Material*); +public: void attack(Level*, const TilePos& pos, Player*) override; bool use(Level*, const TilePos& pos, Player*) override; HitResult clip(const Level*, const TilePos& pos, Vec3, Vec3) override; diff --git a/source/world/tile/FarmTile.hpp b/source/world/tile/FarmTile.hpp index 3a9ca241b..c1246d6b0 100644 --- a/source/world/tile/FarmTile.hpp +++ b/source/world/tile/FarmTile.hpp @@ -15,6 +15,7 @@ class FarmTile : public Tile public: FarmTile(TileID ID, Material*); +public: AABB* getAABB(const Level*, const TilePos& pos) override; int getResource(TileData, Random*) const override; int getTexture(Facing::Name face, TileData data) const override; diff --git a/source/world/tile/FenceTile.hpp b/source/world/tile/FenceTile.hpp index 1f6864e4f..bf73b74e4 100644 --- a/source/world/tile/FenceTile.hpp +++ b/source/world/tile/FenceTile.hpp @@ -6,6 +6,8 @@ class FenceTile : public Tile { public: FenceTile(int id, int texture); + +public: bool mayPlace(const Level*, const TilePos& pos) const override; AABB* getAABB(const Level* pLevel, const TilePos& pos) override; bool isSolidRender() const override; diff --git a/source/world/tile/FireTile.hpp b/source/world/tile/FireTile.hpp index 92302058a..5521717fc 100644 --- a/source/world/tile/FireTile.hpp +++ b/source/world/tile/FireTile.hpp @@ -15,6 +15,7 @@ class FireTile : public Tile public: FireTile(int ID, int texture); +public: AABB* getAABB(const Level*, const TilePos& pos) override; eRenderShape getRenderShape() const override; bool isCubeShaped() const override; diff --git a/source/world/tile/GlassTile.hpp b/source/world/tile/GlassTile.hpp index 3977a3329..5ec123e1c 100644 --- a/source/world/tile/GlassTile.hpp +++ b/source/world/tile/GlassTile.hpp @@ -15,5 +15,6 @@ class GlassTile : public HalfTransparentTile public: GlassTile(int ID, int texture, Material*); +public: int getResourceCount(Random*) const override; }; diff --git a/source/world/tile/GlowstoneTile.hpp b/source/world/tile/GlowstoneTile.hpp index da1bf3c45..ae9562ab5 100644 --- a/source/world/tile/GlowstoneTile.hpp +++ b/source/world/tile/GlowstoneTile.hpp @@ -7,6 +7,7 @@ class GlowstoneTile : public Tile public: GlowstoneTile(TileID id, int texture, Material* material); +public: int getResource(TileData, Random*) const override; int getResourceCount(Random*) const override; }; diff --git a/source/world/tile/GrassTile.cpp b/source/world/tile/GrassTile.cpp index fafab551e..4ddfde505 100644 --- a/source/world/tile/GrassTile.cpp +++ b/source/world/tile/GrassTile.cpp @@ -90,7 +90,7 @@ void GrassTile::tick(Level* level, const TilePos& pos, Random* random) level->getRawBrightness(tp.above()) > 3 && !level->getMaterial(tp.above())->blocksLight()) { - //@NOTE: not this->m_ID + //@NOTE: not this->id level->setTile(tp, Tile::grass->m_ID); } } diff --git a/source/world/tile/GravelTile.hpp b/source/world/tile/GravelTile.hpp index 4f7fb2c13..9c6d531e9 100644 --- a/source/world/tile/GravelTile.hpp +++ b/source/world/tile/GravelTile.hpp @@ -15,5 +15,6 @@ class GravelTile : public SandTile public: GravelTile(int ID, int texture, Material*); +public: int getResource(TileData data, Random* random) const override; }; diff --git a/source/world/tile/HalfTransparentTile.cpp b/source/world/tile/HalfTransparentTile.cpp index cdc4523a7..f77b807dd 100644 --- a/source/world/tile/HalfTransparentTile.cpp +++ b/source/world/tile/HalfTransparentTile.cpp @@ -11,7 +11,7 @@ HalfTransparentTile::HalfTransparentTile(int a, int b, Material* c) : Tile(a, b, c) { - field_6C = false; + m_bAllowSame = false; } bool HalfTransparentTile::isSolidRender() const @@ -21,8 +21,8 @@ bool HalfTransparentTile::isSolidRender() const bool HalfTransparentTile::shouldRenderFace(const LevelSource* level, const TilePos& pos, Facing::Name face) const { - if (field_6C || level->getTile(pos) != m_ID) + if (m_bAllowSame || level->getTile(pos) != m_ID) return Tile::shouldRenderFace(level, pos, face); - return field_6C; + return m_bAllowSame; } diff --git a/source/world/tile/HalfTransparentTile.hpp b/source/world/tile/HalfTransparentTile.hpp index 7c0e2d06d..48bccf297 100644 --- a/source/world/tile/HalfTransparentTile.hpp +++ b/source/world/tile/HalfTransparentTile.hpp @@ -15,9 +15,10 @@ class HalfTransparentTile : public Tile public: HalfTransparentTile(int ID, int texture, Material*); +public: virtual bool isSolidRender() const override; virtual bool shouldRenderFace(const LevelSource*, const TilePos& pos, Facing::Name face) const override; -public: - bool field_6C; +private: + bool m_bAllowSame; }; diff --git a/source/world/tile/IceTile.hpp b/source/world/tile/IceTile.hpp index d43c7f695..47fc17f26 100644 --- a/source/world/tile/IceTile.hpp +++ b/source/world/tile/IceTile.hpp @@ -15,6 +15,7 @@ class IceTile : public HalfTransparentTile public: IceTile(int ID, int texture, Material*); +public: int getResourceCount(Random*) const override; void onRemove(Level*, const TilePos& pos) override; void tick(Level*, const TilePos& pos, Random*) override; diff --git a/source/world/tile/InvisibleTile.hpp b/source/world/tile/InvisibleTile.hpp index ea3da6685..cb9d771f1 100644 --- a/source/world/tile/InvisibleTile.hpp +++ b/source/world/tile/InvisibleTile.hpp @@ -14,6 +14,8 @@ class InvisibleTile : public Tile { public: InvisibleTile(TileID ID, int texture, Material*); + +public: eRenderShape getRenderShape() const override; bool mayPick() const override; }; diff --git a/source/world/tile/LadderTile.hpp b/source/world/tile/LadderTile.hpp index 7597246b5..2be02853b 100644 --- a/source/world/tile/LadderTile.hpp +++ b/source/world/tile/LadderTile.hpp @@ -15,6 +15,7 @@ class LadderTile : public Tile public: LadderTile(int ID, int texture); +public: bool isCubeShaped() const override; bool isSolidRender() const override; eRenderShape getRenderShape() const override; diff --git a/source/world/tile/LeafTile.hpp b/source/world/tile/LeafTile.hpp index 56edbc11c..2cfda1b69 100644 --- a/source/world/tile/LeafTile.hpp +++ b/source/world/tile/LeafTile.hpp @@ -35,6 +35,7 @@ class LeafTile : public TransparentTile void die(Level*, const TilePos& pos); +public: int* m_checkBuffer; int field_74; }; diff --git a/source/world/tile/LiquidTile.hpp b/source/world/tile/LiquidTile.hpp index 9ad9a97d6..24d8f2788 100644 --- a/source/world/tile/LiquidTile.hpp +++ b/source/world/tile/LiquidTile.hpp @@ -15,9 +15,10 @@ class LiquidTile : public Tile public: LiquidTile(int ID, Material*); - virtual void onPlace(Level*, const TilePos& pos) override; - virtual void neighborChanged(Level*, const TilePos& pos, TileID tile) override; - virtual void tick(Level*, const TilePos& pos, Random* random) override; +public: + void onPlace(Level*, const TilePos& pos) override; + void neighborChanged(Level*, const TilePos& pos, TileID tile) override; + void tick(Level*, const TilePos& pos, Random* random) override; void animateTick(Level*, const TilePos& pos, Random* random) override; AABB* getAABB(const Level*, const TilePos& pos) override; float getBrightness(const LevelSource*, const TilePos& pos) const override; @@ -40,6 +41,7 @@ class LiquidTile : public Tile int getRenderedDepth(const LevelSource*, const TilePos& pos) const; Vec3 getFlow(const LevelSource*, const TilePos& pos) const; +public: static float getSlopeAngle(const LevelSource*, const TilePos& pos, const Material* pMtl); // @NOTE: This is inlined in minecraftcpp diff --git a/source/world/tile/LiquidTileDynamic.cpp b/source/world/tile/LiquidTileDynamic.cpp index 1beb8efc9..cd8eeded8 100644 --- a/source/world/tile/LiquidTileDynamic.cpp +++ b/source/world/tile/LiquidTileDynamic.cpp @@ -213,7 +213,7 @@ void LiquidTileDynamic::tick(Level* level, const TilePos& pos, Random* random) { int depth = getDepth(level, pos); int speed; - if (m_pMaterial != Material::lava || level->m_pDimension->field_D) + if (m_pMaterial != Material::lava || level->m_pDimension->m_bUltraWarm) speed = 1; else speed = 2; diff --git a/source/world/tile/LiquidTileDynamic.hpp b/source/world/tile/LiquidTileDynamic.hpp index 71eba9642..2718f5ec3 100644 --- a/source/world/tile/LiquidTileDynamic.hpp +++ b/source/world/tile/LiquidTileDynamic.hpp @@ -15,6 +15,7 @@ class LiquidTileDynamic : public LiquidTile public: LiquidTileDynamic(int id, Material* pMtl); +public: void onPlace(Level*, const TilePos& pos) override; void tick(Level*, const TilePos& pos, Random*) override; diff --git a/source/world/tile/LiquidTileStatic.hpp b/source/world/tile/LiquidTileStatic.hpp index 83f81bf17..f8ee4ab8c 100644 --- a/source/world/tile/LiquidTileStatic.hpp +++ b/source/world/tile/LiquidTileStatic.hpp @@ -15,6 +15,7 @@ class LiquidTileStatic : public LiquidTile public: LiquidTileStatic(int id, Material* pMtl); +public: void neighborChanged(Level* level, const TilePos& pos, TileID tile) override; void tick(Level* level, const TilePos& pos, Random* random) override; diff --git a/source/world/tile/MetalTile.hpp b/source/world/tile/MetalTile.hpp index 8b30cd2fe..8bdf6dc75 100644 --- a/source/world/tile/MetalTile.hpp +++ b/source/world/tile/MetalTile.hpp @@ -15,5 +15,6 @@ class MetalTile : public Tile public: MetalTile(int ID, int texture, Material*); - virtual int getTexture(Facing::Name face) const override; +public: + int getTexture(Facing::Name face) const override; }; diff --git a/source/world/tile/ObsidianTile.hpp b/source/world/tile/ObsidianTile.hpp index 33a933cc4..30c443898 100644 --- a/source/world/tile/ObsidianTile.hpp +++ b/source/world/tile/ObsidianTile.hpp @@ -15,6 +15,7 @@ class ObsidianTile : public Tile public: ObsidianTile(int ID, int texture, Material*); +public: int getResource(TileData data, Random*) const override; int getResourceCount(Random*) const override; }; diff --git a/source/world/tile/OreTile.hpp b/source/world/tile/OreTile.hpp index a92d5b769..ef90a7926 100644 --- a/source/world/tile/OreTile.hpp +++ b/source/world/tile/OreTile.hpp @@ -15,6 +15,7 @@ class OreTile : public Tile public: OreTile(TileID id, int texture); +public: int getResource(TileData data, Random*) const override; int getResourceCount(Random*) const override; int getSpawnResourcesAuxValue(int) const override; diff --git a/source/world/tile/PumpkinTile.hpp b/source/world/tile/PumpkinTile.hpp index cd58daa50..166726adb 100644 --- a/source/world/tile/PumpkinTile.hpp +++ b/source/world/tile/PumpkinTile.hpp @@ -6,8 +6,12 @@ class PumpkinTile : public Tile { public: PumpkinTile(TileID id, bool lantern); + +public: int getTexture(Facing::Name face, TileData data) const override; int getTexture(Facing::Name face) const override; void setPlacedBy(Level*, const TilePos& pos, Mob*) override; + +public: bool m_bLantern; }; diff --git a/source/world/tile/RedStoneOreTile.hpp b/source/world/tile/RedStoneOreTile.hpp index 4e7497dff..7c85d8c02 100644 --- a/source/world/tile/RedStoneOreTile.hpp +++ b/source/world/tile/RedStoneOreTile.hpp @@ -15,6 +15,7 @@ class RedStoneOreTile : public Tile public: RedStoneOreTile(TileID id, int texture, bool bLit); +public: int getResource(TileData, Random*) const override; int getResourceCount(Random*) const override; int getSpawnResourcesAuxValue(int) const override; @@ -28,5 +29,6 @@ class RedStoneOreTile : public Tile int poofParticles(Level*, const TilePos& pos); void interact(Level*, const TilePos& pos); +public: bool m_bLit; }; diff --git a/source/world/tile/ReedTile.hpp b/source/world/tile/ReedTile.hpp index 2cb353e22..2f9b5a339 100644 --- a/source/world/tile/ReedTile.hpp +++ b/source/world/tile/ReedTile.hpp @@ -15,6 +15,7 @@ class ReedTile : public Tile public: ReedTile(TileID id); +public: bool canSurvive(const Level*, const TilePos& pos) const override; AABB* getAABB(const Level*, const TilePos& pos) override; eRenderShape getRenderShape() const override; diff --git a/source/world/tile/RocketLauncherTile.hpp b/source/world/tile/RocketLauncherTile.hpp index eda267dc3..4de5899a2 100644 --- a/source/world/tile/RocketLauncherTile.hpp +++ b/source/world/tile/RocketLauncherTile.hpp @@ -15,6 +15,7 @@ class RocketLauncherTile : public Tile public: RocketLauncherTile(TileID id); +public: int getTexture(Facing::Name face, TileData data) const override; AABB* getAABB(const Level*, const TilePos& pos) override; eRenderShape getRenderShape() const override; diff --git a/source/world/tile/SandStoneTile.hpp b/source/world/tile/SandStoneTile.hpp index 20999ad94..5143da154 100644 --- a/source/world/tile/SandStoneTile.hpp +++ b/source/world/tile/SandStoneTile.hpp @@ -15,5 +15,6 @@ class SandStoneTile : public Tile public: SandStoneTile(int ID, int texture, Material*); +public: int getTexture(Facing::Name face) const override; }; diff --git a/source/world/tile/SandTile.hpp b/source/world/tile/SandTile.hpp index 5cd77f508..b953d6425 100644 --- a/source/world/tile/SandTile.hpp +++ b/source/world/tile/SandTile.hpp @@ -15,13 +15,17 @@ class SandTile : public Tile public: SandTile(int ID, int texture, Material*); +public: int getTickDelay() const override; void tick(Level* level, const TilePos& pos, Random* random) override; void neighborChanged(Level* level, const TilePos& pos, TileID tile) override; void onPlace(Level* level, const TilePos& pos) override; void checkSlide(Level* level, const TilePos& pos); + +public: static bool isFree(Level* level, const TilePos& pos); +public: static bool instaFall; }; diff --git a/source/world/tile/Sapling.hpp b/source/world/tile/Sapling.hpp index 1066da73a..6fc345c03 100644 --- a/source/world/tile/Sapling.hpp +++ b/source/world/tile/Sapling.hpp @@ -15,6 +15,7 @@ class Sapling : public Bush public: Sapling(TileID id, int texture); +public: int getTexture(Facing::Name face, TileData data) const override; void tick(Level*, const TilePos& pos, Random*) override; int getSpawnResourcesAuxValue(int x) const override; diff --git a/source/world/tile/SoulSandTile.hpp b/source/world/tile/SoulSandTile.hpp index 50c1cde66..d49127af7 100644 --- a/source/world/tile/SoulSandTile.hpp +++ b/source/world/tile/SoulSandTile.hpp @@ -6,6 +6,8 @@ class SoulSandTile : public Tile { public: SoulSandTile(int id, int texture); + +public: void entityInside(Level* level, const TilePos& pos, Entity* entity) const override; AABB* getAABB(const Level* pLevel, const TilePos& pos) override; }; diff --git a/source/world/tile/SpongeTile.hpp b/source/world/tile/SpongeTile.hpp index c4c07a9ae..d1e78701e 100644 --- a/source/world/tile/SpongeTile.hpp +++ b/source/world/tile/SpongeTile.hpp @@ -15,6 +15,7 @@ class SpongeTile : public Tile public: SpongeTile(TileID ID, int texture); +public: void onPlace(Level*, const TilePos& pos) override; void destroy(Level*, const TilePos& pos, TileData data) override; }; diff --git a/source/world/tile/StairTile.hpp b/source/world/tile/StairTile.hpp index 10563bfab..2787872fe 100644 --- a/source/world/tile/StairTile.hpp +++ b/source/world/tile/StairTile.hpp @@ -15,6 +15,7 @@ class StairTile : public Tile public: StairTile(int ID, Tile* pParent); +public: void addAABBs(const Level*, const TilePos& pos, const AABB*, std::vector&) override; bool isSolidRender() const override; bool isCubeShaped() const override; diff --git a/source/world/tile/StoneSlabTile.hpp b/source/world/tile/StoneSlabTile.hpp index c3f145979..b8010a6f5 100644 --- a/source/world/tile/StoneSlabTile.hpp +++ b/source/world/tile/StoneSlabTile.hpp @@ -21,8 +21,10 @@ class StoneSlabTile : public Tile COBBLE }; +public: StoneSlabTile(int ID, bool bFull); +public: bool isSolidRender() const override; bool isCubeShaped() const override; int getResource(TileData, Random*) const override; diff --git a/source/world/tile/StoneTile.hpp b/source/world/tile/StoneTile.hpp index b80679c2f..f9b9a52c6 100644 --- a/source/world/tile/StoneTile.hpp +++ b/source/world/tile/StoneTile.hpp @@ -15,5 +15,6 @@ class StoneTile : public Tile public: StoneTile(TileID ID, int texture, Material*); +public: int getResource(TileData data, Random*) const override; }; diff --git a/source/world/tile/TallGrass.hpp b/source/world/tile/TallGrass.hpp index 3143b297b..beddc39d9 100644 --- a/source/world/tile/TallGrass.hpp +++ b/source/world/tile/TallGrass.hpp @@ -6,6 +6,8 @@ class TallGrass : public Bush { public: TallGrass(TileID id, int texture); + +public: int getResource(TileData, Random*) const override; bool isValidGrowTile(const TileID tile) const; int getColor(const LevelSource*, const TilePos& pos) const override; diff --git a/source/world/tile/Tile.cpp b/source/world/tile/Tile.cpp index 7c5646745..861449de6 100644 --- a/source/world/tile/Tile.cpp +++ b/source/world/tile/Tile.cpp @@ -101,7 +101,7 @@ void Tile::_init() { m_TextureFrame = 1; m_pSound = nullptr; - field_28 = 1.0f; + m_gravity = 1.0f; m_friction = 0.6f; m_hardness = 0.0f; m_blastResistance = 0.0f; @@ -120,7 +120,7 @@ void Tile::_init(TileID ID, Material* pMaterial, int texture) m_aabb = m_aabbReturned = AABB(0, 0, 0, 1, 1, 1); if (tiles[m_ID]) - // @BUG: Printing &tiles[m_ID], but probably supposed to print tiles[m_ID] + // @BUG: Printing &tiles[id], but probably supposed to print tiles[id] LOG_W("Slot %d is already occupied by %p when adding %p", m_ID, &tiles[m_ID], this); } @@ -802,9 +802,9 @@ void Tile::initTiles() Item::items[Tile::sapling->m_ID] = (new AuxTileItem(Tile::sapling->m_ID - C_MAX_TILES)) ->setDescriptionId("sapling"); - //Item::items[Tile::piston->m_ID] = (new PistonItem(Tile::piston->m_ID - C_MAX_TILES)); + //Item::items[Tile::piston->id] = (new PistonItem(Tile::piston->id - C_MAX_TILES)); - //Item::items[Tile::stickyPiston->m_ID] = (new PistonItem(Tile::stickyPiston->m_ID - C_MAX_TILES)); + //Item::items[Tile::stickyPiston->id] = (new PistonItem(Tile::stickyPiston->id - C_MAX_TILES)); for (int i = 0; i < C_MAX_TILES; i++) { diff --git a/source/world/tile/Tile.hpp b/source/world/tile/Tile.hpp index aad6af4c2..310c33c54 100644 --- a/source/world/tile/Tile.hpp +++ b/source/world/tile/Tile.hpp @@ -248,7 +248,7 @@ class Tile TileID m_ID; AABB m_aabb; const SoundType* m_pSound; - float field_28; + float m_gravity; // only affects particle gravity at the moment Material* m_pMaterial; float m_friction; float m_hardness; diff --git a/source/world/tile/TntTile.hpp b/source/world/tile/TntTile.hpp index e8ff4a5de..40e77b168 100644 --- a/source/world/tile/TntTile.hpp +++ b/source/world/tile/TntTile.hpp @@ -15,6 +15,7 @@ class TntTile : public Tile public: TntTile(int ID, int texture); +public: int getResourceCount(Random*) const override; int getTexture(Facing::Name face) const override; void neighborChanged(Level*, const TilePos& pos, TileID tile) override; diff --git a/source/world/tile/TopSnowTile.hpp b/source/world/tile/TopSnowTile.hpp index 82af8e659..a1f629a65 100644 --- a/source/world/tile/TopSnowTile.hpp +++ b/source/world/tile/TopSnowTile.hpp @@ -15,6 +15,7 @@ class TopSnowTile : public Tile public: TopSnowTile(TileID id, int texture, Material* pMtl); +public: AABB* getAABB(const Level*, const TilePos& pos) override; bool isCubeShaped() const override; bool isSolidRender() const override; diff --git a/source/world/tile/TorchTile.hpp b/source/world/tile/TorchTile.hpp index cb054a52e..3275c8add 100644 --- a/source/world/tile/TorchTile.hpp +++ b/source/world/tile/TorchTile.hpp @@ -15,6 +15,7 @@ class TorchTile : public Tile public: TorchTile(int ID, int texture, Material* pMtl); +public: AABB* getAABB(const Level*, const TilePos& pos) override; bool isSolidRender() const override; bool isCubeShaped() const override; diff --git a/source/world/tile/TransparentTile.hpp b/source/world/tile/TransparentTile.hpp index 4ce24c8c7..9fcbc6fd7 100644 --- a/source/world/tile/TransparentTile.hpp +++ b/source/world/tile/TransparentTile.hpp @@ -15,8 +15,9 @@ class TransparentTile : public Tile public: TransparentTile(int ID, int texture, Material*, bool bTransparent); - virtual bool isSolidRender() const override; - virtual bool shouldRenderFace(const LevelSource*, const TilePos& pos, Facing::Name face) const override; +public: + bool isSolidRender() const override; + bool shouldRenderFace(const LevelSource*, const TilePos& pos, Facing::Name face) const override; public: bool m_bTransparent; diff --git a/source/world/tile/TreeTile.hpp b/source/world/tile/TreeTile.hpp index 4f0a3c2f0..bc4b589e6 100644 --- a/source/world/tile/TreeTile.hpp +++ b/source/world/tile/TreeTile.hpp @@ -15,6 +15,7 @@ class TreeTile : public Tile public: TreeTile(int ID); +public: int getResource(TileData, Random*) const override; int getResourceCount(Random*) const override; int getSpawnResourcesAuxValue(int) const override; diff --git a/source/world/tile/Web.hpp b/source/world/tile/Web.hpp index 7fc99c73f..425eab485 100644 --- a/source/world/tile/Web.hpp +++ b/source/world/tile/Web.hpp @@ -7,6 +7,7 @@ class Web : public Tile public: Web(TileID id, int texture); +public: AABB* getAABB(const Level*, const TilePos& pos) override; virtual eRenderShape getRenderShape() const override; virtual bool isCubeShaped() const override;