diff options
author | yexo <yexo@openttd.org> | 2010-01-05 21:36:05 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2010-01-05 21:36:05 +0000 |
commit | 75f717cce3f096247a0dbafd588abc917ea5a6aa (patch) | |
tree | 45c020b0a64c7a63d0fa2527c99beca43f44b414 | |
parent | 435ef4ea8d2dc370d91c560d19a34634dddc941f (diff) | |
download | openttd-75f717cce3f096247a0dbafd588abc917ea5a6aa.tar.xz |
(svn r18736) -Feature [NewGRF]: implement varaction2houses vars 66 ad 67
-rw-r--r-- | src/house.h | 2 | ||||
-rw-r--r-- | src/newgrf_house.cpp | 33 |
2 files changed, 34 insertions, 1 deletions
diff --git a/src/house.h b/src/house.h index ed73cc806..15b0a38bc 100644 --- a/src/house.h +++ b/src/house.h @@ -113,7 +113,7 @@ struct HouseSpec { byte random_colour[4]; ///< 4 "random" colours byte probability; ///< Relative probability of appearing (16 is the standard value) HouseExtraFlags extra_flags; ///< some more flags - HouseClassID class_id; ///< defines the class this house has (grf file based) @See HouseGetVariable, prop 0x44 + HouseClassID class_id; ///< defines the class this house has (not grf file based) byte animation_frames; ///< number of animation frames byte animation_speed; ///< amount of time between each of those frames byte processing_time; ///< Periodic refresh multiplier diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp index 6028dcc4c..c7f79293d 100644 --- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -308,6 +308,39 @@ static uint32 HouseGetVariable(const ResolverObject *object, byte variable, byte /* Distance test for some house types */ case 0x65: return GetDistanceFromNearbyHouse(parameter, tile, object->u.house.house_id); + + /* Class and ID of nearby house tile */ + case 0x66: { + TileIndex testtile = GetNearbyTile(parameter, tile); + if (!IsTileType(testtile, MP_HOUSE)) return 0xFFFFFFFF; + HouseSpec *hs = HouseSpec::Get(GetHouseType(testtile)); + /* Information about the grf local classid if the house has a class */ + uint houseclass = 0; + if (hs->class_id != HOUSE_NO_CLASS) { + houseclass = (hs->grffile == object->grffile ? 1 : 2) << 8; + houseclass |= _class_mapping[hs->class_id].class_id; + } + /* old house type or grf-local houseid */ + uint local_houseid = 0; + if (house_id < NEW_HOUSE_OFFSET) { + local_houseid = house_id; + } else { + local_houseid = (hs->grffile == object->grffile ? 1 : 2) << 8; + local_houseid |= hs->local_id; + } + return houseclass << 16 | local_houseid; + } + + /* GRFID of nearby house tile */ + case 0x67: { + TileIndex testtile = GetNearbyTile(parameter, tile); + if (!IsTileType(testtile, MP_HOUSE)) return 0xFFFFFFFF; + HouseID house_id = GetHouseType(testtile); + if (house_id < NEW_HOUSE_OFFSET) return 0; + /* Checking the grffile information via HouseSpec doesn't work + * in case the newgrf was removed. */ + return _house_mngr.mapping_ID[house_id].grfid; + } } DEBUG(grf, 1, "Unhandled house property 0x%X", variable); |