Replaced many printf with log (see #937). Thanks to

unitraxx.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12674 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2013-04-19 06:53:17 +00:00
parent a693eb7eb5
commit 9d5c41f4ad
9 changed files with 46 additions and 64 deletions

View File

@ -40,7 +40,7 @@ void Challenge::load(const XMLNode* challengesNode)
const XMLNode* node = challengesNode->getNode( m_data->getId() );
if(node == NULL)
{
fprintf(stderr, "[Challenge] Couldn't find node <%s> in challenge list."
Log::info("Challenge", "Couldn't find node <%s> in challenge list."
"(If this is the first time you play this is normal)\n",
m_data->getId().c_str());
return;

View File

@ -184,7 +184,7 @@ void Kart::init(RaceManager::KartType type)
if(!m_engine_sound)
{
fprintf(stdout, "Error: Could not allocate a sfx object for the kart. Further errors may ensue!\n");
Log::error("Kart","Could not allocate a sfx object for the kart. Further errors may ensue!\n");
}
@ -1002,7 +1002,9 @@ void Kart::update(float dt)
if(m_view_blocked_by_plunger > 0) m_view_blocked_by_plunger -= dt;
// Decrease remaining invulnerability time
if(m_invulnerable_time>0) m_invulnerable_time-=dt;
if(m_invulnerable_time>0){
m_invulnerable_time-=dt;
}
m_slipstream->update(dt);
@ -1139,7 +1141,7 @@ void Kart::update(float dt)
#ifdef DEBUG
if(UserConfigParams::m_material_debug)
{
printf("%s\tfraction %f\ttime %f.\n",
Log::info("Kart","%s\tfraction %f\ttime %f.\n",
material->getTexFname().c_str(),
material->getMaxSpeedFraction(),
material->getSlowDownTime() );
@ -1540,7 +1542,7 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
// Add a counter to make it easier to see if a new line of
// output was added.
static int counter=0;
printf("Kart %s hit track: %d material %s.\n",
Log::info("Kart","Kart %s hit track: %d material %s.\n",
getIdent().c_str(), counter++,
m ? m->getTexFname().c_str() : "None");
}
@ -1623,7 +1625,7 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
}
else
{
fprintf(stderr, "Unknown particles kind <%s> in material "
Log::error("Kart","Unknown particles kind <%s> in material "
"crash-reset properties\n", particles.c_str());
}
}
@ -1855,7 +1857,7 @@ void Kart::updatePhysics(float dt)
m_speed = 0;
updateEngineSFX();
#ifdef XX
printf("forward %f %f %f %f side %f %f %f %f angVel %f %f %f heading %f\n"
Log::info("Kart","forward %f %f %f %f side %f %f %f %f angVel %f %f %f heading %f\n"
,m_vehicle->m_forwardImpulse[0]
,m_vehicle->m_forwardImpulse[1]
,m_vehicle->m_forwardImpulse[2]

View File

@ -38,17 +38,7 @@ OverWorld::OverWorld() : LinearWorld()
{
m_return_to_garage = false;
m_stop_music_when_dialog_open = false;
}
// ----------------------------------------------------------------------------
/** Actually initialises the world, i.e. creates all data structures to
* for all karts etc. In init functions can be called that use
* World::getWorld().
*/
void OverWorld::init()
{
LinearWorld::init();
} // init
} // Overworld
//-----------------------------------------------------------------------------
OverWorld::~OverWorld()
@ -79,7 +69,8 @@ void OverWorld::enterOverWorld()
if (!kart_properties_manager->getKart(UserConfigParams::m_default_kart))
{
Log::warn("overworld", "cannot find kart '%s', "
"will revert to default\n", UserConfigParams::m_default_kart.c_str());
"will revert to default\n",
UserConfigParams::m_default_kart.c_str());
UserConfigParams::m_default_kart.revertToDefaults();
}
@ -185,7 +176,6 @@ void OverWorld::onFirePressed(Controller* who)
if ( (kart_xyz - Vec3(challenges[n].m_position)).length2_2d()
< CHALLENGE_DISTANCE_SQUARED)
{
if (challenges[n].m_challenge_id == "tutorial")
{
scheduleTutorial();
@ -285,9 +275,9 @@ void OverWorld::moveKartAfterRescue(AbstractKart* kart, float angle)
}
else
{
Log::warn("overworld", "invalid position after rescue for kart %s "
"on track %s.\n", (kart->getIdent().c_str()), m_track->getIdent().c_str());
Log::warn("overworld", "Invalid position after rescue for kart %s "
"on track %s.", (kart->getIdent().c_str()),
m_track->getIdent().c_str());
}
} // moveKartAfterRescue
@ -301,7 +291,7 @@ void OverWorld::onMouseClick(int x, int y)
{
const OverworldChallenge *challenge =
((RaceGUIOverworld*)getRaceGUI())->getCurrentChallenge();
if(challenge)
{
AbstractKart* kart = getKart(0);

View File

@ -47,10 +47,6 @@ protected:
public:
OverWorld();
/** call just after instanciating. can't be moved to the contructor as child
classes must be instanciated, otherwise polymorphism will fail and the
results will be incorrect */
virtual void init() OVERRIDE;
virtual ~OverWorld();
static void enterOverWorld();

View File

@ -57,7 +57,7 @@ void ThreeStrikesBattle::init()
// check for possible problems if AI karts were incorrectly added
if(getNumKarts() > race_manager->getNumPlayers())
{
fprintf(stderr, "No AI exists for this game mode\n");
Log::error("Three Strikes Battle", "No AI exists for this game mode");
exit(1);
}
m_kart_info.resize(m_karts.size());
@ -161,7 +161,6 @@ void ThreeStrikesBattle::kartAdded(AbstractKart* kart, scene::ISceneNode* node)
void ThreeStrikesBattle::kartHit(const unsigned int kart_id)
{
assert(kart_id < m_karts.size());
// make kart lose a life
m_kart_info[kart_id].m_lives--;
@ -172,7 +171,6 @@ void ThreeStrikesBattle::kartHit(const unsigned int kart_id)
m_battle_events.push_back(evt);
updateKartRanks();
// check if kart is 'dead'
if (m_kart_info[kart_id].m_lives < 1)
{

View File

@ -37,7 +37,7 @@ GrandPrixData::GrandPrixData(const std::string filename) throw(std::logic_error)
XMLNode* root = file_manager->createXMLTree(file_manager->getDataDir()+filename);
if (!root)
{
fprintf(stderr, "/!\\ Error while trying to read grandprix file '%s'\n", filename.c_str());
Log::error("GrandPrixData","Error while trying to read grandprix file '%s'\n", filename.c_str());
throw std::logic_error("File not found");
}
@ -48,7 +48,7 @@ GrandPrixData::GrandPrixData(const std::string filename) throw(std::logic_error)
std::string temp_name;
if (root->get("name", &temp_name) == 0)
{
fprintf(stderr, "/!\\ Error while trying to read grandprix file '%s' : "
Log::error("GrandPrixData", "Error while trying to read grandprix file '%s' : "
"missing 'name' attribute\n", filename.c_str());
delete root;
throw std::logic_error("File contents are incomplete or corrupt");
@ -58,7 +58,7 @@ GrandPrixData::GrandPrixData(const std::string filename) throw(std::logic_error)
}
else
{
fprintf(stderr, "/!\\ Error while trying to read grandprix file '%s' : "
Log::error("GrandPrixData", "Error while trying to read grandprix file '%s' : "
"Root node has an unexpected name\n", filename.c_str());
delete root;
throw std::logic_error("File contents are incomplete or corrupt");
@ -84,7 +84,7 @@ GrandPrixData::GrandPrixData(const std::string filename) throw(std::logic_error)
if (!idFound || !lapFound)
{
fprintf(stderr, "/!\\ Error while trying to read grandprix file '%s' : "
Log::error("GrandPrixData", "Error while trying to read grandprix file '%s' : "
"<track> tag does not have idi and laps reverse attributes. \n",
filename.c_str());
delete root;
@ -118,7 +118,7 @@ GrandPrixData::GrandPrixData(const std::string filename) throw(std::logic_error)
// sanity checks
if (!foundName)
{
fprintf(stderr, "/!\\ Error while trying to read grandprix file '%s' : "
Log::error("GrandPrixData", "Error while trying to read grandprix file '%s' : "
"missing 'name' attribute\n", filename.c_str());
throw std::logic_error("File contents are incomplete or corrupt");
}
@ -135,9 +135,9 @@ bool GrandPrixData::checkConsistency(bool chatty) const
{
if (chatty)
{
fprintf(stderr, "Grand Prix '%ls': Track '%s' does not exist!\n",
Log::error("GrandPrixData", "Grand Prix '%ls': Track '%s' does not exist!\n",
m_name.c_str(), m_tracks[i].c_str());
fprintf(stderr, "This Grand Prix will not be available.\n");
Log::error("GrandPrixData", "This Grand Prix will not be available.\n");
}
return false;
}

View File

@ -61,7 +61,7 @@ void GrandPrixManager::load(const std::string& filename)
}
catch (std::logic_error& er)
{
fprintf(stderr, "GrandPrixManager : ignoring GP %s ( %s ) \n", filename.c_str(), er.what());
Log::error("GrandPrixManager", "Ignoring GP %s ( %s ) \n", filename.c_str(), er.what());
}
} // load

View File

@ -75,7 +75,7 @@ void HighscoreManager::loadHighscores()
saveHighscores();
if(m_can_write)
{
fprintf(stderr, "New highscore file '%s' created.\n",
Log::error("Highscore Manager", "New highscore file '%s' created.\n",
m_filename.c_str());
}
delete root;
@ -95,8 +95,7 @@ void HighscoreManager::loadHighscores()
int v;
if (!root->get("version", &v) || v<(int)CURRENT_HSCORE_FILE_VERSION)
{
fprintf(stderr,
"Highscore file format too old, a new one will be created.\n");
Log::error("Highscore Manager", "Highscore file format too old, a new one will be created.\n");
irr::core::stringw warning =
_("The highscore file was too old,\nall highscores have been erased.");
user_config->setWarning( warning );
@ -120,23 +119,23 @@ void HighscoreManager::loadHighscores()
}
catch (std::logic_error& e)
{
fprintf(stderr, "Invalid highscore entry will be skipped : %s\n", e.what());
Log::error("Highscore Manager", "Invalid highscore entry will be skipped : %s\n", e.what());
continue;
}
m_all_scores.push_back(highscores);
} // next entry
if(UserConfigParams::logMisc())
fprintf(stderr, "Highscores will be saved in '%s'.\n",
Log::error("Highscore Manager", "Highscores will be saved in '%s'.\n",
m_filename.c_str());
}
catch(std::exception& err)
{
fprintf(stderr, "Error while parsing highscore file '%s':\n",
Log::error("Highscore Manager", "Error while parsing highscore file '%s':\n",
m_filename.c_str());
fprintf(stderr, "%s", err.what());
fprintf(stderr, "\n");
fprintf(stderr, "No old highscores will be available.\n");
Log::error("Highscore Manager", "%s", err.what());
Log::error("Highscore Manager", "\n");
Log::error("Highscore Manager", "No old highscores will be available.\n");
}
if(root)
delete root;
@ -163,7 +162,7 @@ void HighscoreManager::saveHighscores()
}
catch(std::exception &e)
{
printf("Problems saving highscores in '%s'\n", m_filename.c_str());
Log::error("Highscore Manager","Problems saving highscores in '%s'\n", m_filename.c_str());
puts(e.what());
m_can_write=false;
}

View File

@ -112,8 +112,8 @@ void RaceManager::setDefaultAIKartList(const std::vector<std::string>& ai_list)
const KartProperties *kp = kart_properties_manager->getKart(name);
if(!kp)
{
printf("Kart '%s' is unknown and therefore ignored.\n",
name.c_str());
Log::warn("RaceManager", "Kart '%s' is unknown and therefore ignored.",
name.c_str());
continue;
}
// This doesn't work anymore, since this is called when
@ -311,7 +311,7 @@ void RaceManager::startNew(bool from_overworld)
init_gp_rank ++;
if(UserConfigParams::m_ftl_debug)
{
printf("[ftl] rank %d ai-kart %s\n", init_gp_rank,
Log::debug("RaceManager", "[ftl] rank %d ai-kart %s", init_gp_rank,
m_ai_kart_list[i].c_str());
}
}
@ -329,7 +329,7 @@ void RaceManager::startNew(bool from_overworld)
) );
if(UserConfigParams::m_ftl_debug)
{
printf("[ftl] rank %d kart %s\n", init_gp_rank,
Log::debug("RaceManager", "[ftl] rank %d kart %s", init_gp_rank,
m_player_karts[i].getKartName().c_str());
}
init_gp_rank ++;
@ -338,6 +338,7 @@ void RaceManager::startNew(bool from_overworld)
// Then start the race with the first track
// ========================================
m_track_number = 0;
startNextRace();
} // startNew
@ -417,7 +418,7 @@ void RaceManager::startNextRace()
World::setWorld(new EasterEggHunt());
else
{
fprintf(stderr,"Could not create given race mode\n");
Log::error("RaceManager", "Could not create given race mode.");
assert(0);
}
@ -448,7 +449,7 @@ void RaceManager::startNextRace()
//-----------------------------------------------------------------------------
void RaceManager::next()
{
{
World::deleteWorld();
m_num_finished_karts = 0;
m_num_finished_players = 0;
@ -529,9 +530,9 @@ void RaceManager::computeGPRanks()
m_kart_status[0].m_gp_rank = -1;
if(UserConfigParams::m_ftl_debug)
{
printf("[ftl] kart '%s' has position %d.\n",
World::getWorld()->getKart(0)->getIdent().c_str(),
sd->m_position);
Log::debug("Race Manager","[ftl] kart '%s' has position %d.",
World::getWorld()->getKart(0)->getIdent().c_str(),
sd->m_position);
}
}
for (unsigned int kart_id = start; kart_id < NUM_KARTS; ++kart_id)
@ -543,7 +544,7 @@ void RaceManager::computeGPRanks()
sort_data.push_back(sd);
if(UserConfigParams::m_ftl_debug)
{
printf("[ftl] kart '%s' has position %d score %d.\n",
Log::debug("Race Manager","[ftl] kart '%s' has position %d score %d.",
World::getWorld()->getKart(kart_id)->getIdent().c_str(),
sd->m_position, sd->m_score);
}
@ -552,20 +553,17 @@ void RaceManager::computeGPRanks()
sort_data.insertionSort(start);
for (unsigned int i=start; i < NUM_KARTS; ++i)
{
//printf("setting kart %s to rank %i\n",
// m_kart_status[position[i]].m_ident.c_str(), i-start);
if(UserConfigParams::m_ftl_debug)
{
const AbstractKart *kart =
World::getWorld()->getKart(sort_data[i].m_position);
printf("[ftl] kart '%s' has now position %d.\n",
Log::debug("Race Manager","[ftl] kart '%s' has now position %d.",
kart->getIdent().c_str(),
i-start);
}
m_kart_status[sort_data[i].m_position].m_gp_rank = i - start;
}
// printf("kart %s has rank %i\n", 0, m_kart_status[0].m_gp_rank);
} // computeGPRanks
//-----------------------------------------------------------------------------
@ -579,7 +577,6 @@ void RaceManager::exitRace(bool delete_world)
unlock_manager->getCurrentSlot()->grandPrixFinished();
StateManager::get()->resetAndGoToScreen( MainMenuScreen::getInstance() );
bool someHumanPlayerWon = false;
const unsigned int kartStatusCount = m_kart_status.size();