Skip to content

Commit

Permalink
Codechange: Use null pointer literal instead of the NULL macro
Browse files Browse the repository at this point in the history
  • Loading branch information
M3Henry authored and michicc committed Apr 10, 2019
1 parent 3b4f224 commit 7c8e7c6
Show file tree
Hide file tree
Showing 463 changed files with 5,674 additions and 5,674 deletions.
10 changes: 5 additions & 5 deletions src/ai/ai_config.cpp
Expand Up @@ -31,7 +31,7 @@ ScriptConfigItem _start_date_config = {
AI::START_NEXT_DEVIATION,
30,
SCRIPTCONFIG_NONE,
NULL,
nullptr,
false
};

Expand All @@ -52,7 +52,7 @@ AIConfig::AIConfig(const AIConfig *config) : ScriptConfig(config)
} else {
config = &_settings_game.ai_config[company];
}
if (*config == NULL) *config = new AIConfig();
if (*config == nullptr) *config = new AIConfig();
return *config;
}

Expand All @@ -69,7 +69,7 @@ ScriptInfo *AIConfig::FindInfo(const char *name, int version, bool force_exact_m
bool AIConfig::ResetInfo(bool force_exact_match)
{
this->info = (ScriptInfo *)AI::FindInfo(this->name, force_exact_match ? this->version : -1, force_exact_match);
return this->info != NULL;
return this->info != nullptr;
}

void AIConfig::PushExtraConfigList()
Expand All @@ -90,7 +90,7 @@ void AIConfig::ClearConfigList()

int AIConfig::GetSetting(const char *name) const
{
if (this->info == NULL) {
if (this->info == nullptr) {
SettingValueList::const_iterator it = this->settings.find(name);
if (it == this->settings.end()) {
assert(strcmp("start_date", name) == 0);
Expand All @@ -111,7 +111,7 @@ int AIConfig::GetSetting(const char *name) const

void AIConfig::SetSetting(const char *name, int value)
{
if (this->info == NULL) {
if (this->info == nullptr) {
if (strcmp("start_date", name) != 0) return;
value = Clamp(value, AI::START_NEXT_MIN, AI::START_NEXT_MAX);

Expand Down
42 changes: 21 additions & 21 deletions src/ai/ai_core.cpp
Expand Up @@ -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()
{
Expand All @@ -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);
}
Expand All @@ -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);

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();
Expand All @@ -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;
}
}
}
Expand All @@ -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
Expand All @@ -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);
}
}
}
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit 7c8e7c6

Please sign in to comment.