When failing to load a track object, don't leave a malformed TrackObject instance in the track_object_manager
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10842 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
43ba4c4c25
commit
c54a651ce9
@ -152,11 +152,8 @@ TrackObject::TrackObject(const XMLNode &xml_node)
|
||||
|
||||
if(!m_mesh)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Warning: model '%s' in node '%s' not found and is ignored.\n",
|
||||
model_name.c_str(), xml_node.getName().c_str());
|
||||
return;
|
||||
} // if(!m_mesh)
|
||||
throw std::runtime_error("Model '" + model_name + "' cannot be found");
|
||||
}
|
||||
}
|
||||
|
||||
m_mesh->grab();
|
||||
|
@ -47,50 +47,58 @@ TrackObjectManager::~TrackObjectManager()
|
||||
*/
|
||||
void TrackObjectManager::add(const XMLNode &xml_node)
|
||||
{
|
||||
std::string groupname;
|
||||
xml_node.get("lod_group", &groupname);
|
||||
bool is_lod = !groupname.empty();
|
||||
|
||||
std::string type;
|
||||
xml_node.get("type", &type);
|
||||
if(type=="movable")
|
||||
try
|
||||
{
|
||||
if (is_lod)
|
||||
std::string groupname;
|
||||
xml_node.get("lod_group", &groupname);
|
||||
bool is_lod = !groupname.empty();
|
||||
|
||||
std::string type;
|
||||
xml_node.get("type", &type);
|
||||
if(type=="movable")
|
||||
{
|
||||
m_lod_objects[groupname].push_back(new PhysicalObject(xml_node));
|
||||
if (is_lod)
|
||||
{
|
||||
m_lod_objects[groupname].push_back(new PhysicalObject(xml_node));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_all_objects.push_back(new PhysicalObject(xml_node));
|
||||
}
|
||||
}
|
||||
else if(type=="animation")
|
||||
{
|
||||
if (is_lod)
|
||||
{
|
||||
m_lod_objects[groupname].push_back(new ThreeDAnimation(xml_node));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_all_objects.push_back(new ThreeDAnimation(xml_node));
|
||||
}
|
||||
}
|
||||
else if(type=="billboard")
|
||||
{
|
||||
m_all_objects.push_back(new BillboardAnimation(xml_node));
|
||||
}
|
||||
else if(type=="sfx-emitter")
|
||||
{
|
||||
m_all_objects.push_back(new TrackObject(xml_node));
|
||||
}
|
||||
else if(type=="action-trigger")
|
||||
{
|
||||
m_all_objects.push_back(new TrackObject(xml_node));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_all_objects.push_back(new PhysicalObject(xml_node));
|
||||
fprintf(stderr, "Unknown track object: '%s' - ignored.\n",
|
||||
type.c_str());
|
||||
}
|
||||
}
|
||||
else if(type=="animation")
|
||||
catch (std::exception& e)
|
||||
{
|
||||
if (is_lod)
|
||||
{
|
||||
m_lod_objects[groupname].push_back(new ThreeDAnimation(xml_node));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_all_objects.push_back(new ThreeDAnimation(xml_node));
|
||||
}
|
||||
}
|
||||
else if(type=="billboard")
|
||||
{
|
||||
m_all_objects.push_back(new BillboardAnimation(xml_node));
|
||||
}
|
||||
else if(type=="sfx-emitter")
|
||||
{
|
||||
m_all_objects.push_back(new TrackObject(xml_node));
|
||||
}
|
||||
else if(type=="action-trigger")
|
||||
{
|
||||
m_all_objects.push_back(new TrackObject(xml_node));
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Unknown track object: '%s' - ignored.\n",
|
||||
type.c_str());
|
||||
fprintf(stderr, "[TrackObjectManager] WARNING: Could not load track object. Reason : %s\n",
|
||||
e.what());
|
||||
}
|
||||
} // add
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user