Codechange: Use std::map instead of custom SmallMap.

This commit is contained in:
Peter Nelson
2023-05-16 20:50:41 +01:00
committed by PeterN
parent 72018badff
commit c38df2d589
30 changed files with 81 additions and 235 deletions

View File

@@ -818,7 +818,7 @@ struct SpriteAlignerWindow : Window {
SpriteID current_sprite; ///< The currently shown sprite.
Scrollbar *vscroll;
SmallMap<SpriteID, XyOffs> offs_start_map; ///< Mapping of starting offsets for the sprites which have been aligned in the sprite aligner window.
std::map<SpriteID, XyOffs> offs_start_map; ///< Mapping of starting offsets for the sprites which have been aligned in the sprite aligner window.
static bool centre;
static bool crosshair;
@@ -854,7 +854,7 @@ struct SpriteAlignerWindow : Window {
/* Relative offset is new absolute offset - starting absolute offset.
* Show 0, 0 as the relative offsets if entry is not in the map (meaning they have not been changed yet).
*/
const auto key_offs_pair = this->offs_start_map.Find(this->current_sprite);
const auto key_offs_pair = this->offs_start_map.find(this->current_sprite);
if (key_offs_pair != this->offs_start_map.end()) {
SetDParam(0, spr->x_offs - key_offs_pair->second.first);
SetDParam(1, spr->y_offs - key_offs_pair->second.second);
@@ -992,8 +992,8 @@ struct SpriteAlignerWindow : Window {
Sprite *spr = const_cast<Sprite *>(GetSprite(this->current_sprite, SpriteType::Normal));
/* Remember the original offsets of the current sprite, if not already in mapping. */
if (!(this->offs_start_map.Contains(this->current_sprite))) {
this->offs_start_map.Insert(this->current_sprite, XyOffs(spr->x_offs, spr->y_offs));
if (this->offs_start_map.count(this->current_sprite) == 0) {
this->offs_start_map[this->current_sprite] = XyOffs(spr->x_offs, spr->y_offs);
}
switch (widget) {
/* Move eight units at a time if ctrl is pressed. */
@@ -1010,7 +1010,7 @@ struct SpriteAlignerWindow : Window {
case WID_SA_RESET_REL:
/* Reset the starting offsets for the current sprite. */
this->offs_start_map.Erase(this->current_sprite);
this->offs_start_map.erase(this->current_sprite);
this->SetDirty();
break;