Added: #1469 A check in the mission compiler to be sure camera animations referenced by missions exist in the primitive

--HG--
branch : gsoc2012-fabien
hg/feature/gsoc2012-fabien
Fabien_HENON 13 years ago
parent 477c53fd61
commit afbbced99b

@ -732,6 +732,30 @@ bool CMissionCompiler::installCompiledMission(NLLIGO::CLigoConfig &ligoConfig, c
for (uint i=0; i<_CompiledMission.size(); ++i) for (uint i=0; i<_CompiledMission.size(); ++i)
{ {
CMissionData &mission = *(_CompiledMission[i]); CMissionData &mission = *(_CompiledMission[i]);
// Before adding the script to the giver npc, we first check if the referenced camera animations exist in the current primitive
TLoadedPrimitive &currLoadedPrim = loadedPrimitives[toLower(primFileName)];
CPrimitives *currPrimDoc = currLoadedPrim.PrimDoc;
CPrimitiveContext::instance().CurrentPrimitive = currPrimDoc;
std::vector<std::string> cameraAnimationNames = mission.getCameraAnimationNames();
for (std::vector<std::string>::iterator it = cameraAnimationNames.begin(); it != cameraAnimationNames.end(); ++it)
{
std::string animName = *it;
TPrimitiveSet camAnims;
CPrimitiveSet<TPrimitiveClassAndNamePredicate> filter;
TPrimitiveClassAndNamePredicate pred("camera_animation_tree", animName);
filter.buildSet(currPrimDoc->RootNode, pred, camAnims);
if (camAnims.empty())
{
// Error, we cannot find the camera animation !
string err = toString("Can't find camera animation '%s' in primitive '%s' !",
animName.c_str(),
primFileName.c_str());
throw EParseException(NULL, err.c_str());
}
}
string fileName = mission.getGiverPrimitive(); string fileName = mission.getGiverPrimitive();
if (fileName.empty()) if (fileName.empty())
{ {
@ -2184,6 +2208,16 @@ bool CMissionData::isThereAJumpTo(const std::string &stepName)
return false; return false;
} }
void CMissionData::addCameraAnimationName( const std::string& name )
{
_CameraAnimations.push_back(name);
}
std::vector<std::string> CMissionData::getCameraAnimationNames()
{
return _CameraAnimations;
}
void TCompilerVarName::init(const std::string &defaultName, STRING_MANAGER::TParamType type, CMissionData &md, NLLIGO::IPrimitive *prim, const std::string propName) void TCompilerVarName::init(const std::string &defaultName, STRING_MANAGER::TParamType type, CMissionData &md, NLLIGO::IPrimitive *prim, const std::string propName)
{ {
_DefaultName = defaultName; _DefaultName = defaultName;

@ -315,6 +315,8 @@ public:
std::string getProperty(NLLIGO::IPrimitive *prim, const std::string &propertyName, bool replaceVar, bool canFail); std::string getProperty(NLLIGO::IPrimitive *prim, const std::string &propertyName, bool replaceVar, bool canFail);
std::vector<std::string> getPropertyArray(NLLIGO::IPrimitive *prim, const std::string &propertyName, bool replaceVar, bool canFail); std::vector<std::string> getPropertyArray(NLLIGO::IPrimitive *prim, const std::string &propertyName, bool replaceVar, bool canFail);
void addCameraAnimationName(const std::string& name);
std::vector<std::string> getCameraAnimationNames();
bool isThereAJumpTo(const std::string &stepName); bool isThereAJumpTo(const std::string &stepName);
@ -407,6 +409,8 @@ private:
std::set<TJumpInfo> _JumpPoints; std::set<TJumpInfo> _JumpPoints;
std::vector<std::string> _CameraAnimations;
}; };
typedef NLMISC::CSmartPtr<CMissionData> TMissionDataPtr; typedef NLMISC::CSmartPtr<CMissionData> TMissionDataPtr;

@ -3525,6 +3525,8 @@ public:
string err = toString("primitive(%s): 'animation_name' must not be empty.", prim->getName().c_str()); string err = toString("primitive(%s): 'animation_name' must not be empty.", prim->getName().c_str());
throw EParseException(prim, err.c_str()); throw EParseException(prim, err.c_str());
} }
// We add the animation name to the list, so that we can check later if the animation exists
md.addCameraAnimationName(_Name);
} }
string genCode(CMissionData &md) string genCode(CMissionData &md)

Loading…
Cancel
Save