|
@@ -548,88 +548,88 @@ static void GetProducedCargo_Town(TileIn
|
|
|
const HouseSpec *hs = GetHouseSpecs(house_id);
|
|
|
Town *t = GetTownByTile(tile);
|
|
|
|
|
|
if (HasBit(hs->callback_mask, CBM_HOUSE_PRODUCE_CARGO)) {
|
|
|
for (uint i = 0; i < 256; i++) {
|
|
|
uint16 callback = GetHouseCallback(CBID_HOUSE_PRODUCE_CARGO, i, 0, house_id, t, tile);
|
|
|
|
|
|
if (callback == CALLBACK_FAILED || callback == CALLBACK_HOUSEPRODCARGO_END) break;
|
|
|
|
|
|
CargoID cargo = GetCargoTranslation(GB(callback, 8, 7), hs->grffile);
|
|
|
|
|
|
if (cargo == CT_INVALID) continue;
|
|
|
*(b++) = cargo;
|
|
|
}
|
|
|
} else {
|
|
|
if (hs->population > 0) {
|
|
|
*(b++) = CT_PASSENGERS;
|
|
|
}
|
|
|
if (hs->mail_generation > 0) {
|
|
|
*(b++) = CT_MAIL;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static void GetAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac)
|
|
|
static void AddAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac)
|
|
|
{
|
|
|
const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile));
|
|
|
CargoID accepts[3];
|
|
|
|
|
|
/* Set the initial accepted cargo types */
|
|
|
for (uint8 i = 0; i < lengthof(accepts); i++) {
|
|
|
accepts[i] = hs->accepts_cargo[i];
|
|
|
}
|
|
|
|
|
|
/* Check for custom accepted cargo types */
|
|
|
if (HasBit(hs->callback_mask, CBM_HOUSE_ACCEPT_CARGO)) {
|
|
|
uint16 callback = GetHouseCallback(CBID_HOUSE_ACCEPT_CARGO, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile);
|
|
|
if (callback != CALLBACK_FAILED) {
|
|
|
/* Replace accepted cargo types with translated values from callback */
|
|
|
accepts[0] = GetCargoTranslation(GB(callback, 0, 5), hs->grffile);
|
|
|
accepts[1] = GetCargoTranslation(GB(callback, 5, 5), hs->grffile);
|
|
|
accepts[2] = GetCargoTranslation(GB(callback, 10, 5), hs->grffile);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* Check for custom 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);
|
|
|
if (accepts[1] != CT_INVALID) ac[accepts[1]] = GB(callback, 4, 4);
|
|
|
if (accepts[0] != CT_INVALID) ac[accepts[0]] += GB(callback, 0, 4);
|
|
|
if (accepts[1] != CT_INVALID) ac[accepts[1]] += GB(callback, 4, 4);
|
|
|
if (_settings_game.game_creation.landscape != LT_TEMPERATE && HasBit(callback, 12)) {
|
|
|
/* The 'S' bit indicates food instead of goods */
|
|
|
ac[CT_FOOD] = GB(callback, 8, 4);
|
|
|
ac[CT_FOOD] += GB(callback, 8, 4);
|
|
|
} else {
|
|
|
if (accepts[2] != CT_INVALID) ac[accepts[2]] = GB(callback, 8, 4);
|
|
|
if (accepts[2] != CT_INVALID) ac[accepts[2]] += GB(callback, 8, 4);
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* No custom acceptance, so fill in with the default values */
|
|
|
for (uint8 i = 0; i < lengthof(accepts); i++) {
|
|
|
if (accepts[i] != CT_INVALID) ac[accepts[i]] = hs->cargo_acceptance[i];
|
|
|
if (accepts[i] != CT_INVALID) ac[accepts[i]] += hs->cargo_acceptance[i];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static void GetTileDesc_Town(TileIndex tile, TileDesc *td)
|
|
|
{
|
|
|
const HouseID house = GetHouseType(tile);
|
|
|
const HouseSpec *hs = GetHouseSpecs(house);
|
|
|
bool house_completed = IsHouseCompleted(tile);
|
|
|
|
|
|
td->str = hs->building_name;
|
|
|
|
|
|
uint16 callback_res = GetHouseCallback(CBID_HOUSE_CUSTOM_NAME, house_completed ? 1 : 0, 0, house, GetTownByTile(tile), tile);
|
|
|
if (callback_res != CALLBACK_FAILED) {
|
|
|
StringID new_name = GetGRFStringID(hs->grffile->grfid, 0xD000 + callback_res);
|
|
|
if (new_name != STR_NULL && new_name != STR_UNDEFINED) {
|
|
|
td->str = new_name;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (!house_completed) {
|
|
|
SetDParamX(td->dparam, 0, td->str);
|
|
|
td->str = STR_TOWN_DESCRIPTION_UNDER_CONSTRUCTION;
|
|
|
}
|
|
|
|
|
@@ -2862,45 +2862,45 @@ void InitializeTowns()
|
|
|
s->cargo_type = CT_INVALID;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
static CommandCost TerraformTile_Town(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new)
|
|
|
{
|
|
|
if (AutoslopeEnabled()) {
|
|
|
HouseID house = GetHouseType(tile);
|
|
|
GetHouseNorthPart(house); // modifies house to the ID of the north tile
|
|
|
const HouseSpec *hs = GetHouseSpecs(house);
|
|
|
|
|
|
/* Here we differ from TTDP by checking TILE_NOT_SLOPED */
|
|
|
if (((hs->building_flags & TILE_NOT_SLOPED) == 0) && !IsSteepSlope(tileh_new) &&
|
|
|
(GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new))) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
|
|
|
}
|
|
|
|
|
|
return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
|
|
}
|
|
|
|
|
|
/** Tile callback functions for a town */
|
|
|
extern const TileTypeProcs _tile_type_town_procs = {
|
|
|
DrawTile_Town, // draw_tile_proc
|
|
|
GetSlopeZ_Town, // get_slope_z_proc
|
|
|
ClearTile_Town, // clear_tile_proc
|
|
|
GetAcceptedCargo_Town, // get_accepted_cargo_proc
|
|
|
AddAcceptedCargo_Town, // add_accepted_cargo_proc
|
|
|
GetTileDesc_Town, // get_tile_desc_proc
|
|
|
GetTileTrackStatus_Town, // get_tile_track_status_proc
|
|
|
ClickTile_Town, // click_tile_proc
|
|
|
AnimateTile_Town, // animate_tile_proc
|
|
|
TileLoop_Town, // tile_loop_clear
|
|
|
ChangeTileOwner_Town, // change_tile_owner_clear
|
|
|
GetProducedCargo_Town, // get_produced_cargo_proc
|
|
|
NULL, // vehicle_enter_tile_proc
|
|
|
GetFoundation_Town, // get_foundation_proc
|
|
|
TerraformTile_Town, // terraform_tile_proc
|
|
|
};
|
|
|
|
|
|
void ResetHouses()
|
|
|
{
|
|
|
memset(&_house_specs, 0, sizeof(_house_specs));
|
|
|
memcpy(&_house_specs, &_original_house_specs, sizeof(_original_house_specs));
|
|
|
|
|
|
/* Reset any overrides that have been set. */
|
|
|
_house_mngr.ResetOverride();
|
|
|
}
|