From b3a420a8237def08bebdf53719fcaa7d35271211 Mon Sep 17 00:00:00 2001 From: Alberth Date: Sun, 28 Dec 2014 10:16:05 +0100 Subject: [PATCH] Add: Global storage of cargo types and effects. --- main.nut | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/main.nut b/main.nut index a280c75..91bf0fa 100644 --- a/main.nut +++ b/main.nut @@ -1,10 +1,34 @@ class FMainClass extends GSController { + cargoes = null; // Cargoes of the game (index -> 'cid' number, 'freight' boolean, 'effect' on town). + function Start(); } +// Examine and store cargo types of the game. +function FMainClass::ExamineCargoes() +{ + this.cargoes = {}; + local num_cargoes = 0; + + for (local cid = 0; cid < 32; cid += 1) { + if (!GSCargo.IsValidCargo(cid)) continue; + + local is_freight = GSCargo.IsFreight(cid); + local town_effect = GSCargo.GetTownEffect(cid); + cargoes[num_cargoes] <- {cid=cid, freight=is_freight, effect=town_effect}; + num_cargoes += 1; + } +} + function FMainClass::Start() { + this.ExamineCargoes(); + +// foreach(idx, val in cargoes) { +// GSLog.Info(idx + " : " + GSCargo.GetCargoLabel(val.cid) + ", " + val.cid + ", " + val.freight + ", " + val.effect); +// } + for (local cid = 0; cid < 32; cid += 1) { if (!GSCargo.IsValidCargo(cid)) continue; local label = cid + " (" + GSCargo.GetCargoLabel(cid) + ")"