diff --git a/platforms/sdl/desktop/AppPlatform_sdl.cpp b/platforms/sdl/desktop/AppPlatform_sdl.cpp index 7c4bd97..049a8f2 100644 --- a/platforms/sdl/desktop/AppPlatform_sdl.cpp +++ b/platforms/sdl/desktop/AppPlatform_sdl.cpp @@ -14,7 +14,7 @@ AppPlatform_sdl::AppPlatform_sdl(std::string storageDir, SDL_Window *window) : AppPlatform_sdl_base(storageDir, window) { - setIcon(loadTexture("icon.png")); + setIcon(AppPlatform_sdl::loadTexture("icon.png")); } // Take Screenshot @@ -81,7 +81,7 @@ ret: } if (rows != NULL) { - delete rows[height]; + delete[] rows; } if (file != NULL) { diff --git a/source/client/gui/Gui.cpp b/source/client/gui/Gui.cpp index b6c577d..0abb9e0 100644 --- a/source/client/gui/Gui.cpp +++ b/source/client/gui/Gui.cpp @@ -134,8 +134,6 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY) if (!m->m_pLevel || !m->m_pLocalPlayer) return; - bool isTouchscreen = m->isTouchscreen(); - field_4 = -90.0f; #ifndef ENH_TRANSPARENT_HOTBAR @@ -257,15 +255,15 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY) emptyHeartX += 9 * b1; } +#ifdef ORIGINAL_CODE // @NOTE: At the default scale, this would go off screen. int heartX = cenX - 191; // why? int heartYStart = height - 10; - +#else //@NOTE: Alpha-style health UI. I'll probably remove this on release. -#ifndef ORIGINAL_CODE - heartX = cenX - 91; - heartYStart = height - 32; + int heartX = cenX - 91; + int heartYStart = height - 32; #endif int playerHealth = pLP->m_health; @@ -301,12 +299,12 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY) int breathFull = int(ceilf((float(breathRaw - 2) * 10.0f) / 300.0f)); int breathMeter = int(ceilf((float(breathRaw) * 10.0f) / 300.0f)) - breathFull; +#ifdef ORIGINAL_CODE int bubbleX = cenX - 191; int bubbleY = height - 19; - -#ifndef ORIGINAL_CODE - bubbleX = cenX - 91; - bubbleY = height - 41; +#else + int bubbleX = cenX - 91; + int bubbleY = height - 41; #endif //@NOTE: Not sure this works as it should diff --git a/source/client/gui/components/OptionList.cpp b/source/client/gui/components/OptionList.cpp index 2ae1932..59bc8d2 100644 --- a/source/client/gui/components/OptionList.cpp +++ b/source/client/gui/components/OptionList.cpp @@ -234,7 +234,6 @@ void OptionList::drawOnOffSwitch(int x, int y, bool state, bool disabled) void OptionList::renderItem(int index, int x, int y, int height, Tesselator& t) { - Font* f = m_pMinecraft->m_pFont; OptionItem* pItem = m_items[index]; pItem->render(this, x, y); @@ -347,6 +346,8 @@ void OptionList::initDefaultMenu() #ifdef __EMSCRIPTEN m_items[idxLM]->setDisabled(true); +#else + (void)idxLM; #endif if (!GetPatchManager()->IsGrassSidesTinted()) diff --git a/source/client/gui/components/ScrolledSelectionList.cpp b/source/client/gui/components/ScrolledSelectionList.cpp index 1267623..3116b41 100644 --- a/source/client/gui/components/ScrolledSelectionList.cpp +++ b/source/client/gui/components/ScrolledSelectionList.cpp @@ -97,7 +97,6 @@ void ScrolledSelectionList::renderScrollBackground() void ScrolledSelectionList::checkInput(int mouseX, int mouseY) { - int nItems = getNumberOfItems(); if (Mouse::isButtonDown(BUTTON_LEFT)) { if (float(mouseY) >= field_C && float(mouseY) <= field_10 && abs(mouseY - field_28) > 5) diff --git a/source/client/gui/components/TextInputBox.cpp b/source/client/gui/components/TextInputBox.cpp index 9805045..fa66ba5 100644 --- a/source/client/gui/components/TextInputBox.cpp +++ b/source/client/gui/components/TextInputBox.cpp @@ -47,9 +47,9 @@ void TextInputBox::keyPressed(Minecraft* minecraft, int key) if (!m_bFocused) return; - bool bShiftPressed = minecraft->platform()->shiftPressed(); - #ifndef HANDLE_CHARS_SEPARATELY + bool bShiftPressed = minecraft->platform()->shiftPressed(); + char chr = '\0'; if (key >= AKEYCODE_A && key <= AKEYCODE_Z) { diff --git a/source/client/gui/screens/PauseScreen.cpp b/source/client/gui/screens/PauseScreen.cpp index b06a550..7f155f5 100644 --- a/source/client/gui/screens/PauseScreen.cpp +++ b/source/client/gui/screens/PauseScreen.cpp @@ -63,7 +63,7 @@ void PauseScreen::init() m_btnOptions.m_yPos = currY; m_btnOptions.m_xPos = m_btnBack.m_xPos; #endif - currY += inc; + //currY += inc; // add the buttons to the screen: m_buttons.push_back(&m_btnBack); diff --git a/source/client/player/input/UnifiedTurnBuild.cpp b/source/client/player/input/UnifiedTurnBuild.cpp index 5934f10..c8f7786 100644 --- a/source/client/player/input/UnifiedTurnBuild.cpp +++ b/source/client/player/input/UnifiedTurnBuild.cpp @@ -30,7 +30,7 @@ UnifiedTurnBuild::UnifiedTurnBuild(int a, int width, int height, float d, float { m_includeExcludeArea.field_4 = false; - setScreenSize(width, height); + UnifiedTurnBuild::setScreenSize(width, height); field_B8 = getTimeS(); field_CC = field_B8; field_D0 = 0; diff --git a/source/client/renderer/LevelRenderer.cpp b/source/client/renderer/LevelRenderer.cpp index 5e88bb2..4258e57 100644 --- a/source/client/renderer/LevelRenderer.cpp +++ b/source/client/renderer/LevelRenderer.cpp @@ -764,10 +764,10 @@ bool LevelRenderer::updateDirtyChunks(Mob* pMob, bool b) ChunkVector* v40; // r0 Chunk* v42[3]; // [sp+1Ch] [bp+0h] BYREF Chunk* a3; // [sp+28h] [bp+Ch] BYREF - Entity* pMob_1; // [sp+2Ch] [bp+10h] BYREF + //Entity* pMob_1; // [sp+2Ch] [bp+10h] BYREF v3 = 0; - pMob_1 = pMob; + //pMob_1 = pMob; DirtyChunkSorter dcs(pMob); memset(v42, 0, sizeof v42); field_88_Beg = this->field_88.begin(); diff --git a/source/client/renderer/TileRenderer.cpp b/source/client/renderer/TileRenderer.cpp index 0e59321..ec01fe5 100644 --- a/source/client/renderer/TileRenderer.cpp +++ b/source/client/renderer/TileRenderer.cpp @@ -796,7 +796,7 @@ bool TileRenderer::tesselateWaterInWorld(Tile* tile1, int x, int y, int z) label_8: bFlag2 = bFlag1; - bool bRenderedSides = false; + //bool bRenderedSides = false; for (int dir = 0; dir < 4; dir++) { @@ -868,7 +868,7 @@ label_8: texV_2 = C_RATIO * (float(texY) + (1.0f - height2) * 16.0f); texV_3 = C_RATIO * (float(texY + 16.0f) - 0.01f); bFlag2 = true; - bRenderedSides = true; + //bRenderedSides = true; float brightMul = dir >= DIR_XNEG ? 0.6f : 0.8f; float bright = tile->getBrightness(m_pLevelSource, checkX, y, checkZ); diff --git a/source/client/renderer/entity/EntityRenderDispatcher.cpp b/source/client/renderer/entity/EntityRenderDispatcher.cpp index c5fac5c..70c4072 100644 --- a/source/client/renderer/entity/EntityRenderDispatcher.cpp +++ b/source/client/renderer/entity/EntityRenderDispatcher.cpp @@ -65,7 +65,7 @@ EntityRenderDispatcher* EntityRenderDispatcher::getInstance() EntityRenderer* EntityRenderDispatcher::getRenderer(Entity* pEnt) { - switch (pEnt->field_C8) + switch (pEnt->m_renderType) { case RENDER_TNT: return &m_TntRenderer; diff --git a/source/client/renderer/entity/TripodCameraRenderer.cpp b/source/client/renderer/entity/TripodCameraRenderer.cpp index 6c28561..8a5f126 100644 --- a/source/client/renderer/entity/TripodCameraRenderer.cpp +++ b/source/client/renderer/entity/TripodCameraRenderer.cpp @@ -20,10 +20,10 @@ TripodCameraRenderer::TripodCameraRenderer() : float TripodCameraRenderer::getFlashTime(TripodCamera* camera, float f) { - if (camera->field_B90 > 7 || camera->field_B90 < 0) + if (camera->m_iTimer > 7 || camera->m_iTimer < 0) return -1.0f; - return 0.125f * (float(camera->field_B90) - f); + return 0.125f * (float(camera->m_iTimer) - f); } void TripodCameraRenderer::render(Entity* entity, float x, float y, float z, float a, float b) diff --git a/source/network/ServerSideNetworkHandler.cpp b/source/network/ServerSideNetworkHandler.cpp index c94af93..99e451d 100644 --- a/source/network/ServerSideNetworkHandler.cpp +++ b/source/network/ServerSideNetworkHandler.cpp @@ -119,9 +119,9 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, LoginPacke sgp.m_version = 2; sgp.m_time = m_pLevel->getTime(); - RakNet::BitStream sgpbs; - sgp.write(&sgpbs); - m_pRakNetPeer->Send(&sgpbs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, guid, false); + RakNet::BitStream *sgpbs; + sgp.write(sgpbs); + m_pRakNetPeer->Send(sgpbs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, guid, false); // send the connecting player info about all other players in the world for (int i = 0; i < int(m_pLevel->m_players.size()); i++) diff --git a/source/network/packets/LevelDataPacket.cpp b/source/network/packets/LevelDataPacket.cpp index 2059b80..3f82b64 100644 --- a/source/network/packets/LevelDataPacket.cpp +++ b/source/network/packets/LevelDataPacket.cpp @@ -60,7 +60,7 @@ void LevelDataPacket::write(RakNet::BitStream* pbs) if (pCompressedData) { - float ratio = 100.0f * float(compSize) / float(uncompSize); + //float ratio = 100.0f * float(compSize) / float(uncompSize); //LOG_I("Compression ratio: %.2f (%d comp, %d uncomp)", ratio, int(compSize), int(uncompSize)); int cs2 = int(compSize), us2 = int(uncompSize); diff --git a/source/world/entity/Entity.cpp b/source/world/entity/Entity.cpp index 8350e2f..aade02b 100644 --- a/source/world/entity/Entity.cpp +++ b/source/world/entity/Entity.cpp @@ -49,7 +49,7 @@ void Entity::_init() field_B8 = 0; field_BC = 300; field_C0 = 0; - field_C8 = 0; // @NOTE: Render type? (eEntityRenderType) + m_renderType = RENDER_NONE; m_distanceFallen = 0.0f; field_D0 = 300; field_D4 = 0; @@ -64,7 +64,7 @@ Entity::Entity(Level* pLevel) m_pLevel = pLevel; m_EntityID = ++entityCounter; - setPos(0, 0, 0); + Entity::setPos(0, 0, 0); } Entity::~Entity() diff --git a/source/world/entity/Entity.hpp b/source/world/entity/Entity.hpp index a012730..e6d9c05 100644 --- a/source/world/entity/Entity.hpp +++ b/source/world/entity/Entity.hpp @@ -203,7 +203,7 @@ public: int field_BC; int field_C0; int field_C4; - int field_C8; // @NOTE: Render type? (eEntityRenderType) + int m_renderType; float m_distanceFallen; int field_D0; uint8_t field_D4; diff --git a/source/world/entity/FallingTile.cpp b/source/world/entity/FallingTile.cpp index 41cd8f1..f9a5f77 100644 --- a/source/world/entity/FallingTile.cpp +++ b/source/world/entity/FallingTile.cpp @@ -30,7 +30,7 @@ FallingTile::FallingTile(Level* level, float x, float y, float z, int id) : Enti m_vel.z = 0.0f; #if defined(ENH_ALLOW_SAND_GRAVITY) - field_C8 = RENDER_FALLING_TILE; + m_renderType = RENDER_FALLING_TILE; #endif } diff --git a/source/world/entity/ItemEntity.cpp b/source/world/entity/ItemEntity.cpp index 338f028..f95703a 100644 --- a/source/world/entity/ItemEntity.cpp +++ b/source/world/entity/ItemEntity.cpp @@ -28,7 +28,7 @@ void ItemEntity::_init(ItemInstance* itemInstance, float x, float y, float z) { _init(itemInstance); - field_C8 = RENDER_ITEM; + m_renderType = RENDER_ITEM; setPos(x, y, z); m_yaw = 360.0f * Mth::random(); @@ -149,6 +149,7 @@ void ItemEntity::checkInTile(float x, float y, float z) if (!solidYP && 1.0f - ydiff < mindist) mindist = 1.0f - ydiff, mindir = 3; if (!solidZN && zdiff < mindist) mindist = zdiff, mindir = 4; if (!solidZP && 1.0f - zdiff < mindist) mindist = 1.0f - zdiff, mindir = 5; + (void)mindist; // the -1 case will be handled accordingly float force = 0.1f + 0.2f * sharedRandom.nextFloat(); diff --git a/source/world/entity/Player.cpp b/source/world/entity/Player.cpp index 0b3c200..f3dc63d 100644 --- a/source/world/entity/Player.cpp +++ b/source/world/entity/Player.cpp @@ -22,7 +22,7 @@ Player::Player(Level* pLevel) : Mob(pLevel) field_BC4 = 0; m_bHaveRespawnPos = false; - field_C8 = 2; + m_renderType = RENDER_HUMANOID; m_pInventory = new Inventory(this); diff --git a/source/world/entity/PrimedTnt.cpp b/source/world/entity/PrimedTnt.cpp index bca6ab9..fbac499 100644 --- a/source/world/entity/PrimedTnt.cpp +++ b/source/world/entity/PrimedTnt.cpp @@ -12,7 +12,7 @@ void PrimedTnt::_init() { m_fuseTimer = 0; - field_C8 = RENDER_TNT; + m_renderType = RENDER_TNT; field_34 = 1; setSize(0.98f, 0.98f); field_84 = field_8C * 0.5f; diff --git a/source/world/entity/TripodCamera.cpp b/source/world/entity/TripodCamera.cpp index 107336c..e8699a2 100644 --- a/source/world/entity/TripodCamera.cpp +++ b/source/world/entity/TripodCamera.cpp @@ -12,12 +12,11 @@ TripodCamera::TripodCamera(Level* level, Player* player, float x, float y, float z) : Mob(level) { - field_B8C = 0; - field_B90 = 80; + m_iTimer = 80; m_bActive = false; m_owner = player; - field_C8 = RENDER_CAMERA; + m_renderType = RENDER_CAMERA; field_60 = m_pitch = player->m_pitch; field_5C = m_yaw = player->m_yaw; @@ -83,14 +82,14 @@ void TripodCamera::tick() if (!m_bActive) return; - field_B90--; - if (field_B90 == 0) + m_iTimer--; + if (m_iTimer == 0) { remove(); return; } - if (field_B90 == 8) + if (m_iTimer == 8) { m_pLevel->takePicture(this, m_owner); m_pLevel->addParticle("explode", m_pos.x, m_pos.y + 0.6f, m_pos.z, 0.0f, 0.0f, 0.0f); @@ -99,7 +98,7 @@ void TripodCamera::tick() return; } - if (field_B90 > 8) + if (m_iTimer > 8) { m_pLevel->addParticle("smoke", m_pos.x, m_pos.y + 1.0f, m_pos.z, 0.0f, 0.0f, 0.0f); } diff --git a/source/world/entity/TripodCamera.hpp b/source/world/entity/TripodCamera.hpp index 871ab29..4c701b9 100644 --- a/source/world/entity/TripodCamera.hpp +++ b/source/world/entity/TripodCamera.hpp @@ -27,8 +27,7 @@ public: void tick() override; public: - int field_B8C; - int field_B90; + int m_iTimer; Player* m_owner; bool m_bActive; }; diff --git a/source/world/level/Level.cpp b/source/world/level/Level.cpp index 9ffb2f2..9bb1bac 100644 --- a/source/world/level/Level.cpp +++ b/source/world/level/Level.cpp @@ -1706,6 +1706,7 @@ float Level::getSeenPercent(Vec3 vec, AABB aabb) float aabbSizeZ = aabb.max.z - aabb.min.z; // This shoots a bunch of rays from a point and checks if the rays hit something. Stuupiiiddd + // FIXME(Er2): clang-analyzer-security.FloatLoopCounter for (float xi = 0.0f; xi <= 1.0f; xi += 1.0f / (1.0f + 2 * aabbSizeX)) { for (float yi = 0.0f; yi <= 1.0f; yi += 1.0f / (1.0f + 2 * aabbSizeY)) diff --git a/source/world/level/levelgen/chunk/ChunkCache.cpp b/source/world/level/levelgen/chunk/ChunkCache.cpp index 772f71f..06ab756 100644 --- a/source/world/level/levelgen/chunk/ChunkCache.cpp +++ b/source/world/level/levelgen/chunk/ChunkCache.cpp @@ -85,6 +85,8 @@ LevelChunk* ChunkCache::getChunk(int x, int z) if (m_pChunkSource) pChunk = m_pChunkSource->getChunk(x, z); + if (!pChunk) + return nullptr; m_chunkMap[z][x] = pChunk; pChunk->lightLava(); } @@ -92,6 +94,8 @@ LevelChunk* ChunkCache::getChunk(int x, int z) pChunk = m_chunkMap[z][x]; if (pChunk) pChunk->load(); + else + return nullptr; if (!pChunk->field_234 && hasChunk(x + 1, z + 1) && hasChunk(x, z + 1) && hasChunk(x + 1, z)) postProcess(this, x, z); diff --git a/source/world/level/levelgen/feature/BirchFeature.cpp b/source/world/level/levelgen/feature/BirchFeature.cpp index 8e906f5..1263c46 100644 --- a/source/world/level/levelgen/feature/BirchFeature.cpp +++ b/source/world/level/levelgen/feature/BirchFeature.cpp @@ -74,19 +74,19 @@ bool BirchFeature::place(Level* level, Random* random, int x, int y, int z) for (int i = lowerY; i <= upperY; i++, diff = i - upperY) { int c1 = 1 - diff / 2; - int c2 = diff / 2 - 1; + //int c2 = diff / 2 - 1; for (int ax = x - c1; ax <= x + c1; ax++) { - int c3 = c2; + //int c3 = c2; int c4 = diff / 2 - 1; - if (c2 < 0) - c3 = -c2; + //if (c2 < 0) + // c3 = -c2; //int c5 = c3; for (int az = z - c1; az <= z + c1; az++, c4++) { - if ((abs(ax - x) != c1 || abs(az - z) != c1 || (random->nextInt(2) != 0 && diff != 0)) && !Tile::solid[level->getTile(ax, i, az)]) + if ((abs(ax - x) != c1 || abs(az - z) != c1 || (random->nextInt(2) != 0 && diff != 0)) && !Tile::solid[level->getTile(ax, i, az)]) { level->setTileAndDataNoUpdate(ax, i, az, Tile::leaves->m_ID, 2); } diff --git a/source/world/level/levelgen/feature/TreeFeature.cpp b/source/world/level/levelgen/feature/TreeFeature.cpp index 638ac38..7c5a511 100644 --- a/source/world/level/levelgen/feature/TreeFeature.cpp +++ b/source/world/level/levelgen/feature/TreeFeature.cpp @@ -74,19 +74,19 @@ bool TreeFeature::place(Level* level, Random* random, int x, int y, int z) for (int i = lowerY; i <= upperY; i++, diff = i - upperY) { int c1 = 1 - diff / 2; - int c2 = diff / 2 - 1; + //int c2 = diff / 2 - 1; for (int ax = x - c1; ax <= x + c1; ax++) { - int c3 = c2; + //int c3 = c2; int c4 = diff / 2 - 1; - if (c2 < 0) - c3 = -c2; + //if (c2 < 0) + // c3 = -c2; //int c5 = c3; for (int az = z - c1; az <= z + c1; az++, c4++) { - if ((abs(ax - x) != c1 || abs(az - z) != c1 || (random->nextInt(2) != 0 && diff != 0)) && !Tile::solid[level->getTile(ax, i, az)]) + if ((abs(ax - x) != c1 || abs(az - z) != c1 || (random->nextInt(2) != 0 && diff != 0)) && !Tile::solid[level->getTile(ax, i, az)]) { level->setTileNoUpdate(ax, i, az, Tile::leaves->m_ID); } diff --git a/source/world/level/storage/ExternalFileLevelStorageSource.cpp b/source/world/level/storage/ExternalFileLevelStorageSource.cpp index 53eaa5e..9a633e3 100644 --- a/source/world/level/storage/ExternalFileLevelStorageSource.cpp +++ b/source/world/level/storage/ExternalFileLevelStorageSource.cpp @@ -26,7 +26,7 @@ ExternalFileLevelStorageSource::ExternalFileLevelStorageSource(const std::string if (createFolderIfNotExists(m_worldsPath.c_str())) { std::vector vls; - getLevelList(vls); + ExternalFileLevelStorageSource::getLevelList(vls); } } } diff --git a/source/world/tile/ClothTile.cpp b/source/world/tile/ClothTile.cpp index 28088a8..92832ae 100644 --- a/source/world/tile/ClothTile.cpp +++ b/source/world/tile/ClothTile.cpp @@ -13,7 +13,7 @@ ClothTile::ClothTile(int id, int type) : Tile(id, TEXTURE_CLOTH_64, Material::cl { field_6C = type; - m_TextureFrame = getTexture(0, type); + m_TextureFrame = ClothTile::getTexture(0, type); } int ClothTile::getTexture(int dir) diff --git a/source/world/tile/Sapling.cpp b/source/world/tile/Sapling.cpp index e40930c..0c8a2c4 100644 --- a/source/world/tile/Sapling.cpp +++ b/source/world/tile/Sapling.cpp @@ -40,6 +40,7 @@ bool Sapling::maybeGrowTree(Level* level, int x, int y, int z, Random* random) BirchFeature birchFeature; SpruceFeature spruceFeature; +/* Feature* pFeature = &treeFeature; int data = level->getData(x, y, z); @@ -52,6 +53,7 @@ bool Sapling::maybeGrowTree(Level* level, int x, int y, int z, Random* random) pFeature = &spruceFeature; break; } +*/ return treeFeature.place(level, random, x, y, z); }