diff options
author | rubidium <rubidium@openttd.org> | 2007-07-25 19:06:29 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-07-25 19:06:29 +0000 |
commit | feb91ab5ea9c0c19846825f3deb5260a4ecb36a1 (patch) | |
tree | f2e904bfcb0f95592e6d631d8b0bacddd27cbdd6 /src | |
parent | 3c253483483495b748f9644933f4c17c88f877a1 (diff) | |
download | openttd-feb91ab5ea9c0c19846825f3deb5260a4ecb36a1.tar.xz |
(svn r10690) -Codechange: use the enum that describes all callback IDs in favor of "just" using an untyped integer.
Diffstat (limited to 'src')
-rw-r--r-- | src/newgrf_callbacks.h | 3 | ||||
-rw-r--r-- | src/newgrf_canal.cpp | 2 | ||||
-rw-r--r-- | src/newgrf_cargo.cpp | 4 | ||||
-rw-r--r-- | src/newgrf_cargo.h | 4 | ||||
-rw-r--r-- | src/newgrf_engine.cpp | 6 | ||||
-rw-r--r-- | src/newgrf_engine.h | 4 | ||||
-rw-r--r-- | src/newgrf_house.cpp | 4 | ||||
-rw-r--r-- | src/newgrf_house.h | 3 | ||||
-rw-r--r-- | src/newgrf_industries.cpp | 4 | ||||
-rw-r--r-- | src/newgrf_industries.h | 2 | ||||
-rw-r--r-- | src/newgrf_industrytiles.cpp | 4 | ||||
-rw-r--r-- | src/newgrf_industrytiles.h | 2 | ||||
-rw-r--r-- | src/newgrf_spritegroup.h | 2 | ||||
-rw-r--r-- | src/newgrf_station.cpp | 4 | ||||
-rw-r--r-- | src/newgrf_station.h | 3 |
15 files changed, 29 insertions, 22 deletions
diff --git a/src/newgrf_callbacks.h b/src/newgrf_callbacks.h index 33f005c2b..59fd6da60 100644 --- a/src/newgrf_callbacks.h +++ b/src/newgrf_callbacks.h @@ -15,6 +15,9 @@ * Names are formatted as CBID_<CLASS>_<CALLBACK> */ enum CallbackID { + /** Set when using the callback resolve system, but not to resolve a callback. */ + CBID_NO_CALLBACK = 0x00, + /** Set when calling a randomizing trigger (almost undocumented). */ CBID_RANDOM_TRIGGER = 0x01, diff --git a/src/newgrf_canal.cpp b/src/newgrf_canal.cpp index f7ee308e3..9a8fe7ea1 100644 --- a/src/newgrf_canal.cpp +++ b/src/newgrf_canal.cpp @@ -73,7 +73,7 @@ static void NewCanalResolver(ResolverObject *res, TileIndex tile) res->u.canal.tile = tile; - res->callback = 0; + res->callback = CBID_NO_CALLBACK; res->callback_param1 = 0; res->callback_param2 = 0; res->last_value = 0; diff --git a/src/newgrf_cargo.cpp b/src/newgrf_cargo.cpp index ff9a633bc..1a731b835 100644 --- a/src/newgrf_cargo.cpp +++ b/src/newgrf_cargo.cpp @@ -58,7 +58,7 @@ static void NewCargoResolver(ResolverObject *res, const CargoSpec *cs) res->u.cargo.cs = cs; - res->callback = 0; + res->callback = CBID_NO_CALLBACK; res->callback_param1 = 0; res->callback_param2 = 0; res->last_value = 0; @@ -81,7 +81,7 @@ SpriteID GetCustomCargoSprite(const CargoSpec *cs) } -uint16 GetCargoCallback(uint16 callback, uint32 param1, uint32 param2, const CargoSpec *cs) +uint16 GetCargoCallback(CallbackID callback, uint32 param1, uint32 param2, const CargoSpec *cs) { ResolverObject object; const SpriteGroup *group; diff --git a/src/newgrf_cargo.h b/src/newgrf_cargo.h index e3f544d61..0c6e41af4 100644 --- a/src/newgrf_cargo.h +++ b/src/newgrf_cargo.h @@ -5,6 +5,8 @@ #ifndef NEWGRF_CARGO_H #define NEWGRF_CARGO_H +#include "newgrf_callbacks.h" + enum { CC_NOAVAILABLE = 0, CC_PASSENGERS = 1 << 0, @@ -26,7 +28,7 @@ struct CargoSpec; struct GRFFile; SpriteID GetCustomCargoSprite(const CargoSpec *cs); -uint16 GetCargoCallback(uint16 callback, uint32 param1, uint32 param2, const CargoSpec *cs); +uint16 GetCargoCallback(CallbackID callback, uint32 param1, uint32 param2, const CargoSpec *cs); CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile); uint8 GetReverseCargoTranslation(CargoID cargo, const GRFFile *grffile); diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index ad7dc3730..e51ed4f3f 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -838,7 +838,7 @@ static inline void NewVehicleResolver(ResolverObject *res, EngineID engine_type, res->info_view = false; - res->callback = 0; + res->callback = CBID_NO_CALLBACK; res->callback_param1 = 0; res->callback_param2 = 0; res->last_value = 0; @@ -938,7 +938,7 @@ bool UsesWagonOverride(const Vehicle* v) * @param v The vehicle to evaluate the callback for, or NULL if it doesnt exist yet * @return The value the callback returned, or CALLBACK_FAILED if it failed */ -uint16 GetVehicleCallback(uint16 callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v) +uint16 GetVehicleCallback(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v) { const SpriteGroup *group; ResolverObject object; @@ -965,7 +965,7 @@ uint16 GetVehicleCallback(uint16 callback, uint32 param1, uint32 param2, EngineI * @param parent The vehicle to use for parent scope * @return The value the callback returned, or CALLBACK_FAILED if it failed */ -uint16 GetVehicleCallbackParent(uint16 callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v, const Vehicle *parent) +uint16 GetVehicleCallbackParent(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v, const Vehicle *parent) { const SpriteGroup *group; ResolverObject object; diff --git a/src/newgrf_engine.h b/src/newgrf_engine.h index e77cdac0f..222f229ad 100644 --- a/src/newgrf_engine.h +++ b/src/newgrf_engine.h @@ -30,8 +30,8 @@ void SetEngineGRF(EngineID engine, const struct GRFFile *file); const struct GRFFile *GetEngineGRF(EngineID engine); uint32 GetEngineGRFID(EngineID engine); -uint16 GetVehicleCallback(uint16 callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v); -uint16 GetVehicleCallbackParent(uint16 callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v, const Vehicle *parent); +uint16 GetVehicleCallback(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v); +uint16 GetVehicleCallbackParent(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v, const Vehicle *parent); bool UsesWagonOverride(const Vehicle *v); #define GetCustomVehicleSprite(v, direction) GetCustomEngineSprite(v->engine_type, v, direction) #define GetCustomVehicleIcon(et, direction) GetCustomEngineSprite(et, NULL, direction) diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp index 4ec663143..5656470f3 100644 --- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -274,7 +274,7 @@ static void NewHouseResolver(ResolverObject *res, HouseID house_id, TileIndex ti res->u.house.town = town; res->u.house.house_id = house_id; - res->callback = 0; + res->callback = CBID_NO_CALLBACK; res->callback_param1 = 0; res->callback_param2 = 0; res->last_value = 0; @@ -282,7 +282,7 @@ static void NewHouseResolver(ResolverObject *res, HouseID house_id, TileIndex ti res->reseed = 0; } -uint16 GetHouseCallback(uint16 callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile) +uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile) { ResolverObject object; const SpriteGroup *group; diff --git a/src/newgrf_house.h b/src/newgrf_house.h index 2ebd7601f..821eff04c 100644 --- a/src/newgrf_house.h +++ b/src/newgrf_house.h @@ -6,6 +6,7 @@ #define NEWGRF_HOUSE_H #include "town.h" +#include "newgrf_callbacks.h" /** * Makes class IDs unique to each GRF file. @@ -38,7 +39,7 @@ void DrawNewHouseTile(TileInfo *ti, HouseID house_id); void AnimateNewHouseTile(TileIndex tile); void ChangeHouseAnimationFrame(TileIndex tile, uint16 callback_result); -uint16 GetHouseCallback(uint16 callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile); +uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile); bool CanDeleteHouse(TileIndex tile); diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index 5900300bf..0ce3627d1 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -275,7 +275,7 @@ static void NewIndustryResolver(ResolverObject *res, TileIndex tile, Industry *i res->u.industry.ind = indus; res->u.industry.gfx = INVALID_INDUSTRYTILE; - res->callback = 0; + res->callback = CBID_NO_CALLBACK; res->callback_param1 = 0; res->callback_param2 = 0; res->last_value = 0; @@ -283,7 +283,7 @@ static void NewIndustryResolver(ResolverObject *res, TileIndex tile, Industry *i res->reseed = 0; } -uint16 GetIndustryCallback(uint16 callback, uint32 param1, uint32 param2, Industry *industry, IndustryType type, TileIndex tile) +uint16 GetIndustryCallback(CallbackID callback, uint32 param1, uint32 param2, Industry *industry, IndustryType type, TileIndex tile) { ResolverObject object; const SpriteGroup *group; diff --git a/src/newgrf_industries.h b/src/newgrf_industries.h index fa25147c3..779050b33 100644 --- a/src/newgrf_industries.h +++ b/src/newgrf_industries.h @@ -10,7 +10,7 @@ /* in newgrf_industry.cpp */ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available); -uint16 GetIndustryCallback(uint16 callback, uint32 param1, uint32 param2, Industry *industry, IndustryType type, TileIndex tile); +uint16 GetIndustryCallback(CallbackID callback, uint32 param1, uint32 param2, Industry *industry, IndustryType type, TileIndex tile); uint32 GetIndustryIDAtOffset(TileIndex new_tile, TileIndex old_tile, const Industry *i); void IndustryProductionCallback(Industry *ind, int reason); bool CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint itspec_index); diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp index 6983abd4e..ec7b269c5 100644 --- a/src/newgrf_industrytiles.cpp +++ b/src/newgrf_industrytiles.cpp @@ -142,7 +142,7 @@ static void NewIndustryTileResolver(ResolverObject *res, IndustryGfx gfx, TileIn res->u.industry.ind = indus; res->u.industry.gfx = gfx; - res->callback = 0; + res->callback = CBID_NO_CALLBACK; res->callback_param1 = 0; res->callback_param2 = 0; res->last_value = 0; @@ -188,7 +188,7 @@ void IndustryDrawTileLayout(const TileInfo *ti, const SpriteGroup *group, byte r } } -uint16 GetIndustryTileCallback(uint16 callback, uint32 param1, uint32 param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile) +uint16 GetIndustryTileCallback(CallbackID callback, uint32 param1, uint32 param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile) { ResolverObject object; const SpriteGroup *group; diff --git a/src/newgrf_industrytiles.h b/src/newgrf_industrytiles.h index 91bfa97fa..a65fb35db 100644 --- a/src/newgrf_industrytiles.h +++ b/src/newgrf_industrytiles.h @@ -14,7 +14,7 @@ enum IndustryAnimationTrigger { }; bool DrawNewIndustryTile(TileInfo *ti, Industry *i, IndustryGfx gfx, const IndustryTileSpec *inds); -uint16 GetIndustryTileCallback(uint16 callback, uint32 param1, uint32 param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile); +uint16 GetIndustryTileCallback(CallbackID callback, uint32 param1, uint32 param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile); bool PerformIndustryTileSlopeCheck(TileIndex tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx); void AnimateNewIndustryTile(TileIndex tile); diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h index b7bc581d5..e91846097 100644 --- a/src/newgrf_spritegroup.h +++ b/src/newgrf_spritegroup.h @@ -188,7 +188,7 @@ void InitializeSpriteGroupPool(); struct ResolverObject { - uint16 callback; + CallbackID callback; uint32 callback_param1; uint32 callback_param2; diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp index 7e2e40c9b..4e40cacd8 100644 --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -555,7 +555,7 @@ static void NewStationResolver(ResolverObject *res, const StationSpec *statspec, res->u.station.statspec = statspec; res->u.station.tile = tile; - res->callback = 0; + res->callback = CBID_NO_CALLBACK; res->callback_param1 = 0; res->callback_param2 = 0; res->last_value = 0; @@ -627,7 +627,7 @@ SpriteID GetCustomStationGroundRelocation(const StationSpec *statspec, const Sta } -uint16 GetStationCallback(uint16 callback, uint32 param1, uint32 param2, const StationSpec *statspec, const Station *st, TileIndex tile) +uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, const Station *st, TileIndex tile) { const SpriteGroup *group; ResolverObject object; diff --git a/src/newgrf_station.h b/src/newgrf_station.h index d3dd0ac99..a14330303 100644 --- a/src/newgrf_station.h +++ b/src/newgrf_station.h @@ -6,6 +6,7 @@ #define NEWGRF_STATION_H #include "engine.h" +#include "newgrf_callbacks.h" #include "newgrf_cargo.h" #include "helpers.hpp" @@ -117,7 +118,7 @@ uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, i * for variational sprite groups. */ SpriteID GetCustomStationRelocation(const StationSpec *statspec, const Station *st, TileIndex tile); SpriteID GetCustomStationGroundRelocation(const StationSpec *statspec, const Station *st, TileIndex tile); -uint16 GetStationCallback(uint16 callback, uint32 param1, uint32 param2, const StationSpec *statspec, const Station *st, TileIndex tile); +uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, const Station *st, TileIndex tile); /* Check if a rail station tile is traversable. */ bool IsStationTileBlocked(TileIndex tile); |