From afbbced99b3af8653853e4aba807eeaff662effa Mon Sep 17 00:00:00 2001 From: Fabien_HENON Date: Sat, 2 Jun 2012 00:10:16 +0200 Subject: [PATCH] Added: #1469 A check in the mission compiler to be sure camera animations referenced by missions exist in the primitive --HG-- branch : gsoc2012-fabien --- .../mission_compiler_lib/mission_compiler.cpp | 34 +++++++++++++++++++ .../mission_compiler_lib/mission_compiler.h | 4 +++ .../mission_compiler_lib/step_content.cpp | 2 ++ 3 files changed, 40 insertions(+) diff --git a/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.cpp b/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.cpp index 20e957859..71f9ac27b 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.cpp +++ b/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.cpp @@ -732,6 +732,30 @@ bool CMissionCompiler::installCompiledMission(NLLIGO::CLigoConfig &ligoConfig, c for (uint i=0; i<_CompiledMission.size(); ++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 cameraAnimationNames = mission.getCameraAnimationNames(); + for (std::vector::iterator it = cameraAnimationNames.begin(); it != cameraAnimationNames.end(); ++it) + { + std::string animName = *it; + TPrimitiveSet camAnims; + CPrimitiveSet 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(); if (fileName.empty()) { @@ -2184,6 +2208,16 @@ bool CMissionData::isThereAJumpTo(const std::string &stepName) return false; } +void CMissionData::addCameraAnimationName( const std::string& name ) +{ + _CameraAnimations.push_back(name); +} + +std::vector CMissionData::getCameraAnimationNames() +{ + return _CameraAnimations; +} + void TCompilerVarName::init(const std::string &defaultName, STRING_MANAGER::TParamType type, CMissionData &md, NLLIGO::IPrimitive *prim, const std::string propName) { _DefaultName = defaultName; diff --git a/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.h b/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.h index 1f2323fdf..4ef854433 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.h +++ b/code/ryzom/tools/leveldesign/mission_compiler_lib/mission_compiler.h @@ -315,6 +315,8 @@ public: std::string getProperty(NLLIGO::IPrimitive *prim, const std::string &propertyName, bool replaceVar, bool canFail); std::vector getPropertyArray(NLLIGO::IPrimitive *prim, const std::string &propertyName, bool replaceVar, bool canFail); + void addCameraAnimationName(const std::string& name); + std::vector getCameraAnimationNames(); bool isThereAJumpTo(const std::string &stepName); @@ -407,6 +409,8 @@ private: std::set _JumpPoints; + std::vector _CameraAnimations; + }; typedef NLMISC::CSmartPtr TMissionDataPtr; diff --git a/code/ryzom/tools/leveldesign/mission_compiler_lib/step_content.cpp b/code/ryzom/tools/leveldesign/mission_compiler_lib/step_content.cpp index 11a0e0b4c..d6a79865f 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_lib/step_content.cpp +++ b/code/ryzom/tools/leveldesign/mission_compiler_lib/step_content.cpp @@ -3525,6 +3525,8 @@ public: string err = toString("primitive(%s): 'animation_name' must not be empty.", prim->getName().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)