Merge branch 'origin/master' commit 'a499e9acdd385b57dd43caf88af3a6f7f53716ba'

This commit is contained in:
pelya
2020-03-20 00:10:46 +02:00
1448 changed files with 32573 additions and 27146 deletions

View File

@@ -1,5 +1,3 @@
/* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
@@ -40,7 +38,7 @@
#include "safeguards.h"
void CcTerraform(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
void CcTerraform(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
{
if (result.Succeeded()) {
if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_SPLAT_OTHER, tile);
@@ -165,14 +163,14 @@ struct TerraformToolbarWindow : Window {
{
}
virtual void OnInit()
void OnInit() override
{
/* Don't show the place object button when there are no objects to place. */
NWidgetStacked *show_object = this->GetWidget<NWidgetStacked>(WID_TT_SHOW_PLACE_OBJECT);
show_object->SetDisplayedPlane(ObjectClass::GetUIClassCount() != 0 ? 0 : SZSP_NONE);
}
virtual void OnClick(Point pt, int widget, int click_count)
void OnClick(Point pt, int widget, int click_count) override
{
if (widget < WID_TT_BUTTONS_START) return;
@@ -219,7 +217,7 @@ struct TerraformToolbarWindow : Window {
}
}
virtual void OnPlaceObject(Point pt, TileIndex tile)
void OnPlaceObject(Point pt, TileIndex tile) override
{
switch (this->last_user_action) {
case WID_TT_LOWER_LAND: // Lower land button
@@ -254,19 +252,19 @@ struct TerraformToolbarWindow : Window {
}
}
virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
{
VpSelectTilesWithMethod(pt.x, pt.y, select_method);
}
virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number)
Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override
{
Point pt = GetToolbarAlignedWindowPosition(sm_width);
pt.y += sm_height;
return pt;
}
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
{
if (pt.x != -1) {
switch (select_proc) {
@@ -282,7 +280,7 @@ struct TerraformToolbarWindow : Window {
}
}
virtual void OnPlaceObjectAbort()
void OnPlaceObjectAbort() override
{
MoveAllHiddenWindowsBackToScreen();
this->RaiseButtons();
@@ -309,8 +307,8 @@ struct TerraformToolbarWindow : Window {
static EventState TerraformToolbarGlobalHotkeys(int hotkey)
{
if (_game_mode != GM_NORMAL) return ES_NOT_HANDLED;
Window *w = ShowTerraformToolbar(NULL);
if (w == NULL) return ES_NOT_HANDLED;
Window *w = ShowTerraformToolbar(nullptr);
if (w == nullptr) return ES_NOT_HANDLED;
return w->OnHotkey(hotkey);
}
@@ -369,14 +367,14 @@ static WindowDesc _terraform_desc(
/**
* Show the toolbar for terraforming in the game.
* @param link The toolbar we might want to link to.
* @return The allocated toolbar if the window was newly opened, else \c NULL.
* @return The allocated toolbar if the window was newly opened, else \c nullptr.
*/
Window *ShowTerraformToolbar(Window *link)
{
if (!Company::IsValidID(_local_company)) return NULL;
if (!Company::IsValidID(_local_company)) return nullptr;
Window *w;
if (link == NULL) {
if (link == nullptr) {
w = AllocateWindowDescFront<TerraformToolbarWindow>(&_terraform_desc, 0);
return w;
}
@@ -518,8 +516,7 @@ static void ResetLandscapeConfirmationCallback(Window *w, bool confirmed)
_generating_world = true;
/* Delete all companies */
Company *c;
FOR_ALL_COMPANIES(c) {
for (Company *c : Company::Iterate()) {
ChangeOwnershipOfCompanyItems(c->index, INVALID_OWNER);
delete c;
}
@@ -527,8 +524,7 @@ static void ResetLandscapeConfirmationCallback(Window *w, bool confirmed)
_generating_world = false;
/* Delete all station signs */
BaseStation *st;
FOR_ALL_BASE_STATIONS(st) {
for (BaseStation *st : BaseStation::Iterate()) {
/* There can be buoys, remove them */
if (IsBuoyTile(st->xy)) DoCommand(st->xy, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
if (!st->IsInUse()) delete st;
@@ -554,7 +550,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window {
this->last_user_action = WIDGET_LIST_END;
}
virtual void OnPaint()
void OnPaint() override
{
this->DrawWidgets();
@@ -563,7 +559,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window {
}
}
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{
if (widget != WID_ETT_DOTS) return;
@@ -571,7 +567,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window {
size->height = max<uint>(size->height, ScaleGUITrad(31));
}
virtual void DrawWidget(const Rect &r, int widget) const
void DrawWidget(const Rect &r, int widget) const override
{
if (widget != WID_ETT_DOTS) return;
@@ -588,7 +584,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window {
} while (--n);
}
virtual void OnClick(Point pt, int widget, int click_count)
void OnClick(Point pt, int widget, int click_count) override
{
if (widget < WID_ETT_BUTTONS_START) return;
@@ -647,14 +643,14 @@ struct ScenarioEditorLandscapeGenerationWindow : Window {
break;
case WID_ETT_RESET_LANDSCAPE: // Reset landscape
ShowQuery(STR_QUERY_RESET_LANDSCAPE_CAPTION, STR_RESET_LANDSCAPE_CONFIRMATION_TEXT, NULL, ResetLandscapeConfirmationCallback);
ShowQuery(STR_QUERY_RESET_LANDSCAPE_CAPTION, STR_RESET_LANDSCAPE_CONFIRMATION_TEXT, nullptr, ResetLandscapeConfirmationCallback);
break;
default: NOT_REACHED();
}
}
virtual void OnTimeout()
void OnTimeout() override
{
for (uint i = WID_ETT_START; i < this->nested_array_size; i++) {
if (i == WID_ETT_BUTTONS_START) i = WID_ETT_BUTTONS_END; // skip the buttons
@@ -665,7 +661,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window {
}
}
virtual void OnPlaceObject(Point pt, TileIndex tile)
void OnPlaceObject(Point pt, TileIndex tile) override
{
switch (this->last_user_action) {
case WID_ETT_DEMOLISH: // Demolish aka dynamite button
@@ -696,12 +692,12 @@ struct ScenarioEditorLandscapeGenerationWindow : Window {
}
}
virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
{
VpSelectTilesWithMethod(pt.x, pt.y, select_method);
}
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
{
if (pt.x != -1) {
switch (select_proc) {
@@ -718,7 +714,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window {
}
}
virtual void OnPlaceObjectAbort()
void OnPlaceObjectAbort() override
{
this->RaiseButtons();
this->SetDirty();
@@ -736,7 +732,7 @@ static EventState TerraformToolbarEditorGlobalHotkeys(int hotkey)
{
if (_game_mode != GM_EDITOR) return ES_NOT_HANDLED;
Window *w = ShowEditorTerraformToolbar();
if (w == NULL) return ES_NOT_HANDLED;
if (w == nullptr) return ES_NOT_HANDLED;
return w->OnHotkey(hotkey);
}
@@ -763,7 +759,7 @@ static WindowDesc _scen_edit_land_gen_desc(
/**
* Show the toolbar for terraforming in the scenario editor.
* @return The allocated toolbar if the window was newly opened, else \c NULL.
* @return The allocated toolbar if the window was newly opened, else \c nullptr.
*/
Window *ShowEditorTerraformToolbar()
{