forked from mirror/OpenTTD
(svn r12122) -Codechange: Add framework for generic feature callbacks, along with some parts for AI use.
This commit is contained in:
@@ -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();
|
||||
|
||||
|
Reference in New Issue
Block a user