mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: Replaced SmallVector::Get() const with std alternatives
This commit is contained in:
parent
aa7ca7fe64
commit
097328c3d7
|
@ -113,11 +113,11 @@ private:
|
|||
void BuildBridge(uint8 i)
|
||||
{
|
||||
switch ((TransportType)(this->type >> 15)) {
|
||||
case TRANSPORT_RAIL: _last_railbridge_type = this->bridges->Get(i)->index; break;
|
||||
case TRANSPORT_ROAD: _last_roadbridge_type = this->bridges->Get(i)->index; break;
|
||||
case TRANSPORT_RAIL: _last_railbridge_type = this->bridges->at(i).index; break;
|
||||
case TRANSPORT_ROAD: _last_roadbridge_type = this->bridges->at(i).index; break;
|
||||
default: break;
|
||||
}
|
||||
DoCommandP(this->end_tile, this->start_tile, this->type | this->bridges->Get(i)->index,
|
||||
DoCommandP(this->end_tile, this->start_tile, this->type | this->bridges->at(i).index,
|
||||
CMD_BUILD_BRIDGE | CMD_MSG(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE), CcBuildBridge);
|
||||
}
|
||||
|
||||
|
@ -187,10 +187,10 @@ public:
|
|||
Dimension sprite_dim = {0, 0}; // Biggest bridge sprite dimension
|
||||
Dimension text_dim = {0, 0}; // Biggest text dimension
|
||||
for (int i = 0; i < (int)this->bridges->size(); i++) {
|
||||
const BridgeSpec *b = this->bridges->Get(i)->spec;
|
||||
const BridgeSpec *b = this->bridges->at(i).spec;
|
||||
sprite_dim = maxdim(sprite_dim, GetSpriteSize(b->sprite));
|
||||
|
||||
SetDParam(2, this->bridges->Get(i)->cost);
|
||||
SetDParam(2, this->bridges->at(i).cost);
|
||||
SetDParam(1, b->speed);
|
||||
SetDParam(0, b->material);
|
||||
text_dim = maxdim(text_dim, GetStringBoundingBox(_game_mode == GM_EDITOR ? STR_SELECT_BRIDGE_SCENEDIT_INFO : STR_SELECT_BRIDGE_INFO));
|
||||
|
@ -227,9 +227,9 @@ public:
|
|||
case WID_BBS_BRIDGE_LIST: {
|
||||
uint y = r.top;
|
||||
for (int i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < (int)this->bridges->size(); i++) {
|
||||
const BridgeSpec *b = this->bridges->Get(i)->spec;
|
||||
const BridgeSpec *b = this->bridges->at(i).spec;
|
||||
|
||||
SetDParam(2, this->bridges->Get(i)->cost);
|
||||
SetDParam(2, this->bridges->at(i).cost);
|
||||
SetDParam(1, b->speed);
|
||||
SetDParam(0, b->material);
|
||||
|
||||
|
|
|
@ -167,19 +167,6 @@ public:
|
|||
{
|
||||
return std::vector<T>::data() + std::vector<T>::size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pointer to item "number" (const)
|
||||
*
|
||||
* @param index the position of the item
|
||||
* @return the pointer to the item
|
||||
*/
|
||||
inline const T *Get(uint index) const
|
||||
{
|
||||
/* Allow access to the 'first invalid' item */
|
||||
assert(index <= std::vector<T>::size());
|
||||
return this->Begin() + index;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ public:
|
|||
*/
|
||||
inline const FiosItem *Get(uint index) const
|
||||
{
|
||||
return this->files.Get(index);
|
||||
return this->files.data() + index;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -158,7 +158,7 @@ public:
|
|||
int GetLeading() const { return l->getLeading(); }
|
||||
int GetWidth() const { return l->getWidth(); }
|
||||
int CountRuns() const { return l->countRuns(); }
|
||||
const ParagraphLayouter::VisualRun *GetVisualRun(int run) const { return *this->Get(run); }
|
||||
const ParagraphLayouter::VisualRun *GetVisualRun(int run) const { return this->at(run); }
|
||||
|
||||
int GetInternalCharLength(WChar c) const
|
||||
{
|
||||
|
@ -458,7 +458,7 @@ int FallbackParagraphLayout::FallbackLine::CountRuns() const
|
|||
*/
|
||||
const ParagraphLayouter::VisualRun *FallbackParagraphLayout::FallbackLine::GetVisualRun(int run) const
|
||||
{
|
||||
return *this->Get(run);
|
||||
return this->at(run);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -133,7 +133,7 @@ public:
|
|||
/** Get the begin of the content inf iterator. */
|
||||
ConstContentIterator Begin() const { return this->infos.Begin(); }
|
||||
/** Get the nth position of the content inf iterator. */
|
||||
ConstContentIterator Get(uint32 index) const { return this->infos.Get(index); }
|
||||
ConstContentIterator Get(uint32 index) const { return this->infos.data() + index; }
|
||||
/** Get the end of the content inf iterator. */
|
||||
ConstContentIterator End() const { return this->infos.End(); }
|
||||
|
||||
|
|
|
@ -641,7 +641,7 @@ public:
|
|||
int text_y_offset = WD_MATRIX_TOP + (line_height - FONT_HEIGHT_NORMAL) / 2;
|
||||
uint y = r.top;
|
||||
int cnt = 0;
|
||||
for (ConstContentIterator iter = this->content.Get(this->vscroll->GetPosition()); iter != this->content.End() && cnt < this->vscroll->GetCapacity(); iter++, cnt++) {
|
||||
for (ConstContentIterator iter = this->content.data() + this->vscroll->GetPosition(); iter != this->content.End() && cnt < this->vscroll->GetCapacity(); iter++, cnt++) {
|
||||
const ContentInfo *ci = *iter;
|
||||
|
||||
if (ci == this->selected) GfxFillRect(r.left + 1, y + 1, r.right - 1, y + this->resize.step_height - 1, PC_GREY);
|
||||
|
@ -793,7 +793,7 @@ public:
|
|||
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_NCL_MATRIX);
|
||||
if (id_v >= this->content.size()) return; // click out of bounds
|
||||
|
||||
this->selected = *this->content.Get(id_v);
|
||||
this->selected = this->content[id_v];
|
||||
this->list_pos = id_v;
|
||||
|
||||
const NWidgetBase *checkbox = this->GetWidget<NWidgetBase>(WID_NCL_CHECKBOX);
|
||||
|
@ -923,7 +923,7 @@ public:
|
|||
return ES_HANDLED;
|
||||
}
|
||||
|
||||
this->selected = *this->content.Get(this->list_pos);
|
||||
this->selected = this->content[this->list_pos];
|
||||
|
||||
if (this->UpdateFilterState()) {
|
||||
this->content.ForceRebuild();
|
||||
|
|
|
@ -1209,17 +1209,17 @@ void AlterVehicleListOrder(EngineID engine, uint target)
|
|||
*/
|
||||
static int CDECL EnginePreSort(const EngineID *a, const EngineID *b)
|
||||
{
|
||||
const EngineIDMapping *id_a = _engine_mngr.Get(*a);
|
||||
const EngineIDMapping *id_b = _engine_mngr.Get(*b);
|
||||
const EngineIDMapping &id_a = _engine_mngr.at(*a);
|
||||
const EngineIDMapping &id_b = _engine_mngr.at(*b);
|
||||
|
||||
/* 1. Sort by engine type */
|
||||
if (id_a->type != id_b->type) return (int)id_a->type - (int)id_b->type;
|
||||
if (id_a.type != id_b.type) return (int)id_a.type - (int)id_b.type;
|
||||
|
||||
/* 2. Sort by scope-GRFID */
|
||||
if (id_a->grfid != id_b->grfid) return id_a->grfid < id_b->grfid ? -1 : 1;
|
||||
if (id_a.grfid != id_b.grfid) return id_a.grfid < id_b.grfid ? -1 : 1;
|
||||
|
||||
/* 3. Sort by local ID */
|
||||
return (int)id_a->internal_id - (int)id_b->internal_id;
|
||||
return (int)id_a.internal_id - (int)id_b.internal_id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1241,7 +1241,7 @@ void CommitVehicleListOrderChanges()
|
|||
EngineID source = it->engine;
|
||||
uint local_target = it->target;
|
||||
|
||||
const EngineIDMapping *id_source = _engine_mngr.Get(source);
|
||||
const EngineIDMapping *id_source = _engine_mngr.data() + source;
|
||||
if (id_source->internal_id == local_target) continue;
|
||||
|
||||
EngineID target = _engine_mngr.GetID(id_source->type, local_target, id_source->grfid);
|
||||
|
|
|
@ -1186,7 +1186,7 @@ static void CheckCaches()
|
|||
|
||||
uint i = 0;
|
||||
FOR_ALL_TOWNS(t) {
|
||||
if (MemCmpT(old_town_caches.Get(i), &t->cache) != 0) {
|
||||
if (MemCmpT(old_town_caches.data() + i, &t->cache) != 0) {
|
||||
DEBUG(desync, 2, "town cache mismatch: town %i", (int)t->index);
|
||||
}
|
||||
i++;
|
||||
|
@ -1202,7 +1202,7 @@ static void CheckCaches()
|
|||
|
||||
i = 0;
|
||||
FOR_ALL_COMPANIES(c) {
|
||||
if (MemCmpT(old_infrastructure.Get(i), &c->infrastructure) != 0) {
|
||||
if (MemCmpT(old_infrastructure.data() + i, &c->infrastructure) != 0) {
|
||||
DEBUG(desync, 2, "infrastructure cache mismatch: company %i", (int)c->index);
|
||||
}
|
||||
i++;
|
||||
|
|
|
@ -86,7 +86,7 @@ public:
|
|||
virtual int GetLeading() const;
|
||||
virtual int GetWidth() const;
|
||||
virtual int CountRuns() const { return this->size(); }
|
||||
virtual const VisualRun *GetVisualRun(int run) const { return *this->Get(run); }
|
||||
virtual const VisualRun *GetVisualRun(int run) const { return this->at(run); }
|
||||
|
||||
int GetInternalCharLength(WChar c) const
|
||||
{
|
||||
|
|
|
@ -111,7 +111,7 @@ public:
|
|||
virtual int GetLeading() const;
|
||||
virtual int GetWidth() const;
|
||||
virtual int CountRuns() const { return this->size(); }
|
||||
virtual const VisualRun *GetVisualRun(int run) const { return *this->Get(run); }
|
||||
virtual const VisualRun *GetVisualRun(int run) const { return this->at(run); }
|
||||
|
||||
int GetInternalCharLength(WChar c) const
|
||||
{
|
||||
|
|
|
@ -1468,7 +1468,7 @@ static void ViewportDrawParentSprites(const ParentSpriteToSortVector *psd, const
|
|||
|
||||
int child_idx = ps->first_child;
|
||||
while (child_idx >= 0) {
|
||||
const ChildScreenSpriteToDraw *cs = csstdv->Get(child_idx);
|
||||
const ChildScreenSpriteToDraw *cs = csstdv->data() + child_idx;
|
||||
child_idx = cs->next;
|
||||
DrawSpriteViewport(cs->image, cs->pal, ps->left + cs->x, ps->top + cs->y, cs->sub);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue