summaryrefslogtreecommitdiff
path: root/station_cmd.c
diff options
context:
space:
mode:
authordarkvater <darkvater@openttd.org>2004-11-14 18:18:28 +0000
committerdarkvater <darkvater@openttd.org>2004-11-14 18:18:28 +0000
commit183c33931d95f13c95882cd7a9300678efef97cb (patch)
tree1ea88e661641af45692ac47a290cc8e5ec186630 /station_cmd.c
parenta348f74c65495651424975bb8ad0ffe1704b7013 (diff)
downloadopenttd-183c33931d95f13c95882cd7a9300678efef97cb.tar.xz
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
Diffstat (limited to 'station_cmd.c')
-rw-r--r--station_cmd.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/station_cmd.c b/station_cmd.c
index 40a4137df..da83d893e 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -977,6 +977,9 @@ void SetCustomStation(byte local_stid, struct StationSpec *spec)
if (_waypoint_data[i].grfid == spec->grfid
&& _waypoint_data[i].localidx == local_stid + 1) {
stid = i;
+ /* FIXME: Release original SpriteGroup to
+ * prevent leaks. But first we need to
+ * refcount the SpriteGroup. --pasky */
break;
}
}
@@ -1003,25 +1006,30 @@ struct StationSpec *GetCustomStation(uint32 classid, byte stid)
return &_waypoint_data[stid];
}
-uint32 GetCustomStationRelocation(struct StationSpec *spec, byte ctype)
+uint32 GetCustomStationRelocation(struct StationSpec *spec, struct Station *stat, byte ctype)
{
+ struct RealSpriteGroup *rsg;
+
assert(spec->classid == 'WAYP');
/* In the future, variational spritegroups will kick in through this
- * accessor. */
-
- if (spec->relocation[ctype].loading_count != 0) {
- return spec->relocation[ctype].loading[0];
- } else if (spec->relocation[ctype].loading_count != 0) {
- return spec->relocation[ctype].loaded[0];
- } else {
- error("Custom station 0x%08x::0x%02x has no sprites associated.",
- spec->grfid, spec->localidx);
- /* This is what gets subscribed of dtss->image in grfspecial.c,
- * so it's probably kinda "default offset". Try to use it as
- * emergency measure. */
- return 0x42D;
+ * accessor, using @stat. */
+ rsg = TriviallyGetRSG(&spec->spritegroup[ctype]);
+
+ if (rsg->sprites_per_set != 0) {
+ if (rsg->loading_count != 0) {
+ return rsg->loading[0];
+ } else if (rsg->loading_count != 0) {
+ return rsg->loaded[0];
+ }
}
+
+ error("Custom station 0x%08x::0x%02x has no sprites associated.",
+ spec->grfid, spec->localidx);
+ /* This is what gets subscribed of dtss->image in grfspecial.c,
+ * so it's probably kinda "default offset". Try to use it as
+ * emergency measure. */
+ return 0x42D;
}
int GetCustomStationsCount(uint32 classid)