mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 10:37:07 +01:00
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 <name> 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.
This commit is contained in:
+8
-1
@@ -15,6 +15,9 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "stdafx.h"
|
||||
#include "model/AnimModel.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
|
||||
#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<unsigned char>( Left ) ) == std::tolower( static_cast<unsigned char>( Right ) ); } ); } };
|
||||
auto const found { std::ranges::find_if( clips, same ) };
|
||||
if( found == clips.end() ) { return false; }
|
||||
auto const index { static_cast<std::size_t>( std::distance( clips.begin(), found ) ) };
|
||||
std::erase_if( m_clips, [ index ]( clip_playing const &Playing ) { return Playing.clip == index; } );
|
||||
|
||||
Reference in New Issue
Block a user