File diff r12233:9d0861714103 → r12234:fd1a494e7620
src/town_cmd.cpp
Show inline comments
 
@@ -560,64 +560,64 @@ static void GetProducedCargo_Town(TileIn
 
			*(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);
 
@@ -2874,25 +2874,25 @@ static CommandCost TerraformTile_Town(Ti
 
		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
 
};