From a3e313b4d58930cce53c8651ec679497cb49da84 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sun, 11 Dec 2022 15:36:23 +0000 Subject: [PATCH] Fix plan lines not being refreshed when privacy mode changed --- src/plans_cmd.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/plans_cmd.cpp b/src/plans_cmd.cpp index 7e1e7e5dd1..4aa67b0ec3 100644 --- a/src/plans_cmd.cpp +++ b/src/plans_cmd.cpp @@ -127,9 +127,17 @@ CommandCost CmdChangePlanVisibility(TileIndex tile, DoCommandFlag flags, uint32 CommandCost ret = CheckOwnership(p->owner); if (ret.Failed()) return ret; if (flags & DC_EXEC) { - p->visible_by_all = p2 != 0; - Window *w = FindWindowById(WC_PLANS, 0); - if (w) w->InvalidateData(INVALID_PLAN, false); + bool visible = (p2 != 0); + if (p->visible_by_all != visible) { + p->visible_by_all = visible; + Window *w = FindWindowById(WC_PLANS, 0); + if (w) w->InvalidateData(INVALID_PLAN, false); + if (p->owner != _local_company && p->visible) { + for (PlanLine *line : p->lines) { + if (line->visible) line->MarkDirty(); + } + } + } } return CommandCost(); }