Make fatal fatal
Removes a lot of duplicated code. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12827 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
c06125b392
commit
a6a2ec66d4
@ -82,7 +82,6 @@ void STKConfig::load(const std::string &filename)
|
|||||||
{
|
{
|
||||||
Log::error("StkConfig", "FATAL ERROR while reading '%s':", filename.c_str());
|
Log::error("StkConfig", "FATAL ERROR while reading '%s':", filename.c_str());
|
||||||
Log::fatal("StkConfig", " %s", err.what());
|
Log::fatal("StkConfig", " %s", err.what());
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
delete root;
|
delete root;
|
||||||
|
|
||||||
@ -91,24 +90,21 @@ void STKConfig::load(const std::string &filename)
|
|||||||
|
|
||||||
#define CHECK_NEG( a,strA) if(a<=UNDEFINED) { \
|
#define CHECK_NEG( a,strA) if(a<=UNDEFINED) { \
|
||||||
Log::fatal("StkConfig", "Missing default value for '%s' in '%s'.", \
|
Log::fatal("StkConfig", "Missing default value for '%s' in '%s'.", \
|
||||||
strA,filename.c_str());exit(-1); \
|
strA,filename.c_str()); \
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_score_increase.size()==0 || (int)m_score_increase.size()!=m_max_karts)
|
if(m_score_increase.size()==0 || (int)m_score_increase.size()!=m_max_karts)
|
||||||
{
|
{
|
||||||
Log::fatal("StkConfig", "Not or not enough scores defined in stk_config");
|
Log::fatal("StkConfig", "Not or not enough scores defined in stk_config");
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
if(m_leader_intervals.size()==0)
|
if(m_leader_intervals.size()==0)
|
||||||
{
|
{
|
||||||
Log::fatal("StkConfig", "No follow leader interval(s) defined in stk_config");
|
Log::fatal("StkConfig", "No follow leader interval(s) defined in stk_config");
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_switch_items.size()!=Item::ITEM_LAST-Item::ITEM_FIRST+1)
|
if(m_switch_items.size()!=Item::ITEM_LAST-Item::ITEM_FIRST+1)
|
||||||
{
|
{
|
||||||
Log::fatal("StkConfig", "Wrong number of item switches defined in stk_config");
|
Log::fatal("StkConfig", "Wrong number of item switches defined in stk_config");
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_NEG(m_max_karts, "<karts max=..." );
|
CHECK_NEG(m_max_karts, "<karts max=..." );
|
||||||
@ -228,7 +224,6 @@ void STKConfig::getAllData(const XMLNode * root)
|
|||||||
Log::error("StkConfig", "Incorrect GP point specification:");
|
Log::error("StkConfig", "Incorrect GP point specification:");
|
||||||
Log::fatal("StkConfig", "from: %d to: %d points: %d",
|
Log::fatal("StkConfig", "from: %d to: %d points: %d",
|
||||||
from, to, points);
|
from, to, points);
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
for(int j=from; j<=to; j++)
|
for(int j=from; j<=to; j++)
|
||||||
m_score_increase.push_back(points);
|
m_score_increase.push_back(points);
|
||||||
|
@ -150,7 +150,6 @@ X11::Window get_toplevel_parent(X11::Display* display, X11::Window window)
|
|||||||
&parent, &children, &num_children))
|
&parent, &children, &num_children))
|
||||||
{
|
{
|
||||||
Log::fatal("irr_driver", "XQueryTree error\n");
|
Log::fatal("irr_driver", "XQueryTree error\n");
|
||||||
abort(); //change to whatever error handling you prefer
|
|
||||||
}
|
}
|
||||||
if (children) { //must test for null
|
if (children) { //must test for null
|
||||||
X11::XFree(children);
|
X11::XFree(children);
|
||||||
@ -379,7 +378,6 @@ void IrrDriver::initDevice()
|
|||||||
if(!m_device)
|
if(!m_device)
|
||||||
{
|
{
|
||||||
Log::fatal("irr_driver", "Couldn't initialise irrlicht device. Quitting.\n");
|
Log::fatal("irr_driver", "Couldn't initialise irrlicht device. Quitting.\n");
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_scene_manager = m_device->getSceneManager();
|
m_scene_manager = m_device->getSceneManager();
|
||||||
|
@ -48,19 +48,16 @@ void Referee::init()
|
|||||||
if(filename=="")
|
if(filename=="")
|
||||||
{
|
{
|
||||||
Log::fatal("referee", "Can't find referee.xml, aborting.");
|
Log::fatal("referee", "Can't find referee.xml, aborting.");
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
XMLNode *node = file_manager->createXMLTree(filename);
|
XMLNode *node = file_manager->createXMLTree(filename);
|
||||||
if(!node)
|
if(!node)
|
||||||
{
|
{
|
||||||
Log::fatal("referee", "Can't read XML file referee.xml, aborting.");
|
Log::fatal("referee", "Can't read XML file referee.xml, aborting.");
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
if(node->getName()!="referee")
|
if(node->getName()!="referee")
|
||||||
{
|
{
|
||||||
Log::fatal("referee", "The file referee.xml does not contain a referee"
|
Log::fatal("referee", "The file referee.xml does not contain a referee"
|
||||||
"node, aborting.");
|
"node, aborting.");
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
std::string model_filename;
|
std::string model_filename;
|
||||||
node->get("model", &model_filename);
|
node->get("model", &model_filename);
|
||||||
@ -71,7 +68,6 @@ void Referee::init()
|
|||||||
{
|
{
|
||||||
Log::fatal("referee", "Can't find referee model '%s', aborting.",
|
Log::fatal("referee", "Can't find referee model '%s', aborting.",
|
||||||
model_filename.c_str());
|
model_filename.c_str());
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translate the mesh so that the x/z middle point
|
// Translate the mesh so that the x/z middle point
|
||||||
@ -109,7 +105,6 @@ void Referee::init()
|
|||||||
{
|
{
|
||||||
Log::fatal("referee",
|
Log::fatal("referee",
|
||||||
"Not enough colors for referee defined, aborting.");
|
"Not enough colors for referee defined, aborting.");
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
for(unsigned int i=0; i<3; i++)
|
for(unsigned int i=0; i<3; i++)
|
||||||
{
|
{
|
||||||
@ -119,7 +114,6 @@ void Referee::init()
|
|||||||
Log::fatal("referee",
|
Log::fatal("referee",
|
||||||
"Can't find texture '%s' for referee, aborting.",
|
"Can't find texture '%s' for referee, aborting.",
|
||||||
colors[i].c_str());
|
colors[i].c_str());
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
m_st_traffic_lights[i] = irr_driver->getTexture(full_path);
|
m_st_traffic_lights[i] = irr_driver->getTexture(full_path);
|
||||||
}
|
}
|
||||||
|
@ -82,10 +82,9 @@ void AIProperties::load(const XMLNode *ai_node)
|
|||||||
m_nitro_usage = NITRO_ALL;
|
m_nitro_usage = NITRO_ALL;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log::error("AIProperties",
|
Log::fatal("AIProperties",
|
||||||
"Incorrect nitro-usage '%s' in AI '%s'.\n",s.c_str(),
|
"Incorrect nitro-usage '%s' in AI '%s'.\n",s.c_str(),
|
||||||
m_ident.c_str());
|
m_ident.c_str());
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
// We actually need the square of the distance later
|
// We actually need the square of the distance later
|
||||||
m_bad_item_closeness_2 *= m_bad_item_closeness_2;
|
m_bad_item_closeness_2 *= m_bad_item_closeness_2;
|
||||||
@ -100,10 +99,9 @@ void AIProperties::load(const XMLNode *ai_node)
|
|||||||
void AIProperties::checkAllSet(const std::string &filename) const
|
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::error("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'.\n", \
|
||||||
str_a, filename.c_str(), m_ident.c_str()); \
|
str_a, filename.c_str(), m_ident.c_str()); \
|
||||||
exit(-1); \
|
|
||||||
}
|
}
|
||||||
CHECK_NEG(m_max_item_angle, "max-item-angle" );
|
CHECK_NEG(m_max_item_angle, "max-item-angle" );
|
||||||
CHECK_NEG(m_max_item_angle_high_speed, "max-item-angle-high-speed" );
|
CHECK_NEG(m_max_item_angle_high_speed, "max-item-angle-high-speed" );
|
||||||
@ -117,20 +115,17 @@ void AIProperties::checkAllSet(const std::string &filename) const
|
|||||||
|
|
||||||
if(m_skid_probability.size()==0)
|
if(m_skid_probability.size()==0)
|
||||||
{
|
{
|
||||||
Log::error("AIProperties", "No skid probability defined.\n");
|
Log::fatal("AIProperties", "No skid probability defined.\n");
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_speed_cap.size()==0)
|
if(m_speed_cap.size()==0)
|
||||||
{
|
{
|
||||||
Log::error("AIProperties", "No speed cap defined.\n");
|
Log::fatal("AIProperties", "No speed cap defined.\n");
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_collect_item_probability.size()==0)
|
if(m_collect_item_probability.size()==0)
|
||||||
{
|
{
|
||||||
Log::error("AIProperties", "No collect-item-probability defined.\n");
|
Log::fatal("AIProperties", "No collect-item-probability defined.\n");
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // checkAllSet
|
} // checkAllSet
|
||||||
|
@ -376,7 +376,6 @@ void KartProperties::getAllData(const XMLNode * root)
|
|||||||
Log::fatal("KartProperties",
|
Log::fatal("KartProperties",
|
||||||
"Incorrect engine-power specifications for kart '%s'\n",
|
"Incorrect engine-power specifications for kart '%s'\n",
|
||||||
getIdent().c_str());
|
getIdent().c_str());
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
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)
|
||||||
@ -384,7 +383,6 @@ void KartProperties::getAllData(const XMLNode * root)
|
|||||||
Log::fatal("KartProperties",
|
Log::fatal("KartProperties",
|
||||||
"Incorrect max-speed specifications for kart '%s'\n",
|
"Incorrect max-speed specifications for kart '%s'\n",
|
||||||
getIdent().c_str());
|
getIdent().c_str());
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
} // if getNode("engine")
|
} // if getNode("engine")
|
||||||
|
|
||||||
@ -458,7 +456,6 @@ void KartProperties::getAllData(const XMLNode * root)
|
|||||||
Log::fatal("KartProperties",
|
Log::fatal("KartProperties",
|
||||||
"Missing or incorrect value for impulse-type: '%s'.\n",
|
"Missing or incorrect value for impulse-type: '%s'.\n",
|
||||||
s.c_str());
|
s.c_str());
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,7 +475,6 @@ void KartProperties::getAllData(const XMLNode * root)
|
|||||||
{
|
{
|
||||||
Log::fatal("KartProperties",
|
Log::fatal("KartProperties",
|
||||||
"Invalid plunger in-face-time specification.");
|
"Invalid plunger in-face-time specification.");
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -573,14 +569,12 @@ void KartProperties::checkAllSet(const std::string &filename)
|
|||||||
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'.\n",
|
||||||
filename.c_str());
|
filename.c_str());
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
if(m_gear_power_increase.size()==0)
|
if(m_gear_power_increase.size()==0)
|
||||||
{
|
{
|
||||||
Log::error("KartProperties",
|
Log::fatal("KartProperties",
|
||||||
"Missing default value for 'gear-power-increase' in '%s'.\n",
|
"Missing default value for 'gear-power-increase' in '%s'.\n",
|
||||||
filename.c_str());
|
filename.c_str());
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
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",
|
||||||
@ -588,19 +582,17 @@ void KartProperties::checkAllSet(const std::string &filename)
|
|||||||
"'gear-power-increase\n");
|
"'gear-power-increase\n");
|
||||||
Log::fatal("KartProperties", "in '%s' must be equal.\n",
|
Log::fatal("KartProperties", "in '%s' must be equal.\n",
|
||||||
filename.c_str());
|
filename.c_str());
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
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\n");
|
||||||
Log::fatal("KartProperties", "must be identical.\n");
|
Log::fatal("KartProperties", "must be identical.\n");
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
#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'.\n", \
|
||||||
strA,filename.c_str());exit(-1); \
|
strA,filename.c_str()); \
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_NEG(m_mass, "mass" );
|
CHECK_NEG(m_mass, "mass" );
|
||||||
|
@ -75,9 +75,9 @@ void SkiddingProperties::load(const XMLNode *skid_node)
|
|||||||
void SkiddingProperties::checkAllSet(const std::string &filename) const
|
void SkiddingProperties::checkAllSet(const std::string &filename) const
|
||||||
{
|
{
|
||||||
#define CHECK_NEG( a,strA) if(a<=UNDEFINED) { \
|
#define CHECK_NEG( a,strA) if(a<=UNDEFINED) { \
|
||||||
Log::error("Skidding_Properties", "Missing default value for '%s'"\
|
Log::fatal("Skidding_Properties", "Missing default value for '%s'"\
|
||||||
"in '%s'.", \
|
"in '%s'.", \
|
||||||
strA,filename.c_str());exit(-1); \
|
strA,filename.c_str()); \
|
||||||
}
|
}
|
||||||
CHECK_NEG(m_skid_increase, "skid increase" );
|
CHECK_NEG(m_skid_increase, "skid increase" );
|
||||||
CHECK_NEG(m_skid_decrease, "skid decrease" );
|
CHECK_NEG(m_skid_decrease, "skid decrease" );
|
||||||
@ -98,29 +98,25 @@ void SkiddingProperties::checkAllSet(const std::string &filename) const
|
|||||||
"can be ignored.");
|
"can be ignored.");
|
||||||
if(m_skid_time_till_bonus.size()!=m_skid_bonus_speed.size())
|
if(m_skid_time_till_bonus.size()!=m_skid_bonus_speed.size())
|
||||||
{
|
{
|
||||||
Log::error("Skidding_Properties", "Warning: skid time-till-bonus"
|
Log::fatal("Skidding_Properties", "Warning: skid time-till-bonus"
|
||||||
"and bonus-speed\n must have same number of elements.");
|
"and bonus-speed\n must have same number of elements.");
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
if(m_skid_time_till_bonus.size()!=m_skid_bonus_time.size())
|
if(m_skid_time_till_bonus.size()!=m_skid_bonus_time.size())
|
||||||
{
|
{
|
||||||
Log::error("Skidding_Properties", "Warning: skid time-till-bonus"
|
Log::fatal("Skidding_Properties", "Warning: skid time-till-bonus"
|
||||||
"and bonus-time must\n have same number of elements.");
|
"and bonus-time must\n have same number of elements.");
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
if(m_skid_time_till_bonus.size()!=m_skid_bonus_force.size())
|
if(m_skid_time_till_bonus.size()!=m_skid_bonus_force.size())
|
||||||
{
|
{
|
||||||
Log::error("Skidding_Properties", "Warning: skid time-till-bonus"
|
Log::fatal("Skidding_Properties", "Warning: skid time-till-bonus"
|
||||||
"and bonus-force must\n have same number of elements.");
|
"and bonus-force must\n have same number of elements.");
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
for(unsigned int i=0; i<m_skid_time_till_bonus.size()-1; i++)
|
for(unsigned int i=0; i<m_skid_time_till_bonus.size()-1; i++)
|
||||||
{
|
{
|
||||||
if(m_skid_time_till_bonus[i]>=m_skid_time_till_bonus[i+1])
|
if(m_skid_time_till_bonus[i]>=m_skid_time_till_bonus[i+1])
|
||||||
{
|
{
|
||||||
Log::error("Skidding_Properties", "Warning: skid time-till-bonus"
|
Log::fatal("Skidding_Properties", "Warning: skid time-till-bonus"
|
||||||
"not sorted.");
|
"not sorted.");
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
} // for i
|
} // for i
|
||||||
|
|
||||||
|
@ -572,7 +572,6 @@ int handleCmdLinePreliminary(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
Log::fatal("main", "Error: --screensize argument must be "
|
Log::fatal("main", "Error: --screensize argument must be "
|
||||||
"given as WIDTHxHEIGHT");
|
"given as WIDTHxHEIGHT");
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (strcmp(argv[i], "--version") == 0 ||
|
else if (strcmp(argv[i], "--version") == 0 ||
|
||||||
|
@ -57,8 +57,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::error("Three Strikes Battle", "No AI exists for this game mode");
|
Log::fatal("Three Strikes Battle", "No AI exists for this game mode");
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
m_kart_info.resize(m_karts.size());
|
m_kart_info.resize(m_karts.size());
|
||||||
} // ThreeStrikesBattle
|
} // ThreeStrikesBattle
|
||||||
|
@ -474,7 +474,6 @@ void Track::loadQuadGraph(unsigned int mode_id, const bool reverse)
|
|||||||
{
|
{
|
||||||
Log::fatal("track", "I can handle the lack of driveline in single"
|
Log::fatal("track", "I can handle the lack of driveline in single"
|
||||||
"kart mode, but not with AIs\n");
|
"kart mode, but not with AIs\n");
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -744,7 +743,6 @@ bool Track::loadMainTrack(const XMLNode &root)
|
|||||||
Log::fatal("track",
|
Log::fatal("track",
|
||||||
"Main track model '%s' in '%s' not found, aborting.\n",
|
"Main track model '%s' in '%s' not found, aborting.\n",
|
||||||
track_node->getName().c_str(), model_name.c_str());
|
track_node->getName().c_str(), model_name.c_str());
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The mesh as returned does not have all mesh buffers with the same
|
// The mesh as returned does not have all mesh buffers with the same
|
||||||
@ -1141,7 +1139,6 @@ bool Track::loadMainTrack(const XMLNode &root)
|
|||||||
if (m_track_mesh == NULL)
|
if (m_track_mesh == NULL)
|
||||||
{
|
{
|
||||||
Log::fatal("track", "m_track_mesh == NULL, cannot loadMainTrack\n");
|
Log::fatal("track", "m_track_mesh == NULL, cannot loadMainTrack\n");
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_gfx_effect_mesh->createCollisionShape();
|
m_gfx_effect_mesh->createCollisionShape();
|
||||||
|
@ -74,6 +74,8 @@ public:
|
|||||||
va_start(args, format); \
|
va_start(args, format); \
|
||||||
printMessage(LEVEL, component, format, args); \
|
printMessage(LEVEL, component, format, args); \
|
||||||
va_end(args); \
|
va_end(args); \
|
||||||
|
\
|
||||||
|
if (LEVEL == LL_FATAL) exit(1); \
|
||||||
}
|
}
|
||||||
LOG(verbose, LL_VERBOSE);
|
LOG(verbose, LL_VERBOSE);
|
||||||
LOG(debug, LL_DEBUG);
|
LOG(debug, LL_DEBUG);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user