From a13e7cdc3ba5a8f73b94013e4805183717b6170b Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Thu, 8 Aug 2024 12:40:58 -0500 Subject: [PATCH] replace atoi with std::stoi --- src/dialogxml/dialogs/dialog.cpp | 3 ++- src/game/boe.main.cpp | 4 ++-- src/location.cpp | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/dialogxml/dialogs/dialog.cpp b/src/dialogxml/dialogs/dialog.cpp index 3f25744f..8be76bcd 100644 --- a/src/dialogxml/dialogs/dialog.cpp +++ b/src/dialogxml/dialogs/dialog.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #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(atoi(info["mods"].c_str())); + eKeyMod mods = static_cast(std::stoi(info["mods"])); controls[info["id"]]->triggerClickHandler(*this, info["id"], mods); }else{ while(win.pollEvent(currentEvent)) handle_one_event(currentEvent); diff --git a/src/game/boe.main.cpp b/src/game/boe.main.cpp index c15f2c24..d8e4cbaa 100644 --- a/src/game/boe.main.cpp +++ b/src/game/boe.main.cpp @@ -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(atoi(next_action.GetText().c_str())); + eStartButton btn = static_cast(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) { diff --git a/src/location.cpp b/src/location.cpp index e6c7dde5..91e8844c 100644 --- a/src/location.cpp +++ b/src/location.cpp @@ -10,6 +10,7 @@ #include "mathutil.hpp" #include #include +#include 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; }