Merge pull request #36 from KroArtem/master

Clean src/modes and src/karts from old logging code
This commit is contained in:
auriamg 2014-02-07 18:36:54 -05:00
commit 3fdae349b2
32 changed files with 232 additions and 240 deletions

View File

@ -194,7 +194,7 @@ void AddonsManager::initAddons(const XMLNode *xml)
if(file_manager->fileExists(full_path)) if(file_manager->fileExists(full_path))
{ {
if(UserConfigParams::logAddons()) if(UserConfigParams::logAddons())
Log::warn("[addons] Removing cached icon '%s'.\n", Log::warn("[AddonsManager] Removing cached icon '%s'.\n",
addon.getIconBasename().c_str()); addon.getIconBasename().c_str());
file_manager->removeFile(full_path); file_manager->removeFile(full_path);
} }
@ -225,10 +225,9 @@ void AddonsManager::initAddons(const XMLNode *xml)
} }
else else
{ {
fprintf(stderr, Log::error("[AddonsManager]", "Found invalid node '%s' while downloading addons.",
"[addons] Found invalid node '%s' while downloading addons.\n",
node->getName().c_str()); node->getName().c_str());
fprintf(stderr, "[addons] Ignored.\n"); Log::error("[AddonsManager]", "Ignored.");
} }
} // for i<xml->getNumNodes } // for i<xml->getNumNodes
delete xml; delete xml;
@ -254,7 +253,7 @@ void AddonsManager::initAddons(const XMLNode *xml)
// it from the list. // it from the list.
if(UserConfigParams::logAddons()) if(UserConfigParams::logAddons())
Log::warn( Log::warn(
"[addons] Removing '%s' which is not on the server anymore.\n", "[AddonsManager] Removing '%s' which is not on the server anymore.\n",
m_addons_list.getData()[i].getId().c_str() ); m_addons_list.getData()[i].getId().c_str() );
std::string icon = m_addons_list.getData()[i].getIconBasename(); std::string icon = m_addons_list.getData()[i].getIconBasename();
std::string icon_file =file_manager->getAddonsFile("icons/"+icon); std::string icon_file =file_manager->getAddonsFile("icons/"+icon);
@ -311,7 +310,7 @@ void AddonsManager::checkInstalledAddons()
if(n<0) continue; if(n<0) continue;
if(!m_addons_list.getData()[n].isInstalled()) if(!m_addons_list.getData()[n].isInstalled())
{ {
Log::info("[addons] Marking '%s' as being installed.", Log::info("[AddonsManager] Marking '%s' as being installed.",
kp->getIdent().c_str()); kp->getIdent().c_str());
m_addons_list.getData()[n].setInstalled(true); m_addons_list.getData()[n].setInstalled(true);
something_was_changed = true; something_was_changed = true;
@ -330,7 +329,7 @@ void AddonsManager::checkInstalledAddons()
if(n<0) continue; if(n<0) continue;
if(!m_addons_list.getData()[n].isInstalled()) if(!m_addons_list.getData()[n].isInstalled())
{ {
Log::info("[addons] Marking '%s' as being installed.", Log::info("[AddonsManager] Marking '%s' as being installed.",
track->getIdent().c_str()); track->getIdent().c_str());
m_addons_list.getData()[n].setInstalled(true); m_addons_list.getData()[n].setInstalled(true);
something_was_changed = true; something_was_changed = true;
@ -361,9 +360,8 @@ void AddonsManager::downloadIcons()
if(icon=="") if(icon=="")
{ {
if(UserConfigParams::logAddons()) if(UserConfigParams::logAddons())
fprintf(stderr, Log::error("[AddonsManager]", "No icon or image specified for '%s'.",
"[addons] No icon or image specified for '%s'.\n", addon.getId().c_str());
addon.getId().c_str());
continue; continue;
} }
@ -401,8 +399,8 @@ void AddonsManager::loadInstalledAddons()
/* checking for installed addons */ /* checking for installed addons */
if(UserConfigParams::logAddons()) if(UserConfigParams::logAddons())
{ {
std::cout << "[addons] Loading an xml file for installed addons: "; Log::info("[AddonsManager]", "Loading an xml file for installed addons: %s",
std::cout << m_file_installed << std::endl; m_file_installed.c_str());
} }
const XMLNode *xml = file_manager->createXMLTree(m_file_installed); const XMLNode *xml = file_manager->createXMLTree(m_file_installed);
if(!xml) if(!xml)
@ -479,16 +477,16 @@ bool AddonsManager::install(const Addon &addon)
if (!success) if (!success)
{ {
// TODO: show a message in the interface // TODO: show a message in the interface
std::cerr << "[addons] Failed to unzip '" << from << "' to '" Log::error("[AddonsManager]", "Failed to unzip '%s' to '%s'",
<< to << "'\n"; from.c_str(), to.c_str());
std::cerr << "[addons] Zip file will not be removed.\n"; Log::error("[AddonsManager]", "Zip file will not be removed.");
return false; return false;
} }
if(!file_manager->removeFile(from)) if(!file_manager->removeFile(from))
{ {
std::cerr << "[addons] Problems removing temporary file '" Log::error("[AddonsManager]", "Problems removing temporary file '%s'",
<< from << "'.\n"; from.c_str());
} }
int index = getAddonIndex(addon.getId()); int index = getAddonIndex(addon.getId());
@ -521,8 +519,8 @@ bool AddonsManager::install(const Addon &addon)
} }
catch (std::exception& e) catch (std::exception& e)
{ {
fprintf(stderr, "[AddonsManager] ERROR: Cannot load track <%s> : %s\n", Log::error("[AddonsManager]", "ERROR: Cannot load track <%s> : %s",
addon.getDataDir().c_str(), e.what()); addon.getDataDir().c_str(), e.what());
} }
} }
saveInstalled(); saveInstalled();
@ -536,8 +534,8 @@ bool AddonsManager::install(const Addon &addon)
*/ */
bool AddonsManager::uninstall(const Addon &addon) bool AddonsManager::uninstall(const Addon &addon)
{ {
std::cout << "[addons] Uninstalling <" Log::info("[AddonsManager]", "Uninstalling <%s>",
<< core::stringc(addon.getName()).c_str() << ">\n"; core::stringc(addon.getName()).c_str());
// addon is a const reference, and to avoid removing the const, we // addon is a const reference, and to avoid removing the const, we
// find the proper index again to modify the installed state // find the proper index again to modify the installed state

View File

@ -208,10 +208,8 @@ void NewsManager::checkRedirect(const XMLNode *xml)
{ {
if(UserConfigParams::logAddons()) if(UserConfigParams::logAddons())
{ {
std::cout << "[Addons] Current server: " Log::info("[Addons]", "Current server: '%s'\n [Addons] New server: '%s'",
<< (std::string)UserConfigParams::m_server_addons UserConfigParams::m_server_addons.c_str(), new_server.c_str());
<< std::endl
<< "[Addons] New server: " << new_server << std::endl;
} }
UserConfigParams::m_server_addons = new_server; UserConfigParams::m_server_addons = new_server;
} }

View File

@ -64,7 +64,7 @@ std::vector<std::string> FileManager::m_root_dirs;
bool macSetBundlePathIfRelevant(std::string& data_dir) bool macSetBundlePathIfRelevant(std::string& data_dir)
{ {
Log::debug("FileManager", "Checking whether we are using an app bundle... "); Log::debug("[FileManager]", "Checking whether we are using an app bundle... ");
// the following code will enable STK to find its data when placed in an // the following code will enable STK to find its data when placed in an
// app bundle on mac OS X. // app bundle on mac OS X.
// returns true if path is set, returns false if path was not set // returns true if path is set, returns false if path was not set
@ -82,14 +82,14 @@ bool macSetBundlePathIfRelevant(std::string& data_dir)
std::string contents = std::string(path) + std::string("/Contents"); std::string contents = std::string(path) + std::string("/Contents");
if(contents.find(".app") != std::string::npos) if(contents.find(".app") != std::string::npos)
{ {
Log::debug("FileManager", "yes\n"); Log::debug("[FileManager]", "yes");
// executable is inside an app bundle, use app bundle-relative paths // executable is inside an app bundle, use app bundle-relative paths
data_dir = contents + std::string("/Resources/"); data_dir = contents + std::string("/Resources/");
return true; return true;
} }
else else
{ {
Log::debug("FileManager", "no\n"); Log::debug("[FileManager]", "no");
return false; return false;
} }
} }
@ -197,13 +197,13 @@ FileManager::FileManager()
// We can't use _() here, since translations will only be initalised // We can't use _() here, since translations will only be initalised
// after the filemanager (to get the path to the tranlsations from it) // after the filemanager (to get the path to the tranlsations from it)
for(unsigned int i=0; i<m_root_dirs.size(); i++) for(unsigned int i=0; i<m_root_dirs.size(); i++)
Log::info("FileManager", "Data files will be fetched from: '%s'", Log::info("[FileManager]", "Data files will be fetched from: '%s'",
m_root_dirs[i].c_str()); m_root_dirs[i].c_str());
Log::info("FileManager", "User directory is '%s'.", Log::info("[FileManager]", "User directory is '%s'.",
m_user_config_dir.c_str()); m_user_config_dir.c_str());
Log::info("FileManager", "Addons files will be stored in '%s'.", Log::info("[FileManager]", "Addons files will be stored in '%s'.",
m_addons_dir.c_str()); m_addons_dir.c_str());
Log::info("FileManager", "Screenshots will be stored in '%s'.", Log::info("[FileManager]", "Screenshots will be stored in '%s'.",
m_screenshot_dir.c_str()); m_screenshot_dir.c_str());
/** Now search for the path to all needed subdirectories. */ /** Now search for the path to all needed subdirectories. */
@ -232,16 +232,16 @@ FileManager::FileManager()
{ {
if(!dir_found[i]) if(!dir_found[i])
{ {
Log::warn("FileManager", "Directory '%s' not found, aborting.", Log::warn("[FileManager]", "Directory '%s' not found, aborting.",
m_subdir_name[i].c_str()); m_subdir_name[i].c_str());
was_error = true; was_error = true;
} }
else else
Log::info("FileManager", "Asset %d will be loaded from '%s'.", Log::info("[FileManager]", "Asset %d will be loaded from '%s'.",
i, m_subdir_name[i].c_str()); i, m_subdir_name[i].c_str());
} }
if(was_error) if(was_error)
Log::fatal("FileManager", "Not all assets found - aborting."); Log::fatal("[FileManager]", "Not all assets found - aborting.");
} // FileManager } // FileManager
@ -307,14 +307,14 @@ FileManager::~FileManager()
if(StringUtils::getExtension(*i)!="zip" && if(StringUtils::getExtension(*i)!="zip" &&
StringUtils::getExtension(*i)!="part" ) StringUtils::getExtension(*i)!="part" )
{ {
Log::warn("FileManager", "Unexpected tmp file '%s' found.", Log::warn("[FileManager]", "Unexpected tmp file '%s' found.",
full_path.c_str()); full_path.c_str());
continue; continue;
} }
if(isDirectory(full_path)) if(isDirectory(full_path))
{ {
// Gee, a .zip file which is a directory - stay away from it // Gee, a .zip file which is a directory - stay away from it
Log::warn("FileManager", "'%s' is a directory and will not be deleted.", Log::warn("[FileManager]", "'%s' is a directory and will not be deleted.",
full_path.c_str()); full_path.c_str());
continue; continue;
} }
@ -324,13 +324,13 @@ FileManager::~FileManager()
if(current - mystat.st_ctime <24*3600) if(current - mystat.st_ctime <24*3600)
{ {
if(UserConfigParams::logAddons()) if(UserConfigParams::logAddons())
Log::verbose("FileManager", "'%s' is less than 24h old " Log::verbose("[FileManager]", "'%s' is less than 24h old "
"and will not be deleted.", "and will not be deleted.",
full_path.c_str()); full_path.c_str());
continue; continue;
} }
if(UserConfigParams::logAddons()) if(UserConfigParams::logAddons())
Log::verbose("FileManager", "Deleting tmp file'%s'.",full_path.c_str()); Log::verbose("[FileManager]", "Deleting tmp file'%s'.",full_path.c_str());
removeFile(full_path); removeFile(full_path);
} // for i in all files in tmp } // for i in all files in tmp
@ -380,7 +380,7 @@ XMLNode *FileManager::createXMLTree(const std::string &filename)
{ {
if (UserConfigParams::logMisc()) if (UserConfigParams::logMisc())
{ {
Log::error("FileManager", "createXMLTree: %s\n", e.what()); Log::error("[FileManager]", "createXMLTree: %s", e.what());
} }
return NULL; return NULL;
} }
@ -406,7 +406,7 @@ XMLNode *FileManager::createXMLTreeFromString(const std::string & content)
{ {
if (UserConfigParams::logMisc()) if (UserConfigParams::logMisc())
{ {
Log::error("FileManager", "createXMLTreeFromString: %s\n", e.what()); Log::error("[FileManager]", "createXMLTreeFromString: %s", e.what());
} }
return NULL; return NULL;
} }
@ -532,7 +532,7 @@ std::string FileManager::getAssetChecked(FileManager::AssetType type,
if(abort_on_error) if(abort_on_error)
{ {
Log::fatal("FileManager", "Can not find file '%s' in '%s'", Log::fatal("[FileManager]", "Can not find file '%s' in '%s'",
name.c_str(), m_subdir_name[type].c_str()); name.c_str(), m_subdir_name[type].c_str());
} }
return ""; return "";
@ -636,20 +636,20 @@ bool FileManager::checkAndCreateDirectoryP(const std::string &path)
if(m_file_system->existFile(io::path(path.c_str()))) if(m_file_system->existFile(io::path(path.c_str())))
return true; return true;
std::cout << "[FileManager] Creating directory(ies) '" << path << "'.\n"; Log::info("[FileManager]", "Creating directory(ies) '%s'", path.c_str());
std::vector<std::string> split = StringUtils::split(path,'/'); std::vector<std::string> split = StringUtils::split(path,'/');
std::string current_path = ""; std::string current_path = "";
for (unsigned int i=0; i<split.size(); i++) for (unsigned int i=0; i<split.size(); i++)
{ {
current_path += split[i] + "/"; current_path += split[i] + "/";
std::cout << "[FileManager] Checking for: '" Log::info("[FileManager]", "Checking for: '%s",
<< current_path << "'.\n"; current_path.c_str());
if (!m_file_system->existFile(io::path(current_path.c_str()))) if (!m_file_system->existFile(io::path(current_path.c_str())))
{ {
if (!checkAndCreateDirectory(current_path)) if (!checkAndCreateDirectory(current_path))
{ {
Log::error("FileManager", "Can't create dir '%s'", Log::error("[FileManager]", "Can't create dir '%s'",
current_path.c_str()); current_path.c_str());
break; break;
} }
@ -684,8 +684,8 @@ void FileManager::checkAndCreateConfigDir()
m_user_config_dir = getenv("APPDATA"); m_user_config_dir = getenv("APPDATA");
if(!checkAndCreateDirectory(m_user_config_dir)) if(!checkAndCreateDirectory(m_user_config_dir))
{ {
std::cerr << "[FileManager] Can't create config dir '" Log::error("[FileManager]", "Can't create config dir '%s"
<< m_user_config_dir << "', falling back to '.'.\n"; ", falling back to '.'.", m_user_config_dir);
m_user_config_dir = "."; m_user_config_dir = ".";
} }
} }
@ -702,8 +702,8 @@ void FileManager::checkAndCreateConfigDir()
} }
else else
{ {
std::cerr << Log::error("[FileManager]",
"[FileManager] No home directory, this should NOT happen!\n"; "No home directory, this should NOT happen!");
// Fall back to system-wide app data (rather than // Fall back to system-wide app data (rather than
// user-specific data), but should not happen anyway. // user-specific data), but should not happen anyway.
m_user_config_dir = ""; m_user_config_dir = "";
@ -721,9 +721,9 @@ void FileManager::checkAndCreateConfigDir()
} }
else if (!getenv("HOME")) else if (!getenv("HOME"))
{ {
std::cerr Log::error("[FileManager]",
<< "[FileManager] No home directory, this should NOT happen " "No home directory, this should NOT happen "
<< "- trying '.' for config files!\n"; "- trying '.' for config files!");
m_user_config_dir = "."; m_user_config_dir = ".";
} }
else else
@ -733,9 +733,9 @@ void FileManager::checkAndCreateConfigDir()
if(!checkAndCreateDirectory(m_user_config_dir)) if(!checkAndCreateDirectory(m_user_config_dir))
{ {
// If $HOME/.config can not be created: // If $HOME/.config can not be created:
std::cerr << "[FileManager] Cannot create directory '" Log::error("[FileManager]",
<< m_user_config_dir <<"', falling back to use '" "Cannot create directory '%s', falling back to use '%s'",
<< getenv("HOME")<< "'.\n"; m_user_config_dir.c_str(), getenv("HOME"));
m_user_config_dir = getenv("HOME"); m_user_config_dir = getenv("HOME");
} }
} }

