(svn r10690) -Codechange: use the enum that describes all callback IDs in favor of "just" using an untyped integer.

replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
rubidium 17 years ago
parent 77b0e30b76
commit 9e3ee0e689

@ -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,

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

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

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

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

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

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

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

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

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

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

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

@ -188,7 +188,7 @@ void InitializeSpriteGroupPool();
struct ResolverObject {
uint16 callback;
CallbackID callback;
uint32 callback_param1;
uint32 callback_param2;

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

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

Loading…
Cancel
Save