diff options
Diffstat (limited to 'src/ai')
-rw-r--r-- | src/ai/ai_config.cpp | 10 | ||||
-rw-r--r-- | src/ai/ai_core.cpp | 42 | ||||
-rw-r--r-- | src/ai/ai_gui.cpp | 60 | ||||
-rw-r--r-- | src/ai/ai_info.cpp | 12 | ||||
-rw-r--r-- | src/ai/ai_info.hpp | 2 | ||||
-rw-r--r-- | src/ai/ai_instance.cpp | 6 | ||||
-rw-r--r-- | src/ai/ai_scanner.cpp | 12 | ||||
-rw-r--r-- | src/ai/ai_scanner.hpp | 4 |
8 files changed, 74 insertions, 74 deletions
diff --git a/src/ai/ai_config.cpp b/src/ai/ai_config.cpp index a78281478..93db57158 100644 --- a/src/ai/ai_config.cpp +++ b/src/ai/ai_config.cpp @@ -31,7 +31,7 @@ ScriptConfigItem _start_date_config = { AI::START_NEXT_DEVIATION, 30, SCRIPTCONFIG_NONE, - NULL, + nullptr, false }; @@ -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; } @@ -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() @@ -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); @@ -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); 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); diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index eaf2a9d83..4932c0f61 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -139,13 +139,13 @@ struct AIListWindow : public Window { break; } case WID_AIL_INFO_BG: { - AIInfo *selected_info = NULL; + AIInfo *selected_info = nullptr; ScriptInfoList::const_iterator it = this->info_list->begin(); - for (int i = 1; selected_info == NULL && it != this->info_list->end(); i++, it++) { + for (int i = 1; selected_info == nullptr && it != this->info_list->end(); i++, it++) { if (this->selected == i - 1) selected_info = static_cast<AIInfo *>((*it).second); } /* Some info about the currently selected AI. */ - if (selected_info != NULL) { + if (selected_info != nullptr) { int y = r.top + WD_FRAMERECT_TOP; SetDParamStr(0, selected_info->GetAuthor()); DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, y, STR_AI_LIST_AUTHOR); @@ -153,7 +153,7 @@ struct AIListWindow : public Window { SetDParam(0, selected_info->GetVersion()); DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, y, STR_AI_LIST_VERSION); y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL; - if (selected_info->GetURL() != NULL) { + if (selected_info->GetURL() != nullptr) { SetDParamStr(0, selected_info->GetURL()); DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, y, STR_AI_LIST_URL); y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL; @@ -172,7 +172,7 @@ struct AIListWindow : public Window { void ChangeAI() { if (this->selected == -1) { - GetConfig(slot)->Change(NULL); + GetConfig(slot)->Change(nullptr); } else { ScriptInfoList::const_iterator it = this->info_list->begin(); for (int i = 0; i < this->selected; i++) it++; @@ -407,7 +407,7 @@ struct AISettingsWindow : public Window { } else { DrawArrowButtons(buttons_left, y + button_y_offset, COLOUR_YELLOW, (this->clicked_button == i) ? 1 + (this->clicked_increase != rtl) : 0, editable && current_value > config_item.min_value, editable && current_value < config_item.max_value); } - if (config_item.labels != NULL && config_item.labels->Contains(current_value)) { + if (config_item.labels != nullptr && config_item.labels->Contains(current_value)) { SetDParam(idx++, STR_JUST_RAW_STRING); SetDParamStr(idx++, config_item.labels->Find(current_value)->second); } else { @@ -805,7 +805,7 @@ struct AIConfigWindow : public Window { */ static bool IsEditable(CompanyID slot) { - if (slot == OWNER_DEITY) return _game_mode != GM_NORMAL || Game::GetInstance() != NULL; + if (slot == OWNER_DEITY) return _game_mode != GM_NORMAL || Game::GetInstance() != nullptr; if (_game_mode != GM_NORMAL) { return slot > 0 && slot <= GetGameSettings().difficulty.max_no_competitors; @@ -825,7 +825,7 @@ struct AIConfigWindow : public Window { case WID_AIC_GAMELIST: { StringID text = STR_AI_CONFIG_NONE; - if (GameConfig::GetConfig()->GetInfo() != NULL) { + if (GameConfig::GetConfig()->GetInfo() != nullptr) { SetDParamStr(0, GameConfig::GetConfig()->GetInfo()->GetName()); text = STR_JUST_RAW_STRING; } @@ -843,7 +843,7 @@ struct AIConfigWindow : public Window { if ((_game_mode != GM_NORMAL && i == 0) || (_game_mode == GM_NORMAL && Company::IsValidHumanID(i))) { text = STR_AI_CONFIG_HUMAN_PLAYER; - } else if (AIConfig::GetConfig((CompanyID)i)->GetInfo() != NULL) { + } else if (AIConfig::GetConfig((CompanyID)i)->GetInfo() != nullptr) { SetDParamStr(0, AIConfig::GetConfig((CompanyID)i)->GetInfo()->GetName()); text = STR_JUST_RAW_STRING; } else { @@ -861,7 +861,7 @@ struct AIConfigWindow : public Window { void OnClick(Point pt, int widget, int click_count) override { if (widget >= WID_AIC_TEXTFILE && widget < WID_AIC_TEXTFILE + TFT_END) { - if (this->selected_slot == INVALID_COMPANY || GetConfig(this->selected_slot) == NULL) return; + if (this->selected_slot == INVALID_COMPANY || GetConfig(this->selected_slot) == nullptr) return; ShowScriptTextfileWindow((TextfileType)(widget - WID_AIC_TEXTFILE), this->selected_slot); return; @@ -928,7 +928,7 @@ struct AIConfigWindow : public Window { if (!_network_available) { ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR); } else { - ShowNetworkContentListWindow(NULL, CONTENT_TYPE_AI, CONTENT_TYPE_GAME); + ShowNetworkContentListWindow(nullptr, CONTENT_TYPE_AI, CONTENT_TYPE_GAME); } break; } @@ -955,7 +955,7 @@ struct AIConfigWindow : public Window { this->SetWidgetDisabledState(WID_AIC_MOVE_DOWN, this->selected_slot == OWNER_DEITY || this->selected_slot == INVALID_COMPANY || !IsEditable((CompanyID)(this->selected_slot + 1))); for (TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) { - this->SetWidgetDisabledState(WID_AIC_TEXTFILE + tft, this->selected_slot == INVALID_COMPANY || (GetConfig(this->selected_slot)->GetTextfile(tft, this->selected_slot) == NULL)); + this->SetWidgetDisabledState(WID_AIC_TEXTFILE + tft, this->selected_slot == INVALID_COMPANY || (GetConfig(this->selected_slot)->GetTextfile(tft, this->selected_slot) == nullptr)); } } }; @@ -1024,7 +1024,7 @@ struct AIDebugWindow : public Window { { if (ai_debug_company == OWNER_DEITY) { GameInstance *game = Game::GetInstance(); - return game == NULL || game->IsDead(); + return game == nullptr || game->IsDead(); } return !Company::IsValidAiID(ai_debug_company) || Company::Get(ai_debug_company)->ai_instance->IsDead(); } @@ -1038,7 +1038,7 @@ struct AIDebugWindow : public Window { { switch (company) { case INVALID_COMPANY: return false; - case OWNER_DEITY: return Game::GetInstance() != NULL; + case OWNER_DEITY: return Game::GetInstance() != nullptr; default: return Company::IsValidAiID(company); } } @@ -1063,7 +1063,7 @@ struct AIDebugWindow : public Window { } /* If no AI is available, see if there is a game script. */ - if (Game::GetInstance() != NULL) ChangeToAI(OWNER_DEITY); + if (Game::GetInstance() != nullptr) ChangeToAI(OWNER_DEITY); } /** @@ -1140,7 +1140,7 @@ struct AIDebugWindow : public Window { /* Set button colour for Game Script. */ GameInstance *game = Game::GetInstance(); - bool valid = game != NULL; + bool valid = game != nullptr; bool dead = valid && game->IsDead(); bool paused = valid && game->IsPaused(); @@ -1154,7 +1154,7 @@ struct AIDebugWindow : public Window { ScriptLog::LogData *log = this->GetLogPointer(); - int scroll_count = (log == NULL) ? 0 : log->used; + int scroll_count = (log == nullptr) ? 0 : log->used; if (this->vscroll->GetCount() != scroll_count) { this->vscroll->SetCount(scroll_count); @@ -1162,7 +1162,7 @@ struct AIDebugWindow : public Window { this->SetWidgetDirty(WID_AID_SCROLLBAR); } - if (log == NULL) return; + if (log == nullptr) return; /* Detect when the user scrolls the window. Enable autoscroll when the * bottom-most line becomes visible. */ @@ -1188,7 +1188,7 @@ struct AIDebugWindow : public Window { case WID_AID_NAME_TEXT: if (ai_debug_company == OWNER_DEITY) { const GameInfo *info = Game::GetInfo(); - assert(info != NULL); + assert(info != nullptr); SetDParam(0, STR_AI_DEBUG_NAME_AND_VERSION); SetDParamStr(1, info->GetName()); SetDParam(2, info->GetVersion()); @@ -1196,7 +1196,7 @@ struct AIDebugWindow : public Window { SetDParam(0, STR_EMPTY); } else { const AIInfo *info = Company::Get(ai_debug_company)->ai_info; - assert(info != NULL); + assert(info != nullptr); SetDParam(0, STR_AI_DEBUG_NAME_AND_VERSION); SetDParamStr(1, info->GetName()); SetDParam(2, info->GetVersion()); @@ -1212,12 +1212,12 @@ struct AIDebugWindow : public Window { switch (widget) { case WID_AID_LOG_PANEL: { ScriptLog::LogData *log = this->GetLogPointer(); - if (log == NULL) return; + if (log == nullptr) return; int y = this->top_offset; for (int i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < log->used; i++) { int pos = (i + log->pos + 1 - log->used + log->count) % log->count; - if (log->lines[pos] == NULL) break; + if (log->lines[pos] == nullptr) break; TextColour colour; switch (log->type[pos]) { @@ -1357,7 +1357,7 @@ struct AIDebugWindow : public Window { /* Get the log instance of the active company */ ScriptLog::LogData *log = this->GetLogPointer(); - if (log != NULL) { + if (log != nullptr) { this->break_string_filter.ResetState(); this->break_string_filter.AddLine(log->lines[log->pos]); if (this->break_string_filter.GetState()) { @@ -1385,8 +1385,8 @@ struct AIDebugWindow : public Window { this->SelectValidDebugCompany(); - ScriptLog::LogData *log = ai_debug_company != INVALID_COMPANY ? this->GetLogPointer() : NULL; - this->vscroll->SetCount((log == NULL) ? 0 : log->used); + ScriptLog::LogData *log = ai_debug_company != INVALID_COMPANY ? this->GetLogPointer() : nullptr; + this->vscroll->SetCount((log == nullptr) ? 0 : log->used); /* Update company buttons */ for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) { @@ -1394,7 +1394,7 @@ struct AIDebugWindow : public Window { this->SetWidgetLoweredState(i + WID_AID_COMPANY_BUTTON_START, ai_debug_company == i); } - this->SetWidgetDisabledState(WID_AID_SCRIPT_GAME, Game::GetGameInstance() == NULL); + this->SetWidgetDisabledState(WID_AID_SCRIPT_GAME, Game::GetGameInstance() == nullptr); this->SetWidgetLoweredState(WID_AID_SCRIPT_GAME, ai_debug_company == OWNER_DEITY); this->SetWidgetLoweredState(WID_AID_BREAK_STR_ON_OFF_BTN, this->break_check_enabled); @@ -1437,7 +1437,7 @@ static EventState AIDebugGlobalHotkeys(int hotkey) { if (_game_mode != GM_NORMAL) return ES_NOT_HANDLED; Window *w = ShowAIDebugWindow(INVALID_COMPANY); - if (w == NULL) return ES_NOT_HANDLED; + if (w == nullptr) return ES_NOT_HANDLED; return w->OnHotkey(hotkey); } @@ -1530,14 +1530,14 @@ Window *ShowAIDebugWindow(CompanyID show_company) { if (!_networking || _network_server) { AIDebugWindow *w = (AIDebugWindow *)BringWindowToFrontById(WC_AI_DEBUG, 0); - if (w == NULL) w = new AIDebugWindow(&_ai_debug_desc, 0); + if (w == nullptr) w = new AIDebugWindow(&_ai_debug_desc, 0); if (show_company != INVALID_COMPANY) w->ChangeToAI(show_company); return w; } else { ShowErrorMessage(STR_ERROR_AI_DEBUG_SERVER_ONLY, INVALID_STRING_ID, WL_INFO); } - return NULL; + return nullptr; } /** @@ -1563,7 +1563,7 @@ void ShowAIDebugWindowIfAIError() } GameInstance *g = Game::GetGameInstance(); - if (g != NULL && g->IsDead()) { + if (g != nullptr && g->IsDead()) { ShowAIDebugWindow(OWNER_DEITY); } } diff --git a/src/ai/ai_info.cpp b/src/ai/ai_info.cpp index 62ddb2344..af7ae5729 100644 --- a/src/ai/ai_info.cpp +++ b/src/ai/ai_info.cpp @@ -65,8 +65,8 @@ template <> const char *GetClassName<AIInfo, ST_AI>() { return "AIInfo"; } /* static */ SQInteger AIInfo::Constructor(HSQUIRRELVM vm) { /* Get the AIInfo */ - SQUserPointer instance = NULL; - if (SQ_FAILED(sq_getinstanceup(vm, 2, &instance, 0)) || instance == NULL) return sq_throwerror(vm, "Pass an instance of a child class of AIInfo to RegisterAI"); + SQUserPointer instance = nullptr; + if (SQ_FAILED(sq_getinstanceup(vm, 2, &instance, 0)) || instance == nullptr) return sq_throwerror(vm, "Pass an instance of a child class of AIInfo to RegisterAI"); AIInfo *info = (AIInfo *)instance; SQInteger res = ScriptInfo::Constructor(vm, info); @@ -100,7 +100,7 @@ template <> const char *GetClassName<AIInfo, ST_AI>() { return "AIInfo"; } } /* Remove the link to the real instance, else it might get deleted by RegisterAI() */ - sq_setinstanceup(vm, 2, NULL); + sq_setinstanceup(vm, 2, nullptr); /* Register the AI to the base system */ info->GetScanner()->RegisterScript(info); return 0; @@ -112,7 +112,7 @@ template <> const char *GetClassName<AIInfo, ST_AI>() { return "AIInfo"; } SQUserPointer instance; sq_getinstanceup(vm, 2, &instance, 0); AIInfo *info = (AIInfo *)instance; - info->api_version = NULL; + info->api_version = nullptr; SQInteger res = ScriptInfo::Constructor(vm, info); if (res != 0) return res; @@ -122,7 +122,7 @@ template <> const char *GetClassName<AIInfo, ST_AI>() { return "AIInfo"; } info->api_version = stredup(buf); /* Remove the link to the real instance, else it might get deleted by RegisterAI() */ - sq_setinstanceup(vm, 2, NULL); + sq_setinstanceup(vm, 2, nullptr); /* Register the AI to the base system */ static_cast<AIScannerInfo *>(info->GetScanner())->SetDummyAI(info); return 0; @@ -131,7 +131,7 @@ template <> const char *GetClassName<AIInfo, ST_AI>() { return "AIInfo"; } AIInfo::AIInfo() : min_loadable_version(0), use_as_random(false), - api_version(NULL) + api_version(nullptr) { } diff --git a/src/ai/ai_info.hpp b/src/ai/ai_info.hpp index 51cfb7d8a..ddf1edc6c 100644 --- a/src/ai/ai_info.hpp +++ b/src/ai/ai_info.hpp @@ -59,7 +59,7 @@ private: /** All static information from an AI library like name, version, etc. */ class AILibrary : public ScriptInfo { public: - AILibrary() : ScriptInfo(), category(NULL) {}; + AILibrary() : ScriptInfo(), category(nullptr) {}; ~AILibrary(); /** diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp index c03e74599..f5f5904c0 100644 --- a/src/ai/ai_instance.cpp +++ b/src/ai/ai_instance.cpp @@ -216,10 +216,10 @@ void AIInstance::Died() ShowAIDebugWindow(_current_company); const AIInfo *info = AIConfig::GetConfig(_current_company, AIConfig::SSS_FORCE_GAME)->GetInfo(); - if (info != NULL) { + if (info != nullptr) { ShowErrorMessage(STR_ERROR_AI_PLEASE_REPORT_CRASH, INVALID_STRING_ID, WL_WARNING); - if (info->GetURL() != NULL) { + if (info->GetURL() != nullptr) { ScriptLog::Info("Please report the error to the following URL:"); ScriptLog::Info(info->GetURL()); } @@ -258,7 +258,7 @@ void CcAI(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) * when the company does not exist anymore. */ const Company *c = Company::GetIfValid(_current_company); - if (c == NULL || c->ai_instance == NULL) return; + if (c == nullptr || c->ai_instance == nullptr) return; c->ai_instance->DoCommandCallback(result, tile, p1, p2); c->ai_instance->Continue(); diff --git a/src/ai/ai_scanner.cpp b/src/ai/ai_scanner.cpp index 5f16de3f9..1d0fed188 100644 --- a/src/ai/ai_scanner.cpp +++ b/src/ai/ai_scanner.cpp @@ -23,7 +23,7 @@ AIScannerInfo::AIScannerInfo() : ScriptScanner(), - info_dummy(NULL) + info_dummy(nullptr) { } @@ -94,14 +94,14 @@ AIInfo *AIScannerInfo::SelectRandomAI() const AIInfo *AIScannerInfo::FindInfo(const char *nameParam, int versionParam, bool force_exact_match) { - if (this->info_list.size() == 0) return NULL; - if (nameParam == NULL) return NULL; + if (this->info_list.size() == 0) return nullptr; + if (nameParam == nullptr) return nullptr; char ai_name[1024]; strecpy(ai_name, nameParam, lastof(ai_name)); strtolower(ai_name); - AIInfo *info = NULL; + AIInfo *info = nullptr; int version = -1; if (versionParam == -1) { @@ -110,7 +110,7 @@ AIInfo *AIScannerInfo::FindInfo(const char *nameParam, int versionParam, bool fo /* If we didn't find a match AI, maybe the user included a version */ char *e = strrchr(ai_name, '.'); - if (e == NULL) return NULL; + if (e == nullptr) return nullptr; *e = '\0'; e++; versionParam = atoi(e); @@ -165,7 +165,7 @@ AILibrary *AIScannerLibrary::FindLibrary(const char *library, int version) /* Check if the library + version exists */ ScriptInfoList::iterator iter = this->info_list.find(library_name); - if (iter == this->info_list.end()) return NULL; + if (iter == this->info_list.end()) return nullptr; return static_cast<AILibrary *>((*iter).second); } diff --git a/src/ai/ai_scanner.hpp b/src/ai/ai_scanner.hpp index dafc340be..2e0532d00 100644 --- a/src/ai/ai_scanner.hpp +++ b/src/ai/ai_scanner.hpp @@ -32,7 +32,7 @@ public: * @param nameParam The name of the AI. * @param versionParam The version of the AI, or -1 if you want the latest. * @param force_exact_match Only match name+version, never latest. - * @return NULL if no match found, otherwise the AI that matched. + * @return nullptr if no match found, otherwise the AI that matched. */ class AIInfo *FindInfo(const char *nameParam, int versionParam, bool force_exact_match); @@ -60,7 +60,7 @@ public: * Find a library in the pool. * @param library The library name to find. * @param version The version the library should have. - * @return The library if found, NULL otherwise. + * @return The library if found, nullptr otherwise. */ class AILibrary *FindLibrary(const char *library, int version); |