diff options
author | michi_cc <michi_cc@openttd.org> | 2011-10-31 22:31:31 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2011-10-31 22:31:31 +0000 |
commit | e7f7a749e80348f22f3927acd1a7c79b924d4b58 (patch) | |
tree | 47df2dd5263aca91b50c4588713a528d4c705f9d /src | |
parent | 6d32787dfc58f146e8e566e6f10a2451b5913d20 (diff) | |
download | openttd-e7f7a749e80348f22f3927acd1a7c79b924d4b58.tar.xz |
(svn r23070) -Add: [NewGRF] House variable 0x64.
Diffstat (limited to 'src')
-rw-r--r-- | src/newgrf_house.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp index 42a90e20d..e4961c7a4 100644 --- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -24,6 +24,8 @@ #include "sprite.h" #include "genworld.h" #include "newgrf_animation_base.h" +#include "newgrf_cargo.h" +#include "station_base.h" static BuildingCounts<uint32> _building_counts; static HouseClassMapping _class_mapping[HOUSE_CLASS_MAX]; @@ -309,7 +311,29 @@ static uint32 HouseGetVariable(const ResolverObject *object, byte variable, byte } /* Cargo acceptance history of nearby stations */ - /*case 0x64: not implemented yet */ + case 0x64: { + CargoID cid = GetCargoTranslation(parameter, object->grffile); + if (cid == CT_INVALID) return 0; + + /* Extract tile offset. */ + int8 x_offs = GB(GetRegister(0x100), 0, 8); + int8 y_offs = GB(GetRegister(0x100), 8, 8); + TileIndex testtile = TILE_MASK(tile + TileDiffXY(x_offs, y_offs)); + + const StationList *sl = StationFinder(TileArea(testtile, 1, 1)).GetStations(); + + /* Collect acceptance stats. */ + uint32 res = 0; + for (Station * const * st_iter = sl->Begin(); st_iter != sl->End(); st_iter++) { + const Station *st = *st_iter; + if (HasBit(st->goods[cid].acceptance_pickup, GoodsEntry::GES_EVER_ACCEPTED)) SetBit(res, 0); + if (HasBit(st->goods[cid].acceptance_pickup, GoodsEntry::GES_LAST_MONTH)) SetBit(res, 1); + if (HasBit(st->goods[cid].acceptance_pickup, GoodsEntry::GES_CURRENT_MONTH)) SetBit(res, 2); + if (HasBit(st->goods[cid].acceptance_pickup, GoodsEntry::GES_ACCEPTED_BIGTICK)) SetBit(res, 3); + } + + return res; + } /* Distance test for some house types */ case 0x65: return GetDistanceFromNearbyHouse(parameter, tile, object->u.house.house_id); |