summaryrefslogtreecommitdiffstats
path: root/src/input_common
diff options
context:
space:
mode:
authorMorph <39850852+Morph1984@users.noreply.github.com>2022-01-10 01:43:06 +0100
committerGitHub <noreply@github.com>2022-01-10 01:43:06 +0100
commit18adea343ebd77dce1180942fc773ec891153ff8 (patch)
treeb3a224c730c7201f2bcc8b8c309cbc0be2cfd2f9 /src/input_common
parentMerge pull request #7682 from german77/udp_fix (diff)
parentinput_common: Handle errors on TAS scripts (diff)
downloadyuzu-18adea343ebd77dce1180942fc773ec891153ff8.tar
yuzu-18adea343ebd77dce1180942fc773ec891153ff8.tar.gz
yuzu-18adea343ebd77dce1180942fc773ec891153ff8.tar.bz2
yuzu-18adea343ebd77dce1180942fc773ec891153ff8.tar.lz
yuzu-18adea343ebd77dce1180942fc773ec891153ff8.tar.xz
yuzu-18adea343ebd77dce1180942fc773ec891153ff8.tar.zst
yuzu-18adea343ebd77dce1180942fc773ec891153ff8.zip
Diffstat (limited to 'src/input_common')
-rw-r--r--src/input_common/drivers/tas_input.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/input_common/drivers/tas_input.cpp b/src/input_common/drivers/tas_input.cpp
index 5bdd5dac3..d78228b50 100644
--- a/src/input_common/drivers/tas_input.cpp
+++ b/src/input_common/drivers/tas_input.cpp
@@ -105,10 +105,16 @@ void Tas::LoadTasFile(size_t player_index, size_t file_index) {
continue;
}
- const auto num_frames = std::stoi(seg_list[0]);
- while (frame_no < num_frames) {
- commands[player_index].emplace_back();
- frame_no++;
+ try {
+ const auto num_frames = std::stoi(seg_list[0]);
+ while (frame_no < num_frames) {
+ commands[player_index].emplace_back();
+ frame_no++;
+ }
+ } catch (const std::invalid_argument&) {
+ LOG_ERROR(Input, "Invalid argument: '{}' at command {}", seg_list[0], frame_no);
+ } catch (const std::out_of_range&) {
+ LOG_ERROR(Input, "Out of range: '{}' at command {}", seg_list[0], frame_no);
}
TASCommand command = {
@@ -233,10 +239,21 @@ TasAnalog Tas::ReadCommandAxis(const std::string& line) const {
}
}
- const float x = std::stof(seg_list.at(0)) / 32767.0f;
- const float y = std::stof(seg_list.at(1)) / 32767.0f;
+ if (seg_list.size() < 2) {
+ LOG_ERROR(Input, "Invalid axis data: '{}'", line);
+ return {};
+ }
- return {x, y};
+ try {
+ const float x = std::stof(seg_list.at(0)) / 32767.0f;
+ const float y = std::stof(seg_list.at(1)) / 32767.0f;
+ return {x, y};
+ } catch (const std::invalid_argument&) {
+ LOG_ERROR(Input, "Invalid argument: '{}'", line);
+ } catch (const std::out_of_range&) {
+ LOG_ERROR(Input, "Out of range: '{}'", line);
+ }
+ return {};
}
u64 Tas::ReadCommandButtons(const std::string& line) const {