(svn r11173) -Codechange: rename some callback enums so they are more uniform.

replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
rubidium 17 years ago
parent 01edaeec57
commit 127c7c9b0f

@ -364,7 +364,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->cargo_type = cargo;
if (HASBIT(EngInfo(p1)->callbackmask, CBM_REFIT_CAPACITY)) {
if (HASBIT(EngInfo(p1)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
callback = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, v->engine_type, v);
}
@ -645,7 +645,7 @@ CommandCost CmdRefitAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/* Check the refit capacity callback */
uint16 callback = CALLBACK_FAILED;
if (HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_REFIT_CAPACITY)) {
if (HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
/* Back up the existing cargo type */
CargoID temp_cid = v->cargo_type;
byte temp_subtype = v->cargo_subtype;

@ -17,7 +17,7 @@
uint CountArticulatedParts(EngineID engine_type, bool purchase_window)
{
if (!HASBIT(EngInfo(engine_type)->callbackmask, CBM_ARTIC_ENGINE)) return 0;
if (!HASBIT(EngInfo(engine_type)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return 0;
Vehicle *v = NULL;;
if (!purchase_window) {
@ -41,7 +41,7 @@ void AddArticulatedParts(Vehicle **vl, VehicleType type)
const Vehicle *v = vl[0];
Vehicle *u = vl[0];
if (!HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_ARTIC_ENGINE)) return;
if (!HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return;
for (uint i = 1; i < MAX_UVALUE(EngineID); i++) {
uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, i, 0, v->engine_type, v);

@ -1530,7 +1530,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
if (v->cargo_cap == 0) continue;
byte load_amount = EngInfo(v->engine_type)->load_amount;
if (_patches.gradual_loading && HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_LOAD_AMOUNT)) {
if (_patches.gradual_loading && HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_LOAD_AMOUNT)) {
uint16 cb_load_amount = GetVehicleCallback(CBID_VEHICLE_LOAD_AMOUNT, 0, 0, v->engine_type, v);
if (cb_load_amount != CALLBACK_FAILED) load_amount = cb_load_amount & 0xFF;
}

@ -24,6 +24,8 @@ enum CallbackID {
/** Set when calling a randomizing trigger (almost undocumented). */
CBID_RANDOM_TRIGGER = 0x01,
/* There are no callbacks 0x02 - 0x0F. */
/** Powered wagons, if the result is lower as 0x40 then the wagon is powered
* @todo : interpret the rest of the result, aka "visual effects". */
CBID_TRAIN_WAGON_POWER = 0x10,
@ -69,7 +71,7 @@ enum CallbackID {
CBID_TRAIN_ALLOW_WAGON_ATTACH = 0x1D,
/** Called to determine the colour of a town building. */
CBID_BUILDING_COLOUR = 0x1E,
CBID_HOUSE_COLOUR = 0x1E,
/** Called to decide how much cargo a town building can accept. */
CBID_HOUSE_CARGO_ACCEPTANCE = 0x1F,
@ -168,6 +170,8 @@ enum CallbackID {
/** Called to determine if the industry can still accept or refuse more cargo arrival */
CBID_INDUSTRY_REFUSE_CARGO = 0x3D,
/* There are no callbacks 0x3E - 0x142. */
/** Called to determine whether a town building can be destroyed. */
CBID_HOUSE_DENY_DESTRUCTION = 0x143,
@ -182,6 +186,20 @@ enum CallbackID {
/** Add an offset to the default sprite numbers to show another sprite. */
CBID_CANALS_SPRITE_OFFSET = 0x147, // not implemented
/* There is no callback 0x148.*/
/** Callback done for each tile of a station to check the slope. */
CBID_STATION_LAND_SLOPE_CHECK = 0x149, // not implemented
/** Called to determine the color of an industry. */
CBID_INDUSTRY_DECIDE_COLOUR = 0x14A, // not implemented
/** Customize the input cargo types of a newly build industry. */
CBID_INDUSTRY_INPUT_CARGO_TYPES = 0x14B, // not implemented
/** Customize the output cargo types of a newly build industry. */
CBID_INDUSTRY_OUTPUT_CARGO_TYPES = 0x14C, // not implemented
};
/**
@ -189,64 +207,70 @@ enum CallbackID {
* Some callbacks are always used and don't have a mask.
*/
enum VehicleCallbackMask {
CBM_WAGON_POWER = 0, ///< Powered wagons (trains only)
CBM_VEHICLE_LENGTH = 1, ///< Vehicle length (trains only)
CBM_LOAD_AMOUNT = 2, ///< Load amount
CBM_REFIT_CAPACITY = 3, ///< Cargo capacity after refit
CBM_ARTIC_ENGINE = 4, ///< Add articulated engines (trains only)
CBM_CARGO_SUFFIX = 5, ///< Show suffix after cargo name
CBM_COLOUR_REMAP = 6, ///< Change colour mapping of vehicle
CBM_SOUND_EFFECT = 7, ///< Vehicle uses custom sound effects
CBM_TRAIN_WAGON_POWER = 0, ///< Powered wagons (trains only)
CBM_VEHICLE_LENGTH = 1, ///< Vehicle length (trains and road vehicles)
CBM_VEHICLE_LOAD_AMOUNT = 2, ///< Load amount
CBM_VEHICLE_REFIT_CAPACITY = 3, ///< Cargo capacity after refit
CBM_VEHICLE_ARTIC_ENGINE = 4, ///< Add articulated engines (trains only)
CBM_VEHICLE_CARGO_SUFFIX = 5, ///< Show suffix after cargo name
CBM_VEHICLE_COLOUR_REMAP = 6, ///< Change colour mapping of vehicle
CBM_VEHICLE_SOUND_EFFECT = 7, ///< Vehicle uses custom sound effects
};
/**
* Callback masks for stations.
*/
enum StationCallbackMask {
CBM_STATION_AVAIL = 0, ///< Availability of station in construction window
CBM_CUSTOM_LAYOUT = 1, ///< Use callback to select a tile layout to use
CBM_STATION_AVAIL = 0, ///< Availability of station in construction window
CBM_STATION_SPRITE_LAYOUT = 1, ///< Use callback to select a sprite layout to use
CBM_STATION_ANIMATION_NEXT_FRAME = 2, ///< Use a custom next frame callback
CBM_STATION_ANIMATION_SPEED = 3, ///< Customize the animation speed of the station
CBM_STATION_SLOPE_CHECK = 4, ///< Check slope of new station tiles
};
/**
* Callback masks for houses.
*/
enum HouseCallbackMask {
CBM_HOUSE_ALLOW_CONSTRUCTION = 0,
CBM_ANIMATION_NEXT_FRAME = 1,
CBM_ANIMATION_START_STOP = 2,
CBM_CONSTRUCTION_STATE_CHANGE = 3,
CBM_BUILDING_COLOUR = 4,
CBM_CARGO_ACCEPTANCE = 5,
CBM_ANIMATION_SPEED = 6,
CBM_HOUSE_DESTRUCTION = 7,
CBM_HOUSE_ACCEPT_CARGO = 8,
CBM_HOUSE_PRODUCE_CARGO = 9,
CBM_HOUSE_DENY_DESTRUCTION = 10,
CBM_HOUSE_ALLOW_CONSTRUCTION = 0,
CBM_HOUSE_ANIMATION_NEXT_FRAME = 1,
CBM_HOUSE_ANIMATION_START_STOP = 2,
CBM_HOUSE_CONSTRUCTION_STATE_CHANGE = 3,
CBM_HOUSE_COLOUR = 4,
CBM_HOUSE_CARGO_ACCEPTANCE = 5,
CBM_HOUSE_ANIMATION_SPEED = 6,
CBM_HOUSE_DESTRUCTION = 7,
CBM_HOUSE_ACCEPT_CARGO = 8,
CBM_HOUSE_PRODUCE_CARGO = 9,
CBM_HOUSE_DENY_DESTRUCTION = 10,
};
/**
* Callback masks for cargos.
*/
enum CargoCallbackMask {
CBM_CARGO_PROFIT_CALC = 0,
CBM_CARGO_STATION_RATING_CALC = 1,
CBM_CARGO_PROFIT_CALC = 0, ///< custom profit calculation
CBM_CARGO_STATION_RATING_CALC = 1, ///< custom station rating for this cargo type
};
/**
* Callback masks for Industries
*/
enum IndustryCallbackMask {
CBM_IND_AVAILABLE = 0, ///< industry availability callback
CBM_IND_PRODUCTION_CARGO_ARRIVAL = 1, ///< call production callback when cargo arrives at the industry
CBM_IND_PRODUCTION_256_TICKS = 2, ///< call production callback every 256 ticks
CBM_IND_LOCATION = 3, ///< check industry construction on given area
CBM_IND_PRODUCTION_CHANGE = 4, ///< controls random production change
CBM_IND_MONTHLYPROD_CHANGE = 5, ///< controls monthly random production change
CBM_IND_CARGO_SUFFIX = 6, ///< cargo sub-type display
CBM_IND_FUND_MORE_TEXT = 7, ///< additional text in fund window
CBM_IND_WINDOW_MORE_TEXT = 8, ///< additional text in industry window
CBM_IND_SPECIAL_EFFECT = 9, ///< control special effects
CBM_IND_AVAILABLE = 0, ///< industry availability callback
CBM_IND_PRODUCTION_CARGO_ARRIVAL = 1, ///< call production callback when cargo arrives at the industry
CBM_IND_PRODUCTION_256_TICKS = 2, ///< call production callback every 256 ticks
CBM_IND_LOCATION = 3, ///< check industry construction on given area
CBM_IND_PRODUCTION_CHANGE = 4, ///< controls random production change
CBM_IND_MONTHLYPROD_CHANGE = 5, ///< controls monthly random production change
CBM_IND_CARGO_SUFFIX = 6, ///< cargo sub-type display
CBM_IND_FUND_MORE_TEXT = 7, ///< additional text in fund window
CBM_IND_WINDOW_MORE_TEXT = 8, ///< additional text in industry window
CBM_IND_SPECIAL_EFFECT = 9, ///< control special effects
CBM_IND_REFUSE_CARGO = 10, ///< option out of accepting cargo
CBM_IND_DECIDE_COLOUR = 11, ///< give a custom colour to newly build industries
CBM_IND_INPUT_CARGO_TYPES = 12, ///< customize the cargos the industry requires
CBM_IND_OUTPUT_CARGO_TYPES = 13, ///< customize the cargos the industry produces
};
/**

@ -323,8 +323,8 @@ void DrawTileLayout(const TileInfo *ti, const SpriteGroup *group, byte stage, Ho
if ((HASBIT(image, SPRITE_MODIFIER_OPAQUE) || !HASBIT(_transparent_opt, TO_HOUSES)) && HASBIT(image, PALETTE_MODIFIER_COLOR)) {
if (pal == 0) {
const HouseSpec *hs = GetHouseSpecs(house_id);
if (HASBIT(hs->callback_mask, CBM_BUILDING_COLOUR)) {
uint16 callback = GetHouseCallback(CBID_BUILDING_COLOUR, 0, 0, house_id, GetTownByTile(ti->tile), ti->tile);
if (HASBIT(hs->callback_mask, CBM_HOUSE_COLOUR)) {
uint16 callback = GetHouseCallback(CBID_HOUSE_COLOUR, 0, 0, house_id, GetTownByTile(ti->tile), ti->tile);
if (callback != CALLBACK_FAILED) {
/* If bit 14 is set, we should use a 2cc colour map, else use the callback value. */
pal = HASBIT(callback, 14) ? GB(callback, 0, 8) + SPR_2CCMAP_BASE : callback;
@ -379,7 +379,7 @@ void AnimateNewHouseTile(TileIndex tile)
byte animation_speed = hs->animation_speed;
bool frame_set_by_callback = false;
if (HASBIT(hs->callback_mask, CBM_ANIMATION_SPEED)) {
if (HASBIT(hs->callback_mask, CBM_HOUSE_ANIMATION_SPEED)) {
uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_SPEED, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile);
if (callback_res != CALLBACK_FAILED) animation_speed = clamp(callback_res & 0xFF, 2, 16);
}
@ -393,7 +393,7 @@ void AnimateNewHouseTile(TileIndex tile)
byte frame = GetHouseAnimationFrame(tile);
byte num_frames = GB(hs->animation_frames, 0, 7);
if (HASBIT(hs->callback_mask, CBM_ANIMATION_NEXT_FRAME)) {
if (HASBIT(hs->callback_mask, CBM_HOUSE_ANIMATION_NEXT_FRAME)) {
uint32 param = (hs->extra_flags & CALLBACK_1A_RANDOM_BITS) ? Random() : 0;
uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_NEXT_FRAME, param, 0, GetHouseType(tile), GetTownByTile(tile), tile);
@ -472,7 +472,7 @@ static void AnimationControl(TileIndex tile, uint16 random_bits)
{
const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile));
if (HASBIT(hs->callback_mask, CBM_ANIMATION_START_STOP)) {
if (HASBIT(hs->callback_mask, CBM_HOUSE_ANIMATION_START_STOP)) {
uint32 param = (hs->extra_flags & SYNCHRONISED_CALLBACK_1B) ? (GB(Random(), 0, 16) | random_bits << 16) : Random();
uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_START_STOP, param, 0, GetHouseType(tile), GetTownByTile(tile), tile);
@ -495,7 +495,7 @@ bool NewHouseTileLoop(TileIndex tile)
* MarkTileDirtyByTile(tile);
*/
if (HASBIT(hs->callback_mask, CBM_ANIMATION_START_STOP)) {
if (HASBIT(hs->callback_mask, CBM_HOUSE_ANIMATION_START_STOP)) {
/* If this house is marked as having a synchronised callback, all the
* tiles will have the callback called at once, rather than when the
* tile loop reaches them. This should only be enabled for the northern

@ -59,7 +59,7 @@ bool PlayVehicleSound(const Vehicle *v, VehicleSoundEvent event)
if (file == NULL) return false;
/* Check that the vehicle type uses the sound effect callback */
if (!HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_SOUND_EFFECT)) return false;
if (!HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_SOUND_EFFECT)) return false;
callback = GetVehicleCallback(CBID_VEHICLE_SOUND_EFFECT, event, 0, v->engine_type, v);
if (callback == CALLBACK_FAILED) return false;

@ -212,7 +212,7 @@ static inline const SpriteGroup *ResolveVariable(const SpriteGroup *group, Resol
switch (object->callback) {
/* All these functions are 15 bit callbacks */
case CBID_VEHICLE_REFIT_CAPACITY:
case CBID_BUILDING_COLOUR:
case CBID_HOUSE_COLOUR:
case CBID_HOUSE_CARGO_ACCEPTANCE:
case CBID_INDUSTRY_LOCATION:
case CBID_INDTILE_CARGO_ACCEPTANCE:

@ -751,7 +751,7 @@ bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID
relocation = GetCustomStationRelocation(statspec, NULL, INVALID_TILE);
if (HASBIT(statspec->callbackmask, CBM_CUSTOM_LAYOUT)) {
if (HASBIT(statspec->callbackmask, CBM_STATION_SPRITE_LAYOUT)) {
uint16 callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0x2110000, 0, statspec, NULL, INVALID_TILE);
if (callback != CALLBACK_FAILED) tile = callback;
}

@ -1518,7 +1518,7 @@ static void DrawTile_Track(TileInfo *ti)
const Station* st = ComposeWaypointStation(ti->tile);
uint gfx = 2;
if (HASBIT(statspec->callbackmask, CBM_CUSTOM_LAYOUT)) {
if (HASBIT(statspec->callbackmask, CBM_STATION_SPRITE_LAYOUT)) {
uint16 callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0, 0, statspec, st, ti->tile);
if (callback != CALLBACK_FAILED) gfx = callback;
}

@ -2023,7 +2023,7 @@ CommandCost CmdRefitRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (v->cargo_cap == 0) continue;
if (HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_REFIT_CAPACITY)) {
if (HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
/* Back up the cargo type */
CargoID temp_cid = v->cargo_type;
byte temp_subtype = v->cargo_subtype;

@ -1079,7 +1079,7 @@ CommandCost CmdRefitShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN);
/* Check the refit capacity callback */
if (HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_REFIT_CAPACITY)) {
if (HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
/* Back up the existing cargo type */
CargoID temp_cid = v->cargo_type;
byte temp_subtype = v->cargo_subtype;

@ -2054,7 +2054,7 @@ static void DrawTile_Station(TileInfo *ti)
relocation = GetCustomStationRelocation(statspec, st, ti->tile);
if (HASBIT(statspec->callbackmask, CBM_CUSTOM_LAYOUT)) {
if (HASBIT(statspec->callbackmask, CBM_STATION_SPRITE_LAYOUT)) {
uint16 callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0, 0, statspec, st, ti->tile);
if (callback != CALLBACK_FAILED) tile = (callback & ~1) + GetRailStationAxis(ti->tile);
}

@ -347,7 +347,7 @@ static void MakeSingleHouseBigger(TileIndex tile)
if (GetHouseConstructionTick(tile) != 0) return;
/* Check and/or */
if (HASBIT(GetHouseSpecs(GetHouseType(tile))->callback_mask, CBM_CONSTRUCTION_STATE_CHANGE)) {
if (HASBIT(GetHouseSpecs(GetHouseType(tile))->callback_mask, CBM_HOUSE_CONSTRUCTION_STATE_CHANGE)) {
uint16 callback_res = GetHouseCallback(CBID_HOUSE_CONSTRUCTION_STATE_CHANGE, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile);
if (callback_res != CALLBACK_FAILED) ChangeHouseAnimationFrame(tile, callback_res);
}
@ -535,7 +535,7 @@ static void GetAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac)
}
/* Check for custom cargo acceptance */
if (HASBIT(hs->callback_mask, CBM_CARGO_ACCEPTANCE)) {
if (HASBIT(hs->callback_mask, CBM_HOUSE_CARGO_ACCEPTANCE)) {
uint16 callback = GetHouseCallback(CBID_HOUSE_CARGO_ACCEPTANCE, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile);
if (callback != CALLBACK_FAILED) {
if (accepts[0] != CT_INVALID) ac[accepts[0]] = GB(callback, 0, 4);

@ -193,7 +193,7 @@ void TrainConsistChanged(Vehicle* v)
if (!IsArticulatedPart(u)) {
/* Check powered wagon / visual effect callback */
if (HASBIT(EngInfo(u->engine_type)->callbackmask, CBM_WAGON_POWER)) {
if (HASBIT(EngInfo(u->engine_type)->callbackmask, CBM_TRAIN_WAGON_POWER)) {
uint16 callback = GetVehicleCallback(CBID_TRAIN_WAGON_POWER, 0, 0, u->engine_type, u);
if (callback != CALLBACK_FAILED) u->u.rail.cached_vis_effect = callback;
@ -1625,7 +1625,7 @@ CommandCost CmdReverseTrainDirection(TileIndex tile, uint32 flags, uint32 p1, ui
if (p2) {
/* turn a single unit around */
if (IsMultiheaded(v) || HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_ARTIC_ENGINE)) {
if (IsMultiheaded(v) || HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) {
return_cmd_error(STR_ONLY_TURN_SINGLE_UNIT);
}
@ -1716,7 +1716,7 @@ CommandCost CmdRefitRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32
if (v->cargo_cap != 0) {
uint16 amount = CALLBACK_FAILED;
if (HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_REFIT_CAPACITY)) {
if (HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
/* Back up the vehicle's cargo type */
CargoID temp_cid = v->cargo_type;
byte temp_subtype = v->cargo_subtype;

@ -2619,7 +2619,7 @@ static SpriteID GetEngineColourMap(EngineID engine_type, PlayerID player, Engine
SpriteID map = PAL_NONE;
/* Check if we should use the colour map callback */
if (HASBIT(EngInfo(engine_type)->callbackmask, CBM_COLOUR_REMAP)) {
if (HASBIT(EngInfo(engine_type)->callbackmask, CBM_VEHICLE_COLOUR_REMAP)) {
uint16 callback = GetVehicleCallback(CBID_VEHICLE_COLOUR_MAPPING, 0, 0, engine_type, v);
/* A return value of 0xC000 is stated to "use the default two-color
* maps" which happens to be the failure action too... */

@ -208,7 +208,7 @@ static RefitList *BuildRefitList(const Vehicle *v)
if (!HASBIT(cmask, cid)) continue;
/* Check the vehicle's callback mask for cargo suffixes */
if (HASBIT(callbackmask, CBM_CARGO_SUFFIX)) {
if (HASBIT(callbackmask, CBM_VEHICLE_CARGO_SUFFIX)) {
/* Make a note of the original cargo type. It has to be
* changed to test the cargo & subtype... */
CargoID temp_cargo = u->cargo_type;

Loading…
Cancel
Save