diff src/town_cmd.cpp @ 13586:6093f71745bf draft

(svn r18110) -Codechange [FS#3316]: search for stations nearby only once per producer (instead of once pre produced cargo type) (fonsinchen)
author smatz <smatz@openttd.org>
date Sun, 15 Nov 2009 21:06:13 +0000
parents f7e05f44c9be
children 9f062af2f34a
line wrap: on
line diff
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -465,6 +465,8 @@
 	Town *t = Town::GetByTile(tile);
 	uint32 r = Random();
 
+	StationFinder stations(tile, 1, 1);
+
 	if (HasBit(hs->callback_mask, CBM_HOUSE_PRODUCE_CARGO)) {
 		for (uint i = 0; i < 256; i++) {
 			uint16 callback = GetHouseCallback(CBID_HOUSE_PRODUCE_CARGO, i, r, house_id, t, tile);
@@ -477,7 +479,7 @@
 			uint amt = GB(callback, 0, 8);
 			if (amt == 0) continue;
 
-			uint moved = MoveGoodsToStation(tile, 1, 1, cargo, amt, ST_TOWN, t->index);
+			uint moved = MoveGoodsToStation(cargo, amt, ST_TOWN, t->index, stations.GetStations());
 
 			const CargoSpec *cs = CargoSpec::Get(cargo);
 			switch (cs->town_effect) {
@@ -501,7 +503,7 @@
 
 			if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
 			t->new_max_pass += amt;
-			t->new_act_pass += MoveGoodsToStation(tile, 1, 1, CT_PASSENGERS, amt, ST_TOWN, t->index);
+			t->new_act_pass += MoveGoodsToStation(CT_PASSENGERS, amt, ST_TOWN, t->index, stations.GetStations());
 		}
 
 		if (GB(r, 8, 8) < hs->mail_generation) {
@@ -509,7 +511,7 @@
 
 			if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
 			t->new_max_mail += amt;
-			t->new_act_mail += MoveGoodsToStation(tile, 1, 1, CT_MAIL, amt, ST_TOWN, t->index);
+			t->new_act_mail += MoveGoodsToStation(CT_MAIL, amt, ST_TOWN, t->index, stations.GetStations());
 		}
 	}