mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Replace linkgraph related FOR_ALL with range-based for loops
parent
00c2a98cf3
commit
09fa39c5b5
|
@ -210,8 +210,7 @@ static void OnNewYear()
|
||||||
_date -= days_this_year;
|
_date -= days_this_year;
|
||||||
FOR_ALL_VEHICLES(v) v->date_of_last_service -= days_this_year;
|
FOR_ALL_VEHICLES(v) v->date_of_last_service -= days_this_year;
|
||||||
|
|
||||||
LinkGraph *lg;
|
for (LinkGraph *lg : LinkGraph::Iterate()) lg->ShiftDates(-days_this_year);
|
||||||
FOR_ALL_LINK_GRAPHS(lg) lg->ShiftDates(-days_this_year);
|
|
||||||
|
|
||||||
/* Because the _date wraps here, and text-messages expire by game-days, we have to clean out
|
/* Because the _date wraps here, and text-messages expire by game-days, we have to clean out
|
||||||
* all of them if the date is set back, else those messages will hang for ever */
|
* all of them if the date is set back, else those messages will hang for ever */
|
||||||
|
|
|
@ -534,6 +534,4 @@ protected:
|
||||||
EdgeMatrix edges; ///< Edges in the component.
|
EdgeMatrix edges; ///< Edges in the component.
|
||||||
};
|
};
|
||||||
|
|
||||||
#define FOR_ALL_LINK_GRAPHS(var) FOR_ALL_ITEMS_FROM(LinkGraph, link_graph_index, var, 0)
|
|
||||||
|
|
||||||
#endif /* LINKGRAPH_H */
|
#endif /* LINKGRAPH_H */
|
||||||
|
|
|
@ -334,8 +334,6 @@ public:
|
||||||
inline const LinkGraph &Graph() const { return this->link_graph; }
|
inline const LinkGraph &Graph() const { return this->link_graph; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#define FOR_ALL_LINK_GRAPH_JOBS(var) FOR_ALL_ITEMS_FROM(LinkGraphJob, link_graph_job_index, var, 0)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A leg of a path in the link graph. Paths can form trees by being "forked".
|
* A leg of a path in the link graph. Paths can form trees by being "forked".
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -107,10 +107,8 @@ void LinkGraphSchedule::SpawnAll()
|
||||||
*/
|
*/
|
||||||
void LinkGraphSchedule::ShiftDates(int interval)
|
void LinkGraphSchedule::ShiftDates(int interval)
|
||||||
{
|
{
|
||||||
LinkGraph *lg;
|
for (LinkGraph *lg : LinkGraph::Iterate()) lg->ShiftDates(interval);
|
||||||
FOR_ALL_LINK_GRAPHS(lg) lg->ShiftDates(interval);
|
for (LinkGraphJob *lgj : LinkGraphJob::Iterate()) lgj->ShiftJoinDate(interval);
|
||||||
LinkGraphJob *lgj;
|
|
||||||
FOR_ALL_LINK_GRAPH_JOBS(lgj) lgj->ShiftJoinDate(interval);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -228,17 +228,15 @@ static void Load_LGRS()
|
||||||
void AfterLoadLinkGraphs()
|
void AfterLoadLinkGraphs()
|
||||||
{
|
{
|
||||||
if (IsSavegameVersionBefore(SLV_191)) {
|
if (IsSavegameVersionBefore(SLV_191)) {
|
||||||
LinkGraph *lg;
|
for (LinkGraph *lg : LinkGraph::Iterate()) {
|
||||||
FOR_ALL_LINK_GRAPHS(lg) {
|
|
||||||
for (NodeID node_id = 0; node_id < lg->Size(); ++node_id) {
|
for (NodeID node_id = 0; node_id < lg->Size(); ++node_id) {
|
||||||
const Station *st = Station::GetIfValid((*lg)[node_id].Station());
|
const Station *st = Station::GetIfValid((*lg)[node_id].Station());
|
||||||
if (st != nullptr) (*lg)[node_id].UpdateLocation(st->xy);
|
if (st != nullptr) (*lg)[node_id].UpdateLocation(st->xy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LinkGraphJob *lgj;
|
for (LinkGraphJob *lgj : LinkGraphJob::Iterate()) {
|
||||||
FOR_ALL_LINK_GRAPH_JOBS(lgj) {
|
LinkGraph *lg = &(const_cast<LinkGraph &>(lgj->Graph()));
|
||||||
lg = &(const_cast<LinkGraph &>(lgj->Graph()));
|
|
||||||
for (NodeID node_id = 0; node_id < lg->Size(); ++node_id) {
|
for (NodeID node_id = 0; node_id < lg->Size(); ++node_id) {
|
||||||
const Station *st = Station::GetIfValid((*lg)[node_id].Station());
|
const Station *st = Station::GetIfValid((*lg)[node_id].Station());
|
||||||
if (st != nullptr) (*lg)[node_id].UpdateLocation(st->xy);
|
if (st != nullptr) (*lg)[node_id].UpdateLocation(st->xy);
|
||||||
|
@ -254,8 +252,7 @@ void AfterLoadLinkGraphs()
|
||||||
*/
|
*/
|
||||||
static void Save_LGRP()
|
static void Save_LGRP()
|
||||||
{
|
{
|
||||||
LinkGraph *lg;
|
for (LinkGraph *lg : LinkGraph::Iterate()) {
|
||||||
FOR_ALL_LINK_GRAPHS(lg) {
|
|
||||||
SlSetArrayIndex(lg->index);
|
SlSetArrayIndex(lg->index);
|
||||||
SlAutolength((AutolengthProc*)DoSave_LGRP, lg);
|
SlAutolength((AutolengthProc*)DoSave_LGRP, lg);
|
||||||
}
|
}
|
||||||
|
@ -266,8 +263,7 @@ static void Save_LGRP()
|
||||||
*/
|
*/
|
||||||
static void Save_LGRJ()
|
static void Save_LGRJ()
|
||||||
{
|
{
|
||||||
LinkGraphJob *lgj;
|
for (LinkGraphJob *lgj : LinkGraphJob::Iterate()) {
|
||||||
FOR_ALL_LINK_GRAPH_JOBS(lgj) {
|
|
||||||
SlSetArrayIndex(lgj->index);
|
SlSetArrayIndex(lgj->index);
|
||||||
SlAutolength((AutolengthProc*)DoSave_LGRJ, lgj);
|
SlAutolength((AutolengthProc*)DoSave_LGRJ, lgj);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue