(svn r12122) -Codechange: Add framework for generic feature callbacks, along with some parts for AI use.

This commit is contained in:
2008-02-12 13:23:57 +00:00
parent 9f6fd72c09
commit 4d0c443953
7 changed files with 257 additions and 6 deletions

View File

@@ -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();