From 77f1f58c0a7eb55001b375f1945690ed5c1e87a2 Mon Sep 17 00:00:00 2001 From: tycho Date: Tue, 19 May 2015 19:32:10 +0100 Subject: Make -Werror disabling file only Ad fix a load of warnings --- src/BlockEntities/CMakeLists.txt | 5 +++++ src/BlockEntities/MobSpawnerEntity.cpp | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src/BlockEntities') diff --git a/src/BlockEntities/CMakeLists.txt b/src/BlockEntities/CMakeLists.txt index 5f4af288d..b0bfca5e4 100644 --- a/src/BlockEntities/CMakeLists.txt +++ b/src/BlockEntities/CMakeLists.txt @@ -41,6 +41,11 @@ SET (HDRS NoteEntity.h SignEntity.h) +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set_source_files_properties(BeaconEntity.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion -Wno-error=switch-enum") + set_source_files_properties(NoteEntity.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=conversion -Wno-error=sign-conversion") +endif() + if(NOT MSVC) add_library(BlockEntities ${SRCS} ${HDRS}) endif() diff --git a/src/BlockEntities/MobSpawnerEntity.cpp b/src/BlockEntities/MobSpawnerEntity.cpp index 764d7af84..f8222822c 100644 --- a/src/BlockEntities/MobSpawnerEntity.cpp +++ b/src/BlockEntities/MobSpawnerEntity.cpp @@ -246,9 +246,9 @@ int cMobSpawnerEntity::GetNearbyMonsterNum(eMonsterType a_EntityType) class cCallback : public cChunkDataCallback { public: - cCallback(Vector3d a_SpawnerPos, eMonsterType a_EntityType, int & a_NumEntities) : + cCallback(Vector3d a_SpawnerPos, eMonsterType a_CallbackEntityType, int & a_NumEntities) : m_SpawnerPos(a_SpawnerPos), - m_EntityType(a_EntityType), + m_EntityType(a_CallbackEntityType), m_NumEntities(a_NumEntities) { } -- cgit v1.2.3 From dae9e5792a4f030ae9e748548a16a89790fbd311 Mon Sep 17 00:00:00 2001 From: tycho Date: Sun, 24 May 2015 12:56:56 +0100 Subject: Made -Weverything an error. --- src/BlockEntities/BeaconEntity.cpp | 6 +++--- src/BlockEntities/MobSpawnerEntity.cpp | 13 +++++++++---- src/BlockEntities/NoteEntity.cpp | 9 +++++++-- 3 files changed, 19 insertions(+), 9 deletions(-) (limited to 'src/BlockEntities') diff --git a/src/BlockEntities/BeaconEntity.cpp b/src/BlockEntities/BeaconEntity.cpp index fb3940ce9..a945c6ea9 100644 --- a/src/BlockEntities/BeaconEntity.cpp +++ b/src/BlockEntities/BeaconEntity.cpp @@ -77,7 +77,7 @@ bool cBeaconEntity::IsValidEffect(cEntityEffect::eType a_Effect, char a_BeaconLe default: { - LOGD("%s: Invalid beacon effect: %d", __FUNCTION__, (int)a_Effect); + LOGD("%s: Invalid beacon effect: %d", __FUNCTION__, static_cast(a_Effect)); return false; } } @@ -228,9 +228,9 @@ void cBeaconEntity::GiveEffects(void) virtual bool Item(cPlayer * a_Player) { Vector3d PlayerPosition = Vector3d(a_Player->GetPosition()); - if (PlayerPosition.y > (double)m_PosY) + if (PlayerPosition.y > static_cast(m_PosY)) { - PlayerPosition.y = (double)m_PosY; + PlayerPosition.y = static_cast(m_PosY); } // TODO: Vanilla minecraft uses an AABB check instead of a radius one diff --git a/src/BlockEntities/MobSpawnerEntity.cpp b/src/BlockEntities/MobSpawnerEntity.cpp index f8222822c..4746bdd1b 100644 --- a/src/BlockEntities/MobSpawnerEntity.cpp +++ b/src/BlockEntities/MobSpawnerEntity.cpp @@ -145,9 +145,9 @@ void cMobSpawnerEntity::SpawnEntity(void) break; } - int RelX = (int) (m_RelX + (double)(Random.NextFloat() - Random.NextFloat()) * 4.0); + int RelX = static_cast(m_RelX + static_cast(Random.NextFloat() - Random.NextFloat()) * 4.0); int RelY = m_RelY + Random.NextInt(3) - 1; - int RelZ = (int) (m_RelZ + (double)(Random.NextFloat() - Random.NextFloat()) * 4.0); + int RelZ = static_cast(m_RelZ + static_cast(Random.NextFloat() - Random.NextFloat()) * 4.0); cChunk * Chunk = a_Chunk->GetRelNeighborChunkAdjustCoords(RelX, RelZ); if ((Chunk == nullptr) || !Chunk->IsValid()) @@ -172,7 +172,12 @@ void cMobSpawnerEntity::SpawnEntity(void) if (Chunk->GetWorld()->SpawnMobFinalize(Monster) != cEntity::INVALID_ID) { EntitiesSpawned = true; - Chunk->BroadcastSoundParticleEffect(2004, (int)(PosX * 8.0), (int)(RelY * 8.0), (int)(PosZ * 8.0), 0); + Chunk->BroadcastSoundParticleEffect( + 2004, + static_cast(PosX * 8.0), + static_cast(RelY * 8.0), + static_cast(PosZ * 8.0), + 0); m_NearbyEntitiesNum++; } } @@ -260,7 +265,7 @@ int cMobSpawnerEntity::GetNearbyMonsterNum(eMonsterType a_EntityType) return; } - cMonster * Mob = (cMonster *)a_Entity; + cMonster * Mob = static_cast(a_Entity); if (Mob->GetMobType() != m_EntityType) { return; diff --git a/src/BlockEntities/NoteEntity.cpp b/src/BlockEntities/NoteEntity.cpp index a9af13c55..48ca15d1f 100644 --- a/src/BlockEntities/NoteEntity.cpp +++ b/src/BlockEntities/NoteEntity.cpp @@ -90,8 +90,13 @@ void cNoteEntity::MakeSound(void) m_World->BroadcastBlockAction(m_PosX, m_PosY, m_PosZ, instrument, m_Pitch, E_BLOCK_NOTE_BLOCK); // TODO: instead of calculating the power function over and over, make a precalculated table - there's only 24 pitches after all - float calcPitch = pow(2.0f, ((float)m_Pitch - 12.0f) / 12.0f); - m_World->BroadcastSoundEffect(sampleName, (double)m_PosX, (double)m_PosY, (double)m_PosZ, 3.0f, calcPitch); + float calcPitch = pow(2.0f, static_cast(m_Pitch - 12.0f) / 12.0f); + m_World->BroadcastSoundEffect( + sampleName, + static_cast(m_PosX), + static_cast(m_PosY), + static_cast(m_PosZ), + 3.0f, calcPitch); } -- cgit v1.2.3 From b2fa71a32ac8bd86bda778a5d54fe2e7e471a1c0 Mon Sep 17 00:00:00 2001 From: tycho Date: Thu, 28 May 2015 12:29:26 +0100 Subject: Fix comments --- src/BlockEntities/MobSpawnerEntity.cpp | 3 ++- src/BlockEntities/NoteEntity.cpp | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src/BlockEntities') diff --git a/src/BlockEntities/MobSpawnerEntity.cpp b/src/BlockEntities/MobSpawnerEntity.cpp index 4746bdd1b..1a0ce5b22 100644 --- a/src/BlockEntities/MobSpawnerEntity.cpp +++ b/src/BlockEntities/MobSpawnerEntity.cpp @@ -177,7 +177,8 @@ void cMobSpawnerEntity::SpawnEntity(void) static_cast(PosX * 8.0), static_cast(RelY * 8.0), static_cast(PosZ * 8.0), - 0); + 0 + ); m_NearbyEntitiesNum++; } } diff --git a/src/BlockEntities/NoteEntity.cpp b/src/BlockEntities/NoteEntity.cpp index 48ca15d1f..29839bae1 100644 --- a/src/BlockEntities/NoteEntity.cpp +++ b/src/BlockEntities/NoteEntity.cpp @@ -92,11 +92,13 @@ void cNoteEntity::MakeSound(void) // TODO: instead of calculating the power function over and over, make a precalculated table - there's only 24 pitches after all float calcPitch = pow(2.0f, static_cast(m_Pitch - 12.0f) / 12.0f); m_World->BroadcastSoundEffect( - sampleName, - static_cast(m_PosX), - static_cast(m_PosY), - static_cast(m_PosZ), - 3.0f, calcPitch); + sampleName, + static_cast(m_PosX), + static_cast(m_PosY), + static_cast(m_PosZ), + 3.0f, + calcPitch + ); } -- cgit v1.2.3