summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2019-12-14 17:22:38 +0100
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-12-21 20:13:03 +0100
commit3a14cea068d130e11b5d9dde11d4451dd7dec453 (patch)
tree7afd5a1160872aeba8a630c2915a8168cbc483dd /src/ai
parent68f22134cb35267d6fa01134a385d3854fda1787 (diff)
downloadopenttd-3a14cea068d130e11b5d9dde11d4451dd7dec453.tar.xz
Codechange: Replace FOR_ALL_COMPANIES with range-based for loops
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/ai_core.cpp6
-rw-r--r--src/ai/ai_gui.cpp9
2 files changed, 5 insertions, 10 deletions
diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp
index 459a3ead4..95c971af8 100644
--- a/src/ai/ai_core.cpp
+++ b/src/ai/ai_core.cpp
@@ -75,8 +75,7 @@
if ((AI::frame_counter & ((1 << (4 - _settings_game.difficulty.competitor_speed)) - 1)) != 0) return;
Backup<CompanyID> cur_company(_current_company, FILE_LINE);
- const Company *c;
- FOR_ALL_COMPANIES(c) {
+ for (const Company *c : Company::Iterate()) {
if (c->is_ai) {
PerformanceMeasurer framerate((PerformanceElement)(PFE_AI0 + c->index));
cur_company.Change(c->index);
@@ -154,8 +153,7 @@
/* It might happen there are no companies .. than we have nothing to loop */
if (Company::GetPoolSize() == 0) return;
- const Company *c;
- FOR_ALL_COMPANIES(c) {
+ for (const Company *c : Company::Iterate()) {
if (c->is_ai) AI::Stop(c->index);
}
}
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index 25d34dee0..a684e4a35 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -1052,8 +1052,7 @@ struct AIDebugWindow : public Window {
ai_debug_company = INVALID_COMPANY;
- const Company *c;
- FOR_ALL_COMPANIES(c) {
+ for (const Company *c : Company::Iterate()) {
if (c->is_ai) {
ChangeToAI(c->index);
return;
@@ -1312,8 +1311,7 @@ struct AIDebugWindow : public Window {
if ((_pause_mode & PM_PAUSED_NORMAL) == PM_PAUSED_NORMAL) {
bool all_unpaused = !Game::IsPaused();
if (all_unpaused) {
- Company *c;
- FOR_ALL_COMPANIES(c) {
+ for (const Company *c : Company::Iterate()) {
if (c->is_ai && AI::IsPaused(c->index)) {
all_unpaused = false;
break;
@@ -1552,8 +1550,7 @@ void ShowAIDebugWindowIfAIError()
/* Network clients can't debug AIs. */
if (_networking && !_network_server) return;
- Company *c;
- FOR_ALL_COMPANIES(c) {
+ for (const Company *c : Company::Iterate()) {
if (c->is_ai && c->ai_instance->IsDead()) {
ShowAIDebugWindow(c->index);
break;