diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-01 20:11:00 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-01 20:11:00 +0300 |
| commit | 480161a733ebcb8261b13cf602df24d4423b4125 (patch) | |
| tree | 5acfd62fa9b6c216b8ce0928d6e57068a0f20eb5 /apps/fparkan-game/src/audio.rs | |
| parent | 90cc800c36c6c8f974c2f96fa6499ad3486a7ef1 (diff) | |
| download | fparkan-480161a733ebcb8261b13cf602df24d4423b4125.tar.xz fparkan-480161a733ebcb8261b13cf602df24d4423b4125.zip | |
fix(ui): show the original sender on mission messages
Diffstat (limited to 'apps/fparkan-game/src/audio.rs')
| -rw-r--r-- | apps/fparkan-game/src/audio.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/apps/fparkan-game/src/audio.rs b/apps/fparkan-game/src/audio.rs index 256a88d2..e4580707 100644 --- a/apps/fparkan-game/src/audio.rs +++ b/apps/fparkan-game/src/audio.rs @@ -1504,20 +1504,20 @@ pub(crate) fn message_symbol( index: u32, field: &str, ) -> Result<Option<String>, String> { - for object in config_objects(&String::from_utf8_lossy(bytes)) { - if object + message_fields(&String::from_utf8_lossy(bytes), index) + .and_then(|object| object.get(field).copied()) + .map(parse_cfg_value) + .transpose() +} + +pub(crate) fn message_fields(text: &str, index: u32) -> Option<BTreeMap<String, &str>> { + config_objects(text).find(|object| { + object .get("MESSAGE_INDEX") .and_then(|index| parse_cfg_value(index).ok()) .and_then(|value| value.parse::<u32>().ok()) == Some(index) - { - return object - .get(field) - .map(|value| parse_cfg_value(value)) - .transpose(); - } - } - Ok(None) + }) } fn voice_resource(bytes: &[u8], symbol: &str) -> Result<Option<(String, String)>, String> { |
