Fix overuse of _current_plan in struct Plan methods

This commit is contained in:
Jonathan G Rennison
2021-11-16 00:02:08 +00:00
parent 95a60d520e
commit f53b295a58

View File

@@ -231,11 +231,11 @@ struct Plan : PlanPool::PoolItem<&_plan_pool> {
uint buffer_length = 0; uint buffer_length = 0;
const TileIndex *buffer = this->temp_line->Export(&buffer_length); const TileIndex *buffer = this->temp_line->Export(&buffer_length);
if (buffer) { if (buffer) {
_current_plan->SetVisibility(true, false); this->SetVisibility(true, false);
ret = DoCommandPEx(0, _current_plan->index, (uint32) this->temp_line->tiles.size(), 0, CMD_ADD_PLAN_LINE, nullptr, (const char *) buffer, buffer_length); ret = DoCommandPEx(0, this->index, (uint32) this->temp_line->tiles.size(), 0, CMD_ADD_PLAN_LINE, nullptr, (const char *) buffer, buffer_length);
free(buffer); free(buffer);
} }
_current_plan->temp_line->MarkDirty(); this->temp_line->MarkDirty();
this->temp_line->Clear(); this->temp_line->Clear();
} }
return ret; return ret;
@@ -259,13 +259,13 @@ struct Plan : PlanPool::PoolItem<&_plan_pool> {
bool ToggleVisibilityByAll() bool ToggleVisibilityByAll()
{ {
if (_current_plan->owner == _local_company) DoCommandP(0, _current_plan->index, !this->visible_by_all, CMD_CHANGE_PLAN_VISIBILITY); if (this->owner == _local_company) DoCommandP(0, this->index, !this->visible_by_all, CMD_CHANGE_PLAN_VISIBILITY);
return this->visible_by_all; return this->visible_by_all;
} }
void SetPlanColour(Colours colour) void SetPlanColour(Colours colour)
{ {
if (_current_plan->owner == _local_company) DoCommandP(0, _current_plan->index, colour, CMD_CHANGE_PLAN_COLOUR); if (this->owner == _local_company) DoCommandP(0, this->index, colour, CMD_CHANGE_PLAN_COLOUR);
} }
const std::string &GetName() const const std::string &GetName() const