Made WARNING build option usable again
authorIngo Ruhnke <grumbel@gmail.com>
Sun, 10 Aug 2014 17:46:54 +0000 (19:46 +0200)
committerIngo Ruhnke <grumbel@gmail.com>
Sun, 10 Aug 2014 17:46:54 +0000 (19:46 +0200)
* disabled compiler warning that currently make the build fail
* made warnings specific to the supertux2 target
* split of .c code into separate target, as gcc doesn't like C++ warning flags for C files
* fixed a few -Weffc++ issues in the code

17 files changed:
CMakeLists.txt
src/badguy/goldbomb.cpp
src/badguy/haywire.cpp
src/badguy/haywire.hpp
src/badguy/livefire.cpp
src/gui/menu.cpp
src/object/bonus_block.cpp
src/object/player.cpp
src/supertux/game_session.cpp
src/supertux/title_screen.cpp
src/supertux/world.hpp
src/trigger/secretarea_trigger.cpp
src/video/gl/gl_renderer.cpp
src/video/gl/gl_renderer.hpp
src/video/sdl/sdl_lightmap.cpp
src/video/sdl/sdl_texture.cpp
src/worldmap/worldmap.cpp

index d4b606d..c3f7371 100644 (file)
@@ -6,12 +6,12 @@
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
@@ -255,9 +255,13 @@ IF(CMAKE_COMPILER_IS_GNUCC)
     REMOVE_DEFINITIONS(-Werror)
   ENDIF(WERROR)
   IF(WARNINGS)
-    ADD_DEFINITIONS(-fdiagnostics-show-option -pedantic -Wno-long-long -Wcast-align -Wdisabled-optimization -Winit-self -Winvalid-pch -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wredundant-decls -Wstack-protector -Wconversion -Wundef -Wsign-conversion -Wshadow -Winline -Wunsafe-loop-optimizations -Wfloat-equal -Wswitch-default -Wswitch-enum -Wcast-qual -Wsign-promo -Woverloaded-virtual -Wmissing-format-attribute -Wstrict-overflow=5 -Wformat=2-Weffc++ -Wabi -Wctor-dtor-privacy -Wstrict-null-sentinel -Wno-unused-parameter)
-    # -ansi fails in MinGW
-    # still left:  -Wold-style-cast -Wpadded
+    # temporarily disabled:
+    #   -Wsign-conversion -Wfloat-equal -Wconversion -Wundef -Wshadow -Wswitch-default
+    #   -Wswitch-enum -Wsign-promo -Wcast-qual -Woverloaded-virtual -Wmissing-format-attribute
+    #   -Wold-style-cast -Wpadded
+    # fails on MinGW:
+    #   -ansi
+    SET(SUPERTUX2_EXTRA_WARNING_FLAGS "-fdiagnostics-show-option -pedantic -Wno-long-long -Wcast-align -Wdisabled-optimization -Winit-self -Winvalid-pch -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wredundant-decls -Wstack-protector -Winline -Wunsafe-loop-optimizations  -Wstrict-overflow=5 -Wformat=2 -Weffc++ -Wabi -Wctor-dtor-privacy -Wstrict-null-sentinel -Wno-unused-parameter")
   ENDIF(WARNINGS)
 ENDIF(CMAKE_COMPILER_IS_GNUCC)
 
@@ -307,7 +311,7 @@ IF(GENERATE_MESSAGESPOT)
     ENDFOREACH(SUPERTUX_LEVEL_DIR)
 
     ADD_CUSTOM_TARGET(
-      supertux2-messages ALL 
+      supertux2-messages ALL
       DEPENDS ${MESSAGES_POT_FILES}
     )
 
@@ -350,13 +354,15 @@ SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
 
 ## Add target for supertux binary
 
-ADD_EXECUTABLE(supertux2 ${CMAKE_BINARY_DIR}/version.h ${SUPERTUX_SOURCES_C} ${SUPERTUX_SOURCES_CXX} ${TINYGETTEXT_SOURCES_CXX})
+ADD_LIBRARY(supertux2_c OBJECT ${SUPERTUX_SOURCES_C})
+ADD_EXECUTABLE(supertux2 ${CMAKE_BINARY_DIR}/version.h ${SUPERTUX_SOURCES_CXX} ${TINYGETTEXT_SOURCES_CXX} $<TARGET_OBJECTS:supertux2_c>)
 ADD_DEPENDENCIES(supertux2 gitversion)
