summaryrefslogtreecommitdiff
path: root/src/newgrf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/newgrf.cpp')
-rw-r--r--src/newgrf.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index d9130fec4..3e37d1893 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -3089,6 +3089,11 @@ static void FeatureMapSpriteGroup(byte *buf, int len)
* W cid cargo ID (sprite group ID) for this type of cargo
* W def-cid default cargo ID (sprite group ID) */
+ if (_cur_grffile->spritegroups == 0) {
+ grfmsg(1, "FeatureMapSpriteGroup: No sprite groups to work on! Skipping");
+ return;
+ }
+
if (!check_length(len, 6, "FeatureMapSpriteGroup")) return;
uint8 feature = buf[1];
@@ -3099,7 +3104,12 @@ static void FeatureMapSpriteGroup(byte *buf, int len)
/* If idcount is zero, this is a feature callback */
if (idcount == 0) {
- grfmsg(2, "FeatureMapSpriteGroup: Feature callbacks not implemented yet");
+ byte *bp = &buf[4];
+ uint16 groupid = grf_load_word(&bp);
+
+ grfmsg(6, "FeatureMapSpriteGroup: Adding generic feature callback for feature %d", feature);
+
+ AddGenericCallback(feature, _cur_grffile, _cur_grffile->spritegroups[groupid]);
return;
}
@@ -3109,11 +3119,6 @@ static void FeatureMapSpriteGroup(byte *buf, int len)
grfmsg(6, "FeatureMapSpriteGroup: Feature %d, %d ids, %d cids, wagon override %d",
feature, idcount, cidcount, wagover);
- if (_cur_grffile->spritegroups == 0) {
- grfmsg(1, "FeatureMapSpriteGroup: No sprite groups to work on! Skipping");
- return;
- }
-
switch (feature) {
case GSF_TRAIN:
case GSF_ROAD:
@@ -5101,6 +5106,9 @@ static void ResetNewGRFData()
UnloadCustomEngineSprites();
ResetEngineListOrder();
+ /* Reset generic feature callback lists */
+ ResetGenericCallbacks();
+
/* Reset price base data */
ResetPriceBaseMultipliers();