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

@@ -443,10 +443,10 @@ struct NewGRFParametersWindow : public Window {
}
}
void OnQueryTextFinished(char *str) override
void OnQueryTextFinished(std::optional<std::string> str) override
{
if (StrEmpty(str)) return;
int32_t value = atoi(str);
if (!str.has_value() || str->empty()) return;
int32_t value = atoi(str->c_str());
GRFParameterInfo &par_info = this->GetParameterInfo(this->clicked_row);
uint32_t val = Clamp<uint32_t>(value, par_info.min_value, par_info.max_value);
par_info.SetValue(this->grf_config, val);
@@ -1195,11 +1195,11 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
this->InvalidateData(GOID_NEWGRF_CHANGES_MADE);
}
void OnQueryTextFinished(char *str) override
void OnQueryTextFinished(std::optional<std::string> str) override
{
if (str == nullptr) return;
if (!str.has_value()) return;
SaveGRFPresetToConfig(str, this->actives);
SaveGRFPresetToConfig(str->c_str(), this->actives);
this->grf_presets = GetGRFPresetList();
/* Switch to this preset */