summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2022-01-08 19:10:21 +0100
committergerman77 <juangerman-13@hotmail.com>2022-01-08 19:27:16 +0100
commitea089c012eb88eb2e43526e8d5899e751c2eed94 (patch)
tree57b473bbd70e1fc20ebdb29c414415985c19a82f
parentMerge pull request #7658 from ameerj/sparse-fixes (diff)
downloadyuzu-ea089c012eb88eb2e43526e8d5899e751c2eed94.tar
yuzu-ea089c012eb88eb2e43526e8d5899e751c2eed94.tar.gz
yuzu-ea089c012eb88eb2e43526e8d5899e751c2eed94.tar.bz2
yuzu-ea089c012eb88eb2e43526e8d5899e751c2eed94.tar.lz
yuzu-ea089c012eb88eb2e43526e8d5899e751c2eed94.tar.xz
yuzu-ea089c012eb88eb2e43526e8d5899e751c2eed94.tar.zst
yuzu-ea089c012eb88eb2e43526e8d5899e751c2eed94.zip
-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 {