Fail more quietly while loading

This was SVN commit r2565.
This commit is contained in:
Ykkrosh 2005-07-30 20:12:41 +00:00
parent af3a188200
commit a04abf2967
4 changed files with 33 additions and 17 deletions

View File

@ -420,12 +420,18 @@ int CXMLReader::ReadEntities(XMBElement parent, double end_time)
debug_warn("Invalid XML data - DTD shouldn't allow this"); debug_warn("Invalid XML data - DTD shouldn't allow this");
} }
HEntity ent = g_EntityManager.create(g_EntityTemplateCollection.getTemplate(TemplateName), Position, Orientation); CBaseEntity* base = g_EntityTemplateCollection.getTemplate(TemplateName);
if (! base)
LOG(ERROR, LOG_CATEGORY, "Failed to load entity template '%ls'", TemplateName.c_str());
else
{
HEntity ent = g_EntityManager.create(base, Position, Orientation);
if (! ent) if (! ent)
LOG(ERROR, LOG_CATEGORY, "Failed to create entity '%ls'", TemplateName.c_str()); LOG(ERROR, LOG_CATEGORY, "Failed to create entity of type '%ls'", TemplateName.c_str());
else else
ent->SetPlayer(g_Game->GetPlayer(PlayerID)); ent->SetPlayer(g_Game->GetPlayer(PlayerID));
}
completed_jobs++; completed_jobs++;
LDR_CHECK_TIMEOUT(completed_jobs, total_jobs); LDR_CHECK_TIMEOUT(completed_jobs, total_jobs);

View File

@ -67,6 +67,13 @@ bool CObjectEntry::BuildRandomVariant(const CObjectBase::variation_key& vars, CO
if (var_id < 0 || var_id >= grp->size()) if (var_id < 0 || var_id >= grp->size())
{ {
LOG(ERROR, LOG_CATEGORY, "Internal error (BuildRandomVariant: %d not in 0..%d)", var_id, grp->size()-1); LOG(ERROR, LOG_CATEGORY, "Internal error (BuildRandomVariant: %d not in 0..%d)", var_id, grp->size()-1);
// Carry on as best we can, by using some arbitrary variant (rather
// than choosing none, else we might end up with no model or texture)
if (grp->size())
var_id = 0;
else
// ... unless there aren't any variants in this group, in which
// case just give up and try the next group
continue; continue;
} }
CObjectBase::Variant& var ((*grp)[var_id]); CObjectBase::Variant& var ((*grp)[var_id]);
@ -92,7 +99,7 @@ bool CObjectEntry::BuildRandomVariant(const CObjectBase::variation_key& vars, CO
// So, erase all existing animations which are overridden by this variant: // So, erase all existing animations which are overridden by this variant:
for (std::vector<CObjectBase::Anim>::iterator it = var.m_Anims.begin(); it != var.m_Anims.end(); ++it) for (std::vector<CObjectBase::Anim>::iterator it = var.m_Anims.begin(); it != var.m_Anims.end(); ++it)
chosenAnims.erase(chosenAnims.lower_bound(it->m_AnimName), chosenAnims.upper_bound(it->m_AnimName)); chosenAnims.erase(chosenAnims.lower_bound(it->m_AnimName), chosenAnims.upper_bound(it->m_AnimName));
// and this insert the new ones: // and then insert the new ones:
for (std::vector<CObjectBase::Anim>::iterator it = var.m_Anims.begin(); it != var.m_Anims.end(); ++it) for (std::vector<CObjectBase::Anim>::iterator it = var.m_Anims.begin(); it != var.m_Anims.end(); ++it)
chosenAnims.insert(make_pair(it->m_AnimName, *it)); chosenAnims.insert(make_pair(it->m_AnimName, *it));
} }
@ -117,6 +124,7 @@ bool CObjectEntry::BuildRandomVariant(const CObjectBase::variation_key& vars, CO
for (std::map<CStr, CObjectBase::Prop>::iterator it = chosenProps.begin(); it != chosenProps.end(); ++it) for (std::map<CStr, CObjectBase::Prop>::iterator it = chosenProps.begin(); it != chosenProps.end(); ++it)
props.push_back(it->second); props.push_back(it->second);
// TODO: This is all wrong, since it breaks the order (which vars_it relies on)
// Build the model: // Build the model:

View File

@ -68,13 +68,13 @@ public:
// set this matrix to a rotation described by given quaternion // set this matrix to a rotation described by given quaternion
void SetRotation(const CQuaternion& quat); void SetRotation(const CQuaternion& quat);
// concatentate a rotation about the X axis onto this matrix // concatenate a rotation about the X axis onto this matrix
void RotateX(float angle); void RotateX(float angle);
// concatentate a rotation about the Y axis onto this matrix // concatenate a rotation about the Y axis onto this matrix
void RotateY(float angle); void RotateY(float angle);
// concatentate a rotation about the Z axis onto this matrix // concatenate a rotation about the Z axis onto this matrix
void RotateZ(float angle); void RotateZ(float angle);
// concatentate a rotation described by given quaternion // concatenate a rotation described by given quaternion
void Rotate(const CQuaternion& quat); void Rotate(const CQuaternion& quat);
// set this matrix to given translation // set this matrix to given translation
@ -88,7 +88,7 @@ public:
// set this matrix to the given scaling matrix // set this matrix to the given scaling matrix
void SetScaling(float x_scale, float y_scale, float z_scale); void SetScaling(float x_scale, float y_scale, float z_scale);
// concatentate given scaling matrix onto this matrix // concatenate given scaling matrix onto this matrix
void Scale(float x_scale, float y_scale, float z_scale); void Scale(float x_scale, float y_scale, float z_scale);
// calculate the inverse of this matrix, store in dst // calculate the inverse of this matrix, store in dst

View File

@ -43,10 +43,12 @@ void CFileUnpacker::Read(const char* filename,const char magicstr[4])
// avoid vfs_load complaining about missing data files (which happens // avoid vfs_load complaining about missing data files (which happens
// too often). better to check here than squelch internal VFS error // too often). better to check here than squelch internal VFS error
// reporting. we disable this in release mode to avoid a speed hit. // reporting. we disable this in release mode to avoid a speed hit.
#ifndef NDEBUG // UPDATE: We don't disable this in release mode, because vfs_load now
// complains about missing files when running in release
//#ifndef NDEBUG
if(!vfs_exists(filename)) if(!vfs_exists(filename))
throw CFileOpenError(); throw CFileOpenError();
#endif //#endif
// load the whole thing into memory // load the whole thing into memory
Handle hm = vfs_load(filename, m_Buf, m_Size); Handle hm = vfs_load(filename, m_Buf, m_Size);