diff --git a/src/plans_cmd.cpp b/src/plans_cmd.cpp index f0c314817b..19ca84eb74 100644 --- a/src/plans_cmd.cpp +++ b/src/plans_cmd.cpp @@ -22,7 +22,7 @@ * Create a new plan. * @param tile unused * @param flags type of operation - * @param p1 owner of the plan + * @param p1 unused * @param p2 unused * @param text unused * @return the cost of this operation or an error @@ -30,16 +30,8 @@ CommandCost CmdAddPlan(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (!Plan::CanAllocateItem()) return_cmd_error(STR_ERROR_TOO_MANY_PLANS); - Owner o = (Owner) p1; - CommandCost ret = CheckOwnership(o); - if (ret.Failed()) return ret; if (flags & DC_EXEC) { - _new_plan = new Plan(o); - if (o == _local_company) { - _new_plan->SetVisibility(true); - Window *w = FindWindowById(WC_PLANS, 0); - if (w) w->InvalidateData(INVALID_PLAN, false); - } + _new_plan = new Plan(_current_company); } return CommandCost(); } diff --git a/src/plans_gui.cpp b/src/plans_gui.cpp index 1d2aff8b55..6691d6b177 100644 --- a/src/plans_gui.cpp +++ b/src/plans_gui.cpp @@ -113,7 +113,7 @@ struct PlansWindow : Window { { switch (widget) { case WID_PLN_NEW: - DoCommandP(0, _local_company, 0, CMD_ADD_PLAN, CcAddPlan); + DoCommandP(0, 0, 0, CMD_ADD_PLAN, CcAddPlan); break; case WID_PLN_ADD_LINES: if (_current_plan) HandlePlacePushButton(this, widget, SPR_CURSOR_MOUSE, HT_POINT | HT_MAP); @@ -510,7 +510,7 @@ void CcAddPlan(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t _current_plan->SetVisibility(true); Window *w = FindWindowById(WC_PLANS, 0); - if (w) { + if (w != nullptr) { w->InvalidateData(INVALID_PLAN, false); ((PlansWindow *) w)->SelectPlan(_current_plan->index); if (!w->IsWidgetLowered(WID_PLN_ADD_LINES)) {