str("") is unsafe on its own for clearing stream

This commit is contained in:
2025-04-20 19:21:02 -05:00
parent a2f4c8a903
commit 58107f1856
15 changed files with 37 additions and 32 deletions

View File

@@ -2447,7 +2447,7 @@ void set_up_main_screen() {
set_lb(-1,LB_TEXT,LB_EDIT_OUT,"Edit Outdoor Terrain");
set_lb(-1,LB_TEXT,LB_NO_ACTION,"",0);
set_lb(-1,LB_TEXT,LB_NO_ACTION,"Town/Dungeon Options");
strb.str("");
clear_sstr(strb);
strb << " Town " << cur_town << ": " << town->name;
set_lb(-1,LB_TEXT,LB_NO_ACTION, strb.str());
set_lb(-1,LB_TEXT,LB_LOAD_TOWN,"Load Another Town");

View File

@@ -646,7 +646,7 @@ static void put_monst_info_in_dlog(cDialog& me, cMonster& monst, mon_num_t which
me["pic"].setTextToNum(monst.picture_num);
strb << "Width = " << int(monst.x_width);
me["w"].setText(strb.str());
strb.str("");
clear_sstr(strb);
strb << "Height = " << int(monst.y_width);
me["h"].setText(strb.str());
me["level"].setTextToNum(monst.level);
@@ -704,7 +704,7 @@ static void put_monst_info_in_dlog(cDialog& me, cMonster& monst, mon_num_t which
case 122: summoned_by.push_back(eSpell::SUMMON_GUARDIAN); break;
}
strb.str("");
clear_sstr(strb);
bool first = true;
if(summoned_by.empty())
strb << "None";
@@ -755,7 +755,7 @@ static bool check_monst_pic(cDialog& me, std::string id, bool losing, cMonster&
std::ostringstream strb;
strb << "Width = " << int(monst.x_width);
me["w"].setText(strb.str());
strb.str("");
clear_sstr(strb);
strb << "Height = " << int(monst.y_width);
me["h"].setText(strb.str());
}

View File

@@ -609,7 +609,7 @@ void writeMonstersToXml(ticpp::Printer&& data, cScenario& scenario) {
if(monst.guard) data.PushElement("guard");
for(auto& p : monst.abil) {
if(p.first == eMonstAbil::NO_ABIL || !p.second.active) continue;
str.str("");
clear_sstr(str);
eMonstAbil abil = p.first;
uAbility& param = p.second;
switch(getMonstAbilCategory(abil)) {

View File

@@ -1378,14 +1378,14 @@ void place_location() {
TextStyle style;
style.lineHeight = 12;
win_draw_string(mainPtr(), draw_rect, sout.str(), eTextMode::LEFT_TOP, style);
sout.str("");
clear_sstr(sout);
moveTo = location(260 ,terrain_rects[255].top + 18);
draw_rect = text_rect;
draw_rect.offset(moveTo);
sout << current_terrain_type;
win_draw_string(mainPtr(), draw_rect, sout.str(), eTextMode::LEFT_TOP, style);
sout.str("");
clear_sstr(sout);
if(overall_mode < MODE_MAIN_SCREEN) {
moveTo = location(5,terrain_rects[255].bottom + 121);

View File

@@ -1463,7 +1463,7 @@ static void put_out_loc_in_dlog(cDialog& me, location cur_loc, cScenario& scenar
std::ostringstream str;
str << "X = " << cur_loc.x;
me["x"].setText(str.str());
str.str("");
clear_sstr(str);
str << "Y = " << cur_loc.y;
me["y"].setText(str.str());
me["title"].setText(scenario.outdoors[cur_loc.x][cur_loc.y]->name);