Codechange: Use proper enum type to index sprite groups in VariableGRFFileProps.

This commit is contained in:
frosch
2025-04-26 18:57:03 +02:00
committed by frosch
parent 893aa0fb91
commit 41a20e512d
11 changed files with 73 additions and 92 deletions
-27
View File
@@ -740,30 +740,3 @@ void GRFFilePropsBase::SetGRFFile(const struct GRFFile *grffile)
this->grffile = grffile;
this->grfid = grffile == nullptr ? 0 : grffile->grfid;
}
/**
* Get the SpriteGroup at the specified index.
* @param index Index to get.
* @returns SpriteGroup at index, or nullptr if not present.
*/
const SpriteGroup *VariableGRFFileProps::GetSpriteGroup(size_t index) const
{
auto it = std::ranges::lower_bound(this->spritegroups, index, std::less{}, &CargoSpriteGroup::first);
if (it == std::end(this->spritegroups) || it->first != index) return nullptr;
return it->second;
}
/**
* Set the SpriteGroup at the specified index.
* @param index Index to set.
* @param spritegroup SpriteGroup to set.
*/
void VariableGRFFileProps::SetSpriteGroup(size_t index, const SpriteGroup *spritegroup)
{
auto it = std::ranges::lower_bound(this->spritegroups, index, std::less{}, &CargoSpriteGroup::first);
if (it == std::end(this->spritegroups) || it->first != index) {
this->spritegroups.emplace(it, index, spritegroup);
} else {
it->second = spritegroup;
}
}