From 485551aa89e7b56a682b1c87ed87bfd53f11d1aa Mon Sep 17 00:00:00 2001 From: auria Date: Sun, 9 Jun 2013 20:04:07 +0000 Subject: [PATCH] Apply patch by KroArtem to fix minor issues : unused variables and other minor warnings from cppcheck, crash when launching from terminal with AI karts in a mode where AI is not supported git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12857 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/config/user_config.cpp | 1 - src/karts/kart.cpp | 2 +- src/main.cpp | 50 +++++++++++++++++++++++++++-------- src/modes/easter_egg_hunt.cpp | 1 - src/physics/physics.cpp | 1 - src/tracks/quad_graph.cpp | 8 +++--- 6 files changed, 44 insertions(+), 19 deletions(-) diff --git a/src/config/user_config.cpp b/src/config/user_config.cpp index 8bc3539d2..d4f11a16a 100644 --- a/src/config/user_config.cpp +++ b/src/config/user_config.cpp @@ -284,7 +284,6 @@ irr::core::stringw TimeUserConfigParam::toString() const // we can't use an irrlicht's stringw directly. Since it's only a // number, we can use std::string, and convert to stringw - std::string tmp; std::ostringstream o; o<setDamping(0.8f, 0.8f); m_goo_sound->position(getXYZ()); m_goo_sound->play(); diff --git a/src/main.cpp b/src/main.cpp index 71c083beb..2f84d9c06 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -352,7 +352,7 @@ void cmdLineHelp (char* invocation) " -N, --no-start-screen Immediately start race without showing a " "menu.\n" " -R, --race-now Same as -N but also skip the ready-set-go phase" - "and the music.\n" + " and the music.\n" " -t, --track NAME Start at track NAME (see --list-tracks).\n" " --gp NAME Start the specified Grand Prix.\n" " --stk-config FILE use ./data/FILE instead of " @@ -432,8 +432,6 @@ int handleCmdLinePreliminary(int argc, char **argv) { if(argv[i][0] != '-') continue; if (!strcmp(argv[i], "--help" ) || - !strcmp(argv[i], "-help" ) || - !strcmp(argv[i], "--help" ) || !strcmp(argv[i], "-help" ) || !strcmp(argv[i], "-h" ) ) { @@ -828,9 +826,23 @@ int handleCmdLine(int argc, char **argv) argv[i+1]); } else if (t->isArena()) + { + //if it's arena, don't create ai karts + const std::vector l; + race_manager->setDefaultAIKartList(l); + // Add 1 for the player kart + race_manager->setNumKarts(1); race_manager->setMinorMode(RaceManager::MINOR_MODE_3_STRIKES); + } else if(t->isSoccer()) + { + //if it's soccer, don't create ai karts + const std::vector l; + race_manager->setDefaultAIKartList(l); + // Add 1 for the player kart + race_manager->setNumKarts(1); race_manager->setMinorMode(RaceManager::MINOR_MODE_SOCCER); + } } else { @@ -932,17 +944,33 @@ int handleCmdLine(int argc, char **argv) } else if ( !strcmp(argv[i], "--laps") && i+1setNumLaps(atoi(argv[i+1])); - i++; + int laps = atoi(argv[i+1]); + if (laps < 0) + { + Log::error("main", "Invalid number of laps: %s.\n", argv[i+1] ); + return 0; + } + else + { + Log::verbose("main", "You choose to have %d laps.", laps); + race_manager->setNumLaps(laps); + i++; + } } else if( sscanf(argv[i], "--profile-laps=%d", &n)==1) { - Log::verbose("main", "Profiling %d laps.",n); - UserConfigParams::m_no_start_screen = true; - ProfileWorld::setProfileModeLaps(n); - race_manager->setNumLaps(n); + if (n < 0) + { + Log::error("main", "Invalid number of profile-laps: %i.\n", n ); + return 0; + } + else + { + Log::verbose("main", "Profiling %d laps.",n); + UserConfigParams::m_no_start_screen = true; + ProfileWorld::setProfileModeLaps(n); + race_manager->setNumLaps(n); + } } else if( sscanf(argv[i], "--profile-time=%d", &n)==1) { diff --git a/src/modes/easter_egg_hunt.cpp b/src/modes/easter_egg_hunt.cpp index 7b411172e..f50e81b00 100644 --- a/src/modes/easter_egg_hunt.cpp +++ b/src/modes/easter_egg_hunt.cpp @@ -198,7 +198,6 @@ void EasterEggHunt::getKartsDisplayInfo( for(unsigned int i = 0; i < kart_amount ; i++) { RaceGUIBase::KartIconDisplayInfo& rank_info = (*info)[i]; - std::ostringstream o; //I18n: number of collected eggs / overall number of eggs rank_info.m_text = StringUtils::insertValues(_("Eggs: %d / %d"), m_eggs_collected[i], diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp index eb4d81605..cf13ed9d1 100644 --- a/src/physics/physics.cpp +++ b/src/physics/physics.cpp @@ -415,7 +415,6 @@ btScalar Physics::solveGroup(btCollisionObject** bodies, int numBodies, // more than one object, and/or more than once with each object (if there // is more than one collision point). So keep a list of rockets that will // be exploded after the collisions - std::vector rocketsToExplode; for(int i=0; igetQuad().getVertices(new_v+4*i, c); @@ -538,8 +538,8 @@ void QuadGraph::createDebugMesh() for(unsigned int i=0; igetVertexCount(); i++) { // Swap the colours from red to blue and back - c.setRed (i%2 ? 255 : 0); - c.setBlue(i%2 ? 0 : 255); + c.setRed ((i%2) ? 255 : 0); + c.setBlue((i%2) ? 0 : 255); v[i].Color = c; } m_node = irr_driver->addMesh(m_mesh);