12 #include "table/strings.h"
15 template <
typename Tspec,
typename Tindex, Tindex Tmax>
31 template <
typename Tspec,
typename Tindex, Tindex Tmax>
46 GrfMsg(2,
"ClassAllocate: already allocated {} classes, using default", Tmax);
47 return static_cast<Tindex
>(0);
54 template <
typename Tspec,
typename Tindex, Tindex Tmax>
57 auto it = this->spec.insert(std::end(this->spec), spec);
58 uint16_t index =
static_cast<uint16_t
>(std::distance(std::begin(this->spec), it));
59 if (spec !=
nullptr) (*it)->index = index;
61 if (this->IsUIAvailable(index)) this->ui_count++;
69 template <
typename Tspec,
typename Tindex, Tindex Tmax>
73 Get(spec->class_index)->Insert(spec);
81 template <
typename Tspec,
typename Tindex, Tindex Tmax>
92 template <
typename Tspec,
typename Tindex, Tindex Tmax>
102 template <
typename Tspec,
typename Tindex, Tindex Tmax>
113 template <
typename Tspec,
typename Tindex, Tindex Tmax>
117 return index < this->GetSpecCount() ? this->spec[index] :
nullptr;
127 template <
typename Tspec,
typename Tindex, Tindex Tmax>
131 for (
const auto &spec : cls.spec) {
132 if (spec ==
nullptr)
continue;
133 if (spec->grf_prop.local_id != local_id)
continue;
134 if ((spec->grf_prop.grffile ==
nullptr ? 0 : spec->grf_prop.grffile->grfid) == grfid)
return spec;