From 7b6bdf22bb3da1c5909a018d02086704fa61c52c Mon Sep 17 00:00:00 2001 From: maj00r <73280030+maj00r@users.noreply.github.com> Date: Sun, 29 Nov 2026 18:19:19 +0100 Subject: [PATCH] fix(events): EU07M review of #542: clip names keep their case and match regardless of it, an event without a pace told - The clip event reads the name of the clip as written (getTokens lowercased it), and play_clip() finds the clip regardless of case, as the submodels are found by their names: a clip named Open or Armature|Wave couldn't be started from a scenery. - An event without a pace (clip endevent) plays the clip at its own pace with a line in the log, and leaves the keyword it met to the event: before, endevent was read as a pace of 0 (stopping the clips) and the next token was swallowed. - Pace 0 with several instances of one model is held by #540's fix (the clips stopped stay set per instance). - The spec says so. --- docs/eu07m-format.md | 4 +++- model/AnimModel.cpp | 9 ++++++++- world/Event.cpp | 11 +++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/docs/eu07m-format.md b/docs/eu07m-format.md index feeb14ddb..050f7debe 100644 --- a/docs/eu07m-format.md +++ b/docs/eu07m-format.md @@ -267,7 +267,9 @@ Części węzła bez ścieżki zostają takie, jak w jego TRS. instancjonowany. Klip ruszający jointami skóry zgina skinowane części (sekcja „Skinning”). - **Event scenerii.** `event animation clip endevent` startuje klip od początku w podanym tempie (klip już grający zaczyna od nowa), a tempo 0 zatrzymuje klipy modelu; węzły zostają tam, - gdzie klip je zostawił. Klip, którego model nie ma, daje w logu `Bad event: ... can't find clip`. To nowa forma + gdzie klip je zostawił. Nazwa klipu jest porównywana bez względu na wielkość liter, jak nazwy submodeli. Event bez + tempa (`clip endevent`) gra klip w jego tempie i daje w logu `Bad event: ... gives no pace for clip`. Klip, + którego model nie ma, daje w logu `Bad event: ... can't find clip`. To nowa forma eventu `animation`, której obecne wydanie nie czyta; dotychczasowe formy (`rotate`, `translate`, `digital`, `.vmd`) czytają się jak dotąd. - **Jeszcze nie:** powiązanie kanałów `CHNL` z czasem klipu. Obecne wydanie nie czyta sekcji klipów, a plik bez nich diff --git a/model/AnimModel.cpp b/model/AnimModel.cpp index d4abeb0b3..b5a5d1c1a 100644 --- a/model/AnimModel.cpp +++ b/model/AnimModel.cpp @@ -15,6 +15,9 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "model/AnimModel.h" +#include +#include + #include "rendering/renderer.h" #include "model/MdlMngr.h" #include "simulation/simulation.h" @@ -802,7 +805,11 @@ bool TAnimModel::play_clip( std::string_view const Name, float const Speed ) { if( pModel == nullptr ) { return false; } auto const &clips { pModel->clips() }; - auto const found { std::ranges::find( clips, Name, &animation::clip::name ) }; + // the name regardless of case, as the submodels are found by theirs + auto const same { [ Name ]( animation::clip const &Clip ) { + return std::ranges::equal( Clip.name, Name, []( char const Left, char const Right ) { + return std::tolower( static_cast( Left ) ) == std::tolower( static_cast( Right ) ); } ); } }; + auto const found { std::ranges::find_if( clips, same ) }; if( found == clips.end() ) { return false; } auto const index { static_cast( std::distance( clips.begin(), found ) ) }; std::erase_if( m_clips, [ index ]( clip_playing const &Playing ) { return Playing.clip == index; } ); diff --git a/world/Event.cpp b/world/Event.cpp index cf02e9409..e7c055e75 100644 --- a/world/Event.cpp +++ b/world/Event.cpp @@ -1662,11 +1662,18 @@ animation_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) >> m_animationparams[ 3 ]; } else if( token == "clip" ) { - // an animation clip of the model (EU07M): its name and pace; a pace of 0 stops the clips playing - Input.getTokens(); + // an animation clip of the model (EU07M): its name, as written (the parser would lowercase it), and pace; a pace of 0 + // stops the clips playing + Input.getTokens( 1, false ); Input >> m_animationsubmodel; m_animationtype = clip_animation; Input.getTokens( 1 ); + if( is_keyword( Input.peek() ) ) { + // no pace: the clip plays at its own, and the keyword read is the next token of the event, not a number of it + m_animationparams[ 0 ] = 1.0; + ErrorLog( "Bad event: \"" + m_name + "\" (type: " + type() + ") gives no pace for clip \"" + m_animationsubmodel + "\", it plays at its own" ); + return; + } Input >> m_animationparams[ 0 ]; } else if( token.ends_with(".vmd") ) // na razie tu, może będzie inaczej