Merge 1.10.0-beta1

This commit is contained in:
dP
2019-11-01 16:08:44 +03:00
parent 4bf7002873
commit ceea4c88be
920 changed files with 26309 additions and 16944 deletions

View File

@@ -24,6 +24,7 @@
#include "tilehighlight_func.h"
#include "network/network.h"
#include "station_base.h"
#include "industry.h"
#include "waypoint_base.h"
#include "core/geometry_func.hpp"
#include "hotkeys.h"
@@ -311,7 +312,7 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
/* Check range for aircraft. */
if (v->type == VEH_AIRCRAFT && Aircraft::From(v)->GetRange() > 0 && order->IsGotoOrder()) {
const Order *next = order->next != NULL ? order->next : v->GetFirstOrder();
const Order *next = order->next != nullptr ? order->next : v->GetFirstOrder();
if (GetOrderDistance(order, next, v) > Aircraft::From(v)->acache.cached_max_range_sqr) SetDParam(8, STR_ORDER_OUT_OF_RANGE);
}
@@ -474,20 +475,29 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
return order;
}
if (IsTileType(tile, MP_STATION)) {
StationID st_index = GetStationIndex(tile);
const Station *st = Station::Get(st_index);
/* check for station or industry with neutral station */
if (IsTileType(tile, MP_STATION) || IsTileType(tile, MP_INDUSTRY)) {
const Station *st = nullptr;
if (st->owner == _local_company || st->owner == OWNER_NONE) {
if (IsTileType(tile, MP_STATION)) {
st = Station::GetByTile(tile);
} else {
const Industry *in = Industry::GetByTile(tile);
st = in->neutral_station;
}
if (st != nullptr && (st->owner == _local_company || st->owner == OWNER_NONE)) {
byte facil;
(facil = FACIL_DOCK, v->type == VEH_SHIP) ||
(facil = FACIL_TRAIN, v->type == VEH_TRAIN) ||
(facil = FACIL_AIRPORT, v->type == VEH_AIRCRAFT) ||
(facil = FACIL_BUS_STOP, v->type == VEH_ROAD && RoadVehicle::From(v)->IsBus()) ||
(facil = FACIL_TRUCK_STOP, 1);
switch (v->type) {
case VEH_SHIP: facil = FACIL_DOCK; break;
case VEH_TRAIN: facil = FACIL_TRAIN; break;
case VEH_AIRCRAFT: facil = FACIL_AIRPORT; break;
case VEH_ROAD: facil = FACIL_BUS_STOP | FACIL_TRUCK_STOP; break;
default: NOT_REACHED();
}
if (st->facilities & facil) {
order.MakeGoToStation(st->index);
uint8 os = 0xff;
order.MakeGoToStation(st_index);
if (_ctrl_pressed) {
if (_shift_pressed)
os = _settings_client.gui.goto_shortcuts_ctrlshift_lclick;
@@ -686,7 +696,7 @@ private:
VehicleOrderID sel_ord = this->OrderGetSel();
const Order *order = this->vehicle->GetOrder(sel_ord);
if (order == NULL || order->GetLoadType() == load_type) return;
if (order == nullptr || order->GetLoadType() == load_type) return;
if (load_type < 0) {
load_type = order->GetLoadType() == OLF_LOAD_IF_POSSIBLE ? OLF_FULL_LOAD_ANY : OLF_LOAD_IF_POSSIBLE;
@@ -711,7 +721,7 @@ private:
if (i < 0) {
const Order *order = this->vehicle->GetOrder(sel_ord);
if (order == NULL) return;
if (order == nullptr) return;
i = (order->GetDepotOrderType() & ODTFB_SERVICE) ? DA_ALWAYS_GO : DA_SERVICE;
}
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_DEPOT_ACTION | (i << 4), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
@@ -723,7 +733,7 @@ private:
void OrderClick_NearestDepot()
{
Order order;
order.next = NULL;
order.next = nullptr;
order.index = 0;
order.MakeGoToDepot(0, ODTFB_PART_OF_ORDERS,
_settings_client.gui.new_nonstop && this->vehicle->IsGroundVehicle() ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
@@ -740,7 +750,7 @@ private:
VehicleOrderID sel_ord = this->OrderGetSel();
const Order *order = this->vehicle->GetOrder(sel_ord);
if (order == NULL || order->GetUnloadType() == unload_type) return;
if (order == nullptr || order->GetUnloadType() == unload_type) return;
if (unload_type < 0) {
unload_type = order->GetUnloadType() == OUF_UNLOAD_IF_POSSIBLE ? OUFB_UNLOAD : OUF_UNLOAD_IF_POSSIBLE;
@@ -789,7 +799,7 @@ private:
VehicleOrderID sel_ord = this->OrderGetSel();
const Order *order = this->vehicle->GetOrder(sel_ord);
if (order == NULL || order->GetNonStopType() == non_stop) return;
if (order == nullptr || order->GetNonStopType() == non_stop) return;
/* Keypress if negative, so 'toggle' to the next */
if (non_stop < 0) {
@@ -877,7 +887,7 @@ private:
{
this->can_do_refit = false;
this->can_do_autorefit = false;
for (const Vehicle *w = this->vehicle; w != NULL; w = w->IsGroundVehicle() ? w->Next() : NULL) {
for (const Vehicle *w = this->vehicle; w != nullptr; w = w->IsGroundVehicle() ? w->Next() : nullptr) {
if (IsEngineRefittable(w->engine_type)) this->can_do_refit = true;
if (HasBit(Engine::Get(w->engine_type)->info.misc_flags, EF_AUTO_REFIT)) this->can_do_autorefit = true;
}
@@ -915,7 +925,7 @@ public:
this->OnInvalidateData(VIWD_MODIFY_ORDERS);
}
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
{
switch (widget) {
case WID_O_ORDER_LIST:
@@ -952,7 +962,7 @@ public:
* @param data Information about the changed data.
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
void OnInvalidateData(int data = 0, bool gui_scope = true) override
{
VehicleOrderID from = INVALID_VEH_ORDER_ID;
VehicleOrderID to = INVALID_VEH_ORDER_ID;
@@ -1070,11 +1080,11 @@ public:
NWidgetStacked *right_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_TOP_RIGHT);
/* Ship or airplane. */
NWidgetStacked *row_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_TOP_ROW);
assert(row_sel != NULL || (train_row_sel != NULL && left_sel != NULL && middle_sel != NULL && right_sel != NULL));
assert(row_sel != nullptr || (train_row_sel != nullptr && left_sel != nullptr && middle_sel != nullptr && right_sel != nullptr));
if (order == NULL) {
if (row_sel != NULL) {
if (order == nullptr) {
if (row_sel != nullptr) {
row_sel->SetDisplayedPlane(DP_ROW_LOAD);
} else {
train_row_sel->SetDisplayedPlane(DP_GROUNDVEHICLE_ROW_NORMAL);
@@ -1093,7 +1103,7 @@ public:
switch (order->GetType()) {
case OT_GOTO_STATION:
if (row_sel != NULL) {
if (row_sel != nullptr) {
row_sel->SetDisplayedPlane(DP_ROW_LOAD);
} else {
train_row_sel->SetDisplayedPlane(DP_GROUNDVEHICLE_ROW_NORMAL);
@@ -1115,7 +1125,7 @@ public:
break;
case OT_GOTO_WAYPOINT:
if (row_sel != NULL) {
if (row_sel != nullptr) {
row_sel->SetDisplayedPlane(DP_ROW_LOAD);
} else {
train_row_sel->SetDisplayedPlane(DP_GROUNDVEHICLE_ROW_NORMAL);
@@ -1131,7 +1141,7 @@ public:
break;
case OT_GOTO_DEPOT:
if (row_sel != NULL) {
if (row_sel != nullptr) {
row_sel->SetDisplayedPlane(DP_ROW_DEPOT);
} else {
train_row_sel->SetDisplayedPlane(DP_GROUNDVEHICLE_ROW_NORMAL);
@@ -1150,7 +1160,7 @@ public:
break;
case OT_CONDITIONAL: {
if (row_sel != NULL) {
if (row_sel != nullptr) {
row_sel->SetDisplayedPlane(DP_ROW_CONDITIONAL);
} else {
train_row_sel->SetDisplayedPlane(DP_GROUNDVEHICLE_ROW_CONDITIONAL);
@@ -1165,7 +1175,7 @@ public:
}
default: // every other order
if (row_sel != NULL) {
if (row_sel != nullptr) {
row_sel->SetDisplayedPlane(DP_ROW_LOAD);
} else {
train_row_sel->SetDisplayedPlane(DP_GROUNDVEHICLE_ROW_NORMAL);
@@ -1187,7 +1197,7 @@ public:
this->SetDirty();
}
virtual void OnPaint()
void OnPaint() override
{
if (this->vehicle->owner != _local_company) {
this->selected_order = -1; // Disable selection any selected row at a competitor order window.
@@ -1197,7 +1207,7 @@ public:
this->DrawWidgets();
}
virtual void DrawWidget(const Rect &r, int widget) const
void DrawWidget(const Rect &r, int widget) const override
{
if (widget != WID_O_ORDER_LIST) return;
@@ -1213,7 +1223,7 @@ public:
const Order *order = this->vehicle->GetOrder(i);
/* First draw the highlighting underground if it exists. */
if (this->order_over != INVALID_VEH_ORDER_ID) {
while (order != NULL) {
while (order != nullptr) {
/* Don't draw anything if it extends past the end of the window. */
if (!this->vscroll->IsVisible(i)) break;
@@ -1238,7 +1248,7 @@ public:
}
/* Draw the orders. */
while (order != NULL) {
while (order != nullptr) {
/* Don't draw anything if it extends past the end of the window. */
if (!this->vscroll->IsVisible(i)) break;
@@ -1255,14 +1265,14 @@ public:
}
}
virtual void SetStringParameters(int widget) const
void SetStringParameters(int widget) const override
{
switch (widget) {
case WID_O_COND_VALUE: {
VehicleOrderID sel = this->OrderGetSel();
const Order *order = this->vehicle->GetOrder(sel);
if (order != NULL && order->IsType(OT_CONDITIONAL)) {
if (order != nullptr && order->IsType(OT_CONDITIONAL)) {
uint value = order->GetConditionValue();
if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
SetDParam(0, value);
@@ -1276,7 +1286,7 @@ public:
}
}
virtual void OnClick(Point pt, int widget, int click_count)
void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
case WID_O_ORDER_LIST: {
@@ -1284,7 +1294,7 @@ public:
VehicleOrderID order_id = this->GetOrderFromPt(_cursor.pos.y - this->top);
if (order_id != INVALID_VEH_ORDER_ID) {
Order order;
order.next = NULL;
order.next = nullptr;
order.index = 0;
order.MakeConditional(order_id);
@@ -1412,11 +1422,11 @@ public:
break;
case WID_O_COND_VARIABLE: {
DropDownList *list = new DropDownList();
DropDownList list;
for (uint i = 0; i < lengthof(_order_conditional_variable); i++) {
*list->Append() = new DropDownListStringItem(STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + _order_conditional_variable[i], _order_conditional_variable[i], false);
list.emplace_back(new DropDownListStringItem(STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + _order_conditional_variable[i], _order_conditional_variable[i], false));
}
ShowDropDownList(this, list, this->vehicle->GetOrder(this->OrderGetSel())->GetConditionVariable(), WID_O_COND_VARIABLE);
ShowDropDownList(this, std::move(list), this->vehicle->GetOrder(this->OrderGetSel())->GetConditionVariable(), WID_O_COND_VARIABLE);
break;
}
@@ -1441,7 +1451,7 @@ public:
}
}
virtual void OnQueryTextFinished(char *str)
void OnQueryTextFinished(char *str) override
{
if (!StrEmpty(str)) {
VehicleOrderID sel = this->OrderGetSel();
@@ -1464,7 +1474,7 @@ public:
}
}
virtual void OnDropdownSelect(int widget, int index)
void OnDropdownSelect(int widget, int index) override
{
switch (widget) {
case WID_O_NON_STOP:
@@ -1507,7 +1517,7 @@ public:
}
}
virtual void OnDragDrop(Point pt, int widget)
void OnDragDrop(Point pt, int widget) override
{
switch (widget) {
case WID_O_ORDER_LIST: {
@@ -1540,7 +1550,7 @@ public:
}
}
virtual EventState OnHotkey(int hotkey)
EventState OnHotkey(int hotkey) override
{
if (this->vehicle->owner != _local_company) return ES_NOT_HANDLED;
if(hotkey == OHK_GOTO && this->goto_type != OPOS_NONE){
@@ -1567,7 +1577,7 @@ public:
return ES_HANDLED;
}
virtual void OnPlaceObject(Point pt, TileIndex tile)
void OnPlaceObject(Point pt, TileIndex tile) override
{
if (this->goto_type == OPOS_GOTO) {
const Order cmd = GetOrderCmdFromTile(this->vehicle, tile);
@@ -1594,7 +1604,7 @@ public:
}
}
virtual bool OnVehicleSelect(const Vehicle *v)
bool OnVehicleSelect(const Vehicle *v) override
{
/* v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet.
* We disallow copying orders of other vehicles if we already have at least one order entry
@@ -1612,7 +1622,7 @@ public:
return true;
}
virtual void OnPlaceObjectAbort()
void OnPlaceObjectAbort() override
{
this->goto_type = OPOS_NONE;
this->SetWidgetDirty(WID_O_GOTO);
@@ -1624,7 +1634,7 @@ public:
}
}
virtual void OnMouseDrag(Point pt, int widget)
void OnMouseDrag(Point pt, int widget) override
{
if (this->selected_order != -1 && widget == WID_O_ORDER_LIST) {
/* An order is dragged.. */
@@ -1644,7 +1654,7 @@ public:
}
}
virtual void OnResize()
void OnResize() override
{
/* Update the scroll bar */
this->vscroll->SetCapacityFromWidget(this, WID_O_ORDER_LIST);
@@ -1852,7 +1862,7 @@ void ShowOrdersWindow(const Vehicle *v)
{
DeleteWindowById(WC_VEHICLE_DETAILS, v->index, false);
DeleteWindowById(WC_VEHICLE_TIMETABLE, v->index, false);
if (BringWindowToFrontById(WC_VEHICLE_ORDERS, v->index) != NULL) return;
if (BringWindowToFrontById(WC_VEHICLE_ORDERS, v->index) != nullptr) return;
/* Using a different WindowDescs for _local_company causes problems.
* Due to this we have to close order windows in ChangeWindowOwner/DeleteCompanyWindows,