mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: Use null pointer literal instead of the NULL macro
This commit is contained in:
parent
3b4f224c0b
commit
7c8e7c6b6e
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
/**
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ static StationID FindNearestHangar(const Aircraft *v)
|
|||
if (v->acache.cached_max_range_sqr != 0) {
|
||||
/* Check if our current destination can be reached from the depot airport. */
|
||||
const Station *cur_dest = GetTargetAirportIfValid(v);
|
||||
if (cur_dest != NULL && DistanceSquare(st->airport.tile, cur_dest->airport.tile) > v->acache.cached_max_range_sqr) continue;
|
||||
if (cur_dest != nullptr && DistanceSquare(st->airport.tile, cur_dest->airport.tile) > v->acache.cached_max_range_sqr) continue;
|
||||
}
|
||||
if (distance < best || index == INVALID_STATION) {
|
||||
best = distance;
|
||||
|
@ -295,7 +295,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, const Engine *
|
|||
v->cargo_type = e->GetDefaultCargoType();
|
||||
u->cargo_type = CT_MAIL;
|
||||
|
||||
v->name = NULL;
|
||||
v->name = nullptr;
|
||||
v->last_station_visited = INVALID_STATION;
|
||||
v->last_loading_station = INVALID_STATION;
|
||||
|
||||
|
@ -379,7 +379,7 @@ bool Aircraft::FindClosestDepot(TileIndex *location, DestinationID *destination,
|
|||
{
|
||||
const Station *st = GetTargetAirportIfValid(this);
|
||||
/* If the station is not a valid airport or if it has no hangars */
|
||||
if (st == NULL || !CanVehicleUseStation(this, st) || !st->airport.HasHangar()) {
|
||||
if (st == nullptr || !CanVehicleUseStation(this, st) || !st->airport.HasHangar()) {
|
||||
/* the aircraft has to search for a hangar on its own */
|
||||
StationID station = FindNearestHangar(this);
|
||||
|
||||
|
@ -388,8 +388,8 @@ bool Aircraft::FindClosestDepot(TileIndex *location, DestinationID *destination,
|
|||
st = Station::Get(station);
|
||||
}
|
||||
|
||||
if (location != NULL) *location = st->xy;
|
||||
if (destination != NULL) *destination = st->index;
|
||||
if (location != nullptr) *location = st->xy;
|
||||
if (destination != nullptr) *destination = st->index;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -408,7 +408,7 @@ static void CheckIfAircraftNeedsService(Aircraft *v)
|
|||
|
||||
const Station *st = Station::Get(v->current_order.GetDestination());
|
||||
|
||||
assert(st != NULL);
|
||||
assert(st != nullptr);
|
||||
|
||||
/* only goto depot if the target airport has a depot */
|
||||
if (st->airport.HasHangar() && CanVehicleUseStation(v, st)) {
|
||||
|
@ -531,7 +531,7 @@ void SetAircraftPosition(Aircraft *v, int x, int y, int z)
|
|||
u->UpdatePositionAndViewport();
|
||||
|
||||
u = u->Next();
|
||||
if (u != NULL) {
|
||||
if (u != nullptr) {
|
||||
u->x_pos = x;
|
||||
u->y_pos = y;
|
||||
u->z_pos = z + ROTOR_Z_OFFSET;
|
||||
|
@ -552,7 +552,7 @@ void HandleAircraftEnterHangar(Aircraft *v)
|
|||
Aircraft *u = v->Next();
|
||||
u->vehstatus |= VS_HIDDEN;
|
||||
u = u->Next();
|
||||
if (u != NULL) {
|
||||
if (u != nullptr) {
|
||||
u->vehstatus |= VS_HIDDEN;
|
||||
u->cur_speed = 0;
|
||||
}
|
||||
|
@ -725,8 +725,8 @@ void GetAircraftFlightLevelBounds(const Vehicle *v, int *min_level, int *max_lev
|
|||
/* Make faster planes fly higher so that they can overtake slower ones */
|
||||
base_altitude += min(20 * (v->vcache.cached_max_speed / 200) - 90, 0);
|
||||
|
||||
if (min_level != NULL) *min_level = base_altitude + AIRCRAFT_MIN_FLYING_ALTITUDE;
|
||||
if (max_level != NULL) *max_level = base_altitude + AIRCRAFT_MAX_FLYING_ALTITUDE;
|
||||
if (min_level != nullptr) *min_level = base_altitude + AIRCRAFT_MIN_FLYING_ALTITUDE;
|
||||
if (max_level != nullptr) *max_level = base_altitude + AIRCRAFT_MAX_FLYING_ALTITUDE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -801,8 +801,8 @@ template int GetAircraftFlightLevel(Aircraft *v, bool takeoff);
|
|||
*/
|
||||
static byte AircraftGetEntryPoint(const Aircraft *v, const AirportFTAClass *apc, Direction rotation)
|
||||
{
|
||||
assert(v != NULL);
|
||||
assert(apc != NULL);
|
||||
assert(v != nullptr);
|
||||
assert(apc != nullptr);
|
||||
|
||||
/* In the case the station doesn't exit anymore, set target tile 0.
|
||||
* It doesn't hurt much, aircraft will go to next order, nearest hangar
|
||||
|
@ -810,7 +810,7 @@ static byte AircraftGetEntryPoint(const Aircraft *v, const AirportFTAClass *apc,
|
|||
TileIndex tile = 0;
|
||||
|
||||
const Station *st = Station::GetIfValid(v->targetairport);
|
||||
if (st != NULL) {
|
||||
if (st != nullptr) {
|
||||
/* Make sure we don't go to INVALID_TILE if the airport has been removed. */
|
||||
tile = (st->airport.tile != INVALID_TILE) ? st->airport.tile : st->xy;
|
||||
}
|
||||
|
@ -844,13 +844,13 @@ static bool AircraftController(Aircraft *v)
|
|||
{
|
||||
int count;
|
||||
|
||||
/* NULL if station is invalid */
|
||||
/* nullptr if station is invalid */
|
||||
const Station *st = Station::GetIfValid(v->targetairport);
|
||||
/* INVALID_TILE if there is no station */
|
||||
TileIndex tile = INVALID_TILE;
|
||||
Direction rotation = DIR_N;
|
||||
uint size_x = 1, size_y = 1;
|
||||
if (st != NULL) {
|
||||
if (st != nullptr) {
|
||||
if (st->airport.tile != INVALID_TILE) {
|
||||
tile = st->airport.tile;
|
||||
rotation = st->airport.rotation;
|
||||
|
@ -864,7 +864,7 @@ static bool AircraftController(Aircraft *v)
|
|||
const AirportFTAClass *afc = tile == INVALID_TILE ? GetAirport(AT_DUMMY) : st->airport.GetFTA();
|
||||
|
||||
/* prevent going to INVALID_TILE if airport is deleted. */
|
||||
if (st == NULL || st->airport.tile == INVALID_TILE) {
|
||||
if (st == nullptr || st->airport.tile == INVALID_TILE) {
|
||||
/* Jump into our "holding pattern" state machine if possible */
|
||||
if (v->pos >= afc->nofelements) {
|
||||
v->pos = v->previous_pos = AircraftGetEntryPoint(v, afc, DIR_N);
|
||||
|
@ -904,7 +904,7 @@ static bool AircraftController(Aircraft *v)
|
|||
v->tile = 0;
|
||||
|
||||
int z_dest;
|
||||
GetAircraftFlightLevelBounds(v, &z_dest, NULL);
|
||||
GetAircraftFlightLevelBounds(v, &z_dest, nullptr);
|
||||
|
||||
/* Reached altitude? */
|
||||
if (v->z_pos >= z_dest) {
|
||||
|
@ -921,7 +921,7 @@ static bool AircraftController(Aircraft *v)
|
|||
if (amd.flag & AMED_HELI_LOWER) {
|
||||
SetBit(v->flags, VAF_HELI_DIRECT_DESCENT);
|
||||
|
||||
if (st == NULL) {
|
||||
if (st == nullptr) {
|
||||
/* FIXME - AircraftController -> if station no longer exists, do not land
|
||||
* helicopter will circle until sign disappears, then go to next order
|
||||
* what to do when it is the only order left, right now it just stays in 1 place */
|
||||
|
@ -1127,7 +1127,7 @@ static bool HandleCrashedAircraft(Aircraft *v)
|
|||
Station *st = GetTargetAirportIfValid(v);
|
||||
|
||||
/* make aircraft crash down to the ground */
|
||||
if (v->crashed_counter < 500 && st == NULL && ((v->crashed_counter % 3) == 0) ) {
|
||||
if (v->crashed_counter < 500 && st == nullptr && ((v->crashed_counter % 3) == 0) ) {
|
||||
int z = GetSlopePixelZ(Clamp(v->x_pos, 0, MapMaxX() * TILE_SIZE), Clamp(v->y_pos, 0, MapMaxY() * TILE_SIZE));
|
||||
v->z_pos -= 1;
|
||||
if (v->z_pos == z) {
|
||||
|
@ -1158,7 +1158,7 @@ static bool HandleCrashedAircraft(Aircraft *v)
|
|||
/* clear runway-in on all airports, set by crashing plane
|
||||
* small airports use AIRPORT_BUSY, city airports use RUNWAY_IN_OUT_block, etc.
|
||||
* but they all share the same number */
|
||||
if (st != NULL) {
|
||||
if (st != nullptr) {
|
||||
CLRBITS(st->airport.flags, RUNWAY_IN_block);
|
||||
CLRBITS(st->airport.flags, RUNWAY_IN_OUT_block); // commuter airport
|
||||
CLRBITS(st->airport.flags, RUNWAY_IN2_block); // intercontinental
|
||||
|
@ -1232,7 +1232,7 @@ void HandleMissingAircraftOrders(Aircraft *v)
|
|||
* actually stops.
|
||||
*/
|
||||
const Station *st = GetTargetAirportIfValid(v);
|
||||
if (st == NULL) {
|
||||
if (st == nullptr) {
|
||||
Backup<CompanyByte> cur_company(_current_company, v->owner, FILE_LINE);
|
||||
CommandCost ret = DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_SEND_VEHICLE_TO_DEPOT);
|
||||
cur_company.Restore();
|
||||
|
@ -1288,17 +1288,17 @@ static void CrashAirplane(Aircraft *v)
|
|||
v->Next()->cargo.Truncate();
|
||||
const Station *st = GetTargetAirportIfValid(v);
|
||||
StringID newsitem;
|
||||
if (st == NULL) {
|
||||
if (st == nullptr) {
|
||||
newsitem = STR_NEWS_PLANE_CRASH_OUT_OF_FUEL;
|
||||
} else {
|
||||
SetDParam(1, st->index);
|
||||
newsitem = STR_NEWS_AIRCRAFT_CRASH;
|
||||
}
|
||||
|
||||
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, st == NULL ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING));
|
||||
Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, st == NULL ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING));
|
||||
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING));
|
||||
Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING));
|
||||
|
||||
AddVehicleNewsItem(newsitem, NT_ACCIDENT, v->index, st != NULL ? st->index : INVALID_STATION);
|
||||
AddVehicleNewsItem(newsitem, NT_ACCIDENT, v->index, st != nullptr ? st->index : INVALID_STATION);
|
||||
|
||||
ModifyStationRatingAround(v->tile, v->owner, -160, 30);
|
||||
if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v);
|
||||
|
@ -1392,8 +1392,8 @@ void AircraftNextAirportPos_and_Order(Aircraft *v)
|
|||
}
|
||||
|
||||
const Station *st = GetTargetAirportIfValid(v);
|
||||
const AirportFTAClass *apc = st == NULL ? GetAirport(AT_DUMMY) : st->airport.GetFTA();
|
||||
Direction rotation = st == NULL ? DIR_N : st->airport.rotation;
|
||||
const AirportFTAClass *apc = st == nullptr ? GetAirport(AT_DUMMY) : st->airport.GetFTA();
|
||||
Direction rotation = st == nullptr ? DIR_N : st->airport.rotation;
|
||||
v->pos = v->previous_pos = AircraftGetEntryPoint(v, apc, rotation);
|
||||
}
|
||||
|
||||
|
@ -1418,7 +1418,7 @@ void AircraftLeaveHangar(Aircraft *v, Direction exit_dir)
|
|||
|
||||
/* Rotor blades */
|
||||
u = u->Next();
|
||||
if (u != NULL) {
|
||||
if (u != nullptr) {
|
||||
u->vehstatus &= ~VS_HIDDEN;
|
||||
u->cur_speed = 80;
|
||||
}
|
||||
|
@ -1605,7 +1605,7 @@ static void AircraftEventHandler_Flying(Aircraft *v, const AirportFTAClass *apc)
|
|||
* it is possible to choose from multiple landing runways, so loop until a free one is found */
|
||||
byte landingtype = (v->subtype == AIR_HELICOPTER) ? HELILANDING : LANDING;
|
||||
const AirportFTA *current = apc->layout[v->pos].next;
|
||||
while (current != NULL) {
|
||||
while (current != nullptr) {
|
||||
if (current->heading == landingtype) {
|
||||
/* save speed before, since if AirportHasBlock is false, it resets them to 0
|
||||
* we don't want that for plane in air
|
||||
|
@ -1761,7 +1761,7 @@ static bool AirportMove(Aircraft *v, const AirportFTAClass *apc)
|
|||
v->previous_pos = v->pos; // save previous location
|
||||
|
||||
/* there is only one choice to move to */
|
||||
if (current->next == NULL) {
|
||||
if (current->next == nullptr) {
|
||||
if (AirportSetBlocks(v, current, apc)) {
|
||||
v->pos = current->next_position;
|
||||
UpdateAircraftCache(v);
|
||||
|
@ -1780,7 +1780,7 @@ static bool AirportMove(Aircraft *v, const AirportFTAClass *apc)
|
|||
return false;
|
||||
}
|
||||
current = current->next;
|
||||
} while (current != NULL);
|
||||
} while (current != nullptr);
|
||||
|
||||
DEBUG(misc, 0, "[Ap] cannot move further on Airport! (pos %d state %d) for vehicle %d", v->pos, v->state, v->index);
|
||||
NOT_REACHED();
|
||||
|
@ -1830,7 +1830,7 @@ static bool AirportSetBlocks(Aircraft *v, const AirportFTA *current_pos, const A
|
|||
* this means more blocks should be checked/set */
|
||||
const AirportFTA *current = current_pos;
|
||||
if (current == reference) current = current->next;
|
||||
while (current != NULL) {
|
||||
while (current != nullptr) {
|
||||
if (current->heading == current_pos->heading && current->block != 0) {
|
||||
airport_flags |= current->block;
|
||||
break;
|
||||
|
@ -1938,7 +1938,7 @@ static bool AirportFindFreeTerminal(Aircraft *v, const AirportFTAClass *apc)
|
|||
const Station *st = Station::Get(v->targetairport);
|
||||
const AirportFTA *temp = apc->layout[v->pos].next;
|
||||
|
||||
while (temp != NULL) {
|
||||
while (temp != nullptr) {
|
||||
if (temp->heading == 255) {
|
||||
if (!(st->airport.flags & temp->block)) {
|
||||
/* read which group do we want to go to?
|
||||
|
@ -2037,9 +2037,9 @@ static bool AircraftEventHandler(Aircraft *v, int loop)
|
|||
/* Check the distance to the next destination. This code works because the target
|
||||
* airport is only updated after take off and not on the ground. */
|
||||
Station *cur_st = Station::GetIfValid(v->targetairport);
|
||||
Station *next_st = v->current_order.IsType(OT_GOTO_STATION) || v->current_order.IsType(OT_GOTO_DEPOT) ? Station::GetIfValid(v->current_order.GetDestination()) : NULL;
|
||||
Station *next_st = v->current_order.IsType(OT_GOTO_STATION) || v->current_order.IsType(OT_GOTO_DEPOT) ? Station::GetIfValid(v->current_order.GetDestination()) : nullptr;
|
||||
|
||||
if (cur_st != NULL && cur_st->airport.tile != INVALID_TILE && next_st != NULL && next_st->airport.tile != INVALID_TILE) {
|
||||
if (cur_st != nullptr && cur_st->airport.tile != INVALID_TILE && next_st != nullptr && next_st->airport.tile != INVALID_TILE) {
|
||||
uint dist = DistanceSquare(cur_st->airport.tile, next_st->airport.tile);
|
||||
AircraftHandleDestTooFar(v, dist > v->acache.cached_max_range_sqr);
|
||||
}
|
||||
|
@ -2077,16 +2077,16 @@ bool Aircraft::Tick()
|
|||
* Returns aircraft's target station if v->target_airport
|
||||
* is a valid station with airport.
|
||||
* @param v vehicle to get target airport for
|
||||
* @return pointer to target station, NULL if invalid
|
||||
* @return pointer to target station, nullptr if invalid
|
||||
*/
|
||||
Station *GetTargetAirportIfValid(const Aircraft *v)
|
||||
{
|
||||
assert(v->type == VEH_AIRCRAFT);
|
||||
|
||||
Station *st = Station::GetIfValid(v->targetairport);
|
||||
if (st == NULL) return NULL;
|
||||
if (st == nullptr) return nullptr;
|
||||
|
||||
return st->airport.tile == INVALID_TILE ? NULL : st;
|
||||
return st->airport.tile == INVALID_TILE ? nullptr : st;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,7 +36,7 @@ void DrawAircraftDetails(const Aircraft *v, int left, int right, int y)
|
|||
int y_offset = (v->Next()->cargo_cap != 0) ? -(FONT_HEIGHT_NORMAL + 1): 0;
|
||||
Money feeder_share = 0;
|
||||
|
||||
for (const Aircraft *u = v; u != NULL; u = u->Next()) {
|
||||
for (const Aircraft *u = v; u != nullptr; u = u->Next()) {
|
||||
if (u->IsNormalAircraft()) {
|
||||
SetDParam(0, u->engine_type);
|
||||
SetDParam(1, u->build_year);
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
* @param delta_z Height of the airport above the land.
|
||||
*/
|
||||
#define HELIPORT(name, num_helipads, delta_z) \
|
||||
AIRPORT_GENERIC(name, NULL, num_helipads, AirportFTAClass::HELICOPTERS, delta_z)
|
||||
AIRPORT_GENERIC(name, nullptr, num_helipads, AirportFTAClass::HELICOPTERS, delta_z)
|
||||
|
||||
AIRPORT(country, 0, true)
|
||||
AIRPORT(city, 0, false)
|
||||
|
@ -58,7 +58,7 @@ HELIPORT(helidepot, 1, 0)
|
|||
AIRPORT(intercontinental, 2, false)
|
||||
HELIPORT(helistation, 3, 0)
|
||||
HELIPORT(oilrig, 1, 54)
|
||||
AIRPORT_GENERIC(dummy, NULL, 0, AirportFTAClass::ALL, 0)
|
||||
AIRPORT_GENERIC(dummy, nullptr, 0, AirportFTAClass::ALL, 0)
|
||||
|
||||
#undef HELIPORT
|
||||
#undef AIRPORT
|
||||
|
@ -135,7 +135,7 @@ AirportFTAClass::~AirportFTAClass()
|
|||
{
|
||||
for (uint i = 0; i < nofelements; i++) {
|
||||
AirportFTA *current = layout[i].next;
|
||||
while (current != NULL) {
|
||||
while (current != nullptr) {
|
||||
AirportFTA *next = current->next;
|
||||
free(current);
|
||||
current = next;
|
||||
|
@ -195,7 +195,7 @@ static AirportFTA *AirportBuildAutomata(uint nofelements, const AirportFTAbuildu
|
|||
current = current->next;
|
||||
internalcounter++;
|
||||
}
|
||||
current->next = NULL;
|
||||
current->next = nullptr;
|
||||
internalcounter++;
|
||||
}
|
||||
return FAutomata;
|
||||
|
|
|
@ -161,7 +161,7 @@ static EventState AirportToolbarGlobalHotkeys(int hotkey)
|
|||
{
|
||||
if (_game_mode != GM_NORMAL || !CanBuildVehicleInfrastructure(VEH_AIRCRAFT)) return ES_NOT_HANDLED;
|
||||
Window *w = ShowBuildAirToolbar();
|
||||
if (w == NULL) return ES_NOT_HANDLED;
|
||||
if (w == nullptr) return ES_NOT_HANDLED;
|
||||
return w->OnHotkey(hotkey);
|
||||
}
|
||||
|
||||
|
@ -198,11 +198,11 @@ static WindowDesc _air_toolbar_desc(
|
|||
*
|
||||
* If the terraform toolbar is linked to the toolbar, that window is also opened.
|
||||
*
|
||||
* @return newly opened airport toolbar, or NULL if the toolbar could not be opened.
|
||||
* @return newly opened airport toolbar, or nullptr if the toolbar could not be opened.
|
||||
*/
|
||||
Window *ShowBuildAirToolbar()
|
||||
{
|
||||
if (!Company::IsValidID(_local_company)) return NULL;
|
||||
if (!Company::IsValidID(_local_company)) return nullptr;
|
||||
|
||||
DeleteWindowByClass(WC_BUILD_TOOLBAR);
|
||||
return AllocateWindowDescFront<BuildAirToolbarWindow>(&_air_toolbar_desc, TRANSPORT_AIR);
|
||||
|
|
|
@ -31,9 +31,9 @@ static const uint MAX_ARTICULATED_PARTS = 100; ///< Maximum of articulated parts
|
|||
* @param mirrored Returns whether the part shall be flipped.
|
||||
* @return engine to add or INVALID_ENGINE
|
||||
*/
|
||||
static EngineID GetNextArticulatedPart(uint index, EngineID front_type, Vehicle *front = NULL, bool *mirrored = NULL)
|
||||
static EngineID GetNextArticulatedPart(uint index, EngineID front_type, Vehicle *front = nullptr, bool *mirrored = nullptr)
|
||||
{
|
||||
assert(front == NULL || front->engine_type == front_type);
|
||||
assert(front == nullptr || front->engine_type == front_type);
|
||||
|
||||
const Engine *front_engine = Engine::Get(front_type);
|
||||
|
||||
|
@ -44,12 +44,12 @@ static EngineID GetNextArticulatedPart(uint index, EngineID front_type, Vehicle
|
|||
/* 8 bits, bit 7 for mirroring */
|
||||
callback = GB(callback, 0, 8);
|
||||
if (callback == 0xFF) return INVALID_ENGINE;
|
||||
if (mirrored != NULL) *mirrored = HasBit(callback, 7);
|
||||
if (mirrored != nullptr) *mirrored = HasBit(callback, 7);
|
||||
callback = GB(callback, 0, 7);
|
||||
} else {
|
||||
/* 15 bits, bit 14 for mirroring */
|
||||
if (callback == 0x7FFF) return INVALID_ENGINE;
|
||||
if (mirrored != NULL) *mirrored = HasBit(callback, 14);
|
||||
if (mirrored != nullptr) *mirrored = HasBit(callback, 14);
|
||||
callback = GB(callback, 0, 14);
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ uint CountArticulatedParts(EngineID engine_type, bool purchase_window)
|
|||
* either, so it doesn't matter how many articulated parts there are. */
|
||||
if (!Vehicle::CanAllocateItem()) return 0;
|
||||
|
||||
Vehicle *v = NULL;
|
||||
Vehicle *v = nullptr;
|
||||
if (!purchase_window) {
|
||||
v = new Vehicle();
|
||||
v->engine_type = engine_type;
|
||||
|
@ -108,7 +108,7 @@ static inline uint16 GetVehicleDefaultCapacity(EngineID engine, CargoID *cargo_t
|
|||
{
|
||||
const Engine *e = Engine::Get(engine);
|
||||
CargoID cargo = (e->CanCarryCargo() ? e->GetDefaultCargoType() : (CargoID)CT_INVALID);
|
||||
if (cargo_type != NULL) *cargo_type = cargo;
|
||||
if (cargo_type != nullptr) *cargo_type = cargo;
|
||||
if (cargo == CT_INVALID) return 0;
|
||||
return e->GetDisplayDefaultCapacity();
|
||||
}
|
||||
|
@ -290,15 +290,15 @@ bool IsArticulatedVehicleCarryingDifferentCargoes(const Vehicle *v, CargoID *car
|
|||
if (v->cargo_type != CT_INVALID && v->GetEngine()->CanCarryCargo()) {
|
||||
if (first_cargo == CT_INVALID) first_cargo = v->cargo_type;
|
||||
if (first_cargo != v->cargo_type) {
|
||||
if (cargo_type != NULL) *cargo_type = CT_INVALID;
|
||||
if (cargo_type != nullptr) *cargo_type = CT_INVALID;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
v = v->HasArticulatedPart() ? v->GetNextArticulatedPart() : NULL;
|
||||
} while (v != NULL);
|
||||
v = v->HasArticulatedPart() ? v->GetNextArticulatedPart() : nullptr;
|
||||
} while (v != nullptr);
|
||||
|
||||
if (cargo_type != NULL) *cargo_type = first_cargo;
|
||||
if (cargo_type != nullptr) *cargo_type = first_cargo;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -330,8 +330,8 @@ void CheckConsistencyOfArticulatedVehicle(const Vehicle *v)
|
|||
assert(v->cargo_type < NUM_CARGO);
|
||||
real_default_capacity[v->cargo_type] += v->cargo_cap;
|
||||
|
||||
v = v->HasArticulatedPart() ? v->GetNextArticulatedPart() : NULL;
|
||||
} while (v != NULL);
|
||||
v = v->HasArticulatedPart() ? v->GetNextArticulatedPart() : nullptr;
|
||||
} while (v != nullptr);
|
||||
|
||||
/* Check whether the vehicle carries more cargoes than expected */
|
||||
bool carries_more = false;
|
||||
|
|
|
@ -29,11 +29,11 @@ static EngineRenew *GetEngineReplacement(EngineRenewList erl, EngineID engine, G
|
|||
{
|
||||
EngineRenew *er = (EngineRenew *)erl;
|
||||
|
||||
while (er != NULL) {
|
||||
while (er != nullptr) {
|
||||
if (er->from == engine && GroupIsInGroup(group, er->group_id)) return er;
|
||||
er = er->next;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,12 +46,12 @@ void RemoveAllEngineReplacement(EngineRenewList *erl)
|
|||
EngineRenew *er = (EngineRenew *)(*erl);
|
||||
EngineRenew *next;
|
||||
|
||||
while (er != NULL) {
|
||||
while (er != nullptr) {
|
||||
next = er->next;
|
||||
delete er;
|
||||
er = next;
|
||||
}
|
||||
*erl = NULL; // Empty list
|
||||
*erl = nullptr; // Empty list
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,12 +66,12 @@ void RemoveAllEngineReplacement(EngineRenewList *erl)
|
|||
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group, bool *replace_when_old)
|
||||
{
|
||||
const EngineRenew *er = GetEngineReplacement(erl, engine, group);
|
||||
if (er == NULL && (group == DEFAULT_GROUP || (Group::IsValidID(group) && !Group::Get(group)->replace_protection))) {
|
||||
if (er == nullptr && (group == DEFAULT_GROUP || (Group::IsValidID(group) && !Group::Get(group)->replace_protection))) {
|
||||
/* We didn't find anything useful in the vehicle's own group so we will try ALL_GROUP */
|
||||
er = GetEngineReplacement(erl, engine, ALL_GROUP);
|
||||
}
|
||||
if (replace_when_old != NULL) *replace_when_old = er == NULL ? false : er->replace_when_old;
|
||||
return er == NULL ? INVALID_ENGINE : er->to;
|
||||
if (replace_when_old != nullptr) *replace_when_old = er == nullptr ? false : er->replace_when_old;
|
||||
return er == nullptr ? INVALID_ENGINE : er->to;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,7 +88,7 @@ CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, Engi
|
|||
{
|
||||
/* Check if the old vehicle is already in the list */
|
||||
EngineRenew *er = GetEngineReplacement(*erl, old_engine, group);
|
||||
if (er != NULL) {
|
||||
if (er != nullptr) {
|
||||
if (flags & DC_EXEC) {
|
||||
er->to = new_engine;
|
||||
er->replace_when_old = replace_when_old;
|
||||
|
@ -122,12 +122,12 @@ CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, Engi
|
|||
CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, DoCommandFlag flags)
|
||||
{
|
||||
EngineRenew *er = (EngineRenew *)(*erl);
|
||||
EngineRenew *prev = NULL;
|
||||
EngineRenew *prev = nullptr;
|
||||
|
||||
while (er != NULL) {
|
||||
while (er != nullptr) {
|
||||
if (er->from == engine && er->group_id == group) {
|
||||
if (flags & DC_EXEC) {
|
||||
if (prev == NULL) { // First element
|
||||
if (prev == nullptr) { // First element
|
||||
/* The second becomes the new first element */
|
||||
*erl = (EngineRenewList)er->next;
|
||||
} else {
|
||||
|
|
|
@ -98,9 +98,9 @@ bool CheckAutoreplaceValidity(EngineID from, EngineID to, CompanyID company)
|
|||
*/
|
||||
void CheckCargoCapacity(Vehicle *v)
|
||||
{
|
||||
assert(v == NULL || v->First() == v);
|
||||
assert(v == nullptr || v->First() == v);
|
||||
|
||||
for (Vehicle *src = v; src != NULL; src = src->Next()) {
|
||||
for (Vehicle *src = v; src != nullptr; src = src->Next()) {
|
||||
assert(src->cargo.TotalCount() == src->cargo.ActionCount(VehicleCargoList::MTA_KEEP));
|
||||
|
||||
/* Do we need to more cargo away? */
|
||||
|
@ -108,7 +108,7 @@ void CheckCargoCapacity(Vehicle *v)
|
|||
|
||||
/* We need to move a particular amount. Try that on the other vehicles. */
|
||||
uint to_spread = src->cargo.TotalCount() - src->cargo_cap;
|
||||
for (Vehicle *dest = v; dest != NULL && to_spread != 0; dest = dest->Next()) {
|
||||
for (Vehicle *dest = v; dest != nullptr && to_spread != 0; dest = dest->Next()) {
|
||||
assert(dest->cargo.TotalCount() == dest->cargo.ActionCount(VehicleCargoList::MTA_KEEP));
|
||||
if (dest->cargo.TotalCount() >= dest->cargo_cap || dest->cargo_type != src->cargo_type) continue;
|
||||
|
||||
|
@ -135,7 +135,7 @@ static void TransferCargo(Vehicle *old_veh, Vehicle *new_head, bool part_of_chai
|
|||
{
|
||||
assert(!part_of_chain || new_head->IsPrimaryVehicle());
|
||||
/* Loop through source parts */
|
||||
for (Vehicle *src = old_veh; src != NULL; src = src->Next()) {
|
||||
for (Vehicle *src = old_veh; src != nullptr; src = src->Next()) {
|
||||
assert(src->cargo.TotalCount() == src->cargo.ActionCount(VehicleCargoList::MTA_KEEP));
|
||||
if (!part_of_chain && src->type == VEH_TRAIN && src != old_veh && src != Train::From(old_veh)->other_multiheaded_part && !src->IsArticulatedPart()) {
|
||||
/* Skip vehicles, which do not belong to old_veh */
|
||||
|
@ -145,7 +145,7 @@ static void TransferCargo(Vehicle *old_veh, Vehicle *new_head, bool part_of_chai
|
|||
if (src->cargo_type >= NUM_CARGO || src->cargo.TotalCount() == 0) continue;
|
||||
|
||||
/* Find free space in the new chain */
|
||||
for (Vehicle *dest = new_head; dest != NULL && src->cargo.TotalCount() > 0; dest = dest->Next()) {
|
||||
for (Vehicle *dest = new_head; dest != nullptr && src->cargo.TotalCount() > 0; dest = dest->Next()) {
|
||||
assert(dest->cargo.TotalCount() == dest->cargo.ActionCount(VehicleCargoList::MTA_KEEP));
|
||||
if (!part_of_chain && dest->type == VEH_TRAIN && dest != new_head && dest != Train::From(new_head)->other_multiheaded_part && !dest->IsArticulatedPart()) {
|
||||
/* Skip vehicles, which do not belong to new_head */
|
||||
|
@ -216,7 +216,7 @@ static CargoID GetNewCargoTypeForReplace(Vehicle *v, EngineID engine_type, bool
|
|||
/* the old engine didn't have cargo capacity, but the new one does
|
||||
* now we will figure out what cargo the train is carrying and refit to fit this */
|
||||
|
||||
for (v = v->First(); v != NULL; v = v->Next()) {
|
||||
for (v = v->First(); v != nullptr; v = v->Next()) {
|
||||
if (!v->GetEngine()->CanCarryCargo()) continue;
|
||||
/* Now we found a cargo type being carried on the train and we will see if it is possible to carry to this one */
|
||||
if (HasBit(available_cargo_types, v->cargo_type)) return v->cargo_type;
|
||||
|
@ -280,7 +280,7 @@ static CommandCost GetNewEngineType(const Vehicle *v, const Company *c, bool alw
|
|||
*/
|
||||
static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehicle, bool part_of_chain)
|
||||
{
|
||||
*new_vehicle = NULL;
|
||||
*new_vehicle = nullptr;
|
||||
|
||||
/* Shall the vehicle be replaced? */
|
||||
const Company *c = Company::Get(_current_company);
|
||||
|
@ -330,14 +330,14 @@ static inline CommandCost CmdStartStopVehicle(const Vehicle *v, bool evaluate_ca
|
|||
/**
|
||||
* Issue a train vehicle move command
|
||||
* @param v The vehicle to move
|
||||
* @param after The vehicle to insert 'v' after, or NULL to start new chain
|
||||
* @param after The vehicle to insert 'v' after, or nullptr to start new chain
|
||||
* @param flags the command flags to use
|
||||
* @param whole_chain move all vehicles following 'v' (true), or only 'v' (false)
|
||||
* @return success or error
|
||||
*/
|
||||
static inline CommandCost CmdMoveVehicle(const Vehicle *v, const Vehicle *after, DoCommandFlag flags, bool whole_chain)
|
||||
{
|
||||
return DoCommand(0, v->index | (whole_chain ? 1 : 0) << 20, after != NULL ? after->index : INVALID_VEHICLE, flags | DC_NO_CARGO_CAP_CHECK, CMD_MOVE_RAIL_VEHICLE);
|
||||
return DoCommand(0, v->index | (whole_chain ? 1 : 0) << 20, after != nullptr ? after->index : INVALID_VEHICLE, flags | DC_NO_CARGO_CAP_CHECK, CMD_MOVE_RAIL_VEHICLE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -395,11 +395,11 @@ static CommandCost ReplaceFreeUnit(Vehicle **single_unit, DoCommandFlag flags, b
|
|||
CommandCost cost = CommandCost(EXPENSES_NEW_VEHICLES, 0);
|
||||
|
||||
/* Build and refit replacement vehicle */
|
||||
Vehicle *new_v = NULL;
|
||||
Vehicle *new_v = nullptr;
|
||||
cost.AddCost(BuildReplacementVehicle(old_v, &new_v, false));
|
||||
|
||||
/* Was a new vehicle constructed? */
|
||||
if (cost.Succeeded() && new_v != NULL) {
|
||||
if (cost.Succeeded() && new_v != nullptr) {
|
||||
*nothing_to_do = false;
|
||||
|
||||
if ((flags & DC_EXEC) != 0) {
|
||||
|
@ -449,17 +449,17 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
uint16 old_total_length = CeilDiv(Train::From(old_head)->gcache.cached_total_length, TILE_SIZE) * TILE_SIZE;
|
||||
|
||||
int num_units = 0; ///< Number of units in the chain
|
||||
for (Train *w = Train::From(old_head); w != NULL; w = w->GetNextUnit()) num_units++;
|
||||
for (Train *w = Train::From(old_head); w != nullptr; w = w->GetNextUnit()) num_units++;
|
||||
|
||||
Train **old_vehs = CallocT<Train *>(num_units); ///< Will store vehicles of the old chain in their order
|
||||
Train **new_vehs = CallocT<Train *>(num_units); ///< New vehicles corresponding to old_vehs or NULL if no replacement
|
||||
Train **new_vehs = CallocT<Train *>(num_units); ///< New vehicles corresponding to old_vehs or nullptr if no replacement
|
||||
Money *new_costs = MallocT<Money>(num_units); ///< Costs for buying and refitting the new vehicles
|
||||
|
||||
/* Collect vehicles and build replacements
|
||||
* Note: The replacement vehicles can only successfully build as long as the old vehicles are still in their chain */
|
||||
int i;
|
||||
Train *w;
|
||||
for (w = Train::From(old_head), i = 0; w != NULL; w = w->GetNextUnit(), i++) {
|
||||
for (w = Train::From(old_head), i = 0; w != nullptr; w = w->GetNextUnit(), i++) {
|
||||
assert(i < num_units);
|
||||
old_vehs[i] = w;
|
||||
|
||||
|
@ -468,41 +468,41 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
if (cost.Failed()) break;
|
||||
|
||||
new_costs[i] = ret.GetCost();
|
||||
if (new_vehs[i] != NULL) *nothing_to_do = false;
|
||||
if (new_vehs[i] != nullptr) *nothing_to_do = false;
|
||||
}
|
||||
Train *new_head = (new_vehs[0] != NULL ? new_vehs[0] : old_vehs[0]);
|
||||
Train *new_head = (new_vehs[0] != nullptr ? new_vehs[0] : old_vehs[0]);
|
||||
|
||||
/* Note: When autoreplace has already failed here, old_vehs[] is not completely initialized. But it is also not needed. */
|
||||
if (cost.Succeeded()) {
|
||||
/* Separate the head, so we can start constructing the new chain */
|
||||
Train *second = Train::From(old_head)->GetNextUnit();
|
||||
if (second != NULL) cost.AddCost(CmdMoveVehicle(second, NULL, DC_EXEC | DC_AUTOREPLACE, true));
|
||||
if (second != nullptr) cost.AddCost(CmdMoveVehicle(second, nullptr, DC_EXEC | DC_AUTOREPLACE, true));
|
||||
|
||||
assert(Train::From(new_head)->GetNextUnit() == NULL);
|
||||
assert(Train::From(new_head)->GetNextUnit() == nullptr);
|
||||
|
||||
/* Append engines to the new chain
|
||||
* We do this from back to front, so that the head of the temporary vehicle chain does not change all the time.
|
||||
* That way we also have less trouble when exceeding the unitnumber limit.
|
||||
* OTOH the vehicle attach callback is more expensive this way :s */
|
||||
Train *last_engine = NULL; ///< Shall store the last engine unit after this step
|
||||
Train *last_engine = nullptr; ///< Shall store the last engine unit after this step
|
||||
if (cost.Succeeded()) {
|
||||
for (int i = num_units - 1; i > 0; i--) {
|
||||
Train *append = (new_vehs[i] != NULL ? new_vehs[i] : old_vehs[i]);
|
||||
Train *append = (new_vehs[i] != nullptr ? new_vehs[i] : old_vehs[i]);
|
||||
|
||||
if (RailVehInfo(append->engine_type)->railveh_type == RAILVEH_WAGON) continue;
|
||||
|
||||
if (new_vehs[i] != NULL) {
|
||||
if (new_vehs[i] != nullptr) {
|
||||
/* Move the old engine to a separate row with DC_AUTOREPLACE. Else
|
||||
* moving the wagon in front may fail later due to unitnumber limit.
|
||||
* (We have to attach wagons without DC_AUTOREPLACE.) */
|
||||
CmdMoveVehicle(old_vehs[i], NULL, DC_EXEC | DC_AUTOREPLACE, false);
|
||||
CmdMoveVehicle(old_vehs[i], nullptr, DC_EXEC | DC_AUTOREPLACE, false);
|
||||
}
|
||||
|
||||
if (last_engine == NULL) last_engine = append;
|
||||
if (last_engine == nullptr) last_engine = append;
|
||||
cost.AddCost(CmdMoveVehicle(append, new_head, DC_EXEC, false));
|
||||
if (cost.Failed()) break;
|
||||
}
|
||||
if (last_engine == NULL) last_engine = new_head;
|
||||
if (last_engine == nullptr) last_engine = new_head;
|
||||
}
|
||||
|
||||
/* When wagon removal is enabled and the new engines without any wagons are already longer than the old, we have to fail */
|
||||
|
@ -513,8 +513,8 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
*/
|
||||
if (cost.Succeeded()) {
|
||||
for (int i = num_units - 1; i > 0; i--) {
|
||||
assert(last_engine != NULL);
|
||||
Vehicle *append = (new_vehs[i] != NULL ? new_vehs[i] : old_vehs[i]);
|
||||
assert(last_engine != nullptr);
|
||||
Vehicle *append = (new_vehs[i] != nullptr ? new_vehs[i] : old_vehs[i]);
|
||||
|
||||
if (RailVehInfo(append->engine_type)->railveh_type == RAILVEH_WAGON) {
|
||||
/* Insert wagon after 'last_engine' */
|
||||
|
@ -524,7 +524,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
* to the train becoming too long, or the train becoming longer
|
||||
* would move the vehicle to the empty vehicle chain. */
|
||||
if (wagon_removal && (res.Failed() ? res.GetErrorMessage() == STR_ERROR_TRAIN_TOO_LONG : new_head->gcache.cached_total_length > old_total_length)) {
|
||||
CmdMoveVehicle(append, NULL, DC_EXEC | DC_AUTOREPLACE, false);
|
||||
CmdMoveVehicle(append, nullptr, DC_EXEC | DC_AUTOREPLACE, false);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -543,7 +543,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
assert(new_head->gcache.cached_total_length <= _settings_game.vehicle.max_train_length * TILE_SIZE);
|
||||
for (int i = 1; i < num_units; i++) {
|
||||
Vehicle *wagon = new_vehs[i];
|
||||
if (wagon == NULL) continue;
|
||||
if (wagon == nullptr) continue;
|
||||
if (wagon->First() == new_head) break;
|
||||
|
||||
assert(RailVehInfo(wagon->engine_type)->railveh_type == RAILVEH_WAGON);
|
||||
|
@ -551,7 +551,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
/* Sell wagon */
|
||||
CommandCost ret = DoCommand(0, wagon->index, 0, DC_EXEC, GetCmdSellVeh(wagon));
|
||||
assert(ret.Succeeded());
|
||||
new_vehs[i] = NULL;
|
||||
new_vehs[i] = nullptr;
|
||||
|
||||
/* Revert the money subtraction when the vehicle was built.
|
||||
* This value is different from the sell value, esp. because of refitting */
|
||||
|
@ -572,7 +572,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
for (int i = 0; i < num_units; i++) {
|
||||
Vehicle *w = old_vehs[i];
|
||||
/* Is the vehicle again part of the new chain?
|
||||
* Note: We cannot test 'new_vehs[i] != NULL' as wagon removal might cause to remove both */
|
||||
* Note: We cannot test 'new_vehs[i] != nullptr' as wagon removal might cause to remove both */
|
||||
if (w->First() == new_head) continue;
|
||||
|
||||
if ((flags & DC_EXEC) != 0) TransferCargo(w, new_head, true);
|
||||
|
@ -582,8 +582,8 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
* it from failing due to engine limits. */
|
||||
cost.AddCost(DoCommand(0, w->index, 0, flags | DC_AUTOREPLACE, GetCmdSellVeh(w)));
|
||||
if ((flags & DC_EXEC) != 0) {
|
||||
old_vehs[i] = NULL;
|
||||
if (i == 0) old_head = NULL;
|
||||
old_vehs[i] = nullptr;
|
||||
if (i == 0) old_head = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -596,9 +596,9 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
if ((flags & DC_EXEC) == 0) {
|
||||
/* Separate the head, so we can reattach the old vehicles */
|
||||
Train *second = Train::From(old_head)->GetNextUnit();
|
||||
if (second != NULL) CmdMoveVehicle(second, NULL, DC_EXEC | DC_AUTOREPLACE, true);
|
||||
if (second != nullptr) CmdMoveVehicle(second, nullptr, DC_EXEC | DC_AUTOREPLACE, true);
|
||||
|
||||
assert(Train::From(old_head)->GetNextUnit() == NULL);
|
||||
assert(Train::From(old_head)->GetNextUnit() == nullptr);
|
||||
|
||||
for (int i = num_units - 1; i > 0; i--) {
|
||||
CommandCost ret = CmdMoveVehicle(old_vehs[i], old_head, DC_EXEC | DC_AUTOREPLACE, false);
|
||||
|
@ -610,9 +610,9 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
/* Finally undo buying of new vehicles */
|
||||
if ((flags & DC_EXEC) == 0) {
|
||||
for (int i = num_units - 1; i >= 0; i--) {
|
||||
if (new_vehs[i] != NULL) {
|
||||
if (new_vehs[i] != nullptr) {
|
||||
DoCommand(0, new_vehs[i]->index, 0, DC_EXEC, GetCmdSellVeh(new_vehs[i]));
|
||||
new_vehs[i] = NULL;
|
||||
new_vehs[i] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -622,11 +622,11 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
free(new_costs);
|
||||
} else {
|
||||
/* Build and refit replacement vehicle */
|
||||
Vehicle *new_head = NULL;
|
||||
Vehicle *new_head = nullptr;
|
||||
cost.AddCost(BuildReplacementVehicle(old_head, &new_head, true));
|
||||
|
||||
/* Was a new vehicle constructed? */
|
||||
if (cost.Succeeded() && new_head != NULL) {
|
||||
if (cost.Succeeded() && new_head != nullptr) {
|
||||
*nothing_to_do = false;
|
||||
|
||||
/* The new vehicle is constructed, now take over orders and everything... */
|
||||
|
@ -666,7 +666,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
|
|||
CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
Vehicle *v = Vehicle::GetIfValid(p1);
|
||||
if (v == NULL) return CMD_ERROR;
|
||||
if (v == nullptr) return CMD_ERROR;
|
||||
|
||||
CommandCost ret = CheckOwnership(v->owner);
|
||||
if (ret.Failed()) return ret;
|
||||
|
@ -690,12 +690,12 @@ CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1
|
|||
/* Test whether any replacement is set, before issuing a whole lot of commands that would end in nothing changed */
|
||||
Vehicle *w = v;
|
||||
bool any_replacements = false;
|
||||
while (w != NULL) {
|
||||
while (w != nullptr) {
|
||||
EngineID e;
|
||||
CommandCost cost = GetNewEngineType(w, c, false, e);
|
||||
if (cost.Failed()) return cost;
|
||||
any_replacements |= (e != INVALID_ENGINE);
|
||||
w = (!free_wagon && w->type == VEH_TRAIN ? Train::From(w)->GetNextUnit() : NULL);
|
||||
w = (!free_wagon && w->type == VEH_TRAIN ? Train::From(w)->GetNextUnit() : nullptr);
|
||||
}
|
||||
|
||||
CommandCost cost = CommandCost(EXPENSES_NEW_VEHICLES, 0);
|
||||
|
@ -756,7 +756,7 @@ CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1
|
|||
CommandCost CmdSetAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
Company *c = Company::GetIfValid(_current_company);
|
||||
if (c == NULL) return CMD_ERROR;
|
||||
if (c == nullptr) return CMD_ERROR;
|
||||
|
||||
EngineID old_engine_type = GB(p2, 0, 16);
|
||||
EngineID new_engine_type = GB(p2, 16, 16);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "company_base.h"
|
||||
|
||||
void RemoveAllEngineReplacement(EngineRenewList *erl);
|
||||
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group, bool *replace_when_old = NULL);
|
||||
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group, bool *replace_when_old = nullptr);
|
||||
CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlag flags);
|
||||
CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, DoCommandFlag flags);
|
||||
|
||||
|
@ -38,7 +38,7 @@ static inline void RemoveAllEngineReplacementForCompany(Company *c)
|
|||
* @return The engine type to replace with, or INVALID_ENGINE if no
|
||||
* replacement is in the list.
|
||||
*/
|
||||
static inline EngineID EngineReplacementForCompany(const Company *c, EngineID engine, GroupID group, bool *replace_when_old = NULL)
|
||||
static inline EngineID EngineReplacementForCompany(const Company *c, EngineID engine, GroupID group, bool *replace_when_old = nullptr)
|
||||
{
|
||||
return EngineReplacement(c->engine_renew_list, engine, group, replace_when_old);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ void BaseConsist::CopyConsistPropertiesFrom(const BaseConsist *src)
|
|||
if (this == src) return;
|
||||
|
||||
free(this->name);
|
||||
this->name = src->name != NULL ? stredup(src->name) : NULL;
|
||||
this->name = src->name != nullptr ? stredup(src->name) : nullptr;
|
||||
|
||||
this->current_order_time = src->current_order_time;
|
||||
this->lateness_counter = src->lateness_counter;
|
||||
|
|
|
@ -31,7 +31,7 @@ struct BaseConsist {
|
|||
|
||||
uint16 vehicle_flags; ///< Used for gradual loading and other miscellaneous things (@see VehicleFlags enum)
|
||||
|
||||
BaseConsist() : name(NULL) {}
|
||||
BaseConsist() : name(nullptr) {}
|
||||
virtual ~BaseConsist();
|
||||
|
||||
void CopyConsistPropertiesFrom(const BaseConsist *src);
|
||||
|
|
|
@ -118,9 +118,9 @@ struct BaseSet {
|
|||
* @param isocode the isocode to search for
|
||||
* @return the description
|
||||
*/
|
||||
const char *GetDescription(const char *isocode = NULL) const
|
||||
const char *GetDescription(const char *isocode = nullptr) const
|
||||
{
|
||||
if (isocode != NULL) {
|
||||
if (isocode != nullptr) {
|
||||
/* First the full ISO code */
|
||||
for (const auto &pair : this->description) {
|
||||
if (strcmp(pair.first, isocode) == 0) return pair.second;
|
||||
|
@ -151,17 +151,17 @@ struct BaseSet {
|
|||
/**
|
||||
* Search a textfile file next to this base media.
|
||||
* @param type The type of the textfile to search for.
|
||||
* @return The filename for the textfile, \c NULL otherwise.
|
||||
* @return The filename for the textfile, \c nullptr otherwise.
|
||||
*/
|
||||
const char *GetTextfile(TextfileType type) const
|
||||
{
|
||||
for (uint i = 0; i < NUM_FILES; i++) {
|
||||
const char *textfile = ::GetTextfile(type, BASESET_DIR, this->files[i].filename);
|
||||
if (textfile != NULL) {
|
||||
if (textfile != nullptr) {
|
||||
return textfile;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -231,7 +231,7 @@ template <class Tbase_set> /* static */ Tbase_set *BaseMedia<Tbase_set>::duplica
|
|||
* @param ci The content info to compare it to.
|
||||
* @param md5sum Should the MD5 checksum be tested as well?
|
||||
* @param s The list with sets.
|
||||
* @return The filename of the first file of the base set, or \c NULL if there is no match.
|
||||
* @return The filename of the first file of the base set, or \c nullptr if there is no match.
|
||||
*/
|
||||
template <class Tbase_set>
|
||||
const char *TryGetBaseSetFile(const ContentInfo *ci, bool md5sum, const Tbase_set *s);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
*/
|
||||
#define fetch_metadata(name) \
|
||||
item = metadata->GetItem(name, false); \
|
||||
if (item == NULL || StrEmpty(item->value)) { \
|
||||
if (item == nullptr || StrEmpty(item->value)) { \
|
||||
DEBUG(grf, 0, "Base " SET_TYPE "set detail loading: %s field missing.", name); \
|
||||
DEBUG(grf, 0, " Is %s readable for the user running OpenTTD?", full_filename); \
|
||||
return false; \
|
||||
|
@ -50,7 +50,7 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
|
|||
this->description[stredup("")] = stredup(item->value);
|
||||
|
||||
/* Add the translations of the descriptions too. */
|
||||
for (const IniItem *item = metadata->item; item != NULL; item = item->next) {
|
||||
for (const IniItem *item = metadata->item; item != nullptr; item = item->next) {
|
||||
if (strncmp("description.", item->name, 12) != 0) continue;
|
||||
|
||||
this->description[stredup(item->name + 12)] = stredup(item->value);
|
||||
|
@ -65,7 +65,7 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
|
|||
this->version = atoi(item->value);
|
||||
|
||||
item = metadata->GetItem("fallback", false);
|
||||
this->fallback = (item != NULL && strcmp(item->value, "0") != 0 && strcmp(item->value, "false") != 0);
|
||||
this->fallback = (item != nullptr && strcmp(item->value, "0") != 0 && strcmp(item->value, "false") != 0);
|
||||
|
||||
/* For each of the file types we want to find the file, MD5 checksums and warning messages. */
|
||||
IniGroup *files = ini->GetGroup("files");
|
||||
|
@ -75,14 +75,14 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
|
|||
MD5File *file = &this->files[i];
|
||||
/* Find the filename first. */
|
||||
item = files->GetItem(BaseSet<T, Tnum_files, Tsearch_in_tars>::file_names[i], false);
|
||||
if (item == NULL || (item->value == NULL && !allow_empty_filename)) {
|
||||
if (item == nullptr || (item->value == nullptr && !allow_empty_filename)) {
|
||||
DEBUG(grf, 0, "No " SET_TYPE " file for: %s (in %s)", BaseSet<T, Tnum_files, Tsearch_in_tars>::file_names[i], full_filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *filename = item->value;
|
||||
if (filename == NULL) {
|
||||
file->filename = NULL;
|
||||
if (filename == nullptr) {
|
||||
file->filename = nullptr;
|
||||
/* If we list no file, that file must be valid */
|
||||
this->valid_files++;
|
||||
this->found_files++;
|
||||
|
@ -93,7 +93,7 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
|
|||
|
||||
/* Then find the MD5 checksum */
|
||||
item = md5s->GetItem(filename, false);
|
||||
if (item == NULL || item->value == NULL) {
|
||||
if (item == nullptr || item->value == nullptr) {
|
||||
DEBUG(grf, 0, "No MD5 checksum specified for: %s (in %s)", filename, full_filename);
|
||||
return false;
|
||||
}
|
||||
|
@ -119,8 +119,8 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
|
|||
|
||||
/* Then find the warning message when the file's missing */
|
||||
item = origin->GetItem(filename, false);
|
||||
if (item == NULL) item = origin->GetItem("default", false);
|
||||
if (item == NULL) {
|
||||
if (item == nullptr) item = origin->GetItem("default", false);
|
||||
if (item == nullptr) {
|
||||
DEBUG(grf, 1, "No origin warning message specified for: %s", filename);
|
||||
file->missing_warning = stredup("");
|
||||
} else {
|
||||
|
@ -163,21 +163,21 @@ bool BaseMedia<Tbase_set>::AddFile(const char *filename, size_t basepath_length,
|
|||
|
||||
char *path = stredup(filename + basepath_length);
|
||||
char *psep = strrchr(path, PATHSEPCHAR);
|
||||
if (psep != NULL) {
|
||||
if (psep != nullptr) {
|
||||
psep[1] = '\0';
|
||||
} else {
|
||||
*path = '\0';
|
||||
}
|
||||
|
||||
if (set->FillSetDetails(ini, path, filename)) {
|
||||
Tbase_set *duplicate = NULL;
|
||||
for (Tbase_set *c = BaseMedia<Tbase_set>::available_sets; c != NULL; c = c->next) {
|
||||
Tbase_set *duplicate = nullptr;
|
||||
for (Tbase_set *c = BaseMedia<Tbase_set>::available_sets; c != nullptr; c = c->next) {
|
||||
if (strcmp(c->name, set->name) == 0 || c->shortname == set->shortname) {
|
||||
duplicate = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (duplicate != NULL) {
|
||||
if (duplicate != nullptr) {
|
||||
/* The more complete set takes precedence over the version number. */
|
||||
if ((duplicate->valid_files == set->valid_files && duplicate->version >= set->version) ||
|
||||
duplicate->valid_files > set->valid_files) {
|
||||
|
@ -205,7 +205,7 @@ bool BaseMedia<Tbase_set>::AddFile(const char *filename, size_t basepath_length,
|
|||
}
|
||||
} else {
|
||||
Tbase_set **last = &BaseMedia<Tbase_set>::available_sets;
|
||||
while (*last != NULL) last = &(*last)->next;
|
||||
while (*last != nullptr) last = &(*last)->next;
|
||||
|
||||
*last = set;
|
||||
ret = true;
|
||||
|
@ -238,7 +238,7 @@ template <class Tbase_set>
|
|||
return true;
|
||||
}
|
||||
|
||||
for (const Tbase_set *s = BaseMedia<Tbase_set>::available_sets; s != NULL; s = s->next) {
|
||||
for (const Tbase_set *s = BaseMedia<Tbase_set>::available_sets; s != nullptr; s = s->next) {
|
||||
if (strcmp(name, s->name) == 0) {
|
||||
BaseMedia<Tbase_set>::used_set = s;
|
||||
CheckExternalFiles();
|
||||
|
@ -258,7 +258,7 @@ template <class Tbase_set>
|
|||
/* static */ char *BaseMedia<Tbase_set>::GetSetsList(char *p, const char *last)
|
||||
{
|
||||
p += seprintf(p, last, "List of " SET_TYPE " sets:\n");
|
||||
for (const Tbase_set *s = BaseMedia<Tbase_set>::available_sets; s != NULL; s = s->next) {
|
||||
for (const Tbase_set *s = BaseMedia<Tbase_set>::available_sets; s != nullptr; s = s->next) {
|
||||
p += seprintf(p, last, "%18s: %s", s->name, s->GetDescription());
|
||||
int invalid = s->GetNumInvalid();
|
||||
if (invalid != 0) {
|
||||
|
@ -281,7 +281,7 @@ template <class Tbase_set>
|
|||
|
||||
template <class Tbase_set> const char *TryGetBaseSetFile(const ContentInfo *ci, bool md5sum, const Tbase_set *s)
|
||||
{
|
||||
for (; s != NULL; s = s->next) {
|
||||
for (; s != nullptr; s = s->next) {
|
||||
if (s->GetNumMissing() != 0) continue;
|
||||
|
||||
if (s->shortname != ci->unique_id) continue;
|
||||
|
@ -296,14 +296,14 @@ template <class Tbase_set> const char *TryGetBaseSetFile(const ContentInfo *ci,
|
|||
}
|
||||
if (memcmp(md5, ci->md5sum, sizeof(md5)) == 0) return s->files[0].filename;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <class Tbase_set>
|
||||
/* static */ bool BaseMedia<Tbase_set>::HasSet(const ContentInfo *ci, bool md5sum)
|
||||
{
|
||||
return (TryGetBaseSetFile(ci, md5sum, BaseMedia<Tbase_set>::available_sets) != NULL) ||
|
||||
(TryGetBaseSetFile(ci, md5sum, BaseMedia<Tbase_set>::duplicate_sets) != NULL);
|
||||
return (TryGetBaseSetFile(ci, md5sum, BaseMedia<Tbase_set>::available_sets) != nullptr) ||
|
||||
(TryGetBaseSetFile(ci, md5sum, BaseMedia<Tbase_set>::duplicate_sets) != nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -314,7 +314,7 @@ template <class Tbase_set>
|
|||
/* static */ int BaseMedia<Tbase_set>::GetNumSets()
|
||||
{
|
||||
int n = 0;
|
||||
for (const Tbase_set *s = BaseMedia<Tbase_set>::available_sets; s != NULL; s = s->next) {
|
||||
for (const Tbase_set *s = BaseMedia<Tbase_set>::available_sets; s != nullptr; s = s->next) {
|
||||
if (s != BaseMedia<Tbase_set>::used_set && s->GetNumMissing() != 0) continue;
|
||||
n++;
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ template <class Tbase_set>
|
|||
/* static */ int BaseMedia<Tbase_set>::GetIndexOfUsedSet()
|
||||
{
|
||||
int n = 0;
|
||||
for (const Tbase_set *s = BaseMedia<Tbase_set>::available_sets; s != NULL; s = s->next) {
|
||||
for (const Tbase_set *s = BaseMedia<Tbase_set>::available_sets; s != nullptr; s = s->next) {
|
||||
if (s == BaseMedia<Tbase_set>::used_set) return n;
|
||||
if (s->GetNumMissing() != 0) continue;
|
||||
n++;
|
||||
|
@ -344,7 +344,7 @@ template <class Tbase_set>
|
|||
template <class Tbase_set>
|
||||
/* static */ const Tbase_set *BaseMedia<Tbase_set>::GetSet(int index)
|
||||
{
|
||||
for (const Tbase_set *s = BaseMedia<Tbase_set>::available_sets; s != NULL; s = s->next) {
|
||||
for (const Tbase_set *s = BaseMedia<Tbase_set>::available_sets; s != nullptr; s = s->next) {
|
||||
if (s != BaseMedia<Tbase_set>::used_set && s->GetNumMissing() != 0) continue;
|
||||
if (index == 0) return s;
|
||||
index--;
|
||||
|
|
|
@ -220,7 +220,7 @@ struct SpecializedStation : public BaseStation {
|
|||
*/
|
||||
static inline T *GetIfValid(size_t index)
|
||||
{
|
||||
return IsValidID(index) ? Get(index) : NULL;
|
||||
return IsValidID(index) ? Get(index) : nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -414,7 +414,7 @@ void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, in
|
|||
uint32 *udst = (uint32 *)dst;
|
||||
const uint32 *src = (const uint32 *)video;
|
||||
|
||||
if (this->anim_buf == NULL) return;
|
||||
if (this->anim_buf == nullptr) return;
|
||||
|
||||
const uint16 *anim_line = this->ScreenToAnimOffset((const uint32 *)video) + this->anim_buf;
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ protected:
|
|||
|
||||
public:
|
||||
Blitter_32bppAnim() :
|
||||
anim_buf(NULL),
|
||||
anim_alloc(NULL),
|
||||
anim_buf(nullptr),
|
||||
anim_alloc(nullptr),
|
||||
anim_buf_width(0),
|
||||
anim_buf_height(0),
|
||||
anim_buf_pitch(0)
|
||||
|
|
|
@ -167,7 +167,7 @@ Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::Sprite *sprite, Alloca
|
|||
uint trans = 0;
|
||||
uint pixels = 0;
|
||||
uint last_colour = 0;
|
||||
byte *count_dst = NULL;
|
||||
byte *count_dst = nullptr;
|
||||
|
||||
/* Store the scaled image */
|
||||
const SpriteLoader::CommonPixel *src = &sprite[i].data[y * sprite[i].width];
|
||||
|
@ -176,11 +176,11 @@ Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::Sprite *sprite, Alloca
|
|||
uint colour = src++->m;
|
||||
|
||||
if (last_colour == 0 || colour == 0 || pixels == 255) {
|
||||
if (count_dst != NULL) {
|
||||
if (count_dst != nullptr) {
|
||||
/* Write how many non-transparent bytes we get */
|
||||
*count_dst = pixels;
|
||||
pixels = 0;
|
||||
count_dst = NULL;
|
||||
count_dst = nullptr;
|
||||
}
|
||||
/* As long as we find transparency bytes, keep counting */
|
||||
if (colour == 0 && trans != 255) {
|
||||
|
@ -206,7 +206,7 @@ Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::Sprite *sprite, Alloca
|
|||
}
|
||||
}
|
||||
|
||||
if (count_dst != NULL) *count_dst = pixels;
|
||||
if (count_dst != nullptr) *count_dst = pixels;
|
||||
|
||||
/* Write line-ending */
|
||||
*dst = 0; dst++;
|
||||
|
|
|
@ -48,7 +48,7 @@ private:
|
|||
*/
|
||||
static Blitter **GetActiveBlitter()
|
||||
{
|
||||
static Blitter *s_blitter = NULL;
|
||||
static Blitter *s_blitter = nullptr;
|
||||
return &s_blitter;
|
||||
}
|
||||
|
||||
|
@ -58,8 +58,8 @@ protected:
|
|||
* @param name The name of the blitter.
|
||||
* @param description A longer description for the blitter.
|
||||
* @param usable Whether the blitter is usable (on the current computer). For example for disabling SSE blitters when the CPU can't handle them.
|
||||
* @pre name != NULL.
|
||||
* @pre description != NULL.
|
||||
* @pre name != nullptr.
|
||||
* @pre description != nullptr.
|
||||
* @pre There is no blitter registered with this name.
|
||||
*/
|
||||
BlitterFactory(const char *name, const char *description, bool usable = true) :
|
||||
|
@ -96,7 +96,7 @@ public:
|
|||
static Blitter *SelectBlitter(const char *name)
|
||||
{
|
||||
BlitterFactory *b = GetBlitterFactory(name);
|
||||
if (b == NULL) return NULL;
|
||||
if (b == nullptr) return nullptr;
|
||||
|
||||
Blitter *newb = b->CreateInstance();
|
||||
delete *GetActiveBlitter();
|
||||
|
@ -109,7 +109,7 @@ public:
|
|||
/**
|
||||
* Get the blitter factory with the given name.
|
||||
* @param name the blitter factory to select.
|
||||
* @return The blitter factory, or NULL when there isn't one with the wanted name.
|
||||
* @return The blitter factory, or nullptr when there isn't one with the wanted name.
|
||||
*/
|
||||
static BlitterFactory *GetBlitterFactory(const char *name)
|
||||
{
|
||||
|
@ -128,7 +128,7 @@ public:
|
|||
}
|
||||
#endif /* defined(WITH_COCOA) */
|
||||
#endif /* defined(DEDICATED) */
|
||||
if (GetBlitters().size() == 0) return NULL;
|
||||
if (GetBlitters().size() == 0) return nullptr;
|
||||
const char *bname = (StrEmpty(name)) ? default_blitter : name;
|
||||
|
||||
Blitters::iterator it = GetBlitters().begin();
|
||||
|
@ -138,7 +138,7 @@ public:
|
|||
return b;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override {};
|
||||
void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override {};
|
||||
Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override;
|
||||
void *MoveTo(void *video, int x, int y) override { return NULL; };
|
||||
void *MoveTo(void *video, int x, int y) override { return nullptr; };
|
||||
void SetPixel(void *video, int x, int y, uint8 colour) override {};
|
||||
void DrawRect(void *video, int width, int height, uint8 colour) override {};
|
||||
void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override {};
|
||||
|
|
|
@ -319,7 +319,7 @@ static inline bool BmpRead24(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
|||
bool BmpReadHeader(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
{
|
||||
uint32 header_size;
|
||||
assert(info != NULL);
|
||||
assert(info != nullptr);
|
||||
MemSetT(info, 0);
|
||||
|
||||
/* Reading BMP header */
|
||||
|
@ -390,7 +390,7 @@ bool BmpReadHeader(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
|||
*/
|
||||
bool BmpReadBitmap(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
||||
{
|
||||
assert(info != NULL && data != NULL);
|
||||
assert(info != nullptr && data != nullptr);
|
||||
|
||||
data->bitmap = CallocT<byte>(info->width * info->height * ((info->bpp == 24) ? 3 : 1));
|
||||
|
||||
|
@ -413,7 +413,7 @@ bool BmpReadBitmap(BmpBuffer *buffer, BmpInfo *info, BmpData *data)
|
|||
|
||||
void BmpDestroyData(BmpData *data)
|
||||
{
|
||||
assert(data != NULL);
|
||||
assert(data != nullptr);
|
||||
free(data->palette);
|
||||
free(data->bitmap);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ static const struct NWidgetPart _background_widgets[] = {
|
|||
* Window description for the background window to prevent smearing.
|
||||
*/
|
||||
static WindowDesc _background_desc(
|
||||
WDP_MANUAL, NULL, 0, 0,
|
||||
WDP_MANUAL, nullptr, 0, 0,
|
||||
WC_BOOTSTRAP, WC_NONE,
|
||||
0,
|
||||
_background_widgets, lengthof(_background_widgets)
|
||||
|
@ -73,7 +73,7 @@ static const NWidgetPart _nested_boostrap_download_status_window_widgets[] = {
|
|||
|
||||
/** Window description for the download window */
|
||||
static WindowDesc _bootstrap_download_status_window_desc(
|
||||
WDP_CENTER, NULL, 0, 0,
|
||||
WDP_CENTER, nullptr, 0, 0,
|
||||
WC_NETWORK_STATUS_WINDOW, WC_NONE,
|
||||
WDF_MODAL,
|
||||
_nested_boostrap_download_status_window_widgets, lengthof(_nested_boostrap_download_status_window_widgets)
|
||||
|
@ -118,7 +118,7 @@ static const NWidgetPart _bootstrap_query_widgets[] = {
|
|||
|
||||
/** The window description for the query. */
|
||||
static WindowDesc _bootstrap_query_desc(
|
||||
WDP_CENTER, NULL, 0, 0,
|
||||
WDP_CENTER, nullptr, 0, 0,
|
||||
WC_CONFIRM_POPUP_QUERY, WC_NONE,
|
||||
0,
|
||||
_bootstrap_query_widgets, lengthof(_bootstrap_query_widgets)
|
||||
|
@ -214,7 +214,7 @@ public:
|
|||
*/
|
||||
bool HandleBootstrap()
|
||||
{
|
||||
if (BaseGraphics::GetUsedSet() != NULL) return true;
|
||||
if (BaseGraphics::GetUsedSet() != nullptr) return true;
|
||||
|
||||
/* No user interface, bail out with an error. */
|
||||
if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 0) goto failure;
|
||||
|
@ -255,7 +255,7 @@ bool HandleBootstrap()
|
|||
if (_exit_game) return false;
|
||||
|
||||
/* Try to probe the graphics. Should work this time. */
|
||||
if (!BaseGraphics::SetSet(NULL)) goto failure;
|
||||
if (!BaseGraphics::SetSet(nullptr)) goto failure;
|
||||
|
||||
/* Finally we can continue heading for the menu. */
|
||||
_game_mode = GM_MENU;
|
||||
|
|
|
@ -392,7 +392,7 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo
|
|||
StringID errmsg = INVALID_STRING_ID;
|
||||
CommandCost ret = DoCommand(end, start, type, CommandFlagsToDCFlags(GetCommandFlags(CMD_BUILD_BRIDGE)) | DC_QUERY_COST, CMD_BUILD_BRIDGE);
|
||||
|
||||
GUIBridgeList *bl = NULL;
|
||||
GUIBridgeList *bl = nullptr;
|
||||
if (ret.Failed()) {
|
||||
errmsg = ret.GetErrorMessage();
|
||||
} else {
|
||||
|
@ -427,7 +427,7 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo
|
|||
}
|
||||
}
|
||||
|
||||
if (bl != NULL && bl->size() != 0) {
|
||||
if (bl != nullptr && bl->size() != 0) {
|
||||
new BuildBridgeWindow(&_build_bridge_desc, start, end, type, bl);
|
||||
} else {
|
||||
delete bl;
|
||||
|
|
|
@ -833,7 +833,7 @@ static int DrawAircraftPurchaseInfo(int left, int right, int y, EngineID engine_
|
|||
*/
|
||||
static uint ShowAdditionalText(int left, int right, int y, EngineID engine)
|
||||
{
|
||||
uint16 callback = GetVehicleCallback(CBID_VEHICLE_ADDITIONAL_TEXT, 0, 0, engine, NULL);
|
||||
uint16 callback = GetVehicleCallback(CBID_VEHICLE_ADDITIONAL_TEXT, 0, 0, engine, nullptr);
|
||||
if (callback == CALLBACK_FAILED || callback == 0x400) return y;
|
||||
const GRFFile *grffile = Engine::Get(engine)->GetGRF();
|
||||
if (callback > 0x400) {
|
||||
|
@ -1180,7 +1180,7 @@ struct BuildVehicleWindow : Window {
|
|||
|
||||
if (!this->listview_mode) {
|
||||
/* Query for cost and refitted capacity */
|
||||
CommandCost ret = DoCommand(this->window_number, this->sel_engine | (cargo << 24), 0, DC_QUERY_COST, GetCmdBuildVeh(this->vehicle_type), NULL);
|
||||
CommandCost ret = DoCommand(this->window_number, this->sel_engine | (cargo << 24), 0, DC_QUERY_COST, GetCmdBuildVeh(this->vehicle_type), nullptr);
|
||||
if (ret.Succeeded()) {
|
||||
this->te.cost = ret.GetCost() - e->GetCost();
|
||||
this->te.capacity = _returned_refit_capacity;
|
||||
|
@ -1316,7 +1316,7 @@ struct BuildVehicleWindow : Window {
|
|||
|
||||
this->eng_list.clear();
|
||||
|
||||
const Station *st = this->listview_mode ? NULL : Station::GetByTile(this->window_number);
|
||||
const Station *st = this->listview_mode ? nullptr : Station::GetByTile(this->window_number);
|
||||
|
||||
/* Make list of all available planes.
|
||||
* Also check to see if the previously selected plane is still available,
|
||||
|
@ -1408,8 +1408,8 @@ struct BuildVehicleWindow : Window {
|
|||
break;
|
||||
|
||||
case WID_BV_SHOW_HIDE: {
|
||||
const Engine *e = (this->sel_engine == INVALID_ENGINE) ? NULL : Engine::Get(this->sel_engine);
|
||||
if (e != NULL) {
|
||||
const Engine *e = (this->sel_engine == INVALID_ENGINE) ? nullptr : Engine::Get(this->sel_engine);
|
||||
if (e != nullptr) {
|
||||
DoCommandP(0, 0, this->sel_engine | (e->IsHidden(_current_company) ? 0 : (1u << 31)), CMD_SET_VEHICLE_VISIBILITY);
|
||||
}
|
||||
break;
|
||||
|
@ -1477,8 +1477,8 @@ struct BuildVehicleWindow : Window {
|
|||
break;
|
||||
|
||||
case WID_BV_SHOW_HIDE: {
|
||||
const Engine *e = (this->sel_engine == INVALID_ENGINE) ? NULL : Engine::Get(this->sel_engine);
|
||||
if (e != NULL && e->IsHidden(_local_company)) {
|
||||
const Engine *e = (this->sel_engine == INVALID_ENGINE) ? nullptr : Engine::Get(this->sel_engine);
|
||||
if (e != nullptr && e->IsHidden(_local_company)) {
|
||||
SetDParam(0, STR_BUY_VEHICLE_TRAIN_SHOW_TOGGLE_BUTTON + this->vehicle_type);
|
||||
} else {
|
||||
SetDParam(0, STR_BUY_VEHICLE_TRAIN_HIDE_TOGGLE_BUTTON + this->vehicle_type);
|
||||
|
@ -1567,9 +1567,9 @@ struct BuildVehicleWindow : Window {
|
|||
|
||||
void OnQueryTextFinished(char *str) override
|
||||
{
|
||||
if (str == NULL) return;
|
||||
if (str == nullptr) return;
|
||||
|
||||
DoCommandP(0, this->rename_engine, 0, CMD_RENAME_ENGINE | CMD_MSG(STR_ERROR_CAN_T_RENAME_TRAIN_TYPE + this->vehicle_type), NULL, str);
|
||||
DoCommandP(0, this->rename_engine, 0, CMD_RENAME_ENGINE | CMD_MSG(STR_ERROR_CAN_T_RENAME_TRAIN_TYPE + this->vehicle_type), nullptr, str);
|
||||
}
|
||||
|
||||
void OnDropdownSelect(int widget, int index) override
|
||||
|
|
|
@ -121,7 +121,7 @@ bool CargoDelivery::operator()(CargoPacket *cp)
|
|||
bool CargoLoad::operator()(CargoPacket *cp)
|
||||
{
|
||||
CargoPacket *cp_new = this->Preprocess(cp);
|
||||
if (cp_new == NULL) return false;
|
||||
if (cp_new == nullptr) return false;
|
||||
cp_new->SetLoadPlace(this->load_place);
|
||||
this->source->RemoveFromCache(cp_new, cp_new->Count());
|
||||
this->destination->Append(cp_new, VehicleCargoList::MTA_KEEP);
|
||||
|
@ -136,7 +136,7 @@ bool CargoLoad::operator()(CargoPacket *cp)
|
|||
bool CargoReservation::operator()(CargoPacket *cp)
|
||||
{
|
||||
CargoPacket *cp_new = this->Preprocess(cp);
|
||||
if (cp_new == NULL) return false;
|
||||
if (cp_new == nullptr) return false;
|
||||
cp_new->SetLoadPlace(this->load_place);
|
||||
this->source->reserved_count += cp_new->Count();
|
||||
this->source->RemoveFromCache(cp_new, cp_new->Count());
|
||||
|
@ -152,7 +152,7 @@ bool CargoReservation::operator()(CargoPacket *cp)
|
|||
bool CargoReturn::operator()(CargoPacket *cp)
|
||||
{
|
||||
CargoPacket *cp_new = this->Preprocess(cp);
|
||||
if (cp_new == NULL) cp_new = cp;
|
||||
if (cp_new == nullptr) cp_new = cp;
|
||||
assert(cp_new->Count() <= this->destination->reserved_count);
|
||||
this->source->RemoveFromMeta(cp_new, VehicleCargoList::MTA_LOAD, cp_new->Count());
|
||||
this->destination->reserved_count -= cp_new->Count();
|
||||
|
@ -168,7 +168,7 @@ bool CargoReturn::operator()(CargoPacket *cp)
|
|||
bool CargoTransfer::operator()(CargoPacket *cp)
|
||||
{
|
||||
CargoPacket *cp_new = this->Preprocess(cp);
|
||||
if (cp_new == NULL) return false;
|
||||
if (cp_new == nullptr) return false;
|
||||
this->source->RemoveFromMeta(cp_new, VehicleCargoList::MTA_TRANSFER, cp_new->Count());
|
||||
/* No transfer credits here as they were already granted during Stage(). */
|
||||
this->destination->Append(cp_new, cp_new->NextStation());
|
||||
|
@ -183,7 +183,7 @@ bool CargoTransfer::operator()(CargoPacket *cp)
|
|||
bool CargoShift::operator()(CargoPacket *cp)
|
||||
{
|
||||
CargoPacket *cp_new = this->Preprocess(cp);
|
||||
if (cp_new == NULL) cp_new = cp;
|
||||
if (cp_new == nullptr) cp_new = cp;
|
||||
this->source->RemoveFromMeta(cp_new, VehicleCargoList::MTA_KEEP, cp_new->Count());
|
||||
this->destination->Append(cp_new, VehicleCargoList::MTA_KEEP);
|
||||
return cp_new == cp;
|
||||
|
@ -197,7 +197,7 @@ bool CargoShift::operator()(CargoPacket *cp)
|
|||
bool StationCargoReroute::operator()(CargoPacket *cp)
|
||||
{
|
||||
CargoPacket *cp_new = this->Preprocess(cp);
|
||||
if (cp_new == NULL) cp_new = cp;
|
||||
if (cp_new == nullptr) cp_new = cp;
|
||||
StationID next = this->ge->GetVia(cp_new->SourceStation(), this->avoid, this->avoid2);
|
||||
assert(next != this->avoid && next != this->avoid2);
|
||||
if (this->source != this->destination) {
|
||||
|
@ -220,7 +220,7 @@ bool StationCargoReroute::operator()(CargoPacket *cp)
|
|||
bool VehicleCargoReroute::operator()(CargoPacket *cp)
|
||||
{
|
||||
CargoPacket *cp_new = this->Preprocess(cp);
|
||||
if (cp_new == NULL) cp_new = cp;
|
||||
if (cp_new == nullptr) cp_new = cp;
|
||||
if (cp_new->NextStation() == this->avoid || cp_new->NextStation() == this->avoid2) {
|
||||
cp->SetNextStation(this->ge->GetVia(cp_new->SourceStation(), this->avoid, this->avoid2));
|
||||
}
|
||||
|
|
|
@ -86,11 +86,11 @@ CargoPacket::CargoPacket(uint16 count, byte days_in_transit, StationID source, T
|
|||
/**
|
||||
* Split this packet in two and return the split off part.
|
||||
* @param new_size Size of the split part.
|
||||
* @return Split off part, or NULL if no packet could be allocated!
|
||||
* @return Split off part, or nullptr if no packet could be allocated!
|
||||
*/
|
||||
CargoPacket *CargoPacket::Split(uint new_size)
|
||||
{
|
||||
if (!CargoPacket::CanAllocateItem()) return NULL;
|
||||
if (!CargoPacket::CanAllocateItem()) return nullptr;
|
||||
|
||||
Money fs = this->FeederShare(new_size);
|
||||
CargoPacket *cp_new = new CargoPacket(new_size, this->days_in_transit, this->source, this->source_xy, this->loaded_at_xy, fs, this->source_type, this->source_id);
|
||||
|
@ -248,12 +248,12 @@ template <class Tinst, class Tcont>
|
|||
* @param cp Cargo packet to add.
|
||||
* @param action Either MTA_KEEP if you want to add the packet directly or MTA_LOAD
|
||||
* if you want to reserve it first.
|
||||
* @pre cp != NULL
|
||||
* @pre cp != nullptr
|
||||
* @pre action == MTA_LOAD || (action == MTA_KEEP && this->designation_counts[MTA_LOAD] == 0)
|
||||
*/
|
||||
void VehicleCargoList::Append(CargoPacket *cp, MoveToAction action)
|
||||
{
|
||||
assert(cp != NULL);
|
||||
assert(cp != nullptr);
|
||||
assert(action == MTA_LOAD ||
|
||||
(action == MTA_KEEP && this->action_counts[MTA_LOAD] == 0));
|
||||
this->AddToMeta(cp, action);
|
||||
|
@ -689,11 +689,11 @@ uint VehicleCargoList::Reroute(uint max_move, VehicleCargoList *dest, StationID
|
|||
* @note Do not use the cargo packet anymore after it has been appended to this CargoList!
|
||||
* @param next the next hop
|
||||
* @param cp the cargo packet to add
|
||||
* @pre cp != NULL
|
||||
* @pre cp != nullptr
|
||||
*/
|
||||
void StationCargoList::Append(CargoPacket *cp, StationID next)
|
||||
{
|
||||
assert(cp != NULL);
|
||||
assert(cp != nullptr);
|
||||
this->AddToCache(cp);
|
||||
|
||||
StationCargoPacketMap::List &list = this->packets[next];
|
||||
|
@ -776,7 +776,7 @@ uint StationCargoList::Truncate(uint max_move, StationCargoAmountMap *cargo_per_
|
|||
uint prev_count = this->count;
|
||||
uint moved = 0;
|
||||
uint loop = 0;
|
||||
bool do_count = cargo_per_source != NULL;
|
||||
bool do_count = cargo_per_source != nullptr;
|
||||
while (max_move > moved) {
|
||||
for (Iterator it(this->packets.begin()); it != this->packets.end();) {
|
||||
CargoPacket *cp = *it;
|
||||
|
|
|
@ -549,7 +549,7 @@ public:
|
|||
|
||||
uint Reserve(uint max_move, VehicleCargoList *dest, TileIndex load_place, StationIDStack next);
|
||||
uint Load(uint max_move, VehicleCargoList *dest, TileIndex load_place, StationIDStack next);
|
||||
uint Truncate(uint max_move = UINT_MAX, StationCargoAmountMap *cargo_per_source = NULL);
|
||||
uint Truncate(uint max_move = UINT_MAX, StationCargoAmountMap *cargo_per_source = nullptr);
|
||||
uint Reroute(uint max_move, StationCargoList *dest, StationID avoid, StationID avoid2, const GoodsEntry *ge);
|
||||
|
||||
/**
|
||||
|
|
|
@ -152,7 +152,7 @@ static inline bool IsCargoInClass(CargoID c, CargoClass cc)
|
|||
return (CargoSpec::Get(c)->classes & cc) != 0;
|
||||
}
|
||||
|
||||
#define FOR_ALL_CARGOSPECS_FROM(var, start) for (size_t cargospec_index = start; var = NULL, cargospec_index < CargoSpec::GetArraySize(); cargospec_index++) \
|
||||
#define FOR_ALL_CARGOSPECS_FROM(var, start) for (size_t cargospec_index = start; var = nullptr, cargospec_index < CargoSpec::GetArraySize(); cargospec_index++) \
|
||||
if ((var = CargoSpec::Get(cargospec_index))->IsValid())
|
||||
#define FOR_ALL_CARGOSPECS(var) FOR_ALL_CARGOSPECS_FROM(var, 0)
|
||||
|
||||
|
|
|
@ -186,9 +186,9 @@ struct CheatEntry {
|
|||
static const CheatEntry _cheats_ui[] = {
|
||||
{SLE_INT32, STR_CHEAT_MONEY, &_money_cheat_amount, &_cheats.money.been_used, &ClickMoneyCheat },
|
||||
{SLE_UINT8, STR_CHEAT_CHANGE_COMPANY, &_local_company, &_cheats.switch_company.been_used, &ClickChangeCompanyCheat },
|
||||
{SLE_BOOL, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, NULL },
|
||||
{SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, NULL },
|
||||
{SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, NULL },
|
||||
{SLE_BOOL, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, nullptr },
|
||||
{SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, nullptr },
|
||||
{SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, nullptr },
|
||||
{SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, &ClickSetProdCheat },
|
||||
{SLE_UINT8, STR_CHEAT_EDIT_MAX_HL, &_settings_game.construction.max_heightlevel, &_cheats.edit_max_hl.been_used, &ClickChangeMaxHlCheat },
|
||||
{SLE_INT32, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
|
||||
|
@ -365,7 +365,7 @@ struct CheatWindow : Window {
|
|||
switch (ce->type) {
|
||||
case SLE_BOOL:
|
||||
value ^= 1;
|
||||
if (ce->proc != NULL) ce->proc(value, 0);
|
||||
if (ce->proc != nullptr) ce->proc(value, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -393,7 +393,7 @@ struct CheatWindow : Window {
|
|||
void OnQueryTextFinished(char *str) override
|
||||
{
|
||||
/* Was 'cancel' pressed or nothing entered? */
|
||||
if (str == NULL || StrEmpty(str)) return;
|
||||
if (str == nullptr || StrEmpty(str)) return;
|
||||
|
||||
const CheatEntry *ce = &_cheats_ui[clicked_widget];
|
||||
int oldvalue = (int32)ReadValue(ce->variable, ce->type);
|
||||
|
|
|
@ -389,15 +389,15 @@ extern const TileTypeProcs _tile_type_clear_procs = {
|
|||
DrawTile_Clear, ///< draw_tile_proc
|
||||
GetSlopePixelZ_Clear, ///< get_slope_z_proc
|
||||
ClearTile_Clear, ///< clear_tile_proc
|
||||
NULL, ///< add_accepted_cargo_proc
|
||||
nullptr, ///< add_accepted_cargo_proc
|
||||
GetTileDesc_Clear, ///< get_tile_desc_proc
|
||||
GetTileTrackStatus_Clear, ///< get_tile_track_status_proc
|
||||
NULL, ///< click_tile_proc
|
||||
NULL, ///< animate_tile_proc
|
||||
nullptr, ///< click_tile_proc
|
||||
nullptr, ///< animate_tile_proc
|
||||
TileLoop_Clear, ///< tile_loop_proc
|
||||
ChangeTileOwner_Clear, ///< change_tile_owner_proc
|
||||
NULL, ///< add_produced_cargo_proc
|
||||
NULL, ///< vehicle_enter_tile_proc
|
||||
nullptr, ///< add_produced_cargo_proc
|
||||
nullptr, ///< vehicle_enter_tile_proc
|
||||
GetFoundation_Clear, ///< get_foundation_proc
|
||||
TerraformTile_Clear, ///< terraform_tile_proc
|
||||
};
|
||||
|
|
|
@ -361,7 +361,7 @@ static const Command _command_proc_table[] = {
|
|||
};
|
||||
|
||||
/*!
|
||||
* This function range-checks a cmd, and checks if the cmd is not NULL
|
||||
* This function range-checks a cmd, and checks if the cmd is not nullptr
|
||||
*
|
||||
* @param cmd The integer value of a command
|
||||
* @return true if the command is valid (and got a CommandProc function)
|
||||
|
@ -370,7 +370,7 @@ bool IsValidCommand(uint32 cmd)
|
|||
{
|
||||
cmd &= CMD_ID_MASK;
|
||||
|
||||
return cmd < lengthof(_command_proc_table) && _command_proc_table[cmd].proc != NULL;
|
||||
return cmd < lengthof(_command_proc_table) && _command_proc_table[cmd].proc != nullptr;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -594,7 +594,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallbac
|
|||
ShowCostOrIncomeAnimation(x, y, GetSlopePixelZ(x, y), res.GetCost());
|
||||
}
|
||||
|
||||
if (!estimate_only && !only_sending && callback != NULL) {
|
||||
if (!estimate_only && !only_sending && callback != nullptr) {
|
||||
callback(res, tile, p1, p2);
|
||||
}
|
||||
|
||||
|
@ -637,7 +637,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
|
|||
CommandProc *proc = _command_proc_table[cmd_id].proc;
|
||||
/* Shouldn't happen, but you never know when someone adds
|
||||
* NULLs to the _command_proc_table. */
|
||||
assert(proc != NULL);
|
||||
assert(proc != nullptr);
|
||||
|
||||
/* Command flags are used internally */
|
||||
CommandFlags cmd_flags = GetCommandFlags(cmd);
|
||||
|
@ -750,7 +750,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
|
|||
/* update last build coordinate of company. */
|
||||
if (tile != 0) {
|
||||
Company *c = Company::GetIfValid(_current_company);
|
||||
if (c != NULL) c->last_build_coordinate = tile;
|
||||
if (c != nullptr) c->last_build_coordinate = tile;
|
||||
}
|
||||
|
||||
SubtractMoneyFromCompany(res2);
|
||||
|
|
|
@ -34,10 +34,10 @@ static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID);
|
|||
*/
|
||||
#define return_cmd_error(errcode) return CommandCost(errcode);
|
||||
|
||||
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const char *text = NULL);
|
||||
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const char *text = nullptr);
|
||||
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags);
|
||||
|
||||
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback = NULL, const char *text = NULL, bool my_cmd = true);
|
||||
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback = nullptr, const char *text = nullptr, bool my_cmd = true);
|
||||
bool DoCommandP(const CommandContainer *container, bool my_cmd = true);
|
||||
|
||||
CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd, bool estimate_only);
|
||||
|
|
|
@ -36,25 +36,25 @@ public:
|
|||
/**
|
||||
* Creates a command cost return with no cost and no error
|
||||
*/
|
||||
CommandCost() : expense_type(INVALID_EXPENSES), cost(0), message(INVALID_STRING_ID), success(true), textref_stack_grffile(NULL), textref_stack_size(0) {}
|
||||
CommandCost() : expense_type(INVALID_EXPENSES), cost(0), message(INVALID_STRING_ID), success(true), textref_stack_grffile(nullptr), textref_stack_size(0) {}
|
||||
|
||||
/**
|
||||
* Creates a command return value the is failed with the given message
|
||||
*/
|
||||
explicit CommandCost(StringID msg) : expense_type(INVALID_EXPENSES), cost(0), message(msg), success(false), textref_stack_grffile(NULL), textref_stack_size(0) {}
|
||||
explicit CommandCost(StringID msg) : expense_type(INVALID_EXPENSES), cost(0), message(msg), success(false), textref_stack_grffile(nullptr), textref_stack_size(0) {}
|
||||
|
||||
/**
|
||||
* Creates a command cost with given expense type and start cost of 0
|
||||
* @param ex_t the expense type
|
||||
*/
|
||||
explicit CommandCost(ExpensesType ex_t) : expense_type(ex_t), cost(0), message(INVALID_STRING_ID), success(true), textref_stack_grffile(NULL), textref_stack_size(0) {}
|
||||
explicit CommandCost(ExpensesType ex_t) : expense_type(ex_t), cost(0), message(INVALID_STRING_ID), success(true), textref_stack_grffile(nullptr), textref_stack_size(0) {}
|
||||
|
||||
/**
|
||||
* Creates a command return value with the given start cost and expense type
|
||||
* @param ex_t the expense type
|
||||
* @param cst the initial cost of this command
|
||||
*/
|
||||
CommandCost(ExpensesType ex_t, const Money &cst) : expense_type(ex_t), cost(cst), message(INVALID_STRING_ID), success(true), textref_stack_grffile(NULL), textref_stack_size(0) {}
|
||||
CommandCost(ExpensesType ex_t, const Money &cst) : expense_type(ex_t), cost(cst), message(INVALID_STRING_ID), success(true), textref_stack_grffile(nullptr), textref_stack_size(0) {}
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -98,7 +98,7 @@ struct CompanyProperties {
|
|||
|
||||
// TODO: Change some of these member variables to use relevant INVALID_xxx constants
|
||||
CompanyProperties()
|
||||
: name_2(0), name_1(0), name(NULL), president_name_1(0), president_name_2(0), president_name(NULL),
|
||||
: name_2(0), name_1(0), name(nullptr), president_name_1(0), president_name_2(0), president_name(nullptr),
|
||||
face(0), money(0), money_fraction(0), current_loan(0), colour(0), block_preview(0),
|
||||
location_of_HQ(0), last_build_coordinate(0), share_owners(), inaugurated_year(0),
|
||||
months_of_bankruptcy(0), bankrupt_asked(0), bankrupt_timeout(0), bankrupt_value(0),
|
||||
|
@ -137,7 +137,7 @@ struct Company : CompanyPool::PoolItem<&_company_pool>, CompanyProperties {
|
|||
static inline bool IsValidAiID(size_t index)
|
||||
{
|
||||
const Company *c = Company::GetIfValid(index);
|
||||
return c != NULL && c->is_ai;
|
||||
return c != nullptr && c->is_ai;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,7 +149,7 @@ struct Company : CompanyPool::PoolItem<&_company_pool>, CompanyProperties {
|
|||
static inline bool IsValidHumanID(size_t index)
|
||||
{
|
||||
const Company *c = Company::GetIfValid(index);
|
||||
return c != NULL && !c->is_ai;
|
||||
return c != nullptr && !c->is_ai;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -193,7 +193,7 @@ bool CheckCompanyHasMoney(CommandCost &cost)
|
|||
{
|
||||
if (cost.GetCost() > 0) {
|
||||
const Company *c = Company::GetIfValid(_current_company);
|
||||
if (c != NULL && cost.GetCost() > c->money) {
|
||||
if (c != nullptr && cost.GetCost() > c->money) {
|
||||
SetDParam(0, cost.GetCost());
|
||||
cost.MakeError(STR_ERROR_NOT_ENOUGH_CASH_REQUIRES_CURRENCY);
|
||||
return false;
|
||||
|
@ -239,7 +239,7 @@ static void SubtractMoneyFromAnyCompany(Company *c, CommandCost cost)
|
|||
void SubtractMoneyFromCompany(CommandCost cost)
|
||||
{
|
||||
Company *c = Company::GetIfValid(_current_company);
|
||||
if (c != NULL) SubtractMoneyFromAnyCompany(c, cost);
|
||||
if (c != nullptr) SubtractMoneyFromAnyCompany(c, cost);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -353,7 +353,7 @@ static void GenerateCompanyName(Company *c)
|
|||
|
||||
StringID str;
|
||||
uint32 strp;
|
||||
if (t->name == NULL && IsInsideMM(t->townnametype, SPECSTR_TOWNNAME_START, SPECSTR_TOWNNAME_LAST + 1)) {
|
||||
if (t->name == nullptr && IsInsideMM(t->townnametype, SPECSTR_TOWNNAME_START, SPECSTR_TOWNNAME_LAST + 1)) {
|
||||
str = t->townnametype - SPECSTR_TOWNNAME_START + SPECSTR_COMPANY_NAME_START;
|
||||
strp = t->townnameparts;
|
||||
|
||||
|
@ -539,7 +539,7 @@ void ResetCompanyLivery(Company *c)
|
|||
*/
|
||||
Company *DoStartupNewCompany(bool is_ai, CompanyID company = INVALID_COMPANY)
|
||||
{
|
||||
if (!Company::CanAllocateItem()) return NULL;
|
||||
if (!Company::CanAllocateItem()) return nullptr;
|
||||
|
||||
/* we have to generate colour before this company is valid */
|
||||
Colours colour = GenerateCompanyColour();
|
||||
|
@ -548,7 +548,7 @@ Company *DoStartupNewCompany(bool is_ai, CompanyID company = INVALID_COMPANY)
|
|||
if (company == INVALID_COMPANY) {
|
||||
c = new Company(STR_SV_UNNAMED, is_ai);
|
||||
} else {
|
||||
if (Company::IsValidID(company)) return NULL;
|
||||
if (Company::IsValidID(company)) return nullptr;
|
||||
c = new (company) Company(STR_SV_UNNAMED, is_ai);
|
||||
}
|
||||
|
||||
|
@ -670,7 +670,7 @@ static void HandleBankruptcyTakeover(Company *c)
|
|||
/* Did we ask everyone for bankruptcy? If so, bail out. */
|
||||
if (c->bankrupt_asked == MAX_UVALUE(CompanyMask)) return;
|
||||
|
||||
Company *c2, *best = NULL;
|
||||
Company *c2, *best = nullptr;
|
||||
int32 best_performance = -1;
|
||||
|
||||
/* Ask the company with the highest performance history first */
|
||||
|
@ -706,7 +706,7 @@ void OnTick_Companies()
|
|||
if (_game_mode == GM_EDITOR) return;
|
||||
|
||||
Company *c = Company::GetIfValid(_cur_company_tick_index);
|
||||
if (c != NULL) {
|
||||
if (c != nullptr) {
|
||||
if (c->name_1 != 0) GenerateCompanyName(c);
|
||||
if (c->bankrupt_asked != 0) HandleBankruptcyTakeover(c);
|
||||
}
|
||||
|
@ -759,14 +759,14 @@ void CompaniesYearlyLoop()
|
|||
/**
|
||||
* Fill the CompanyNewsInformation struct with the required data.
|
||||
* @param c the current company.
|
||||
* @param other the other company (use \c NULL if not relevant).
|
||||
* @param other the other company (use \c nullptr if not relevant).
|
||||
*/
|
||||
void CompanyNewsInformation::FillData(const Company *c, const Company *other)
|
||||
{
|
||||
SetDParam(0, c->index);
|
||||
GetString(this->company_name, STR_COMPANY_NAME, lastof(this->company_name));
|
||||
|
||||
if (other == NULL) {
|
||||
if (other == nullptr) {
|
||||
*this->other_company_name = '\0';
|
||||
} else {
|
||||
SetDParam(0, other->index);
|
||||
|
@ -832,8 +832,8 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||
/* When replaying the client ID is not a valid client; there
|
||||
* are actually no clients at all. However, the company has to
|
||||
* be created, otherwise we cannot rerun the game properly.
|
||||
* So only allow a NULL client info in that case. */
|
||||
if (ci == NULL) return CommandCost();
|
||||
* So only allow a nullptr client info in that case. */
|
||||
if (ci == nullptr) return CommandCost();
|
||||
#endif /* NOT DEBUG_DUMP_COMMANDS */
|
||||
|
||||
/* Delete multiplayer progress bar */
|
||||
|
@ -842,7 +842,7 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||
Company *c = DoStartupNewCompany(false);
|
||||
|
||||
/* A new company could not be created, revert to being a spectator */
|
||||
if (c == NULL) {
|
||||
if (c == nullptr) {
|
||||
if (_network_server) {
|
||||
ci->client_playas = COMPANY_SPECTATOR;
|
||||
NetworkUpdateClientInfo(ci->client_id);
|
||||
|
@ -874,7 +874,7 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||
|
||||
if (company_id != INVALID_COMPANY && (company_id >= MAX_COMPANIES || Company::IsValidID(company_id))) return CMD_ERROR;
|
||||
Company *c = DoStartupNewCompany(true, company_id);
|
||||
if (c != NULL) NetworkServerNewCompany(c, NULL);
|
||||
if (c != nullptr) NetworkServerNewCompany(c, nullptr);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -883,7 +883,7 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||
if (reason >= CRR_END) return CMD_ERROR;
|
||||
|
||||
Company *c = Company::GetIfValid(company_id);
|
||||
if (c == NULL) return CMD_ERROR;
|
||||
if (c == nullptr) return CMD_ERROR;
|
||||
|
||||
if (!(flags & DC_EXEC)) return CommandCost();
|
||||
|
||||
|
@ -1055,7 +1055,7 @@ static bool IsUniqueCompanyName(const char *name)
|
|||
const Company *c;
|
||||
|
||||
FOR_ALL_COMPANIES(c) {
|
||||
if (c->name != NULL && strcmp(c->name, name) == 0) return false;
|
||||
if (c->name != nullptr && strcmp(c->name, name) == 0) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1082,7 +1082,7 @@ CommandCost CmdRenameCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
|
|||
if (flags & DC_EXEC) {
|
||||
Company *c = Company::Get(_current_company);
|
||||
free(c->name);
|
||||
c->name = reset ? NULL : stredup(text);
|
||||
c->name = reset ? nullptr : stredup(text);
|
||||
MarkWholeScreenDirty();
|
||||
CompanyAdminUpdate(c);
|
||||
}
|
||||
|
@ -1100,7 +1100,7 @@ static bool IsUniquePresidentName(const char *name)
|
|||
const Company *c;
|
||||
|
||||
FOR_ALL_COMPANIES(c) {
|
||||
if (c->president_name != NULL && strcmp(c->president_name, name) == 0) return false;
|
||||
if (c->president_name != nullptr && strcmp(c->president_name, name) == 0) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1129,11 +1129,11 @@ CommandCost CmdRenamePresident(TileIndex tile, DoCommandFlag flags, uint32 p1, u
|
|||
free(c->president_name);
|
||||
|
||||
if (reset) {
|
||||
c->president_name = NULL;
|
||||
c->president_name = nullptr;
|
||||
} else {
|
||||
c->president_name = stredup(text);
|
||||
|
||||
if (c->name_1 == STR_SV_UNNAMED && c->name == NULL) {
|
||||
if (c->name_1 == STR_SV_UNNAMED && c->name == nullptr) {
|
||||
char buf[80];
|
||||
|
||||
seprintf(buf, lastof(buf), "%s Transport", text);
|
||||
|
@ -1150,13 +1150,13 @@ CommandCost CmdRenamePresident(TileIndex tile, DoCommandFlag flags, uint32 p1, u
|
|||
|
||||
/**
|
||||
* Get the service interval for the given company and vehicle type.
|
||||
* @param c The company, or NULL for client-default settings.
|
||||
* @param c The company, or nullptr for client-default settings.
|
||||
* @param type The vehicle type to get the interval for.
|
||||
* @return The service interval.
|
||||
*/
|
||||
int CompanyServiceInterval(const Company *c, VehicleType type)
|
||||
{
|
||||
const VehicleDefaultSettings *vds = (c == NULL) ? &_settings_client.company.vehicle : &c->settings.vehicle;
|
||||
const VehicleDefaultSettings *vds = (c == nullptr) ? &_settings_client.company.vehicle : &c->settings.vehicle;
|
||||
switch (type) {
|
||||
default: NOT_REACHED();
|
||||
case VEH_TRAIN: return vds->servint_trains;
|
||||
|
|
|
@ -569,7 +569,7 @@ private:
|
|||
{
|
||||
uint32 used_colours = 0;
|
||||
const Company *c;
|
||||
const Livery *livery, *default_livery = NULL;
|
||||
const Livery *livery, *default_livery = nullptr;
|
||||
bool primary = widget == WID_SCL_PRI_COL_DROPDOWN;
|
||||
byte default_col;
|
||||
|
||||
|
@ -603,7 +603,7 @@ private:
|
|||
}
|
||||
|
||||
DropDownList list;
|
||||
if (default_livery != NULL) {
|
||||
if (default_livery != nullptr) {
|
||||
/* Add COLOUR_END to put the colour out of range, but also allow us to show what the default is */
|
||||
default_col = (primary ? default_livery->colour1 : default_livery->colour2) + COLOUR_END;
|
||||
list.emplace_back(new DropDownListColourItem(default_col, false));
|
||||
|
@ -612,13 +612,13 @@ private:
|
|||
list.emplace_back(new DropDownListColourItem(i, HasBit(used_colours, i)));
|
||||
}
|
||||
|
||||
byte sel = (default_livery == NULL || HasBit(livery->in_use, primary ? 0 : 1)) ? (primary ? livery->colour1 : livery->colour2) : default_col;
|
||||
byte sel = (default_livery == nullptr || HasBit(livery->in_use, primary ? 0 : 1)) ? (primary ? livery->colour1 : livery->colour2) : default_col;
|
||||
ShowDropDownList(this, std::move(list), sel, widget);
|
||||
}
|
||||
|
||||
static int CDECL GroupNameSorter(const Group * const *a, const Group * const *b)
|
||||
{
|
||||
static const Group *last_group[2] = { NULL, NULL };
|
||||
static const Group *last_group[2] = { nullptr, nullptr };
|
||||
static char last_name[2][64] = { "", "" };
|
||||
|
||||
if (*a != last_group[0]) {
|
||||
|
@ -1100,7 +1100,7 @@ static WindowDesc _select_company_livery_desc(
|
|||
void ShowCompanyLiveryWindow(CompanyID company, GroupID group)
|
||||
{
|
||||
SelectCompanyLiveryWindow *w = (SelectCompanyLiveryWindow *)BringWindowToFrontById(WC_COMPANY_COLOUR, company);
|
||||
if (w == NULL) {
|
||||
if (w == nullptr) {
|
||||
new SelectCompanyLiveryWindow(&_select_company_livery_desc, company, group);
|
||||
} else if (group != INVALID_GROUP) {
|
||||
w->SetSelectedGroup(company, group);
|
||||
|
@ -1711,10 +1711,10 @@ public:
|
|||
|
||||
void OnQueryTextFinished(char *str) override
|
||||
{
|
||||
if (str == NULL) return;
|
||||
if (str == nullptr) return;
|
||||
/* Set a new company manager face number */
|
||||
if (!StrEmpty(str)) {
|
||||
this->face = strtoul(str, NULL, 10);
|
||||
this->face = strtoul(str, nullptr, 10);
|
||||
ScaleAllCompanyManagerFaceBits(this->face);
|
||||
ShowErrorMessage(STR_FACE_FACECODE_SET, INVALID_STRING_ID, WL_INFO);
|
||||
this->UpdateData();
|
||||
|
@ -2633,17 +2633,17 @@ struct CompanyWindow : Window
|
|||
|
||||
void OnQueryTextFinished(char *str) override
|
||||
{
|
||||
if (str == NULL) return;
|
||||
if (str == nullptr) return;
|
||||
|
||||
switch (this->query_widget) {
|
||||
default: NOT_REACHED();
|
||||
|
||||
case WID_C_PRESIDENT_NAME:
|
||||
DoCommandP(0, 0, 0, CMD_RENAME_PRESIDENT | CMD_MSG(STR_ERROR_CAN_T_CHANGE_PRESIDENT), NULL, str);
|
||||
DoCommandP(0, 0, 0, CMD_RENAME_PRESIDENT | CMD_MSG(STR_ERROR_CAN_T_CHANGE_PRESIDENT), nullptr, str);
|
||||
break;
|
||||
|
||||
case WID_C_COMPANY_NAME:
|
||||
DoCommandP(0, 0, 0, CMD_RENAME_COMPANY | CMD_MSG(STR_ERROR_CAN_T_CHANGE_COMPANY_NAME), NULL, str);
|
||||
DoCommandP(0, 0, 0, CMD_RENAME_COMPANY | CMD_MSG(STR_ERROR_CAN_T_CHANGE_COMPANY_NAME), nullptr, str);
|
||||
break;
|
||||
|
||||
case WID_C_COMPANY_JOIN:
|
||||
|
@ -2796,7 +2796,7 @@ static const NWidgetPart _nested_buy_company_widgets[] = {
|
|||
};
|
||||
|
||||
static WindowDesc _buy_company_desc(
|
||||
WDP_AUTO, NULL, 0, 0,
|
||||
WDP_AUTO, nullptr, 0, 0,
|
||||
WC_BUY_COMPANY, WC_NONE,
|
||||
WDF_CONSTRUCTION,
|
||||
_nested_buy_company_widgets, lengthof(_nested_buy_company_widgets)
|
||||
|
|
|
@ -32,7 +32,7 @@ FILE *_iconsole_output_file;
|
|||
|
||||
void IConsoleInit()
|
||||
{
|
||||
_iconsole_output_file = NULL;
|
||||
_iconsole_output_file = nullptr;
|
||||
_redirect_console_to_client = INVALID_CLIENT_ID;
|
||||
_redirect_console_to_admin = INVALID_ADMIN_ID;
|
||||
|
||||
|
@ -43,14 +43,14 @@ void IConsoleInit()
|
|||
|
||||
static void IConsoleWriteToLogFile(const char *string)
|
||||
{
|
||||
if (_iconsole_output_file != NULL) {
|
||||
if (_iconsole_output_file != nullptr) {
|
||||
/* if there is an console output file ... also print it there */
|
||||
const char *header = GetLogPrefix();
|
||||
if ((strlen(header) != 0 && fwrite(header, strlen(header), 1, _iconsole_output_file) != 1) ||
|
||||
fwrite(string, strlen(string), 1, _iconsole_output_file) != 1 ||
|
||||
fwrite("\n", 1, 1, _iconsole_output_file) != 1) {
|
||||
fclose(_iconsole_output_file);
|
||||
_iconsole_output_file = NULL;
|
||||
_iconsole_output_file = nullptr;
|
||||
IConsolePrintF(CC_DEFAULT, "cannot write to log file");
|
||||
}
|
||||
}
|
||||
|
@ -58,10 +58,10 @@ static void IConsoleWriteToLogFile(const char *string)
|
|||
|
||||
bool CloseConsoleLogIfActive()
|
||||
{
|
||||
if (_iconsole_output_file != NULL) {
|
||||
if (_iconsole_output_file != nullptr) {
|
||||
IConsolePrintF(CC_DEFAULT, "file output complete");
|
||||
fclose(_iconsole_output_file);
|
||||
_iconsole_output_file = NULL;
|
||||
_iconsole_output_file = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -203,22 +203,22 @@ bool GetArgumentInteger(uint32 *value, const char *arg)
|
|||
template<class T>
|
||||
void IConsoleAddSorted(T **base, T *item_new)
|
||||
{
|
||||
if (*base == NULL) {
|
||||
if (*base == nullptr) {
|
||||
*base = item_new;
|
||||
return;
|
||||
}
|
||||
|
||||
T *item_before = NULL;
|
||||
T *item_before = nullptr;
|
||||
T *item = *base;
|
||||
/* The list is alphabetically sorted, insert the new item at the correct location */
|
||||
while (item != NULL) {
|
||||
while (item != nullptr) {
|
||||
if (strcmp(item->name, item_new->name) > 0) break; // insert here
|
||||
|
||||
item_before = item;
|
||||
item = item->next;
|
||||
}
|
||||
|
||||
if (item_before == NULL) {
|
||||
if (item_before == nullptr) {
|
||||
*base = item_new;
|
||||
} else {
|
||||
item_before->next = item_new;
|
||||
|
@ -251,7 +251,7 @@ void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc, IConsoleHook *
|
|||
{
|
||||
IConsoleCmd *item_new = MallocT<IConsoleCmd>(1);
|
||||
item_new->name = RemoveUnderscores(stredup(name));
|
||||
item_new->next = NULL;
|
||||
item_new->next = nullptr;
|
||||
item_new->proc = proc;
|
||||
item_new->hook = hook;
|
||||
|
||||
|
@ -261,16 +261,16 @@ void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc, IConsoleHook *
|
|||
/**
|
||||
* Find the command pointed to by its string
|
||||
* @param name command to be found
|
||||
* @return return Cmdstruct of the found command, or NULL on failure
|
||||
* @return return Cmdstruct of the found command, or nullptr on failure
|
||||
*/
|
||||
IConsoleCmd *IConsoleCmdGet(const char *name)
|
||||
{
|
||||
IConsoleCmd *item;
|
||||
|
||||
for (item = _iconsole_cmds; item != NULL; item = item->next) {
|
||||
for (item = _iconsole_cmds; item != nullptr; item = item->next) {
|
||||
if (strcmp(item->name, name) == 0) return item;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -280,7 +280,7 @@ IConsoleCmd *IConsoleCmdGet(const char *name)
|
|||
*/
|
||||
void IConsoleAliasRegister(const char *name, const char *cmd)
|
||||
{
|
||||
if (IConsoleAliasGet(name) != NULL) {
|
||||
if (IConsoleAliasGet(name) != nullptr) {
|
||||
IConsoleError("an alias with this name already exists; insertion aborted");
|
||||
return;
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ void IConsoleAliasRegister(const char *name, const char *cmd)
|
|||
char *cmd_aliased = stredup(cmd);
|
||||
IConsoleAlias *item_new = MallocT<IConsoleAlias>(1);
|
||||
|
||||
item_new->next = NULL;
|
||||
item_new->next = nullptr;
|
||||
item_new->cmdline = cmd_aliased;
|
||||
item_new->name = new_alias;
|
||||
|
||||
|
@ -299,17 +299,17 @@ void IConsoleAliasRegister(const char *name, const char *cmd)
|
|||
/**
|
||||
* Find the alias pointed to by its string
|
||||
* @param name alias to be found
|
||||
* @return return Aliasstruct of the found alias, or NULL on failure
|
||||
* @return return Aliasstruct of the found alias, or nullptr on failure
|
||||
*/
|
||||
IConsoleAlias *IConsoleAliasGet(const char *name)
|
||||
{
|
||||
IConsoleAlias *item;
|
||||
|
||||
for (item = _iconsole_aliases; item != NULL; item = item->next) {
|
||||
for (item = _iconsole_aliases; item != nullptr; item = item->next) {
|
||||
if (strcmp(item->name, name) == 0) return item;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
/**
|
||||
* An alias is just another name for a command, or for more commands
|
||||
|
@ -478,7 +478,7 @@ void IConsoleCmdExec(const char *cmdstr)
|
|||
}
|
||||
}
|
||||
|
||||
for (uint i = 0; i < lengthof(tokens) && tokens[i] != NULL; i++) {
|
||||
for (uint i = 0; i < lengthof(tokens) && tokens[i] != nullptr; i++) {
|
||||
DEBUG(console, 8, "Token %d is: '%s'", i, tokens[i]);
|
||||
}
|
||||
|
||||
|
@ -489,12 +489,12 @@ void IConsoleCmdExec(const char *cmdstr)
|
|||
*/
|
||||
RemoveUnderscores(tokens[0]);
|
||||
IConsoleCmd *cmd = IConsoleCmdGet(tokens[0]);
|
||||
if (cmd != NULL) {
|
||||
ConsoleHookResult chr = (cmd->hook == NULL ? CHR_ALLOW : cmd->hook(true));
|
||||
if (cmd != nullptr) {
|
||||
ConsoleHookResult chr = (cmd->hook == nullptr ? CHR_ALLOW : cmd->hook(true));
|
||||
switch (chr) {
|
||||
case CHR_ALLOW:
|
||||
if (!cmd->proc(t_index, tokens)) { // index started with 0
|
||||
cmd->proc(0, NULL); // if command failed, give help
|
||||
cmd->proc(0, nullptr); // if command failed, give help
|
||||
}
|
||||
return;
|
||||
|
||||
|
@ -505,7 +505,7 @@ void IConsoleCmdExec(const char *cmdstr)
|
|||
|
||||
t_index--;
|
||||
IConsoleAlias *alias = IConsoleAliasGet(tokens[0]);
|
||||
if (alias != NULL) {
|
||||
if (alias != nullptr) {
|
||||
IConsoleAliasExec(alias, t_index, &tokens[1]);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -349,7 +349,7 @@ DEF_CONSOLE_CMD(ConLoad)
|
|||
const char *file = argv[1];
|
||||
_console_file_list.ValidateFileList();
|
||||
const FiosItem *item = _console_file_list.FindItem(file);
|
||||
if (item != NULL) {
|
||||
if (item != nullptr) {
|
||||
if (GetAbstractFileType(item->type) == FT_SAVEGAME) {
|
||||
_switch_mode = SM_LOAD_GAME;
|
||||
_file_to_saveload.SetMode(item->type);
|
||||
|
@ -378,7 +378,7 @@ DEF_CONSOLE_CMD(ConRemove)
|
|||
const char *file = argv[1];
|
||||
_console_file_list.ValidateFileList();
|
||||
const FiosItem *item = _console_file_list.FindItem(file);
|
||||
if (item != NULL) {
|
||||
if (item != nullptr) {
|
||||
if (!FiosDelete(item->name)) {
|
||||
IConsolePrintF(CC_ERROR, "%s: Failed to delete file", file);
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ DEF_CONSOLE_CMD(ConChangeDirectory)
|
|||
const char *file = argv[1];
|
||||
_console_file_list.ValidateFileList(true);
|
||||
const FiosItem *item = _console_file_list.FindItem(file);
|
||||
if (item != NULL) {
|
||||
if (item != nullptr) {
|
||||
switch (item->type) {
|
||||
case FIOS_TYPE_DIR: case FIOS_TYPE_DRIVE: case FIOS_TYPE_PARENT:
|
||||
FiosBrowseTo(item);
|
||||
|
@ -448,7 +448,7 @@ DEF_CONSOLE_CMD(ConPrintWorkingDirectory)
|
|||
_console_file_list.ValidateFileList(true);
|
||||
_console_file_list.InvalidateFileList();
|
||||
|
||||
FiosGetDescText(&path, NULL);
|
||||
FiosGetDescText(&path, nullptr);
|
||||
IConsolePrint(CC_DEFAULT, path);
|
||||
return true;
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ static bool ConKickOrBan(const char *argv, bool ban)
|
|||
{
|
||||
uint n;
|
||||
|
||||
if (strchr(argv, '.') == NULL && strchr(argv, ':') == NULL) { // banning with ID
|
||||
if (strchr(argv, '.') == nullptr && strchr(argv, ':') == nullptr) { // banning with ID
|
||||
ClientID client_id = (ClientID)atoi(argv);
|
||||
|
||||
/* Don't kill the server, or the client doing the rcon. The latter can't be kicked because
|
||||
|
@ -487,7 +487,7 @@ static bool ConKickOrBan(const char *argv, bool ban)
|
|||
}
|
||||
|
||||
NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(client_id);
|
||||
if (ci == NULL) {
|
||||
if (ci == nullptr) {
|
||||
IConsoleError("Invalid client");
|
||||
return true;
|
||||
}
|
||||
|
@ -688,7 +688,7 @@ DEF_CONSOLE_CMD(ConClientNickChange)
|
|||
return true;
|
||||
}
|
||||
|
||||
if (NetworkClientInfo::GetByClientID(client_id) == NULL) {
|
||||
if (NetworkClientInfo::GetByClientID(client_id) == nullptr) {
|
||||
IConsoleError("Invalid client");
|
||||
return true;
|
||||
}
|
||||
|
@ -759,7 +759,7 @@ DEF_CONSOLE_CMD(ConMoveClient)
|
|||
CompanyID company_id = (CompanyID)(atoi(argv[2]) <= MAX_COMPANIES ? atoi(argv[2]) - 1 : atoi(argv[2]));
|
||||
|
||||
/* check the client exists */
|
||||
if (ci == NULL) {
|
||||
if (ci == nullptr) {
|
||||
IConsoleError("Invalid client-id, check the command 'clients' for valid client-id's.");
|
||||
return true;
|
||||
}
|
||||
|
@ -887,8 +887,8 @@ DEF_CONSOLE_CMD(ConNetworkConnect)
|
|||
if (argc < 2) return false;
|
||||
if (_networking) NetworkDisconnect(); // we are in network-mode, first close it!
|
||||
|
||||
const char *port = NULL;
|
||||
const char *company = NULL;
|
||||
const char *port = nullptr;
|
||||
const char *company = nullptr;
|
||||
char *ip = argv[1];
|
||||
/* Default settings: default port and new company */
|
||||
uint16 rport = NETWORK_DEFAULT_PORT;
|
||||
|
@ -897,7 +897,7 @@ DEF_CONSOLE_CMD(ConNetworkConnect)
|
|||
ParseConnectionString(&company, &port, ip);
|
||||
|
||||
IConsolePrintF(CC_DEFAULT, "Connecting to %s...", ip);
|
||||
if (company != NULL) {
|
||||
if (company != nullptr) {
|
||||
join_as = (CompanyID)atoi(company);
|
||||
IConsolePrintF(CC_DEFAULT, " company-no: %d", join_as);
|
||||
|
||||
|
@ -908,7 +908,7 @@ DEF_CONSOLE_CMD(ConNetworkConnect)
|
|||
join_as--;
|
||||
}
|
||||
}
|
||||
if (port != NULL) {
|
||||
if (port != nullptr) {
|
||||
rport = atoi(port);
|
||||
IConsolePrintF(CC_DEFAULT, " port: %s", port);
|
||||
}
|
||||
|
@ -933,7 +933,7 @@ DEF_CONSOLE_CMD(ConExec)
|
|||
|
||||
FILE *script_file = FioFOpenFile(argv[1], "r", BASE_DIR);
|
||||
|
||||
if (script_file == NULL) {
|
||||
if (script_file == nullptr) {
|
||||
if (argc == 2 || atoi(argv[2]) != 0) IConsoleError("script file not found");
|
||||
return true;
|
||||
}
|
||||
|
@ -941,7 +941,7 @@ DEF_CONSOLE_CMD(ConExec)
|
|||
_script_running = true;
|
||||
|
||||
char cmdline[ICON_CMDLN_SIZE];
|
||||
while (_script_running && fgets(cmdline, sizeof(cmdline), script_file) != NULL) {
|
||||
while (_script_running && fgets(cmdline, sizeof(cmdline), script_file) != nullptr) {
|
||||
/* Remove newline characters from the executing script */
|
||||
for (char *cmdptr = cmdline; *cmdptr != '\0'; cmdptr++) {
|
||||
if (*cmdptr == '\n' || *cmdptr == '\r') {
|
||||
|
@ -992,7 +992,7 @@ DEF_CONSOLE_CMD(ConScript)
|
|||
|
||||
IConsolePrintF(CC_DEFAULT, "file output started to: %s", argv[1]);
|
||||
_iconsole_output_file = fopen(argv[1], "ab");
|
||||
if (_iconsole_output_file == NULL) IConsoleError("could not open file");
|
||||
if (_iconsole_output_file == nullptr) IConsoleError("could not open file");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1031,7 +1031,7 @@ DEF_CONSOLE_CMD(ConNewGame)
|
|||
return true;
|
||||
}
|
||||
|
||||
StartNewGameWithoutGUI((argc == 2) ? strtoul(argv[1], NULL, 10) : GENERATE_NEW_SEED);
|
||||
StartNewGameWithoutGUI((argc == 2) ? strtoul(argv[1], nullptr, 10) : GENERATE_NEW_SEED);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1283,7 +1283,7 @@ DEF_CONSOLE_CMD(ConRescanNewGRF)
|
|||
return true;
|
||||
}
|
||||
|
||||
ScanNewGRFFiles(NULL);
|
||||
ScanNewGRFFiles(nullptr);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1326,7 +1326,7 @@ DEF_CONSOLE_CMD(ConAlias)
|
|||
if (argc < 3) return false;
|
||||
|
||||
alias = IConsoleAliasGet(argv[1]);
|
||||
if (alias == NULL) {
|
||||
if (alias == nullptr) {
|
||||
IConsoleAliasRegister(argv[1], argv[2]);
|
||||
} else {
|
||||
free(alias->cmdline);
|
||||
|
@ -1348,7 +1348,7 @@ DEF_CONSOLE_CMD(ConScreenShot)
|
|||
if (argc > 3) return false;
|
||||
|
||||
ScreenshotType type = SC_VIEWPORT;
|
||||
const char *name = NULL;
|
||||
const char *name = nullptr;
|
||||
|
||||
if (argc > 1) {
|
||||
if (strcmp(argv[1], "big") == 0) {
|
||||
|
@ -1386,7 +1386,7 @@ DEF_CONSOLE_CMD(ConInfoCmd)
|
|||
if (argc < 2) return false;
|
||||
|
||||
const IConsoleCmd *cmd = IConsoleCmdGet(argv[1]);
|
||||
if (cmd == NULL) {
|
||||
if (cmd == nullptr) {
|
||||
IConsoleError("the given command was not found");
|
||||
return true;
|
||||
}
|
||||
|
@ -1394,7 +1394,7 @@ DEF_CONSOLE_CMD(ConInfoCmd)
|
|||
IConsolePrintF(CC_DEFAULT, "command name: %s", cmd->name);
|
||||
IConsolePrintF(CC_DEFAULT, "command proc: %p", cmd->proc);
|
||||
|
||||
if (cmd->hook != NULL) IConsoleWarning("command is hooked");
|
||||
if (cmd->hook != nullptr) IConsoleWarning("command is hooked");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1452,16 +1452,16 @@ DEF_CONSOLE_CMD(ConHelp)
|
|||
|
||||
RemoveUnderscores(argv[1]);
|
||||
cmd = IConsoleCmdGet(argv[1]);
|
||||
if (cmd != NULL) {
|
||||
cmd->proc(0, NULL);
|
||||
if (cmd != nullptr) {
|
||||
cmd->proc(0, nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
alias = IConsoleAliasGet(argv[1]);
|
||||
if (alias != NULL) {
|
||||
if (alias != nullptr) {
|
||||
cmd = IConsoleCmdGet(alias->cmdline);
|
||||
if (cmd != NULL) {
|
||||
cmd->proc(0, NULL);
|
||||
if (cmd != nullptr) {
|
||||
cmd->proc(0, nullptr);
|
||||
return true;
|
||||
}
|
||||
IConsolePrintF(CC_ERROR, "ERROR: alias is of special type, please see its execution-line: '%s'", alias->cmdline);
|
||||
|
@ -1491,9 +1491,9 @@ DEF_CONSOLE_CMD(ConListCommands)
|
|||
return true;
|
||||
}
|
||||
|
||||
for (const IConsoleCmd *cmd = _iconsole_cmds; cmd != NULL; cmd = cmd->next) {
|
||||
if (argv[1] == NULL || strstr(cmd->name, argv[1]) != NULL) {
|
||||
if (cmd->hook == NULL || cmd->hook(false) != CHR_HIDE) IConsolePrintF(CC_DEFAULT, "%s", cmd->name);
|
||||
for (const IConsoleCmd *cmd = _iconsole_cmds; cmd != nullptr; cmd = cmd->next) {
|
||||
if (argv[1] == nullptr || strstr(cmd->name, argv[1]) != nullptr) {
|
||||
if (cmd->hook == nullptr || cmd->hook(false) != CHR_HIDE) IConsolePrintF(CC_DEFAULT, "%s", cmd->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1507,8 +1507,8 @@ DEF_CONSOLE_CMD(ConListAliases)
|
|||
return true;
|
||||
}
|
||||
|
||||
for (const IConsoleAlias *alias = _iconsole_aliases; alias != NULL; alias = alias->next) {
|
||||
if (argv[1] == NULL || strstr(alias->name, argv[1]) != NULL) {
|
||||
for (const IConsoleAlias *alias = _iconsole_aliases; alias != nullptr; alias = alias->next) {
|
||||
if (argv[1] == nullptr || strstr(alias->name, argv[1]) != nullptr) {
|
||||
IConsolePrintF(CC_DEFAULT, "%s => %s", alias->name, alias->cmdline);
|
||||
}
|
||||
}
|
||||
|
@ -1717,8 +1717,8 @@ static void OutputContentState(const ContentInfo *const ci)
|
|||
|
||||
DEF_CONSOLE_CMD(ConContent)
|
||||
{
|
||||
static ContentCallback *cb = NULL;
|
||||
if (cb == NULL) {
|
||||
static ContentCallback *cb = nullptr;
|
||||
if (cb == nullptr) {
|
||||
cb = new ConsoleContentCallback();
|
||||
_network_content_client.AddCallback(cb);
|
||||
}
|
||||
|
@ -1776,7 +1776,7 @@ DEF_CONSOLE_CMD(ConContent)
|
|||
if (strcasecmp(argv[1], "state") == 0) {
|
||||
IConsolePrintF(CC_WHITE, "id, type, state, name");
|
||||
for (ConstContentIterator iter = _network_content_client.Begin(); iter != _network_content_client.End(); iter++) {
|
||||
if (argc > 2 && strcasestr((*iter)->name, argv[2]) == NULL) continue;
|
||||
if (argc > 2 && strcasestr((*iter)->name, argv[2]) == nullptr) continue;
|
||||
OutputContentState(*iter);
|
||||
}
|
||||
return true;
|
||||
|
@ -1841,7 +1841,7 @@ DEF_CONSOLE_CMD(ConListSettings)
|
|||
|
||||
if (argc > 2) return false;
|
||||
|
||||
IConsoleListSettings((argc == 2) ? argv[1] : NULL);
|
||||
IConsoleListSettings((argc == 2) ? argv[1] : nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ struct IConsoleLine {
|
|||
static const IConsoleLine *Get(uint index)
|
||||
{
|
||||
const IConsoleLine *item = IConsoleLine::front;
|
||||
while (index != 0 && item != NULL) {
|
||||
while (index != 0 && item != nullptr) {
|
||||
index--;
|
||||
item = item->previous;
|
||||
}
|
||||
|
@ -96,14 +96,14 @@ struct IConsoleLine {
|
|||
static bool Truncate()
|
||||
{
|
||||
IConsoleLine *cur = IConsoleLine::front;
|
||||
if (cur == NULL) return false;
|
||||
if (cur == nullptr) return false;
|
||||
|
||||
int count = 1;
|
||||
for (IConsoleLine *item = cur->previous; item != NULL; count++, cur = item, item = item->previous) {
|
||||
for (IConsoleLine *item = cur->previous; item != nullptr; count++, cur = item, item = item->previous) {
|
||||
if (item->time > _settings_client.gui.console_backlog_timeout &&
|
||||
count > _settings_client.gui.console_backlog_length) {
|
||||
delete item;
|
||||
cur->previous = NULL;
|
||||
cur->previous = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -119,12 +119,12 @@ struct IConsoleLine {
|
|||
static void Reset()
|
||||
{
|
||||
delete IConsoleLine::front;
|
||||
IConsoleLine::front = NULL;
|
||||
IConsoleLine::front = nullptr;
|
||||
IConsoleLine::size = 0;
|
||||
}
|
||||
};
|
||||
|
||||
/* static */ IConsoleLine *IConsoleLine::front = NULL;
|
||||
/* static */ IConsoleLine *IConsoleLine::front = nullptr;
|
||||
/* static */ int IConsoleLine::size = 0;
|
||||
|
||||
|
||||
|
@ -162,7 +162,7 @@ static const struct NWidgetPart _nested_console_window_widgets[] = {
|
|||
};
|
||||
|
||||
static WindowDesc _console_window_desc(
|
||||
WDP_MANUAL, NULL, 0, 0,
|
||||
WDP_MANUAL, nullptr, 0, 0,
|
||||
WC_CONSOLE, WC_NONE,
|
||||
0,
|
||||
_nested_console_window_widgets, lengthof(_nested_console_window_widgets)
|
||||
|
@ -207,7 +207,7 @@ struct IConsoleWindow : Window
|
|||
|
||||
GfxFillRect(0, 0, this->width - 1, this->height - 1, PC_BLACK);
|
||||
int ypos = this->height - this->line_height;
|
||||
for (const IConsoleLine *print = IConsoleLine::Get(IConsoleWindow::scroll); print != NULL; print = print->previous) {
|
||||
for (const IConsoleLine *print = IConsoleLine::Get(IConsoleWindow::scroll); print != nullptr; print = print->previous) {
|
||||
SetDParamStr(0, print->buffer);
|
||||
ypos = DrawStringMultiLine(5, right, -this->line_height, ypos, STR_JUST_RAW_STRING, print->colour, SA_LEFT | SA_BOTTOM | SA_FORCE) - ICON_LINE_SPACING;
|
||||
if (ypos < 0) break;
|
||||
|
@ -287,7 +287,7 @@ struct IConsoleWindow : Window
|
|||
const char *cmd = IConsoleHistoryAdd(_iconsole_cmdline.buf);
|
||||
IConsoleClearCommand();
|
||||
|
||||
if (cmd != NULL) IConsoleCmdExec(cmd);
|
||||
if (cmd != nullptr) IConsoleCmdExec(cmd);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -335,7 +335,7 @@ struct IConsoleWindow : Window
|
|||
|
||||
const char *GetMarkedText(size_t *length) const override
|
||||
{
|
||||
if (_iconsole_cmdline.markend == 0) return NULL;
|
||||
if (_iconsole_cmdline.markend == 0) return nullptr;
|
||||
|
||||
*length = _iconsole_cmdline.markend - _iconsole_cmdline.markpos;
|
||||
return _iconsole_cmdline.buf + _iconsole_cmdline.markpos;
|
||||
|
@ -364,7 +364,7 @@ struct IConsoleWindow : Window
|
|||
{
|
||||
int delta = min(this->width - this->line_offset - _iconsole_cmdline.pixels - ICON_RIGHT_BORDERWIDTH, 0);
|
||||
|
||||
if (!IsInsideMM(pt.y, this->height - this->line_height, this->height)) return NULL;
|
||||
if (!IsInsideMM(pt.y, this->height - this->line_height, this->height)) return nullptr;
|
||||
|
||||
return GetCharAtPosition(_iconsole_cmdline.buf, pt.x - delta);
|
||||
}
|
||||
|
@ -459,10 +459,10 @@ static const char *IConsoleHistoryAdd(const char *cmd)
|
|||
while (IsWhitespace(*cmd)) cmd++;
|
||||
|
||||
/* Do not put empty command in history */
|
||||
if (StrEmpty(cmd)) return NULL;
|
||||
if (StrEmpty(cmd)) return nullptr;
|
||||
|
||||
/* Do not put in history if command is same as previous */
|
||||
if (_iconsole_history[0] == NULL || strcmp(_iconsole_history[0], cmd) != 0) {
|
||||
if (_iconsole_history[0] == nullptr || strcmp(_iconsole_history[0], cmd) != 0) {
|
||||
free(_iconsole_history[ICON_HISTORY_SIZE - 1]);
|
||||
memmove(&_iconsole_history[1], &_iconsole_history[0], sizeof(_iconsole_history[0]) * (ICON_HISTORY_SIZE - 1));
|
||||
_iconsole_history[0] = stredup(cmd);
|
||||
|
@ -479,10 +479,10 @@ static const char *IConsoleHistoryAdd(const char *cmd)
|
|||
*/
|
||||
static void IConsoleHistoryNavigate(int direction)
|
||||
{
|
||||
if (_iconsole_history[0] == NULL) return; // Empty history
|
||||
if (_iconsole_history[0] == nullptr) return; // Empty history
|
||||
_iconsole_historypos = Clamp(_iconsole_historypos + direction, -1, ICON_HISTORY_SIZE - 1);
|
||||
|
||||
if (direction > 0 && _iconsole_history[_iconsole_historypos] == NULL) _iconsole_historypos--;
|
||||
if (direction > 0 && _iconsole_history[_iconsole_historypos] == nullptr) _iconsole_historypos--;
|
||||
|
||||
if (_iconsole_historypos == -1) {
|
||||
_iconsole_cmdline.DeleteAll();
|
||||
|
|
|
@ -69,7 +69,7 @@ extern IConsoleAlias *_iconsole_aliases; ///< List of registered aliases.
|
|||
void IConsoleClearBuffer();
|
||||
|
||||
/* Commands */
|
||||
void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc, IConsoleHook *hook = NULL);
|
||||
void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc, IConsoleHook *hook = nullptr);
|
||||
void IConsoleAliasRegister(const char *name, const char *cmd);
|
||||
IConsoleCmd *IConsoleCmdGet(const char *name);
|
||||
IConsoleAlias *IConsoleAliasGet(const char *name);
|
||||
|
|
|
@ -53,23 +53,23 @@ static inline void CheckAllocationConstraints(size_t num_elements)
|
|||
* @note the memory contains garbage data (i.e. possibly non-zero values).
|
||||
* @tparam T the type of the variable(s) to allocation.
|
||||
* @param num_elements the number of elements to allocate of the given type.
|
||||
* @return NULL when num_elements == 0, non-NULL otherwise.
|
||||
* @return nullptr when num_elements == 0, non-nullptr otherwise.
|
||||
*/
|
||||
template <typename T>
|
||||
static inline T *MallocT(size_t num_elements)
|
||||
{
|
||||
/*
|
||||
* MorphOS cannot handle 0 elements allocations, or rather that always
|
||||
* returns NULL. So we do that for *all* allocations, thus causing it
|
||||
* returns nullptr. So we do that for *all* allocations, thus causing it
|
||||
* to behave the same on all OSes.
|
||||
*/
|
||||
if (num_elements == 0) return NULL;
|
||||
if (num_elements == 0) return nullptr;
|
||||
|
||||
/* Ensure the size does not overflow. */
|
||||
CheckAllocationConstraints<T>(num_elements);
|
||||
|
||||
T *t_ptr = (T*)malloc(num_elements * sizeof(T));
|
||||
if (t_ptr == NULL) MallocError(num_elements * sizeof(T));
|
||||
if (t_ptr == nullptr) MallocError(num_elements * sizeof(T));
|
||||
return t_ptr;
|
||||
}
|
||||
|
||||
|
@ -81,20 +81,20 @@ static inline T *MallocT(size_t num_elements)
|
|||
* @note the memory contains all zero values.
|
||||
* @tparam T the type of the variable(s) to allocation.
|
||||
* @param num_elements the number of elements to allocate of the given type.
|
||||
* @return NULL when num_elements == 0, non-NULL otherwise.
|
||||
* @return nullptr when num_elements == 0, non-nullptr otherwise.
|
||||
*/
|
||||
template <typename T>
|
||||
static inline T *CallocT(size_t num_elements)
|
||||
{
|
||||
/*
|
||||
* MorphOS cannot handle 0 elements allocations, or rather that always
|
||||
* returns NULL. So we do that for *all* allocations, thus causing it
|
||||
* returns nullptr. So we do that for *all* allocations, thus causing it
|
||||
* to behave the same on all OSes.
|
||||
*/
|
||||
if (num_elements == 0) return NULL;
|
||||
if (num_elements == 0) return nullptr;
|
||||
|
||||
T *t_ptr = (T*)calloc(num_elements, sizeof(T));
|
||||
if (t_ptr == NULL) MallocError(num_elements * sizeof(T));
|
||||
if (t_ptr == nullptr) MallocError(num_elements * sizeof(T));
|
||||
return t_ptr;
|
||||
}
|
||||
|
||||
|
@ -107,26 +107,26 @@ static inline T *CallocT(size_t num_elements)
|
|||
* @tparam T the type of the variable(s) to allocation.
|
||||
* @param t_ptr the previous allocation to extend/shrink.
|
||||
* @param num_elements the number of elements to allocate of the given type.
|
||||
* @return NULL when num_elements == 0, non-NULL otherwise.
|
||||
* @return nullptr when num_elements == 0, non-nullptr otherwise.
|
||||
*/
|
||||
template <typename T>
|
||||
static inline T *ReallocT(T *t_ptr, size_t num_elements)
|
||||
{
|
||||
/*
|
||||
* MorphOS cannot handle 0 elements allocations, or rather that always
|
||||
* returns NULL. So we do that for *all* allocations, thus causing it
|
||||
* returns nullptr. So we do that for *all* allocations, thus causing it
|
||||
* to behave the same on all OSes.
|
||||
*/
|
||||
if (num_elements == 0) {
|
||||
free(t_ptr);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Ensure the size does not overflow. */
|
||||
CheckAllocationConstraints<T>(num_elements);
|
||||
|
||||
t_ptr = (T*)realloc(static_cast<void *>(t_ptr), num_elements * sizeof(T));
|
||||
if (t_ptr == NULL) ReallocError(num_elements * sizeof(T));
|
||||
if (t_ptr == nullptr) ReallocError(num_elements * sizeof(T));
|
||||
return t_ptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ private:
|
|||
|
||||
public:
|
||||
/** Create a new buffer */
|
||||
ReusableBuffer() : buffer(NULL), count(0) {}
|
||||
ReusableBuffer() : buffer(nullptr), count(0) {}
|
||||
/** Clear the buffer */
|
||||
~ReusableBuffer() { free(this->buffer); }
|
||||
|
||||
|
|
|
@ -108,11 +108,11 @@ class Kdtree {
|
|||
std::vector<T> elements = this->FreeSubtree(this->root);
|
||||
elements.push_back(root_element);
|
||||
|
||||
if (include_element != NULL) {
|
||||
if (include_element != nullptr) {
|
||||
elements.push_back(*include_element);
|
||||
initial_count++;
|
||||
}
|
||||
if (exclude_element != NULL) {
|
||||
if (exclude_element != nullptr) {
|
||||
typename std::vector<T>::iterator removed = std::remove(elements.begin(), elements.end(), *exclude_element);
|
||||
elements.erase(removed, elements.end());
|
||||
initial_count--;
|
||||
|
@ -377,7 +377,7 @@ public:
|
|||
*/
|
||||
void Rebuild()
|
||||
{
|
||||
this->Rebuild(NULL, NULL);
|
||||
this->Rebuild(nullptr, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -390,7 +390,7 @@ public:
|
|||
if (this->Count() == 0) {
|
||||
this->root = this->AddNode(element);
|
||||
} else {
|
||||
if (!this->IsUnbalanced() || !this->Rebuild(&element, NULL)) {
|
||||
if (!this->IsUnbalanced() || !this->Rebuild(&element, nullptr)) {
|
||||
this->InsertRecursive(element, this->root, 0);
|
||||
this->IncrementUnbalanced();
|
||||
}
|
||||
|
@ -408,7 +408,7 @@ public:
|
|||
{
|
||||
size_t count = this->Count();
|
||||
if (count == 0) return;
|
||||
if (!this->IsUnbalanced() || !this->Rebuild(NULL, &element)) {
|
||||
if (!this->IsUnbalanced() || !this->Rebuild(nullptr, &element)) {
|
||||
/* If the removed element is the root node, this modifies this->root */
|
||||
this->root = this->RemoveRecursive(element, this->root, 0);
|
||||
this->IncrementUnbalanced();
|
||||
|
|
|
@ -78,7 +78,7 @@ static inline int MemCmpT(const T *ptr1, const T *ptr2, size_t num = 1)
|
|||
template <typename T>
|
||||
static inline void MemReverseT(T *ptr1, T *ptr2)
|
||||
{
|
||||
assert(ptr1 != NULL && ptr2 != NULL);
|
||||
assert(ptr1 != nullptr && ptr2 != nullptr);
|
||||
assert(ptr1 < ptr2);
|
||||
|
||||
do {
|
||||
|
@ -95,7 +95,7 @@ static inline void MemReverseT(T *ptr1, T *ptr2)
|
|||
template <typename T>
|
||||
static inline void MemReverseT(T *ptr, size_t num)
|
||||
{
|
||||
assert(ptr != NULL);
|
||||
assert(ptr != nullptr);
|
||||
|
||||
MemReverseT(ptr, ptr + (num - 1));
|
||||
}
|
||||
|
|
|
@ -39,8 +39,8 @@ DEFINE_POOL_METHOD(inline)::Pool(const char *name) :
|
|||
checked(0),
|
||||
#endif /* OTTD_ASSERT */
|
||||
cleaning(false),
|
||||
data(NULL),
|
||||
alloc_cache(NULL)
|
||||
data(nullptr),
|
||||
alloc_cache(nullptr)
|
||||
{ }
|
||||
|
||||
/**
|
||||
|
@ -71,7 +71,7 @@ DEFINE_POOL_METHOD(inline size_t)::FindFirstFree()
|
|||
size_t index = this->first_free;
|
||||
|
||||
for (; index < this->first_unused; index++) {
|
||||
if (this->data[index] == NULL) return index;
|
||||
if (this->data[index] == nullptr) return index;
|
||||
}
|
||||
|
||||
if (index < this->size) {
|
||||
|
@ -96,17 +96,17 @@ DEFINE_POOL_METHOD(inline size_t)::FindFirstFree()
|
|||
* @param size size of item
|
||||
* @param index index of item
|
||||
* @pre index < this->size
|
||||
* @pre this->Get(index) == NULL
|
||||
* @pre this->Get(index) == nullptr
|
||||
*/
|
||||
DEFINE_POOL_METHOD(inline void *)::AllocateItem(size_t size, size_t index)
|
||||
{
|
||||
assert(this->data[index] == NULL);
|
||||
assert(this->data[index] == nullptr);
|
||||
|
||||
this->first_unused = max(this->first_unused, index + 1);
|
||||
this->items++;
|
||||
|
||||
Titem *item;
|
||||
if (Tcache && this->alloc_cache != NULL) {
|
||||
if (Tcache && this->alloc_cache != nullptr) {
|
||||
assert(sizeof(Titem) == size);
|
||||
item = (Titem *)this->alloc_cache;
|
||||
this->alloc_cache = this->alloc_cache->next;
|
||||
|
@ -164,7 +164,7 @@ DEFINE_POOL_METHOD(void *)::GetNew(size_t size, size_t index)
|
|||
|
||||
if (index >= this->size) this->ResizeFor(index);
|
||||
|
||||
if (this->data[index] != NULL) {
|
||||
if (this->data[index] != nullptr) {
|
||||
SlErrorCorruptFmt("%s index " PRINTF_SIZE " already in use", this->name, index);
|
||||
}
|
||||
|
||||
|
@ -174,13 +174,13 @@ DEFINE_POOL_METHOD(void *)::GetNew(size_t size, size_t index)
|
|||
/**
|
||||
* Deallocates memory used by this index and marks item as free
|
||||
* @param index item to deallocate
|
||||
* @pre unit is allocated (non-NULL)
|
||||
* @note 'delete NULL' doesn't cause call of this function, so it is safe
|
||||
* @pre unit is allocated (non-nullptr)
|
||||
* @note 'delete nullptr' doesn't cause call of this function, so it is safe
|
||||
*/
|
||||
DEFINE_POOL_METHOD(void)::FreeItem(size_t index)
|
||||
{
|
||||
assert(index < this->size);
|
||||
assert(this->data[index] != NULL);
|
||||
assert(this->data[index] != nullptr);
|
||||
if (Tcache) {
|
||||
AllocCache *ac = (AllocCache *)this->data[index];
|
||||
ac->next = this->alloc_cache;
|
||||
|
@ -188,7 +188,7 @@ DEFINE_POOL_METHOD(void)::FreeItem(size_t index)
|
|||
} else {
|
||||
free(this->data[index]);
|
||||
}
|
||||
this->data[index] = NULL;
|
||||
this->data[index] = nullptr;
|
||||
this->first_free = min(this->first_free, index);
|
||||
this->items--;
|
||||
if (!this->cleaning) Titem::PostDestructor(index);
|
||||
|
@ -199,16 +199,16 @@ DEFINE_POOL_METHOD(void)::CleanPool()
|
|||
{
|
||||
this->cleaning = true;
|
||||
for (size_t i = 0; i < this->first_unused; i++) {
|
||||
delete this->Get(i); // 'delete NULL;' is very valid
|
||||
delete this->Get(i); // 'delete nullptr;' is very valid
|
||||
}
|
||||
assert(this->items == 0);
|
||||
free(this->data);
|
||||
this->first_unused = this->first_free = this->size = 0;
|
||||
this->data = NULL;
|
||||
this->data = nullptr;
|
||||
this->cleaning = false;
|
||||
|
||||
if (Tcache) {
|
||||
while (this->alloc_cache != NULL) {
|
||||
while (this->alloc_cache != nullptr) {
|
||||
AllocCache *ac = this->alloc_cache;
|
||||
this->alloc_cache = ac->next;
|
||||
free(ac);
|
||||
|
|
|
@ -91,7 +91,7 @@ struct Pool : PoolBase {
|
|||
size_t size; ///< Current allocated size
|
||||
size_t first_free; ///< No item with index lower than this is free (doesn't say anything about this one!)
|
||||
size_t first_unused; ///< This and all higher indexes are free (doesn't say anything about first_unused-1 !)
|
||||
size_t items; ///< Number of used indexes (non-NULL)
|
||||
size_t items; ///< Number of used indexes (non-nullptr)
|
||||
#ifdef OTTD_ASSERT
|
||||
size_t checked; ///< Number of items we checked for
|
||||
#endif /* OTTD_ASSERT */
|
||||
|
@ -115,13 +115,13 @@ struct Pool : PoolBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests whether given index can be used to get valid (non-NULL) Titem
|
||||
* Tests whether given index can be used to get valid (non-nullptr) Titem
|
||||
* @param index index to examine
|
||||
* @return true if PoolItem::Get(index) will return non-NULL pointer
|
||||
* @return true if PoolItem::Get(index) will return non-nullptr pointer
|
||||
*/
|
||||
inline bool IsValidID(size_t index)
|
||||
{
|
||||
return index < this->first_unused && this->Get(index) != NULL;
|
||||
return index < this->first_unused && this->Get(index) != nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,7 +150,7 @@ struct Pool : PoolBase {
|
|||
* Allocates space for new Titem
|
||||
* @param size size of Titem
|
||||
* @return pointer to allocated memory
|
||||
* @note can never fail (return NULL), use CanAllocate() to check first!
|
||||
* @note can never fail (return nullptr), use CanAllocate() to check first!
|
||||
*/
|
||||
inline void *operator new(size_t size)
|
||||
{
|
||||
|
@ -164,7 +164,7 @@ struct Pool : PoolBase {
|
|||
*/
|
||||
inline void operator delete(void *p)
|
||||
{
|
||||
if (p == NULL) return;
|
||||
if (p == nullptr) return;
|
||||
Titem *pn = (Titem *)p;
|
||||
assert(pn == Tpool->Get(pn->index));
|
||||
Tpool->FreeItem(pn->index);
|
||||
|
@ -175,7 +175,7 @@ struct Pool : PoolBase {
|
|||
* @param size size of Titem
|
||||
* @param index index of item
|
||||
* @return pointer to allocated memory
|
||||
* @note can never fail (return NULL), use CanAllocate() to check first!
|
||||
* @note can never fail (return nullptr), use CanAllocate() to check first!
|
||||
* @pre index has to be unused! Else it will crash
|
||||
*/
|
||||
inline void *operator new(size_t size, size_t index)
|
||||
|
@ -228,9 +228,9 @@ struct Pool : PoolBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests whether given index can be used to get valid (non-NULL) Titem
|
||||
* Tests whether given index can be used to get valid (non-nullptr) Titem
|
||||
* @param index index to examine
|
||||
* @return true if PoolItem::Get(index) will return non-NULL pointer
|
||||
* @return true if PoolItem::Get(index) will return non-nullptr pointer
|
||||
*/
|
||||
static inline bool IsValidID(size_t index)
|
||||
{
|
||||
|
@ -252,11 +252,11 @@ struct Pool : PoolBase {
|
|||
* Returns Titem with given index
|
||||
* @param index of item to get
|
||||
* @return pointer to Titem
|
||||
* @note returns NULL for invalid index
|
||||
* @note returns nullptr for invalid index
|
||||
*/
|
||||
static inline Titem *GetIfValid(size_t index)
|
||||
{
|
||||
return index < Tpool->first_unused ? Tpool->Get(index) : NULL;
|
||||
return index < Tpool->first_unused ? Tpool->Get(index) : nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -282,7 +282,7 @@ struct Pool : PoolBase {
|
|||
* Dummy function called after destructor of each member.
|
||||
* If you want to use it, override it in PoolItem's subclass.
|
||||
* @param index index of deleted item
|
||||
* @note when this function is called, PoolItem::Get(index) == NULL.
|
||||
* @note when this function is called, PoolItem::Get(index) == nullptr.
|
||||
* @note it's called only when !CleaningPool()
|
||||
*/
|
||||
static inline void PostDestructor(size_t index) { }
|
||||
|
@ -314,8 +314,8 @@ private:
|
|||
};
|
||||
|
||||
#define FOR_ALL_ITEMS_FROM(type, iter, var, start) \
|
||||
for (size_t iter = start; var = NULL, iter < type::GetPoolSize(); iter++) \
|
||||
if ((var = type::Get(iter)) != NULL)
|
||||
for (size_t iter = start; var = nullptr, iter < type::GetPoolSize(); iter++) \
|
||||
if ((var = type::Get(iter)) != nullptr)
|
||||
|
||||
#define FOR_ALL_ITEMS(type, iter, var) FOR_ALL_ITEMS_FROM(type, iter, var, 0)
|
||||
|
||||
|
|
|
@ -46,13 +46,13 @@ protected:
|
|||
|
||||
public:
|
||||
|
||||
SmallMatrix() : data(NULL), width(0), height(0), capacity(0) {}
|
||||
SmallMatrix() : data(nullptr), width(0), height(0), capacity(0) {}
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @param other The other matrix to copy.
|
||||
*/
|
||||
SmallMatrix(const SmallMatrix &other) : data(NULL), width(0), height(0), capacity(0)
|
||||
SmallMatrix(const SmallMatrix &other) : data(nullptr), width(0), height(0), capacity(0)
|
||||
{
|
||||
this->Assign(other);
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ public:
|
|||
this->width = 0;
|
||||
this->capacity = 0;
|
||||
free(this->data);
|
||||
this->data = NULL;
|
||||
this->data = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -216,8 +216,8 @@ public:
|
|||
inline void Resize(uint new_width, uint new_height)
|
||||
{
|
||||
uint new_capacity = new_width * new_height;
|
||||
T *new_data = NULL;
|
||||
void (*copy)(T *dest, const T *src, size_t count) = NULL;
|
||||
T *new_data = nullptr;
|
||||
void (*copy)(T *dest, const T *src, size_t count) = nullptr;
|
||||
if (new_capacity > this->capacity) {
|
||||
/* If the data doesn't fit into current capacity, resize and copy ... */
|
||||
new_data = MallocT<T>(new_capacity);
|
||||
|
|
|
@ -53,8 +53,8 @@ static inline void GSortT(T *base, size_t num, int (CDECL *comparator)(const T*,
|
|||
{
|
||||
if (num < 2) return;
|
||||
|
||||
assert(base != NULL);
|
||||
assert(comparator != NULL);
|
||||
assert(base != nullptr);
|
||||
assert(comparator != nullptr);
|
||||
|
||||
T *a = base;
|
||||
T *b = base + 1;
|
||||
|
|
|
@ -70,9 +70,9 @@
|
|||
|
||||
#include "safeguards.h"
|
||||
|
||||
/* static */ const char *CrashLog::message = NULL;
|
||||
/* static */ char *CrashLog::gamelog_buffer = NULL;
|
||||
/* static */ const char *CrashLog::gamelog_last = NULL;
|
||||
/* static */ const char *CrashLog::message = nullptr;
|
||||
/* static */ char *CrashLog::gamelog_buffer = nullptr;
|
||||
/* static */ const char *CrashLog::gamelog_last = nullptr;
|
||||
|
||||
char *CrashLog::LogCompiler(char *buffer, const char *last) const
|
||||
{
|
||||
|
@ -168,18 +168,18 @@ char *CrashLog::LogConfiguration(char *buffer, const char *last) const
|
|||
" Sound driver: %s\n"
|
||||
" Sound set: %s (%u)\n"
|
||||
" Video driver: %s\n\n",
|
||||
BlitterFactory::GetCurrentBlitter() == NULL ? "none" : BlitterFactory::GetCurrentBlitter()->GetName(),
|
||||
BaseGraphics::GetUsedSet() == NULL ? "none" : BaseGraphics::GetUsedSet()->name,
|
||||
BaseGraphics::GetUsedSet() == NULL ? UINT32_MAX : BaseGraphics::GetUsedSet()->version,
|
||||
_current_language == NULL ? "none" : _current_language->file,
|
||||
MusicDriver::GetInstance() == NULL ? "none" : MusicDriver::GetInstance()->GetName(),
|
||||
BaseMusic::GetUsedSet() == NULL ? "none" : BaseMusic::GetUsedSet()->name,
|
||||
BaseMusic::GetUsedSet() == NULL ? UINT32_MAX : BaseMusic::GetUsedSet()->version,
|
||||
BlitterFactory::GetCurrentBlitter() == nullptr ? "none" : BlitterFactory::GetCurrentBlitter()->GetName(),
|
||||
BaseGraphics::GetUsedSet() == nullptr ? "none" : BaseGraphics::GetUsedSet()->name,
|
||||
BaseGraphics::GetUsedSet() == nullptr ? UINT32_MAX : BaseGraphics::GetUsedSet()->version,
|
||||
_current_language == nullptr ? "none" : _current_language->file,
|
||||
MusicDriver::GetInstance() == nullptr ? "none" : MusicDriver::GetInstance()->GetName(),
|
||||
BaseMusic::GetUsedSet() == nullptr ? "none" : BaseMusic::GetUsedSet()->name,
|
||||
BaseMusic::GetUsedSet() == nullptr ? UINT32_MAX : BaseMusic::GetUsedSet()->version,
|
||||
_networking ? (_network_server ? "server" : "client") : "no",
|
||||
SoundDriver::GetInstance() == NULL ? "none" : SoundDriver::GetInstance()->GetName(),
|
||||
BaseSounds::GetUsedSet() == NULL ? "none" : BaseSounds::GetUsedSet()->name,
|
||||
BaseSounds::GetUsedSet() == NULL ? UINT32_MAX : BaseSounds::GetUsedSet()->version,
|
||||
VideoDriver::GetInstance() == NULL ? "none" : VideoDriver::GetInstance()->GetName()
|
||||
SoundDriver::GetInstance() == nullptr ? "none" : SoundDriver::GetInstance()->GetName(),
|
||||
BaseSounds::GetUsedSet() == nullptr ? "none" : BaseSounds::GetUsedSet()->name,
|
||||
BaseSounds::GetUsedSet() == nullptr ? UINT32_MAX : BaseSounds::GetUsedSet()->version,
|
||||
VideoDriver::GetInstance() == nullptr ? "none" : VideoDriver::GetInstance()->GetName()
|
||||
);
|
||||
|
||||
buffer += seprintf(buffer, last,
|
||||
|
@ -197,14 +197,14 @@ char *CrashLog::LogConfiguration(char *buffer, const char *last) const
|
|||
buffer += seprintf(buffer, last, "AI Configuration (local: %i) (current: %i):\n", (int)_local_company, (int)_current_company);
|
||||
const Company *c;
|
||||
FOR_ALL_COMPANIES(c) {
|
||||
if (c->ai_info == NULL) {
|
||||
if (c->ai_info == nullptr) {
|
||||
buffer += seprintf(buffer, last, " %2i: Human\n", (int)c->index);
|
||||
} else {
|
||||
buffer += seprintf(buffer, last, " %2i: %s (v%d)\n", (int)c->index, c->ai_info->GetName(), c->ai_info->GetVersion());
|
||||
}
|
||||
}
|
||||
|
||||
if (Game::GetInfo() != NULL) {
|
||||
if (Game::GetInfo() != nullptr) {
|
||||
buffer += seprintf(buffer, last, " GS: %s (v%d)\n", Game::GetInfo()->GetName(), Game::GetInfo()->GetVersion());
|
||||
}
|
||||
buffer += seprintf(buffer, last, "\n");
|
||||
|
@ -263,7 +263,7 @@ char *CrashLog::LogLibraries(char *buffer, const char *last) const
|
|||
#endif
|
||||
|
||||
#ifdef WITH_PNG
|
||||
buffer += seprintf(buffer, last, " PNG: %s\n", png_get_libpng_ver(NULL));
|
||||
buffer += seprintf(buffer, last, " PNG: %s\n", png_get_libpng_ver(nullptr));
|
||||
#endif /* WITH_PNG */
|
||||
|
||||
#ifdef WITH_SDL
|
||||
|
@ -312,7 +312,7 @@ char *CrashLog::LogRecentNews(char *buffer, const char *last) const
|
|||
{
|
||||
buffer += seprintf(buffer, last, "Recent news messages:\n");
|
||||
|
||||
for (NewsItem *news = _oldest_news; news != NULL; news = news->next) {
|
||||
for (NewsItem *news = _oldest_news; news != nullptr; news = news->next) {
|
||||
YearMonthDay ymd;
|
||||
ConvertDateToYMD(news->date, &ymd);
|
||||
buffer += seprintf(buffer, last, "(%i-%02i-%02i) StringID: %u, Type: %u, Ref1: %u, %u, Ref2: %u, %u\n",
|
||||
|
@ -331,7 +331,7 @@ char *CrashLog::LogRecentNews(char *buffer, const char *last) const
|
|||
*/
|
||||
char *CrashLog::FillCrashLog(char *buffer, const char *last) const
|
||||
{
|
||||
time_t cur_time = time(NULL);
|
||||
time_t cur_time = time(nullptr);
|
||||
buffer += seprintf(buffer, last, "*** OpenTTD Crash Report ***\n\n");
|
||||
buffer += seprintf(buffer, last, "Crash at: %s", asctime(gmtime(&cur_time)));
|
||||
|
||||
|
@ -369,7 +369,7 @@ bool CrashLog::WriteCrashLog(const char *buffer, char *filename, const char *fil
|
|||
seprintf(filename, filename_last, "%scrash.log", _personal_dir);
|
||||
|
||||
FILE *file = FioFOpenFile(filename, "w", NO_DIRECTORY);
|
||||
if (file == NULL) return false;
|
||||
if (file == nullptr) return false;
|
||||
|
||||
size_t len = strlen(buffer);
|
||||
size_t written = fwrite(buffer, 1, len, file);
|
||||
|
@ -396,7 +396,7 @@ bool CrashLog::WriteSavegame(char *filename, const char *filename_last) const
|
|||
{
|
||||
/* If the map array doesn't exist, saving will fail too. If the map got
|
||||
* initialised, there is a big chance the rest is initialised too. */
|
||||
if (_m == NULL) return false;
|
||||
if (_m == nullptr) return false;
|
||||
|
||||
try {
|
||||
GamelogEmergency();
|
||||
|
@ -421,7 +421,7 @@ bool CrashLog::WriteSavegame(char *filename, const char *filename_last) const
|
|||
bool CrashLog::WriteScreenshot(char *filename, const char *filename_last) const
|
||||
{
|
||||
/* Don't draw when we have invalid screen size */
|
||||
if (_screen.width < 1 || _screen.height < 1 || _screen.dst_ptr == NULL) return false;
|
||||
if (_screen.width < 1 || _screen.height < 1 || _screen.dst_ptr == nullptr) return false;
|
||||
|
||||
bool res = MakeScreenshot(SC_CRASHLOG, "crash");
|
||||
if (res) strecpy(filename, _full_screenshot_name, filename_last);
|
||||
|
@ -504,7 +504,7 @@ bool CrashLog::MakeCrashLog() const
|
|||
*/
|
||||
/* static */ void CrashLog::AfterCrashLogCleanup()
|
||||
{
|
||||
if (MusicDriver::GetInstance() != NULL) MusicDriver::GetInstance()->Stop();
|
||||
if (SoundDriver::GetInstance() != NULL) SoundDriver::GetInstance()->Stop();
|
||||
if (VideoDriver::GetInstance() != NULL) VideoDriver::GetInstance()->Stop();
|
||||
if (MusicDriver::GetInstance() != nullptr) MusicDriver::GetInstance()->Stop();
|
||||
if (SoundDriver::GetInstance() != nullptr) SoundDriver::GetInstance()->Stop();
|
||||
if (VideoDriver::GetInstance() != nullptr) VideoDriver::GetInstance()->Stop();
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ protected:
|
|||
* Writes actually encountered error to the buffer.
|
||||
* @param buffer The begin where to write at.
|
||||
* @param last The last position in the buffer to write to.
|
||||
* @param message Message passed to use for possible errors. Can be NULL.
|
||||
* @param message Message passed to use for possible errors. Can be nullptr.
|
||||
* @return the position of the \c '\0' character after the buffer.
|
||||
*/
|
||||
virtual char *LogError(char *buffer, const char *last, const char *message) const = 0;
|
||||
|
|
|
@ -148,7 +148,7 @@ struct SetDateWindow : Window {
|
|||
break;
|
||||
|
||||
case WID_SD_SET_DATE:
|
||||
if (this->callback != NULL) this->callback(this, ConvertYMDToDate(this->date.year, this->date.month, this->date.day));
|
||||
if (this->callback != nullptr) this->callback(this, ConvertYMDToDate(this->date.year, this->date.month, this->date.day));
|
||||
delete this;
|
||||
break;
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ static const NWidgetPart _nested_set_date_widgets[] = {
|
|||
|
||||
/** Description of the date setting window. */
|
||||
static WindowDesc _set_date_desc(
|
||||
WDP_CENTER, NULL, 0, 0,
|
||||
WDP_CENTER, nullptr, 0, 0,
|
||||
WC_SET_DATE, WC_NONE,
|
||||
0,
|
||||
_nested_set_date_widgets, lengthof(_nested_set_date_widgets)
|
||||
|
|
|
@ -120,14 +120,14 @@ static void debug_print(const char *dbg, const char *buf)
|
|||
}
|
||||
if (strcmp(dbg, "desync") == 0) {
|
||||
static FILE *f = FioFOpenFile("commands-out.log", "wb", AUTOSAVE_DIR);
|
||||
if (f == NULL) return;
|
||||
if (f == nullptr) return;
|
||||
|
||||
fprintf(f, "%s%s\n", GetLogPrefix(), buf);
|
||||
fflush(f);
|
||||
#ifdef RANDOM_DEBUG
|
||||
} else if (strcmp(dbg, "random") == 0) {
|
||||
static FILE *f = FioFOpenFile("random-out.log", "wb", AUTOSAVE_DIR);
|
||||
if (f == NULL) return;
|
||||
if (f == nullptr) return;
|
||||
|
||||
fprintf(f, "%s\n", buf);
|
||||
fflush(f);
|
||||
|
@ -200,7 +200,7 @@ void SetDebugString(const char *s)
|
|||
while (*s >= 'a' && *s <= 'z') s++;
|
||||
|
||||
/* check debugging levels */
|
||||
p = NULL;
|
||||
p = nullptr;
|
||||
for (i = debug_level; i != endof(debug_level); ++i) {
|
||||
if (s == t + strlen(i->name) && strncmp(t, i->name, s - t) == 0) {
|
||||
p = i->level;
|
||||
|
@ -211,7 +211,7 @@ void SetDebugString(const char *s)
|
|||
if (*s == '=') s++;
|
||||
v = strtoul(s, &end, 0);
|
||||
s = end;
|
||||
if (p != NULL) {
|
||||
if (p != nullptr) {
|
||||
*p = v;
|
||||
} else {
|
||||
ShowInfoF("Unknown debug level '%.*s'", (int)(s - t), t);
|
||||
|
@ -246,13 +246,13 @@ const char *GetDebugString()
|
|||
/**
|
||||
* Get the prefix for logs; if show_date_in_logs is enabled it returns
|
||||
* the date, otherwise it returns nothing.
|
||||
* @return the prefix for logs (do not free), never NULL
|
||||
* @return the prefix for logs (do not free), never nullptr
|
||||
*/
|
||||
const char *GetLogPrefix()
|
||||
{
|
||||
static char _log_prefix[24];
|
||||
if (_settings_client.gui.show_date_in_logs) {
|
||||
time_t cur_time = time(NULL);
|
||||
time_t cur_time = time(nullptr);
|
||||
strftime(_log_prefix, sizeof(_log_prefix), "[%Y-%m-%d %H:%M:%S] ", localtime(&cur_time));
|
||||
} else {
|
||||
*_log_prefix = '\0';
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
#include "stdafx.h"
|
||||
|
||||
char *_log_file = NULL; ///< File to reroute output of a forked OpenTTD to
|
||||
FILE *_log_fd = NULL; ///< File to reroute output of a forked OpenTTD to
|
||||
char *_log_file = nullptr; ///< File to reroute output of a forked OpenTTD to
|
||||
FILE *_log_fd = nullptr; ///< File to reroute output of a forked OpenTTD to
|
||||
|
||||
#if defined(UNIX)
|
||||
|
||||
|
@ -41,7 +41,7 @@ void DedicatedFork()
|
|||
case 0: { // We're the child
|
||||
/* Open the log-file to log all stuff too */
|
||||
_log_fd = fopen(_log_file, "a");
|
||||
if (_log_fd == NULL) {
|
||||
if (_log_fd == nullptr) {
|
||||
perror("Unable to open logfile");
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
*
|
||||
* Copies the source string to the destination buffer with respect of the
|
||||
* terminating null-character and the last pointer to the last element in
|
||||
* the destination buffer. If the last pointer is set to NULL no boundary
|
||||
* the destination buffer. If the last pointer is set to nullptr no boundary
|
||||
* check is performed.
|
||||
*
|
||||
* @note usage: strecpy(dst, src, lastof(dst));
|
||||
|
@ -85,7 +85,7 @@ char *strecpy(char *dst, const char *src, const char *last)
|
|||
*
|
||||
* Appends the source string to the destination string with respect of the
|
||||
* terminating null-character and and the last pointer to the last element
|
||||
* in the destination buffer. If the last pointer is set to NULL no
|
||||
* in the destination buffer. If the last pointer is set to nullptr no
|
||||
* boundary check is performed.
|
||||
*
|
||||
* @note usage: strecat(dst, src, lastof(dst));
|
||||
|
@ -163,13 +163,13 @@ public:
|
|||
File(const char *filename)
|
||||
{
|
||||
this->fp = fopen(filename, "r");
|
||||
if (this->fp == NULL) {
|
||||
if (this->fp == nullptr) {
|
||||
fprintf(stdout, "Could not open %s for reading\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
this->dirname = strdup(filename);
|
||||
char *last = strrchr(this->dirname, '/');
|
||||
if (last != NULL) {
|
||||
if (last != nullptr) {
|
||||
*last = '\0';
|
||||
} else {
|
||||
*this->dirname = '\0';
|
||||
|
@ -247,7 +247,7 @@ public:
|
|||
* Create the lexer and fill the keywords table.
|
||||
* @param file the file to read from.
|
||||
*/
|
||||
Lexer(const File *file) : file(file), current_char('\0'), string(NULL), token(TOKEN_UNKNOWN)
|
||||
Lexer(const File *file) : file(file), current_char('\0'), string(nullptr), token(TOKEN_UNKNOWN)
|
||||
{
|
||||
this->keywords["define"] = TOKEN_DEFINE;
|
||||
this->keywords["defined"] = TOKEN_DEFINED;
|
||||
|
@ -293,7 +293,7 @@ public:
|
|||
|
||||
/**
|
||||
* Read the currenty processed string.
|
||||
* @return the string, can be NULL.
|
||||
* @return the string, can be nullptr.
|
||||
*/
|
||||
const char *GetString() const
|
||||
{
|
||||
|
@ -308,7 +308,7 @@ public:
|
|||
{
|
||||
for (;;) {
|
||||
free(this->string);
|
||||
this->string = NULL;
|
||||
this->string = nullptr;
|
||||
this->token = TOKEN_UNKNOWN;
|
||||
|
||||
switch (this->current_char) {
|
||||
|
@ -503,7 +503,7 @@ private:
|
|||
* @param dirname the directory to look in.
|
||||
* @param filename the file to look for.
|
||||
* @param local whether to look locally (in dirname) for the file.
|
||||
* @return the absolute path, or NULL if the file doesn't exist.
|
||||
* @return the absolute path, or nullptr if the file doesn't exist.
|
||||
*/
|
||||
const char *GeneratePath(const char *dirname, const char *filename, bool local)
|
||||
{
|
||||
|
@ -517,7 +517,7 @@ const char *GeneratePath(const char *dirname, const char *filename, bool local)
|
|||
while (*p == '.') {
|
||||
if (*(++p) == '.') {
|
||||
char *s = strrchr(path, '/');
|
||||
if (s != NULL) *s = '\0';
|
||||
if (s != nullptr) *s = '\0';
|
||||
p += 2;
|
||||
}
|
||||
}
|
||||
|
@ -535,7 +535,7 @@ const char *GeneratePath(const char *dirname, const char *filename, bool local)
|
|||
while (*p == '.') {
|
||||
if (*(++p) == '.') {
|
||||
char *s = strrchr(path, '/');
|
||||
if (s != NULL) *s = '\0';
|
||||
if (s != nullptr) *s = '\0';
|
||||
p += 2;
|
||||
}
|
||||
}
|
||||
|
@ -545,7 +545,7 @@ const char *GeneratePath(const char *dirname, const char *filename, bool local)
|
|||
if (access(path, R_OK) == 0) return strdup(path);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -730,7 +730,7 @@ void ScanFile(const char *filename, const char *ext, bool header, bool verbose)
|
|||
break;
|
||||
}
|
||||
const char *h = GeneratePath(file.GetDirname(), lexer.GetString(), lexer.GetToken() == TOKEN_LOCAL);
|
||||
if (h != NULL) {
|
||||
if (h != nullptr) {
|
||||
StringMap::iterator it = _headers.find(h);
|
||||
if (it == _headers.end()) {
|
||||
it = (_headers.insert(StringMapItem(strdup(h), new StringSet()))).first;
|
||||
|
@ -745,7 +745,7 @@ void ScanFile(const char *filename, const char *ext, bool header, bool verbose)
|
|||
char path[PATH_MAX];
|
||||
strecpy(path, filename, lastof(path));
|
||||
*(strrchr(path, '.')) = '\0';
|
||||
strecat(path, ext != NULL ? ext : ".o", lastof(path));
|
||||
strecat(path, ext != nullptr ? ext : ".o", lastof(path));
|
||||
curfile = _files.find(path);
|
||||
if (curfile == _files.end()) {
|
||||
curfile = (_files.insert(StringMapItem(strdup(path), new StringSet()))).first;
|
||||
|
@ -909,9 +909,9 @@ void ScanFile(const char *filename, const char *ext, bool header, bool verbose)
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
bool ignorenext = true;
|
||||
char *filename = NULL;
|
||||
char *ext = NULL;
|
||||
char *delimiter = NULL;
|
||||
char *filename = nullptr;
|
||||
char *ext = nullptr;
|
||||
char *delimiter = nullptr;
|
||||
bool append = false;
|
||||
bool verbose = false;
|
||||
|
||||
|
@ -936,25 +936,25 @@ int main(int argc, char *argv[])
|
|||
/* Define */
|
||||
if (strncmp(argv[i], "-D", 2) == 0) {
|
||||
char *p = strchr(argv[i], '=');
|
||||
if (p != NULL) *p = '\0';
|
||||
if (p != nullptr) *p = '\0';
|
||||
_defines.insert(strdup(&argv[i][2]));
|
||||
continue;
|
||||
}
|
||||
/* Output file */
|
||||
if (strncmp(argv[i], "-f", 2) == 0) {
|
||||
if (filename != NULL) continue;
|
||||
if (filename != nullptr) continue;
|
||||
filename = strdup(&argv[i][2]);
|
||||
continue;
|
||||
}
|
||||
/* Object file extension */
|
||||
if (strncmp(argv[i], "-o", 2) == 0) {
|
||||
if (ext != NULL) continue;
|
||||
if (ext != nullptr) continue;
|
||||
ext = strdup(&argv[i][2]);
|
||||
continue;
|
||||
}
|
||||
/* Starting string delimiter */
|
||||
if (strncmp(argv[i], "-s", 2) == 0) {
|
||||
if (delimiter != NULL) continue;
|
||||
if (delimiter != nullptr) continue;
|
||||
delimiter = strdup(&argv[i][2]);
|
||||
continue;
|
||||
}
|
||||
|
@ -966,22 +966,22 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
/* Default output file is Makefile */
|
||||
if (filename == NULL) filename = strdup("Makefile");
|
||||
if (filename == nullptr) filename = strdup("Makefile");
|
||||
|
||||
/* Default delimiter string */
|
||||
if (delimiter == NULL) delimiter = strdup("# DO NOT DELETE");
|
||||
if (delimiter == nullptr) delimiter = strdup("# DO NOT DELETE");
|
||||
|
||||
char backup[PATH_MAX];
|
||||
strecpy(backup, filename, lastof(backup));
|
||||
strecat(backup, ".bak", lastof(backup));
|
||||
|
||||
char *content = NULL;
|
||||
char *content = nullptr;
|
||||
long size = 0;
|
||||
|
||||
/* Read in the current file; so we can overwrite everything from the
|
||||
* end of non-depend data marker down till the end. */
|
||||
FILE *src = fopen(filename, "rb");
|
||||
if (src != NULL) {
|
||||
if (src != nullptr) {
|
||||
fseek(src, 0, SEEK_END);
|
||||
if ((size = ftell(src)) < 0) {
|
||||
fprintf(stderr, "Could not read %s\n", filename);
|
||||
|
@ -1009,7 +1009,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* Then append it to the real file. */
|
||||
src = fopen(backup, "r");
|
||||
while (fgets(content, size, src) != NULL) {
|
||||
while (fgets(content, size, src) != nullptr) {
|
||||
fputs(content, dst);
|
||||
if (!strncmp(content, delimiter, strlen(delimiter))) found_delimiter = true;
|
||||
if (!append && found_delimiter) break;
|
||||
|
|
|
@ -33,7 +33,7 @@ static bool IsUniqueDepotName(const char *name)
|
|||
const Depot *d;
|
||||
|
||||
FOR_ALL_DEPOTS(d) {
|
||||
if (d->name != NULL && strcmp(d->name, name) == 0) return false;
|
||||
if (d->name != nullptr && strcmp(d->name, name) == 0) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -51,7 +51,7 @@ static bool IsUniqueDepotName(const char *name)
|
|||
CommandCost CmdRenameDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
Depot *d = Depot::GetIfValid(p1);
|
||||
if (d == NULL) return CMD_ERROR;
|
||||
if (d == nullptr) return CMD_ERROR;
|
||||
|
||||
CommandCost ret = CheckTileOwnership(d->xy);
|
||||
if (ret.Failed()) return ret;
|
||||
|
@ -67,7 +67,7 @@ CommandCost CmdRenameDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||
free(d->name);
|
||||
|
||||
if (reset) {
|
||||
d->name = NULL;
|
||||
d->name = nullptr;
|
||||
MakeDefaultName(d);
|
||||
} else {
|
||||
d->name = stredup(text);
|
||||
|
|
|
@ -133,16 +133,16 @@ static void TrainDepotMoveVehicle(const Vehicle *wagon, VehicleID sel, const Veh
|
|||
|
||||
if (v == wagon) return;
|
||||
|
||||
if (wagon == NULL) {
|
||||
if (head != NULL) wagon = head->Last();
|
||||
if (wagon == nullptr) {
|
||||
if (head != nullptr) wagon = head->Last();
|
||||
} else {
|
||||
wagon = wagon->Previous();
|
||||
if (wagon == NULL) return;
|
||||
if (wagon == nullptr) return;
|
||||
}
|
||||
|
||||
if (wagon == v) return;
|
||||
|
||||
DoCommandP(v->tile, v->index | (_ctrl_pressed ? 1 : 0) << 20, wagon == NULL ? INVALID_VEHICLE : wagon->index, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_MOVE_VEHICLE));
|
||||
DoCommandP(v->tile, v->index | (_ctrl_pressed ? 1 : 0) << 20, wagon == nullptr ? INVALID_VEHICLE : wagon->index, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_MOVE_VEHICLE));
|
||||
}
|
||||
|
||||
static VehicleCellSize _base_block_sizes_depot[VEH_COMPANY_END]; ///< Cell size for vehicle images in the depot view.
|
||||
|
@ -228,7 +228,7 @@ void InitDepotWindowBlockSizes()
|
|||
if (!e->IsEnabled()) continue;
|
||||
|
||||
uint w = TRAININFO_DEFAULT_VEHICLE_WIDTH;
|
||||
if (e->GetGRF() != NULL && is_custom_sprite(e->u.rail.image_index)) {
|
||||
if (e->GetGRF() != nullptr && is_custom_sprite(e->u.rail.image_index)) {
|
||||
w = e->GetGRF()->traininfo_vehicle_width;
|
||||
if (w != VEHICLEINFO_FULL_VEHICLE_WIDTH) {
|
||||
/* Hopeless.
|
||||
|
@ -279,7 +279,7 @@ struct DepotWindow : Window {
|
|||
this->unitnumber_digits = 2;
|
||||
|
||||
this->CreateNestedTree();
|
||||
this->hscroll = (this->type == VEH_TRAIN ? this->GetScrollbar(WID_D_H_SCROLL) : NULL);
|
||||
this->hscroll = (this->type == VEH_TRAIN ? this->GetScrollbar(WID_D_H_SCROLL) : nullptr);
|
||||
this->vscroll = this->GetScrollbar(WID_D_V_SCROLL);
|
||||
/* Don't show 'rename button' of aircraft hangar */
|
||||
this->GetWidget<NWidgetStacked>(WID_D_SHOW_RENAME)->SetDisplayedPlane(type == VEH_AIRCRAFT ? SZSP_NONE : 0);
|
||||
|
@ -469,8 +469,8 @@ struct DepotWindow : Window {
|
|||
/* Clicking on 'line' / 'block' without a vehicle */
|
||||
if (this->type == VEH_TRAIN) {
|
||||
/* End the dragging */
|
||||
d->head = NULL;
|
||||
d->wagon = NULL;
|
||||
d->head = nullptr;
|
||||
d->wagon = nullptr;
|
||||
return MODE_DRAG_VEHICLE;
|
||||
} else {
|
||||
return MODE_ERROR; // empty block, so no vehicle is selected
|
||||
|
@ -490,7 +490,7 @@ struct DepotWindow : Window {
|
|||
wagon = true;
|
||||
}
|
||||
|
||||
const Train *v = NULL;
|
||||
const Train *v = nullptr;
|
||||
if (this->type == VEH_TRAIN) {
|
||||
v = Train::From(*veh);
|
||||
d->head = d->wagon = v;
|
||||
|
@ -525,12 +525,12 @@ struct DepotWindow : Window {
|
|||
x -= this->header_width;
|
||||
|
||||
/* find the vehicle in this row that was clicked */
|
||||
for (; v != NULL; v = v->Next()) {
|
||||
for (; v != nullptr; v = v->Next()) {
|
||||
x -= v->GetDisplayImageWidth();
|
||||
if (x < 0) break;
|
||||
}
|
||||
|
||||
d->wagon = (v != NULL ? v->GetFirstEnginePart() : NULL);
|
||||
d->wagon = (v != nullptr ? v->GetFirstEnginePart() : nullptr);
|
||||
|
||||
return MODE_DRAG_VEHICLE;
|
||||
}
|
||||
|
@ -542,8 +542,8 @@ struct DepotWindow : Window {
|
|||
*/
|
||||
void DepotClick(int x, int y)
|
||||
{
|
||||
GetDepotVehiclePtData gdvp = { NULL, NULL };
|
||||
const Vehicle *v = NULL;
|
||||
GetDepotVehiclePtData gdvp = { nullptr, nullptr };
|
||||
const Vehicle *v = nullptr;
|
||||
DepotGUIAction mode = this->GetVehicleFromDepotWndPt(x, y, &v, &gdvp);
|
||||
|
||||
if (this->type == VEH_TRAIN) v = gdvp.wagon;
|
||||
|
@ -553,14 +553,14 @@ struct DepotWindow : Window {
|
|||
return;
|
||||
|
||||
case MODE_DRAG_VEHICLE: { // start dragging of vehicle
|
||||
if (v != NULL && VehicleClicked(v)) return;
|
||||
if (v != nullptr && VehicleClicked(v)) return;
|
||||
|
||||
VehicleID sel = this->sel;
|
||||
|
||||
if (this->type == VEH_TRAIN && sel != INVALID_VEHICLE) {
|
||||
this->sel = INVALID_VEHICLE;
|
||||
TrainDepotMoveVehicle(v, sel, gdvp.head);
|
||||
} else if (v != NULL) {
|
||||
} else if (v != nullptr) {
|
||||
SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
|
||||
SetMouseCursorVehicle(v, EIT_IN_DEPOT);
|
||||
_cursor.vehchain = _ctrl_pressed;
|
||||
|
@ -728,7 +728,7 @@ struct DepotWindow : Window {
|
|||
uint max_width = ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
|
||||
for (uint num = 0; num < this->vehicle_list.size(); num++) {
|
||||
uint width = 0;
|
||||
for (const Train *v = Train::From(this->vehicle_list[num]); v != NULL; v = v->Next()) {
|
||||
for (const Train *v = Train::From(this->vehicle_list[num]); v != nullptr; v = v->Next()) {
|
||||
width += v->GetDisplayImageWidth();
|
||||
}
|
||||
max_width = max(max_width, width);
|
||||
|
@ -839,24 +839,24 @@ struct DepotWindow : Window {
|
|||
|
||||
void OnQueryTextFinished(char *str) override
|
||||
{
|
||||
if (str == NULL) return;
|
||||
if (str == nullptr) return;
|
||||
|
||||
/* Do depot renaming */
|
||||
DoCommandP(0, GetDepotIndex(this->window_number), 0, CMD_RENAME_DEPOT | CMD_MSG(STR_ERROR_CAN_T_RENAME_DEPOT), NULL, str);
|
||||
DoCommandP(0, GetDepotIndex(this->window_number), 0, CMD_RENAME_DEPOT | CMD_MSG(STR_ERROR_CAN_T_RENAME_DEPOT), nullptr, str);
|
||||
}
|
||||
|
||||
bool OnRightClick(Point pt, int widget) override
|
||||
{
|
||||
if (widget != WID_D_MATRIX) return false;
|
||||
|
||||
GetDepotVehiclePtData gdvp = { NULL, NULL };
|
||||
const Vehicle *v = NULL;
|
||||
GetDepotVehiclePtData gdvp = { nullptr, nullptr };
|
||||
const Vehicle *v = nullptr;
|
||||
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_D_MATRIX);
|
||||
DepotGUIAction mode = this->GetVehicleFromDepotWndPt(pt.x - nwi->pos_x, pt.y - nwi->pos_y, &v, &gdvp);
|
||||
|
||||
if (this->type == VEH_TRAIN) v = gdvp.wagon;
|
||||
|
||||
if (v == NULL || mode != MODE_DRAG_VEHICLE) return false;
|
||||
if (v == nullptr || mode != MODE_DRAG_VEHICLE) return false;
|
||||
|
||||
CargoArray capacity, loaded;
|
||||
|
||||
|
@ -865,7 +865,7 @@ struct DepotWindow : Window {
|
|||
|
||||
/* loop through vehicle chain and collect cargoes */
|
||||
uint num = 0;
|
||||
for (const Vehicle *w = v; w != NULL; w = w->Next()) {
|
||||
for (const Vehicle *w = v; w != nullptr; w = w->Next()) {
|
||||
if (w->cargo_cap > 0 && w->cargo_type < NUM_CARGO) {
|
||||
capacity[w->cargo_type] += w->cargo_cap;
|
||||
loaded [w->cargo_type] += w->cargo.StoredCount();
|
||||
|
@ -910,7 +910,7 @@ struct DepotWindow : Window {
|
|||
{
|
||||
if (_ctrl_pressed) {
|
||||
/* Share-clone, do not open new viewport, and keep tool active */
|
||||
DoCommandP(this->window_number, v->index, 1, CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN + v->type), NULL);
|
||||
DoCommandP(this->window_number, v->index, 1, CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN + v->type), nullptr);
|
||||
} else {
|
||||
/* Copy-clone, open viewport for new vehicle, and deselect the tool (assume player wants to changs things on new vehicle) */
|
||||
if (DoCommandP(this->window_number, v->index, 0, CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN + v->type), CcCloneVehicle)) {
|
||||
|
@ -965,20 +965,20 @@ struct DepotWindow : Window {
|
|||
}
|
||||
|
||||
NWidgetBase *matrix = this->GetWidget<NWidgetBase>(widget);
|
||||
const Vehicle *v = NULL;
|
||||
GetDepotVehiclePtData gdvp = {NULL, NULL};
|
||||
const Vehicle *v = nullptr;
|
||||
GetDepotVehiclePtData gdvp = {nullptr, nullptr};
|
||||
|
||||
if (this->GetVehicleFromDepotWndPt(pt.x - matrix->pos_x, pt.y - matrix->pos_y, &v, &gdvp) != MODE_DRAG_VEHICLE) return;
|
||||
|
||||
VehicleID new_vehicle_over = INVALID_VEHICLE;
|
||||
if (gdvp.head != NULL) {
|
||||
if (gdvp.wagon == NULL && gdvp.head->Last()->index != this->sel) { // ..at the end of the train.
|
||||
if (gdvp.head != nullptr) {
|
||||
if (gdvp.wagon == nullptr && gdvp.head->Last()->index != this->sel) { // ..at the end of the train.
|
||||
/* NOTE: As a wagon can't be moved at the begin of a train, head index isn't used to mark a drag-and-drop
|
||||
* destination inside a train. This head index is then used to indicate that a wagon is inserted at
|
||||
* the end of the train.
|
||||
*/
|
||||
new_vehicle_over = gdvp.head->index;
|
||||
} else if (gdvp.wagon != NULL && gdvp.head != gdvp.wagon &&
|
||||
} else if (gdvp.wagon != nullptr && gdvp.head != gdvp.wagon &&
|
||||
gdvp.wagon->index != this->sel &&
|
||||
gdvp.wagon->Previous()->index != this->sel) { // ..over an existing wagon.
|
||||
new_vehicle_over = gdvp.wagon->index;
|
||||
|
@ -995,7 +995,7 @@ struct DepotWindow : Window {
|
|||
{
|
||||
switch (widget) {
|
||||
case WID_D_MATRIX: {
|
||||
const Vehicle *v = NULL;
|
||||
const Vehicle *v = nullptr;
|
||||
VehicleID sel = this->sel;
|
||||
|
||||
this->sel = INVALID_VEHICLE;
|
||||
|
@ -1003,20 +1003,20 @@ struct DepotWindow : Window {
|
|||
|
||||
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(WID_D_MATRIX);
|
||||
if (this->type == VEH_TRAIN) {
|
||||
GetDepotVehiclePtData gdvp = { NULL, NULL };
|
||||
GetDepotVehiclePtData gdvp = { nullptr, nullptr };
|
||||
|
||||
if (this->GetVehicleFromDepotWndPt(pt.x - nwi->pos_x, pt.y - nwi->pos_y, &v, &gdvp) == MODE_DRAG_VEHICLE && sel != INVALID_VEHICLE) {
|
||||
if (gdvp.wagon != NULL && gdvp.wagon->index == sel && _ctrl_pressed) {
|
||||
if (gdvp.wagon != nullptr && gdvp.wagon->index == sel && _ctrl_pressed) {
|
||||
DoCommandP(Vehicle::Get(sel)->tile, Vehicle::Get(sel)->index, true,
|
||||
CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE));
|
||||
} else if (gdvp.wagon == NULL || gdvp.wagon->index != sel) {
|
||||
} else if (gdvp.wagon == nullptr || gdvp.wagon->index != sel) {
|
||||
this->vehicle_over = INVALID_VEHICLE;
|
||||
TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
|
||||
} else if (gdvp.head != NULL && gdvp.head->IsFrontEngine()) {
|
||||
} else if (gdvp.head != nullptr && gdvp.head->IsFrontEngine()) {
|
||||
ShowVehicleViewWindow(gdvp.head);
|
||||
}
|
||||
}
|
||||
} else if (this->GetVehicleFromDepotWndPt(pt.x - nwi->pos_x, pt.y - nwi->pos_y, &v, NULL) == MODE_DRAG_VEHICLE && v != NULL && sel == v->index) {
|
||||
} else if (this->GetVehicleFromDepotWndPt(pt.x - nwi->pos_x, pt.y - nwi->pos_y, &v, nullptr) == MODE_DRAG_VEHICLE && v != nullptr && sel == v->index) {
|
||||
ShowVehicleViewWindow(v);
|
||||
}
|
||||
break;
|
||||
|
@ -1052,7 +1052,7 @@ struct DepotWindow : Window {
|
|||
this->RaiseWidget(WID_D_SELL);
|
||||
this->SetWidgetDirty(WID_D_SELL);
|
||||
}
|
||||
if (this->nested_array[WID_D_SELL] != NULL && !this->IsWidgetDisabled(WID_D_SELL_CHAIN)) {
|
||||
if (this->nested_array[WID_D_SELL] != nullptr && !this->IsWidgetDisabled(WID_D_SELL_CHAIN)) {
|
||||
this->RaiseWidget(WID_D_SELL_CHAIN);
|
||||
this->SetWidgetDirty(WID_D_SELL_CHAIN);
|
||||
}
|
||||
|
@ -1098,7 +1098,7 @@ static void DepotSellAllConfirmationCallback(Window *win, bool confirmed)
|
|||
*/
|
||||
void ShowDepotWindow(TileIndex tile, VehicleType type)
|
||||
{
|
||||
if (BringWindowToFrontById(WC_VEHICLE_DEPOT, tile) != NULL) return;
|
||||
if (BringWindowToFrontById(WC_VEHICLE_DEPOT, tile) != nullptr) return;
|
||||
|
||||
WindowDesc *desc;
|
||||
switch (type) {
|
||||
|
@ -1126,7 +1126,7 @@ void DeleteDepotHighlightOfVehicle(const Vehicle *v)
|
|||
if (_special_mouse_mode != WSM_DRAGDROP) return;
|
||||
|
||||
w = dynamic_cast<DepotWindow*>(FindWindowById(WC_VEHICLE_DEPOT, v->tile));
|
||||
if (w != NULL) {
|
||||
if (w != nullptr) {
|
||||
if (w->sel == v->index) ResetObjectToPlace();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,11 +137,11 @@ DisasterVehicle::DisasterVehicle(int x, int y, Direction direction, DisasterSubT
|
|||
case ST_HELICOPTER:
|
||||
case ST_BIG_UFO:
|
||||
case ST_BIG_UFO_DESTROYER:
|
||||
GetAircraftFlightLevelBounds(this, &this->z_pos, NULL);
|
||||
GetAircraftFlightLevelBounds(this, &this->z_pos, nullptr);
|
||||
break;
|
||||
|
||||
case ST_HELICOPTER_ROTORS:
|
||||
GetAircraftFlightLevelBounds(this, &this->z_pos, NULL);
|
||||
GetAircraftFlightLevelBounds(this, &this->z_pos, nullptr);
|
||||
this->z_pos += ROTOR_Z_OFFSET;
|
||||
break;
|
||||
|
||||
|
@ -190,7 +190,7 @@ void DisasterVehicle::UpdatePosition(int x, int y, int z)
|
|||
this->UpdatePositionAndViewport();
|
||||
|
||||
DisasterVehicle *u = this->Next();
|
||||
if (u != NULL) {
|
||||
if (u != nullptr) {
|
||||
int safe_x = Clamp(x, 0, MapMaxX() * TILE_SIZE);
|
||||
int safe_y = Clamp(y - 1, 0, MapMaxY() * TILE_SIZE);
|
||||
|
||||
|
@ -203,7 +203,7 @@ void DisasterVehicle::UpdatePosition(int x, int y, int z)
|
|||
u->UpdateImage();
|
||||
u->UpdatePositionAndViewport();
|
||||
|
||||
if ((u = u->Next()) != NULL) {
|
||||
if ((u = u->Next()) != nullptr) {
|
||||
u->x_pos = x;
|
||||
u->y_pos = y;
|
||||
u->z_pos = z + ROTOR_Z_OFFSET;
|
||||
|
@ -357,7 +357,7 @@ static bool DisasterTick_Ufo(DisasterVehicle *v)
|
|||
} else {
|
||||
/* Target a vehicle */
|
||||
RoadVehicle *u = RoadVehicle::Get(v->dest_tile);
|
||||
assert(u != NULL && u->type == VEH_ROAD && u->IsFrontEngine());
|
||||
assert(u != nullptr && u->type == VEH_ROAD && u->IsFrontEngine());
|
||||
|
||||
uint dist = Delta(v->x_pos, u->x_pos) + Delta(v->y_pos, u->y_pos);
|
||||
|
||||
|
@ -748,16 +748,16 @@ static void Disaster_Airplane_Init()
|
|||
{
|
||||
if (!Vehicle::CanAllocateItem(2)) return;
|
||||
|
||||
Industry *i, *found = NULL;
|
||||
Industry *i, *found = nullptr;
|
||||
|
||||
FOR_ALL_INDUSTRIES(i) {
|
||||
if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_AIRPLANE_ATTACKS) &&
|
||||
(found == NULL || Chance16(1, 2))) {
|
||||
(found == nullptr || Chance16(1, 2))) {
|
||||
found = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (found == NULL) return;
|
||||
if (found == nullptr) return;
|
||||
|
||||
/* Start from the bottom (south side) of the map */
|
||||
int x = (MapSizeX() + 9) * TILE_SIZE - 1;
|
||||
|
@ -774,16 +774,16 @@ static void Disaster_Helicopter_Init()
|
|||
{
|
||||
if (!Vehicle::CanAllocateItem(3)) return;
|
||||
|
||||
Industry *i, *found = NULL;
|
||||
Industry *i, *found = nullptr;
|
||||
|
||||
FOR_ALL_INDUSTRIES(i) {
|
||||
if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_CHOPPER_ATTACKS) &&
|
||||
(found == NULL || Chance16(1, 2))) {
|
||||
(found == nullptr || Chance16(1, 2))) {
|
||||
found = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (found == NULL) return;
|
||||
if (found == nullptr) return;
|
||||
|
||||
int x = -16 * (int)TILE_SIZE;
|
||||
int y = TileY(found->location.tile) * TILE_SIZE + 37;
|
||||
|
@ -966,7 +966,7 @@ void ReleaseDisastersTargetingVehicle(VehicleID vehicle)
|
|||
/* Revert to target-searching */
|
||||
v->current_order.SetDestination(0);
|
||||
v->dest_tile = RandomTile();
|
||||
GetAircraftFlightLevelBounds(v, &v->z_pos, NULL);
|
||||
GetAircraftFlightLevelBounds(v, &v->z_pos, nullptr);
|
||||
v->age = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ void CcPlaySound_SPLAT_WATER(const CommandCost &result, TileIndex tile, uint32 p
|
|||
* @param[out] tile_to The tile till where to show a selection for the aqueduct.
|
||||
* @return The other end of the aqueduct, or otherwise a tile in line with the aqueduct to cause the right error message.
|
||||
*/
|
||||
static TileIndex GetOtherAqueductEnd(TileIndex tile_from, TileIndex *tile_to = NULL)
|
||||
static TileIndex GetOtherAqueductEnd(TileIndex tile_from, TileIndex *tile_to = nullptr)
|
||||
{
|
||||
int z;
|
||||
DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile_from, &z));
|
||||
|
@ -83,7 +83,7 @@ static TileIndex GetOtherAqueductEnd(TileIndex tile_from, TileIndex *tile_to = N
|
|||
if (length > max_length) break;
|
||||
|
||||
if (GetTileMaxZ(endtile) > z) {
|
||||
if (tile_to != NULL) *tile_to = endtile;
|
||||
if (tile_to != nullptr) *tile_to = endtile;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ static EventState DockToolbarGlobalHotkeys(int hotkey)
|
|||
{
|
||||
if (_game_mode != GM_NORMAL) return ES_NOT_HANDLED;
|
||||
Window *w = ShowBuildDocksToolbar();
|
||||
if (w == NULL) return ES_NOT_HANDLED;
|
||||
if (w == nullptr) return ES_NOT_HANDLED;
|
||||
return w->OnHotkey(hotkey);
|
||||
}
|
||||
|
||||
|
@ -341,11 +341,11 @@ static WindowDesc _build_docks_toolbar_desc(
|
|||
*
|
||||
* If the terraform toolbar is linked to the toolbar, that window is also opened.
|
||||
*
|
||||
* @return newly opened water toolbar, or NULL if the toolbar could not be opened.
|
||||
* @return newly opened water toolbar, or nullptr if the toolbar could not be opened.
|
||||
*/
|
||||
Window *ShowBuildDocksToolbar()
|
||||
{
|
||||
if (!Company::IsValidID(_local_company)) return NULL;
|
||||
if (!Company::IsValidID(_local_company)) return nullptr;
|
||||
|
||||
DeleteWindowByClass(WC_BUILD_TOOLBAR);
|
||||
return AllocateWindowDescFront<BuildDocksToolbarWindow>(&_build_docks_toolbar_desc, TRANSPORT_WATER);
|
||||
|
@ -382,7 +382,7 @@ static WindowDesc _build_docks_scen_toolbar_desc(
|
|||
/**
|
||||
* Open the build water toolbar window for the scenario editor.
|
||||
*
|
||||
* @return newly opened water toolbar, or NULL if the toolbar could not be opened.
|
||||
* @return newly opened water toolbar, or nullptr if the toolbar could not be opened.
|
||||
*/
|
||||
Window *ShowBuildDocksScenToolbar()
|
||||
{
|
||||
|
@ -475,7 +475,7 @@ static const NWidgetPart _nested_build_dock_station_widgets[] = {
|
|||
};
|
||||
|
||||
static WindowDesc _build_dock_station_desc(
|
||||
WDP_AUTO, NULL, 0, 0,
|
||||
WDP_AUTO, nullptr, 0, 0,
|
||||
WC_BUILD_STATION, WC_BUILD_TOOLBAR,
|
||||
WDF_CONSTRUCTION,
|
||||
_nested_build_dock_station_widgets, lengthof(_nested_build_dock_station_widgets)
|
||||
|
@ -568,7 +568,7 @@ static const NWidgetPart _nested_build_docks_depot_widgets[] = {
|
|||
};
|
||||
|
||||
static WindowDesc _build_docks_depot_desc(
|
||||
WDP_AUTO, NULL, 0, 0,
|
||||
WDP_AUTO, nullptr, 0, 0,
|
||||
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
|
||||
WDF_CONSTRUCTION,
|
||||
_nested_build_docks_depot_widgets, lengthof(_nested_build_docks_depot_widgets)
|
||||
|
|
|
@ -41,10 +41,10 @@ const char *GetDriverParam(const char * const *parm, const char *name)
|
|||
{
|
||||
size_t len;
|
||||
|
||||
if (parm == NULL) return NULL;
|
||||
if (parm == nullptr) return nullptr;
|
||||
|
||||
len = strlen(name);
|
||||
for (; *parm != NULL; parm++) {
|
||||
for (; *parm != nullptr; parm++) {
|
||||
const char *p = *parm;
|
||||
|
||||
if (strncmp(p, name, len) == 0) {
|
||||
|
@ -52,7 +52,7 @@ const char *GetDriverParam(const char * const *parm, const char *name)
|
|||
if (p[len] == '\0') return p + len;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,7 +63,7 @@ const char *GetDriverParam(const char * const *parm, const char *name)
|
|||
*/
|
||||
bool GetDriverParamBool(const char * const *parm, const char *name)
|
||||
{
|
||||
return GetDriverParam(parm, name) != NULL;
|
||||
return GetDriverParam(parm, name) != nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,7 +76,7 @@ bool GetDriverParamBool(const char * const *parm, const char *name)
|
|||
int GetDriverParamInt(const char * const *parm, const char *name, int def)
|
||||
{
|
||||
const char *p = GetDriverParam(parm, name);
|
||||
return p != NULL ? atoi(p) : def;
|
||||
return p != nullptr ? atoi(p) : def;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -120,8 +120,8 @@ bool DriverFactoryBase::SelectDriverImpl(const char *name, Driver::Type type)
|
|||
Driver *newd = d->CreateInstance();
|
||||
*GetActiveDriver(type) = newd;
|
||||
|
||||
const char *err = newd->Start(NULL);
|
||||
if (err == NULL) {
|
||||
const char *err = newd->Start(nullptr);
|
||||
if (err == nullptr) {
|
||||
DEBUG(driver, 1, "Successfully probed %s driver '%s'", GetDriverTypeName(type), d->name);
|
||||
delete oldd;
|
||||
return true;
|
||||
|
@ -141,8 +141,8 @@ bool DriverFactoryBase::SelectDriverImpl(const char *name, Driver::Type type)
|
|||
/* Extract the driver name and put parameter list in parm */
|
||||
strecpy(buffer, name, lastof(buffer));
|
||||
parm = strchr(buffer, ':');
|
||||
parms[0] = NULL;
|
||||
if (parm != NULL) {
|
||||
parms[0] = nullptr;
|
||||
if (parm != nullptr) {
|
||||
uint np = 0;
|
||||
/* Tokenize the parm. */
|
||||
do {
|
||||
|
@ -150,7 +150,7 @@ bool DriverFactoryBase::SelectDriverImpl(const char *name, Driver::Type type)
|
|||
if (np < lengthof(parms) - 1) parms[np++] = parm;
|
||||
while (*parm != '\0' && *parm != ',') parm++;
|
||||
} while (*parm == ',');
|
||||
parms[np] = NULL;
|
||||
parms[np] = nullptr;
|
||||
}
|
||||
|
||||
/* Find this driver */
|
||||
|
@ -168,7 +168,7 @@ bool DriverFactoryBase::SelectDriverImpl(const char *name, Driver::Type type)
|
|||
Driver *newd = d->CreateInstance();
|
||||
|
||||
const char *err = newd->Start(parms);
|
||||
if (err != NULL) {
|
||||
if (err != nullptr) {
|
||||
delete newd;
|
||||
usererror("Unable to load driver '%s'. The error was: %s", d->name, err);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
/**
|
||||
* Start this driver.
|
||||
* @param parm Parameters passed to the driver.
|
||||
* @return NULL if everything went okay, otherwise an error message.
|
||||
* @return nullptr if everything went okay, otherwise an error message.
|
||||
*/
|
||||
virtual const char *Start(const char * const *parm) = 0;
|
||||
|
||||
|
@ -86,7 +86,7 @@ private:
|
|||
*/
|
||||
static Driver **GetActiveDriver(Driver::Type type)
|
||||
{
|
||||
static Driver *s_driver[3] = { NULL, NULL, NULL };
|
||||
static Driver *s_driver[3] = { nullptr, nullptr, nullptr };
|
||||
return &s_driver[type];
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ public:
|
|||
{
|
||||
for (Driver::Type dt = Driver::DT_BEGIN; dt < Driver::DT_END; dt++) {
|
||||
Driver *driver = *GetActiveDriver(dt);
|
||||
if (driver != NULL) driver->Stop();
|
||||
if (driver != nullptr) driver->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -401,7 +401,7 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
|
|||
FOR_ALL_VEHICLES(v) {
|
||||
if (v->owner == old_owner && IsCompanyBuildableVehicleType(v->type)) {
|
||||
if (new_owner == INVALID_OWNER) {
|
||||
if (v->Previous() == NULL) delete v;
|
||||
if (v->Previous() == nullptr) delete v;
|
||||
} else {
|
||||
if (v->IsEngineCountable()) GroupStatistics::CountEngine(v, -1);
|
||||
if (v->IsPrimaryVehicle()) GroupStatistics::CountVehicle(v, -1);
|
||||
|
@ -476,7 +476,7 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
|
|||
}
|
||||
|
||||
/* Invalidate the vehicle's cargo payment "owner cache". */
|
||||
if (v->cargo_payment != NULL) v->cargo_payment->owner = NULL;
|
||||
if (v->cargo_payment != nullptr) v->cargo_payment->owner = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -959,7 +959,7 @@ Money GetPrice(Price index, uint cost_factor, const GRFFile *grf_file, int shift
|
|||
if (index >= PR_END) return 0;
|
||||
|
||||
Money cost = _price[index] * cost_factor;
|
||||
if (grf_file != NULL) shift += grf_file->price_base_multipliers[index];
|
||||
if (grf_file != nullptr) shift += grf_file->price_base_multipliers[index];
|
||||
|
||||
if (shift >= 0) {
|
||||
cost <<= shift;
|
||||
|
@ -1180,7 +1180,7 @@ CargoPayment::~CargoPayment()
|
|||
{
|
||||
if (this->CleaningPool()) return;
|
||||
|
||||
this->front->cargo_payment = NULL;
|
||||
this->front->cargo_payment = nullptr;
|
||||
|
||||
if (this->visual_profit == 0 && this->visual_transfer == 0) return;
|
||||
|
||||
|
@ -1211,7 +1211,7 @@ CargoPayment::~CargoPayment()
|
|||
*/
|
||||
void CargoPayment::PayFinalDelivery(const CargoPacket *cp, uint count)
|
||||
{
|
||||
if (this->owner == NULL) {
|
||||
if (this->owner == nullptr) {
|
||||
this->owner = Company::Get(this->front->owner);
|
||||
}
|
||||
|
||||
|
@ -1259,7 +1259,7 @@ void PrepareUnload(Vehicle *front_v)
|
|||
/* Start unloading at the first possible moment */
|
||||
front_v->load_unload_ticks = 1;
|
||||
|
||||
assert(front_v->cargo_payment == NULL);
|
||||
assert(front_v->cargo_payment == nullptr);
|
||||
/* One CargoPayment per vehicle and the vehicle limit equals the
|
||||
* limit in number of CargoPayments. Can't go wrong. */
|
||||
assert_compile(CargoPaymentPool::MAX_SIZE == VehiclePool::MAX_SIZE);
|
||||
|
@ -1267,9 +1267,9 @@ void PrepareUnload(Vehicle *front_v)
|
|||
front_v->cargo_payment = new CargoPayment(front_v);
|
||||
|
||||
StationIDStack next_station = front_v->GetNextStoppingStation();
|
||||
if (front_v->orders.list == NULL || (front_v->current_order.GetUnloadType() & OUFB_NO_UNLOAD) == 0) {
|
||||
if (front_v->orders.list == nullptr || (front_v->current_order.GetUnloadType() & OUFB_NO_UNLOAD) == 0) {
|
||||
Station *st = Station::Get(front_v->last_station_visited);
|
||||
for (Vehicle *v = front_v; v != NULL; v = v->Next()) {
|
||||
for (Vehicle *v = front_v; v != nullptr; v = v->Next()) {
|
||||
const GoodsEntry *ge = &st->goods[v->cargo_type];
|
||||
if (v->cargo_cap > 0 && v->cargo.TotalCount() > 0) {
|
||||
v->cargo.Stage(
|
||||
|
@ -1300,7 +1300,7 @@ static uint GetLoadAmount(Vehicle *v)
|
|||
|
||||
if (_settings_game.order.gradual_loading) {
|
||||
uint16 cb_load_amount = CALLBACK_FAILED;
|
||||
if (e->GetGRF() != NULL && e->GetGRF()->grf_version >= 8) {
|
||||
if (e->GetGRF() != nullptr && e->GetGRF()->grf_version >= 8) {
|
||||
/* Use callback 36 */
|
||||
cb_load_amount = GetVehicleProperty(v, PROP_VEHICLE_LOAD_AMOUNT, CALLBACK_FAILED);
|
||||
} else if (HasBit(e->info.callback_mask, CBM_VEHICLE_LOAD_AMOUNT)) {
|
||||
|
@ -1336,8 +1336,8 @@ static uint GetLoadAmount(Vehicle *v)
|
|||
template<class Taction>
|
||||
bool IterateVehicleParts(Vehicle *v, Taction action)
|
||||
{
|
||||
for (Vehicle *w = v; w != NULL;
|
||||
w = w->HasArticulatedPart() ? w->GetNextArticulatedPart() : NULL) {
|
||||
for (Vehicle *w = v; w != nullptr;
|
||||
w = w->HasArticulatedPart() ? w->GetNextArticulatedPart() : nullptr) {
|
||||
if (!action(w)) return false;
|
||||
if (w->type == VEH_TRAIN) {
|
||||
Train *train = Train::From(w);
|
||||
|
@ -1564,8 +1564,8 @@ static void ReserveConsist(Station *st, Vehicle *u, CargoArray *consist_capleft,
|
|||
/* If there is a cargo payment not all vehicles of the consist have tried to do the refit.
|
||||
* In that case, only reserve if it's a fixed refit and the equivalent of "articulated chain"
|
||||
* a vehicle belongs to already has the right cargo. */
|
||||
bool must_reserve = !u->current_order.IsRefit() || u->cargo_payment == NULL;
|
||||
for (Vehicle *v = u; v != NULL; v = v->Next()) {
|
||||
bool must_reserve = !u->current_order.IsRefit() || u->cargo_payment == nullptr;
|
||||
for (Vehicle *v = u; v != nullptr; v = v->Next()) {
|
||||
assert(v->cargo_cap >= v->cargo.RemainingCount());
|
||||
|
||||
/* Exclude various ways in which the vehicle might not be the head of an equivalent of
|
||||
|
@ -1577,7 +1577,7 @@ static void ReserveConsist(Station *st, Vehicle *u, CargoArray *consist_capleft,
|
|||
(must_reserve || u->current_order.GetRefitCargo() == v->cargo_type)) {
|
||||
IterateVehicleParts(v, ReserveCargoAction(st, next_station));
|
||||
}
|
||||
if (consist_capleft == NULL || v->cargo_cap == 0) continue;
|
||||
if (consist_capleft == nullptr || v->cargo_cap == 0) continue;
|
||||
(*consist_capleft)[v->cargo_type] += v->cargo_cap - v->cargo.RemainingCount();
|
||||
}
|
||||
}
|
||||
|
@ -1618,9 +1618,9 @@ static void LoadUnloadVehicle(Vehicle *front)
|
|||
bool use_autorefit = front->current_order.IsRefit() && front->current_order.GetRefitCargo() == CT_AUTO_REFIT;
|
||||
CargoArray consist_capleft;
|
||||
if (_settings_game.order.improved_load && use_autorefit ?
|
||||
front->cargo_payment == NULL : (front->current_order.GetLoadType() & OLFB_FULL_LOAD) != 0) {
|
||||
front->cargo_payment == nullptr : (front->current_order.GetLoadType() & OLFB_FULL_LOAD) != 0) {
|
||||
ReserveConsist(st, front,
|
||||
(use_autorefit && front->load_unload_ticks != 0) ? &consist_capleft : NULL,
|
||||
(use_autorefit && front->load_unload_ticks != 0) ? &consist_capleft : nullptr,
|
||||
&next_station);
|
||||
}
|
||||
|
||||
|
@ -1652,7 +1652,7 @@ static void LoadUnloadVehicle(Vehicle *front)
|
|||
CargoPayment *payment = front->cargo_payment;
|
||||
|
||||
uint artic_part = 0; // Articulated part we are currently trying to load. (not counting parts without capacity)
|
||||
for (Vehicle *v = front; v != NULL; v = v->Next()) {
|
||||
for (Vehicle *v = front; v != nullptr; v = v->Next()) {
|
||||
if (v == front || !v->Previous()->HasArticulatedPart()) artic_part = 0;
|
||||
if (v->cargo_cap == 0) continue;
|
||||
artic_part++;
|
||||
|
@ -1664,7 +1664,7 @@ static void LoadUnloadVehicle(Vehicle *front)
|
|||
uint amount_unloaded = _settings_game.order.gradual_loading ? min(cargo_count, GetLoadAmount(v)) : cargo_count;
|
||||
bool remaining = false; // Are there cargo entities in this vehicle that can still be unloaded here?
|
||||
|
||||
assert(payment != NULL);
|
||||
assert(payment != nullptr);
|
||||
payment->SetCargo(v->cargo_type);
|
||||
|
||||
if (!HasBit(ge->status, GoodsEntry::GES_ACCEPTANCE) && v->cargo.ActionCount(VehicleCargoList::MTA_DELIVER) > 0) {
|
||||
|
@ -1916,7 +1916,7 @@ void LoadUnloadStation(Station *st)
|
|||
/* No vehicle is here... */
|
||||
if (st->loading_vehicles.empty()) return;
|
||||
|
||||
Vehicle *last_loading = NULL;
|
||||
Vehicle *last_loading = nullptr;
|
||||
std::list<Vehicle *>::iterator iter;
|
||||
|
||||
/* Check if anything will be loaded at all. Otherwise we don't need to reserve either. */
|
||||
|
@ -1936,7 +1936,7 @@ void LoadUnloadStation(Station *st)
|
|||
* consist in a station which is not allowed to load yet because its
|
||||
* load_unload_ticks is still not 0.
|
||||
*/
|
||||
if (last_loading == NULL) return;
|
||||
if (last_loading == nullptr) return;
|
||||
|
||||
for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end(); ++iter) {
|
||||
Vehicle *v = *iter;
|
||||
|
@ -2018,7 +2018,7 @@ CommandCost CmdBuyShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
|||
|
||||
/* Check if buying shares is allowed (protection against modified clients)
|
||||
* Cannot buy own shares */
|
||||
if (c == NULL || !_settings_game.economy.allow_shares || _current_company == target_company) return CMD_ERROR;
|
||||
if (c == nullptr || !_settings_game.economy.allow_shares || _current_company == target_company) return CMD_ERROR;
|
||||
|
||||
/* Protect new companies from hostile takeovers */
|
||||
if (_cur_year - c->inaugurated_year < 6) return_cmd_error(STR_ERROR_PROTECTED);
|
||||
|
@ -2068,7 +2068,7 @@ CommandCost CmdSellShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1
|
|||
Company *c = Company::GetIfValid(target_company);
|
||||
|
||||
/* Cannot sell own shares */
|
||||
if (c == NULL || _current_company == target_company) return CMD_ERROR;
|
||||
if (c == nullptr || _current_company == target_company) return CMD_ERROR;
|
||||
|
||||
/* Check if selling shares is allowed (protection against modified clients).
|
||||
* However, we must sell shares of companies being closed down. */
|
||||
|
@ -2107,7 +2107,7 @@ CommandCost CmdBuyCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|||
{
|
||||
CompanyID target_company = (CompanyID)p1;
|
||||
Company *c = Company::GetIfValid(target_company);
|
||||
if (c == NULL) return CMD_ERROR;
|
||||
if (c == nullptr) return CMD_ERROR;
|
||||
|
||||
/* Disable takeovers when not asked */
|
||||
if (!HasBit(c->bankrupt_asked, _current_company)) return CMD_ERROR;
|
||||
|
|
|
@ -595,7 +595,7 @@ assert_compile(lengthof(_effect_transparency_options) == EV_END);
|
|||
*/
|
||||
EffectVehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicleType type)
|
||||
{
|
||||
if (!Vehicle::CanAllocateItem()) return NULL;
|
||||
if (!Vehicle::CanAllocateItem()) return nullptr;
|
||||
|
||||
EffectVehicle *v = new EffectVehicle();
|
||||
v->subtype = type;
|
||||
|
|
|
@ -82,7 +82,7 @@ static inline TLG GetTLG(TileIndex t)
|
|||
/**
|
||||
* Finds which Electrified Rail Bits are present on a given tile.
|
||||
* @param t tile to check
|
||||
* @param override pointer to PCP override, can be NULL
|
||||
* @param override pointer to PCP override, can be nullptr
|
||||
* @return trackbits of tile if it is electrified
|
||||
*/
|
||||
static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
|
||||
|
@ -101,7 +101,7 @@ static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
|
|||
case MP_TUNNELBRIDGE:
|
||||
if (GetTunnelBridgeTransportType(t) != TRANSPORT_RAIL) return TRACK_BIT_NONE;
|
||||
if (!HasRailCatenary(GetRailType(t))) return TRACK_BIT_NONE;
|
||||
if (override != NULL && (IsTunnel(t) || GetTunnelBridgeLength(t, GetOtherBridgeEnd(t)) > 0)) {
|
||||
if (override != nullptr && (IsTunnel(t) || GetTunnelBridgeLength(t, GetOtherBridgeEnd(t)) > 0)) {
|
||||
*override = 1 << GetTunnelBridgeDirection(t);
|
||||
}
|
||||
return DiagDirToDiagTrackBits(GetTunnelBridgeDirection(t));
|
||||
|
@ -326,7 +326,7 @@ static void DrawRailCatenaryRailway(const TileInfo *ti)
|
|||
/* Here's one of the main headaches. GetTileSlope does not correct for possibly
|
||||
* existing foundataions, so we do have to do that manually later on.*/
|
||||
tileh[TS_NEIGHBOUR] = GetTileSlope(neighbour);
|
||||
trackconfig[TS_NEIGHBOUR] = GetRailTrackBitsUniversal(neighbour, NULL);
|
||||
trackconfig[TS_NEIGHBOUR] = GetRailTrackBitsUniversal(neighbour, nullptr);
|
||||
wireconfig[TS_NEIGHBOUR] = MaskWireBits(neighbour, trackconfig[TS_NEIGHBOUR]);
|
||||
if (IsTunnelTile(neighbour) && i != GetTunnelBridgeDirection(neighbour)) wireconfig[TS_NEIGHBOUR] = trackconfig[TS_NEIGHBOUR] = TRACK_BIT_NONE;
|
||||
|
||||
|
|
|
@ -69,9 +69,9 @@ assert_compile(lengthof(_orig_rail_vehicle_info) + lengthof(_orig_road_vehicle_i
|
|||
const uint EngineOverrideManager::NUM_DEFAULT_ENGINES = _engine_counts[VEH_TRAIN] + _engine_counts[VEH_ROAD] + _engine_counts[VEH_SHIP] + _engine_counts[VEH_AIRCRAFT];
|
||||
|
||||
Engine::Engine() :
|
||||
name(NULL),
|
||||
name(nullptr),
|
||||
overrides_count(0),
|
||||
overrides(NULL)
|
||||
overrides(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ bool Engine::IsEnabled() const
|
|||
uint32 Engine::GetGRFID() const
|
||||
{
|
||||
const GRFFile *file = this->GetGRF();
|
||||
return file == NULL ? 0 : file->grfid;
|
||||
return file == nullptr ? 0 : file->grfid;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -199,28 +199,28 @@ bool Engine::CanCarryCargo() const
|
|||
/**
|
||||
* Determines capacity of a given vehicle from scratch.
|
||||
* For aircraft the main capacity is determined. Mail might be present as well.
|
||||
* @param v Vehicle of interest; NULL in purchase list
|
||||
* @param v Vehicle of interest; nullptr in purchase list
|
||||
* @param mail_capacity returns secondary cargo (mail) capacity of aircraft
|
||||
* @return Capacity
|
||||
*/
|
||||
uint Engine::DetermineCapacity(const Vehicle *v, uint16 *mail_capacity) const
|
||||
{
|
||||
assert(v == NULL || this->index == v->engine_type);
|
||||
if (mail_capacity != NULL) *mail_capacity = 0;
|
||||
assert(v == nullptr || this->index == v->engine_type);
|
||||
if (mail_capacity != nullptr) *mail_capacity = 0;
|
||||
|
||||
if (!this->CanCarryCargo()) return 0;
|
||||
|
||||
bool new_multipliers = HasBit(this->info.misc_flags, EF_NO_DEFAULT_CARGO_MULTIPLIER);
|
||||
CargoID default_cargo = this->GetDefaultCargoType();
|
||||
CargoID cargo_type = (v != NULL) ? v->cargo_type : default_cargo;
|
||||
CargoID cargo_type = (v != nullptr) ? v->cargo_type : default_cargo;
|
||||
|
||||
if (mail_capacity != NULL && this->type == VEH_AIRCRAFT && IsCargoInClass(cargo_type, CC_PASSENGERS)) {
|
||||
if (mail_capacity != nullptr && this->type == VEH_AIRCRAFT && IsCargoInClass(cargo_type, CC_PASSENGERS)) {
|
||||
*mail_capacity = GetEngineProperty(this->index, PROP_AIRCRAFT_MAIL_CAPACITY, this->u.air.mail_capacity, v);
|
||||
}
|
||||
|
||||
/* Check the refit capacity callback if we are not in the default configuration, or if we are using the new multiplier algorithm. */
|
||||
if (HasBit(this->info.callback_mask, CBM_VEHICLE_REFIT_CAPACITY) &&
|
||||
(new_multipliers || default_cargo != cargo_type || (v != NULL && v->cargo_subtype != 0))) {
|
||||
(new_multipliers || default_cargo != cargo_type || (v != nullptr && v->cargo_subtype != 0))) {
|
||||
uint16 callback = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, this->index, v);
|
||||
if (callback != CALLBACK_FAILED) return callback;
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ uint Engine::DetermineCapacity(const Vehicle *v, uint16 *mail_capacity) const
|
|||
capacity = GetEngineProperty(this->index, PROP_TRAIN_CARGO_CAPACITY, this->u.rail.capacity, v);
|
||||
|
||||
/* In purchase list add the capacity of the second head. Always use the plain property for this. */
|
||||
if (v == NULL && this->u.rail.railveh_type == RAILVEH_MULTIHEAD) capacity += this->u.rail.capacity;
|
||||
if (v == nullptr && this->u.rail.railveh_type == RAILVEH_MULTIHEAD) capacity += this->u.rail.capacity;
|
||||
break;
|
||||
|
||||
case VEH_ROAD:
|
||||
|
@ -869,7 +869,7 @@ void ClearEnginesHiddenFlagOfCompany(CompanyID cid)
|
|||
CommandCost CmdSetVehicleVisibility(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
Engine *e = Engine::GetIfValid(GB(p2, 0, 31));
|
||||
if (e == NULL || _current_company >= MAX_COMPANIES) return CMD_ERROR;
|
||||
if (e == nullptr || _current_company >= MAX_COMPANIES) return CMD_ERROR;
|
||||
if (!IsEngineBuildable(e->index, e->type, _current_company)) return CMD_ERROR;
|
||||
|
||||
if ((flags & DC_EXEC) != 0) {
|
||||
|
@ -893,7 +893,7 @@ CommandCost CmdSetVehicleVisibility(TileIndex tile, DoCommandFlag flags, uint32
|
|||
CommandCost CmdWantEnginePreview(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
Engine *e = Engine::GetIfValid(p1);
|
||||
if (e == NULL || !(e->flags & ENGINE_EXCLUSIVE_PREVIEW) || e->preview_company != _current_company) return CMD_ERROR;
|
||||
if (e == nullptr || !(e->flags & ENGINE_EXCLUSIVE_PREVIEW) || e->preview_company != _current_company) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) AcceptEnginePreview(p1, _current_company);
|
||||
|
||||
|
@ -1021,7 +1021,7 @@ static bool IsUniqueEngineName(const char *name)
|
|||
const Engine *e;
|
||||
|
||||
FOR_ALL_ENGINES(e) {
|
||||
if (e->name != NULL && strcmp(e->name, name) == 0) return false;
|
||||
if (e->name != nullptr && strcmp(e->name, name) == 0) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1039,7 +1039,7 @@ static bool IsUniqueEngineName(const char *name)
|
|||
CommandCost CmdRenameEngine(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
Engine *e = Engine::GetIfValid(p1);
|
||||
if (e == NULL) return CMD_ERROR;
|
||||
if (e == nullptr) return CMD_ERROR;
|
||||
|
||||
bool reset = StrEmpty(text);
|
||||
|
||||
|
@ -1052,7 +1052,7 @@ CommandCost CmdRenameEngine(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
|||
free(e->name);
|
||||
|
||||
if (reset) {
|
||||
e->name = NULL;
|
||||
e->name = nullptr;
|
||||
} else {
|
||||
e->name = stredup(text);
|
||||
}
|
||||
|
@ -1077,7 +1077,7 @@ bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company)
|
|||
const Engine *e = Engine::GetIfValid(engine);
|
||||
|
||||
/* check if it's an engine that is in the engine array */
|
||||
if (e == NULL) return false;
|
||||
if (e == nullptr) return false;
|
||||
|
||||
/* check if it's an engine of specified type */
|
||||
if (e->type != type) return false;
|
||||
|
@ -1113,7 +1113,7 @@ bool IsEngineRefittable(EngineID engine)
|
|||
const Engine *e = Engine::GetIfValid(engine);
|
||||
|
||||
/* check if it's an engine that is in the engine array */
|
||||
if (e == NULL) return false;
|
||||
if (e == nullptr) return false;
|
||||
|
||||
if (!e->CanCarryCargo()) return false;
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
|
|||
return this->info.cargo_type;
|
||||
}
|
||||
|
||||
uint DetermineCapacity(const Vehicle *v, uint16 *mail_capacity = NULL) const;
|
||||
uint DetermineCapacity(const Vehicle *v, uint16 *mail_capacity = nullptr) const;
|
||||
|
||||
bool CanCarryCargo() const;
|
||||
|
||||
|
@ -98,9 +98,9 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> {
|
|||
* @return The default capacity
|
||||
* @see GetDefaultCargoType
|
||||
*/
|
||||
uint GetDisplayDefaultCapacity(uint16 *mail_capacity = NULL) const
|
||||
uint GetDisplayDefaultCapacity(uint16 *mail_capacity = nullptr) const
|
||||
{
|
||||
return this->DetermineCapacity(NULL, mail_capacity);
|
||||
return this->DetermineCapacity(nullptr, mail_capacity);
|
||||
}
|
||||
|
||||
Money GetRunningCost() const;
|
||||
|
|
|
@ -43,7 +43,7 @@ protected:
|
|||
public:
|
||||
ErrorMessageData(const ErrorMessageData &data);
|
||||
~ErrorMessageData();
|
||||
ErrorMessageData(StringID summary_msg, StringID detailed_msg, uint duration = 0, int x = 0, int y = 0, const GRFFile *textref_stack_grffile = NULL, uint textref_stack_size = 0, const uint32 *textref_stack = NULL);
|
||||
ErrorMessageData(StringID summary_msg, StringID detailed_msg, uint duration = 0, int x = 0, int y = 0, const GRFFile *textref_stack_grffile = nullptr, uint textref_stack_size = 0, const uint32 *textref_stack = nullptr);
|
||||
|
||||
/** Check whether error window shall display a company manager face */
|
||||
bool HasFace() const { return face != INVALID_COMPANY; }
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
|
||||
void ScheduleErrorMessage(const ErrorMessageData &data);
|
||||
|
||||
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x = 0, int y = 0, const GRFFile *textref_stack_grffile = NULL, uint textref_stack_size = 0, const uint32 *textref_stack = NULL);
|
||||
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x = 0, int y = 0, const GRFFile *textref_stack_grffile = nullptr, uint textref_stack_size = 0, const uint32 *textref_stack = nullptr);
|
||||
void ClearErrorMessages();
|
||||
void ShowFirstError();
|
||||
void UnshowCriticalError();
|
||||
|
|
|
@ -76,7 +76,7 @@ ErrorMessageData::ErrorMessageData(const ErrorMessageData &data)
|
|||
{
|
||||
*this = data;
|
||||
for (size_t i = 0; i < lengthof(this->strings); i++) {
|
||||
if (this->strings[i] != NULL) {
|
||||
if (this->strings[i] != nullptr) {
|
||||
this->strings[i] = stredup(this->strings[i]);
|
||||
this->decode_params[i] = (size_t)this->strings[i];
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ void ShowFirstError()
|
|||
void UnshowCriticalError()
|
||||
{
|
||||
ErrmsgWindow *w = (ErrmsgWindow*)FindWindowById(WC_ERRMSG, 0);
|
||||
if (_window_system_initialized && w != NULL) {
|
||||
if (_window_system_initialized && w != nullptr) {
|
||||
if (w->IsCritical()) _error_list.push_front(*w);
|
||||
_window_system_initialized = false;
|
||||
delete w;
|
||||
|
@ -377,7 +377,7 @@ void UnshowCriticalError()
|
|||
*/
|
||||
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x, int y, const GRFFile *textref_stack_grffile, uint textref_stack_size, const uint32 *textref_stack)
|
||||
{
|
||||
assert(textref_stack_size == 0 || (textref_stack_grffile != NULL && textref_stack != NULL));
|
||||
assert(textref_stack_size == 0 || (textref_stack_grffile != nullptr && textref_stack != nullptr));
|
||||
if (summary_msg == STR_NULL) summary_msg = STR_EMPTY;
|
||||
|
||||
if (wl != WL_INFO) {
|
||||
|
@ -408,7 +408,7 @@ void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel
|
|||
data.CopyOutDParams();
|
||||
|
||||
ErrmsgWindow *w = (ErrmsgWindow*)FindWindowById(WC_ERRMSG, 0);
|
||||
if (w != NULL && w->IsCritical()) {
|
||||
if (w != nullptr && w->IsCritical()) {
|
||||
/* A critical error is currently shown. */
|
||||
if (wl == WL_CRITICAL) {
|
||||
/* Push another critical error in the queue of errors,
|
||||
|
|
152
src/fileio.cpp
152
src/fileio.cpp
|
@ -99,7 +99,7 @@ void FioSeekTo(size_t pos, int mode)
|
|||
static void FioRestoreFile(int slot)
|
||||
{
|
||||
/* Do we still have the file open, or should we reopen it? */
|
||||
if (_fio.handles[slot] == NULL) {
|
||||
if (_fio.handles[slot] == nullptr) {
|
||||
DEBUG(misc, 6, "Restoring file '%s' in slot '%d' from disk", _fio.filenames[slot], slot);
|
||||
FioOpenFile(slot, _fio.filenames[slot]);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ void FioSeekToFile(uint8 slot, size_t pos)
|
|||
FioRestoreFile(slot);
|
||||
#endif /* LIMITED_FDS */
|
||||
f = _fio.handles[slot];
|
||||
assert(f != NULL);
|
||||
assert(f != nullptr);
|
||||
_fio.cur_fh = f;
|
||||
_fio.filename = _fio.filenames[slot];
|
||||
FioSeekTo(pos, SEEK_SET);
|
||||
|
@ -196,13 +196,13 @@ void FioReadBlock(void *ptr, size_t size)
|
|||
*/
|
||||
static inline void FioCloseFile(int slot)
|
||||
{
|
||||
if (_fio.handles[slot] != NULL) {
|
||||
if (_fio.handles[slot] != nullptr) {
|
||||
fclose(_fio.handles[slot]);
|
||||
|
||||
free(_fio.shortnames[slot]);
|
||||
_fio.shortnames[slot] = NULL;
|
||||
_fio.shortnames[slot] = nullptr;
|
||||
|
||||
_fio.handles[slot] = NULL;
|
||||
_fio.handles[slot] = nullptr;
|
||||
#if defined(LIMITED_FDS)
|
||||
_fio.open_handles--;
|
||||
#endif /* LIMITED_FDS */
|
||||
|
@ -229,7 +229,7 @@ static void FioFreeHandle()
|
|||
slot = -1;
|
||||
/* Find the file that is used the least */
|
||||
for (i = 0; i < lengthof(_fio.handles); i++) {
|
||||
if (_fio.handles[i] != NULL && _fio.usage_count[i] < count) {
|
||||
if (_fio.handles[i] != nullptr && _fio.usage_count[i] < count) {
|
||||
count = _fio.usage_count[i];
|
||||
slot = i;
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ void FioOpenFile(int slot, const char *filename, Subdirectory subdir)
|
|||
FioFreeHandle();
|
||||
#endif /* LIMITED_FDS */
|
||||
f = FioFOpenFile(filename, "rb", subdir);
|
||||
if (f == NULL) usererror("Cannot open file '%s'", filename);
|
||||
if (f == nullptr) usererror("Cannot open file '%s'", filename);
|
||||
long pos = ftell(f);
|
||||
if (pos < 0) usererror("Cannot read file '%s'", filename);
|
||||
|
||||
|
@ -265,9 +265,9 @@ void FioOpenFile(int slot, const char *filename, Subdirectory subdir)
|
|||
|
||||
/* Store the filename without path and extension */
|
||||
const char *t = strrchr(filename, PATHSEPCHAR);
|
||||
_fio.shortnames[slot] = stredup(t == NULL ? filename : t);
|
||||
_fio.shortnames[slot] = stredup(t == nullptr ? filename : t);
|
||||
char *t2 = strrchr(_fio.shortnames[slot], '.');
|
||||
if (t2 != NULL) *t2 = '\0';
|
||||
if (t2 != nullptr) *t2 = '\0';
|
||||
strtolower(_fio.shortnames[slot]);
|
||||
|
||||
#if defined(LIMITED_FDS)
|
||||
|
@ -312,7 +312,7 @@ static TarLinkList _tar_linklist[NUM_SUBDIRS]; ///< List of directory links
|
|||
bool FioCheckFileExists(const char *filename, Subdirectory subdir)
|
||||
{
|
||||
FILE *f = FioFOpenFile(filename, "rb", subdir);
|
||||
if (f == NULL) return false;
|
||||
if (f == nullptr) return false;
|
||||
|
||||
FioFCloseFile(f);
|
||||
return true;
|
||||
|
@ -351,7 +351,7 @@ char *FioGetFullPath(char *buf, const char *last, Searchpath sp, Subdirectory su
|
|||
* @param last End of the destination buffer.
|
||||
* @param subdir Subdirectory to try.
|
||||
* @param filename Filename to look for.
|
||||
* @return \a buf containing the path if the path was found, else \c NULL.
|
||||
* @return \a buf containing the path if the path was found, else \c nullptr.
|
||||
*/
|
||||
char *FioFindFullPath(char *buf, const char *last, Subdirectory subdir, const char *filename)
|
||||
{
|
||||
|
@ -369,7 +369,7 @@ char *FioFindFullPath(char *buf, const char *last, Subdirectory subdir, const ch
|
|||
#endif
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char *FioAppendDirectory(char *buf, const char *last, Searchpath sp, Subdirectory subdir)
|
||||
|
@ -407,7 +407,7 @@ static FILE *FioFOpenFileSp(const char *filename, const char *mode, Searchpath s
|
|||
wchar_t Lmode[5];
|
||||
MultiByteToWideChar(CP_ACP, 0, mode, -1, Lmode, lengthof(Lmode));
|
||||
#endif
|
||||
FILE *f = NULL;
|
||||
FILE *f = nullptr;
|
||||
char buf[MAX_PATH];
|
||||
|
||||
if (subdir == NO_DIRECTORY) {
|
||||
|
@ -417,16 +417,16 @@ static FILE *FioFOpenFileSp(const char *filename, const char *mode, Searchpath s
|
|||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
if (mode[0] == 'r' && GetFileAttributes(OTTD2FS(buf)) == INVALID_FILE_ATTRIBUTES) return NULL;
|
||||
if (mode[0] == 'r' && GetFileAttributes(OTTD2FS(buf)) == INVALID_FILE_ATTRIBUTES) return nullptr;
|
||||
#endif
|
||||
|
||||
f = fopen(buf, mode);
|
||||
#if !defined(_WIN32)
|
||||
if (f == NULL && strtolower(buf + ((subdir == NO_DIRECTORY) ? 0 : strlen(_searchpaths[sp]) - 1))) {
|
||||
if (f == nullptr && strtolower(buf + ((subdir == NO_DIRECTORY) ? 0 : strlen(_searchpaths[sp]) - 1))) {
|
||||
f = fopen(buf, mode);
|
||||
}
|
||||
#endif
|
||||
if (f != NULL && filesize != NULL) {
|
||||
if (f != nullptr && filesize != nullptr) {
|
||||
/* Find the size of the file */
|
||||
fseek(f, 0, SEEK_END);
|
||||
*filesize = ftell(f);
|
||||
|
@ -438,21 +438,21 @@ static FILE *FioFOpenFileSp(const char *filename, const char *mode, Searchpath s
|
|||
/**
|
||||
* Opens a file from inside a tar archive.
|
||||
* @param entry The entry to open.
|
||||
* @param[out] filesize If not \c NULL, size of the opened file.
|
||||
* @return File handle of the opened file, or \c NULL if the file is not available.
|
||||
* @param[out] filesize If not \c nullptr, size of the opened file.
|
||||
* @return File handle of the opened file, or \c nullptr if the file is not available.
|
||||
* @note The file is read from within the tar file, and may not return \c EOF after reading the whole file.
|
||||
*/
|
||||
FILE *FioFOpenFileTar(TarFileListEntry *entry, size_t *filesize)
|
||||
{
|
||||
FILE *f = fopen(entry->tar_filename, "rb");
|
||||
if (f == NULL) return f;
|
||||
if (f == nullptr) return f;
|
||||
|
||||
if (fseek(f, entry->position, SEEK_SET) < 0) {
|
||||
fclose(f);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (filesize != NULL) *filesize = entry->size;
|
||||
if (filesize != nullptr) *filesize = entry->size;
|
||||
return f;
|
||||
}
|
||||
|
||||
|
@ -460,22 +460,22 @@ FILE *FioFOpenFileTar(TarFileListEntry *entry, size_t *filesize)
|
|||
* Opens a OpenTTD file somewhere in a personal or global directory.
|
||||
* @param filename Name of the file to open.
|
||||
* @param subdir Subdirectory to open.
|
||||
* @return File handle of the opened file, or \c NULL if the file is not available.
|
||||
* @return File handle of the opened file, or \c nullptr if the file is not available.
|
||||
*/
|
||||
FILE *FioFOpenFile(const char *filename, const char *mode, Subdirectory subdir, size_t *filesize)
|
||||
{
|
||||
FILE *f = NULL;
|
||||
FILE *f = nullptr;
|
||||
Searchpath sp;
|
||||
|
||||
assert(subdir < NUM_SUBDIRS || subdir == NO_DIRECTORY);
|
||||
|
||||
FOR_ALL_SEARCHPATHS(sp) {
|
||||
f = FioFOpenFileSp(filename, mode, sp, subdir, filesize);
|
||||
if (f != NULL || subdir == NO_DIRECTORY) break;
|
||||
if (f != nullptr || subdir == NO_DIRECTORY) break;
|
||||
}
|
||||
|
||||
/* We can only use .tar in case of data-dir, and read-mode */
|
||||
if (f == NULL && mode[0] == 'r' && subdir != NO_DIRECTORY) {
|
||||
if (f == nullptr && mode[0] == 'r' && subdir != NO_DIRECTORY) {
|
||||
static const uint MAX_RESOLVED_LENGTH = 2 * (100 + 100 + 155) + 1; // Enough space to hold two filenames plus link. See 'TarHeader'.
|
||||
char resolved_name[MAX_RESOLVED_LENGTH];
|
||||
|
||||
|
@ -508,11 +508,11 @@ FILE *FioFOpenFile(const char *filename, const char *mode, Subdirectory subdir,
|
|||
|
||||
/* Sometimes a full path is given. To support
|
||||
* the 'subdirectory' must be 'removed'. */
|
||||
if (f == NULL && subdir != NO_DIRECTORY) {
|
||||
if (f == nullptr && subdir != NO_DIRECTORY) {
|
||||
switch (subdir) {
|
||||
case BASESET_DIR:
|
||||
f = FioFOpenFile(filename, mode, OLD_GM_DIR, filesize);
|
||||
if (f != NULL) break;
|
||||
if (f != nullptr) break;
|
||||
FALLTHROUGH;
|
||||
case NEWGRF_DIR:
|
||||
f = FioFOpenFile(filename, mode, OLD_DATA_DIR, filesize);
|
||||
|
@ -536,7 +536,7 @@ void FioCreateDirectory(const char *name)
|
|||
/* Ignore directory creation errors; they'll surface later on, and most
|
||||
* of the time they are 'directory already exists' errors anyhow. */
|
||||
#if defined(_WIN32)
|
||||
CreateDirectory(OTTD2FS(name), NULL);
|
||||
CreateDirectory(OTTD2FS(name), nullptr);
|
||||
#elif defined(OS2) && !defined(__INNOTEK_LIBC__)
|
||||
mkdir(OTTD2FS(name));
|
||||
#else
|
||||
|
@ -573,7 +573,7 @@ bool AppendPathSeparator(char *buf, const char *last)
|
|||
const char *FioTarFirstDir(const char *tarname, Subdirectory subdir)
|
||||
{
|
||||
TarList::iterator it = _tar_list[subdir].find(tarname);
|
||||
if (it == _tar_list[subdir].end()) return NULL;
|
||||
if (it == _tar_list[subdir].end()) return nullptr;
|
||||
return (*it).second.dirname;
|
||||
}
|
||||
|
||||
|
@ -675,7 +675,7 @@ bool TarScanner::AddFile(Subdirectory sd, const char *filename)
|
|||
bool TarScanner::AddFile(const char *filename, size_t basepath_length, const char *tar_filename)
|
||||
{
|
||||
/* No tar within tar. */
|
||||
assert(tar_filename == NULL);
|
||||
assert(tar_filename == nullptr);
|
||||
|
||||
/* The TAR-header, repeated for every file */
|
||||
struct TarHeader {
|
||||
|
@ -708,11 +708,11 @@ bool TarScanner::AddFile(const char *filename, size_t basepath_length, const cha
|
|||
* a number of reasons we cannot open the file.
|
||||
* Most common case is when we simply have not
|
||||
* been given read access. */
|
||||
if (f == NULL) return false;
|
||||
if (f == nullptr) return false;
|
||||
|
||||
const char *dupped_filename = stredup(filename);
|
||||
_tar_list[this->subdir][filename].filename = dupped_filename;
|
||||
_tar_list[this->subdir][filename].dirname = NULL;
|
||||
_tar_list[this->subdir][filename].dirname = nullptr;
|
||||
|
||||
TarLinkList links; ///< Temporary list to collect links
|
||||
|
||||
|
@ -801,13 +801,13 @@ bool TarScanner::AddFile(const char *filename, size_t basepath_length, const cha
|
|||
* Note: The destination of links must not contain any directory-links. */
|
||||
strecpy(dest, name, lastof(dest));
|
||||
char *destpos = strrchr(dest, PATHSEPCHAR);
|
||||
if (destpos == NULL) destpos = dest;
|
||||
if (destpos == nullptr) destpos = dest;
|
||||
*destpos = '\0';
|
||||
|
||||
char *pos = link;
|
||||
while (*pos != '\0') {
|
||||
char *next = strchr(pos, PATHSEPCHAR);
|
||||
if (next == NULL) {
|
||||
if (next == nullptr) {
|
||||
next = pos + strlen(pos);
|
||||
} else {
|
||||
/* Terminate the substring up to the path separator character. */
|
||||
|
@ -826,7 +826,7 @@ bool TarScanner::AddFile(const char *filename, size_t basepath_length, const cha
|
|||
/* Truncate 'dest' after last PATHSEPCHAR.
|
||||
* This assumes that the truncated part is a real directory and not a link. */
|
||||
destpos = strrchr(dest, PATHSEPCHAR);
|
||||
if (destpos == NULL) destpos = dest;
|
||||
if (destpos == nullptr) destpos = dest;
|
||||
*destpos = '\0';
|
||||
} else {
|
||||
/* Append at end of 'dest' */
|
||||
|
@ -856,7 +856,7 @@ bool TarScanner::AddFile(const char *filename, size_t basepath_length, const cha
|
|||
|
||||
/* Store the first directory name we detect */
|
||||
DEBUG(misc, 6, "Found dir in tar: %s", name);
|
||||
if (_tar_list[this->subdir][filename].dirname == NULL) _tar_list[this->subdir][filename].dirname = stredup(name);
|
||||
if (_tar_list[this->subdir][filename].dirname == nullptr) _tar_list[this->subdir][filename].dirname = stredup(name);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -911,13 +911,13 @@ bool ExtractTar(const char *tar_filename, Subdirectory subdir)
|
|||
const char *dirname = (*it).second.dirname;
|
||||
|
||||
/* The file doesn't have a sub directory! */
|
||||
if (dirname == NULL) return false;
|
||||
if (dirname == nullptr) return false;
|
||||
|
||||
char filename[MAX_PATH];
|
||||
strecpy(filename, tar_filename, lastof(filename));
|
||||
char *p = strrchr(filename, PATHSEPCHAR);
|
||||
/* The file's path does not have a separator? */
|
||||
if (p == NULL) return false;
|
||||
if (p == nullptr) return false;
|
||||
|
||||
p++;
|
||||
strecpy(p, dirname, lastof(filename));
|
||||
|
@ -934,14 +934,14 @@ bool ExtractTar(const char *tar_filename, Subdirectory subdir)
|
|||
/* First open the file in the .tar. */
|
||||
size_t to_copy = 0;
|
||||
FILE *in = FioFOpenFileTar(&(*it2).second, &to_copy);
|
||||
if (in == NULL) {
|
||||
if (in == nullptr) {
|
||||
DEBUG(misc, 6, "Extracting %s failed; could not open %s", filename, tar_filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Now open the 'output' file. */
|
||||
FILE *out = fopen(filename, "wb");
|
||||
if (out == NULL) {
|
||||
if (out == nullptr) {
|
||||
DEBUG(misc, 6, "Extracting %s failed; could not open %s", filename, filename);
|
||||
fclose(in);
|
||||
return false;
|
||||
|
@ -993,12 +993,12 @@ static bool ChangeWorkingDirectoryToExecutable(const char *exe)
|
|||
bool success = false;
|
||||
#ifdef WITH_COCOA
|
||||
char *app_bundle = strchr(tmp, '.');
|
||||
while (app_bundle != NULL && strncasecmp(app_bundle, ".app", 4) != 0) app_bundle = strchr(&app_bundle[1], '.');
|
||||
while (app_bundle != nullptr && strncasecmp(app_bundle, ".app", 4) != 0) app_bundle = strchr(&app_bundle[1], '.');
|
||||
|
||||
if (app_bundle != NULL) *app_bundle = '\0';
|
||||
if (app_bundle != nullptr) *app_bundle = '\0';
|
||||
#endif /* WITH_COCOA */
|
||||
char *s = strrchr(tmp, PATHSEPCHAR);
|
||||
if (s != NULL) {
|
||||
if (s != nullptr) {
|
||||
*s = '\0';
|
||||
if (chdir(tmp) != 0) {
|
||||
DEBUG(misc, 0, "Directory with the binary does not exist?");
|
||||
|
@ -1022,13 +1022,13 @@ static bool ChangeWorkingDirectoryToExecutable(const char *exe)
|
|||
bool DoScanWorkingDirectory()
|
||||
{
|
||||
/* No working directory, so nothing to do. */
|
||||
if (_searchpaths[SP_WORKING_DIR] == NULL) return false;
|
||||
if (_searchpaths[SP_WORKING_DIR] == nullptr) return false;
|
||||
|
||||
/* Working directory is root, so do nothing. */
|
||||
if (strcmp(_searchpaths[SP_WORKING_DIR], PATHSEP) == 0) return false;
|
||||
|
||||
/* No personal/home directory, so the working directory won't be that. */
|
||||
if (_searchpaths[SP_PERSONAL_DIR] == NULL) return true;
|
||||
if (_searchpaths[SP_PERSONAL_DIR] == nullptr) return true;
|
||||
|
||||
char tmp[MAX_PATH];
|
||||
seprintf(tmp, lastof(tmp), "%s%s", _searchpaths[SP_WORKING_DIR], PERSONAL_DIR);
|
||||
|
@ -1044,7 +1044,7 @@ void DetermineBasePaths(const char *exe)
|
|||
{
|
||||
char tmp[MAX_PATH];
|
||||
#if defined(WITH_XDG_BASEDIR) && defined(WITH_PERSONAL_DIR)
|
||||
const char *xdg_data_home = xdgDataHome(NULL);
|
||||
const char *xdg_data_home = xdgDataHome(nullptr);
|
||||
seprintf(tmp, lastof(tmp), "%s" PATHSEP "%s", xdg_data_home,
|
||||
PERSONAL_DIR[0] == '.' ? &PERSONAL_DIR[1] : PERSONAL_DIR);
|
||||
free(xdg_data_home);
|
||||
|
@ -1053,7 +1053,7 @@ void DetermineBasePaths(const char *exe)
|
|||
_searchpaths[SP_PERSONAL_DIR_XDG] = stredup(tmp);
|
||||
#endif
|
||||
#if defined(OS2) || !defined(WITH_PERSONAL_DIR)
|
||||
_searchpaths[SP_PERSONAL_DIR] = NULL;
|
||||
_searchpaths[SP_PERSONAL_DIR] = nullptr;
|
||||
#else
|
||||
#ifdef __HAIKU__
|
||||
BPath path;
|
||||
|
@ -1065,17 +1065,17 @@ void DetermineBasePaths(const char *exe)
|
|||
* variables in any way. It can also contain all kinds of
|
||||
* unvalidated data we rather not want internally. */
|
||||
const char *homedir = getenv("HOME");
|
||||
if (homedir != NULL) {
|
||||
if (homedir != nullptr) {
|
||||
homedir = stredup(homedir);
|
||||
}
|
||||
|
||||
if (homedir == NULL) {
|
||||
if (homedir == nullptr) {
|
||||
const struct passwd *pw = getpwuid(getuid());
|
||||
homedir = (pw == NULL) ? NULL : stredup(pw->pw_dir);
|
||||
homedir = (pw == nullptr) ? nullptr : stredup(pw->pw_dir);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (homedir != NULL) {
|
||||
if (homedir != nullptr) {
|
||||
ValidateString(homedir);
|
||||
seprintf(tmp, lastof(tmp), "%s" PATHSEP "%s", homedir, PERSONAL_DIR);
|
||||
AppendPathSeparator(tmp, lastof(tmp));
|
||||
|
@ -1083,7 +1083,7 @@ void DetermineBasePaths(const char *exe)
|
|||
_searchpaths[SP_PERSONAL_DIR] = stredup(tmp);
|
||||
free(homedir);
|
||||
} else {
|
||||
_searchpaths[SP_PERSONAL_DIR] = NULL;
|
||||
_searchpaths[SP_PERSONAL_DIR] = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1092,10 +1092,10 @@ void DetermineBasePaths(const char *exe)
|
|||
AppendPathSeparator(tmp, lastof(tmp));
|
||||
_searchpaths[SP_SHARED_DIR] = stredup(tmp);
|
||||
#else
|
||||
_searchpaths[SP_SHARED_DIR] = NULL;
|
||||
_searchpaths[SP_SHARED_DIR] = nullptr;
|
||||
#endif
|
||||
|
||||
if (getcwd(tmp, MAX_PATH) == NULL) *tmp = '\0';
|
||||
if (getcwd(tmp, MAX_PATH) == nullptr) *tmp = '\0';
|
||||
AppendPathSeparator(tmp, lastof(tmp));
|
||||
_searchpaths[SP_WORKING_DIR] = stredup(tmp);
|
||||
|
||||
|
@ -1103,14 +1103,14 @@ void DetermineBasePaths(const char *exe)
|
|||
|
||||
/* Change the working directory to that one of the executable */
|
||||
if (ChangeWorkingDirectoryToExecutable(exe)) {
|
||||
if (getcwd(tmp, MAX_PATH) == NULL) *tmp = '\0';
|
||||
if (getcwd(tmp, MAX_PATH) == nullptr) *tmp = '\0';
|
||||
AppendPathSeparator(tmp, lastof(tmp));
|
||||
_searchpaths[SP_BINARY_DIR] = stredup(tmp);
|
||||
} else {
|
||||
_searchpaths[SP_BINARY_DIR] = NULL;
|
||||
_searchpaths[SP_BINARY_DIR] = nullptr;
|
||||
}
|
||||
|
||||
if (_searchpaths[SP_WORKING_DIR] != NULL) {
|
||||
if (_searchpaths[SP_WORKING_DIR] != nullptr) {
|
||||
/* Go back to the current working directory. */
|
||||
if (chdir(_searchpaths[SP_WORKING_DIR]) != 0) {
|
||||
DEBUG(misc, 0, "Failed to return to working directory!");
|
||||
|
@ -1118,7 +1118,7 @@ void DetermineBasePaths(const char *exe)
|
|||
}
|
||||
|
||||
#if !defined(GLOBAL_DATA_DIR)
|
||||
_searchpaths[SP_INSTALLATION_DIR] = NULL;
|
||||
_searchpaths[SP_INSTALLATION_DIR] = nullptr;
|
||||
#else
|
||||
seprintf(tmp, lastof(tmp), "%s", GLOBAL_DATA_DIR);
|
||||
AppendPathSeparator(tmp, lastof(tmp));
|
||||
|
@ -1128,7 +1128,7 @@ void DetermineBasePaths(const char *exe)
|
|||
extern void cocoaSetApplicationBundleDir();
|
||||
cocoaSetApplicationBundleDir();
|
||||
#else
|
||||
_searchpaths[SP_APPLICATION_BUNDLE_DIR] = NULL;
|
||||
_searchpaths[SP_APPLICATION_BUNDLE_DIR] = nullptr;
|
||||
#endif
|
||||
}
|
||||
#endif /* defined(_WIN32) */
|
||||
|
@ -1148,7 +1148,7 @@ void DeterminePaths(const char *exe)
|
|||
#if defined(WITH_XDG_BASEDIR) && defined(WITH_PERSONAL_DIR)
|
||||
char config_home[MAX_PATH];
|
||||
|
||||
const char *xdg_config_home = xdgConfigHome(NULL);
|
||||
const char *xdg_config_home = xdgConfigHome(nullptr);
|
||||
seprintf(config_home, lastof(config_home), "%s" PATHSEP "%s", xdg_config_home,
|
||||
PERSONAL_DIR[0] == '.' ? &PERSONAL_DIR[1] : PERSONAL_DIR);
|
||||
free(xdg_config_home);
|
||||
|
@ -1163,19 +1163,19 @@ void DeterminePaths(const char *exe)
|
|||
}
|
||||
|
||||
char *config_dir;
|
||||
if (_config_file != NULL) {
|
||||
if (_config_file != nullptr) {
|
||||
config_dir = stredup(_config_file);
|
||||
char *end = strrchr(config_dir, PATHSEPCHAR);
|
||||
if (end == NULL) {
|
||||
if (end == nullptr) {
|
||||
config_dir[0] = '\0';
|
||||
} else {
|
||||
end[1] = '\0';
|
||||
}
|
||||
} else {
|
||||
char personal_dir[MAX_PATH];
|
||||
if (FioFindFullPath(personal_dir, lastof(personal_dir), BASE_DIR, "openttd.cfg") != NULL) {
|
||||
if (FioFindFullPath(personal_dir, lastof(personal_dir), BASE_DIR, "openttd.cfg") != nullptr) {
|
||||
char *end = strrchr(personal_dir, PATHSEPCHAR);
|
||||
if (end != NULL) end[1] = '\0';
|
||||
if (end != nullptr) end[1] = '\0';
|
||||
config_dir = stredup(personal_dir);
|
||||
_config_file = str_fmt("%sopenttd.cfg", config_dir);
|
||||
} else {
|
||||
|
@ -1187,14 +1187,14 @@ void DeterminePaths(const char *exe)
|
|||
SP_PERSONAL_DIR, SP_BINARY_DIR, SP_WORKING_DIR, SP_SHARED_DIR, SP_INSTALLATION_DIR
|
||||
};
|
||||
|
||||
config_dir = NULL;
|
||||
config_dir = nullptr;
|
||||
for (uint i = 0; i < lengthof(new_openttd_cfg_order); i++) {
|
||||
if (IsValidSearchPath(new_openttd_cfg_order[i])) {
|
||||
config_dir = stredup(_searchpaths[new_openttd_cfg_order[i]]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert(config_dir != NULL);
|
||||
assert(config_dir != nullptr);
|
||||
#endif
|
||||
_config_file = str_fmt("%sopenttd.cfg", config_dir);
|
||||
}
|
||||
|
@ -1277,27 +1277,27 @@ void SanitizeFilename(char *filename)
|
|||
* @param filename Name of the file to load.
|
||||
* @param[out] lenp Length of loaded data.
|
||||
* @param maxsize Maximum size to load.
|
||||
* @return Pointer to new memory containing the loaded data, or \c NULL if loading failed.
|
||||
* @return Pointer to new memory containing the loaded data, or \c nullptr if loading failed.
|
||||
* @note If \a maxsize less than the length of the file, loading fails.
|
||||
*/
|
||||
void *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize)
|
||||
{
|
||||
FILE *in = fopen(filename, "rb");
|
||||
if (in == NULL) return NULL;
|
||||
if (in == nullptr) return nullptr;
|
||||
|
||||
fseek(in, 0, SEEK_END);
|
||||
size_t len = ftell(in);
|
||||
fseek(in, 0, SEEK_SET);
|
||||
if (len > maxsize) {
|
||||
fclose(in);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
byte *mem = MallocT<byte>(len + 1);
|
||||
mem[len] = 0;
|
||||
if (fread(mem, len, 1, in) != 1) {
|
||||
fclose(in);
|
||||
free(mem);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
fclose(in);
|
||||
|
||||
|
@ -1309,14 +1309,14 @@ void *ReadFileToMem(const char *filename, size_t *lenp, size_t maxsize)
|
|||
* Helper to see whether a given filename matches the extension.
|
||||
* @param extension The extension to look for.
|
||||
* @param filename The filename to look in for the extension.
|
||||
* @return True iff the extension is NULL, or the filename ends with it.
|
||||
* @return True iff the extension is nullptr, or the filename ends with it.
|
||||
*/
|
||||
static bool MatchesExtension(const char *extension, const char *filename)
|
||||
{
|
||||
if (extension == NULL) return true;
|
||||
if (extension == nullptr) return true;
|
||||
|
||||
const char *ext = strrchr(filename, extension[0]);
|
||||
return ext != NULL && strcasecmp(ext, extension) == 0;
|
||||
return ext != nullptr && strcasecmp(ext, extension) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1337,9 +1337,9 @@ static uint ScanPath(FileScanner *fs, const char *extension, const char *path, s
|
|||
struct dirent *dirent;
|
||||
DIR *dir;
|
||||
|
||||
if (path == NULL || (dir = ttd_opendir(path)) == NULL) return 0;
|
||||
if (path == nullptr || (dir = ttd_opendir(path)) == nullptr) return 0;
|
||||
|
||||
while ((dirent = readdir(dir)) != NULL) {
|
||||
while ((dirent = readdir(dir)) != nullptr) {
|
||||
const char *d_name = FS2OTTD(dirent->d_name);
|
||||
char filename[MAX_PATH];
|
||||
|
||||
|
@ -1355,7 +1355,7 @@ static uint ScanPath(FileScanner *fs, const char *extension, const char *path, s
|
|||
num += ScanPath(fs, extension, filename, basepath_length, recursive);
|
||||
} else if (S_ISREG(sb.st_mode)) {
|
||||
/* File */
|
||||
if (MatchesExtension(extension, filename) && fs->AddFile(filename, basepath_length, NULL)) num++;
|
||||
if (MatchesExtension(extension, filename) && fs->AddFile(filename, basepath_length, nullptr)) num++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ void FioSkipBytes(int n);
|
|||
/**
|
||||
* The search paths OpenTTD could search through.
|
||||
* At least one of the slots has to be filled with a path.
|
||||
* NULL paths tell that there is no such path for the
|
||||
* nullptr paths tell that there is no such path for the
|
||||
* current operating system.
|
||||
*/
|
||||
extern const char *_searchpaths[NUM_SEARCHPATHS];
|
||||
|
@ -42,14 +42,14 @@ extern const char *_searchpaths[NUM_SEARCHPATHS];
|
|||
*/
|
||||
static inline bool IsValidSearchPath(Searchpath sp)
|
||||
{
|
||||
return sp < NUM_SEARCHPATHS && _searchpaths[sp] != NULL;
|
||||
return sp < NUM_SEARCHPATHS && _searchpaths[sp] != nullptr;
|
||||
}
|
||||
|
||||
/** Iterator for all the search paths */
|
||||
#define FOR_ALL_SEARCHPATHS(sp) for (sp = SP_FIRST_DIR; sp < NUM_SEARCHPATHS; sp++) if (IsValidSearchPath(sp))
|
||||
|
||||
void FioFCloseFile(FILE *f);
|
||||
FILE *FioFOpenFile(const char *filename, const char *mode, Subdirectory subdir, size_t *filesize = NULL);
|
||||
FILE *FioFOpenFile(const char *filename, const char *mode, Subdirectory subdir, size_t *filesize = nullptr);
|
||||
bool FioCheckFileExists(const char *filename, Subdirectory subdir);
|
||||
char *FioGetFullPath(char *buf, const char *last, Searchpath sp, Subdirectory subdir, const char *filename);
|
||||
char *FioFindFullPath(char *buf, const char *last, Subdirectory subdir, const char *filename);
|
||||
|
@ -107,7 +107,7 @@ public:
|
|||
ALL = BASESET | NEWGRF | AI | SCENARIO | GAME, ///< Scan for everything.
|
||||
};
|
||||
|
||||
bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename = NULL) override;
|
||||
bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename = nullptr) override;
|
||||
|
||||
bool AddFile(Subdirectory sd, const char *filename);
|
||||
|
||||
|
|
74
src/fios.cpp
74
src/fios.cpp
|
@ -105,7 +105,7 @@ void FileList::BuildFileList(AbstractFileType abstract_filetype, SaveLoadOperati
|
|||
* Find file information of a file by its name from the file list.
|
||||
* @param file The filename to return information about. Can be the actual name
|
||||
* or a numbered entry into the filename list.
|
||||
* @return The information on the file, or \c NULL if the file is not available.
|
||||
* @return The information on the file, or \c nullptr if the file is not available.
|
||||
*/
|
||||
const FiosItem *FileList::FindItem(const char *file)
|
||||
{
|
||||
|
@ -130,14 +130,14 @@ const FiosItem *FileList::FindItem(const char *file)
|
|||
if (strcmp(long_file, item->title) == 0) return item;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get descriptive texts. Returns the path and free space
|
||||
* left on the device
|
||||
* @param path string describing the path
|
||||
* @param total_free total free space in megabytes, optional (can be NULL)
|
||||
* @param total_free total free space in megabytes, optional (can be nullptr)
|
||||
* @return StringID describing the path (free space or failure)
|
||||
*/
|
||||
StringID FiosGetDescText(const char **path, uint64 *total_free)
|
||||
|
@ -149,7 +149,7 @@ StringID FiosGetDescText(const char **path, uint64 *total_free)
|
|||
/**
|
||||
* Browse to a new path based on the passed \a item, starting at #_fios_path.
|
||||
* @param *item Item telling us what to do.
|
||||
* @return A filename w/path if we reached a file, otherwise \c NULL.
|
||||
* @return A filename w/path if we reached a file, otherwise \c nullptr.
|
||||
*/
|
||||
const char *FiosBrowseTo(const FiosItem *item)
|
||||
{
|
||||
|
@ -164,13 +164,13 @@ const char *FiosBrowseTo(const FiosItem *item)
|
|||
break;
|
||||
|
||||
case FIOS_TYPE_PARENT: {
|
||||
/* Check for possible NULL ptr */
|
||||
/* Check for possible nullptr ptr */
|
||||
char *s = strrchr(_fios_path, PATHSEPCHAR);
|
||||
if (s != NULL && s != _fios_path) {
|
||||
if (s != nullptr && s != _fios_path) {
|
||||
s[0] = '\0'; // Remove last path separator character, so we can go up one level.
|
||||
}
|
||||
s = strrchr(_fios_path, PATHSEPCHAR);
|
||||
if (s != NULL) {
|
||||
if (s != nullptr) {
|
||||
s[1] = '\0'; // go up a directory
|
||||
}
|
||||
break;
|
||||
|
@ -194,13 +194,13 @@ const char *FiosBrowseTo(const FiosItem *item)
|
|||
return item->name;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a filename from its components in destination buffer \a buf.
|
||||
* @param buf Destination buffer.
|
||||
* @param path Directory path, may be \c NULL.
|
||||
* @param path Directory path, may be \c nullptr.
|
||||
* @param name Filename.
|
||||
* @param ext Filename extension (use \c "" for no extension).
|
||||
* @param last Last element of buffer \a buf.
|
||||
|
@ -211,7 +211,7 @@ static void FiosMakeFilename(char *buf, const char *path, const char *name, cons
|
|||
|
||||
/* Don't append the extension if it is already there */
|
||||
period = strrchr(name, '.');
|
||||
if (period != NULL && strcasecmp(period, ext) == 0) ext = "";
|
||||
if (period != nullptr && strcasecmp(period, ext) == 0) ext = "";
|
||||
seprintf(buf, last, "%s" PATHSEP "%s%s", path, name, ext);
|
||||
}
|
||||
|
||||
|
@ -288,7 +288,7 @@ public:
|
|||
bool FiosFileScanner::AddFile(const char *filename, size_t basepath_length, const char *tar_filename)
|
||||
{
|
||||
const char *ext = strrchr(filename, '.');
|
||||
if (ext == NULL) return false;
|
||||
if (ext == nullptr) return false;
|
||||
|
||||
char fios_title[64];
|
||||
fios_title[0] = '\0'; // reset the title;
|
||||
|
@ -320,7 +320,7 @@ bool FiosFileScanner::AddFile(const char *filename, size_t basepath_length, cons
|
|||
const char *t = fios_title;
|
||||
if (StrEmpty(fios_title)) {
|
||||
t = strrchr(filename, PATHSEPCHAR);
|
||||
t = (t == NULL) ? filename : (t + 1);
|
||||
t = (t == nullptr) ? filename : (t + 1);
|
||||
}
|
||||
strecpy(fios->title, t, lastof(fios->title));
|
||||
str_validate(fios->title, lastof(fios->title));
|
||||
|
@ -357,8 +357,8 @@ static void FiosGetFileList(SaveLoadOperation fop, fios_getlist_callback_proc *c
|
|||
}
|
||||
|
||||
/* Show subdirectories */
|
||||
if ((dir = ttd_opendir(_fios_path)) != NULL) {
|
||||
while ((dirent = readdir(dir)) != NULL) {
|
||||
if ((dir = ttd_opendir(_fios_path)) != nullptr) {
|
||||
while ((dirent = readdir(dir)) != nullptr) {
|
||||
strecpy(d_name, FS2OTTD(dirent->d_name), lastof(d_name));
|
||||
|
||||
/* found file must be directory, but not '.' or '..' */
|
||||
|
@ -390,9 +390,9 @@ static void FiosGetFileList(SaveLoadOperation fop, fios_getlist_callback_proc *c
|
|||
/* Show files */
|
||||
FiosFileScanner scanner(fop, callback_proc, file_list);
|
||||
if (subdir == NO_DIRECTORY) {
|
||||
scanner.Scan(NULL, _fios_path, false);
|
||||
scanner.Scan(nullptr, _fios_path, false);
|
||||
} else {
|
||||
scanner.Scan(NULL, subdir, true, true);
|
||||
scanner.Scan(nullptr, subdir, true, true);
|
||||
}
|
||||
|
||||
QSortT(file_list.Get(sort_start), file_list.Length() - sort_start, CompareFiosItems);
|
||||
|
@ -418,7 +418,7 @@ static void GetFileTitle(const char *file, char *title, const char *last, Subdir
|
|||
strecat(buf, ".title", lastof(buf));
|
||||
|
||||
FILE *f = FioFOpenFile(buf, "r", subdir);
|
||||
if (f == NULL) return;
|
||||
if (f == nullptr) return;
|
||||
|
||||
size_t read = fread(title, 1, last - title, f);
|
||||
assert(title + read <= last);
|
||||
|
@ -432,8 +432,8 @@ static void GetFileTitle(const char *file, char *title, const char *last, Subdir
|
|||
* @param fop Purpose of collecting the list.
|
||||
* @param file Name of the file to check.
|
||||
* @param ext A pointer to the extension identifier inside file
|
||||
* @param title Buffer if a callback wants to lookup the title of the file; NULL to skip the lookup
|
||||
* @param last Last available byte in buffer (to prevent buffer overflows); not used when title == NULL
|
||||
* @param title Buffer if a callback wants to lookup the title of the file; nullptr to skip the lookup
|
||||
* @param last Last available byte in buffer (to prevent buffer overflows); not used when title == nullptr
|
||||
* @return a FIOS_TYPE_* type of the found file, FIOS_TYPE_INVALID if not a savegame
|
||||
* @see FiosGetFileList
|
||||
* @see FiosGetSavegameList
|
||||
|
@ -447,7 +447,7 @@ FiosType FiosGetSavegameListCallback(SaveLoadOperation fop, const char *file, co
|
|||
* .SV2 Transport Tycoon Deluxe (Patch) saved 2-player game */
|
||||
|
||||
/* Don't crash if we supply no extension */
|
||||
if (ext == NULL) return FIOS_TYPE_INVALID;
|
||||
if (ext == nullptr) return FIOS_TYPE_INVALID;
|
||||
|
||||
if (strcasecmp(ext, ".sav") == 0) {
|
||||
GetFileTitle(file, title, last, SAVE_DIR);
|
||||
|
@ -457,7 +457,7 @@ FiosType FiosGetSavegameListCallback(SaveLoadOperation fop, const char *file, co
|
|||
if (fop == SLO_LOAD) {
|
||||
if (strcasecmp(ext, ".ss1") == 0 || strcasecmp(ext, ".sv1") == 0 ||
|
||||
strcasecmp(ext, ".sv2") == 0) {
|
||||
if (title != NULL) GetOldSaveGameName(file, title, last);
|
||||
if (title != nullptr) GetOldSaveGameName(file, title, last);
|
||||
return FIOS_TYPE_OLDFILE;
|
||||
}
|
||||
}
|
||||
|
@ -473,10 +473,10 @@ FiosType FiosGetSavegameListCallback(SaveLoadOperation fop, const char *file, co
|
|||
*/
|
||||
void FiosGetSavegameList(SaveLoadOperation fop, FileList &file_list)
|
||||
{
|
||||
static char *fios_save_path = NULL;
|
||||
static char *fios_save_path_last = NULL;
|
||||
static char *fios_save_path = nullptr;
|
||||
static char *fios_save_path_last = nullptr;
|
||||
|
||||
if (fios_save_path == NULL) {
|
||||
if (fios_save_path == nullptr) {
|
||||
fios_save_path = MallocT<char>(MAX_PATH);
|
||||
fios_save_path_last = fios_save_path + MAX_PATH - 1;
|
||||
FioGetDirectory(fios_save_path, fios_save_path_last, SAVE_DIR);
|
||||
|
@ -528,11 +528,11 @@ static FiosType FiosGetScenarioListCallback(SaveLoadOperation fop, const char *f
|
|||
*/
|
||||
void FiosGetScenarioList(SaveLoadOperation fop, FileList &file_list)
|
||||
{
|
||||
static char *fios_scn_path = NULL;
|
||||
static char *fios_scn_path_last = NULL;
|
||||
static char *fios_scn_path = nullptr;
|
||||
static char *fios_scn_path_last = nullptr;
|
||||
|
||||
/* Copy the default path on first run or on 'New Game' */
|
||||
if (fios_scn_path == NULL) {
|
||||
if (fios_scn_path == nullptr) {
|
||||
fios_scn_path = MallocT<char>(MAX_PATH);
|
||||
fios_scn_path_last = fios_scn_path + MAX_PATH - 1;
|
||||
FioGetDirectory(fios_scn_path, fios_scn_path_last, SCENARIO_DIR);
|
||||
|
@ -599,10 +599,10 @@ static FiosType FiosGetHeightmapListCallback(SaveLoadOperation fop, const char *
|
|||
*/
|
||||
void FiosGetHeightmapList(SaveLoadOperation fop, FileList &file_list)
|
||||
{
|
||||
static char *fios_hmap_path = NULL;
|
||||
static char *fios_hmap_path_last = NULL;
|
||||
static char *fios_hmap_path = nullptr;
|
||||
static char *fios_hmap_path_last = nullptr;
|
||||
|
||||
if (fios_hmap_path == NULL) {
|
||||
if (fios_hmap_path == nullptr) {
|
||||
fios_hmap_path = MallocT<char>(MAX_PATH);
|
||||
fios_hmap_path_last = fios_hmap_path + MAX_PATH - 1;
|
||||
FioGetDirectory(fios_hmap_path, fios_hmap_path_last, HEIGHTMAP_DIR);
|
||||
|
@ -624,9 +624,9 @@ void FiosGetHeightmapList(SaveLoadOperation fop, FileList &file_list)
|
|||
*/
|
||||
const char *FiosGetScreenshotDir()
|
||||
{
|
||||
static char *fios_screenshot_path = NULL;
|
||||
static char *fios_screenshot_path = nullptr;
|
||||
|
||||
if (fios_screenshot_path == NULL) {
|
||||
if (fios_screenshot_path == nullptr) {
|
||||
fios_screenshot_path = MallocT<char>(MAX_PATH);
|
||||
FioGetDirectory(fios_screenshot_path, fios_screenshot_path + MAX_PATH - 1, SCREENSHOT_DIR);
|
||||
}
|
||||
|
@ -676,7 +676,7 @@ public:
|
|||
bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename) override
|
||||
{
|
||||
FILE *f = FioFOpenFile(filename, "r", SCENARIO_DIR);
|
||||
if (f == NULL) return false;
|
||||
if (f == nullptr) return false;
|
||||
|
||||
ScenarioIdentifier id;
|
||||
int fret = fscanf(f, "%i", &id.scenid);
|
||||
|
@ -695,7 +695,7 @@ public:
|
|||
strecpy(basename, filename, lastof(basename));
|
||||
*strrchr(basename, '.') = '\0';
|
||||
f = FioFOpenFile(basename, "rb", SCENARIO_DIR, &size);
|
||||
if (f == NULL) return false;
|
||||
if (f == nullptr) return false;
|
||||
|
||||
/* calculate md5sum */
|
||||
while ((len = fread(buffer, 1, (size > sizeof(buffer)) ? sizeof(buffer) : size, f)) != 0 && size != 0) {
|
||||
|
@ -718,7 +718,7 @@ static ScenarioScanner _scanner;
|
|||
* Find a given scenario based on its unique ID.
|
||||
* @param ci The content info to compare it to.
|
||||
* @param md5sum Whether to look at the md5sum or the id.
|
||||
* @return The filename of the file, else \c NULL.
|
||||
* @return The filename of the file, else \c nullptr.
|
||||
*/
|
||||
const char *FindScenario(const ContentInfo *ci, bool md5sum)
|
||||
{
|
||||
|
@ -731,7 +731,7 @@ const char *FindScenario(const ContentInfo *ci, bool md5sum)
|
|||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -742,7 +742,7 @@ const char *FindScenario(const ContentInfo *ci, bool md5sum)
|
|||
*/
|
||||
bool HasScenario(const ContentInfo *ci, bool md5sum)
|
||||
{
|
||||
return (FindScenario(ci, md5sum) != NULL);
|
||||
return (FindScenario(ci, md5sum) != nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -48,8 +48,8 @@ struct LoadCheckData {
|
|||
struct LoggedAction *gamelog_action; ///< Gamelog actions
|
||||
uint gamelog_actions; ///< Number of gamelog actions
|
||||
|
||||
LoadCheckData() : error_data(NULL), grfconfig(NULL),
|
||||
grf_compatibility(GLC_NOT_FOUND), gamelog_action(NULL), gamelog_actions(0)
|
||||
LoadCheckData() : error_data(nullptr), grfconfig(nullptr),
|
||||
grf_compatibility(GLC_NOT_FOUND), gamelog_action(nullptr), gamelog_actions(0)
|
||||
{
|
||||
this->Clear();
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ struct LoadCheckData {
|
|||
*/
|
||||
bool HasNewGrfs()
|
||||
{
|
||||
return this->checkable && this->error == INVALID_STRING_ID && this->grfconfig != NULL;
|
||||
return this->checkable && this->error == INVALID_STRING_ID && this->grfconfig != nullptr;
|
||||
}
|
||||
|
||||
void Clear();
|
||||
|
|
|
@ -51,7 +51,7 @@ void LoadCheckData::Clear()
|
|||
this->checkable = false;
|
||||
this->error = INVALID_STRING_ID;
|
||||
free(this->error_data);
|
||||
this->error_data = NULL;
|
||||
this->error_data = nullptr;
|
||||
|
||||
this->map_size_x = this->map_size_y = 256; // Default for old savegames which do not store mapsize.
|
||||
this->current_date = 0;
|
||||
|
@ -63,7 +63,7 @@ void LoadCheckData::Clear()
|
|||
companies.clear();
|
||||
|
||||
GamelogFree(this->gamelog_action, this->gamelog_actions);
|
||||
this->gamelog_action = NULL;
|
||||
this->gamelog_action = nullptr;
|
||||
this->gamelog_actions = 0;
|
||||
|
||||
ClearGRFConfigList(&this->grfconfig);
|
||||
|
@ -273,7 +273,7 @@ private:
|
|||
SaveLoadOperation fop; ///< File operation to perform.
|
||||
FileList fios_items; ///< Save game list.
|
||||
FiosItem o_dir;
|
||||
const FiosItem *selected; ///< Selected game in #fios_items, or \c NULL.
|
||||
const FiosItem *selected; ///< Selected game in #fios_items, or \c nullptr.
|
||||
Scrollbar *vscroll;
|
||||
|
||||
StringFilter string_filter; ///< Filter for available games.
|
||||
|
@ -417,7 +417,7 @@ public:
|
|||
break;
|
||||
|
||||
case WID_SL_BACKGROUND: {
|
||||
static const char *path = NULL;
|
||||
static const char *path = nullptr;
|
||||
static StringID str = STR_ERROR_UNABLE_TO_READ_DRIVE;
|
||||
static uint64 tot = 0;
|
||||
|
||||
|
@ -461,7 +461,7 @@ public:
|
|||
r.right - WD_FRAMERECT_RIGHT, r.top + FONT_HEIGHT_NORMAL * 2 + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM, PC_GREY);
|
||||
DrawString(r.left, r.right, r.top + FONT_HEIGHT_NORMAL / 2 + WD_FRAMERECT_TOP, STR_SAVELOAD_DETAIL_CAPTION, TC_FROMSTRING, SA_HOR_CENTER);
|
||||
|
||||
if (this->selected == NULL) break;
|
||||
if (this->selected == nullptr) break;
|
||||
|
||||
uint y = r.top + FONT_HEIGHT_NORMAL * 2 + WD_PAR_VSEP_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
||||
uint y_max = r.bottom - FONT_HEIGHT_NORMAL - WD_FRAMERECT_BOTTOM;
|
||||
|
@ -517,7 +517,7 @@ public:
|
|||
if (y > y_max) break;
|
||||
|
||||
/* NewGrf compatibility */
|
||||
SetDParam(0, _load_check_data.grfconfig == NULL ? STR_NEWGRF_LIST_NONE :
|
||||
SetDParam(0, _load_check_data.grfconfig == nullptr ? STR_NEWGRF_LIST_NONE :
|
||||
STR_NEWGRF_LIST_ALL_FOUND + _load_check_data.grf_compatibility);
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_SAVELOAD_DETAIL_GRFSTATUS);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
|
@ -533,7 +533,7 @@ public:
|
|||
for (auto &pair : _load_check_data.companies) {
|
||||
SetDParam(0, pair.first + 1);
|
||||
const CompanyProperties &c = *pair.second;
|
||||
if (c.name != NULL) {
|
||||
if (c.name != nullptr) {
|
||||
SetDParam(1, STR_JUST_RAW_STRING);
|
||||
SetDParamStr(2, c.name);
|
||||
} else {
|
||||
|
@ -607,7 +607,7 @@ public:
|
|||
break;
|
||||
|
||||
case WID_SL_LOAD_BUTTON:
|
||||
if (this->selected != NULL && !_load_check_data.HasErrors()) {
|
||||
if (this->selected != nullptr && !_load_check_data.HasErrors()) {
|
||||
const char *name = FiosBrowseTo(this->selected);
|
||||
_file_to_saveload.SetMode(this->selected->type);
|
||||
_file_to_saveload.SetName(name);
|
||||
|
@ -652,7 +652,7 @@ public:
|
|||
const FiosItem *file = this->fios_items.Get(y);
|
||||
|
||||
const char *name = FiosBrowseTo(file);
|
||||
if (name != NULL) {
|
||||
if (name != nullptr) {
|
||||
if (click_count == 1) {
|
||||
if (this->selected != file) {
|
||||
this->selected = file;
|
||||
|
@ -700,8 +700,8 @@ public:
|
|||
assert(this->fop == SLO_LOAD);
|
||||
switch (this->abstract_filetype) {
|
||||
default: NOT_REACHED();
|
||||
case FT_SCENARIO: ShowNetworkContentListWindow(NULL, CONTENT_TYPE_SCENARIO); break;
|
||||
case FT_HEIGHTMAP: ShowNetworkContentListWindow(NULL, CONTENT_TYPE_HEIGHTMAP); break;
|
||||
case FT_SCENARIO: ShowNetworkContentListWindow(nullptr, CONTENT_TYPE_SCENARIO); break;
|
||||
case FT_HEIGHTMAP: ShowNetworkContentListWindow(nullptr, CONTENT_TYPE_HEIGHTMAP); break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -776,14 +776,14 @@ public:
|
|||
switch (data) {
|
||||
case SLIWD_RESCAN_FILES:
|
||||
/* Rescan files */
|
||||
this->selected = NULL;
|
||||
this->selected = nullptr;
|
||||
_load_check_data.Clear();
|
||||
if (!gui_scope) break;
|
||||
|
||||
_fios_path_changed = true;
|
||||
this->fios_items.BuildFileList(this->abstract_filetype, this->fop);
|
||||
this->vscroll->SetCount((uint)this->fios_items.Length());
|
||||
this->selected = NULL;
|
||||
this->selected = nullptr;
|
||||
_load_check_data.Clear();
|
||||
|
||||
/* We reset the files filtered */
|
||||
|
@ -799,12 +799,12 @@ public:
|
|||
|
||||
switch (this->abstract_filetype) {
|
||||
case FT_HEIGHTMAP:
|
||||
this->SetWidgetDisabledState(WID_SL_LOAD_BUTTON, this->selected == NULL || _load_check_data.HasErrors());
|
||||
this->SetWidgetDisabledState(WID_SL_LOAD_BUTTON, this->selected == nullptr || _load_check_data.HasErrors());
|
||||
break;
|
||||
|
||||
case FT_SAVEGAME:
|
||||
case FT_SCENARIO: {
|
||||
bool disabled = this->selected == NULL || _load_check_data.HasErrors();
|
||||
bool disabled = this->selected == nullptr || _load_check_data.HasErrors();
|
||||
if (!_settings_client.gui.UserIsAllowedToChangeNewGRFs()) {
|
||||
disabled |= _load_check_data.HasNewGrfs() && _load_check_data.grf_compatibility == GLC_NOT_FOUND;
|
||||
}
|
||||
|
@ -839,7 +839,7 @@ public:
|
|||
|
||||
if (&(this->fios_items[i]) == this->selected && this->fios_items_shown[i] == false) {
|
||||
/* The selected element has been filtered out */
|
||||
this->selected = NULL;
|
||||
this->selected = nullptr;
|
||||
this->OnInvalidateData(SLIWD_SELECTION_CHANGES);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ FontCache::FontCache(FontSize fs) : parent(FontCache::Get(fs)), fs(fs), height(_
|
|||
ascender(_default_font_ascender[fs]), descender(_default_font_ascender[fs] - _default_font_height[fs]),
|
||||
units_per_em(1)
|
||||
{
|
||||
assert(this->parent == NULL || this->fs == this->parent->fs);
|
||||
assert(this->parent == nullptr || this->fs == this->parent->fs);
|
||||
FontCache::caches[this->fs] = this;
|
||||
Layouter::ResetFontCache(this->fs);
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public:
|
|||
virtual int GetHeight() const;
|
||||
virtual bool GetDrawGlyphShadow();
|
||||
virtual GlyphID MapCharToGlyph(WChar key) { assert(IsPrintable(key)); return SPRITE_GLYPH | key; }
|
||||
virtual const void *GetFontTable(uint32 tag, size_t &length) { length = 0; return NULL; }
|
||||
virtual const void *GetFontTable(uint32 tag, size_t &length) { length = 0; return nullptr; }
|
||||
virtual const char *GetFontName() { return "sprite"; }
|
||||
virtual bool IsBuiltInFont() { return true; }
|
||||
};
|
||||
|
@ -93,7 +93,7 @@ public:
|
|||
* Create a new sprite font cache.
|
||||
* @param fs The font size to create the cache for.
|
||||
*/
|
||||
SpriteFontCache::SpriteFontCache(FontSize fs) : FontCache(fs), glyph_to_spriteid_map(NULL)
|
||||
SpriteFontCache::SpriteFontCache(FontSize fs) : FontCache(fs), glyph_to_spriteid_map(nullptr)
|
||||
{
|
||||
this->InitializeUnicodeGlyphMap();
|
||||
}
|
||||
|
@ -108,14 +108,14 @@ SpriteFontCache::~SpriteFontCache()
|
|||
|
||||
SpriteID SpriteFontCache::GetUnicodeGlyph(GlyphID key)
|
||||
{
|
||||
if (this->glyph_to_spriteid_map[GB(key, 8, 8)] == NULL) return 0;
|
||||
if (this->glyph_to_spriteid_map[GB(key, 8, 8)] == nullptr) return 0;
|
||||
return this->glyph_to_spriteid_map[GB(key, 8, 8)][GB(key, 0, 8)];
|
||||
}
|
||||
|
||||
void SpriteFontCache::SetUnicodeGlyph(GlyphID key, SpriteID sprite)
|
||||
{
|
||||
if (this->glyph_to_spriteid_map == NULL) this->glyph_to_spriteid_map = CallocT<SpriteID*>(256);
|
||||
if (this->glyph_to_spriteid_map[GB(key, 8, 8)] == NULL) this->glyph_to_spriteid_map[GB(key, 8, 8)] = CallocT<SpriteID>(256);
|
||||
if (this->glyph_to_spriteid_map == nullptr) this->glyph_to_spriteid_map = CallocT<SpriteID*>(256);
|
||||
if (this->glyph_to_spriteid_map[GB(key, 8, 8)] == nullptr) this->glyph_to_spriteid_map[GB(key, 8, 8)] = CallocT<SpriteID>(256);
|
||||
this->glyph_to_spriteid_map[GB(key, 8, 8)][GB(key, 0, 8)] = sprite;
|
||||
}
|
||||
|
||||
|
@ -159,13 +159,13 @@ void SpriteFontCache::InitializeUnicodeGlyphMap()
|
|||
*/
|
||||
void SpriteFontCache::ClearGlyphToSpriteMap()
|
||||
{
|
||||
if (this->glyph_to_spriteid_map == NULL) return;
|
||||
if (this->glyph_to_spriteid_map == nullptr) return;
|
||||
|
||||
for (uint i = 0; i < 256; i++) {
|
||||
free(this->glyph_to_spriteid_map[i]);
|
||||
}
|
||||
free(this->glyph_to_spriteid_map);
|
||||
this->glyph_to_spriteid_map = NULL;
|
||||
this->glyph_to_spriteid_map = nullptr;
|
||||
}
|
||||
|
||||
void SpriteFontCache::ClearFontCache()
|
||||
|
@ -258,7 +258,7 @@ public:
|
|||
virtual bool IsBuiltInFont() { return false; }
|
||||
};
|
||||
|
||||
FT_Library _library = NULL;
|
||||
FT_Library _library = nullptr;
|
||||
|
||||
FreeTypeSettings _freetype;
|
||||
|
||||
|
@ -271,9 +271,9 @@ static const byte SHADOW_COLOUR = 2;
|
|||
* @param face The font that has to be loaded.
|
||||
* @param pixels The number of pixels this font should be high.
|
||||
*/
|
||||
FreeTypeFontCache::FreeTypeFontCache(FontSize fs, FT_Face face, int pixels) : FontCache(fs), face(face), req_size(pixels), glyph_to_sprite(NULL)
|
||||
FreeTypeFontCache::FreeTypeFontCache(FontSize fs, FT_Face face, int pixels) : FontCache(fs), face(face), req_size(pixels), glyph_to_sprite(nullptr)
|
||||
{
|
||||
assert(face != NULL);
|
||||
assert(face != nullptr);
|
||||
|
||||
this->SetFontSize(fs, face, pixels);
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ void FreeTypeFontCache::SetFontSize(FontSize fs, FT_Face face, int pixels)
|
|||
pixels = scaled_height;
|
||||
|
||||
TT_Header *head = (TT_Header *)FT_Get_Sfnt_Table(this->face, ft_sfnt_head);
|
||||
if (head != NULL) {
|
||||
if (head != nullptr) {
|
||||
/* Font height is minimum height plus the difference between the default
|
||||
* height for this font size and the small size. */
|
||||
int diff = scaled_height - ScaleFontTrad(_default_font_height[FS_SMALL]);
|
||||
|
@ -338,7 +338,7 @@ void FreeTypeFontCache::SetFontSize(FontSize fs, FT_Face face, int pixels)
|
|||
*/
|
||||
static void LoadFreeTypeFont(FontSize fs)
|
||||
{
|
||||
FreeTypeSubSetting *settings = NULL;
|
||||
FreeTypeSubSetting *settings = nullptr;
|
||||
switch (fs) {
|
||||
default: NOT_REACHED();
|
||||
case FS_SMALL: settings = &_freetype.small; break;
|
||||
|
@ -349,7 +349,7 @@ static void LoadFreeTypeFont(FontSize fs)
|
|||
|
||||
if (StrEmpty(settings->font)) return;
|
||||
|
||||
if (_library == NULL) {
|
||||
if (_library == nullptr) {
|
||||
if (FT_Init_FreeType(&_library) != FT_Err_Ok) {
|
||||
ShowInfoF("Unable to initialize FreeType, using sprite fonts instead");
|
||||
return;
|
||||
|
@ -358,7 +358,7 @@ static void LoadFreeTypeFont(FontSize fs)
|
|||
DEBUG(freetype, 2, "Initialized");
|
||||
}
|
||||
|
||||
FT_Face face = NULL;
|
||||
FT_Face face = nullptr;
|
||||
FT_Error error = FT_New_Face(_library, settings->font, 0, &face);
|
||||
|
||||
if (error != FT_Err_Ok) error = GetFontByFaceName(settings->font, &face);
|
||||
|
@ -384,7 +384,7 @@ static void LoadFreeTypeFont(FontSize fs)
|
|||
}
|
||||
}
|
||||
|
||||
if (found != NULL) {
|
||||
if (found != nullptr) {
|
||||
error = FT_Set_Charmap(face, found);
|
||||
if (error == FT_Err_Ok) goto found_face;
|
||||
}
|
||||
|
@ -408,7 +408,7 @@ found_face:
|
|||
FreeTypeFontCache::~FreeTypeFontCache()
|
||||
{
|
||||
FT_Done_Face(this->face);
|
||||
this->face = NULL;
|
||||
this->face = nullptr;
|
||||
this->ClearFontCache();
|
||||
|
||||
for (auto &iter : this->font_tables) {
|
||||
|
@ -422,12 +422,12 @@ FreeTypeFontCache::~FreeTypeFontCache()
|
|||
void FreeTypeFontCache::ClearFontCache()
|
||||
{
|
||||
/* Font scaling might have changed, determine font size anew if it was automatically selected. */
|
||||
if (this->face != NULL) this->SetFontSize(this->fs, this->face, this->req_size);
|
||||
if (this->face != nullptr) this->SetFontSize(this->fs, this->face, this->req_size);
|
||||
|
||||
if (this->glyph_to_sprite == NULL) return;
|
||||
if (this->glyph_to_sprite == nullptr) return;
|
||||
|
||||
for (int i = 0; i < 256; i++) {
|
||||
if (this->glyph_to_sprite[i] == NULL) continue;
|
||||
if (this->glyph_to_sprite[i] == nullptr) continue;
|
||||
|
||||
for (int j = 0; j < 256; j++) {
|
||||
if (this->glyph_to_sprite[i][j].duplicate) continue;
|
||||
|
@ -438,27 +438,27 @@ void FreeTypeFontCache::ClearFontCache()
|
|||
}
|
||||
|
||||
free(this->glyph_to_sprite);
|
||||
this->glyph_to_sprite = NULL;
|
||||
this->glyph_to_sprite = nullptr;
|
||||
|
||||
Layouter::ResetFontCache(this->fs);
|
||||
}
|
||||
|
||||
FreeTypeFontCache::GlyphEntry *FreeTypeFontCache::GetGlyphPtr(GlyphID key)
|
||||
{
|
||||
if (this->glyph_to_sprite == NULL) return NULL;
|
||||
if (this->glyph_to_sprite[GB(key, 8, 8)] == NULL) return NULL;
|
||||
if (this->glyph_to_sprite == nullptr) return nullptr;
|
||||
if (this->glyph_to_sprite[GB(key, 8, 8)] == nullptr) return nullptr;
|
||||
return &this->glyph_to_sprite[GB(key, 8, 8)][GB(key, 0, 8)];
|
||||
}
|
||||
|
||||
|
||||
void FreeTypeFontCache::SetGlyphPtr(GlyphID key, const GlyphEntry *glyph, bool duplicate)
|
||||
{
|
||||
if (this->glyph_to_sprite == NULL) {
|
||||
if (this->glyph_to_sprite == nullptr) {
|
||||
DEBUG(freetype, 3, "Allocating root glyph cache for size %u", this->fs);
|
||||
this->glyph_to_sprite = CallocT<GlyphEntry*>(256);
|
||||
}
|
||||
|
||||
if (this->glyph_to_sprite[GB(key, 8, 8)] == NULL) {
|
||||
if (this->glyph_to_sprite[GB(key, 8, 8)] == nullptr) {
|
||||
DEBUG(freetype, 3, "Allocating glyph cache for range 0x%02X00, size %u", GB(key, 8, 8), this->fs);
|
||||
this->glyph_to_sprite[GB(key, 8, 8)] = CallocT<GlyphEntry>(256);
|
||||
}
|
||||
|
@ -497,7 +497,7 @@ const Sprite *FreeTypeFontCache::GetGlyph(GlyphID key)
|
|||
|
||||
/* Check for the glyph in our cache */
|
||||
GlyphEntry *glyph = this->GetGlyphPtr(key);
|
||||
if (glyph != NULL && glyph->sprite != NULL) return glyph->sprite;
|
||||
if (glyph != nullptr && glyph->sprite != nullptr) return glyph->sprite;
|
||||
|
||||
FT_GlyphSlot slot = this->face->glyph;
|
||||
|
||||
|
@ -535,7 +535,7 @@ const Sprite *FreeTypeFontCache::GetGlyph(GlyphID key)
|
|||
};
|
||||
|
||||
Sprite *spr = BlitterFactory::GetCurrentBlitter()->Encode(&builtin_questionmark, AllocateFont);
|
||||
assert(spr != NULL);
|
||||
assert(spr != nullptr);
|
||||
new_glyph.sprite = spr;
|
||||
new_glyph.width = spr->width + (this->fs != FS_NORMAL);
|
||||
this->SetGlyphPtr(key, &new_glyph, false);
|
||||
|
@ -611,7 +611,7 @@ uint FreeTypeFontCache::GetGlyphWidth(GlyphID key)
|
|||
if ((key & SPRITE_GLYPH) != 0) return this->parent->GetGlyphWidth(key);
|
||||
|
||||
GlyphEntry *glyph = this->GetGlyphPtr(key);
|
||||
if (glyph == NULL || glyph->sprite == NULL) {
|
||||
if (glyph == nullptr || glyph->sprite == nullptr) {
|
||||
this->GetGlyph(key);
|
||||
glyph = this->GetGlyphPtr(key);
|
||||
}
|
||||
|
@ -639,9 +639,9 @@ const void *FreeTypeFontCache::GetFontTable(uint32 tag, size_t &length)
|
|||
}
|
||||
|
||||
FT_ULong len = 0;
|
||||
FT_Byte *result = NULL;
|
||||
FT_Byte *result = nullptr;
|
||||
|
||||
FT_Load_Sfnt_Table(this->face, tag, 0, NULL, &len);
|
||||
FT_Load_Sfnt_Table(this->face, tag, 0, nullptr, &len);
|
||||
|
||||
if (len > 0) {
|
||||
result = MallocT<FT_Byte>(len);
|
||||
|
@ -685,6 +685,6 @@ void UninitFreeType()
|
|||
|
||||
#ifdef WITH_FREETYPE
|
||||
FT_Done_FreeType(_library);
|
||||
_library = NULL;
|
||||
_library = nullptr;
|
||||
#endif /* WITH_FREETYPE */
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ public:
|
|||
*/
|
||||
inline bool HasParent()
|
||||
{
|
||||
return this->parent != NULL;
|
||||
return this->parent != nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -53,7 +53,7 @@ const char *GetShortPath(const TCHAR *long_path)
|
|||
#ifdef UNICODE
|
||||
WCHAR short_path_w[MAX_PATH];
|
||||
GetShortPathName(long_path, short_path_w, lengthof(short_path_w));
|
||||
WideCharToMultiByte(CP_ACP, 0, short_path_w, -1, short_path, lengthof(short_path), NULL, NULL);
|
||||
WideCharToMultiByte(CP_ACP, 0, short_path_w, -1, short_path, lengthof(short_path), nullptr, nullptr);
|
||||
#else
|
||||
/* Technically not needed, but do it for consistency. */
|
||||
GetShortPathName(long_path, short_path, lengthof(short_path));
|
||||
|
@ -101,7 +101,7 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
|
|||
DWORD vbuflen = lengthof(vbuffer);
|
||||
DWORD dbuflen = lengthof(dbuffer);
|
||||
|
||||
ret = RegEnumValue(hKey, index, vbuffer, &vbuflen, NULL, NULL, (byte*)dbuffer, &dbuflen);
|
||||
ret = RegEnumValue(hKey, index, vbuffer, &vbuflen, nullptr, nullptr, (byte*)dbuffer, &dbuflen);
|
||||
if (ret != ERROR_SUCCESS) goto registry_no_font_found;
|
||||
|
||||
/* The font names in the registry are of the following 3 forms:
|
||||
|
@ -114,16 +114,16 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
|
|||
* by '&'. Our best bet will be to do substr match for the fontname
|
||||
* and then let FreeType figure out which index to load */
|
||||
s = _tcschr(vbuffer, _T('('));
|
||||
if (s != NULL) s[-1] = '\0';
|
||||
if (s != nullptr) s[-1] = '\0';
|
||||
|
||||
if (_tcschr(vbuffer, _T('&')) == NULL) {
|
||||
if (_tcschr(vbuffer, _T('&')) == nullptr) {
|
||||
if (_tcsicmp(vbuffer, font_namep) == 0) break;
|
||||
} else {
|
||||
if (_tcsstr(vbuffer, font_namep) != NULL) break;
|
||||
if (_tcsstr(vbuffer, font_namep) != nullptr) break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!SUCCEEDED(OTTDSHGetFolderPath(NULL, CSIDL_FONTS, NULL, SHGFP_TYPE_CURRENT, vbuffer))) {
|
||||
if (!SUCCEEDED(OTTDSHGetFolderPath(nullptr, CSIDL_FONTS, nullptr, SHGFP_TYPE_CURRENT, vbuffer))) {
|
||||
DEBUG(freetype, 0, "SHGetFolderPath cannot return fonts directory");
|
||||
goto folder_error;
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ registry_no_font_found:
|
|||
static const char *GetEnglishFontName(const ENUMLOGFONTEX *logfont)
|
||||
{
|
||||
static char font_name[MAX_PATH];
|
||||
const char *ret_font_name = NULL;
|
||||
const char *ret_font_name = nullptr;
|
||||
uint pos = 0;
|
||||
HDC dc;
|
||||
HGDIOBJ oldfont;
|
||||
|
@ -184,11 +184,11 @@ static const char *GetEnglishFontName(const ENUMLOGFONTEX *logfont)
|
|||
uint16 format, count, stringOffset, platformId, encodingId, languageId, nameId, length, offset;
|
||||
|
||||
HFONT font = CreateFontIndirect(&logfont->elfLogFont);
|
||||
if (font == NULL) goto err1;
|
||||
if (font == nullptr) goto err1;
|
||||
|
||||
dc = GetDC(NULL);
|
||||
dc = GetDC(nullptr);
|
||||
oldfont = SelectObject(dc, font);
|
||||
dw = GetFontData(dc, 'eman', 0, NULL, 0);
|
||||
dw = GetFontData(dc, 'eman', 0, nullptr, 0);
|
||||
if (dw == GDI_ERROR) goto err2;
|
||||
|
||||
buf = MallocT<byte>(dw);
|
||||
|
@ -236,10 +236,10 @@ err3:
|
|||
free(buf);
|
||||
err2:
|
||||
SelectObject(dc, oldfont);
|
||||
ReleaseDC(NULL, dc);
|
||||
ReleaseDC(nullptr, dc);
|
||||
DeleteObject(font);
|
||||
err1:
|
||||
return ret_font_name == NULL ? WIDE_TO_MB((const TCHAR*)logfont->elfFullName) : ret_font_name;
|
||||
return ret_font_name == nullptr ? WIDE_TO_MB((const TCHAR*)logfont->elfFullName) : ret_font_name;
|
||||
}
|
||||
|
||||
class FontList {
|
||||
|
@ -249,10 +249,10 @@ protected:
|
|||
uint capacity;
|
||||
|
||||
public:
|
||||
FontList() : fonts(NULL), items(0), capacity(0) { };
|
||||
FontList() : fonts(nullptr), items(0), capacity(0) { };
|
||||
|
||||
~FontList() {
|
||||
if (this->fonts == NULL) return;
|
||||
if (this->fonts == nullptr) return;
|
||||
|
||||
for (uint i = 0; i < this->items; i++) {
|
||||
free(this->fonts[i]);
|
||||
|
@ -303,12 +303,12 @@ static int CALLBACK EnumFontCallback(const ENUMLOGFONTEX *logfont, const NEWTEXT
|
|||
FONTSIGNATURE fs;
|
||||
memset(&fs, 0, sizeof(fs));
|
||||
HFONT font = CreateFontIndirect(&logfont->elfLogFont);
|
||||
if (font != NULL) {
|
||||
HDC dc = GetDC(NULL);
|
||||
if (font != nullptr) {
|
||||
HDC dc = GetDC(nullptr);
|
||||
HGDIOBJ oldfont = SelectObject(dc, font);
|
||||
GetTextCharsetInfo(dc, &fs, 0);
|
||||
SelectObject(dc, oldfont);
|
||||
ReleaseDC(NULL, dc);
|
||||
ReleaseDC(nullptr, dc);
|
||||
DeleteObject(font);
|
||||
}
|
||||
if ((fs.fsCsb[0] & info->locale.lsCsbSupported[0]) == 0 && (fs.fsCsb[1] & info->locale.lsCsbSupported[1]) == 0) return 1;
|
||||
|
@ -322,7 +322,7 @@ static int CALLBACK EnumFontCallback(const ENUMLOGFONTEX *logfont, const NEWTEXT
|
|||
strecpy(font_name + strlen(font_name) + 1, english_name, lastof(font_name));
|
||||
|
||||
/* Check whether we can actually load the font. */
|
||||
bool ft_init = _library != NULL;
|
||||
bool ft_init = _library != nullptr;
|
||||
bool found = false;
|
||||
FT_Face face;
|
||||
/* Init FreeType if needed. */
|
||||
|
@ -333,13 +333,13 @@ static int CALLBACK EnumFontCallback(const ENUMLOGFONTEX *logfont, const NEWTEXT
|
|||
if (!ft_init) {
|
||||
/* Uninit FreeType if we did the init. */
|
||||
FT_Done_FreeType(_library);
|
||||
_library = NULL;
|
||||
_library = nullptr;
|
||||
}
|
||||
|
||||
if (!found) return 1;
|
||||
|
||||
info->callback->SetFontNames(info->settings, font_name);
|
||||
if (info->callback->FindMissingGlyphs(NULL)) return 1;
|
||||
if (info->callback->FindMissingGlyphs(nullptr)) return 1;
|
||||
DEBUG(freetype, 1, "Fallback font: %s (%s)", font_name, english_name);
|
||||
return 0; // stop enumerating
|
||||
}
|
||||
|
@ -362,9 +362,9 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
|
|||
font.lfFaceName[0] = '\0';
|
||||
font.lfPitchAndFamily = 0;
|
||||
|
||||
HDC dc = GetDC(NULL);
|
||||
HDC dc = GetDC(nullptr);
|
||||
int ret = EnumFontFamiliesEx(dc, &font, (FONTENUMPROC)&EnumFontCallback, (LPARAM)&langInfo, 0);
|
||||
ReleaseDC(NULL, dc);
|
||||
ReleaseDC(nullptr, dc);
|
||||
return ret == 0;
|
||||
}
|
||||
|
||||
|
@ -400,14 +400,14 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
|
|||
CFRelease(name);
|
||||
|
||||
/* Loop over all matches until we can get a path for one of them. */
|
||||
for (CFIndex i = 0; descs != NULL && i < CFArrayGetCount(descs) && os_err != noErr; i++) {
|
||||
CTFontRef font = CTFontCreateWithFontDescriptor((CTFontDescriptorRef)CFArrayGetValueAtIndex(descs, i), 0.0, NULL);
|
||||
for (CFIndex i = 0; descs != nullptr && i < CFArrayGetCount(descs) && os_err != noErr; i++) {
|
||||
CTFontRef font = CTFontCreateWithFontDescriptor((CTFontDescriptorRef)CFArrayGetValueAtIndex(descs, i), 0.0, nullptr);
|
||||
CFURLRef fontURL = (CFURLRef)CTFontCopyAttribute(font, kCTFontURLAttribute);
|
||||
if (CFURLGetFileSystemRepresentation(fontURL, true, file_path, lengthof(file_path))) os_err = noErr;
|
||||
CFRelease(font);
|
||||
CFRelease(fontURL);
|
||||
}
|
||||
if (descs != NULL) CFRelease(descs);
|
||||
if (descs != nullptr) CFRelease(descs);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
|
@ -467,7 +467,7 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
|
|||
/* Just copy the first part of the isocode. */
|
||||
strecpy(lang, language_isocode, lastof(lang));
|
||||
char *sep = strchr(lang, '_');
|
||||
if (sep != NULL) *sep = '\0';
|
||||
if (sep != nullptr) *sep = '\0';
|
||||
}
|
||||
|
||||
/* Create a font descriptor matching the wanted language and latin (english) glyphs. */
|
||||
|
@ -487,7 +487,7 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
|
|||
CFRelease(mandatory_attribs);
|
||||
CFRelease(lang_desc);
|
||||
|
||||
for (CFIndex i = 0; descs != NULL && i < CFArrayGetCount(descs); i++) {
|
||||
for (CFIndex i = 0; descs != nullptr && i < CFArrayGetCount(descs); i++) {
|
||||
CTFontDescriptorRef font = (CTFontDescriptorRef)CFArrayGetValueAtIndex(descs, i);
|
||||
|
||||
/* Get font traits. */
|
||||
|
@ -515,13 +515,13 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
|
|||
|
||||
/* Save result. */
|
||||
callback->SetFontNames(settings, name);
|
||||
if (!callback->FindMissingGlyphs(NULL)) {
|
||||
if (!callback->FindMissingGlyphs(nullptr)) {
|
||||
DEBUG(freetype, 2, "CT-Font for %s: %s", language_isocode, name);
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (descs != NULL) CFRelease(descs);
|
||||
if (descs != nullptr) CFRelease(descs);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
|
@ -530,7 +530,7 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
|
|||
* are available to the application. */
|
||||
ATSFontIterator itr;
|
||||
ATSFontRef font;
|
||||
ATSFontIteratorCreate(kATSFontContextLocal, NULL, NULL, kATSOptionFlagsDefaultScope, &itr);
|
||||
ATSFontIteratorCreate(kATSFontContextLocal, nullptr, nullptr, kATSOptionFlagsDefaultScope, &itr);
|
||||
while (!result && ATSFontIteratorNext(itr, &font) == noErr) {
|
||||
/* Get font name. */
|
||||
char name[128];
|
||||
|
@ -545,14 +545,14 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
|
|||
if (monospace != callback->Monospace()) continue;
|
||||
|
||||
/* We only want the base font and not bold or italic variants. */
|
||||
if (strstr(name, "Italic") != NULL || strstr(name, "Bold")) continue;
|
||||
if (strstr(name, "Italic") != nullptr || strstr(name, "Bold")) continue;
|
||||
|
||||
/* Skip some inappropriate or ugly looking fonts that have better alternatives. */
|
||||
if (name[0] == '.' || strncmp(name, "Apple Symbols", 13) == 0 || strncmp(name, "LastResort", 10) == 0) continue;
|
||||
|
||||
/* Save result. */
|
||||
callback->SetFontNames(settings, name);
|
||||
if (!callback->FindMissingGlyphs(NULL)) {
|
||||
if (!callback->FindMissingGlyphs(nullptr)) {
|
||||
DEBUG(freetype, 2, "ATS-Font for %s: %s", language_isocode, name);
|
||||
result = true;
|
||||
break;
|
||||
|
@ -566,10 +566,10 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
|
|||
/* For some OS versions, the font 'Arial Unicode MS' does not report all languages it
|
||||
* supports. If we didn't find any other font, just try it, maybe we get lucky. */
|
||||
callback->SetFontNames(settings, "Arial Unicode MS");
|
||||
result = !callback->FindMissingGlyphs(NULL);
|
||||
result = !callback->FindMissingGlyphs(nullptr);
|
||||
}
|
||||
|
||||
callback->FindMissingGlyphs(NULL);
|
||||
callback->FindMissingGlyphs(nullptr);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -599,7 +599,7 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
|
|||
/* Split & strip the font's style */
|
||||
font_family = stredup(font_name);
|
||||
font_style = strchr(font_family, ',');
|
||||
if (font_style != NULL) {
|
||||
if (font_style != nullptr) {
|
||||
font_style[0] = '\0';
|
||||
font_style++;
|
||||
while (*font_style == ' ' || *font_style == '\t') font_style++;
|
||||
|
@ -607,13 +607,13 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
|
|||
|
||||
/* Resolve the name and populate the information structure */
|
||||
pat = FcNameParse((FcChar8*)font_family);
|
||||
if (font_style != NULL) FcPatternAddString(pat, FC_STYLE, (FcChar8*)font_style);
|
||||
if (font_style != nullptr) FcPatternAddString(pat, FC_STYLE, (FcChar8*)font_style);
|
||||
FcConfigSubstitute(0, pat, FcMatchPattern);
|
||||
FcDefaultSubstitute(pat);
|
||||
fs = FcFontSetCreate();
|
||||
match = FcFontMatch(0, pat, &result);
|
||||
|
||||
if (fs != NULL && match != NULL) {
|
||||
if (fs != nullptr && match != nullptr) {
|
||||
int i;
|
||||
FcChar8 *family;
|
||||
FcChar8 *style;
|
||||
|
@ -627,7 +627,7 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
|
|||
FcPatternGetString(fs->fonts[i], FC_STYLE, 0, &style) == FcResultMatch) {
|
||||
|
||||
/* The correct style? */
|
||||
if (font_style != NULL && strcasecmp(font_style, (char*)style) != 0) continue;
|
||||
if (font_style != nullptr && strcasecmp(font_style, (char*)style) != 0) continue;
|
||||
|
||||
/* Font config takes the best shot, which, if the family name is spelled
|
||||
* wrongly a 'random' font, so check whether the family name is the
|
||||
|
@ -660,29 +660,29 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
|
|||
char lang[16];
|
||||
seprintf(lang, lastof(lang), ":lang=%s", language_isocode);
|
||||
char *split = strchr(lang, '_');
|
||||
if (split != NULL) *split = '\0';
|
||||
if (split != nullptr) *split = '\0';
|
||||
|
||||
/* First create a pattern to match the wanted language. */
|
||||
FcPattern *pat = FcNameParse((FcChar8*)lang);
|
||||
/* We only want to know the filename. */
|
||||
FcObjectSet *os = FcObjectSetBuild(FC_FILE, FC_SPACING, FC_SLANT, FC_WEIGHT, NULL);
|
||||
FcObjectSet *os = FcObjectSetBuild(FC_FILE, FC_SPACING, FC_SLANT, FC_WEIGHT, nullptr);
|
||||
/* Get the list of filenames matching the wanted language. */
|
||||
FcFontSet *fs = FcFontList(NULL, pat, os);
|
||||
FcFontSet *fs = FcFontList(nullptr, pat, os);
|
||||
|
||||
/* We don't need these anymore. */
|
||||
FcObjectSetDestroy(os);
|
||||
FcPatternDestroy(pat);
|
||||
|
||||
if (fs != NULL) {
|
||||
if (fs != nullptr) {
|
||||
int best_weight = -1;
|
||||
const char *best_font = NULL;
|
||||
const char *best_font = nullptr;
|
||||
|
||||
for (int i = 0; i < fs->nfont; i++) {
|
||||
FcPattern *font = fs->fonts[i];
|
||||
|
||||
FcChar8 *file = NULL;
|
||||
FcChar8 *file = nullptr;
|
||||
FcResult res = FcPatternGetString(font, FC_FILE, 0, &file);
|
||||
if (res != FcResultMatch || file == NULL) {
|
||||
if (res != FcResultMatch || file == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -701,7 +701,7 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
|
|||
|
||||
callback->SetFontNames(settings, (const char*)file);
|
||||
|
||||
bool missing = callback->FindMissingGlyphs(NULL);
|
||||
bool missing = callback->FindMissingGlyphs(nullptr);
|
||||
DEBUG(freetype, 1, "Font \"%s\" misses%s glyphs", file, missing ? "" : " no");
|
||||
|
||||
if (!missing) {
|
||||
|
@ -710,7 +710,7 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
|
|||
}
|
||||
}
|
||||
|
||||
if (best_font != NULL) {
|
||||
if (best_font != nullptr) {
|
||||
ret = true;
|
||||
callback->SetFontNames(settings, best_font);
|
||||
InitFreeType(callback->Monospace());
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
} else {
|
||||
config = &_settings_game.game_config;
|
||||
}
|
||||
if (*config == NULL) *config = new GameConfig();
|
||||
if (*config == nullptr) *config = new GameConfig();
|
||||
return *config;
|
||||
}
|
||||
|
||||
|
@ -42,5 +42,5 @@ ScriptInfo *GameConfig::FindInfo(const char *name, int version, bool force_exact
|
|||
bool GameConfig::ResetInfo(bool force_exact_match)
|
||||
{
|
||||
this->info = (ScriptInfo *)Game::FindInfo(this->name, force_exact_match ? this->version : -1, force_exact_match);
|
||||
return this->info != NULL;
|
||||
return this->info != nullptr;
|
||||
}
|
||||
|
|
|
@ -25,10 +25,10 @@
|
|||
#include "../safeguards.h"
|
||||
|
||||
/* static */ uint Game::frame_counter = 0;
|
||||
/* static */ GameInfo *Game::info = NULL;
|
||||
/* static */ GameInstance *Game::instance = NULL;
|
||||
/* static */ GameScannerInfo *Game::scanner_info = NULL;
|
||||
/* static */ GameScannerLibrary *Game::scanner_library = NULL;
|
||||
/* static */ GameInfo *Game::info = nullptr;
|
||||
/* static */ GameInstance *Game::instance = nullptr;
|
||||
/* static */ GameScannerInfo *Game::scanner_info = nullptr;
|
||||
/* static */ GameScannerLibrary *Game::scanner_library = nullptr;
|
||||
|
||||
/* static */ void Game::GameLoop()
|
||||
{
|
||||
|
@ -36,7 +36,7 @@
|
|||
PerformanceMeasurer::SetInactive(PFE_GAMESCRIPT);
|
||||
return;
|
||||
}
|
||||
if (Game::instance == NULL) {
|
||||
if (Game::instance == nullptr) {
|
||||
PerformanceMeasurer::SetInactive(PFE_GAMESCRIPT);
|
||||
return;
|
||||
}
|
||||
|
@ -58,11 +58,11 @@
|
|||
|
||||
/* static */ void Game::Initialize()
|
||||
{
|
||||
if (Game::instance != NULL) Game::Uninitialize(true);
|
||||
if (Game::instance != nullptr) Game::Uninitialize(true);
|
||||
|
||||
Game::frame_counter = 0;
|
||||
|
||||
if (Game::scanner_info == NULL) {
|
||||
if (Game::scanner_info == nullptr) {
|
||||
TarScanner::DoScan(TarScanner::GAME);
|
||||
Game::scanner_info = new GameScannerInfo();
|
||||
Game::scanner_info->Initialize();
|
||||
|
@ -73,14 +73,14 @@
|
|||
|
||||
/* static */ void Game::StartNew()
|
||||
{
|
||||
if (Game::instance != NULL) return;
|
||||
if (Game::instance != nullptr) return;
|
||||
|
||||
/* Clients shouldn't start GameScripts */
|
||||
if (_networking && !_network_server) return;
|
||||
|
||||
GameConfig *config = GameConfig::GetConfig(GameConfig::SSS_FORCE_GAME);
|
||||
GameInfo *info = config->GetInfo();
|
||||
if (info == NULL) return;
|
||||
if (info == nullptr) return;
|
||||
|
||||
config->AnchorUnchangeableSettings();
|
||||
|
||||
|
@ -101,8 +101,8 @@
|
|||
Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
|
||||
|
||||
delete Game::instance;
|
||||
Game::instance = NULL;
|
||||
Game::info = NULL;
|
||||
Game::instance = nullptr;
|
||||
Game::info = nullptr;
|
||||
|
||||
cur_company.Restore();
|
||||
|
||||
|
@ -111,33 +111,33 @@
|
|||
} else {
|
||||
delete Game::scanner_info;
|
||||
delete Game::scanner_library;
|
||||
Game::scanner_info = NULL;
|
||||
Game::scanner_library = NULL;
|
||||
Game::scanner_info = nullptr;
|
||||
Game::scanner_library = nullptr;
|
||||
|
||||
if (_settings_game.game_config != NULL) {
|
||||
if (_settings_game.game_config != nullptr) {
|
||||
delete _settings_game.game_config;
|
||||
_settings_game.game_config = NULL;
|
||||
_settings_game.game_config = nullptr;
|
||||
}
|
||||
if (_settings_newgame.game_config != NULL) {
|
||||
if (_settings_newgame.game_config != nullptr) {
|
||||
delete _settings_newgame.game_config;
|
||||
_settings_newgame.game_config = NULL;
|
||||
_settings_newgame.game_config = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* static */ void Game::Pause()
|
||||
{
|
||||
if (Game::instance != NULL) Game::instance->Pause();
|
||||
if (Game::instance != nullptr) Game::instance->Pause();
|
||||
}
|
||||
|
||||
/* static */ void Game::Unpause()
|
||||
{
|
||||
if (Game::instance != NULL) Game::instance->Unpause();
|
||||
if (Game::instance != nullptr) Game::instance->Unpause();
|
||||
}
|
||||
|
||||
/* static */ bool Game::IsPaused()
|
||||
{
|
||||
return Game::instance != NULL? Game::instance->IsPaused() : false;
|
||||
return Game::instance != nullptr? Game::instance->IsPaused() : false;
|
||||
}
|
||||
|
||||
/* static */ void Game::NewEvent(ScriptEvent *event)
|
||||
|
@ -152,7 +152,7 @@
|
|||
}
|
||||
|
||||
/* Check if Game instance is alive */
|
||||
if (Game::instance == NULL) {
|
||||
if (Game::instance == nullptr) {
|
||||
event->Release();
|
||||
return;
|
||||
}
|
||||
|
@ -169,23 +169,23 @@
|
|||
{
|
||||
/* Check for both newgame as current game if we can reload the GameInfo inside
|
||||
* the GameConfig. If not, remove the Game from the list. */
|
||||
if (_settings_game.game_config != NULL && _settings_game.game_config->HasScript()) {
|
||||
if (_settings_game.game_config != nullptr && _settings_game.game_config->HasScript()) {
|
||||
if (!_settings_game.game_config->ResetInfo(true)) {
|
||||
DEBUG(script, 0, "After a reload, the GameScript by the name '%s' was no longer found, and removed from the list.", _settings_game.game_config->GetName());
|
||||
_settings_game.game_config->Change(NULL);
|
||||
if (Game::instance != NULL) {
|
||||
_settings_game.game_config->Change(nullptr);
|
||||
if (Game::instance != nullptr) {
|
||||
delete Game::instance;
|
||||
Game::instance = NULL;
|
||||
Game::info = NULL;
|
||||
Game::instance = nullptr;
|
||||
Game::info = nullptr;
|
||||
}
|
||||
} else if (Game::instance != NULL) {
|
||||
} else if (Game::instance != nullptr) {
|
||||
Game::info = _settings_game.game_config->GetInfo();
|
||||
}
|
||||
}
|
||||
if (_settings_newgame.game_config != NULL && _settings_newgame.game_config->HasScript()) {
|
||||
if (_settings_newgame.game_config != nullptr && _settings_newgame.game_config->HasScript()) {
|
||||
if (!_settings_newgame.game_config->ResetInfo(false)) {
|
||||
DEBUG(script, 0, "After a reload, the GameScript by the name '%s' was no longer found, and removed from the list.", _settings_newgame.game_config->GetName());
|
||||
_settings_newgame.game_config->Change(NULL);
|
||||
_settings_newgame.game_config->Change(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +206,7 @@
|
|||
|
||||
/* static */ void Game::Save()
|
||||
{
|
||||
if (Game::instance != NULL && (!_networking || _network_server)) {
|
||||
if (Game::instance != nullptr && (!_networking || _network_server)) {
|
||||
Backup<CompanyByte> cur_company(_current_company, OWNER_DEITY, FILE_LINE);
|
||||
Game::instance->Save();
|
||||
cur_company.Restore();
|
||||
|
@ -217,7 +217,7 @@
|
|||
|
||||
/* static */ void Game::Load(int version)
|
||||
{
|
||||
if (Game::instance != NULL && (!_networking || _network_server)) {
|
||||
if (Game::instance != nullptr && (!_networking || _network_server)) {
|
||||
Backup<CompanyByte> cur_company(_current_company, OWNER_DEITY, FILE_LINE);
|
||||
Game::instance->Load(version);
|
||||
cur_company.Restore();
|
||||
|
|
|
@ -55,8 +55,8 @@ template <> const char *GetClassName<GameInfo, ST_GS>() { return "GSInfo"; }
|
|||
/* static */ SQInteger GameInfo::Constructor(HSQUIRRELVM vm)
|
||||
{
|
||||
/* Get the GameInfo */
|
||||
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 GameInfo to RegisterGame");
|
||||
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 GameInfo to RegisterGame");
|
||||
GameInfo *info = (GameInfo *)instance;
|
||||
|
||||
SQInteger res = ScriptInfo::Constructor(vm, info);
|
||||
|
@ -82,7 +82,7 @@ template <> const char *GetClassName<GameInfo, ST_GS>() { return "GSInfo"; }
|
|||
}
|
||||
|
||||
/* Remove the link to the real instance, else it might get deleted by RegisterGame() */
|
||||
sq_setinstanceup(vm, 2, NULL);
|
||||
sq_setinstanceup(vm, 2, nullptr);
|
||||
/* Register the Game to the base system */
|
||||
info->GetScanner()->RegisterScript(info);
|
||||
return 0;
|
||||
|
@ -91,7 +91,7 @@ template <> const char *GetClassName<GameInfo, ST_GS>() { return "GSInfo"; }
|
|||
GameInfo::GameInfo() :
|
||||
min_loadable_version(0),
|
||||
is_developer_only(false),
|
||||
api_version(NULL)
|
||||
api_version(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ private:
|
|||
/** All static information from an Game library like name, version, etc. */
|
||||
class GameLibrary : public ScriptInfo {
|
||||
public:
|
||||
GameLibrary() : ScriptInfo(), category(NULL) {};
|
||||
GameLibrary() : ScriptInfo(), category(nullptr) {};
|
||||
~GameLibrary();
|
||||
|
||||
/**
|
||||
|
|
|
@ -239,10 +239,10 @@ void GameInstance::Died()
|
|||
ShowAIDebugWindow(OWNER_DEITY);
|
||||
|
||||
const GameInfo *info = 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());
|
||||
}
|
||||
|
|
|
@ -35,14 +35,14 @@ void GameScannerInfo::RegisterAPI(class Squirrel *engine)
|
|||
|
||||
GameInfo *GameScannerInfo::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 game_name[1024];
|
||||
strecpy(game_name, nameParam, lastof(game_name));
|
||||
strtolower(game_name);
|
||||
|
||||
GameInfo *info = NULL;
|
||||
GameInfo *info = nullptr;
|
||||
int version = -1;
|
||||
|
||||
if (versionParam == -1) {
|
||||
|
@ -51,7 +51,7 @@ GameInfo *GameScannerInfo::FindInfo(const char *nameParam, int versionParam, boo
|
|||
|
||||
/* If we didn't find a match Game script, maybe the user included a version */
|
||||
char *e = strrchr(game_name, '.');
|
||||
if (e == NULL) return NULL;
|
||||
if (e == nullptr) return nullptr;
|
||||
*e = '\0';
|
||||
e++;
|
||||
versionParam = atoi(e);
|
||||
|
@ -106,7 +106,7 @@ GameLibrary *GameScannerLibrary::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<GameLibrary *>((*iter).second);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
* @param nameParam The name of the game script.
|
||||
* @param versionParam The version of the game script, 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 game script that matched.
|
||||
* @return nullptr if no match found, otherwise the game script that matched.
|
||||
*/
|
||||
class GameInfo *FindInfo(const char *nameParam, int versionParam, bool force_exact_match);
|
||||
|
||||
|
@ -44,7 +44,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 GameLibrary *FindLibrary(const char *library, int version);
|
||||
|
||||
|
|
|
@ -63,11 +63,11 @@ void NORETURN CDECL strgen_fatal(const char *s, ...)
|
|||
/**
|
||||
* Create a new container for language strings.
|
||||
* @param language The language name.
|
||||
* @param end If not NULL, terminate \a language at this position.
|
||||
* @param end If not nullptr, terminate \a language at this position.
|
||||
*/
|
||||
LanguageStrings::LanguageStrings(const char *language, const char *end)
|
||||
{
|
||||
this->language = stredup(language, end != NULL ? end - 1 : NULL);
|
||||
this->language = stredup(language, end != nullptr ? end - 1 : nullptr);
|
||||
}
|
||||
|
||||
/** Free everything. */
|
||||
|
@ -79,31 +79,31 @@ LanguageStrings::~LanguageStrings()
|
|||
/**
|
||||
* Read all the raw language strings from the given file.
|
||||
* @param file The file to read from.
|
||||
* @return The raw strings, or NULL upon error.
|
||||
* @return The raw strings, or nullptr upon error.
|
||||
*/
|
||||
std::unique_ptr<LanguageStrings> ReadRawLanguageStrings(const char *file)
|
||||
{
|
||||
try {
|
||||
size_t to_read;
|
||||
FILE *fh = FioFOpenFile(file, "rb", GAME_DIR, &to_read);
|
||||
if (fh == NULL) return NULL;
|
||||
if (fh == nullptr) return nullptr;
|
||||
|
||||
FileCloser fhClose(fh);
|
||||
|
||||
const char *langname = strrchr(file, PATHSEPCHAR);
|
||||
if (langname == NULL) {
|
||||
if (langname == nullptr) {
|
||||
langname = file;
|
||||
} else {
|
||||
langname++;
|
||||
}
|
||||
|
||||
/* Check for invalid empty filename */
|
||||
if (*langname == '.' || *langname == 0) return NULL;
|
||||
if (*langname == '.' || *langname == 0) return nullptr;
|
||||
|
||||
std::unique_ptr<LanguageStrings> ret(new LanguageStrings(langname, strchr(langname, '.')));
|
||||
|
||||
char buffer[2048];
|
||||
while (to_read != 0 && fgets(buffer, sizeof(buffer), fh) != NULL) {
|
||||
while (to_read != 0 && fgets(buffer, sizeof(buffer), fh) != nullptr) {
|
||||
size_t len = strlen(buffer);
|
||||
|
||||
/* Remove trailing spaces/newlines from the string. */
|
||||
|
@ -122,7 +122,7 @@ std::unique_ptr<LanguageStrings> ReadRawLanguageStrings(const char *file)
|
|||
|
||||
return ret;
|
||||
} catch (...) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ struct StringListReader : StringReader {
|
|||
|
||||
char *ReadLine(char *buffer, const char *last) override
|
||||
{
|
||||
if (this->p == this->end) return NULL;
|
||||
if (this->p == this->end) return nullptr;
|
||||
|
||||
strecpy(buffer, this->p->c_str(), last);
|
||||
this->p++;
|
||||
|
@ -237,7 +237,7 @@ public:
|
|||
if (strcmp(filename, exclude) == 0) return true;
|
||||
|
||||
auto ls = ReadRawLanguageStrings(filename);
|
||||
if (ls == NULL) return false;
|
||||
if (ls == nullptr) return false;
|
||||
|
||||
gs->raw_strings.push_back(std::move(ls));
|
||||
return true;
|
||||
|
@ -254,14 +254,14 @@ GameStrings *LoadTranslations()
|
|||
char filename[512];
|
||||
strecpy(filename, info->GetMainScript(), lastof(filename));
|
||||
char *e = strrchr(filename, PATHSEPCHAR);
|
||||
if (e == NULL) return NULL;
|
||||
if (e == nullptr) return nullptr;
|
||||
e++; // Make 'e' point after the PATHSEPCHAR
|
||||
|
||||
strecpy(e, "lang" PATHSEP "english.txt", lastof(filename));
|
||||
if (!FioCheckFileExists(filename, GAME_DIR)) return NULL;
|
||||
if (!FioCheckFileExists(filename, GAME_DIR)) return nullptr;
|
||||
|
||||
auto ls = ReadRawLanguageStrings(filename);
|
||||
if (ls == NULL) return NULL;
|
||||
if (ls == nullptr) return nullptr;
|
||||
|
||||
GameStrings *gs = new GameStrings();
|
||||
try {
|
||||
|
@ -274,7 +274,7 @@ GameStrings *LoadTranslations()
|
|||
|
||||
const char *tar_filename = info->GetTarFile();
|
||||
TarList::iterator iter;
|
||||
if (tar_filename != NULL && (iter = _tar_list[GAME_DIR].find(tar_filename)) != _tar_list[GAME_DIR].end()) {
|
||||
if (tar_filename != nullptr && (iter = _tar_list[GAME_DIR].find(tar_filename)) != _tar_list[GAME_DIR].end()) {
|
||||
/* The main script is in a tar file, so find all files that
|
||||
* are in the same tar and add them to the langfile scanner. */
|
||||
TarFileList::iterator tar;
|
||||
|
@ -297,7 +297,7 @@ GameStrings *LoadTranslations()
|
|||
return gs;
|
||||
} catch (...) {
|
||||
delete gs;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -327,7 +327,7 @@ void GameStrings::Compile()
|
|||
}
|
||||
|
||||
/** The currently loaded game strings. */
|
||||
GameStrings *_current_data = NULL;
|
||||
GameStrings *_current_data = nullptr;
|
||||
|
||||
/**
|
||||
* Get the string pointer of a particular game string.
|
||||
|
@ -348,7 +348,7 @@ void RegisterGameTranslation(Squirrel *engine)
|
|||
{
|
||||
delete _current_data;
|
||||
_current_data = LoadTranslations();
|
||||
if (_current_data == NULL) return;
|
||||
if (_current_data == nullptr) return;
|
||||
|
||||
HSQUIRRELVM vm = engine->GetVM();
|
||||
sq_pushroottable(vm);
|
||||
|
@ -373,19 +373,19 @@ void RegisterGameTranslation(Squirrel *engine)
|
|||
*/
|
||||
void ReconsiderGameScriptLanguage()
|
||||
{
|
||||
if (_current_data == NULL) return;
|
||||
if (_current_data == nullptr) return;
|
||||
|
||||
char temp[MAX_PATH];
|
||||
strecpy(temp, _current_language->file, lastof(temp));
|
||||
|
||||
/* Remove the extension */
|
||||
char *l = strrchr(temp, '.');
|
||||
assert(l != NULL);
|
||||
assert(l != nullptr);
|
||||
*l = '\0';
|
||||
|
||||
/* Skip the path */
|
||||
char *language = strrchr(temp, PATHSEPCHAR);
|
||||
assert(language != NULL);
|
||||
assert(language != nullptr);
|
||||
language++;
|
||||
|
||||
for (auto &p : _current_data->compiled_strings) {
|
||||
|
|
|
@ -23,7 +23,7 @@ struct LanguageStrings {
|
|||
const char *language; ///< Name of the language (base filename).
|
||||
StringList lines; ///< The lines of the file to pass into the parser/encoder.
|
||||
|
||||
LanguageStrings(const char *language, const char *end = NULL);
|
||||
LanguageStrings(const char *language, const char *end = nullptr);
|
||||
~LanguageStrings();
|
||||
};
|
||||
|
||||
|
|
|
@ -34,9 +34,9 @@ extern byte _sl_minor_version; ///< the minor savegame version, DO NOT USE!
|
|||
|
||||
static GamelogActionType _gamelog_action_type = GLAT_NONE; ///< action to record if anything changes
|
||||
|
||||
LoggedAction *_gamelog_action = NULL; ///< first logged action
|
||||
LoggedAction *_gamelog_action = nullptr; ///< first logged action
|
||||
uint _gamelog_actions = 0; ///< number of actions
|
||||
static LoggedAction *_current_action = NULL; ///< current action we are logging, NULL when there is no action active
|
||||
static LoggedAction *_current_action = nullptr; ///< current action we are logging, nullptr when there is no action active
|
||||
|
||||
|
||||
/**
|
||||
|
@ -81,9 +81,9 @@ void GamelogStopAction()
|
|||
{
|
||||
assert(_gamelog_action_type != GLAT_NONE); // nobody should try to stop if there is no action in progress
|
||||
|
||||
bool print = _current_action != NULL;
|
||||
bool print = _current_action != nullptr;
|
||||
|
||||
_current_action = NULL;
|
||||
_current_action = nullptr;
|
||||
_gamelog_action_type = GLAT_NONE;
|
||||
|
||||
if (print) GamelogPrintDebug(5);
|
||||
|
@ -114,9 +114,9 @@ void GamelogReset()
|
|||
assert(_gamelog_action_type == GLAT_NONE);
|
||||
GamelogFree(_gamelog_action, _gamelog_actions);
|
||||
|
||||
_gamelog_action = NULL;
|
||||
_gamelog_action = nullptr;
|
||||
_gamelog_actions = 0;
|
||||
_current_action = NULL;
|
||||
_current_action = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -132,18 +132,18 @@ static char *PrintGrfInfo(char *buf, const char *last, uint grfid, const uint8 *
|
|||
{
|
||||
char txt[40];
|
||||
|
||||
if (md5sum != NULL) {
|
||||
if (md5sum != nullptr) {
|
||||
md5sumToString(txt, lastof(txt), md5sum);
|
||||
buf += seprintf(buf, last, "GRF ID %08X, checksum %s", BSWAP32(grfid), txt);
|
||||
} else {
|
||||
buf += seprintf(buf, last, "GRF ID %08X", BSWAP32(grfid));
|
||||
}
|
||||
|
||||
if (gc != NULL) {
|
||||
if (gc != nullptr) {
|
||||
buf += seprintf(buf, last, ", filename: %s (md5sum matches)", gc->filename);
|
||||
} else {
|
||||
gc = FindGRFConfig(grfid, FGCM_ANY);
|
||||
if (gc != NULL) {
|
||||
if (gc != nullptr) {
|
||||
buf += seprintf(buf, last, ", filename: %s (matches GRFID only)", gc->filename);
|
||||
} else {
|
||||
buf += seprintf(buf, last, ", unknown GRF");
|
||||
|
@ -273,7 +273,7 @@ void GamelogPrint(GamelogPrintProc *proc)
|
|||
case GLCT_GRFREM: {
|
||||
GrfIDMapping::Pair *gm = grf_names.Find(lc->grfrem.grfid);
|
||||
buf += seprintf(buf, lastof(buffer), la->at == GLAT_LOAD ? "Missing NewGRF: " : "Removed NewGRF: ");
|
||||
buf = PrintGrfInfo(buf, lastof(buffer), lc->grfrem.grfid, NULL, gm != grf_names.End() ? gm->second.gc : NULL);
|
||||
buf = PrintGrfInfo(buf, lastof(buffer), lc->grfrem.grfid, nullptr, gm != grf_names.End() ? gm->second.gc : nullptr);
|
||||
if (gm == grf_names.End()) {
|
||||
buf += seprintf(buf, lastof(buffer), ". Gamelog inconsistency: GrfID was never added!");
|
||||
} else {
|
||||
|
@ -299,7 +299,7 @@ void GamelogPrint(GamelogPrintProc *proc)
|
|||
case GLCT_GRFPARAM: {
|
||||
GrfIDMapping::Pair *gm = grf_names.Find(lc->grfrem.grfid);
|
||||
buf += seprintf(buf, lastof(buffer), "GRF parameter changed: ");
|
||||
buf = PrintGrfInfo(buf, lastof(buffer), lc->grfparam.grfid, NULL, gm != grf_names.End() ? gm->second.gc : NULL);
|
||||
buf = PrintGrfInfo(buf, lastof(buffer), lc->grfparam.grfid, nullptr, gm != grf_names.End() ? gm->second.gc : nullptr);
|
||||
if (gm == grf_names.End()) buf += seprintf(buf, lastof(buffer), ". Gamelog inconsistency: GrfID was never added!");
|
||||
break;
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ void GamelogPrint(GamelogPrintProc *proc)
|
|||
GrfIDMapping::Pair *gm = grf_names.Find(lc->grfrem.grfid);
|
||||
buf += seprintf(buf, lastof(buffer), "GRF order changed: %08X moved %d places %s",
|
||||
BSWAP32(lc->grfmove.grfid), abs(lc->grfmove.offset), lc->grfmove.offset >= 0 ? "down" : "up" );
|
||||
buf = PrintGrfInfo(buf, lastof(buffer), lc->grfmove.grfid, NULL, gm != grf_names.End() ? gm->second.gc : NULL);
|
||||
buf = PrintGrfInfo(buf, lastof(buffer), lc->grfmove.grfid, nullptr, gm != grf_names.End() ? gm->second.gc : nullptr);
|
||||
if (gm == grf_names.End()) buf += seprintf(buf, lastof(buffer), ". Gamelog inconsistency: GrfID was never added!");
|
||||
break;
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ void GamelogPrint(GamelogPrintProc *proc)
|
|||
buf += seprintf(buf, lastof(buffer), "Rail vehicle changes length outside a depot: GRF ID %08X, internal ID 0x%X", BSWAP32(lc->grfbug.grfid), (uint)lc->grfbug.data);
|
||||
break;
|
||||
}
|
||||
buf = PrintGrfInfo(buf, lastof(buffer), lc->grfbug.grfid, NULL, gm != grf_names.End() ? gm->second.gc : NULL);
|
||||
buf = PrintGrfInfo(buf, lastof(buffer), lc->grfbug.grfid, nullptr, gm != grf_names.End() ? gm->second.gc : nullptr);
|
||||
if (gm == grf_names.End()) buf += seprintf(buf, lastof(buffer), ". Gamelog inconsistency: GrfID was never added!");
|
||||
break;
|
||||
}
|
||||
|
@ -372,21 +372,21 @@ void GamelogPrintDebug(int level)
|
|||
|
||||
/**
|
||||
* Allocates new LoggedChange and new LoggedAction if needed.
|
||||
* If there is no action active, NULL is returned.
|
||||
* If there is no action active, nullptr is returned.
|
||||
* @param ct type of change
|
||||
* @return new LoggedChange, or NULL if there is no action active
|
||||
* @return new LoggedChange, or nullptr if there is no action active
|
||||
*/
|
||||
static LoggedChange *GamelogChange(GamelogChangeType ct)
|
||||
{
|
||||
if (_current_action == NULL) {
|
||||
if (_gamelog_action_type == GLAT_NONE) return NULL;
|
||||
if (_current_action == nullptr) {
|
||||
if (_gamelog_action_type == GLAT_NONE) return nullptr;
|
||||
|
||||
_gamelog_action = ReallocT(_gamelog_action, _gamelog_actions + 1);
|
||||
_current_action = &_gamelog_action[_gamelog_actions++];
|
||||
|
||||
_current_action->at = _gamelog_action_type;
|
||||
_current_action->tick = _tick_counter;
|
||||
_current_action->change = NULL;
|
||||
_current_action->change = nullptr;
|
||||
_current_action->changes = 0;
|
||||
}
|
||||
|
||||
|
@ -416,7 +416,7 @@ void GamelogEmergency()
|
|||
*/
|
||||
bool GamelogTestEmergency()
|
||||
{
|
||||
const LoggedChange *emergency = NULL;
|
||||
const LoggedChange *emergency = nullptr;
|
||||
|
||||
const LoggedAction *laend = &_gamelog_action[_gamelog_actions];
|
||||
for (const LoggedAction *la = _gamelog_action; la != laend; la++) {
|
||||
|
@ -426,7 +426,7 @@ bool GamelogTestEmergency()
|
|||
}
|
||||
}
|
||||
|
||||
return (emergency != NULL);
|
||||
return (emergency != nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -437,7 +437,7 @@ void GamelogRevision()
|
|||
assert(_gamelog_action_type == GLAT_START || _gamelog_action_type == GLAT_LOAD);
|
||||
|
||||
LoggedChange *lc = GamelogChange(GLCT_REVISION);
|
||||
if (lc == NULL) return;
|
||||
if (lc == nullptr) return;
|
||||
|
||||
memset(lc->revision.text, 0, sizeof(lc->revision.text));
|
||||
strecpy(lc->revision.text, GetGamelogRevisionString(), lastof(lc->revision.text));
|
||||
|
@ -454,7 +454,7 @@ void GamelogMode()
|
|||
assert(_gamelog_action_type == GLAT_START || _gamelog_action_type == GLAT_LOAD || _gamelog_action_type == GLAT_CHEAT);
|
||||
|
||||
LoggedChange *lc = GamelogChange(GLCT_MODE);
|
||||
if (lc == NULL) return;
|
||||
if (lc == nullptr) return;
|
||||
|
||||
lc->mode.mode = _game_mode;
|
||||
lc->mode.landscape = _settings_game.game_creation.landscape;
|
||||
|
@ -468,7 +468,7 @@ void GamelogOldver()
|
|||
assert(_gamelog_action_type == GLAT_LOAD);
|
||||
|
||||
LoggedChange *lc = GamelogChange(GLCT_OLDVER);
|
||||
if (lc == NULL) return;
|
||||
if (lc == nullptr) return;
|
||||
|
||||
lc->oldver.type = _savegame_type;
|
||||
lc->oldver.version = (_savegame_type == SGT_OTTD ? ((uint32)_sl_version << 8 | _sl_minor_version) : _ttdp_version);
|
||||
|
@ -485,7 +485,7 @@ void GamelogSetting(const char *name, int32 oldval, int32 newval)
|
|||
assert(_gamelog_action_type == GLAT_SETTING);
|
||||
|
||||
LoggedChange *lc = GamelogChange(GLCT_SETTING);
|
||||
if (lc == NULL) return;
|
||||
if (lc == nullptr) return;
|
||||
|
||||
lc->setting.name = stredup(name);
|
||||
lc->setting.oldval = oldval;
|
||||
|
@ -499,7 +499,7 @@ void GamelogSetting(const char *name, int32 oldval, int32 newval)
|
|||
*/
|
||||
void GamelogTestRevision()
|
||||
{
|
||||
const LoggedChange *rev = NULL;
|
||||
const LoggedChange *rev = nullptr;
|
||||
|
||||
const LoggedAction *laend = &_gamelog_action[_gamelog_actions];
|
||||
for (const LoggedAction *la = _gamelog_action; la != laend; la++) {
|
||||
|
@ -509,7 +509,7 @@ void GamelogTestRevision()
|
|||
}
|
||||
}
|
||||
|
||||
if (rev == NULL || strcmp(rev->revision.text, GetGamelogRevisionString()) != 0 ||
|
||||
if (rev == nullptr || strcmp(rev->revision.text, GetGamelogRevisionString()) != 0 ||
|
||||
rev->revision.modified != _openttd_revision_modified ||
|
||||
rev->revision.newgrf != _openttd_newgrf_version) {
|
||||
GamelogRevision();
|
||||
|
@ -522,7 +522,7 @@ void GamelogTestRevision()
|
|||
*/
|
||||
void GamelogTestMode()
|
||||
{
|
||||
const LoggedChange *mode = NULL;
|
||||
const LoggedChange *mode = nullptr;
|
||||
|
||||
const LoggedAction *laend = &_gamelog_action[_gamelog_actions];
|
||||
for (const LoggedAction *la = _gamelog_action; la != laend; la++) {
|
||||
|
@ -532,7 +532,7 @@ void GamelogTestMode()
|
|||
}
|
||||
}
|
||||
|
||||
if (mode == NULL || mode->mode.mode != _game_mode || mode->mode.landscape != _settings_game.game_creation.landscape) GamelogMode();
|
||||
if (mode == nullptr || mode->mode.mode != _game_mode || mode->mode.landscape != _settings_game.game_creation.landscape) GamelogMode();
|
||||
}
|
||||
|
||||
|
||||
|
@ -547,7 +547,7 @@ static void GamelogGRFBug(uint32 grfid, byte bug, uint64 data)
|
|||
assert(_gamelog_action_type == GLAT_GRFBUG);
|
||||
|
||||
LoggedChange *lc = GamelogChange(GLCT_GRFBUG);
|
||||
if (lc == NULL) return;
|
||||
if (lc == nullptr) return;
|
||||
|
||||
lc->grfbug.data = data;
|
||||
lc->grfbug.grfid = grfid;
|
||||
|
@ -603,7 +603,7 @@ void GamelogGRFRemove(uint32 grfid)
|
|||
assert(_gamelog_action_type == GLAT_LOAD || _gamelog_action_type == GLAT_GRF);
|
||||
|
||||
LoggedChange *lc = GamelogChange(GLCT_GRFREM);
|
||||
if (lc == NULL) return;
|
||||
if (lc == nullptr) return;
|
||||
|
||||
lc->grfrem.grfid = grfid;
|
||||
}
|
||||
|
@ -619,7 +619,7 @@ void GamelogGRFAdd(const GRFConfig *newg)
|
|||
if (!IsLoggableGrfConfig(newg)) return;
|
||||
|
||||
LoggedChange *lc = GamelogChange(GLCT_GRFADD);
|
||||
if (lc == NULL) return;
|
||||
if (lc == nullptr) return;
|
||||
|
||||
lc->grfadd = newg->ident;
|
||||
}
|
||||
|
@ -634,7 +634,7 @@ void GamelogGRFCompatible(const GRFIdentifier *newg)
|
|||
assert(_gamelog_action_type == GLAT_LOAD || _gamelog_action_type == GLAT_GRF);
|
||||
|
||||
LoggedChange *lc = GamelogChange(GLCT_GRFCOMPAT);
|
||||
if (lc == NULL) return;
|
||||
if (lc == nullptr) return;
|
||||
|
||||
lc->grfcompat = *newg;
|
||||
}
|
||||
|
@ -649,7 +649,7 @@ static void GamelogGRFMove(uint32 grfid, int32 offset)
|
|||
assert(_gamelog_action_type == GLAT_GRF);
|
||||
|
||||
LoggedChange *lc = GamelogChange(GLCT_GRFMOVE);
|
||||
if (lc == NULL) return;
|
||||
if (lc == nullptr) return;
|
||||
|
||||
lc->grfmove.grfid = grfid;
|
||||
lc->grfmove.offset = offset;
|
||||
|
@ -665,7 +665,7 @@ static void GamelogGRFParameters(uint32 grfid)
|
|||
assert(_gamelog_action_type == GLAT_GRF);
|
||||
|
||||
LoggedChange *lc = GamelogChange(GLCT_GRFPARAM);
|
||||
if (lc == NULL) return;
|
||||
if (lc == nullptr) return;
|
||||
|
||||
lc->grfparam.grfid = grfid;
|
||||
}
|
||||
|
@ -679,7 +679,7 @@ void GamelogGRFAddList(const GRFConfig *newg)
|
|||
{
|
||||
assert(_gamelog_action_type == GLAT_START || _gamelog_action_type == GLAT_LOAD);
|
||||
|
||||
for (; newg != NULL; newg = newg->next) {
|
||||
for (; newg != nullptr; newg = newg->next) {
|
||||
GamelogGRFAdd(newg);
|
||||
}
|
||||
}
|
||||
|
@ -697,14 +697,14 @@ struct GRFList {
|
|||
static GRFList *GenerateGRFList(const GRFConfig *grfc)
|
||||
{
|
||||
uint n = 0;
|
||||
for (const GRFConfig *g = grfc; g != NULL; g = g->next) {
|
||||
for (const GRFConfig *g = grfc; g != nullptr; g = g->next) {
|
||||
if (IsLoggableGrfConfig(g)) n++;
|
||||
}
|
||||
|
||||
GRFList *list = (GRFList*)MallocT<byte>(sizeof(GRFList) + n * sizeof(GRFConfig*));
|
||||
|
||||
list->n = 0;
|
||||
for (const GRFConfig *g = grfc; g != NULL; g = g->next) {
|
||||
for (const GRFConfig *g = grfc; g != nullptr; g = g->next) {
|
||||
if (IsLoggableGrfConfig(g)) list->grf[list->n++] = g;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,8 +82,8 @@ static void CleanupGeneration()
|
|||
/* Show all vital windows again, because we have hidden them */
|
||||
if (_gw.threaded && _game_mode != GM_MENU) ShowVitalWindows();
|
||||
SetModalProgress(false);
|
||||
_gw.proc = NULL;
|
||||
_gw.abortp = NULL;
|
||||
_gw.proc = nullptr;
|
||||
_gw.abortp = nullptr;
|
||||
_gw.threaded = false;
|
||||
|
||||
DeleteWindowByClass(WC_MODAL_PROGRESS);
|
||||
|
@ -171,7 +171,7 @@ static void _GenerateWorld()
|
|||
if (_game_mode != GM_EDITOR) {
|
||||
Game::StartNew();
|
||||
|
||||
if (Game::GetInstance() != NULL) {
|
||||
if (Game::GetInstance() != nullptr) {
|
||||
SetGeneratingWorldProgress(GWP_RUNSCRIPT, 2500);
|
||||
_generating_world = true;
|
||||
for (i = 0; i < 2500; i++) {
|
||||
|
@ -192,7 +192,7 @@ static void _GenerateWorld()
|
|||
|
||||
SetGeneratingWorldProgress(GWP_GAME_START, 1);
|
||||
/* Call any callback */
|
||||
if (_gw.proc != NULL) _gw.proc();
|
||||
if (_gw.proc != nullptr) _gw.proc();
|
||||
IncreaseGeneratingWorldProgress(GWP_GAME_START);
|
||||
|
||||
CleanupGeneration();
|
||||
|
@ -278,7 +278,7 @@ void HandleGeneratingWorldAbortion()
|
|||
/* Clean up - in SE create an empty map, otherwise, go to intro menu */
|
||||
_switch_mode = (_game_mode == GM_EDITOR) ? SM_EDITOR : SM_MENU;
|
||||
|
||||
if (_gw.abortp != NULL) _gw.abortp();
|
||||
if (_gw.abortp != nullptr) _gw.abortp();
|
||||
|
||||
CleanupGeneration();
|
||||
|
||||
|
@ -302,7 +302,7 @@ void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_setti
|
|||
_gw.size_y = size_y;
|
||||
SetModalProgress(true);
|
||||
_gw.abort = false;
|
||||
_gw.abortp = NULL;
|
||||
_gw.abortp = nullptr;
|
||||
_gw.lc = _local_company;
|
||||
_gw.quit_thread = false;
|
||||
_gw.threaded = true;
|
||||
|
@ -345,7 +345,7 @@ void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_setti
|
|||
ShowGenerateWorldProgress();
|
||||
|
||||
/* Centre the view on the map */
|
||||
if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) {
|
||||
if (FindWindowById(WC_MAIN_WINDOW, 0) != nullptr) {
|
||||
ScrollMainWindowToTile(TileXY(MapSizeX() / 2, MapSizeY() / 2), true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,8 +60,8 @@ struct GenWorldInfo {
|
|||
CompanyID lc; ///< The local_company before generating
|
||||
uint size_x; ///< X-size of the map
|
||||
uint size_y; ///< Y-size of the map
|
||||
GWDoneProc *proc; ///< Proc that is called when done (can be NULL)
|
||||
GWAbortProc *abortp; ///< Proc that is called when aborting (can be NULL)
|
||||
GWDoneProc *proc; ///< Proc that is called when done (can be nullptr)
|
||||
GWAbortProc *abortp; ///< Proc that is called when aborting (can be nullptr)
|
||||
std::thread thread; ///< The thread we are in (joinable if a thread was created)
|
||||
};
|
||||
|
||||
|
|
|
@ -442,7 +442,7 @@ struct GenerateLandscapeWindow : public Window {
|
|||
|
||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||
{
|
||||
const StringID *strs = NULL;
|
||||
const StringID *strs = nullptr;
|
||||
switch (widget) {
|
||||
case WID_GL_MAX_HEIGHTLEVEL_TEXT:
|
||||
SetDParam(0, MAX_TILE_HEIGHT);
|
||||
|
@ -509,7 +509,7 @@ struct GenerateLandscapeWindow : public Window {
|
|||
default:
|
||||
return;
|
||||
}
|
||||
if (strs != NULL) {
|
||||
if (strs != nullptr) {
|
||||
while (*strs != INVALID_STRING_ID) {
|
||||
*size = maxdim(*size, GetStringBoundingBox(*strs++));
|
||||
}
|
||||
|
@ -761,7 +761,7 @@ struct GenerateLandscapeWindow : public Window {
|
|||
void OnQueryTextFinished(char *str) override
|
||||
{
|
||||
/* Was 'cancel' pressed? */
|
||||
if (str == NULL) return;
|
||||
if (str == nullptr) return;
|
||||
|
||||
int32 value;
|
||||
if (!StrEmpty(str)) {
|
||||
|
@ -808,14 +808,14 @@ struct GenerateLandscapeWindow : public Window {
|
|||
};
|
||||
|
||||
static WindowDesc _generate_landscape_desc(
|
||||
WDP_CENTER, NULL, 0, 0,
|
||||
WDP_CENTER, nullptr, 0, 0,
|
||||
WC_GENERATE_LANDSCAPE, WC_NONE,
|
||||
0,
|
||||
_nested_generate_landscape_widgets, lengthof(_nested_generate_landscape_widgets)
|
||||
);
|
||||
|
||||
static WindowDesc _heightmap_load_desc(
|
||||
WDP_CENTER, NULL, 0, 0,
|
||||
WDP_CENTER, nullptr, 0, 0,
|
||||
WC_GENERATE_LANDSCAPE, WC_NONE,
|
||||
0,
|
||||
_nested_heightmap_load_widgets, lengthof(_nested_heightmap_load_widgets)
|
||||
|
@ -1110,7 +1110,7 @@ static const NWidgetPart _nested_create_scenario_widgets[] = {
|
|||
};
|
||||
|
||||
static WindowDesc _create_scenario_desc(
|
||||
WDP_CENTER, NULL, 0, 0,
|
||||
WDP_CENTER, nullptr, 0, 0,
|
||||
WC_GENERATE_LANDSCAPE, WC_NONE,
|
||||
0,
|
||||
_nested_create_scenario_widgets, lengthof(_nested_create_scenario_widgets)
|
||||
|
@ -1138,7 +1138,7 @@ static const NWidgetPart _nested_generate_progress_widgets[] = {
|
|||
|
||||
|
||||
static WindowDesc _generate_progress_desc(
|
||||
WDP_CENTER, NULL, 0, 0,
|
||||
WDP_CENTER, nullptr, 0, 0,
|
||||
WC_MODAL_PROGRESS, WC_NONE,
|
||||
0,
|
||||
_nested_generate_progress_widgets, lengthof(_nested_generate_progress_widgets)
|
||||
|
|
28
src/gfx.cpp
28
src/gfx.cpp
|
@ -53,8 +53,8 @@ static byte _stringwidth_table[FS_END][224]; ///< Cache containing width of ofte
|
|||
DrawPixelInfo *_cur_dpi;
|
||||
byte _colour_gradient[COLOUR_END][8];
|
||||
|
||||
static void GfxMainBlitterViewport(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub = NULL, SpriteID sprite_id = SPR_CURSOR_MOUSE);
|
||||
static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub = NULL, SpriteID sprite_id = SPR_CURSOR_MOUSE, ZoomLevel zoom = ZOOM_LVL_NORMAL);
|
||||
static void GfxMainBlitterViewport(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub = nullptr, SpriteID sprite_id = SPR_CURSOR_MOUSE);
|
||||
static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub = nullptr, SpriteID sprite_id = SPR_CURSOR_MOUSE, ZoomLevel zoom = ZOOM_LVL_NORMAL);
|
||||
|
||||
static ReusableBuffer<uint8> _cursor_backup;
|
||||
|
||||
|
@ -76,7 +76,7 @@ static const uint DIRTY_BLOCK_HEIGHT = 8;
|
|||
static const uint DIRTY_BLOCK_WIDTH = 64;
|
||||
|
||||
static uint _dirty_bytes_per_line = 0;
|
||||
static byte *_dirty_blocks = NULL;
|
||||
static byte *_dirty_blocks = nullptr;
|
||||
extern uint _dirty_block_colour;
|
||||
|
||||
void GfxScroll(int left, int top, int width, int height, int xo, int yo)
|
||||
|
@ -367,7 +367,7 @@ static int DrawLayoutLine(const ParagraphLayouter::Line &line, int y, int left,
|
|||
|
||||
truncation &= max_w < w; // Whether we need to do truncation.
|
||||
int dot_width = 0; // Cache for the width of the dot.
|
||||
const Sprite *dot_sprite = NULL; // Cache for the sprite of the dot.
|
||||
const Sprite *dot_sprite = nullptr; // Cache for the sprite of the dot.
|
||||
|
||||
if (truncation) {
|
||||
/*
|
||||
|
@ -734,11 +734,11 @@ Point GetCharPosInString(const char *str, const char *ch, FontSize start_fontsiz
|
|||
* @param str String to test.
|
||||
* @param x Position relative to the start of the string.
|
||||
* @param start_fontsize Font size to start the text with.
|
||||
* @return Pointer to the character at the position or NULL if there is no character at the position.
|
||||
* @return Pointer to the character at the position or nullptr if there is no character at the position.
|
||||
*/
|
||||
const char *GetCharAtPosition(const char *str, int x, FontSize start_fontsize)
|
||||
{
|
||||
if (x < 0) return NULL;
|
||||
if (x < 0) return nullptr;
|
||||
|
||||
Layouter layout(str, INT32_MAX, TC_FROMSTRING, start_fontsize);
|
||||
return layout.GetCharAtPosition(x);
|
||||
|
@ -768,7 +768,7 @@ Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
|
|||
{
|
||||
const Sprite *sprite = GetSprite(sprid, ST_NORMAL);
|
||||
|
||||
if (offset != NULL) {
|
||||
if (offset != nullptr) {
|
||||
offset->x = UnScaleByZoom(sprite->x_offs, zoom);
|
||||
offset->y = UnScaleByZoom(sprite->y_offs, zoom);
|
||||
}
|
||||
|
@ -874,7 +874,7 @@ static void GfxBlitter(const Sprite * const sprite, int x, int y, BlitterMode mo
|
|||
x += sprite->x_offs;
|
||||
y += sprite->y_offs;
|
||||
|
||||
if (sub == NULL) {
|
||||
if (sub == nullptr) {
|
||||
/* No clipping. */
|
||||
bp.skip_left = 0;
|
||||
bp.skip_top = 0;
|
||||
|
@ -1011,7 +1011,7 @@ void DoPaletteAnimations()
|
|||
uint i;
|
||||
uint j;
|
||||
|
||||
if (blitter != NULL && blitter->UsePaletteAnimation() == Blitter::PALETTE_ANIMATION_NONE) {
|
||||
if (blitter != nullptr && blitter->UsePaletteAnimation() == Blitter::PALETTE_ANIMATION_NONE) {
|
||||
palette_animation_counter = 0;
|
||||
}
|
||||
|
||||
|
@ -1096,7 +1096,7 @@ void DoPaletteAnimations()
|
|||
if (j >= EPV_CYCLES_GLITTER_WATER) j -= EPV_CYCLES_GLITTER_WATER;
|
||||
}
|
||||
|
||||
if (blitter != NULL && blitter->UsePaletteAnimation() == Blitter::PALETTE_ANIMATION_NONE) {
|
||||
if (blitter != nullptr && blitter->UsePaletteAnimation() == Blitter::PALETTE_ANIMATION_NONE) {
|
||||
palette_animation_counter = old_tc;
|
||||
} else {
|
||||
if (memcmp(old_val, &_cur_palette.palette[PALETTE_ANIM_START], sizeof(old_val)) != 0 && _cur_palette.count_dirty == 0) {
|
||||
|
@ -1203,7 +1203,7 @@ void ScreenSizeChanged()
|
|||
void UndrawMouseCursor()
|
||||
{
|
||||
/* Don't undraw the mouse cursor if the screen is not ready */
|
||||
if (_screen.dst_ptr == NULL) return;
|
||||
if (_screen.dst_ptr == nullptr) return;
|
||||
|
||||
if (_cursor.visible) {
|
||||
Blitter *blitter = BlitterFactory::GetCurrentBlitter();
|
||||
|
@ -1216,7 +1216,7 @@ void UndrawMouseCursor()
|
|||
void DrawMouseCursor()
|
||||
{
|
||||
/* Don't draw the mouse cursor if the screen is not ready */
|
||||
if (_screen.dst_ptr == NULL) return;
|
||||
if (_screen.dst_ptr == nullptr) return;
|
||||
|
||||
Blitter *blitter = BlitterFactory::GetCurrentBlitter();
|
||||
|
||||
|
@ -1578,7 +1578,7 @@ static void SwitchAnimatedCursor()
|
|||
{
|
||||
const AnimCursor *cur = _cursor.animate_cur;
|
||||
|
||||
if (cur == NULL || cur->sprite == AnimCursor::LAST) cur = _cursor.animate_list;
|
||||
if (cur == nullptr || cur->sprite == AnimCursor::LAST) cur = _cursor.animate_list;
|
||||
|
||||
SetCursorSprite(cur->sprite, _cursor.sprite_seq[0].pal);
|
||||
|
||||
|
@ -1628,7 +1628,7 @@ void SetMouseCursor(CursorID sprite, PaletteID pal)
|
|||
void SetAnimatedMouseCursor(const AnimCursor *table)
|
||||
{
|
||||
_cursor.animate_list = table;
|
||||
_cursor.animate_cur = NULL;
|
||||
_cursor.animate_cur = nullptr;
|
||||
_cursor.sprite_seq[0].pal = PAL_NONE;
|
||||
SwitchAnimatedCursor();
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ extern Dimension _cur_resolution;
|
|||
extern Palette _cur_palette; ///< Current palette
|
||||
|
||||
void HandleKeypress(uint keycode, WChar key);
|
||||
void HandleTextInput(const char *str, bool marked = false, const char *caret = NULL, const char *insert_location = NULL, const char *replacement_end = NULL);
|
||||
void HandleTextInput(const char *str, bool marked = false, const char *caret = nullptr, const char *insert_location = nullptr, const char *replacement_end = nullptr);
|
||||
void HandleCtrlChanged();
|
||||
void HandleMouseEvents();
|
||||
void UpdateWindows();
|
||||
|
@ -88,9 +88,9 @@ static const int DRAW_STRING_BUFFER = 2048;
|
|||
void RedrawScreenRect(int left, int top, int right, int bottom);
|
||||
void GfxScroll(int left, int top, int width, int height, int xo, int yo);
|
||||
|
||||
Dimension GetSpriteSize(SpriteID sprid, Point *offset = NULL, ZoomLevel zoom = ZOOM_LVL_GUI);
|
||||
void DrawSpriteViewport(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = NULL);
|
||||
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = NULL, ZoomLevel zoom = ZOOM_LVL_GUI);
|
||||
Dimension GetSpriteSize(SpriteID sprid, Point *offset = nullptr, ZoomLevel zoom = ZOOM_LVL_GUI);
|
||||
void DrawSpriteViewport(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = nullptr);
|
||||
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = nullptr, ZoomLevel zoom = ZOOM_LVL_GUI);
|
||||
|
||||
/** How to align the to-be drawn text. */
|
||||
enum StringAlignment {
|
||||
|
|
|
@ -174,7 +174,7 @@ public:
|
|||
std::unique_ptr<const Line> NextLine(int max_width) override
|
||||
{
|
||||
icu::ParagraphLayout::Line *l = p->nextLine(max_width);
|
||||
return std::unique_ptr<const Line>(l == NULL ? NULL : new ICULine(l));
|
||||
return std::unique_ptr<const Line>(l == nullptr ? nullptr : new ICULine(l));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -208,10 +208,10 @@ public:
|
|||
LEErrorCode status = LE_NO_ERROR;
|
||||
/* ParagraphLayout does not copy "buff", so it must stay valid.
|
||||
* "runs" is copied according to the ICU source, but the documentation does not specify anything, so this might break somewhen. */
|
||||
icu::ParagraphLayout *p = new icu::ParagraphLayout(buff, length, &runs, NULL, NULL, NULL, _current_text_dir == TD_RTL ? UBIDI_DEFAULT_RTL : UBIDI_DEFAULT_LTR, false, status);
|
||||
icu::ParagraphLayout *p = new icu::ParagraphLayout(buff, length, &runs, nullptr, nullptr, nullptr, _current_text_dir == TD_RTL ? UBIDI_DEFAULT_RTL : UBIDI_DEFAULT_LTR, false, status);
|
||||
if (status != LE_NO_ERROR) {
|
||||
delete p;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new ICUParagraphLayout(p);
|
||||
|
@ -234,7 +234,7 @@ public:
|
|||
* visual runs.
|
||||
*
|
||||
* One constructs this class with the text that needs to be split into
|
||||
* lines. Then nextLine is called with the maximum width until NULL is
|
||||
* lines. Then nextLine is called with the maximum width until nullptr is
|
||||
* returned. Each nextLine call creates VisualRuns which contain the
|
||||
* length of text that are to be drawn with the same font. In other
|
||||
* words, the result of this class is a list of sub strings with their
|
||||
|
@ -358,9 +358,9 @@ FallbackParagraphLayout::FallbackVisualRun::FallbackVisualRun(FallbackVisualRun
|
|||
this->glyph_to_char = other.glyph_to_char;
|
||||
this->glyphs = other.glyphs;
|
||||
|
||||
other.positions = NULL;
|
||||
other.glyph_to_char = NULL;
|
||||
other.glyphs = NULL;
|
||||
other.positions = nullptr;
|
||||
other.glyph_to_char = nullptr;
|
||||
other.glyphs = nullptr;
|
||||
}
|
||||
|
||||
/** Free all data. */
|
||||
|
@ -496,7 +496,7 @@ void FallbackParagraphLayout::Reflow()
|
|||
/**
|
||||
* Construct a new line with a maximum width.
|
||||
* @param max_width The maximum width of the string.
|
||||
* @return A Line, or NULL when at the end of the paragraph.
|
||||
* @return A Line, or nullptr when at the end of the paragraph.
|
||||
*/
|
||||
std::unique_ptr<const ParagraphLayouter::Line> FallbackParagraphLayout::NextLine(int max_width)
|
||||
{
|
||||
|
@ -504,13 +504,13 @@ std::unique_ptr<const ParagraphLayouter::Line> FallbackParagraphLayout::NextLine
|
|||
* - split a line at a newline character, or at a space where we can break a line.
|
||||
* - split for a visual run whenever a new line happens, or the font changes.
|
||||
*/
|
||||
if (this->buffer == NULL) return NULL;
|
||||
if (this->buffer == nullptr) return nullptr;
|
||||
|
||||
std::unique_ptr<FallbackLine> l(new FallbackLine());
|
||||
|
||||
if (*this->buffer == '\0') {
|
||||
/* Only a newline. */
|
||||
this->buffer = NULL;
|
||||
this->buffer = nullptr;
|
||||
l->emplace_back(this->runs.front().second, this->buffer, 0, 0);
|
||||
return std::move(l); // Not supposed to be needed, but clang-3.8 barfs otherwise.
|
||||
}
|
||||
|
@ -526,7 +526,7 @@ std::unique_ptr<const ParagraphLayouter::Line> FallbackParagraphLayout::NextLine
|
|||
const WChar *next_run = this->buffer_begin + iter->first;
|
||||
|
||||
const WChar *begin = this->buffer;
|
||||
const WChar *last_space = NULL;
|
||||
const WChar *last_space = nullptr;
|
||||
const WChar *last_char;
|
||||
int width = 0;
|
||||
for (;;) {
|
||||
|
@ -534,7 +534,7 @@ std::unique_ptr<const ParagraphLayouter::Line> FallbackParagraphLayout::NextLine
|
|||
last_char = this->buffer;
|
||||
|
||||
if (c == '\0') {
|
||||
this->buffer = NULL;
|
||||
this->buffer = nullptr;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -547,7 +547,7 @@ std::unique_ptr<const ParagraphLayouter::Line> FallbackParagraphLayout::NextLine
|
|||
next_run = this->buffer_begin + iter->first;
|
||||
begin = this->buffer;
|
||||
|
||||
last_space = NULL;
|
||||
last_space = nullptr;
|
||||
}
|
||||
|
||||
if (IsWhitespace(c)) last_space = this->buffer;
|
||||
|
@ -561,11 +561,11 @@ std::unique_ptr<const ParagraphLayouter::Line> FallbackParagraphLayout::NextLine
|
|||
if (width == char_width) {
|
||||
/* The character is wider than allowed width; don't know
|
||||
* what to do with this case... bail out! */
|
||||
this->buffer = NULL;
|
||||
this->buffer = nullptr;
|
||||
return std::move(l); // Not supposed to be needed, but clang-3.8 barfs otherwise.
|
||||
}
|
||||
|
||||
if (last_space == NULL) {
|
||||
if (last_space == nullptr) {
|
||||
/* No space has been found. Just terminate at our current
|
||||
* location. This usually happens for languages that do not
|
||||
* require spaces in strings, like Chinese, Japanese and
|
||||
|
@ -595,7 +595,7 @@ std::unique_ptr<const ParagraphLayouter::Line> FallbackParagraphLayout::NextLine
|
|||
/**
|
||||
* Helper for getting a ParagraphLayouter of the given type.
|
||||
*
|
||||
* @note In case no ParagraphLayouter could be constructed, line.layout will be NULL.
|
||||
* @note In case no ParagraphLayouter could be constructed, line.layout will be nullptr.
|
||||
* @param line The cache item to store our layouter in.
|
||||
* @param str The string to create a layouter for.
|
||||
* @param state The state of the font and color.
|
||||
|
@ -604,7 +604,7 @@ std::unique_ptr<const ParagraphLayouter::Line> FallbackParagraphLayout::NextLine
|
|||
template <typename T>
|
||||
static inline void GetLayouter(Layouter::LineCacheItem &line, const char *&str, FontState &state)
|
||||
{
|
||||
if (line.buffer != NULL) free(line.buffer);
|
||||
if (line.buffer != nullptr) free(line.buffer);
|
||||
|
||||
typename T::CharType *buff_begin = MallocT<typename T::CharType>(DRAW_STRING_BUFFER);
|
||||
const typename T::CharType *buffer_last = buff_begin + DRAW_STRING_BUFFER;
|
||||
|
@ -679,7 +679,7 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi
|
|||
}
|
||||
|
||||
LineCacheItem& line = GetCachedParagraphLayout(str, lineend - str, state);
|
||||
if (line.layout != NULL) {
|
||||
if (line.layout != nullptr) {
|
||||
/* Line is in cache */
|
||||
str = lineend + 1;
|
||||
state = line.state_after;
|
||||
|
@ -693,7 +693,7 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi
|
|||
|
||||
#ifdef WITH_ICU_LX
|
||||
GetLayouter<ICUParagraphLayoutFactory>(line, str, state);
|
||||
if (line.layout == NULL) {
|
||||
if (line.layout == nullptr) {
|
||||
static bool warned = false;
|
||||
if (!warned) {
|
||||
DEBUG(misc, 0, "ICU layouter bailed on the font. Falling back to the fallback layouter");
|
||||
|
@ -706,9 +706,9 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi
|
|||
#endif
|
||||
|
||||
#ifdef WITH_UNISCRIBE
|
||||
if (line.layout == NULL) {
|
||||
if (line.layout == nullptr) {
|
||||
GetLayouter<UniscribeParagraphLayoutFactory>(line, str, state);
|
||||
if (line.layout == NULL) {
|
||||
if (line.layout == nullptr) {
|
||||
state = old_state;
|
||||
str = old_str;
|
||||
}
|
||||
|
@ -716,16 +716,16 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi
|
|||
#endif
|
||||
|
||||
#ifdef WITH_COCOA
|
||||
if (line.layout == NULL) {
|
||||
if (line.layout == nullptr) {
|
||||
GetLayouter<CoreTextParagraphLayoutFactory>(line, str, state);
|
||||
if (line.layout == NULL) {
|
||||
if (line.layout == nullptr) {
|
||||
state = old_state;
|
||||
str = old_str;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (line.layout == NULL) {
|
||||
if (line.layout == nullptr) {
|
||||
GetLayouter<FallbackParagraphLayoutFactory>(line, str, state);
|
||||
}
|
||||
}
|
||||
|
@ -733,7 +733,7 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi
|
|||
/* Move all lines into a local cache so we can reuse them later on more easily. */
|
||||
for (;;) {
|
||||
auto l = line.layout->NextLine(maxw);
|
||||
if (l == NULL) break;
|
||||
if (l == nullptr) break;
|
||||
this->push_back(std::move(l));
|
||||
}
|
||||
} while (c != '\0');
|
||||
|
@ -804,7 +804,7 @@ Point Layouter::GetCharPosition(const char *ch) const
|
|||
/**
|
||||
* Get the character that is at a position.
|
||||
* @param x Position in the string.
|
||||
* @return Pointer to the character at the position or NULL if no character is at the position.
|
||||
* @return Pointer to the character at the position or nullptr if no character is at the position.
|
||||
*/
|
||||
const char *Layouter::GetCharAtPosition(int x) const
|
||||
{
|
||||
|
@ -835,7 +835,7 @@ const char *Layouter::GetCharAtPosition(int x) const
|
|||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -883,7 +883,7 @@ void Layouter::ResetFontCache(FontSize size)
|
|||
*/
|
||||
Layouter::LineCacheItem &Layouter::GetCachedParagraphLayout(const char *str, size_t len, const FontState &state)
|
||||
{
|
||||
if (linecache == NULL) {
|
||||
if (linecache == nullptr) {
|
||||
/* Create linecache on first access to avoid trouble with initialisation order of static variables. */
|
||||
linecache = new LineCache();
|
||||
}
|
||||
|
@ -899,7 +899,7 @@ Layouter::LineCacheItem &Layouter::GetCachedParagraphLayout(const char *str, siz
|
|||
*/
|
||||
void Layouter::ResetLineCache()
|
||||
{
|
||||
if (linecache != NULL) linecache->clear();
|
||||
if (linecache != nullptr) linecache->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -907,7 +907,7 @@ void Layouter::ResetLineCache()
|
|||
*/
|
||||
void Layouter::ReduceLineCache()
|
||||
{
|
||||
if (linecache != NULL) {
|
||||
if (linecache != nullptr) {
|
||||
/* TODO LRU cache would be fancy, but not exactly necessary */
|
||||
if (linecache->size() > 4096) ResetLineCache();
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ public:
|
|||
FontState state_after; ///< Font state after the line.
|
||||
ParagraphLayouter *layout; ///< Layout of the line.
|
||||
|
||||
LineCacheItem() : buffer(NULL), layout(NULL) {}
|
||||
LineCacheItem() : buffer(nullptr), layout(nullptr) {}
|
||||
~LineCacheItem() { delete layout; free(buffer); }
|
||||
};
|
||||
private:
|
||||
|
|
|
@ -120,7 +120,7 @@ static void LoadGrfFileIndexed(const char *filename, const SpriteID *index_tbl,
|
|||
*/
|
||||
void CheckExternalFiles()
|
||||
{
|
||||
if (BaseGraphics::GetUsedSet() == NULL || BaseSounds::GetUsedSet() == NULL) return;
|
||||
if (BaseGraphics::GetUsedSet() == nullptr || BaseSounds::GetUsedSet() == nullptr) return;
|
||||
|
||||
const GraphicsSet *used_set = BaseGraphics::GetUsedSet();
|
||||
|
||||
|
@ -265,7 +265,7 @@ static bool SwitchNewGRFBlitter()
|
|||
*/
|
||||
uint depth_wanted_by_base = BaseGraphics::GetUsedSet()->blitter == BLT_32BPP ? 32 : 8;
|
||||
uint depth_wanted_by_grf = _support8bpp == S8BPP_NONE ? 32 : 8;
|
||||
for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) {
|
||||
for (GRFConfig *c = _grfconfig; c != nullptr; c = c->next) {
|
||||
if (c->status == GCS_DISABLED || c->status == GCS_NOT_FOUND || HasBit(c->flags, GCF_INIT_ONLY)) continue;
|
||||
if (c->palette & GRFP_BLT_32BPP) depth_wanted_by_grf = 32;
|
||||
}
|
||||
|
@ -307,18 +307,18 @@ static bool SwitchNewGRFBlitter()
|
|||
VideoDriver::GetInstance()->ReleaseBlitterLock();
|
||||
return false;
|
||||
}
|
||||
if (BlitterFactory::GetBlitterFactory(repl_blitter) == NULL) continue;
|
||||
if (BlitterFactory::GetBlitterFactory(repl_blitter) == nullptr) continue;
|
||||
|
||||
DEBUG(misc, 1, "Switching blitter from '%s' to '%s'... ", cur_blitter, repl_blitter);
|
||||
Blitter *new_blitter = BlitterFactory::SelectBlitter(repl_blitter);
|
||||
if (new_blitter == NULL) NOT_REACHED();
|
||||
if (new_blitter == nullptr) NOT_REACHED();
|
||||
DEBUG(misc, 1, "Successfully switched to %s.", repl_blitter);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!VideoDriver::GetInstance()->AfterBlitterChange()) {
|
||||
/* Failed to switch blitter, let's hope we can return to the old one. */
|
||||
if (BlitterFactory::SelectBlitter(cur_blitter) == NULL || !VideoDriver::GetInstance()->AfterBlitterChange()) usererror("Failed to reinitialize video driver. Specify a fixed blitter in the config");
|
||||
if (BlitterFactory::SelectBlitter(cur_blitter) == nullptr || !VideoDriver::GetInstance()->AfterBlitterChange()) usererror("Failed to reinitialize video driver. Specify a fixed blitter in the config");
|
||||
}
|
||||
|
||||
VideoDriver::GetInstance()->ReleaseBlitterLock();
|
||||
|
@ -362,7 +362,7 @@ bool GraphicsSet::FillSetDetails(IniFile *ini, const char *path, const char *ful
|
|||
|
||||
/* Get optional blitter information. */
|
||||
item = metadata->GetItem("blitter", false);
|
||||
this->blitter = (item != NULL && *item->value == '3') ? BLT_32BPP : BLT_8BPP;
|
||||
this->blitter = (item != nullptr && *item->value == '3') ? BLT_32BPP : BLT_8BPP;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -380,7 +380,7 @@ bool GraphicsSet::FillSetDetails(IniFile *ini, const char *path, const char *ful
|
|||
{
|
||||
size_t size = 0;
|
||||
FILE *f = FioFOpenFile(file->filename, "rb", subdir, &size);
|
||||
if (f == NULL) return MD5File::CR_NO_FILE;
|
||||
if (f == nullptr) return MD5File::CR_NO_FILE;
|
||||
|
||||
size_t max = GRFGetSizeOfDataSection(f);
|
||||
|
||||
|
@ -404,7 +404,7 @@ MD5File::ChecksumResult MD5File::CheckMD5(Subdirectory subdir, size_t max_size)
|
|||
size_t size;
|
||||
FILE *f = FioFOpenFile(this->filename, "rb", subdir, &size);
|
||||
|
||||
if (f == NULL) return CR_NO_FILE;
|
||||
if (f == nullptr) return CR_NO_FILE;
|
||||
|
||||
size = min(size, max_size);
|
||||
|
||||
|
@ -434,14 +434,14 @@ template <class T, size_t Tnum_files, bool Tsearch_in_tars>
|
|||
template <class Tbase_set>
|
||||
/* static */ bool BaseMedia<Tbase_set>::DetermineBestSet()
|
||||
{
|
||||
if (BaseMedia<Tbase_set>::used_set != NULL) return true;
|
||||
if (BaseMedia<Tbase_set>::used_set != nullptr) return true;
|
||||
|
||||
const Tbase_set *best = NULL;
|
||||
for (const Tbase_set *c = BaseMedia<Tbase_set>::available_sets; c != NULL; c = c->next) {
|
||||
const Tbase_set *best = nullptr;
|
||||
for (const Tbase_set *c = BaseMedia<Tbase_set>::available_sets; c != nullptr; c = c->next) {
|
||||
/* Skip unusable sets */
|
||||
if (c->GetNumMissing() != 0) continue;
|
||||
|
||||
if (best == NULL ||
|
||||
if (best == nullptr ||
|
||||
(best->fallback && !c->fallback) ||
|
||||
best->valid_files < c->valid_files ||
|
||||
(best->valid_files == c->valid_files && (
|
||||
|
@ -452,7 +452,7 @@ template <class Tbase_set>
|
|||
}
|
||||
|
||||
BaseMedia<Tbase_set>::used_set = best;
|
||||
return BaseMedia<Tbase_set>::used_set != NULL;
|
||||
return BaseMedia<Tbase_set>::used_set != nullptr;
|
||||
}
|
||||
|
||||
template <class Tbase_set>
|
||||
|
|
|
@ -93,7 +93,7 @@ CommandCost CmdCreateGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|||
g->dst = p2;
|
||||
g->company = company;
|
||||
g->text = stredup(text);
|
||||
g->progress = NULL;
|
||||
g->progress = nullptr;
|
||||
g->completed = false;
|
||||
|
||||
if (g->company == INVALID_COMPANY) {
|
||||
|
@ -187,7 +187,7 @@ CommandCost CmdSetGoalProgress(TileIndex tile, DoCommandFlag flags, uint32 p1, u
|
|||
Goal *g = Goal::Get(p1);
|
||||
free(g->progress);
|
||||
if (StrEmpty(text)) {
|
||||
g->progress = NULL;
|
||||
g->progress = nullptr;
|
||||
} else {
|
||||
g->progress = stredup(text);
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue