mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Return reference from GetNextParameterPointer.
GetNextParameterPointer can no longer return nullptr, and the callers do not check for nullptr, so return a reference instead.pull/12718/head
parent
59b18560d4
commit
9eb28def57
|
@ -76,9 +76,9 @@ void StringParameters::PrepareForNextRun()
|
|||
* Get the next parameter from our parameters.
|
||||
* This updates the offset, so the next time this is called the next parameter
|
||||
* will be read.
|
||||
* @return The pointer to the next parameter.
|
||||
* @return The next parameter.
|
||||
*/
|
||||
StringParameter *StringParameters::GetNextParameterPointer()
|
||||
const StringParameter &StringParameters::GetNextParameterReference()
|
||||
{
|
||||
assert(this->next_type == 0 || (SCC_CONTROL_START <= this->next_type && this->next_type <= SCC_CONTROL_END));
|
||||
if (this->offset >= this->parameters.size()) {
|
||||
|
@ -92,7 +92,7 @@ StringParameter *StringParameters::GetNextParameterPointer()
|
|||
}
|
||||
param.type = this->next_type;
|
||||
this->next_type = 0;
|
||||
return ¶m;
|
||||
return param;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ protected:
|
|||
parameters(parameters)
|
||||
{}
|
||||
|
||||
StringParameter *GetNextParameterPointer();
|
||||
const StringParameter &GetNextParameterReference();
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -92,8 +92,8 @@ public:
|
|||
template <typename T>
|
||||
T GetNextParameter()
|
||||
{
|
||||
auto ptr = GetNextParameterPointer();
|
||||
return static_cast<T>(ptr->data);
|
||||
const auto ¶m = GetNextParameterReference();
|
||||
return static_cast<T>(param.data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,8 +104,8 @@ public:
|
|||
*/
|
||||
const char *GetNextParameterString()
|
||||
{
|
||||
auto ptr = GetNextParameterPointer();
|
||||
return ptr->string != nullptr ? ptr->string->c_str() : nullptr;
|
||||
const auto ¶m = GetNextParameterReference();
|
||||
return param.string != nullptr ? param.string->c_str() : nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue