File diff r14156:7136b6af34ec → r14157:8722b3bbfc4d
src/unmovable_cmd.cpp
Show inline comments
 
@@ -298,97 +298,97 @@ static CommandCost ClearTile_Unmovable(T
 
	if (flags & DC_EXEC) {
 
		DoClearSquare(tile);
 
	}
 

	
 
	return CommandCost();
 
}
 

	
 
static void AddAcceptedCargo_Unmovable(TileIndex tile, CargoArray &acceptance, uint32 *always_accepted)
 
{
 
	if (!IsCompanyHQ(tile)) return;
 

	
 
	/* HQ accepts passenger and mail; but we have to divide the values
 
	 * between 4 tiles it occupies! */
 

	
 
	/* HQ level (depends on company performance) in the range 1..5. */
 
	uint level = GetCompanyHQSize(tile) + 1;
 

	
 
	/* Top town building generates 10, so to make HQ interesting, the top
 
	 * type makes 20. */
 
	acceptance[CT_PASSENGERS] += max(1U, level);
 
	SetBit(*always_accepted, CT_PASSENGERS);
 

	
 
	/* Top town building generates 4, HQ can make up to 8. The
 
	 * proportion passengers:mail is different because such a huge
 
	 * commercial building generates unusually high amount of mail
 
	 * correspondence per physical visitor. */
 
	acceptance[CT_MAIL] += max(1U, level / 2);
 
	SetBit(*always_accepted, CT_MAIL);
 
}
 

	
 

	
 
static void GetTileDesc_Unmovable(TileIndex tile, TileDesc *td)
 
{
 
	td->str = GetUnmovableSpec(GetUnmovableType(tile))->name;
 
	td->owner[0] = GetTileOwner(tile);
 
}
 

	
 
static void TileLoop_Unmovable(TileIndex tile)
 
{
 
	if (!IsCompanyHQ(tile)) return;
 

	
 
	/* HQ accepts passenger and mail; but we have to divide the values
 
	 * between 4 tiles it occupies! */
 

	
 
	/* HQ level (depends on company performance) in the range 1..5. */
 
	uint level = GetCompanyHQSize(tile) + 1;
 
	assert(level < 6);
 

	
 
	StationFinder stations(tile, 2, 2);
 
	StationFinder stations(TileArea(tile, 2, 2));
 

	
 
	uint r = Random();
 
	/* Top town buildings generate 250, so the top HQ type makes 256. */
 
	if (GB(r, 0, 8) < (256 / 4 / (6 - level))) {
 
		uint amt = GB(r, 0, 8) / 8 / 4 + 1;
 
		if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
 
		MoveGoodsToStation(CT_PASSENGERS, amt, ST_HEADQUARTERS, GetTileOwner(tile), stations.GetStations());
 
	}
 

	
 
	/* Top town building generates 90, HQ can make up to 196. The
 
	 * proportion passengers:mail is about the same as in the acceptance
 
	 * equations. */
 
	if (GB(r, 8, 8) < (196 / 4 / (6 - level))) {
 
		uint amt = GB(r, 8, 8) / 8 / 4 + 1;
 
		if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
 
		MoveGoodsToStation(CT_MAIL, amt, ST_HEADQUARTERS, GetTileOwner(tile), stations.GetStations());
 
	}
 
}
 

	
 

	
 
static TrackStatus GetTileTrackStatus_Unmovable(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 
{
 
	return 0;
 
}
 

	
 
static bool ClickTile_Unmovable(TileIndex tile)
 
{
 
	if (!IsCompanyHQ(tile)) return false;
 

	
 
	ShowCompany(GetTileOwner(tile));
 
	return true;
 
}
 

	
 

	
 
/* checks, if a radio tower is within a 9x9 tile square around tile */
 
static bool IsRadioTowerNearby(TileIndex tile)
 
{
 
	TileIndex tile_s = tile - TileDiffXY(min(TileX(tile), 4U), min(TileY(tile), 4U));
 
	uint w = min(TileX(tile), 4U) + 1 + min(MapMaxX() - TileX(tile), 4U);
 
	uint h = min(TileY(tile), 4U) + 1 + min(MapMaxY() - TileY(tile), 4U);
 

	
 
	TILE_LOOP(tile, w, h, tile_s) {
 
		if (IsTransmitterTile(tile)) return true;
 
	}
 

	
 
	return false;
 
}