+SET_TARGET_PROPERTIES(supertux2 PROPERTIES COMPILE_FLAGS "${SUPERTUX2_EXTRA_WARNING_FLAGS}")
 
 ## Link supertux binary with squirrel and other libraries
 
-TARGET_INCLUDE_DIRECTORIES(supertux2 PUBLIC ${SDL2_INCLUDE_DIRS})
-TARGET_INCLUDE_DIRECTORIES(supertux2 PUBLIC ${SDL2IMAGE_INCLUDE_DIRS})
+TARGET_INCLUDE_DIRECTORIES(supertux2 SYSTEM PUBLIC ${SDL2_INCLUDE_DIRS})
+TARGET_INCLUDE_DIRECTORIES(supertux2 SYSTEM PUBLIC ${SDL2IMAGE_INCLUDE_DIRS})
 TARGET_LINK_LIBRARIES(supertux2 ${SDL2_LIBRARIES})
 TARGET_LINK_LIBRARIES(supertux2 ${SDL2IMAGE_LIBRARIES})
 
index 60cc90f..c177a99 100644 (file)
@@ -31,7 +31,8 @@ GoldBomb::GoldBomb(const Reader& reader) :
   WalkingBadguy(reader, "images/creatures/gold_bomb/gold_bomb.sprite", "left", "right"),
   tstate(STATE_NORMAL),
   grabbed(false),
-  grabber(NULL)
+  grabber(NULL),
+  ticking()
 {
   walk_speed = 80;
   max_drop_height = 16;
index b968de5..d1bfa58 100644 (file)
@@ -34,7 +34,9 @@ Haywire::Haywire(const Reader& reader) :
   is_exploding(false),
   time_until_explosion(0.0f),
   is_stunned(false),
-  time_stunned(0.0f)
+  time_stunned(0.0f),
+  ticking(),
+  grunting()
 {
   walk_speed = 80;
   max_drop_height = 16;
index 5e4817d..c7a1e54 100644 (file)
@@ -44,7 +44,7 @@ private:
   bool is_stunned;
   float time_stunned;
   
-  std::unique_ptr<SoundSource> ticking;  
+  std::unique_ptr<SoundSource> ticking;
   std::unique_ptr<SoundSource> grunting;
 };
 
index cc5011c..46b0ba5 100644 (file)
 LiveFire::LiveFire(const Reader& reader) :
   WalkingBadguy(reader, "images/creatures/livefire/livefire.sprite", "left", "right"),
   lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-medium.sprite")),
+  death_sound("sounds/fall.wav"),
   state(STATE_WALKING)  
 {
   walk_speed = 80;
   max_drop_height = 20;
   lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
   lightsprite->set_color(Color(1.0f, 0.9f, 0.8f));
-  death_sound = "sounds/fall.wav";
 }
 
 void
index 7acd17f..d26a782 100644 (file)
@@ -327,6 +327,7 @@ Menu::process_input()
         case MN_BACK:
           MenuManager::instance().pop_menu();
           break;
+
         default:
           break;
       }
index 83cab76..8b53826 100644 (file)
@@ -45,6 +45,8 @@ BonusBlock::BonusBlock(const Vector& pos, int data) :
   contents(),
   object(0),
   hit_counter(1),
