summaryrefslogtreecommitdiff
path: root/src/input_common/drivers/tas_input.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/drivers/tas_input.cpp')
-rw-r--r--src/input_common/drivers/tas_input.cpp45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/input_common/drivers/tas_input.cpp b/src/input_common/drivers/tas_input.cpp
index a7d3d0b47..d14a43b9e 100644
--- a/src/input_common/drivers/tas_input.cpp
+++ b/src/input_common/drivers/tas_input.cpp
@@ -93,27 +93,29 @@ void Tas::LoadTasFile(size_t player_index, size_t file_index) {
93 continue; 93 continue;
94 } 94 }
95 95
96 std::istringstream linestream(line); 96 std::vector<std::string> seg_list;
97 std::string segment; 97 {
98 std::vector<std::string> seglist; 98 std::istringstream line_stream(line);
99 99 std::string segment;
100 while (std::getline(linestream, segment, ' ')) { 100 while (std::getline(line_stream, segment, ' ')) {
101 seglist.push_back(segment); 101 seg_list.push_back(std::move(segment));
102 }
102 } 103 }
103 104
104 if (seglist.size() < 4) { 105 if (seg_list.size() < 4) {
105 continue; 106 continue;
106 } 107 }
107 108
108 while (frame_no < std::stoi(seglist.at(0))) { 109 const auto num_frames = std::stoi(seg_list[0]);
109 commands[player_index].push_back({}); 110 while (frame_no < num_frames) {
111 commands[player_index].emplace_back();
110 frame_no++; 112 frame_no++;
111 } 113 }
112 114
113 TASCommand command = { 115 TASCommand command = {
114 .buttons = ReadCommandButtons(seglist.at(1)), 116 .buttons = ReadCommandButtons(seg_list[1]),
115 .l_axis = ReadCommandAxis(seglist.at(2)), 117 .l_axis = ReadCommandAxis(seg_list[2]),
116 .r_axis = ReadCommandAxis(seglist.at(3)), 118 .r_axis = ReadCommandAxis(seg_list[3]),
117 }; 119 };
118 commands[player_index].push_back(command); 120 commands[player_index].push_back(command);
119 frame_no++; 121 frame_no++;
@@ -223,22 +225,23 @@ void Tas::ClearInput() {
223} 225}
224 226
225TasAnalog Tas::ReadCommandAxis(const std::string& line) const { 227TasAnalog Tas::ReadCommandAxis(const std::string& line) const {
226 std::stringstream linestream(line); 228 std::vector<std::string> seg_list;
227 std::string segment; 229 {
228 std::vector<std::string> seglist; 230 std::istringstream line_stream(line);
229 231 std::string segment;
230 while (std::getline(linestream, segment, ';')) { 232 while (std::getline(line_stream, segment, ';')) {
231 seglist.push_back(segment); 233 seg_list.push_back(std::move(segment));
234 }
232 } 235 }
233 236
234 const float x = std::stof(seglist.at(0)) / 32767.0f; 237 const float x = std::stof(seg_list.at(0)) / 32767.0f;
235 const float y = std::stof(seglist.at(1)) / 32767.0f; 238 const float y = std::stof(seg_list.at(1)) / 32767.0f;
236 239
237 return {x, y}; 240 return {x, y};
238} 241}
239 242
240u64 Tas::ReadCommandButtons(const std::string& line) const { 243u64 Tas::ReadCommandButtons(const std::string& line) const {
241 std::stringstream button_text(line); 244 std::istringstream button_text(line);
242 std::string button_line; 245 std::string button_line;
243 u64 buttons = 0; 246 u64 buttons = 0;
244 while (std::getline(button_text, button_line, ';')) { 247 while (std::getline(button_text, button_line, ';')) {