17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 01:39:20 +02:00

event names: drop redundant locale-dependent ToLower() at registration

make_event() lowercased the event name twice: cParser::getToken() already
folds ASCII via toLowerChar() (which intentionally leaves bytes >= 0x80
alone), then ToLower() ran std::tolower() over every byte on top of that.

With a non-"C" global locale, that second pass remaps cp1250 uppercase
accented letters (e.g. 0xAF -> 0xBF). Every lookup path - TTrack::AssignEvents(),
child-event resolution in multi_event, event-launcher name resolution -
normalizes only through the parser, so a registered name containing such a
letter can no longer be found: the track logs "can't find assigned event"
and the binding is silently dropped.

Removing the extra ToLower() makes the registration key match every lookup
site (ASCII-only folding, non-ASCII bytes compared verbatim), and matches
the direction toLowerChar()'s own comment already points at for UTF-8.
This commit is contained in:
Piotr Warszawski
2026-09-05 19:10:58 +02:00
parent a9b561cd65
commit 2dcae05c77

View File

@@ -2195,7 +2195,13 @@ message_event::export_as_text_( std::ostream &Output ) const {
basic_event *
make_event( cParser &Input, scene::scratch_data &Scratchpad ) {
auto const name = ToLower( Input.getToken<std::string>() );
// getToken() already lowercases ASCII letters via the parser's toLowerChar(),
// which deliberately leaves bytes >= 0x80 untouched. The extra ToLower() here
// ran std::tolower() over every byte, so under a non-"C" global locale it
// remapped cp1250 uppercase accented letters (e.g. 0xAF -> 0xBF) - producing a
// registered name that no lookup site (Track::AssignEvents, child-event and
// launcher resolution) could match, since those normalize with the parser only.
auto const name = Input.getToken<std::string>();
auto const type = Input.getToken<std::string>();
basic_event *event { nullptr };