From 7c8e7c6b6e16d4a26259a676db32d8776b99817e Mon Sep 17 00:00:00 2001 From: Henry Wilson Date: Wed, 10 Apr 2019 22:07:06 +0100 Subject: Codechange: Use null pointer literal instead of the NULL macro --- src/ai/ai_core.cpp | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'src/ai/ai_core.cpp') 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 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 cur_company(_current_company, company, FILE_LINE); c->ai_instance->Load(version); -- cgit v1.2.3-54-g00ecf