Codechange: use std::optional<std::string> over char * for text query results

This commit is contained in:
Rubidium
2024-05-07 21:08:20 +02:00
committed by rubidium42
parent 3819ab25bf
commit 14200212b7
22 changed files with 126 additions and 126 deletions

View File

@@ -595,11 +595,11 @@ struct NewGRFInspectWindow : Window {
}
}
void OnQueryTextFinished(char *str) override
void OnQueryTextFinished(std::optional<std::string> str) override
{
if (StrEmpty(str)) return;
if (!str.has_value() || str->empty()) return;
NewGRFInspectWindow::var60params[GetFeatureNum(this->window_number)][this->current_edit_param - 0x60] = std::strtol(str, nullptr, 16);
NewGRFInspectWindow::var60params[GetFeatureNum(this->window_number)][this->current_edit_param - 0x60] = std::strtol(str->c_str(), nullptr, 16);
this->SetDirty();
}
@@ -1074,11 +1074,11 @@ struct SpriteAlignerWindow : Window {
}
}
void OnQueryTextFinished(char *str) override
void OnQueryTextFinished(std::optional<std::string> str) override
{
if (StrEmpty(str)) return;
if (!str.has_value() || str->empty()) return;
this->current_sprite = atoi(str);
this->current_sprite = atoi(str->c_str());
if (this->current_sprite >= GetMaxSpriteID()) this->current_sprite = 0;
while (GetSpriteType(this->current_sprite) != SpriteType::Normal) {
this->current_sprite = (this->current_sprite + 1) % GetMaxSpriteID();