Fix viewport order lines/markers for multiplayer clients.
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "company_base.h"
|
||||
#include "order_backup.h"
|
||||
#include "cheat_type.h"
|
||||
#include "viewport_func.h"
|
||||
|
||||
#include "table/strings.h"
|
||||
|
||||
@@ -937,6 +938,7 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||
Order *new_o = new Order();
|
||||
new_o->AssignOrder(new_order);
|
||||
InsertOrder(v, new_o, sel_ord);
|
||||
CheckMarkDirtyFocusedRoutePaths(v);
|
||||
}
|
||||
|
||||
return CommandCost();
|
||||
@@ -1022,6 +1024,7 @@ static CommandCost DecloneOrder(Vehicle *dst, DoCommandFlag flags)
|
||||
DeleteVehicleOrders(dst);
|
||||
InvalidateVehicleOrder(dst, VIWD_REMOVE_ALL_ORDERS);
|
||||
InvalidateWindowClassesData(GetWindowClassForVehicleType(dst->type), 0);
|
||||
CheckMarkDirtyFocusedRoutePaths(dst);
|
||||
}
|
||||
return CommandCost();
|
||||
}
|
||||
@@ -1052,7 +1055,10 @@ CommandCost CmdDeleteOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||
|
||||
if (v->GetOrder(sel_ord) == NULL) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) DeleteOrder(v, sel_ord);
|
||||
if (flags & DC_EXEC) {
|
||||
DeleteOrder(v, sel_ord);
|
||||
CheckMarkDirtyFocusedRoutePaths(v);
|
||||
}
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
@@ -1266,6 +1272,7 @@ CommandCost CmdMoveOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||
|
||||
/* Make sure to rebuild the whole list */
|
||||
InvalidateWindowClassesData(GetWindowClassForVehicleType(v->type), 0);
|
||||
CheckMarkDirtyFocusedRoutePaths(v);
|
||||
}
|
||||
|
||||
return CommandCost();
|
||||
@@ -1509,6 +1516,7 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||
}
|
||||
InvalidateVehicleOrder(u, VIWD_MODIFY_ORDERS);
|
||||
}
|
||||
CheckMarkDirtyFocusedRoutePaths(v);
|
||||
}
|
||||
|
||||
return CommandCost();
|
||||
@@ -1621,6 +1629,7 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||
InvalidateVehicleOrder(src, VIWD_MODIFY_ORDERS);
|
||||
|
||||
InvalidateWindowClassesData(GetWindowClassForVehicleType(dst->type), 0);
|
||||
CheckMarkDirtyFocusedRoutePaths(dst);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1683,6 +1692,7 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||
InvalidateVehicleOrder(dst, VIWD_REMOVE_ALL_ORDERS);
|
||||
|
||||
InvalidateWindowClassesData(GetWindowClassForVehicleType(dst->type), 0);
|
||||
CheckMarkDirtyFocusedRoutePaths(dst);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1745,6 +1755,7 @@ CommandCost CmdOrderRefit(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||
u->current_order.SetRefit(cargo);
|
||||
}
|
||||
}
|
||||
CheckMarkDirtyFocusedRoutePaths(v);
|
||||
}
|
||||
|
||||
return CommandCost();
|
||||
|
@@ -617,8 +617,6 @@ private:
|
||||
order.SetDepotActionType(ODATFB_NEAREST_DEPOT);
|
||||
|
||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), order.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER));
|
||||
MarkAllRoutePathsDirty(this->vehicle);
|
||||
MarkAllRouteStepsDirty(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -704,12 +702,9 @@ private:
|
||||
/* When networking, move one order lower */
|
||||
int selected = this->selected_order + (int)_networking;
|
||||
|
||||
MarkAllRouteStepsDirty(this);
|
||||
if (DoCommandP(this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), CMD_DELETE_ORDER | CMD_MSG(STR_ERROR_CAN_T_DELETE_THIS_ORDER))) {
|
||||
this->selected_order = selected >= this->vehicle->GetNumOrders() ? -1 : selected;
|
||||
this->UpdateButtonState();
|
||||
MarkAllRoutePathsDirty(this->vehicle);
|
||||
MarkAllRouteStepsDirty(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -803,7 +798,7 @@ public:
|
||||
~OrdersWindow()
|
||||
{
|
||||
if (!FocusWindowById(WC_VEHICLE_VIEW, this->window_number)) {
|
||||
MarkAllRouteStepsDirty(this);
|
||||
MarkAllRouteStepsDirty(this->vehicle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1181,8 +1176,6 @@ public:
|
||||
order.MakeConditional(order_id);
|
||||
|
||||
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), order.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER));
|
||||
MarkAllRoutePathsDirty(this->vehicle);
|
||||
MarkAllRouteStepsDirty(this);
|
||||
}
|
||||
ResetObjectToPlace();
|
||||
break;
|
||||
@@ -1412,8 +1405,6 @@ public:
|
||||
DoCommandP(this->vehicle->tile, this->vehicle->index, from_order | (to_order << 16), CMD_MOVE_ORDER | CMD_MSG(STR_ERROR_CAN_T_MOVE_THIS_ORDER))) {
|
||||
this->selected_order = -1;
|
||||
this->UpdateButtonState();
|
||||
MarkAllRoutePathsDirty(this->vehicle);
|
||||
MarkAllRouteStepsDirty(this);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1464,8 +1455,6 @@ public:
|
||||
if (cmd.IsType(OT_NOTHING)) return;
|
||||
|
||||
if (DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), cmd.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER))) {
|
||||
MarkAllRoutePathsDirty(this->vehicle);
|
||||
MarkAllRouteStepsDirty(this);
|
||||
/* With quick goto the Go To button stays active */
|
||||
if (!_settings_client.gui.quick_goto) ResetObjectToPlace();
|
||||
}
|
||||
@@ -1486,8 +1475,6 @@ public:
|
||||
share_order ? CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_COPY_ORDER_LIST))) {
|
||||
this->selected_order = -1;
|
||||
ResetObjectToPlace();
|
||||
MarkAllRoutePathsDirty(this->vehicle);
|
||||
MarkAllRouteStepsDirty(this);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1534,7 +1521,7 @@ public:
|
||||
{
|
||||
if (HasFocusedVehicleChanged(this->window_number, previously_focused_window)) {
|
||||
MarkAllRoutePathsDirty(this->vehicle);
|
||||
MarkAllRouteStepsDirty(this);
|
||||
MarkAllRouteStepsDirty(this->vehicle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1542,7 +1529,7 @@ public:
|
||||
{
|
||||
if (HasFocusedVehicleChanged(this->window_number, newly_focused_window)) {
|
||||
MarkAllRoutePathsDirty(this->vehicle);
|
||||
MarkAllRouteStepsDirty(this);
|
||||
MarkAllRouteStepsDirty(this->vehicle);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -175,7 +175,7 @@ struct TimetableWindow : Window {
|
||||
~TimetableWindow()
|
||||
{
|
||||
if (!FocusWindowById(WC_VEHICLE_VIEW, this->window_number)) {
|
||||
MarkAllRouteStepsDirty(this);
|
||||
MarkAllRouteStepsDirty(this->vehicle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -660,7 +660,7 @@ struct TimetableWindow : Window {
|
||||
{
|
||||
if (HasFocusedVehicleChanged(this->window_number, previously_focused_window)) {
|
||||
MarkAllRoutePathsDirty(this->vehicle);
|
||||
MarkAllRouteStepsDirty(this);
|
||||
MarkAllRouteStepsDirty(this->vehicle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -668,7 +668,7 @@ struct TimetableWindow : Window {
|
||||
{
|
||||
if (HasFocusedVehicleChanged(this->window_number, newly_focused_window)) {
|
||||
MarkAllRoutePathsDirty(this->vehicle);
|
||||
MarkAllRouteStepsDirty(this);
|
||||
MarkAllRouteStepsDirty(this->vehicle);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -609,8 +609,11 @@ struct RefitWindow : public Window {
|
||||
{
|
||||
if (this->window_number != INVALID_VEHICLE) {
|
||||
if (!FocusWindowById(WC_VEHICLE_VIEW, this->window_number)) {
|
||||
if (this->window_number != INVALID_VEHICLE) MarkAllRoutePathsDirty(Vehicle::Get(this->window_number));
|
||||
MarkAllRouteStepsDirty(this);
|
||||
if (this->window_number != INVALID_VEHICLE) {
|
||||
const Vehicle *v = Vehicle::Get(this->window_number);
|
||||
MarkAllRoutePathsDirty(v);
|
||||
MarkAllRouteStepsDirty(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -618,16 +621,22 @@ struct RefitWindow : public Window {
|
||||
virtual void OnFocus(Window *previously_focused_window)
|
||||
{
|
||||
if (HasFocusedVehicleChanged(this->window_number, previously_focused_window)) {
|
||||
if (this->window_number != INVALID_VEHICLE) MarkAllRoutePathsDirty(Vehicle::Get(this->window_number));
|
||||
MarkAllRouteStepsDirty(this);
|
||||
if (this->window_number != INVALID_VEHICLE) {
|
||||
const Vehicle *v = Vehicle::Get(this->window_number);
|
||||
MarkAllRoutePathsDirty(v);
|
||||
MarkAllRouteStepsDirty(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnFocusLost(Window *newly_focused_window)
|
||||
{
|
||||
if (HasFocusedVehicleChanged(this->window_number, newly_focused_window)) {
|
||||
if (this->window_number != INVALID_VEHICLE) MarkAllRoutePathsDirty(Vehicle::Get(this->window_number));
|
||||
MarkAllRouteStepsDirty(this);
|
||||
if (this->window_number != INVALID_VEHICLE) {
|
||||
const Vehicle *v = Vehicle::Get(this->window_number);
|
||||
MarkAllRoutePathsDirty(v);
|
||||
MarkAllRouteStepsDirty(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1912,8 +1921,11 @@ struct VehicleDetailsWindow : Window {
|
||||
{
|
||||
if (this->window_number != INVALID_VEHICLE) {
|
||||
if (!FocusWindowById(WC_VEHICLE_VIEW, this->window_number)) {
|
||||
if (this->window_number != INVALID_VEHICLE) MarkAllRoutePathsDirty(Vehicle::Get(this->window_number));
|
||||
MarkAllRouteStepsDirty(this);
|
||||
if (this->window_number != INVALID_VEHICLE) {
|
||||
const Vehicle *v = Vehicle::Get(this->window_number);
|
||||
MarkAllRoutePathsDirty(v);
|
||||
MarkAllRouteStepsDirty(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2270,16 +2282,22 @@ struct VehicleDetailsWindow : Window {
|
||||
virtual void OnFocus(Window *previously_focused_window)
|
||||
{
|
||||
if (HasFocusedVehicleChanged(this->window_number, previously_focused_window)) {
|
||||
if (this->window_number != INVALID_VEHICLE) MarkAllRoutePathsDirty(Vehicle::Get(this->window_number));
|
||||
MarkAllRouteStepsDirty(this);
|
||||
if (this->window_number != INVALID_VEHICLE) {
|
||||
const Vehicle *v = Vehicle::Get(this->window_number);
|
||||
MarkAllRoutePathsDirty(v);
|
||||
MarkAllRouteStepsDirty(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnFocusLost(Window *newly_focused_window)
|
||||
{
|
||||
if (HasFocusedVehicleChanged(this->window_number, newly_focused_window)) {
|
||||
if (this->window_number != INVALID_VEHICLE) MarkAllRoutePathsDirty(Vehicle::Get(this->window_number));
|
||||
MarkAllRouteStepsDirty(this);
|
||||
if (this->window_number != INVALID_VEHICLE) {
|
||||
const Vehicle *v = Vehicle::Get(this->window_number);
|
||||
MarkAllRoutePathsDirty(v);
|
||||
MarkAllRouteStepsDirty(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -2554,8 +2572,11 @@ public:
|
||||
|
||||
~VehicleViewWindow()
|
||||
{
|
||||
if (this->window_number != INVALID_VEHICLE) MarkAllRoutePathsDirty(Vehicle::Get(this->window_number));
|
||||
MarkAllRouteStepsDirty(this);
|
||||
if (this->window_number != INVALID_VEHICLE) {
|
||||
const Vehicle *v = Vehicle::Get(this->window_number);
|
||||
MarkAllRoutePathsDirty(v);
|
||||
MarkAllRouteStepsDirty(v);
|
||||
}
|
||||
DeleteWindowById(WC_VEHICLE_ORDERS, this->window_number, false);
|
||||
DeleteWindowById(WC_VEHICLE_REFIT, this->window_number, false);
|
||||
DeleteWindowById(WC_VEHICLE_DETAILS, this->window_number, false);
|
||||
@@ -2565,16 +2586,22 @@ public:
|
||||
virtual void OnFocus(Window *previously_focused_window)
|
||||
{
|
||||
if (HasFocusedVehicleChanged(this->window_number, previously_focused_window)) {
|
||||
if (this->window_number != INVALID_VEHICLE) MarkAllRoutePathsDirty(Vehicle::Get(this->window_number));
|
||||
MarkAllRouteStepsDirty(this);
|
||||
if (this->window_number != INVALID_VEHICLE) {
|
||||
const Vehicle *v = Vehicle::Get(this->window_number);
|
||||
MarkAllRoutePathsDirty(v);
|
||||
MarkAllRouteStepsDirty(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnFocusLost(Window *newly_focused_window)
|
||||
{
|
||||
if (HasFocusedVehicleChanged(this->window_number, newly_focused_window)) {
|
||||
if (this->window_number != INVALID_VEHICLE) MarkAllRoutePathsDirty(Vehicle::Get(this->window_number));
|
||||
MarkAllRouteStepsDirty(this);
|
||||
if (this->window_number != INVALID_VEHICLE) {
|
||||
const Vehicle *v = Vehicle::Get(this->window_number);
|
||||
MarkAllRoutePathsDirty(v);
|
||||
MarkAllRouteStepsDirty(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -300,7 +300,7 @@ void InitializeWindowViewport(Window *w, int x, int y,
|
||||
veh = Vehicle::Get(vp->follow_vehicle);
|
||||
pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos);
|
||||
MarkAllRoutePathsDirty(veh);
|
||||
MarkAllRouteStepsDirty(w);
|
||||
MarkAllRouteStepsDirty(veh);
|
||||
} else {
|
||||
uint x = TileX(follow_flags) * TILE_SIZE;
|
||||
uint y = TileY(follow_flags) * TILE_SIZE;
|
||||
@@ -2857,9 +2857,8 @@ static void MarkRouteStepDirty(const TileIndex tile, uint order_nr)
|
||||
}
|
||||
}
|
||||
|
||||
void MarkAllRouteStepsDirty(Window *vehicle_window)
|
||||
void MarkAllRouteStepsDirty(const Vehicle *veh)
|
||||
{
|
||||
const Vehicle * const veh = GetVehicleFromWindow(vehicle_window);
|
||||
ViewportPrepareVehicleRouteSteps(veh);
|
||||
for (RouteStepsMap::const_iterator cit = _vp_route_steps.begin(); cit != _vp_route_steps.end(); cit++) {
|
||||
MarkRouteStepDirty(cit);
|
||||
@@ -3003,6 +3002,15 @@ void MarkAllRoutePathsDirty(const Vehicle *veh)
|
||||
_vp_route_paths.clear();
|
||||
}
|
||||
|
||||
void CheckMarkDirtyFocusedRoutePaths(const Vehicle *veh)
|
||||
{
|
||||
const Vehicle *focused_veh = GetVehicleFromWindow(_focused_window);
|
||||
if (focused_veh && veh == focused_veh) {
|
||||
MarkAllRoutePathsDirty(veh);
|
||||
MarkAllRouteStepsDirty(veh);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the selected tiles as dirty.
|
||||
*
|
||||
|
@@ -32,9 +32,10 @@ void UpdateViewportPosition(Window *w);
|
||||
|
||||
void MarkAllViewportsDirty(int left, int top, int right, int bottom, const ZoomLevel mark_dirty_if_zoomlevel_is_below = ZOOM_LVL_END);
|
||||
void MarkAllViewportMapsDirty(int left, int top, int right, int bottom);
|
||||
void MarkAllRouteStepsDirty(Window *vehicle_window);
|
||||
void MarkAllRouteStepsDirty(const Vehicle *veh);
|
||||
void MarkTileLineDirty(const TileIndex from_tile, const TileIndex to_tile);
|
||||
void MarkAllRoutePathsDirty(const Vehicle *veh);
|
||||
void CheckMarkDirtyFocusedRoutePaths(const Vehicle *veh);
|
||||
|
||||
bool DoZoomInOutWindow(ZoomStateChange how, Window *w);
|
||||
void ZoomInOrOutToCursorWindow(bool in, Window * w);
|
||||
|
Reference in New Issue
Block a user