From 3598257da7eaf3af457cc735bc8249dea8b994a3 Mon Sep 17 00:00:00 2001 From: Andy <1780327+andythenorth@users.noreply.github.com> Date: Thu, 1 Jan 2015 08:13:08 +0000 Subject: [PATCH] Fix: get the correct cargo id for use in goals text --- company.nut | 10 +++++----- main.nut | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/company.nut b/company.nut index 503980e..b6db86a 100644 --- a/company.nut +++ b/company.nut @@ -9,7 +9,7 @@ class CompanyGoal { goal_id = null; // Number of the goal in OpenTTD goal window. timeout = null; // Timeout in ticks before the goal becomes obsolete. - constructor(comp_id, cargo_id, accept, wanted_amount) { + constructor(comp_id, cargo_id, accept, wanted_amount, cargoes) { this.cargo_id = cargo_id; this.accept = accept; this.wanted_amount = wanted_amount; @@ -26,7 +26,7 @@ class CompanyGoal { destination_string = GSText(GSText.STR_INDUSTRY_NAME, destination); goal_type = GSGoal.GT_INDUSTRY; } - local goal_text = GSText(GSText.STR_COMPANY_GOAL, this.cargo_id, this.wanted_amount, destination_string); + local goal_text = GSText(GSText.STR_COMPANY_GOAL, cargoes[this.cargo_id].cid, this.wanted_amount, destination_string); this.goal_id = GSGoal.New(comp_id, goal_text, goal_type, destination); } @@ -120,7 +120,7 @@ class CompanyData { } function GetMissingGoalCount(); - function AddActiveGoal(cargo_id, accept, amount); + function AddActiveGoal(cargo_id, accept, amount, cargoes); function HasGoal(cargo_id, accept); function GetNumberOfGoalsForCargo(cargo_id); function IndustryClosed(ind_id); @@ -160,11 +160,11 @@ function CompanyData::GetMissingGoalCount() // @param cargo_id Cargo of the goal. // @param accept Accepting resource of the goal. // @param amount Amount of cargo to deliver. -function CompanyData::AddActiveGoal(cargo_id, accept, amount) +function CompanyData::AddActiveGoal(cargo_id, accept, amount, cargoes) { foreach (num, goal in this.active_goals) { if (goal == null) { - this.active_goals[num] = CompanyGoal(this.comp_id, cargo_id, accept, amount); + this.active_goals[num] = CompanyGoal(this.comp_id, cargo_id, accept, amount, cargoes); break; } } diff --git a/main.nut b/main.nut index f6b025d..0348749 100644 --- a/main.nut +++ b/main.nut @@ -181,7 +181,7 @@ function BusyBeeClass::CreateChallenge(cid) amount = 10 * 25 + 35 * 50 + (amount - 10 - 35) * 100; // 2000..7500 } if (cdata != null) { - cdata.AddActiveGoal(cargo, accept, amount); + cdata.AddActiveGoal(cargo, accept, amount, this.cargoes); local destination_name; if ("town" in accept) {