View File

@ -56,8 +56,8 @@ XMLNode::XMLNode(const std::string &filename)
{ {
if(!is_first_element) if(!is_first_element)
{ {
fprintf(stderr, Log::warn("[XMLNode]",
"More than one root element in '%s' - ignored.\n", "More than one root element in '%s' - ignored.",
filename.c_str()); filename.c_str());
} }
readXML(xml); readXML(xml);
@ -223,8 +223,8 @@ int XMLNode::get(const std::string &attribute, Vec3 *value) const
std::vector<std::string> v = StringUtils::split(s,' '); std::vector<std::string> v = StringUtils::split(s,' ');
if (v.size() != 3) if (v.size() != 3)
{ {
fprintf(stderr, "[XMLNode] WARNING: Expected 3 floating-point values, but found '%s' in file %s\n", Log::warn("[XMLNode]", "WARNING: Expected 3 floating-point values, but found '%s' in file %s",
s.c_str(), m_file_name.c_str()); s.c_str(), m_file_name.c_str());
return 0; return 0;
} }
@ -240,8 +240,8 @@ int XMLNode::get(const std::string &attribute, Vec3 *value) const
} }
else else
{ {
fprintf(stderr, "[XMLNode] WARNING: Expected 3 floating-point values, but found '%s' in file %s\n", Log::warn("[XMLNode]", "WARNING: Expected 3 floating-point values, but found '%s' in file %s",
s.c_str(), m_file_name.c_str()); s.c_str(), m_file_name.c_str());
return 0; return 0;
} }
@ -305,8 +305,8 @@ int XMLNode::get(const std::string &attribute, int32_t *value) const
if (!StringUtils::parseString<int>(s, value)) if (!StringUtils::parseString<int>(s, value))
{ {
fprintf(stderr, "[XMLNode] WARNING: Expected int but found '%s' for attribute '%s' of node '%s' in file %s\n", Log::warn("[XMLNode]", "WARNING: Expected int but found '%s' for attribute '%s' of node '%s' in file %s",
s.c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str()); s.c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str());
return 0; return 0;
} }
@ -321,8 +321,8 @@ int XMLNode::get(const std::string &attribute, int64_t *value) const
if (!StringUtils::parseString<int64_t>(s, value)) if (!StringUtils::parseString<int64_t>(s, value))
{ {
fprintf(stderr, "[XMLNode] WARNING: Expected int but found '%s' for attribute '%s' of node '%s' in file %s\n", Log::warn("[XMLNode]", "WARNING: Expected int but found '%s' for attribute '%s' of node '%s' in file %s",
s.c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str()); s.c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str());
return 0; return 0;
} }
@ -338,8 +338,8 @@ int XMLNode::get(const std::string &attribute, uint16_t *value) const
if (!StringUtils::parseString<uint16_t>(s, value)) if (!StringUtils::parseString<uint16_t>(s, value))
{ {
fprintf(stderr, "[XMLNode] WARNING: Expected uint but found '%s' for attribute '%s' of node '%s' in file %s\n", Log::warn("[XMLNode]", "WARNING: Expected uint but found '%s' for attribute '%s' of node '%s' in file %s",
s.c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str()); s.c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str());
return 0; return 0;
} }
@ -354,8 +354,8 @@ int XMLNode::get(const std::string &attribute, uint32_t *value) const
if (!StringUtils::parseString<unsigned int>(s, value)) if (!StringUtils::parseString<unsigned int>(s, value))
{ {
fprintf(stderr, "[XMLNode] WARNING: Expected uint but found '%s' for attribute '%s' of node '%s' in file %s\n", Log::warn("[XMLNode]", "WARNING: Expected uint but found '%s' for attribute '%s' of node '%s' in file %s",
s.c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str()); s.c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str());
return 0; return 0;
} }
@ -370,8 +370,8 @@ int XMLNode::get(const std::string &attribute, float *value) const
if (!StringUtils::parseString<float>(s, value)) if (!StringUtils::parseString<float>(s, value))
{ {
fprintf(stderr, "[XMLNode] WARNING: Expected float but found '%s' for attribute '%s' of node '%s' in file %s\n", Log::warn("[XMLNode]", "WARNING: Expected float but found '%s' for attribute '%s' of node '%s' in file %s",
s.c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str()); s.c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str());
return 0; return 0;
} }
@ -429,8 +429,8 @@ int XMLNode::get(const std::string &attribute,
float curr; float curr;
if (!StringUtils::parseString<float>(v[i], &curr)) if (!StringUtils::parseString<float>(v[i], &curr))
{ {
fprintf(stderr, "[XMLNode] WARNING: Expected float but found '%s' for attribute '%s' of node '%s' in file %s\n", Log::warn("[XMLNode]", "WARNING: Expected float but found '%s' for attribute '%s' of node '%s' in file %s",
v[i].c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str()); v[i].c_str(), attribute.c_str(), m_name.c_str(), m_file_name.c_str());
return 0; return 0;
} }
@ -460,8 +460,8 @@ int XMLNode::get(const std::string &attribute, std::vector<int> *value) const
int val; int val;
if (!StringUtils::parseString<int>(v[i], &val)) if (!StringUtils::parseString<int>(v[i], &val))
{ {
fprintf(stderr, "[XMLNode] WARNING: Expected int but found '%s' for attribute '%s' of node '%s'\n", Log::warn("[XMLNode]", "WARNING: Expected int but found '%s' for attribute '%s' of node '%s'",
v[i].c_str(), attribute.c_str(), m_name.c_str()); v[i].c_str(), attribute.c_str(), m_name.c_str());
return 0; return 0;
} }
@ -490,22 +490,22 @@ int XMLNode::get(const std::string &attribute, InterpolationArray *value) const
std::vector<std::string> pair = StringUtils::split(pairs[i],':'); std::vector<std::string> pair = StringUtils::split(pairs[i],':');
if(pair.size()!=2) if(pair.size()!=2)
{ {
printf("Incorrect interpolation pair '%s' in '%s'.\n", Log::fatal("[XMLNode]", "Incorrect interpolation pair '%s' in '%s'.",
pairs[i].c_str(), attribute.c_str()); pairs[i].c_str(), attribute.c_str());
printf("Must be x:y.\n"); Log::fatal("[XMLNode]", "Must be x:y.");
exit(-1); exit(-1);
} }
float x; float x;
if(!StringUtils::fromString(pair[0], x)) if(!StringUtils::fromString(pair[0], x))
{ {
printf("Incorrect x in pair '%s' of '%s'.\n", Log::fatal("[XMLNode]", "Incorrect x in pair '%s' of '%s'.",
pairs[i].c_str(), attribute.c_str()); pairs[i].c_str(), attribute.c_str());
exit(-1); exit(-1);
} }
float y; float y;
if(!StringUtils::fromString(pair[1], y)) if(!StringUtils::fromString(pair[1], y))
{ {
printf("Incorrect y in pair '%s' in '%s'.\n", Log::fatal("[XMLNode]", "Incorrect y in pair '%s' in '%s'.",
pair[1].c_str(), attribute.c_str()); pair[1].c_str(), attribute.c_str());
exit(-1); exit(-1);
} }

View File

@ -39,7 +39,6 @@
#include "physics/triangle_mesh.hpp" #include "physics/triangle_mesh.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
#include "utils/constants.hpp" #include "utils/constants.hpp"
#include "utils/log.hpp"
/** Initialises the attachment each kart has. /** Initialises the attachment each kart has.
*/ */

View File

@ -143,9 +143,9 @@ void Flyable::createPhysics(float forw_offset, const Vec3 &velocity,
// Just to get some additional information if the assert is triggered // Just to get some additional information if the assert is triggered
if(isnan(v.getX()) || isnan(v.getY()) || isnan(v.getZ())) if(isnan(v.getX()) || isnan(v.getY()) || isnan(v.getZ()))
{ {
printf("vel %f %f %f v %f %f %f\n", Log::debug("[Flyable]", "vel %f %f %f v %f %f %f",
velocity.getX(),velocity.getY(),velocity.getZ(), velocity.getX(),velocity.getY(),velocity.getZ(),
v.getX(),v.getY(),v.getZ()); v.getX(),v.getY(),v.getZ());
} }
#endif #endif
assert(!isnan(v.getX())); assert(!isnan(v.getX()));

View File

@ -97,8 +97,8 @@ void ItemManager::loadDefaultItemMeshes()
scene::IMesh *mesh = irr_driver->getAnimatedMesh(model_filename); scene::IMesh *mesh = irr_driver->getAnimatedMesh(model_filename);
if(!node || model_filename.size()==0 || !mesh) if(!node || model_filename.size()==0 || !mesh)
{ {
fprintf(stderr, "Item model '%s' in items.xml could not be loaded " Log::fatal("[ItemManager]", "Item model '%s' in items.xml could not be loaded "
"- aborting", name.c_str()); "- aborting", name.c_str());
exit(-1); exit(-1);
} }
mesh->grab(); mesh->grab();

View File

@ -34,8 +34,6 @@
#include "utils/constants.hpp" #include "utils/constants.hpp"
#include "utils/string_utils.hpp" #include "utils/string_utils.hpp"
#include "utils/log.hpp" //TODO: remove after debugging is done
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
Plunger::Plunger(AbstractKart *kart) Plunger::Plunger(AbstractKart *kart)
: Flyable(kart, PowerupManager::POWERUP_PLUNGER) : Flyable(kart, PowerupManager::POWERUP_PLUNGER)

View File

@ -125,8 +125,8 @@ void PowerupManager::loadAllPowerups()
LoadPowerup(type, *node); LoadPowerup(type, *node);
else else
{ {
printf("Can't find item '%s' from powerup.xml, entry %d/\n", Log::fatal("[PowerupManager]", "Can't find item '%s' from powerup.xml, entry %d/",
name.c_str(), i+1); name.c_str(), i+1);
exit(-1); exit(-1);
} }
} }
@ -157,7 +157,7 @@ void PowerupManager::LoadPowerup(PowerupType type, const XMLNode &node)
#ifdef DEBUG #ifdef DEBUG
if (icon_file.size() == 0) if (icon_file.size() == 0)
{ {
fprintf(stderr, "Cannot load powerup %i, no 'icon' attribute under XML node\n", type); Log::debug("[PowerupManager]", "Cannot load powerup %i, no 'icon' attribute under XML node", type);
assert(false); assert(false);
} }
#endif #endif
@ -221,8 +221,9 @@ void PowerupManager::loadWeights(const XMLNode &root,
if(!node || s=="" || s_multi=="") if(!node || s=="" || s_multi=="")
{ {
printf("No weights found for class '%s' - probabilities will be incorrect.\n", Log::error("[PowerupManager]", "No weights found for class '%s'"
class_name.c_str()); " - probabilities will be incorrect.",
class_name.c_str());
return; return;
} }
@ -245,9 +246,9 @@ void PowerupManager::loadWeights(const XMLNode &root,
if(weight_list.size()!=2*(int)POWERUP_LAST) if(weight_list.size()!=2*(int)POWERUP_LAST)
{ {
printf("Incorrect number of weights found in class '%s':\n", Log::error("[PowerupManager]", "Incorrect number of weights found in class '%s':",
class_name.c_str()); class_name.c_str());
printf("%d instead of %d - probabilities will be incorrect.\n", Log::error("[PowerupManager]", "%d instead of %d - probabilities will be incorrect.",
(int)weight_list.size(), (int)POWERUP_LAST); (int)weight_list.size(), (int)POWERUP_LAST);
return; return;
} }

View File

@ -158,7 +158,7 @@ void RubberBall::computeTarget()
if(m_target==m_owner && m_delete_timer < 0) if(m_target==m_owner && m_delete_timer < 0)
{ {
#ifdef PRINT_BALL_REMOVE_INFO #ifdef PRINT_BALL_REMOVE_INFO
Log::debug("RubberBall", Log::debug("[RubberBall]",
"ball %d removed because owner is target.", m_id); "ball %d removed because owner is target.", m_id);
#endif #endif
m_delete_timer = m_st_delete_time; m_delete_timer = m_st_delete_time;
@ -171,7 +171,7 @@ void RubberBall::computeTarget()
// aim at the owner (the ball is unlikely to hit it), and // aim at the owner (the ball is unlikely to hit it), and
// this will trigger the usage of the delete time in updateAndDelete // this will trigger the usage of the delete time in updateAndDelete
#ifdef PRINT_BALL_REMOVE_INFO #ifdef PRINT_BALL_REMOVE_INFO
Log::debug("RubberBall" "ball %d removed because no more active target.", Log::debug("[RubberBall]" "ball %d removed because no more active target.",
m_id); m_id);
#endif #endif
m_delete_timer = m_st_delete_time; m_delete_timer = m_st_delete_time;
@ -312,7 +312,7 @@ bool RubberBall::updateAndDelete(float dt)
{ {
hit(NULL); hit(NULL);
#ifdef PRINT_BALL_REMOVE_INFO #ifdef PRINT_BALL_REMOVE_INFO
Log::debug("RubberBall", "ball %d deleted.", m_id); Log::debug("[RubberBall]", "ball %d deleted.", m_id);
#endif #endif
return true; return true;
} }
@ -355,7 +355,7 @@ bool RubberBall::updateAndDelete(float dt)
float new_y = getHoT()+height; float new_y = getHoT()+height;
if(UserConfigParams::logFlyable()) if(UserConfigParams::logFlyable())
printf("ball %d: %f %f %f height %f new_y %f gethot %f ", Log::debug("[RubberBall]", "ball %d: %f %f %f height %f new_y %f gethot %f ",
m_id, next_xyz.getX(), next_xyz.getY(), next_xyz.getZ(), height, new_y, getHoT()); m_id, next_xyz.getX(), next_xyz.getY(), next_xyz.getZ(), height, new_y, getHoT());
// No need to check for terrain height if the ball is low to the ground // No need to check for terrain height if the ball is low to the ground
@ -503,7 +503,7 @@ bool RubberBall::checkTunneling()
if(m_tunnel_count > 3) if(m_tunnel_count > 3)
{ {
#ifdef PRINT_BALL_REMOVE_INFO #ifdef PRINT_BALL_REMOVE_INFO
Log::debug("RubberBall", Log::debug("[RubberBall]",
"Ball %d nearly tunneled at %f %f %f -> %f %f %f", "Ball %d nearly tunneled at %f %f %f -> %f %f %f",
m_id, m_previous_xyz.getX(),m_previous_xyz.getY(), m_id, m_previous_xyz.getX(),m_previous_xyz.getY(),
m_previous_xyz.getZ(), m_previous_xyz.getZ(),
@ -627,7 +627,7 @@ void RubberBall::updateDistanceToTarget()
m_distance_to_target += world->getTrack()->getTrackLength(); m_distance_to_target += world->getTrack()->getTrackLength();
} }
if(UserConfigParams::logFlyable()) if(UserConfigParams::logFlyable())
printf("ball %d: target %f %f %f distance_2_target %f", Log::debug("[RubberBall]", "ball %d: target %f %f %f distance_2_target %f",
m_id, m_target->getXYZ().getX(),m_target->getXYZ().getY(), m_id, m_target->getXYZ().getX(),m_target->getXYZ().getY(),
m_target->getXYZ().getZ(),m_distance_to_target m_target->getXYZ().getZ(),m_distance_to_target
); );
@ -657,7 +657,7 @@ void RubberBall::updateDistanceToTarget()
{ {
m_delete_timer = m_st_delete_time; m_delete_timer = m_st_delete_time;
#ifdef PRINT_BALL_REMOVE_INFO #ifdef PRINT_BALL_REMOVE_INFO
Log::debug("RubberBall", "ball %d lost target (overtook?).", Log::debug("[RubberBall]", "ball %d lost target (overtook?).",
m_id); m_id);
#endif #endif
@ -690,7 +690,7 @@ bool RubberBall::hit(AbstractKart* kart, PhysicalObject* object)
{ {
#ifdef PRINT_BALL_REMOVE_INFO #ifdef PRINT_BALL_REMOVE_INFO
if(kart) if(kart)
Log::debug("RuberBall", "ball %d hit kart.", m_id); Log::debug("[RuberBall]", "ball %d hit kart.", m_id);
#endif #endif
if(kart && kart!=m_target) if(kart && kart!=m_target)
{ {

View File

@ -111,7 +111,7 @@ void AbstractKart::setKartAnimation(AbstractKartAnimation *ka)
ka->getName().c_str()); ka->getName().c_str());
else Log::debug("Abstract_Kart", "Setting kart animation to NULL."); else Log::debug("Abstract_Kart", "Setting kart animation to NULL.");
if(m_kart_animation) Log::info("Abstract_Kart", "Current kart" if(m_kart_animation) Log::info("Abstract_Kart", "Current kart"
"animation is '%s'.\n", "animation is '%s'.",
m_kart_animation->getName().c_str()); m_kart_animation->getName().c_str());
else Log::debug("Abstract_Kart", "Current kart animation is NULL."); else Log::debug("Abstract_Kart", "Current kart animation is NULL.");
} }

View File

@ -85,7 +85,7 @@ void AIProperties::load(const XMLNode *ai_node)
else else
{ {
Log::fatal("AIProperties", Log::fatal("AIProperties",
"Incorrect nitro-usage '%s' in AI '%s'.\n",s.c_str(), "Incorrect nitro-usage '%s' in AI '%s'.",s.c_str(),
m_ident.c_str()); m_ident.c_str());
} }
// We actually need the square of the distance later // We actually need the square of the distance later
@ -102,7 +102,7 @@ void AIProperties::checkAllSet(const std::string &filename) const
{ {
#define CHECK_NEG( a,str_a) if(a<=UNDEFINED) { \ #define CHECK_NEG( a,str_a) if(a<=UNDEFINED) { \
Log::fatal("AIProperties","Missing default value for" \ Log::fatal("AIProperties","Missing default value for" \
" '%s' in '%s' 'for AI '%s'.\n", \ " '%s' in '%s' 'for AI '%s'.", \
str_a, filename.c_str(), m_ident.c_str()); \ str_a, filename.c_str(), m_ident.c_str()); \
} }
CHECK_NEG(m_max_item_angle, "max-item-angle" ); CHECK_NEG(m_max_item_angle, "max-item-angle" );
@ -118,17 +118,17 @@ void AIProperties::checkAllSet(const std::string &filename) const
if(m_skid_probability.size()==0) if(m_skid_probability.size()==0)
{ {
Log::fatal("AIProperties", "No skid probability defined.\n"); Log::fatal("AIProperties", "No skid probability defined.");
} }
if(m_speed_cap.size()==0) if(m_speed_cap.size()==0)
{ {
Log::fatal("AIProperties", "No speed cap defined.\n"); Log::fatal("AIProperties", "No speed cap defined.");
} }
if(m_collect_item_probability.size()==0) if(m_collect_item_probability.size()==0)
{ {
Log::fatal("AIProperties", "No collect-item-probability defined.\n"); Log::fatal("AIProperties", "No collect-item-probability defined.");
} }
} // checkAllSet } // checkAllSet

View File

@ -218,7 +218,7 @@ void EndController::handleSteering(float dt)
const int next = m_next_node_index[m_track_node]; const int next = m_next_node_index[m_track_node];
target_point = QuadGraph::get()->getQuadOfNode(next).getCenter(); target_point = QuadGraph::get()->getQuadOfNode(next).getCenter();
#ifdef AI_DEBUG #ifdef AI_DEBUG
Log::debug("end_controller.cpp", "- Outside of road: steer to center point.\n"); Log::debug("end_controller.cpp", "- Outside of road: steer to center point.");
#endif #endif
} }
else else

View File

@ -255,7 +255,7 @@ void NetworkPlayerController::update(float dt)
{ {
// Print a dividing line so that it's easier to see which events // Print a dividing line so that it's easier to see which events
// get received in which order in the one frame. // get received in which order in the one frame.
Log::debug("PlayerController", "irr_driver", "-------------------------------------\n"); Log::debug("PlayerController", "irr_driver", "-------------------------------------");
} }
// Don't do steering if it's replay. In position only replay it doesn't // Don't do steering if it's replay. In position only replay it doesn't

View File

@ -311,7 +311,7 @@ void PlayerController::update(float dt)
{ {
// Print a dividing line so that it's easier to see which events // Print a dividing line so that it's easier to see which events
// get received in which order in the one frame. // get received in which order in the one frame.
Log::debug("PlayerController", "irr_driver", "-------------------------------------\n"); Log::debug("PlayerController", "irr_driver", "-------------------------------------");
} }
// Don't do steering if it's replay. In position only replay it doesn't // Don't do steering if it's replay. In position only replay it doesn't

View File

@ -198,7 +198,7 @@ void SkiddingAI::reset()
{ {
Log::error("SkiddingAI", Log::error("SkiddingAI",
"Invalid starting position for '%s' - not on track" "Invalid starting position for '%s' - not on track"
" - can be ignored.\n", " - can be ignored.",
m_kart->getIdent().c_str()); m_kart->getIdent().c_str());
m_track_node = QuadGraph::get()->findOutOfRoadSector(m_kart->getXYZ()); m_track_node = QuadGraph::get()->findOutOfRoadSector(m_kart->getXYZ());
} }
@ -401,7 +401,7 @@ void SkiddingAI::handleBraking()
{ {
#ifdef DEBUG #ifdef DEBUG
if(m_ai_debug) if(m_ai_debug)
Log::debug("SkiddingAI", "braking: %s ahead of leader.\n", Log::debug("SkiddingAI", "braking: %s ahead of leader.",
m_kart->getIdent().c_str()); m_kart->getIdent().c_str());
#endif #endif
@ -421,7 +421,7 @@ void SkiddingAI::handleBraking()
{ {
#ifdef DEBUG #ifdef DEBUG
if(m_ai_debug) if(m_ai_debug)
Log::debug("SkiddingAI", "%s not aligned with track.\n", Log::debug("SkiddingAI", "%s not aligned with track.",
m_kart->getIdent().c_str()); m_kart->getIdent().c_str());
#endif #endif
m_controls->m_brake = true; m_controls->m_brake = true;
@ -486,7 +486,7 @@ void SkiddingAI::handleSteering(float dt)
#ifdef AI_DEBUG #ifdef AI_DEBUG
m_debug_sphere[0]->setPosition(QuadGraph::get()->getQuadOfNode(next) m_debug_sphere[0]->setPosition(QuadGraph::get()->getQuadOfNode(next)
.getCenter().toIrrVector()); .getCenter().toIrrVector());
Log::debug("skidding_ai","-Outside of road: steer to center point.\n"); Log::debug("skidding_ai","-Outside of road: steer to center point.");
#endif #endif
} }
//If we are going to crash against a kart, avoid it if it doesn't //If we are going to crash against a kart, avoid it if it doesn't
@ -522,7 +522,7 @@ void SkiddingAI::handleSteering(float dt)
#ifdef AI_DEBUG #ifdef AI_DEBUG
Log::debug("skidding_ai", "- Velocity vector crashes with kart " Log::debug("skidding_ai", "- Velocity vector crashes with kart "
"and doesn't crashes with road : steer 90 " "and doesn't crashes with road : steer 90 "
"degrees away from kart.\n"); "degrees away from kart.");
#endif #endif
} }
@ -701,7 +701,7 @@ void SkiddingAI::handleItemCollectionAndAvoidance(Vec3 *aim_point,
} }
if(m_ai_debug) if(m_ai_debug)
Log::debug("SkiddingAI", "%s unselects item.\n", Log::debug("SkiddingAI", "%s unselects item.",
m_kart->getIdent().c_str()); m_kart->getIdent().c_str());
// Otherwise remove the pre-selected item (and start // Otherwise remove the pre-selected item (and start
// looking for a new item). // looking for a new item).
@ -771,7 +771,7 @@ void SkiddingAI::handleItemCollectionAndAvoidance(Vec3 *aim_point,
.toIrrVector()); .toIrrVector());
#endif #endif
if(m_ai_debug) if(m_ai_debug)
Log::debug("SkiddingAI", "%s selects item type '%d'.\n", Log::debug("SkiddingAI", "%s selects item type '%d'.",
m_kart->getIdent().c_str(), m_kart->getIdent().c_str(),
item_to_collect->getType()); item_to_collect->getType());
m_item_to_collect = item_to_collect; m_item_to_collect = item_to_collect;
@ -795,7 +795,7 @@ void SkiddingAI::handleItemCollectionAndAvoidance(Vec3 *aim_point,
#endif #endif
if(m_ai_debug) if(m_ai_debug)
Log::debug("SkiddingAI", Log::debug("SkiddingAI",
"%s adjusts to hit type %d angle %f.\n", "%s adjusts to hit type %d angle %f.",
m_kart->getIdent().c_str(), m_kart->getIdent().c_str(),
item_to_collect->getType(), angle); item_to_collect->getType(), angle);
} }
@ -803,7 +803,7 @@ void SkiddingAI::handleItemCollectionAndAvoidance(Vec3 *aim_point,
{ {
if(m_ai_debug) if(m_ai_debug)
Log::debug("SkiddingAI", Log::debug("SkiddingAI",
"%s won't hit '%d', angle %f.\n", "%s won't hit '%d', angle %f.",
m_kart->getIdent().c_str(), m_kart->getIdent().c_str(),
item_to_collect->getType(), angle); item_to_collect->getType(), angle);
} }
@ -1378,7 +1378,7 @@ void SkiddingAI::handleItems(const float dt)
break; break;
default: default:
Log::error("SkiddingAI", Log::error("SkiddingAI",
"Invalid or unhandled powerup '%d' in default AI.\n", "Invalid or unhandled powerup '%d' in default AI.",
m_kart->getPowerup()->getType()); m_kart->getPowerup()->getType());
assert(false); assert(false);
} }
@ -1699,7 +1699,7 @@ void SkiddingAI::checkCrashes(const Vec3& pos )
if(steps<1 || steps>1000) if(steps<1 || steps>1000)
{ {
Log::warn("SkiddingAI", Log::warn("SkiddingAI",
"Incorrect STEPS=%d. kart_length %f velocity %f\n", "Incorrect STEPS=%d. kart_length %f velocity %f",
steps, m_kart_length, m_kart->getVelocityLC().getZ()); steps, m_kart_length, m_kart->getVelocityLC().getZ());
steps=1000; steps=1000;
} }
@ -2181,7 +2181,7 @@ bool SkiddingAI::doSkid(float steer_fraction)
if(m_ai_debug) if(m_ai_debug)
{ {
if(fabsf(steer_fraction)>=2.5f) if(fabsf(steer_fraction)>=2.5f)
Log::debug("SkiddingAI", "%s stops skidding (%f).\n", Log::debug("SkiddingAI", "%s stops skidding (%f).",
m_kart->getIdent().c_str(), steer_fraction); m_kart->getIdent().c_str(), steer_fraction);
} }
#endif #endif
@ -2201,7 +2201,7 @@ bool SkiddingAI::doSkid(float steer_fraction)
#ifdef DEBUG #ifdef DEBUG
if(m_controls->m_skid && m_ai_debug) if(m_controls->m_skid && m_ai_debug)
{ {
Log::debug("SkiddingAI", "%s stops skidding on straight.\n", Log::debug("SkiddingAI", "%s stops skidding on straight.",
m_kart->getIdent().c_str()); m_kart->getIdent().c_str());
} }
#endif #endif
@ -2238,7 +2238,7 @@ bool SkiddingAI::doSkid(float steer_fraction)
if(m_controls->m_skid && duration < 1.0f) if(m_controls->m_skid && duration < 1.0f)
{ {
if(m_ai_debug) if(m_ai_debug)
Log::debug("SkiddingAI", "'%s' too short, stop skid.\n", Log::debug("SkiddingAI", "'%s' too short, stop skid.",
m_kart->getIdent().c_str()); m_kart->getIdent().c_str());
return false; return false;
} }
@ -2254,7 +2254,7 @@ bool SkiddingAI::doSkid(float steer_fraction)
#ifdef DEBUG #ifdef DEBUG
if(m_controls->m_skid && m_ai_debug) if(m_controls->m_skid && m_ai_debug)
Log::debug("SkiddingAI", Log::debug("SkiddingAI",
"%s skidding against track direction.\n", "%s skidding against track direction.",
m_kart->getIdent().c_str()); m_kart->getIdent().c_str());
#endif #endif
return false; return false;
@ -2265,7 +2265,7 @@ bool SkiddingAI::doSkid(float steer_fraction)
{ {
#ifdef DEBUG #ifdef DEBUG
if(!m_controls->m_skid && m_ai_debug) if(!m_controls->m_skid && m_ai_debug)
Log::debug("SkiddingAI", "%s start skid, duration %f.\n", Log::debug("SkiddingAI", "%s start skid, duration %f.",
m_kart->getIdent().c_str(), duration); m_kart->getIdent().c_str(), duration);
#endif #endif
return true; return true;
@ -2274,7 +2274,7 @@ bool SkiddingAI::doSkid(float steer_fraction)
#ifdef DEBUG #ifdef DEBUG
if(m_controls->m_skid && m_ai_debug) if(m_controls->m_skid && m_ai_debug)
Log::debug("SkiddingAI", "%s has no reasons to skid anymore.\n", Log::debug("SkiddingAI", "%s has no reasons to skid anymore.",
m_kart->getIdent().c_str()); m_kart->getIdent().c_str());
#endif #endif
return false; return false;

View File

@ -26,7 +26,6 @@
#include "karts/kart_properties.hpp" #include "karts/kart_properties.hpp"
#include "modes/world.hpp" #include "modes/world.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
#include "utils/log.hpp" //TODO: remove after debugging is done
/** A static create function that does only create an explosion if /** A static create function that does only create an explosion if
* the explosion happens to be close enough to affect the kart. * the explosion happens to be close enough to affect the kart.

View File

@ -198,7 +198,7 @@ void Kart::init(RaceManager::KartType type)
if(!m_engine_sound) if(!m_engine_sound)
{ {
Log::error("Kart","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!");
} }
@ -256,7 +256,7 @@ Kart::~Kart()
if(m_slipstream) delete m_slipstream; if(m_slipstream) delete m_slipstream;
if(m_sky_particles_emitter) delete m_sky_particles_emitter; if(m_sky_particles_emitter) delete m_sky_particles_emitter;
if(m_attachment) delete m_attachment; if(m_attachment) delete m_attachment;
if (m_stars_effect) delete m_stars_effect; if(m_stars_effect) delete m_stars_effect;
delete m_shadow; delete m_shadow;

View File

@ -27,6 +27,7 @@
#include "karts/kart_properties.hpp" #include "karts/kart_properties.hpp"
#include "karts/skidding.hpp" #include "karts/skidding.hpp"
#include "physics/btKart.hpp" #include "physics/btKart.hpp"
#include "utils/log.hpp"
#include <iostream> #include <iostream>
@ -122,7 +123,7 @@ void KartGFX::addEffect(KartGFXType type, const std::string &file_name,
// by adding a NULL to the list (which is tested for in all // by adding a NULL to the list (which is tested for in all
// cases). C++ guarantees that all memory allocated in the // cases). C++ guarantees that all memory allocated in the
// constructor is properly freed. // constructor is properly freed.
std::cerr << e.what() << std::endl; Log::error("[KartGFX]", "%s",e.what());
kind = NULL; kind = NULL;
emitter = NULL; emitter = NULL;
} }

View File

@ -201,9 +201,9 @@ void KartProperties::load(const std::string &filename, const std::string &node)
} }
catch(std::exception& err) catch(std::exception& err)
{ {
Log::error("KartProperties", "Error while parsing KartProperties '%s':\n", Log::error("[KartProperties]", "Error while parsing KartProperties '%s':",
filename.c_str()); filename.c_str());
Log::error("KartProperties", "%s\n", err.what()); Log::error("[KartProperties]", "%s", err.what());
} }
if(root) delete root; if(root) delete root;
@ -392,15 +392,15 @@ void KartProperties::getAllData(const XMLNode * root)
engine_node->get("power", &m_engine_power); engine_node->get("power", &m_engine_power);
if(m_engine_power.size()!=RaceManager::DIFFICULTY_COUNT) if(m_engine_power.size()!=RaceManager::DIFFICULTY_COUNT)
{ {
Log::fatal("KartProperties", Log::fatal("[KartProperties]",
"Incorrect engine-power specifications for kart '%s'\n", "Incorrect engine-power specifications for kart '%s'",
getIdent().c_str()); getIdent().c_str());
} }
engine_node->get("max-speed", &m_max_speed); engine_node->get("max-speed", &m_max_speed);
if(m_max_speed.size()!=RaceManager::DIFFICULTY_COUNT) if(m_max_speed.size()!=RaceManager::DIFFICULTY_COUNT)
{ {
Log::fatal("KartProperties", Log::fatal("[KartProperties]",
"Incorrect max-speed specifications for kart '%s'\n", "Incorrect max-speed specifications for kart '%s'",
getIdent().c_str()); getIdent().c_str());
} }
} // if getNode("engine") } // if getNode("engine")
@ -477,8 +477,8 @@ void KartProperties::getAllData(const XMLNode * root)
m_terrain_impulse_type = IMPULSE_TO_DRIVELINE; m_terrain_impulse_type = IMPULSE_TO_DRIVELINE;
else else
{ {
Log::fatal("KartProperties", Log::fatal("[KartProperties]",
"Missing or incorrect value for impulse-type: '%s'.\n", "Missing or incorrect value for impulse-type: '%s'.",
s.c_str()); s.c_str());
} }
} }
@ -560,7 +560,7 @@ void KartProperties::getAllData(const XMLNode * root)
else if (s == "small") m_engine_sfx_type = "engine_small"; else if (s == "small") m_engine_sfx_type = "engine_small";
else else
{ {
Log::warn("KartProperties", "Kart '%s' has invalid engine '%s'.", Log::warn("[KartProperties]", "Kart '%s' has invalid engine '%s'.",
m_name.c_str(), s.c_str()); m_name.c_str(), s.c_str());
m_engine_sfx_type = "engine_small"; m_engine_sfx_type = "engine_small";
} }
@ -603,32 +603,32 @@ void KartProperties::checkAllSet(const std::string &filename)
{ {
if(m_gear_switch_ratio.size()==0) if(m_gear_switch_ratio.size()==0)
{ {
Log::fatal("KartProperties", Log::fatal("[KartProperties]",
"Missing default value for 'gear-switch-ratio' in '%s'.\n", "Missing default value for 'gear-switch-ratio' in '%s'.",
filename.c_str()); filename.c_str());
} }
if(m_gear_power_increase.size()==0) if(m_gear_power_increase.size()==0)
{ {
Log::fatal("KartProperties", Log::fatal("[KartProperties]",
"Missing default value for 'gear-power-increase' in '%s'.\n", "Missing default value for 'gear-power-increase' in '%s'.",
filename.c_str()); filename.c_str());
} }
if(m_gear_switch_ratio.size()!=m_gear_power_increase.size()) { if(m_gear_switch_ratio.size()!=m_gear_power_increase.size()) {
Log::error("KartProperties", Log::error("KartProperties",
"Number of entries for 'gear-switch-ratio' and " "Number of entries for 'gear-switch-ratio' and "
"'gear-power-increase\n"); "'gear-power-increase");
Log::fatal("KartProperties", "in '%s' must be equal.\n", Log::fatal("KartProperties", "in '%s' must be equal.",
filename.c_str()); filename.c_str());
} }
if(m_startup_boost.size()!=m_startup_times.size()) if(m_startup_boost.size()!=m_startup_times.size())
{ {
Log::error("KartProperties", Log::error("[KartProperties]",
"Number of entried for 'startup times' and 'startup-boost\n"); "Number of entried for 'startup times' and 'startup-boost");
Log::fatal("KartProperties", "must be identical.\n"); Log::fatal("KartProperties", "must be identical.");
} }
#define CHECK_NEG( a,strA) if(a<=UNDEFINED) { \ #define CHECK_NEG( a,strA) if(a<=UNDEFINED) { \
Log::fatal("KartProperties", \ Log::fatal("[KartProperties]", \
"Missing default value for '%s' in '%s'.\n", \ "Missing default value for '%s' in '%s'.", \
strA,filename.c_str()); \ strA,filename.c_str()); \
} }

View File

@ -189,8 +189,8 @@ bool KartPropertiesManager::loadKart(const std::string &dir)
} }
catch (std::runtime_error& err) catch (std::runtime_error& err)
{ {
std::cerr << "Giving up loading '" << config_filename.c_str() Log::error("[Kart_Properties_Manager]","Giving up loading '%s': %s",
<< "' : " << err.what() << std::endl; config_filename.c_str(), err.what());
return false; return false;
} }
@ -199,7 +199,7 @@ bool KartPropertiesManager::loadKart(const std::string &dir)
if (kart_properties->getVersion() < stk_config->m_min_kart_version || if (kart_properties->getVersion() < stk_config->m_min_kart_version ||
kart_properties->getVersion() > stk_config->m_max_kart_version) kart_properties->getVersion() > stk_config->m_max_kart_version)
{ {
Log::warn("Kart_Properties_Manager", "Warning: kart '%s' is not " Log::warn("[Kart_Properties_Manager]", "Warning: kart '%s' is not "
"supported by this binary, ignored.", "supported by this binary, ignored.",
kart_properties->getIdent().c_str()); kart_properties->getIdent().c_str());
delete kart_properties; delete kart_properties;
@ -304,7 +304,7 @@ void KartPropertiesManager::setUnavailableKarts(std::vector<std::string> karts)
{ {
m_kart_available[i] = false; m_kart_available[i] = false;
Log::error("Kart_Properties_Manager", Log::error("[Kart_Properties_Manager]",
"Kart '%s' not available on all clients, disabled.", "Kart '%s' not available on all clients, disabled.",
m_karts_properties[i].getIdent().c_str()); m_karts_properties[i].getIdent().c_str());
} // kart not in list } // kart not in list
@ -425,10 +425,8 @@ void KartPropertiesManager::getRandomKartList(int count,
catch (std::runtime_error& ex) catch (std::runtime_error& ex)
{ {
(void)ex; (void)ex;
std::cerr << Log::error("[KartPropertiesManager]", "getRandomKartList : WARNING, "
"[KartPropertiesManager] getRandomKartList : WARNING, " "can't find kart '%s'", existing_karts[i].getKartName().c_str());
"can't find kart '"
<< existing_karts[i].getKartName() << "'\n";
} }
} }
for(unsigned int i=0; i<ai_list->size(); i++) for(unsigned int i=0; i<ai_list->size(); i++)
@ -441,10 +439,8 @@ void KartPropertiesManager::getRandomKartList(int count,
catch (std::runtime_error &ex) catch (std::runtime_error &ex)
{ {
(void)ex; (void)ex;
std::cerr << Log::error("[KartPropertiesManager]", "getRandomKartList : WARNING, "
"[KartPropertiesManager] getRandomKartList : WARNING, " "can't find kart '%s'",(*ai_list)[i].c_str());
"can't find kart '"
<< (*ai_list)[i] << "'\n";
} }
} }

View File

@ -95,7 +95,7 @@ void CutsceneWorld::init()
if (!StringUtils::fromString(frameStr, frame)) if (!StringUtils::fromString(frameStr, frame))
{ {
fprintf(stderr, "[CutsceneWorld] Invalid condition '%s'\n", Log::error("[CutsceneWorld]", "Invalid condition '%s'",
condition.c_str()); condition.c_str());
continue; continue;
} }
@ -115,7 +115,7 @@ void CutsceneWorld::init()
if (!StringUtils::fromString(frameStr, frame)) if (!StringUtils::fromString(frameStr, frame))
{ {
fprintf(stderr, "[CutsceneWorld] Invalid condition '%s'\n", Log::error("[CutsceneWorld]", "Invalid condition '%s'",
condition.c_str()); condition.c_str());
continue; continue;
} }
@ -130,7 +130,7 @@ void CutsceneWorld::init()
if (!StringUtils::fromString(frameStr, frame)) if (!StringUtils::fromString(frameStr, frame))
{ {
fprintf(stderr, "[CutsceneWorld] Invalid condition '%s'\n", Log::error("[CutsceneWorld]", "Invalid condition '%s'",
condition.c_str()); condition.c_str());
continue; continue;
} }
@ -150,7 +150,7 @@ void CutsceneWorld::init()
if (m_duration <= 0.0f) if (m_duration <= 0.0f)
{ {
fprintf(stderr, "[CutsceneWorld] WARNING: cutscene has no duration\n"); Log::error("[CutsceneWorld]", "WARNING: cutscene has no duration");
} }
} // CutsceneWorld } // CutsceneWorld

View File

@ -119,7 +119,7 @@ bool DemoWorld::updateIdleTimeAndStartDemo(float dt)
&& m_demo_tracks.size() > 0) && m_demo_tracks.size() > 0)
{ {
if(!track) if(!track)
printf("Invalid demo track identifier '%s'.\n", Log::warn("[DemoWorld]", "Invalid demo track identifier '%s'.",
m_demo_tracks[0].c_str()); m_demo_tracks[0].c_str());
m_demo_tracks.erase(m_demo_tracks.begin()); m_demo_tracks.erase(m_demo_tracks.begin());
track = track_manager->getTrack(m_demo_tracks[0]); track = track_manager->getTrack(m_demo_tracks[0]);
@ -129,7 +129,7 @@ bool DemoWorld::updateIdleTimeAndStartDemo(float dt)
// be filled up with all the tracks. // be filled up with all the tracks.
if(m_demo_tracks.size()==0) if(m_demo_tracks.size()==0)
{ {
printf("No valid tracks found, no demo started.\n"); Log::warn("[DemoWorld]", "No valid tracks found, no demo started.");
return false; return false;
} }

View File

@ -42,7 +42,7 @@ void EasterEggHunt::init()
// check for possible problems if AI karts were incorrectly added // check for possible problems if AI karts were incorrectly added
if(getNumKarts() > race_manager->getNumPlayers()) if(getNumKarts() > race_manager->getNumPlayers())
{ {
fprintf(stderr, "No AI exists for this game mode\n"); Log::error("EasterEggHunt]", "No AI exists for this game mode");
exit(1); exit(1);
} }
@ -70,7 +70,7 @@ void EasterEggHunt::readData(const std::string &filename)
if(easter->getName()!="EasterEggHunt") if(easter->getName()!="EasterEggHunt")
{ {
printf("Can't load easter egg file '%s' - no EasterEggHunt element.", Log::error("[EasterEggHunt]", "Can't load easter egg file '%s' - no EasterEggHunt element.",
filename.c_str()); filename.c_str());
delete easter; delete easter;
return; return;
@ -121,7 +121,7 @@ void EasterEggHunt::readData(const std::string &filename)
const XMLNode *egg = data->getNode(i); const XMLNode *egg = data->getNode(i);
if(egg->getName()!="easter-egg") if(egg->getName()!="easter-egg")
{ {
printf("Unknown node '%s' in easter egg level '%s' - ignored.\n", Log::warn("[EasterEggHunt]", "Unknown node '%s' in easter egg level '%s' - ignored.",
egg->getName().c_str(), egg->getName().c_str(),
race_manager->getDifficultyAsString(act_difficulty).c_str()); race_manager->getDifficultyAsString(act_difficulty).c_str());
continue; continue;

View File

@ -108,19 +108,19 @@ void FollowTheLeaderRace::countdownReachedZero()
AbstractKart *kart = getKartAtPosition(position_to_remove); AbstractKart *kart = getKartAtPosition(position_to_remove);
if(!kart || kart->isEliminated()) if(!kart || kart->isEliminated())
{ {
fprintf(stderr,"Problem with removing leader: position %d not found\n", Log::error("[FTL]", "Problem with removing leader: position %d not found",
position_to_remove); position_to_remove);
for(unsigned int i=0; i<m_karts.size(); i++) for(unsigned int i=0; i<m_karts.size(); i++)
{ {
fprintf(stderr,"kart %d: eliminated %d position %d\n", Log::error("[FTL]", "kart %u: eliminated %d position %d",
i,m_karts[i]->isEliminated(), m_karts[i]->getPosition()); i, m_karts[i]->isEliminated(), m_karts[i]->getPosition());
} // for i } // for i
} // } //
else else
{ {
if(UserConfigParams::m_ftl_debug) if(UserConfigParams::m_ftl_debug)
{ {
printf("[ftl] Eliminiating kart '%s' at position %d.\n", Log::debug("[FTL", "Eliminiating kart '%s' at position %d.",
kart->getIdent().c_str(), position_to_remove); kart->getIdent().c_str(), position_to_remove);
} }
eliminateKart(kart->getWorldKartId()); eliminateKart(kart->getWorldKartId());

View File

@ -208,10 +208,10 @@ void LinearWorld::update(float dt)
{ {
if(pos_used[m_karts[i]->getPosition()]!=-99) if(pos_used[m_karts[i]->getPosition()]!=-99)
{ {
for(unsigned int j =0; j<kart_amount; j++) for(unsigned int j=0; j<kart_amount; j++)
{ {
printf("kart id=%d, position=%d, finished=%d, laps=%d, " Log::verbose("[LinearWorld]", "kart id=%u, position=%d, finished=%d, laps=%d, "
"distanceDownTrack=%f overallDistance=%f %s\n", "distanceDownTrack=%f overallDistance=%f %s",
j, m_karts[j]->getPosition(), j, m_karts[j]->getPosition(),
m_karts[j]->hasFinishedRace(), m_karts[j]->hasFinishedRace(),
m_kart_info[j].m_race_lap, m_kart_info[j].m_race_lap,
@ -553,9 +553,9 @@ float LinearWorld::estimateFinishTimeForKart(AbstractKart* kart)
#ifdef DEBUG #ifdef DEBUG
if(kart_info.m_overall_distance > full_distance) if(kart_info.m_overall_distance > full_distance)
{ {
printf("WARNING: full distance < distance covered for kart '%s':\n", Log::debug("[LinearWorld]", "Full distance < distance covered for kart '%s':",
kart->getIdent().c_str()); kart->getIdent().c_str());
printf("%f < %f\n", full_distance, kart_info.m_overall_distance); Log::debug("[LinearWorld]", "%f < %f", full_distance, kart_info.m_overall_distance);
} }
#endif #endif
// Avoid potential problems (floating point issues, coding bug?) if a // Avoid potential problems (floating point issues, coding bug?) if a
@ -699,29 +699,29 @@ void LinearWorld::updateRacePosition()
rank_changed |= kart->getPosition()!=p; rank_changed |= kart->getPosition()!=p;
if (!setKartPosition(i,p)) if (!setKartPosition(i,p))
{ {
std::cerr << "ERROR, same rank used twice!!\n"; Log::error("[LinearWorld]", "Same rank used twice!!");
std::cerr << "Info used to decide ranking :\n"; Log::debug("[LinearWorld]", "Info used to decide ranking :");
for (unsigned int d=0; d<kart_amount; d++) for (unsigned int d=0; d<kart_amount; d++)
{ {
std::cerr << " kart " << m_karts[d]->getIdent() Log::debug("[LinearWorld]", "Kart %s has finished (%d), is at lap (%u),"
<< " has finished(" << m_karts[d]->hasFinishedRace() "is at distance (%u), is eliminated(%d)",
<< "), is at lap (" << getLapForKart(d) m_karts[d]->getIdent().c_str(),
<< "), is at distance(" m_karts[d]->hasFinishedRace(),
<< m_kart_info[d].m_overall_distance getLapForKart(d),
<< "), is eliminated(" << m_karts[d]->isEliminated() m_kart_info[d].m_overall_distance,
<< ")" << std::endl; m_karts[d]->isEliminated());
} }
std::cerr << "Who has each ranking so far :\n"; Log::debug("[LinearWorld]", "Who has each ranking so far :");
for (unsigned int d=0; d<i; d++) for (unsigned int d=0; d<i; d++)
{ {
std::cerr << " " << m_karts[d]->getIdent() << " has rank " Log::debug("[LinearWorld]", "%s has rank %d", m_karts[d]->getIdent().c_str(),
<< m_karts[d]->getPosition() << std::endl; m_karts[d]->getPosition());
} }
std::cerr << " --> And " << kart->getIdent() Log::debug("[LinearWorld]", " --> And %s is being set at rank %d",
<< " is being set at rank " << p << std::endl; kart->getIdent().c_str(), p);
history->Save(); history->Save();
assert(false); assert(false);
} }
@ -749,17 +749,18 @@ void LinearWorld::updateRacePosition()
#ifdef DEBUG_KART_RANK #ifdef DEBUG_KART_RANK
if(rank_changed) if(rank_changed)
{ {
std::cout << "Counting laps at "<<getTime()<<" seconds.\n"; Log::debug("[LinearWorld]", "Counting laps at %u seconds.", getTime());
for (unsigned int i=0; i<kart_amount; i++) for (unsigned int i=0; i<kart_amount; i++)
{ {
AbstractKart* kart = m_karts[i]; AbstractKart* kart = m_karts[i];
std::cout << "counting karts ahead of " << kart->getIdent() Log::debug("[LinearWorld]", "counting karts ahead of %s (laps %u,"
<< " (laps " << m_kart_info[i].m_race_lap " progress %u, finished %d, eliminated %d, initial position %u.",
<< ", progress " << m_kart_info[i].m_overall_distance kart->getIdent().c_str(),
<< " finished " << kart->hasFinishedRace() m_kart_info[i].m_race_lap,
<< " eliminated " << kart->isEliminated() m_kart_info[i].m_overall_distance,
<< " initial position "<< kart->getInitialPosition() kart->hasFinishedRace(),
<< ").\n"; kart->isEliminated(),
kart->getInitialPosition());
// Karts that are either eliminated or have finished the // Karts that are either eliminated or have finished the
// race already have their (final) position assigned. If // race already have their (final) position assigned. If
// these karts would get their rank updated, it could happen // these karts would get their rank updated, it could happen
@ -776,36 +777,36 @@ void LinearWorld::updateRacePosition()
if(j == my_id) continue; if(j == my_id) continue;
if(m_karts[j]->isEliminated()) if(m_karts[j]->isEliminated())
{ {
std::cout << " " << p << " : " << m_karts[j]->getIdent() Log::debug("[LinearWorld]", " %u: %s because it is eliminated.",
<< " because it is eliminated.\n"; p, m_karts[j]->getIdent().c_str());
continue; continue;
} }
if(!kart->hasFinishedRace() && m_karts[j]->hasFinishedRace()) if(!kart->hasFinishedRace() && m_karts[j]->hasFinishedRace())
{ {
p++; p++;
std::cout << " " << p << " : " << m_karts[j]->getIdent() Log::debug("[LinearWorld]", " %u: %s because it has finished the race.",
<< " because it has finished the race.\n"; p, m_karts[j]->getIdent().c_str());
continue; continue;
} }
if(m_kart_info[j].m_overall_distance > my_distance) if(m_kart_info[j].m_overall_distance > my_distance)
{ {
p++; p++;
std::cout << " " << p << " : " << m_karts[j]->getIdent() Log::debug("[LinearWorld]", " %u: %s because it is ahead %u.",
<< " because it is ahead " p, m_karts[j]->getIdent().c_str(),
<< m_kart_info[j].m_overall_distance <<".\n"; m_kart_info[j].m_overall_distance);
continue; continue;
} }
if(m_kart_info[j].m_overall_distance == my_distance && if(m_kart_info[j].m_overall_distance == my_distance &&
m_karts[j]->getInitialPosition()<kart->getInitialPosition()) m_karts[j]->getInitialPosition()<kart->getInitialPosition())
{ {
p++; p++;
std::cout << " " << p << " : " << m_karts[j]->getIdent() Log::debug("[LinearWorld]"," %u: %s has same distance, but started ahead %d",
<< " has same distance, but started ahead " p, m_karts[j]->getIdent().c_str(),
<< m_karts[j]->getInitialPosition()<<".\n"; m_karts[j]->getInitialPosition());
} }
} // next kart j } // next kart j
} // for i<kart_amount } // for i<kart_amount
std::cout << "-------------------------------------------\n"; Log::debug("LinearWorld]", "-------------------------------------------");
} // if rank_changed } // if rank_changed
#endif #endif
#endif #endif

View File

@ -68,8 +68,8 @@ void OverWorld::enterOverWorld()
if (!kart_properties_manager->getKart(UserConfigParams::m_default_kart)) if (!kart_properties_manager->getKart(UserConfigParams::m_default_kart))
{ {
Log::warn("overworld", "cannot find kart '%s', " Log::warn("[overworld]", "cannot find kart '%s', "
"will revert to default\n", "will revert to default",
UserConfigParams::m_default_kart.c_str()); UserConfigParams::m_default_kart.c_str());
UserConfigParams::m_default_kart.revertToDefaults(); UserConfigParams::m_default_kart.revertToDefaults();

View File

@ -76,7 +76,7 @@ void SoccerWorld::init()
// check for possible problems if AI karts were incorrectly added // check for possible problems if AI karts were incorrectly added
if(getNumKarts() > race_manager->getNumPlayers()) if(getNumKarts() > race_manager->getNumPlayers())
{ {
fprintf(stderr, "No AI exists for this game mode\n"); Log::error("[SoccerWorld]", "No AI exists for this game mode");
exit(1); exit(1);
} }
m_goal_target = race_manager->getMaxGoal(); m_goal_target = race_manager->getMaxGoal();
@ -85,7 +85,7 @@ void SoccerWorld::init()
} // init } // init
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/** Called then a battle is restarted. /** Called when a battle is restarted.
*/ */
void SoccerWorld::reset() void SoccerWorld::reset()
{ {
@ -391,8 +391,8 @@ void SoccerWorld::moveKartAfterRescue(AbstractKart* kart)
} }
else else
{ {
fprintf(stderr, "WARNING: invalid position after rescue for kart %s on track %s.\n", Log::warn("[SoccerWorld]", " Invalid position after rescue for kart %s on track %s.",
(kart->getIdent().c_str()), m_track->getIdent().c_str()); kart->getIdent().c_str(), m_track->getIdent().c_str());
} }
} // moveKartAfterRescue } // moveKartAfterRescue

View File

@ -61,7 +61,7 @@ void ThreeStrikesBattle::init()
// check for possible problems if AI karts were incorrectly added // check for possible problems if AI karts were incorrectly added
if(getNumKarts() > race_manager->getNumPlayers()) if(getNumKarts() > race_manager->getNumPlayers())
{ {
Log::fatal("Three Strikes Battle", "No AI exists for this game mode"); Log::fatal("[Three Strikes Battle]", "No AI exists for this game mode");
} }
m_kart_info.resize(m_karts.size()); m_kart_info.resize(m_karts.size());
} // ThreeStrikesBattle } // ThreeStrikesBattle

View File

@ -332,7 +332,7 @@ Controller* World::loadAIController(AbstractKart *kart)
controller = new SkiddingAI(kart); controller = new SkiddingAI(kart);
break; break;
default: default:
Log::warn("World", "Unknown AI, using default."); Log::warn("[World]", "Unknown AI, using default.");
controller = new SkiddingAI(kart); controller = new SkiddingAI(kart);
break; break;
} }
@ -529,12 +529,12 @@ void World::resetAllKarts()
if (!kart_over_ground) if (!kart_over_ground)
{ {
Log::error("World", Log::error("[World]",
"No valid starting position for kart %d on track %s.", "No valid starting position for kart %d on track %s.",
(int)(i-m_karts.begin()), m_track->getIdent().c_str()); (int)(i-m_karts.begin()), m_track->getIdent().c_str());
if (UserConfigParams::m_artist_debug_mode) if (UserConfigParams::m_artist_debug_mode)
{ {
Log::warn("World", "Activating fly mode."); Log::warn("[World]", "Activating fly mode.");
(*i)->flyUp(); (*i)->flyUp();
continue; continue;
} }
@ -580,14 +580,14 @@ void World::resetAllKarts()
&normal); &normal);
if(!material) if(!material)
{ {
Log::error("World", Log::error("[World]",
"No valid starting position for kart %d " "No valid starting position for kart %d "
"on track %s.", "on track %s.",
(int)(i-m_karts.begin()), (int)(i-m_karts.begin()),
m_track->getIdent().c_str()); m_track->getIdent().c_str());
if (UserConfigParams::m_artist_debug_mode) if (UserConfigParams::m_artist_debug_mode)
{ {
Log::warn("World", "Activating fly mode."); Log::warn("[World]", "Activating fly mode.");
(*i)->flyUp(); (*i)->flyUp();
continue; continue;
} }
@ -755,7 +755,7 @@ void World::updateWorld(float dt)
if (!kart_properties_manager->getKart(UserConfigParams::m_default_kart)) if (!kart_properties_manager->getKart(UserConfigParams::m_default_kart))
{ {
Log::warn("World", Log::warn("[World]",
"Cannot find kart '%s', will revert to default.", "Cannot find kart '%s', will revert to default.",
UserConfigParams::m_default_kart.c_str()); UserConfigParams::m_default_kart.c_str());
UserConfigParams::m_default_kart.revertToDefaults(); UserConfigParams::m_default_kart.revertToDefaults();
@ -930,10 +930,10 @@ void World::updateHighscores(int* best_highscore_rank, int* best_finish_time,
// the kart location data is wrong // the kart location data is wrong
#ifdef DEBUG #ifdef DEBUG
Log::error("World", "Incorrect kart positions:"); Log::error("[World]", "Incorrect kart positions:");
for (unsigned int i=0; i<m_karts.size(); i++ ) for (unsigned int i=0; i<m_karts.size(); i++ )
{ {
Log::error("World", "i=%d position %d.",i, Log::error("[World]", "i=%d position %d.",i,
m_karts[i]->getPosition()); m_karts[i]->getPosition());
} }
#endif #endif

View File

@ -21,6 +21,7 @@
#include "karts/kart_properties.hpp" #include "karts/kart_properties.hpp"
#include "race/history.hpp" #include "race/history.hpp"
#include "tracks/track.hpp" #include "tracks/track.hpp"
#include "utils/log.hpp"
#include <iostream> #include <iostream>
@ -85,22 +86,22 @@ bool WorldWithRank::setKartPosition(unsigned int kart_id,
assert(m_position_setting_initialised); assert(m_position_setting_initialised);
if(m_position_used[position-1]) if(m_position_used[position-1])
{ {
std::cerr << "== TWO KARTS ARE BEING GIVEN THE SAME POSITION!! ==\n"; Log::error("[WorldWithRank]", "== TWO KARTS ARE BEING GIVEN THE SAME POSITION!! ==");
for (unsigned int j=0; j < m_position_index.size(); j++) for (unsigned int j=0; j < m_position_index.size(); j++)
{ {
if (!m_position_used[j]) if (!m_position_used[j])
{ {
std::cout << " No kart is yet set at position " << j+1 Log::warn("WorldWithRank]", "No kart is yet set at position %u", j+1);
<< std::endl;
} }
else else
{ {
std::cout << " Kart " << m_position_index[j] Log::warn("WorldWithRank]", "Kart %u is at position %u",
<< " is at position " << j << std::endl; m_position_index[j], j);
} }
} }
std::cout << "Kart " << kart_id << " is being given position " Log::warn("WorldWithRank]", "Kart %u is being given position %u,"
<< position << ", but this position is already taken\n"; "but this position is already taken",
kart_id, position);
return false; return false;
} }
m_position_used[position-1] = true; m_position_used[position-1] = true;

View File

@ -73,7 +73,7 @@ void* STKHost::receive_data(void* self)
} }
} }
myself->m_listening = false; myself->m_listening = false;
delete myself->m_listening_thread; free(myself->m_listening_thread);
myself->m_listening_thread = NULL; myself->m_listening_thread = NULL;
Log::info("STKHost", "Listening has been stopped"); Log::info("STKHost", "Listening has been stopped");
return NULL; return NULL;