+  sprite_name(),
+  script(),
   lightsprite()
 {
   bbox.set_pos(pos);
@@ -85,6 +87,8 @@ BonusBlock::BonusBlock(const Reader& lisp) :
   contents(),
   object(0),
   hit_counter(1),
+  sprite_name(),
+  script(),
   lightsprite()
 {
   Vector pos;
index 2dbc8ef..02aed87 100644 (file)
@@ -117,6 +117,7 @@ Player::Player(PlayerStatus* _player_status, const std::string& name) :
   duck(),
   dead(),
   dying(),
+  winning(),
   backflipping(),
   backflip_direction(),
   peekingX(),
index 69e5fde..50e235d 100644 (file)
 
 GameSession::GameSession(const std::string& levelfile_, PlayerStatus* player_status, Statistics* statistics) :
   level(),
-  statistics_backdrop(),
+  statistics_backdrop(Surface::create("images/engine/menu/score-backdrop.png")),
   scripts(),
-  currentsector(0),
+  currentsector(nullptr),
   levelnb(),
   pause_menu_frame(),
   end_sequence(0),
-  game_pause(),
-  speed_before_pause(),
+  game_pause(false),
+  speed_before_pause(g_screen_manager->get_speed()),
   levelfile(levelfile_), 
   reset_sector(),
   reset_pos(),
@@ -67,15 +67,12 @@ GameSession::GameSession(const std::string& levelfile_, PlayerStatus* player_sta
   demo_controller(0),
   play_time(0), 
   edit_mode(false), 
-  levelintro_shown(false)
+  levelintro_shown(false),
+  coins_at_start(),
+  bonus_at_start(),
+  max_fire_bullets_at_start(),
+  max_ice_bullets_at_start()
 {
-  currentsector = NULL;
-
-  game_pause = false;
-  speed_before_pause = g_screen_manager->get_speed();
-
-  statistics_backdrop = Surface::create("images/engine/menu/score-backdrop.png");
-
   if (restart_level() != 0)
     throw std::runtime_error ("Initializing the level failed.");
 }
index 681e3e3..62d810e 100644 (file)
@@ -43,7 +43,8 @@
 TitleScreen::TitleScreen(PlayerStatus* player_status) :
   frame(),
   controller(),
-  titlesession()
+  titlesession(),
+  copyright_text()
 {
   controller.reset(new CodeController());
   titlesession.reset(new GameSession("levels/misc/menu.stl", player_status));
index c976c60..4200ed9 100644 (file)
@@ -59,6 +59,7 @@ private:
   std::string worldname;
   struct Level
   {
+    Level() : fullpath(), name() {}
     std::string fullpath;
     std::string name;
   };
index 8bddf8c..b356430 100644 (file)
@@ -32,7 +32,8 @@ SecretAreaTrigger::SecretAreaTrigger(const Reader& reader) :
   message_timer(),
   message_displayed(),
   message(),
-  fade_tilemap()
+  fade_tilemap(),
+  script()
 {
   reader.get("x", bbox.p1.x);
   reader.get("y", bbox.p1.y);
index 849006b..6dc1df3 100644 (file)
@@ -37,6 +37,8 @@
 
 GLRenderer::GLRenderer() :
   window(),
+  glcontext(),
+  viewport(),
   desktop_size(0, 0),
   fullscreen_active(false),
   last_texture(static_cast<GLuint> (-1))
index dd07e82..13bc6f9 100644 (file)
@@ -132,6 +132,10 @@ public:
   Vector to_logical(int physical_x, int physical_y);
   void set_gamma(float gamma);
   SDL_Window* get_window() const { return window; }
+
+private:
+  GLRenderer(const GLRenderer&) = delete;
+  GLRenderer& operator=(const GLRenderer&) = delete;
 };
 
 #endif
index 2630a72..794b918 100644 (file)
@@ -24,6 +24,7 @@
 
 SDLLightmap::SDLLightmap() :
   renderer(static_cast<SDLRenderer*>(Renderer::instance())->get_sdl_renderer()),
+  texture(),
   width(),
   height(),
   LIGHTMAP_DIV()
index 6093e3d..853bef2 100644 (file)
@@ -29,7 +29,9 @@
 #include <SDL.h>
 
 SDLTexture::SDLTexture(SDL_Surface* image) :
-  texture()
+  texture(),
+  width(),
+  height()
 {
   texture = SDL_CreateTextureFromSurface(static_cast<SDLRenderer*>(Renderer::instance())->get_sdl_renderer(),
                                          image);
index dafa8d1..e9e66f6 100644 (file)
@@ -104,7 +104,9 @@ WorldMap::WorldMap(const std::string& filename, PlayerStatus* player_status, con
   force_spawnpoint(force_spawnpoint),
   in_level(false),
   pan_pos(),
-  panning(false)
+  panning(false),
+  last_position(),
+  last_target_time()
 {
   tux = new Tux(this);
   add_object(tux);