summaryrefslogtreecommitdiff
path: root/src/ai/ai_core.cpp
diff options
context:
space:
mode:
authorHenry Wilson <m3henry@googlemail.com>2019-04-10 22:07:06 +0100
committerMichael Lutz <michi@icosahedron.de>2019-04-10 23:22:20 +0200
commit7c8e7c6b6e16d4a26259a676db32d8776b99817e (patch)
tree99f134b7e66367cf11e10bc5061896eab4a3264f /src/ai/ai_core.cpp
parent3b4f224c0bc50e7248050d4bcbb6d83fd510c1cc (diff)
downloadopenttd-7c8e7c6b6e16d4a26259a676db32d8776b99817e.tar.xz
Codechange: Use null pointer literal instead of the NULL macro
Diffstat (limited to 'src/ai/ai_core.cpp')
-rw-r--r--src/ai/ai_core.cpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp
index ff2fc286a..cc2eb42c8 100644
--- a/src/ai/ai_core.cpp
+++ b/src/ai/ai_core.cpp
@@ -26,8 +26,8 @@
#include "../safeguards.h"
/* static */ uint AI::frame_counter = 0;
-/* static */ AIScannerInfo *AI::scanner_info = NULL;
-/* static */ AIScannerLibrary *AI::scanner_library = NULL;
+/* static */ AIScannerInfo *AI::scanner_info = nullptr;
+/* static */ AIScannerLibrary *AI::scanner_library = nullptr;
/* static */ bool AI::CanStartNew()
{
@@ -44,9 +44,9 @@
AIConfig *config = AIConfig::GetConfig(company, AIConfig::SSS_FORCE_GAME);
AIInfo *info = config->GetInfo();
- if (info == NULL || (rerandomise_ai && config->IsRandom())) {
+ if (info == nullptr || (rerandomise_ai && config->IsRandom())) {
info = AI::scanner_info->SelectRandomAI();
- assert(info != NULL);
+ assert(info != nullptr);
/* Load default data and store the name in the settings */
config->Change(info->GetName(), -1, false, true);
}
@@ -56,7 +56,7 @@
Company *c = Company::Get(company);
c->ai_info = info;
- assert(c->ai_instance == NULL);
+ assert(c->ai_instance == nullptr);
c->ai_instance = new AIInstance();
c->ai_instance->Initialize(info);
@@ -111,8 +111,8 @@
Company *c = Company::Get(company);
delete c->ai_instance;
- c->ai_instance = NULL;
- c->ai_info = NULL;
+ c->ai_instance = nullptr;
+ c->ai_info = nullptr;
cur_company.Restore();
@@ -164,10 +164,10 @@
/* static */ void AI::Initialize()
{
- if (AI::scanner_info != NULL) AI::Uninitialize(true);
+ if (AI::scanner_info != nullptr) AI::Uninitialize(true);
AI::frame_counter = 0;
- if (AI::scanner_info == NULL) {
+ if (AI::scanner_info == nullptr) {
TarScanner::DoScan(TarScanner::AI);
AI::scanner_info = new AIScannerInfo();
AI::scanner_info->Initialize();
@@ -187,17 +187,17 @@
} else {
delete AI::scanner_info;
delete AI::scanner_library;
- AI::scanner_info = NULL;
- AI::scanner_library = NULL;
+ AI::scanner_info = nullptr;
+ AI::scanner_library = nullptr;
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
- if (_settings_game.ai_config[c] != NULL) {
+ if (_settings_game.ai_config[c] != nullptr) {
delete _settings_game.ai_config[c];
- _settings_game.ai_config[c] = NULL;
+ _settings_game.ai_config[c] = nullptr;
}
- if (_settings_newgame.ai_config[c] != NULL) {
+ if (_settings_newgame.ai_config[c] != nullptr) {
delete _settings_newgame.ai_config[c];
- _settings_newgame.ai_config[c] = NULL;
+ _settings_newgame.ai_config[c] = nullptr;
}
}
}
@@ -209,10 +209,10 @@
* the AIConfig. If not, remove the AI from the list (which will assign
* a random new AI on reload). */
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
- if (_settings_game.ai_config[c] != NULL && _settings_game.ai_config[c]->HasScript()) {
+ if (_settings_game.ai_config[c] != nullptr && _settings_game.ai_config[c]->HasScript()) {
if (!_settings_game.ai_config[c]->ResetInfo(true)) {
DEBUG(script, 0, "After a reload, the AI by the name '%s' was no longer found, and removed from the list.", _settings_game.ai_config[c]->GetName());
- _settings_game.ai_config[c]->Change(NULL);
+ _settings_game.ai_config[c]->Change(nullptr);
if (Company::IsValidAiID(c)) {
/* The code belonging to an already running AI was deleted. We can only do
* one thing here to keep everything sane and that is kill the AI. After
@@ -226,10 +226,10 @@
Company::Get(c)->ai_info = _settings_game.ai_config[c]->GetInfo();
}
}
- if (_settings_newgame.ai_config[c] != NULL && _settings_newgame.ai_config[c]->HasScript()) {
+ if (_settings_newgame.ai_config[c] != nullptr && _settings_newgame.ai_config[c]->HasScript()) {
if (!_settings_newgame.ai_config[c]->ResetInfo(false)) {
DEBUG(script, 0, "After a reload, the AI by the name '%s' was no longer found, and removed from the list.", _settings_newgame.ai_config[c]->GetName());
- _settings_newgame.ai_config[c]->Change(NULL);
+ _settings_newgame.ai_config[c]->Change(nullptr);
}
}
}
@@ -283,7 +283,7 @@
{
if (!_networking || _network_server) {
Company *c = Company::GetIfValid(company);
- assert(c != NULL && c->ai_instance != NULL);
+ assert(c != nullptr && c->ai_instance != nullptr);
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
c->ai_instance->Save();
@@ -297,7 +297,7 @@
{
if (!_networking || _network_server) {
Company *c = Company::GetIfValid(company);
- assert(c != NULL && c->ai_instance != NULL);
+ assert(c != nullptr && c->ai_instance != nullptr);
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
c->ai_instance->Load(version);