| 221 | } |
| 222 | |
| 223 | bool AnimationLibrary::loadModelScript(const std::string& file_name, ModelScriptParser& p) |
| 224 | { |
| 225 | LogInfo() << "load model script " << file_name; |
| 226 | |
| 227 | size_t name_end = file_name.rfind('.'); |
| 228 | std::string name = file_name.substr(0, name_end); |
| 229 | |
| 230 | Animation* anim = nullptr; |
| 231 | |
| 232 | ModelScriptParser::EChunkType type; |
| 233 | while ((type = p.parse()) != ModelScriptParser::CHUNK_EOF) |
| 234 | { |
| 235 | switch (type) |
| 236 | { |
| 237 | case ModelScriptParser::CHUNK_ANI: |
| 238 | { |
| 239 | std::string qname = name + '-' + p.ani().m_Name; |
| 240 | |
| 241 | auto h = m_World.getAnimationAllocator().allocate(qname); |
| 242 | anim = &m_World.getAnimationAllocator().getAnimation(h); |
| 243 | anim->m_Name = p.ani().m_Name; |
| 244 | anim->m_Layer = p.ani().m_Layer; |
| 245 | anim->m_NextName = p.ani().m_Next; |
| 246 | anim->m_BlendIn = p.ani().m_BlendIn; |
| 247 | anim->m_BlendOut = p.ani().m_BlendOut; |
| 248 | anim->m_Flags = (Animation::EModelScriptAniFlags)p.ani().m_Flags; |
| 249 | anim->m_FirstFrame = p.ani().m_FirstFrame; |
| 250 | anim->m_LastFrame = p.ani().m_LastFrame; |
| 251 | anim->m_Dir = p.ani().m_Dir; |
| 252 | anim->m_Next = m_World.getAnimationAllocator().getAnimation(name + "-" + p.ani().m_Next); |
| 253 | |
| 254 | anim->m_Data = loadMAN(qname); |
| 255 | if (!anim->m_Data.isValid()) |
| 256 | return false; |
| 257 | |
| 258 | auto& data = m_World.getAnimationDataAllocator().getAnimationData(anim->m_Data); |
| 259 | anim->m_FpsRate = data.m_Header.fpsRate; |
| 260 | anim->m_FrameCount = data.m_Header.numFrames; |
| 261 | |
| 262 | //LogInfo() << "created animation '" << qname << "' id " << h.index; |
| 263 | |
| 264 | // In case this was an ASCII-File, these will be filled. Binary files have single ones |
| 265 | // stored in chunks handled below |
| 266 | for (auto& sfx : p.sfx()) |
| 267 | { |
| 268 | animationAddEventSFX(anim, sfx); |
| 269 | } |
| 270 | p.sfx().clear(); |
| 271 | |
| 272 | for (auto& sfx : p.sfxGround()) |
| 273 | { |
| 274 | animationAddEventSFXGround(anim, sfx); |
| 275 | } |
| 276 | p.sfxGround().clear(); |
| 277 | |
| 278 | for (auto& tag : p.tag()) |
| 279 | { |
| 280 | animationAddEventTag(anim, tag); |
nothing calls this directly
no test coverage detected