clang-tidy: fix many warnings

This commit is contained in:
Er2
2023-12-02 21:04:21 +03:00
parent 0f9131c43a
commit bf78dd4bf1
28 changed files with 61 additions and 57 deletions

View File

@@ -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)
{

View File

@@ -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

View File

@@ -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())

View File

@@ -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)

View File

@@ -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)
{

View File

@@ -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);

View File

@@ -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;

View File

@@ -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();

View File

@@ -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);

View File

@@ -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;

View File

@@ -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)

View File

@@ -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++)

View File

@@ -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);

View File

@@ -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()

View File

@@ -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;

View File

@@ -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
}

View File

@@ -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();

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -27,8 +27,7 @@ public:
void tick() override;
public:
int field_B8C;
int field_B90;
int m_iTimer;
Player* m_owner;
bool m_bActive;
};

View File

@@ -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))

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -26,7 +26,7 @@ ExternalFileLevelStorageSource::ExternalFileLevelStorageSource(const std::string
if (createFolderIfNotExists(m_worldsPath.c_str()))
{
std::vector<LevelSummary> vls;
getLevelList(vls);
ExternalFileLevelStorageSource::getLevelList(vls);
}
}
}

View File

@@ -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)

View File

@@ -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);
}