grfspecial.c
changeset 403 bfb365c74e80
parent 401 37143866b5df
child 404 7fc41d0ad34f
--- a/grfspecial.c	Sun Nov 14 15:11:25 2004 +0000
+++ b/grfspecial.c	Sun Nov 14 16:11:48 2004 +0000
@@ -934,7 +934,7 @@
 	while (numprops-- && buf < bufend) {
 		uint8 prop = grf_load_byte(&buf);
 
-		if (feature == 4)
+		if (feature == GSF_STATION)
 			// stations don't share those common properties
 			goto run_handler;
 
@@ -1193,15 +1193,33 @@
 	if (feature == GSF_STATION) {
 		// We do things differently for stations.
 
-		/* XXX: Currently we don't support cargo-specific images, so
-		 * we go straight to the defaults. */
-		byte *bp = buf + 4 + idcount + cidcount * 3;
-		uint16 groupid = grf_load_word(&bp);
+		for (i = 0; i < idcount; i++) {
+			uint8 stid = buf[3 + i];
+			StationSpec *stat = &_cur_grffile->stations[stid];
+			byte *bp = &buf[4 + idcount];
 
-		for (i = 0; i < idcount; i++) {
-			struct StationSpec *stat;
-			uint8 stid = buf[3 + i];
-			int j;
+			for (c = 0; c < cidcount; c++) {
+				uint8 ctype = grf_load_byte(&bp);
+				uint16 groupid = grf_load_word(&bp);
+
+				if (groupid >= _cur_grffile->spritegroups_count) {
+					grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Spriteset %x out of range %x, skipping.",
+					       groupid, _cur_grffile->spritegroups_count);
+					return;
+				}
+
+				if (ctype != 0xFF) {
+					/* TODO: No support for any other cargo. */
+					continue;
+				}
+
+				stat->relocation[1] = _cur_grffile->spritegroups[groupid];
+			}
+		}
+
+		{
+			byte *bp = buf + 4 + idcount + cidcount * 3;
+			uint16 groupid = grf_load_word(&bp);
 
 			if (groupid >= _cur_grffile->spritegroups_count) {
 				grfmsg(GMS_WARN, "VehicleMapSpriteGroup: Spriteset %x out of range %x, skipping.",
@@ -1209,19 +1227,15 @@
 				return;
 			}
 
-			stat = &_cur_grffile->stations[stid];
-
-			// relocate sprite indexes based on spriteset locations
-			for (j = 0; j < stat->tiles; j++) {
-				DrawTileSeqStruct *seq;
+			for (i = 0; i < idcount; i++) {
+				uint8 stid = buf[3 + i];
+				struct StationSpec *stat = &_cur_grffile->stations[stid];
 
-				foreach_draw_tile_seq(seq, (DrawTileSeqStruct*) stat->renderdata[j].seq) {
-					seq->image += _cur_grffile->spritegroups[groupid].loading[0];
-				}
+				stat->relocation[0] = _cur_grffile->spritegroups[groupid];
+				stat->grfid = _cur_grffile->grfid;
+				SetCustomStation(stid, stat);
+				stat->classid = 0;
 			}
-			stat->grfid = _cur_grffile->grfid;
-			SetCustomStation(stid, stat);
-			stat->classid = 0;
 		}
 		return;
 	}