replace atoi with std::stoi

This commit is contained in:
2024-08-08 12:40:58 -05:00
committed by Celtic Minstrel
parent f01fdb7e2a
commit a13e7cdc3b
3 changed files with 7 additions and 5 deletions

View File

@@ -10,6 +10,7 @@
#include <stdexcept>
#include <functional>
#include <sstream>
#include <string>
#include "dialog.hpp"
#include "gfx/tiling.hpp" // for bg
#include "fileio/resmgr/res_dialog.hpp"
@@ -540,7 +541,7 @@ void cDialog::handle_events() {
Element& next_action = pop_next_action();
auto info = info_from_action(next_action);
if(info["id"].empty()) continue;
eKeyMod mods = static_cast<eKeyMod>(atoi(info["mods"].c_str()));
eKeyMod mods = static_cast<eKeyMod>(std::stoi(info["mods"]));
controls[info["id"]]->triggerClickHandler(*this, info["id"], mods);
}else{
while(win.pollEvent(currentEvent)) handle_one_event(currentEvent);

View File

@@ -264,7 +264,7 @@ void replay_next_action() {
std::string t = next_action.Value();
if(overall_mode == MODE_STARTUP && t == "startup_button_click"){
eStartButton btn = static_cast<eStartButton>(atoi(next_action.GetText().c_str()));
eStartButton btn = static_cast<eStartButton>(std::stoi(next_action.GetText()));
handle_startup_button_click(btn);
}else if(t == "load_party"){
decode_file(next_action.GetText(), tempDir / "temp.exg");
@@ -343,7 +343,7 @@ void init_boe(int argc, char* argv[]) {
Element& srand_element = pop_next_action("srand");
std::string ts(srand_element.GetText());
game_rand.seed(atoi(ts.c_str()));
game_rand.seed(std::stoi(ts));
} else {
auto t = time(nullptr);
if (recording) {

View File

@@ -10,6 +10,7 @@
#include "mathutil.hpp"
#include <iostream>
#include <sstream>
#include <string>
eDirection& operator++ (eDirection& me, int) {
if(me == DIR_HERE) return me = DIR_N;
@@ -242,11 +243,11 @@ std::istream& operator>> (std::istream& in, location& l) {
in.get(); // (
std::stringbuf sstr;
in.get(sstr, ',');
l.x = atoi(sstr.str().c_str());
l.x = std::stoi(sstr.str());
in.get(); // ,
sstr.str("");
in.get(sstr, ')');
l.y = atoi(sstr.str().c_str());
l.y = std::stoi(sstr.str());
in.get(); // )
return in;
}