Changeset - r1977:1f8b99c96041
[Not reviewed]
master
! ! !
tron - 19 years ago 2005-06-24 12:38:35
tron@openttd.org
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
63 files changed with 536 insertions and 495 deletions:
0 comments (0 inline, 0 general)
ai.c
Show inline comments
 
@@ -278,22 +278,23 @@ static void AiRestoreVehicleOrders(Vehic
 

	
 
static void AiHandleReplaceTrain(Player *p)
 
{
 
	Vehicle *v = p->ai.cur_veh;
 
	BackuppedOrders orderbak[1];
 
	int veh;
 
	uint tile;
 

	
 
	// wait until the vehicle reaches the depot.
 
	if (!IsTileDepotType(v->tile, TRANSPORT_RAIL) || v->u.rail.track != 0x80 || !(v->vehstatus&VS_STOPPED)) {
 
		AiHandleGotoDepot(p, CMD_TRAIN_GOTO_DEPOT);
 
		return;
 
	}
 

	
 
	veh = AiChooseTrainToReplaceWith(p, v);
 
	if (veh != -1) {
 
		TileIndex tile;
 

	
 
		BackupVehicleOrders(v, orderbak);
 
		tile = v->tile;
 

	
 
		if (!CmdFailed(DoCommandByTile(0, v->index, 2, DC_EXEC, CMD_SELL_RAIL_WAGON)) &&
 
			  !CmdFailed(DoCommandByTile(tile, veh, 0, DC_EXEC, CMD_BUILD_RAIL_VEHICLE)) ) {
 
			veh = _new_train_id;
 
@@ -307,21 +308,22 @@ static void AiHandleReplaceTrain(Player 
 

	
 
static void AiHandleReplaceRoadVeh(Player *p)
 
{
 
	Vehicle *v = p->ai.cur_veh;
 
	BackuppedOrders orderbak[1];
 
	int veh;
 
	uint tile;
 

	
 
	if (!IsTileDepotType(v->tile, TRANSPORT_ROAD) || v->u.road.state != 254 || !(v->vehstatus&VS_STOPPED)) {
 
		AiHandleGotoDepot(p, CMD_SEND_ROADVEH_TO_DEPOT);
 
		return;
 
	}
 

	
 
	veh = AiChooseRoadVehToReplaceWith(p, v);
 
	if (veh != -1) {
 
		TileIndex tile;
 

	
 
		BackupVehicleOrders(v, orderbak);
 
		tile = v->tile;
 

	
 
		if (!CmdFailed(DoCommandByTile(0, v->index, 0, DC_EXEC, CMD_SELL_ROAD_VEH)) &&
 
			  !CmdFailed(DoCommandByTile(tile, veh, 0, DC_EXEC, CMD_BUILD_ROAD_VEH)) ) {
 
			veh = _new_roadveh_id;
 
@@ -335,21 +337,22 @@ static void AiHandleReplaceRoadVeh(Playe
 

	
 
static void AiHandleReplaceAircraft(Player *p)
 
{
 
	Vehicle *v = p->ai.cur_veh;
 
	int veh;
 
	BackuppedOrders orderbak[1];
 
	uint tile;
 

	
 
	if (!IsAircraftHangarTile(v->tile) && !(v->vehstatus&VS_STOPPED)) {
 
		AiHandleGotoDepot(p, CMD_SEND_AIRCRAFT_TO_HANGAR);
 
		return;
 
	}
 

	
 
	veh = AiChooseAircraftToReplaceWith(p, v);
 
	if (veh != -1) {
 
		TileIndex tile;
 

	
 
		BackupVehicleOrders(v, orderbak);
 
		tile = v->tile;
 

	
 
		if (!CmdFailed(DoCommandByTile(0, v->index, 0, DC_EXEC, CMD_SELL_AIRCRAFT)) &&
 
			  !CmdFailed(DoCommandByTile(tile, veh, 0, DC_EXEC, CMD_BUILD_AIRCRAFT)) ) {
 
			veh = _new_aircraft_id;
 
@@ -1529,17 +1532,16 @@ static void AiStateWantNewRoute(Player *
 
}
 

	
 
static bool AiCheckTrackResources(TileIndex tile, const AiDefaultBlockData *p, byte cargo)
 
{
 
	uint values[NUM_CARGO];
 
	int w,h;
 
	uint tile2;
 
	int rad;
 

	
 
	for(;p->mode != 4;p++) if (p->mode == 1) {
 
		tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs));
 
		TileIndex tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs));
 

	
 
		w = ((p->attr>>1) & 7);
 
		h = ((p->attr>>4) & 7);
 
		if (p->attr&1) intswap(w, h);
 

	
 

	
 
@@ -1830,13 +1832,13 @@ typedef struct AiRailPathFindData {
 
	TileIndex tile;
 
	TileIndex tile2;
 
	int count;
 
	bool flag;
 
} AiRailPathFindData;
 

	
 
static bool AiEnumFollowTrack(uint tile, AiRailPathFindData *a, int track, uint length, byte *state)
 
static bool AiEnumFollowTrack(TileIndex tile, AiRailPathFindData *a, int track, uint length, byte *state)
 
{
 
	if (a->flag)
 
		return true;
 

	
 
	if (length > 20 || tile == a->tile) {
 
		a->flag = true;
 
@@ -2172,13 +2174,13 @@ static void AiBuildRailConstruct(Player 
 

	
 
static bool AiRemoveTileAndGoForward(Player *p)
 
{
 
	byte b;
 
	int bit;
 
	const byte *ptr;
 
	uint tile = p->ai.cur_tile_a;
 
	TileIndex tile = p->ai.cur_tile_a;
 
	int offs;
 
	TileIndex tilenew;
 

	
 
	if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 
		if (!(_map5[tile] & 0x80)) {
 
			// Clear the tunnel and continue at the other side of it.
 
@@ -2491,13 +2493,14 @@ static bool AiCheckRoadResources(TileInd
 
	}
 

	
 
	for(;;p++) {
 
		if (p->mode == 4) {
 
			return true;
 
		} else if (p->mode == 1) {
 
			uint tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs));
 
			TileIndex tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs));
 

	
 
			if (cargo & 0x80) {
 
				GetProductionAroundTiles(values, tile2, 1, 1, rad);
 
				return values[cargo & 0x7F] != 0;
 
			} else {
 
				GetAcceptanceAroundTiles(values, tile2, 1, 1, rad);
 
				return (values[cargo]&~7) != 0;
 
@@ -2762,19 +2765,19 @@ static bool AiCheckRoadPathBetter(AiRoad
 
	arf->cur_best_depth = 0xff;
 

	
 
	return better;
 
}
 

	
 

	
 
static bool AiEnumFollowRoad(uint tile, AiRoadEnum *a, int track, uint length, byte *state)
 
static bool AiEnumFollowRoad(TileIndex tile, AiRoadEnum *a, int track, uint length, byte *state)
 
{
 
	uint dist = DistanceManhattan(tile, a->dest);
 
	uint tile2;
 

	
 
	if (dist <= a->best_dist) {
 
		tile2 = TILE_MASK(tile + TileOffsByDir(_dir_by_track[track]));
 
		TileIndex tile2 = TILE_MASK(tile + TileOffsByDir(_dir_by_track[track]));
 

	
 
		if (IsTileType(tile2, MP_STREET) &&
 
				(_map5[tile2]&0xF0) == 0) {
 
			a->best_dist = dist;
 
			a->best_tile = tile;
 
			a->best_track = track;
 
		}
 
@@ -2790,13 +2793,13 @@ static const uint16 _ai_road_table_and[4
 
	0x2A00,
 
};
 

	
 
static bool AiCheckRoadFinished(Player *p)
 
{
 
	AiRoadEnum are;
 
	uint tile;
 
	TileIndex tile;
 
	int dir = p->ai.cur_dir_a;
 
	uint32 bits;
 
	int i;
 

	
 
	are.dest = p->ai.cur_tile_b;
 
	tile = TILE_MASK(p->ai.cur_tile_a + TileOffsByDir(dir));
 
@@ -2821,13 +2824,13 @@ static bool AiCheckRoadFinished(Player *
 
	p->ai.cur_tile_a = are.best_tile;
 
	p->ai.cur_dir_a = _dir_by_track[are.best_track];
 
	return false;
 
}
 

	
 

	
 
static bool AiBuildRoadHelper(uint tile, int flags, int type)
 
static bool AiBuildRoadHelper(TileIndex tile, int flags, int type)
 
{
 
	static const byte _road_bits[] = {
 
		8+2,
 
		1+4,
 
		1+8,
 
		4+2,
 
@@ -2959,13 +2962,13 @@ int sw;
 

	
 

	
 
static void AiBuildRoadConstruct(Player *p)
 
{
 
	AiRoadFinder arf;
 
	int i;
 
	uint tile;
 
	TileIndex tile;
 

	
 
	// Reached destination?
 
	if (AiCheckRoadFinished(p)) {
 
		p->ai.state_mode = 255;
 
		return;
 
	}
 
@@ -3161,13 +3164,14 @@ static int AiGetStationIdFromRoadBlock(T
 
	return _map2[TILE_ADD(tile, ToTileIndexDiff(p->tileoffs))];
 
}
 

	
 
static void AiStateBuildRoadVehicles(Player *p)
 
{
 
	const AiDefaultBlockData *ptr;
 
	uint tile,loco_id;
 
	TileIndex tile;
 
	uint loco_id;
 
	int veh, i;
 

	
 
	ptr = _road_default_block_data[p->ai.src.cur_building_rule]->data;
 
	for(;ptr->mode != 0;ptr++) {}
 
	tile = TILE_ADD(p->ai.src.use_tile, ToTileIndexDiff(ptr->tileoffs));
 

	
 
@@ -3233,13 +3237,14 @@ static void AiStateDeleteRoadBlocks(Play
 

	
 
	p->ai.state = AIS_0;
 
}
 

	
 
static bool AiCheckIfHangar(Station *st)
 
{
 
	uint tile = st->airport_tile;
 
	TileIndex tile = st->airport_tile;
 

	
 
	// HANGAR of airports
 
	// 0x20 - hangar large airport (32)
 
	// 0x41 - hangar small airport (65)
 
	return (_map5[tile] == 32 || _map5[tile] == 65);
 
}
 

	
 
@@ -3345,23 +3350,23 @@ static int32 AiDoBuildDefaultAirportBloc
 
}
 

	
 
static bool AiCheckAirportResources(TileIndex tile, const AiDefaultBlockData *p, byte cargo)
 
{
 
	uint values[NUM_CARGO];
 
	int w,h;
 
	uint tile2;
 
	int rad;
 

	
 
	if (_patches.modified_catchment) {
 
		rad = CA_AIR_LARGE;		//I Have NFI what airport the
 
	} else {				//AI is going to build here
 
		rad = 4;
 
	}
 

	
 
	for(;p->mode==0;p++) {
 
		tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs));
 
		TileIndex tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs));
 

	
 
		w = _airport_size_x[p->attr];
 
		h = _airport_size_y[p->attr];
 
		if (cargo & 0x80) {
 
			GetProductionAroundTiles(values, tile2, w, h, rad);
 
			return values[cargo & 0x7F] != 0;
 
		} else {
 
@@ -3478,13 +3483,13 @@ static int AiGetStationIdFromAircraftBlo
 
	return _map2[TILE_ADD(tile, ToTileIndexDiff(p->tileoffs))];
 
}
 

	
 
static void AiStateBuildAircraftVehicles(Player *p)
 
{
 
	const AiDefaultBlockData *ptr;
 
	uint tile;
 
	TileIndex tile;
 
	int veh;
 
	int i;
 
	uint loco_id;
 

	
 
	ptr = _airport_default_block_data[p->ai.src.cur_building_rule];
 
	for(;ptr->mode!=0;ptr++) {}
ai.h
Show inline comments
 
@@ -237,23 +237,23 @@ void AiNewDoGameLoop(Player *p);
 

	
 
// ai_pathfinder.c
 
AyStar *new_AyStar_AiPathFinder(int max_tiles_around, Ai_PathFinderInfo *PathFinderInfo);
 
void clean_AyStar_AiPathFinder(AyStar *aystar, Ai_PathFinderInfo *PathFinderInfo);
 

	
 
// ai_shared.c
 
int AiNew_GetRailDirection(uint tile_a, uint tile_b, uint tile_c);
 
int AiNew_GetRoadDirection(uint tile_a, uint tile_b, uint tile_c);
 
int AiNew_GetDirection(uint tile_a, uint tile_b);
 
int AiNew_GetRailDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c);
 
int AiNew_GetRoadDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c);
 
int AiNew_GetDirection(TileIndex tile_a, TileIndex tile_b);
 
bool AiNew_SetSpecialVehicleFlag(Player *p, Vehicle *v, uint flag);
 
uint AiNew_GetSpecialVehicleFlag(Player *p, Vehicle *v);
 

	
 
// ai_build.c
 
bool AiNew_Build_CompanyHQ(Player *p, uint tile);
 
int AiNew_Build_Station(Player *p, byte type, uint tile, byte length, byte numtracks, byte direction, byte flag);
 
int AiNew_Build_Bridge(Player *p, uint tile_a, uint tile_b, byte flag);
 
bool AiNew_Build_CompanyHQ(Player *p, TileIndex tile);
 
int AiNew_Build_Station(Player *p, byte type, TileIndex tile, byte length, byte numtracks, byte direction, byte flag);
 
int AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, byte flag);
 
int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte flag);
 
int AiNew_PickVehicle(Player *p);
 
int AiNew_Build_Vehicle(Player *p, uint tile, byte flag);
 
int AiNew_Build_Depot(Player *p, uint tile, byte direction, byte flag);
 
int AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag);
 
int AiNew_Build_Depot(Player *p, TileIndex tile, byte direction, byte flag);
 

	
 

	
 
#endif
ai_build.c
Show inline comments
 
@@ -8,13 +8,14 @@
 
#include "engine.h"
 
#include "station.h"
 

	
 
// Build HQ
 
//  Params:
 
//    tile : tile where HQ is going to be build
 
bool AiNew_Build_CompanyHQ(Player *p, uint tile) {
 
bool AiNew_Build_CompanyHQ(Player *p, TileIndex tile)
 
{
 
	if (CmdFailed(DoCommandByTile(tile, 0, 0, DC_AUTO | DC_NO_WATER, CMD_BUILD_COMPANY_HQ)))
 
		return false;
 
	DoCommandByTile(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_BUILD_COMPANY_HQ);
 
	return true;
 
}
 

	
 
@@ -23,13 +24,14 @@ bool AiNew_Build_CompanyHQ(Player *p, ui
 
//    type : AI_TRAIN/AI_BUS/AI_TRUCK : indicates the type of station
 
//    tile : tile where station is going to be build
 
//    length : in case of AI_TRAIN: length of station
 
//    numtracks : in case of AI_TRAIN: tracks of station
 
//    direction : the direction of the station
 
//    flag : flag passed to DoCommand (normally 0 to get the cost or DC_EXEC to build it)
 
int AiNew_Build_Station(Player *p, byte type, uint tile, byte length, byte numtracks, byte direction, byte flag) {
 
int AiNew_Build_Station(Player *p, byte type, TileIndex tile, byte length, byte numtracks, byte direction, byte flag)
 
{
 
	if (type == AI_TRAIN)
 
		return DoCommandByTile(tile, direction + (numtracks << 8) + (length << 16), 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_RAILROAD_STATION);
 

	
 
	if (type == AI_BUS)
 
		return DoCommandByTile(tile, direction, RS_BUS, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP);
 

	
 
@@ -38,13 +40,14 @@ int AiNew_Build_Station(Player *p, byte 
 

	
 
// Builds a brdige. The second best out of the ones available for this player
 
//  Params:
 
//   tile_a : starting point
 
//   tile_b : end point
 
//   flag : flag passed to DoCommand
 
int AiNew_Build_Bridge(Player *p, uint tile_a, uint tile_b, byte flag) {
 
int AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, byte flag)
 
{
 
	int bridge_type, bridge_len, type, type2;
 

	
 
	// Find a good bridgetype (the best money can buy)
 
	bridge_len = GetBridgeLength(tile_a, tile_b);
 
	type = type2 = 0;
 
	for (bridge_type = MAX_BRIDGES-1; bridge_type >= 0; bridge_type--) {
 
@@ -230,23 +233,24 @@ int AiNew_PickVehicle(Player *p) {
 
       	if (CmdFailed(ret)) { return -1; }
 
       	return i;
 
    }
 
}
 

	
 
// Builds the best vehicle possible
 
int AiNew_Build_Vehicle(Player *p, uint tile, byte flag) {
 
int AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag)
 
{
 
	int i = AiNew_PickVehicle(p);
 
	if (i == -1) return CMD_ERROR;
 

	
 
	if (p->ainew.tbt == AI_TRAIN)
 
		return CMD_ERROR;
 

	
 
	return DoCommandByTile(tile, i, 0, flag, CMD_BUILD_ROAD_VEH);
 
}
 

	
 
int AiNew_Build_Depot(Player *p, uint tile, byte direction, byte flag)
 
int AiNew_Build_Depot(Player *p, TileIndex tile, byte direction, byte flag)
 
{
 
	static const byte _roadbits_by_dir[4] = {2,1,8,4};
 
	int ret, ret2;
 
    if (p->ainew.tbt == AI_TRAIN)
 
    	return DoCommandByTile(tile, 0, direction, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_TRAIN_DEPOT);
 

	
ai_pathfinder.c
Show inline comments
 
@@ -8,13 +8,13 @@
 
#include "depot.h"
 

	
 
#define TEST_STATION_NO_DIR 0xFF
 

	
 
// Tests if a station can be build on the given spot
 
// TODO: make it train compatible
 
static bool TestCanBuildStationHere(uint tile, byte dir)
 
static bool TestCanBuildStationHere(TileIndex tile, byte dir)
 
{
 
	Player *p = GetPlayer(_current_player);
 

	
 
	if (dir == TEST_STATION_NO_DIR) {
 
		int32 ret;
 
		// TODO: currently we only allow spots that can be access from al 4 directions...
ai_shared.c
Show inline comments
 
@@ -2,13 +2,14 @@
 
#include "openttd.h"
 
#include "debug.h"
 
#include "map.h"
 
#include "ai.h"
 
#include "vehicle.h"
 

	
 
int AiNew_GetRailDirection(uint tile_a, uint tile_b, uint tile_c) {
 
int AiNew_GetRailDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c)
 
{
 
	// 0 = vert
 
	// 1 = horz
 
	// 2 = dig up-left
 
	// 3 = dig down-right
 
	// 4 = dig down-left
 
	// 5 = dig up-right
 
@@ -43,13 +44,14 @@ int AiNew_GetRailDirection(uint tile_a, 
 
		else return 3;
 
	}
 

	
 
	return 0;
 
}
 

	
 
int AiNew_GetRoadDirection(uint tile_a, uint tile_b, uint tile_c) {
 
int AiNew_GetRoadDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c)
 
{
 
	int x1, x2, x3;
 
	int y1, y2, y3;
 
	int r;
 

	
 
	x1 = TileX(tile_a);
 
	x2 = TileX(tile_b);
 
@@ -72,13 +74,14 @@ int AiNew_GetRoadDirection(uint tile_a, 
 
	if (y2 > y3) r += 1;
 

	
 
	return r;
 
}
 

	
 
// Get's the direction between 2 tiles seen from tile_a
 
int AiNew_GetDirection(uint tile_a, uint tile_b) {
 
int AiNew_GetDirection(TileIndex tile_a, TileIndex tile_b)
 
{
 
	if (TileY(tile_a) < TileY(tile_b)) return 1;
 
	if (TileY(tile_a) > TileY(tile_b)) return 3;
 
	if (TileX(tile_a) < TileX(tile_b)) return 2;
 
	return 0;
 
}
 

	
aircraft_cmd.c
Show inline comments
 
@@ -841,13 +841,14 @@ static bool AircraftController(Vehicle *
 
	int x,y;
 

	
 
	st = GetStation(v->u.air.targetairport);
 

	
 
	// prevent going to 0,0 if airport is deleted.
 
	{
 
		uint tile = st->airport_tile;
 
		TileIndex tile = st->airport_tile;
 

	
 
		if (tile == 0) tile = st->xy;
 
		// xy of destination
 
		x = TileX(tile) * 16;
 
		y = TileY(tile) * 16;
 
	}
 

	
aircraft_gui.c
Show inline comments
 
@@ -68,13 +68,13 @@ static void DrawAircraftImage(const Vehi
 
		DrawSprite(0xF3D, x+25, y+5);
 
	if (v->index == selection) {
 
		DrawFrameRect(x-1, y-1, x+58, y+21, 0xF, FR_BORDERONLY);
 
	}
 
}
 

	
 
void CcBuildAircraft(bool success, uint tile, uint32 p1, uint32 p2)
 
void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 

	
 
	if (success) {
 
		v = GetVehicle(_new_aircraft_id);
 
		if (v->tile == _backup_orders_tile) {
 
@@ -203,13 +203,13 @@ static const WindowDesc _new_aircraft_de
 
	WC_BUILD_VEHICLE,0,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
 
	_new_aircraft_widgets,
 
	NewAircraftWndProc
 
};
 

	
 
static void ShowBuildAircraftWindow(uint tile)
 
static void ShowBuildAircraftWindow(TileIndex tile)
 
{
 
	Window *w;
 

	
 
	DeleteWindowById(WC_BUILD_VEHICLE, tile);
 

	
 
	w = AllocateWindowDesc(&_new_aircraft_desc);
 
@@ -503,13 +503,14 @@ static void AircraftViewWndProc(Window *
 
	case WE_PAINT: {
 
		Vehicle *v = GetVehicle(w->window_number);
 
		uint32 disabled = 1<<8;
 
		StringID str;
 

	
 
		{
 
			uint tile = v->tile;
 
			TileIndex tile = v->tile;
 

	
 
			if (IsTileType(tile, MP_STATION) &&
 
					(_map5[tile] == 32 || _map5[tile] == 65) &&
 
					v->vehstatus&VS_STOPPED)
 
						disabled = 0;
 
		}
 

	
 
@@ -623,13 +624,13 @@ void ShowAircraftViewWindow(Vehicle *v)
 
		AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0);
 
	}
 
}
 

	
 
static void DrawAircraftDepotWindow(Window *w)
 
{
 
	uint tile;
 
	TileIndex tile;
 
	Vehicle *v;
 
	int num,x,y;
 

	
 
	tile = w->window_number;
 

	
 
	/* setup disabled buttons */
 
@@ -674,13 +675,13 @@ static void DrawAircraftDepotWindow(Wind
 
	}
 
}
 

	
 
static int GetVehicleFromAircraftDepotWndPt(Window *w, int x, int y, Vehicle **veh) {
 
	uint xt,row,xm,ym;
 
	Vehicle *v;
 
	uint tile;
 
	TileIndex tile;
 
	int pos;
 

	
 
	xt = x / 74;
 
	xm = x % 74;
 
	if (xt >= w->hscroll.cap)
 
		return 1;
 
@@ -841,13 +842,13 @@ static const WindowDesc _aircraft_depot_
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
 
	_aircraft_depot_widgets,
 
	AircraftDepotWndProc
 
};
 

	
 

	
 
void ShowAircraftDepotWindow(uint tile)
 
void ShowAircraftDepotWindow(TileIndex tile)
 
{
 
	Window *w;
 

	
 
	w = AllocateWindowDescFront(&_aircraft_depot_desc, tile);
 
	if (w) {
 
		w->caption_color = GetTileOwner(tile);
 
@@ -1025,13 +1026,13 @@ static void PlayerAircraftWndProc(Window
 

	
 
				ShowAircraftViewWindow(v);
 
			}
 
		} break;
 

	
 
		case 9: { /* Build new Vehicle */
 
			uint tile;
 
			TileIndex tile;
 

	
 
			if (!IsWindowOfPrototype(w, _player_aircraft_widgets))
 
				break;
 

	
 
			tile = _last_built_aircraft_depot_tile;
 
			do {
airport_gui.c
Show inline comments
 
@@ -16,26 +16,26 @@
 

	
 
static byte _selected_airport_type;
 

	
 
static void ShowBuildAirportPicker(void);
 

	
 

	
 
void CcBuildAirport(bool success, uint tile, uint32 p1, uint32 p2)
 
void CcBuildAirport(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (success) {
 
		SndPlayTileFx(SND_1F_SPLAT, tile);
 
		ResetObjectToPlace();
 
	}
 
}
 

	
 
static void PlaceAirport(uint tile)
 
static void PlaceAirport(TileIndex tile)
 
{
 
	DoCommandP(tile, _selected_airport_type, 0, CcBuildAirport, CMD_BUILD_AIRPORT | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_A001_CAN_T_BUILD_AIRPORT_HERE));
 
}
 

	
 
static void PlaceAir_DemolishArea(uint tile)
 
static void PlaceAir_DemolishArea(TileIndex tile)
 
{
 
	VpStartPlaceSizing(tile, 4);
 
}
 

	
 

	
 
static void BuildAirClick_Airport(Window *w)
aystar.h
Show inline comments
 
@@ -24,13 +24,13 @@ enum {
 
enum{
 
	AYSTAR_INVALID_NODE = -1,
 
};
 

	
 
typedef struct AyStarNode AyStarNode;
 
struct AyStarNode {
 
	uint tile;
 
	TileIndex tile;
 
	uint direction;
 
	uint user_data[2];
 
};
 

	
 
// The resulting path has nodes looking like this.
 
typedef struct PathNode PathNode;
bridge_gui.c
Show inline comments
 
@@ -21,13 +21,13 @@ static struct BridgeData {
 
extern const uint16 _bridge_type_price_mod[MAX_BRIDGES];
 

	
 
extern const PalSpriteID _bridge_sprites[MAX_BRIDGES];
 
extern const uint16 _bridge_speeds[MAX_BRIDGES];
 
extern const StringID _bridge_material[MAX_BRIDGES];
 

	
 
void CcBuildBridge(bool success, uint tile, uint32 p1, uint32 p2)
 
void CcBuildBridge(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (success) SndPlayTileFx(SND_27_BLACKSMITH_ANVIL, tile);
 
}
 

	
 
static void BuildBridge(Window *w, int i)
 
{
 
@@ -107,13 +107,13 @@ static const WindowDesc _build_road_brid
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
 
	_build_road_bridge_widgets,
 
	BuildBridgeWndProc
 
};
 

	
 

	
 
void ShowBuildBridgeWindow(uint start, uint end, byte bridge_type)
 
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, byte bridge_type)
 
{
 
	int j = 0;
 
	int32 ret;
 
	uint16 errmsg;
 

	
 
	DeleteWindowById(WC_BUILD_BRIDGE, 0);
clear_cmd.c
Show inline comments
 
@@ -79,13 +79,13 @@ static void TerraformAddDirtyTileAround(
 
	TerraformAddDirtyTile(ts, tile+TILE_XY(0,-1));
 
	TerraformAddDirtyTile(ts, tile+TILE_XY(-1,-1));
 
	TerraformAddDirtyTile(ts, tile+TILE_XY(-1,0));
 
	TerraformAddDirtyTile(ts, tile);
 
}
 

	
 
static int TerraformProc(TerraformerState *ts, uint tile, int mode)
 
static int TerraformProc(TerraformerState *ts, TileIndex tile, int mode)
 
{
 
	int r;
 
	int32 ret;
 

	
 
	assert(tile < MapSize());
 

	
 
@@ -127,13 +127,13 @@ static int TerraformProc(TerraformerStat
 
		return -1;
 
	ts->tile_table[ts->tile_table_count++] = tile;
 

	
 
	return 0;
 
}
 

	
 
static bool TerraformTileHeight(TerraformerState *ts, uint tile, int height)
 
static bool TerraformTileHeight(TerraformerState *ts, TileIndex tile, int height)
 
{
 
	int nh;
 
	TerraformerHeightMod *mod;
 
	int count;
 

	
 
	assert(tile < MapSize());
 
@@ -269,13 +269,13 @@ int32 CmdTerraformLand(int x, int y, uin
 
		/* Check if tunnel would take damage */
 
		int count;
 
		TileIndex *ti = ts.tile_table;
 

	
 
		for (count = ts.tile_table_count; count != 0; count--, ti++) {
 
			uint z, t;
 
			uint tile = *ti;
 
			TileIndex tile = *ti;
 

	
 
			z = TerraformGetHeightOfTile(&ts, tile + TILE_XY(0,0));
 
			t = TerraformGetHeightOfTile(&ts, tile + TILE_XY(1,0));
 
			if (t <= z) z = t;
 
			t = TerraformGetHeightOfTile(&ts, tile + TILE_XY(1,1));
 
			if (t <= z) z = t;
 
@@ -414,13 +414,13 @@ int32 CmdPurchaseLandArea(int x, int y, 
 
	}
 

	
 
	return cost + _price.purchase_land * 10;
 
}
 

	
 

	
 
static int32 ClearTile_Clear(uint tile, byte flags)
 
static int32 ClearTile_Clear(TileIndex tile, byte flags)
 
{
 
	static const int32 * _clear_price_table[] = {
 
			NULL,
 
			&_price.clear_1, &_price.clear_1,&_price.clear_1,
 
			&_price.purchase_land,&_price.purchase_land,&_price.purchase_land,&_price.purchase_land,
 
			&_price.clear_2,&_price.clear_2,&_price.clear_2,&_price.clear_2,
 
@@ -541,18 +541,18 @@ static uint GetSlopeZ_Clear(TileInfo *ti
 

	
 
static uint GetSlopeTileh_Clear(TileInfo *ti)
 
{
 
	return ti->tileh;
 
}
 

	
 
static void GetAcceptedCargo_Clear(uint tile, AcceptedCargo ac)
 
static void GetAcceptedCargo_Clear(TileIndex tile, AcceptedCargo ac)
 
{
 
	/* unused */
 
}
 

	
 
static void AnimateTile_Clear(uint tile)
 
static void AnimateTile_Clear(TileIndex tile)
 
{
 
	/* unused */
 
}
 

	
 
void TileLoopClearHelper(TileIndex tile)
 
{
 
@@ -639,13 +639,13 @@ void TileLoopClearHelper(TileIndex tile)
 
	if (dirty != INVALID_TILE)
 
		MarkTileDirtyByTile(dirty);
 
}
 

	
 

	
 
/* convert into snowy tiles */
 
static void TileLoopClearAlps(uint tile)
 
static void TileLoopClearAlps(TileIndex tile)
 
{
 
	int k;
 
	byte m5,tmp;
 

	
 
	/* distance from snow line, in steps of 8 */
 
	k = GetTileZ(tile) - _opt.snow_line;
 
@@ -700,13 +700,13 @@ static void TileLoopClearAlps(uint tile)
 
	}
 

	
 
	_map5[tile] = m5;
 
	MarkTileDirtyByTile(tile);
 
}
 

	
 
static void TileLoopClearDesert(uint tile)
 
static void TileLoopClearDesert(TileIndex tile)
 
{
 
 	if ( (_map5[tile] & 0x1C) == 0x14)
 
		return;
 

	
 
	if (GetMapExtraBits(tile) == 1) {
 
		_map5[tile] = 0x17;
 
@@ -719,13 +719,13 @@ static void TileLoopClearDesert(uint til
 
		_map5[tile] = 0x15;
 
	}
 

	
 
	MarkTileDirtyByTile(tile);
 
}
 

	
 
static void TileLoop_Clear(uint tile)
 
static void TileLoop_Clear(TileIndex tile)
 
{
 
	byte m5,m3;
 

	
 
	TileLoopClearHelper(tile);
 

	
 
	if (_opt.landscape == LT_DESERT) {
 
@@ -774,13 +774,13 @@ static void TileLoop_Clear(uint tile)
 
	MarkTileDirtyByTile(tile);
 
}
 

	
 
void GenerateClearTile(void)
 
{
 
	int i,j;
 
	uint tile,tile_new;
 
	TileIndex tile;
 
	uint32 r;
 

	
 
	/* add hills */
 
	i = ScaleByMapSize((Random() & 0x3FF) + 0x400);
 
	do {
 
		tile = TILE_MASK(Random());
 
@@ -793,30 +793,32 @@ void GenerateClearTile(void)
 
	do {
 
		r = Random();
 
		tile = TILE_MASK(r);
 
		if (IsTileType(tile, MP_CLEAR)) {
 
			j = ((r >> 16) & 0xF) + 5;
 
			for(;;) {
 
				TileIndex tile_new;
 

	
 
				_map5[tile] = (byte)((_map5[tile] & ~(3<<2)) | (2<<2));
 
				do {
 
					if (--j == 0) goto get_out;
 
					tile_new = tile + TileOffsByDir(Random() & 3);
 
				} while (!IsTileType(tile_new, MP_CLEAR));
 
				tile = tile_new;
 
			}
 
get_out:;
 
		}
 
	} while (--i);
 
}
 

	
 
static void ClickTile_Clear(uint tile)
 
static void ClickTile_Clear(TileIndex tile)
 
{
 
	/* not used */
 
}
 

	
 
static uint32 GetTileTrackStatus_Clear(uint tile, TransportType mode)
 
static uint32 GetTileTrackStatus_Clear(TileIndex tile, TransportType mode)
 
{
 
	return 0;
 
}
 

	
 
static const StringID _clear_land_str[4+8-1] = {
 
	STR_080B_ROUGH_LAND,
 
@@ -829,22 +831,22 @@ static const StringID _clear_land_str[4+
 
	STR_080C_BARE_LAND,
 
	STR_080D_GRASS,
 
	STR_080D_GRASS,
 
	STR_080D_GRASS,
 
};
 

	
 
static void GetTileDesc_Clear(uint tile, TileDesc *td)
 
static void GetTileDesc_Clear(TileIndex tile, TileDesc *td)
 
{
 
	int i = (_map5[tile]>>2) & 7;
 
	if (i == 0)
 
		i = (_map5[tile] & 3) + 8;
 
	td->str = _clear_land_str[i - 1];
 
	td->owner = GetTileOwner(tile);
 
}
 

	
 
static void ChangeTileOwner_Clear(uint tile, byte old_player, byte new_player)
 
static void ChangeTileOwner_Clear(TileIndex tile, byte old_player, byte new_player)
 
{
 
	return;
 
}
 

	
 
void InitializeClearLand(void)
 
{
depot.c
Show inline comments
 
@@ -30,13 +30,13 @@ MemoryPool _depot_pool = { "Depots", DEP
 

	
 
/**
 
 * Gets a depot from a tile
 
 *
 
 * @return Returns the depot if the tile had a depot, else it returns NULL
 
 */
 
Depot *GetDepotByTile(uint tile)
 
Depot *GetDepotByTile(TileIndex tile)
 
{
 
	Depot *depot;
 

	
 
	FOR_ALL_DEPOTS(depot) {
 
		if (depot->xy == tile)
 
			return depot;
 
@@ -70,13 +70,13 @@ Depot *AllocateDepot(void)
 
	return NULL;
 
}
 

	
 
/**
 
 * Delete a depot
 
 */
 
void DoDeleteDepot(uint tile)
 
void DoDeleteDepot(TileIndex tile)
 
{
 
	Order order;
 
	Depot *depot;
 

	
 
	/* Get the depot */
 
	depot = GetDepotByTile(tile);
depot.h
Show inline comments
 
@@ -109,12 +109,12 @@ static inline DiagDirection GetDepotDire
 
			}
 
		default:
 
			return INVALID_DIAGDIR; /* Not reached */
 
	}
 
}
 

	
 
Depot *GetDepotByTile(uint tile);
 
Depot *GetDepotByTile(TileIndex tile);
 
void InitializeDepot(void);
 
Depot *AllocateDepot(void);
 
void DoDeleteDepot(uint tile);
 
void DoDeleteDepot(TileIndex tile);
 

	
 
#endif /* DEPOT_H */
disaster_cmd.c
Show inline comments
 
@@ -144,13 +144,13 @@ static void SetDisasterVehiclePos(Vehicl
 
static void DisasterTick_Zeppeliner(Vehicle *v)
 
{
 
	GetNewVehiclePosResult gp;
 
	Station *st;
 
	int x,y;
 
	byte z;
 
	uint tile;
 
	TileIndex tile;
 

	
 
	++v->tick_counter;
 

	
 
	if (v->current_order.station < 2) {
 
		if (v->tick_counter&1)
 
			return;
 
@@ -327,13 +327,13 @@ static void DisasterTick_UFO(Vehicle *v)
 
		}
 
	}
 
}
 

	
 
static void DestructIndustry(Industry *i)
 
{
 
	uint tile;
 
	TileIndex tile;
 

	
 
	for(tile=0; tile != MapSize(); tile++) {
 
		if (IsTileType(tile, MP_INDUSTRY) &&	_map2[tile] == i->index) {
 
			_map_owner[tile] = 0;
 
			MarkTileDirtyByTile(tile);
 
		}
 
@@ -386,13 +386,13 @@ static void DisasterTick_2(Vehicle *v)
 
			SetDParam(0, i->town->index);
 
			AddNewsItem(STR_B002_OIL_REFINERY_EXPLOSION, NEWS_FLAGS(NM_THIN,NF_VIEWPORT|NF_TILE,NT_ACCIDENT,0), i->xy, 0);
 
			SndPlayTileFx(SND_12_EXPLOSION, i->xy);
 
		}
 
	} else if (v->current_order.station == 0) {
 
		int x,y;
 
		uint tile;
 
		TileIndex tile;
 
		int ind;
 

	
 
		x = v->x_pos - 15*16;
 
		y = v->y_pos;
 

	
 
		if ( (uint)x > MapMaxX() * 16-1)
 
@@ -457,13 +457,13 @@ static void DisasterTick_3(Vehicle *v)
 
			SetDParam(0, i->town->index);
 
			AddNewsItem(STR_B003_FACTORY_DESTROYED_IN_SUSPICIOUS, NEWS_FLAGS(NM_THIN,NF_VIEWPORT|NF_TILE,NT_ACCIDENT,0), i->xy, 0);
 
			SndPlayTileFx(SND_12_EXPLOSION, i->xy);
 
		}
 
	} else if (v->current_order.station == 0) {
 
		int x,y;
 
		uint tile;
 
		TileIndex tile;
 
		int ind;
 

	
 
		x = v->x_pos - 15*16;
 
		y = v->y_pos;
 

	
 
		if ( (uint)x > MapMaxX() * 16-1)
 
@@ -501,13 +501,14 @@ static void DisasterTick_3b(Vehicle *v)
 
static void DisasterTick_4(Vehicle *v)
 
{
 
	GetNewVehiclePosResult gp;
 
	byte z;
 
	Vehicle *u,*w;
 
	Town *t;
 
	uint tile,tile_org;
 
	TileIndex tile;
 
	TileIndex tile_org;
 

	
 
	v->tick_counter++;
 

	
 
	if (v->current_order.station == 1) {
 
		int x = TileX(v->dest_tile) * 16 + 8;
 
		int y = TileY(v->dest_tile) * 16 + 8;
 
@@ -635,13 +636,13 @@ static void DisasterTick_4b(Vehicle *v)
 

	
 
// Submarine handler
 
static void DisasterTick_5_and_6(Vehicle *v)
 
{
 
	uint32 r;
 
	GetNewVehiclePosResult gp;
 
	uint tile;
 
	TileIndex tile;
 

	
 
	v->tick_counter++;
 

	
 
	if (++v->age > 8880) {
 
		VehiclePositionChanged(v);
 
		BeginVehicleMove(v);
 
@@ -911,14 +912,15 @@ static void Disaster7_Init(void)
 

	
 
				SetDParam(0, i->town->index);
 
				AddNewsItem(STR_B005_COAL_MINE_SUBSIDENCE_LEAVES,
 
					NEWS_FLAGS(NM_THIN,NF_VIEWPORT|NF_TILE,NT_ACCIDENT,0), i->xy + TILE_XY(1,1), 0);
 

	
 
				{
 
					uint tile = i->xy;
 
					TileIndex tile = i->xy;
 
					TileIndexDiff step = TileOffsByDir(Random() & 3);
 

	
 
					int count = 30;
 
					do {
 
						DisasterClearSquare(tile);
 
						tile = TILE_MASK(tile + step);
 
					} while (--count);
 
				}
dock_gui.c
Show inline comments
 
@@ -13,52 +13,52 @@
 

	
 
static void ShowBuildDockStationPicker(void);
 
static void ShowBuildDocksDepotPicker(void);
 

	
 
static byte _ship_depot_direction;
 

	
 
void CcBuildDocks(bool success, uint tile, uint32 p1, uint32 p2)
 
void CcBuildDocks(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (success) {
 
		SndPlayTileFx(SND_02_SPLAT, tile);
 
		ResetObjectToPlace();
 
	}
 
}
 

	
 
void CcBuildCanal(bool success, uint tile, uint32 p1, uint32 p2)
 
void CcBuildCanal(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (success) SndPlayTileFx(SND_02_SPLAT, tile);
 
}
 

	
 

	
 
static void PlaceDocks_Dock(uint tile)
 
static void PlaceDocks_Dock(TileIndex tile)
 
{
 
	DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_DOCK | CMD_AUTO | CMD_MSG(STR_9802_CAN_T_BUILD_DOCK_HERE));
 
}
 

	
 
static void PlaceDocks_Depot(uint tile)
 
static void PlaceDocks_Depot(TileIndex tile)
 
{
 
	DoCommandP(tile, _ship_depot_direction, 0, CcBuildDocks, CMD_BUILD_SHIP_DEPOT | CMD_AUTO | CMD_MSG(STR_3802_CAN_T_BUILD_SHIP_DEPOT));
 
}
 

	
 
static void PlaceDocks_Buoy(uint tile)
 
static void PlaceDocks_Buoy(TileIndex tile)
 
{
 
	DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_BUOY | CMD_AUTO | CMD_MSG(STR_9835_CAN_T_POSITION_BUOY_HERE));
 
}
 

	
 
static void PlaceDocks_DemolishArea(uint tile)
 
static void PlaceDocks_DemolishArea(TileIndex tile)
 
{
 
	VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_DemolishArea);
 
}
 

	
 
static void PlaceDocks_BuildCanal(uint tile)
 
static void PlaceDocks_BuildCanal(TileIndex tile)
 
{
 
	VpStartPlaceSizing(tile, VPM_X_OR_Y);
 
}
 

	
 
static void PlaceDocks_BuildLock(uint tile)
 
static void PlaceDocks_BuildLock(TileIndex tile)
 
{
 
	DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_LOCK | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_LOCKS));
 
}
 

	
 

	
 
static void BuildDocksClick_Canal(Window *w)
 
@@ -161,13 +161,14 @@ static void BuildDocksToolbWndProc(Windo
 

	
 
		w = FindWindowById(WC_BUILD_DEPOT, 0);
 
		if (w != NULL) WP(w,def_d).close=true;
 
		break;
 

	
 
	case WE_PLACE_PRESIZE: {
 
		uint tile_from, tile_to;
 
		TileIndex tile_from;
 
		TileIndex tile_to;
 

	
 
		tile_from = tile_to = e->place.tile;
 
		switch(GetTileSlope(tile_from, NULL)) {
 
		case 3: tile_to += TILE_XY(-1,0); break;
 
		case 6:	tile_to += TILE_XY(0,-1);	break;
 
		case 9:	tile_to += TILE_XY(0,1);	break;
dummy_land.c
Show inline comments
 
@@ -15,49 +15,50 @@ static uint GetSlopeZ_Dummy(TileInfo *ti
 
}
 

	
 
static uint GetSlopeTileh_Dummy(TileInfo *ti) {
 
	return ti->tileh;
 
}
 

	
 
static int32 ClearTile_Dummy(uint tile, byte flags) {
 
static int32 ClearTile_Dummy(TileIndex tile, byte flags)
 
{
 
	return_cmd_error(STR_0001_OFF_EDGE_OF_MAP);
 
}
 

	
 

	
 
static void GetAcceptedCargo_Dummy(uint tile, AcceptedCargo ac)
 
static void GetAcceptedCargo_Dummy(TileIndex tile, AcceptedCargo ac)
 
{
 
	/* not used */
 
}
 

	
 
static void GetTileDesc_Dummy(uint tile, TileDesc *td)
 
static void GetTileDesc_Dummy(TileIndex tile, TileDesc *td)
 
{
 
	td->str = STR_EMPTY;
 
	td->owner = OWNER_NONE;
 
}
 

	
 
static void AnimateTile_Dummy(uint tile)
 
static void AnimateTile_Dummy(TileIndex tile)
 
{
 
	/* not used */
 
}
 

	
 
static void TileLoop_Dummy(uint tile)
 
static void TileLoop_Dummy(TileIndex tile)
 
{
 
	/* not used */
 
}
 

	
 
static void ClickTile_Dummy(uint tile)
 
static void ClickTile_Dummy(TileIndex tile)
 
{
 
	/* not used */
 
}
 

	
 
static void ChangeTileOwner_Dummy(uint tile, byte old_player, byte new_player)
 
static void ChangeTileOwner_Dummy(TileIndex tile, byte old_player, byte new_player)
 
{
 
	/* not used */
 
}
 

	
 
static uint32 GetTileTrackStatus_Dummy(uint tile, TransportType mode)
 
static uint32 GetTileTrackStatus_Dummy(TileIndex tile, TransportType mode)
 
{
 
	return 0;
 
}
 

	
 
const TileTypeProcs _tile_type_dummy_procs = {
 
	DrawTile_Dummy,						/* draw_tile_proc */
economy.c
Show inline comments
 
@@ -44,13 +44,13 @@ void CheckSwitchToEuro(void)
 
	}
 
}
 

	
 
void UpdatePlayerHouse(Player *p, uint score)
 
{
 
	byte val;
 
	uint tile = p->location_of_house;
 
	TileIndex tile = p->location_of_house;
 

	
 
	if (tile == 0)
 
		return;
 

	
 
	(val = 128, score < 170) ||
 
	(val+= 4, score < 350) ||
 
@@ -789,13 +789,14 @@ void StartupEconomy(void)
 
	_economy.max_loan_unround = _economy.max_loan = _opt.diff.max_loan * 1000;
 
	_economy.fluct = (byte)(Random()) + 168;
 
}
 

	
 
Pair SetupSubsidyDecodeParam(Subsidy *s, bool mode)
 
{
 
	int tile, tile2;
 
	TileIndex tile;
 
	TileIndex tile2;
 
	Industry *i;
 
	Town *t;
 
	Station *st;
 
	Pair tp;
 

	
 
	/* if mode is false, convert into plural */
economy.h
Show inline comments
 
@@ -70,9 +70,9 @@ VARDEF Subsidy _subsidies[MAX_PLAYERS];
 
Pair SetupSubsidyDecodeParam(Subsidy *s, bool mode);
 
void DeleteSubsidyWithIndustry(uint16 index);
 
void DeleteSubsidyWithStation(uint16 index);
 
void RemoteSubsidyAdd(Subsidy *s_new);
 

	
 
int32 GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, byte cargo_type);
 
uint MoveGoodsToStation(uint tile, int w, int h, int type, uint amount);
 
uint MoveGoodsToStation(TileIndex tile, int w, int h, int type, uint amount);
 

	
 
#endif /* ECONOMY_H */
functions.h
Show inline comments
 
@@ -61,20 +61,20 @@ void DrawTrainDepotSprite(int x, int y, 
 

	
 
/* road_land.c */
 
void DrawRoadDepotSprite(int x, int y, int image);
 

	
 
/* water_land.c */
 
void DrawShipDepotSprite(int x, int y, int image);
 
void TileLoop_Water(uint tile);
 
void TileLoop_Water(TileIndex tile);
 

	
 
/* players.c */
 
bool CheckPlayerHasMoney(int32 cost);
 
void SubtractMoneyFromPlayer(int32 cost);
 
void SubtractMoneyFromPlayerFract(byte player, int32 cost);
 
bool CheckOwnership(byte owner);
 
bool CheckTileOwnership(uint tile);
 
bool CheckTileOwnership(TileIndex tile);
 
StringID GetPlayerNameString(byte player, byte index);
 

	
 
/* standard */
 
void ShowInfo(const char *str);
 
void CDECL ShowInfoF(const char *str, ...);
 
void NORETURN CDECL error(const char *str, ...);
 
@@ -121,37 +121,37 @@ void DrawTextEffects(DrawPixelInfo *dpi)
 
void InitTextMessage(void);
 
void DrawTextMessage(void);
 
void CDECL AddTextMessage(uint16 color, uint8 duration, const char *message, ...);
 
void UndrawTextMessage(void);
 
void TextMessageDailyLoop(void);
 

	
 
bool AddAnimatedTile(uint tile);
 
void DeleteAnimatedTile(uint tile);
 
bool AddAnimatedTile(TileIndex tile);
 
void DeleteAnimatedTile(TileIndex tile);
 
void AnimateAnimatedTiles(void);
 
void InitializeAnimatedTiles(void);
 

	
 
/* tunnelbridge_cmd.c */
 
bool CheckTunnelInWay(uint tile, int z);
 
bool CheckTunnelInWay(TileIndex tile, int z);
 
bool CheckBridge_Stuff(byte bridge_type, int bridge_len);
 
uint32 GetBridgeLength(TileIndex begin, TileIndex end);
 
int CalcBridgeLenCostFactor(int x);
 

	
 
typedef void CommandCallback(bool success, uint tile, uint32 p1, uint32 p2);
 
typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2);
 
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd);
 

	
 
/* network.c */
 
void NetworkUDPClose(void);
 
void NetworkStartUp(void);
 
void NetworkShutDown(void);
 
void NetworkGameLoop(void);
 
void NetworkUDPGameLoop(void);
 
bool NetworkServerStart(void);
 
bool NetworkClientConnectGame(const char* host, unsigned short port);
 
void NetworkReboot(void);
 
void NetworkDisconnect(void);
 
void NetworkSend_Command(uint32 tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback);
 
void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback);
 

	
 
/* misc_cmd.c */
 
void PlaceTreesRandomly(void);
 

	
 
void InitializeLandscapeVariables(bool only_constants);
 

	
 
@@ -194,18 +194,18 @@ bool EnsureNoVehicleZ(TileIndex tile, by
 
void MarkAllViewportsDirty(int left, int top, int right, int bottom);
 
void ShowCostOrIncomeAnimation(int x, int y, int z, int32 cost);
 
void ShowFeederIncomeAnimation(int x, int y, int z, int32 cost);
 

	
 
void DrawFoundation(TileInfo *ti, uint f);
 

	
 
bool CheckIfAuthorityAllows(uint tile);
 
Town *ClosestTownFromTile(uint tile, uint threshold);
 
bool CheckIfAuthorityAllows(TileIndex tile);
 
Town *ClosestTownFromTile(TileIndex tile, uint threshold);
 
void ChangeTownRating(Town *t, int add, int max);
 

	
 
uint GetRoadBitsByTile(TileIndex tile);
 
int GetTownRadiusGroup(Town *t, uint tile);
 
int GetTownRadiusGroup(Town *t, TileIndex tile);
 
void ShowNetworkChatQueryWindow(byte desttype, byte dest);
 
void ShowNetworkGiveMoneyWindow(byte player);
 
void ShowNetworkNeedGamePassword(void);
 
void ShowNetworkNeedCompanyPassword(void);
 
int FindFirstBit(uint32 x);
 
void ShowHighscoreTable(int difficulty, int8 rank);
gui.h
Show inline comments
 
@@ -2,15 +2,15 @@
 
#define GUI_H
 

	
 
#include "window.h"
 

	
 
/* main_gui.c */
 
void SetupColorsAndInitialWindow(void);
 
void CcPlaySound10(bool success, uint tile, uint32 p1, uint32 p2);
 
void CcBuildCanal(bool success, uint tile, uint32 p1, uint32 p2);
 
void CcTerraform(bool success, uint tile, uint32 p1, uint32 p2);
 
void CcPlaySound10(bool success, TileIndex tile, uint32 p1, uint32 p2);
 
void CcBuildCanal(bool success, TileIndex tile, uint32 p1, uint32 p2);
 
void CcTerraform(bool success, TileIndex tile, uint32 p1, uint32 p2);
 

	
 
/* settings_gui.c */
 
void ShowGameOptions(void);
 
void ShowGameDifficulty(void);
 
void ShowPatchesSelection(void);
 
void ShowNewgrf(void);
 
@@ -30,13 +30,13 @@ void ShowPerformanceRatingDetail(void);
 
void ShowLastNewsMessage(void);
 
void ShowMessageOptions(void);
 
void ShowMessageHistory(void);
 

	
 
/* traintoolb_gui.c */
 
void ShowBuildRailToolbar(int index, int button);
 
void PlaceProc_BuyLand(uint tile);
 
void PlaceProc_BuyLand(TileIndex tile);
 

	
 
/* train_gui.c */
 
void ShowPlayerTrains(int player, int station);
 
void ShowTrainViewWindow(Vehicle *v);
 
void ShowTrainDetailsWindow(Vehicle *v);
 
void ShowOrdersWindow(Vehicle *v);
 
@@ -58,16 +58,16 @@ void ShowShipViewWindow(Vehicle *v);
 
void ShowBuildAirToolbar(void);
 
void ShowPlayerAircraft(int player, int station);
 

	
 
/* terraform_gui.c */
 
void ShowTerraformToolbar(void);
 

	
 
void PlaceProc_DemolishArea(uint tile);
 
void PlaceProc_LowerLand(uint tile);
 
void PlaceProc_RaiseLand(uint tile);
 
void PlaceProc_LevelLand(uint tile);
 
void PlaceProc_DemolishArea(TileIndex tile);
 
void PlaceProc_LowerLand(TileIndex tile);
 
void PlaceProc_RaiseLand(TileIndex tile);
 
void PlaceProc_LevelLand(TileIndex tile);
 
bool GUIPlaceProcDragXY(const WindowEvent *we);
 

	
 
enum { // max 32 - 4 = 28 types
 
	GUI_PlaceProc_DemolishArea    = 0 << 4,
 
	GUI_PlaceProc_LevelArea       = 1 << 4,
 
	GUI_PlaceProc_DesertArea      = 2 << 4,
industry_cmd.c
Show inline comments
 
@@ -34,14 +34,14 @@ void IndustryPoolNewBlock(uint start_ite
 
MemoryPool _industry_pool = { "Industry", INDUSTRY_POOL_MAX_BLOCKS, INDUSTRY_POOL_BLOCK_SIZE_BITS, sizeof(Industry), &IndustryPoolNewBlock, 0, 0, NULL };
 

	
 
byte _industry_sound_ctr;
 
TileIndex _industry_sound_tile;
 

	
 
void ShowIndustryViewWindow(int industry);
 
void BuildOilRig(uint tile);
 
void DeleteOilRig(uint tile);
 
void BuildOilRig(TileIndex tile);
 
void DeleteOilRig(TileIndex tile);
 

	
 
typedef struct DrawIndustryTileStruct {
 
	uint32 sprite_1;
 
	uint32 sprite_2;
 

	
 
	byte subtile_xy;
 
@@ -398,13 +398,13 @@ static uint GetSlopeZ_Industry(TileInfo 
 
}
 

	
 
static uint GetSlopeTileh_Industry(TileInfo *ti) {
 
	return 0;
 
}
 

	
 
static void GetAcceptedCargo_Industry(uint tile, AcceptedCargo ac)
 
static void GetAcceptedCargo_Industry(TileIndex tile, AcceptedCargo ac)
 
{
 
	int m5 = _map5[tile];
 
	int a;
 

	
 
	a = _industry_map5_accepts_1[m5];
 
	if (a >= 0) ac[a] = (a == 0) ? 1 : 8;
 
@@ -413,25 +413,25 @@ static void GetAcceptedCargo_Industry(ui
 
	if (a >= 0) ac[a] = 8;
 

	
 
	a = _industry_map5_accepts_3[m5];
 
	if (a >= 0) ac[a] = 8;
 
}
 

	
 
static void GetTileDesc_Industry(uint tile, TileDesc *td)
 
static void GetTileDesc_Industry(TileIndex tile, TileDesc *td)
 
{
 
	Industry *i = GetIndustry(_map2[tile]);
 

	
 
	td->owner = i->owner;
 
	td->str = STR_4802_COAL_MINE + i->type;
 
	if ((_map_owner[tile] & 0x80) == 0) {
 
		SetDParamX(td->dparam, 0, td->str);
 
		td->str = STR_2058_UNDER_CONSTRUCTION;
 
	}
 
}
 

	
 
static int32 ClearTile_Industry(uint tile, byte flags)
 
static int32 ClearTile_Industry(TileIndex tile, byte flags)
 
{
 
	Industry *i = GetIndustry(_map2[tile]);
 

	
 
	/*	* water can destroy industries
 
			* in editor you can bulldoze industries
 
			* with magic_bulldozer cheat you can destroy industries
 
@@ -456,13 +456,13 @@ static const byte _industry_min_cargo[] 
 
	5, 5, 5, 5, 2, 5, 5, 5,
 
	5, 5, 5, 15, 15, 5, 5, 5,
 
	5, 5, 30, 5, 30, 5, 5, 5,
 
	5, 5, 5, 5, 5,
 
};
 

	
 
static void TransportIndustryGoods(uint tile)
 
static void TransportIndustryGoods(TileIndex tile)
 
{
 
	Industry *i;
 
	int type;
 
	uint cw, am;
 
	byte m5;
 

	
 
@@ -499,13 +499,13 @@ static void TransportIndustryGoods(uint 
 
		am = MoveGoodsToStation(i->xy, i->width, i->height, i->produced_cargo[1], cw);
 
		i->last_mo_transported[1] += am;
 
	}
 
}
 

	
 

	
 
static void AnimateTile_Industry(uint tile)
 
static void AnimateTile_Industry(TileIndex tile)
 
{
 
	byte m,n;
 

	
 
	switch(_map5[tile]) {
 
	case 174:
 
		if ((_tick_counter & 1) == 0) {
 
@@ -658,20 +658,20 @@ static void AnimateTile_Industry(uint ti
 
				MarkTileDirtyByTile(tile);
 
			}
 
		} break;
 
	}
 
}
 

	
 
static void MakeIndustryTileBiggerCase8(uint tile)
 
static void MakeIndustryTileBiggerCase8(TileIndex tile)
 
{
 
	TileInfo ti;
 
	FindLandscapeHeight(&ti, TileX(tile) * 16, TileY(tile) * 16);
 
	CreateEffectVehicle(ti.x + 15, ti.y + 14, ti.z + 59 + (ti.tileh != 0 ? 8 : 0), EV_CHIMNEY_SMOKE);
 
}
 

	
 
static void MakeIndustryTileBigger(uint tile, byte size)
 
static void MakeIndustryTileBigger(TileIndex tile, byte size)
 
{
 
	byte b = (byte)((size + (1<<2)) & (3<<2));
 

	
 
	if (b != 0) {
 
		_map_owner[tile] = b | (size & 3);
 
		return;
 
@@ -710,13 +710,13 @@ static void MakeIndustryTileBigger(uint 
 
		break;
 
	}
 
}
 

	
 

	
 

	
 
static void TileLoopIndustryCase161(uint tile)
 
static void TileLoopIndustryCase161(TileIndex tile)
 
{
 
	int dir;
 
	Vehicle *v;
 
	static const int8 _tileloop_ind_case_161[12] = {
 
		11, 0, -4, -14,
 
		-4, -10, -4, 1,
 
@@ -735,13 +735,13 @@ static void TileLoopIndustryCase161(uint
 
	);
 

	
 
	if (v != NULL)
 
		v->u.special.unk2 = dir;
 
}
 

	
 
static void TileLoop_Industry(uint tile)
 
static void TileLoop_Industry(TileIndex tile)
 
{
 
	byte n;
 

	
 
	if (!(_map_owner[tile] & 0x80)) {
 
		MakeIndustryTileBigger(tile, _map_owner[tile]);
 
		return;
 
@@ -844,30 +844,30 @@ static void TileLoop_Industry(uint tile)
 
		}
 
		break;
 
	}
 
}
 

	
 

	
 
static void ClickTile_Industry(uint tile)
 
static void ClickTile_Industry(TileIndex tile)
 
{
 
	ShowIndustryViewWindow(_map2[tile]);
 
}
 

	
 
static uint32 GetTileTrackStatus_Industry(uint tile, TransportType mode)
 
static uint32 GetTileTrackStatus_Industry(TileIndex tile, TransportType mode)
 
{
 
	return 0;
 
}
 

	
 
static void GetProducedCargo_Industry(uint tile, byte *b)
 
static void GetProducedCargo_Industry(TileIndex tile, byte *b)
 
{
 
	Industry *i = GetIndustry(_map2[tile]);
 
	b[0] = i->produced_cargo[0];
 
	b[1] = i->produced_cargo[1];
 
}
 

	
 
static void ChangeTileOwner_Industry(uint tile, byte old_player, byte new_player)
 
static void ChangeTileOwner_Industry(TileIndex tile, byte old_player, byte new_player)
 
{
 
	/* not used */
 
}
 

	
 
void DeleteIndustry(Industry *i)
 
{
 
@@ -919,13 +919,13 @@ static bool IsBadFarmFieldTile2(TileInde
 

	
 
		default:
 
			return true;
 
	}
 
}
 

	
 
static void SetupFarmFieldFence(uint tile, int size, byte type, int direction)
 
static void SetupFarmFieldFence(TileIndex tile, int size, byte type, int direction)
 
{
 
	byte or, and;
 

	
 
	do {
 
		tile = TILE_MASK(tile);
 

	
 
@@ -944,13 +944,13 @@ static void SetupFarmFieldFence(uint til
 
		}
 

	
 
		tile += direction ? TILE_XY(0,1) : TILE_XY(1,0);
 
	} while (--size);
 
}
 

	
 
static void PlantFarmField(uint tile)
 
static void PlantFarmField(TileIndex tile)
 
{
 
	uint size_x, size_y;
 
	uint32 r;
 
	int count;
 
	int type, type2;
 

	
 
@@ -1005,13 +1005,14 @@ static void PlantFarmField(uint tile)
 
	SetupFarmFieldFence(tile+TILE_XY(1,0) * (size_x-1), size_y, type, 1);
 
	SetupFarmFieldFence(tile+TILE_XY(0,1) * (size_y-1), size_x, type, 0);
 
}
 

	
 
static void MaybePlantFarmField(Industry *i)
 
{
 
	uint tile;
 
	TileIndex tile;
 

	
 
	if (CHANCE16(1,8)) {
 
		int x = (i->width>>1) + Random() % 31 - 16;
 
		int y = (i->height>>1) + Random() % 31 - 16;
 
		tile = TileAddWrap(i->xy, x, y);
 
		if (tile != INVALID_TILE)
 
			PlantFarmField(tile);
 
@@ -1024,13 +1025,13 @@ static void ChopLumberMillTrees(Industry
 
		{ 0,  1},
 
		{ 1,  0},
 
		{ 0, -1},
 
		{-1,  0}
 
	};
 

	
 
	uint tile = i->xy;
 
	TileIndex tile = i->xy;
 
	int dir, a, j;
 

	
 
	if ((_map_owner[tile] & 0x80) == 0)
 
		return;
 

	
 
	/* search outwards as a rectangular spiral */
 
@@ -1154,18 +1155,18 @@ void OnTick_Industry(void)
 
		if (i->xy != 0)
 
			ProduceIndustryGoods(i);
 
	}
 
}
 

	
 

	
 
static bool CheckNewIndustry_NULL(uint tile, int type)
 
static bool CheckNewIndustry_NULL(TileIndex tile, int type)
 
{
 
	return true;
 
}
 

	
 
static bool CheckNewIndustry_Forest(uint tile, int type)
 
static bool CheckNewIndustry_Forest(TileIndex tile, int type)
 
{
 
	if (_opt.landscape == LT_HILLY) {
 
		if (GetTileZ(tile) < _opt.snow_line + 16U) {
 
			_error_message = STR_4831_FOREST_CAN_ONLY_BE_PLANTED;
 
			return false;
 
		}
 
@@ -1173,13 +1174,13 @@ static bool CheckNewIndustry_Forest(uint
 
	return true;
 
}
 

	
 
extern bool _ignore_restrictions;
 

	
 
/* Oil Rig and Oil Refinery */
 
static bool CheckNewIndustry_Oil(uint tile, int type)
 
static bool CheckNewIndustry_Oil(TileIndex tile, int type)
 
{
 
	if(_ignore_restrictions && _game_mode == GM_EDITOR)
 
		return true;
 

	
 
	if (type != IT_OIL_RIG && _game_mode == GM_EDITOR)
 
		return true;
 
@@ -1188,86 +1189,86 @@ static bool CheckNewIndustry_Oil(uint ti
 
		return true;
 

	
 
	_error_message = STR_483B_CAN_ONLY_BE_POSITIONED;
 
	return false;
 
}
 

	
 
static bool CheckNewIndustry_Farm(uint tile, int type)
 
static bool CheckNewIndustry_Farm(TileIndex tile, int type)
 
{
 
	if (_opt.landscape == LT_HILLY) {
 
		if (GetTileZ(tile) + 16 >= _opt.snow_line) {
 
			_error_message = STR_0239_SITE_UNSUITABLE;
 
			return false;
 
		}
 
	}
 
	return true;
 
}
 

	
 
static bool CheckNewIndustry_Plantation(uint tile, int type)
 
static bool CheckNewIndustry_Plantation(TileIndex tile, int type)
 
{
 
	if (GetMapExtraBits(tile) == 1) {
 
		_error_message = STR_0239_SITE_UNSUITABLE;
 
		return false;
 
	}
 

	
 
	return true;
 
}
 

	
 
static bool CheckNewIndustry_Water(uint tile, int type)
 
static bool CheckNewIndustry_Water(TileIndex tile, int type)
 
{
 
	if (GetMapExtraBits(tile) != 1) {
 
		_error_message = STR_0318_CAN_ONLY_BE_BUILT_IN_DESERT;
 
		return false;
 
	}
 

	
 
	return true;
 
}
 

	
 
static bool CheckNewIndustry_Lumbermill(uint tile, int type)
 
static bool CheckNewIndustry_Lumbermill(TileIndex tile, int type)
 
{
 
	if (GetMapExtraBits(tile) != 2) {
 
		_error_message = STR_0317_CAN_ONLY_BE_BUILT_IN_RAINFOREST;
 
		return false;
 
	}
 
	return true;
 
}
 

	
 
static bool CheckNewIndustry_BubbleGen(uint tile, int type)
 
static bool CheckNewIndustry_BubbleGen(TileIndex tile, int type)
 
{
 
	if (GetTileZ(tile) > 32) {
 
		return false;
 
	}
 
	return true;
 
}
 

	
 
typedef bool CheckNewIndustryProc(uint tile, int type);
 
typedef bool CheckNewIndustryProc(TileIndex tile, int type);
 
static CheckNewIndustryProc * const _check_new_industry_procs[] = {
 
	CheckNewIndustry_NULL,
 
	CheckNewIndustry_Forest,
 
	CheckNewIndustry_Oil,
 
	CheckNewIndustry_Farm,
 
	CheckNewIndustry_Plantation,
 
	CheckNewIndustry_Water,
 
	CheckNewIndustry_Lumbermill,
 
	CheckNewIndustry_BubbleGen,
 
};
 

	
 
static bool CheckSuitableIndustryPos(uint tile)
 
static bool CheckSuitableIndustryPos(TileIndex tile)
 
{
 
	uint x = TileX(tile);
 
	uint y = TileY(tile);
 

	
 
	if ( x < 2 || y < 2 || x > MapMaxX() - 3 || y > MapMaxY() - 3) {
 
		_error_message = STR_0239_SITE_UNSUITABLE;
 
		return false;
 
	}
 

	
 
	return true;
 
}
 

	
 
static Town *CheckMultipleIndustryInTown(uint tile, int type)
 
static Town *CheckMultipleIndustryInTown(TileIndex tile, int type)
 
{
 
	Town *t;
 
	Industry *i;
 

	
 
	t = ClosestTownFromTile(tile, (uint)-1);
 

	
 
@@ -1308,21 +1309,21 @@ static const byte _industry_map5_bits[] 
 
	16, 16, 16, 16, 16, 16, 16, 16,
 
	16, 16, 16, 16, 16, 16, 16, 16,
 
	16, 16, 16, 16, 16, 16, 16, 16,
 
	16, 16, 16, 16, 16, 16, 16,
 
};
 

	
 
static bool CheckIfIndustryTilesAreFree(uint tile, const IndustryTileTable *it, int type, Town *t)
 
static bool CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable *it, int type, Town *t)
 
{
 
	TileInfo ti;
 
	uint cur_tile;
 

	
 
	_error_message = STR_0239_SITE_UNSUITABLE;
 

	
 
	do {
 
		cur_tile = tile + ToTileIndexDiff(it->ti);
 
		TileIndex cur_tile = tile + ToTileIndexDiff(it->ti);
 

	
 
		if (!IsValidTile(cur_tile)) {
 
			if (it->map5 == 0xff)
 
				continue;
 
			return false;
 
		}
 

	
 
@@ -1394,13 +1395,13 @@ do_clear:
 
		}
 
	} while ((++it)->ti.x != -0x80);
 

	
 
	return true;
 
}
 

	
 
static bool CheckIfTooCloseToIndustry(uint tile, int type)
 
static bool CheckIfTooCloseToIndustry(TileIndex tile, int type)
 
{
 
	Industry *i;
 
	const IndustrySpec *spec;
 
	spec = &_industry_spec[type];
 

	
 
	// accepting industries won't be close, not even with patch
 
@@ -1453,17 +1454,16 @@ static Industry *AllocateIndustry(void)
 
	if (AddBlockToPool(&_industry_pool))
 
		return AllocateIndustry();
 

	
 
	return NULL;
 
}
 

	
 
static void DoCreateNewIndustry(Industry *i, uint tile, int type, const IndustryTileTable *it, Town *t, byte owner)
 
static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const IndustryTileTable *it, Town *t, byte owner)
 
{
 
	const IndustrySpec *spec;
 
	uint32 r;
 
	uint cur_tile;
 
	int j;
 

	
 
	i->xy = tile;
 
	i->width = i->height = 0;
 
	i->type = type;
 

	
 
@@ -1506,13 +1506,13 @@ static void DoCreateNewIndustry(Industry
 
	if (_generating_world == 0)
 
		i->total_production[0] = i->total_production[1] = 0;
 

	
 
	i->prod_level = 0x10;
 

	
 
	do {
 
		cur_tile = tile + ToTileIndexDiff(it->ti);
 
		TileIndex cur_tile = tile + ToTileIndexDiff(it->ti);
 

	
 
		if (it->map5 != 0xFF) {
 
			byte size;
 

	
 
			size = it->ti.x;
 
			if (size > i->width) i->width = size;
 
@@ -1533,13 +1533,14 @@ static void DoCreateNewIndustry(Industry
 

	
 
	if (i->type == IT_FARM || i->type == IT_FARM_2) {
 
		tile = i->xy + TILE_XY((i->width >> 1), (i->height >> 1));
 
		for(j=0; j!=50; j++) {
 
			int x = Random() % 31 - 16;
 
			int y = Random() % 31 - 16;
 
			uint new_tile = TileAddWrap(tile, x, y);
 
			TileIndex  new_tile = TileAddWrap(tile, x, y);
 

	
 
			if (new_tile != INVALID_TILE)
 
				PlantFarmField(new_tile);
 
		}
 
	}
 
	_industry_sort_dirty = true;
 
	InvalidateWindow(WC_INDUSTRY_DIRECTORY, 0);
 
@@ -1601,13 +1602,13 @@ int32 CmdBuildIndustry(int x, int y, uin
 
		DoCreateNewIndustry(i, tile, p1, it, t, OWNER_NONE);
 

	
 
	return (_price.build_industry >> 5) * _industry_type_costs[p1];
 
}
 

	
 

	
 
Industry *CreateNewIndustry(uint tile, int type)
 
Industry *CreateNewIndustry(TileIndex tile, int type)
 
{
 
	Town *t;
 
	const IndustryTileTable *it;
 
	Industry *i;
 

	
 
	const IndustrySpec *spec;
main_gui.c
Show inline comments
 
@@ -141,13 +141,13 @@ bool HandlePlacePushButton(Window *w, in
 
	w->click_state |= mask;
 
	_place_proc = placeproc;
 
	return true;
 
}
 

	
 

	
 
void CcPlaySound10(bool success, uint tile, uint32 p1, uint32 p2)
 
void CcPlaySound10(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (success) SndPlayTileFx(SND_12_EXPLOSION, tile);
 
}
 

	
 

	
 
typedef void ToolbarButtonProc(Window *w);
 
@@ -1146,13 +1146,13 @@ static void AskResetLandscape(uint mode)
 
 * Raise/Lower a bigger chunk of land at the same time in the editor. When
 
 * raising get the lowest point, when lowering the highest point, and set all
 
 * tiles in the selection to that height.
 
 * @param tile The top-left tile where the terraforming will start
 
 * @param mode 1 for raising, 0 for lowering land
 
 */
 
static void CommonRaiseLowerBigLand(uint tile, int mode)
 
static void CommonRaiseLowerBigLand(TileIndex tile, int mode)
 
{
 
	int sizex, sizey;
 
	byte h;
 

	
 
	_error_message_2 = mode ? STR_0808_CAN_T_RAISE_LAND_HERE : STR_0809_CAN_T_LOWER_LAND_HERE;
 

	
 
@@ -1191,44 +1191,44 @@ static void CommonRaiseLowerBigLand(uint
 
		} END_TILE_LOOP(tile2, sizex, sizey, tile)
 
	}
 

	
 
	_generating_world = false;
 
}
 

	
 
static void PlaceProc_RaiseBigLand(uint tile)
 
static void PlaceProc_RaiseBigLand(TileIndex tile)
 
{
 
	CommonRaiseLowerBigLand(tile, 1);
 
}
 

	
 
static void PlaceProc_LowerBigLand(uint tile)
 
static void PlaceProc_LowerBigLand(TileIndex tile)
 
{
 
	CommonRaiseLowerBigLand(tile, 0);
 
}
 

	
 
static void PlaceProc_RockyArea(uint tile)
 
static void PlaceProc_RockyArea(TileIndex tile)
 
{
 
	if (!IsTileType(tile, MP_CLEAR) && !IsTileType(tile, MP_TREES))
 
		return;
 

	
 
	ModifyTile(tile, MP_SETTYPE(MP_CLEAR) | MP_MAP5, (_map5[tile] & ~0x1C) | 0xB);
 
	SndPlayTileFx(SND_1F_SPLAT, tile);
 
}
 

	
 
static void PlaceProc_LightHouse(uint tile)
 
static void PlaceProc_LightHouse(TileIndex tile)
 
{
 
	TileInfo ti;
 

	
 
	FindLandscapeHeightByTile(&ti, tile);
 
	if (ti.type != MP_CLEAR || (ti.tileh & 0x10))
 
		return;
 

	
 
	ModifyTile(tile, MP_SETTYPE(MP_UNMOVABLE) | MP_MAP5, 1);
 
	SndPlayTileFx(SND_1F_SPLAT, tile);
 
}
 

	
 
static void PlaceProc_Transmitter(uint tile)
 
static void PlaceProc_Transmitter(TileIndex tile)
 
{
 
	TileInfo ti;
 

	
 
	FindLandscapeHeightByTile(&ti, tile);
 
	if (ti.type != MP_CLEAR || (ti.tileh & 0x10))
 
		return;
 
@@ -1452,21 +1452,21 @@ static void ToolbarScenGenLand(Window *w
 
	HandleButtonClick(w, 11);
 
	SndPlayFx(SND_15_BEEP);
 

	
 
	ShowEditorTerraformToolBar();
 
}
 

	
 
void CcBuildTown(bool success, uint tile, uint32 p1, uint32 p2)
 
void CcBuildTown(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (success) {
 
		SndPlayTileFx(SND_1F_SPLAT, tile);
 
		ResetObjectToPlace();
 
	}
 
}
 

	
 
static void PlaceProc_Town(uint tile)
 
static void PlaceProc_Town(TileIndex tile)
 
{
 
	DoCommandP(tile, 0, 0, CcBuildTown, CMD_BUILD_TOWN | CMD_MSG(STR_0236_CAN_T_BUILD_TOWN_HERE));
 
}
 

	
 

	
 
static const Widget _scen_edit_town_gen_widgets[] = {
 
@@ -1652,13 +1652,13 @@ static bool AnyTownExists(void)
 
		if (t->xy)
 
			return true;
 
	}
 
	return false;
 
}
 

	
 
extern Industry *CreateNewIndustry(uint tile, int type);
 
extern Industry *CreateNewIndustry(TileIndex tile, int type);
 

	
 
static bool TryBuildIndustry(TileIndex tile, int type)
 
{
 
	int n;
 

	
 
	if (CreateNewIndustry(tile, type)) return true;
map.h
Show inline comments
 
@@ -42,13 +42,13 @@ typedef enum {
 
	OWNER_NONE			= 0x10,	// nobody owns the tile
 
	OWNER_WATER			= 0x11,	// "water" owns the tile
 
	OWNER_SPECTATOR	= 0xff,	// spectator in MP or in scenario editor
 
} Owner;
 

	
 
enum {
 
	INVALID_TILE = (uint32) -1
 
	INVALID_TILE = (TileIndex)-1
 
};
 

	
 
enum {
 
	TILE_SIZE   = 16,   /* Tiles are 16x16 "units" in size */
 
	TILE_PIXELS = 32,   /* a tile is 32x32 pixels */
 
	TILE_HEIGHT = 8,    /* The standard height-difference between tiles on two levels is 8 (z-diff 8) */
misc_gui.c
Show inline comments
 
@@ -27,13 +27,13 @@ static bool _savegame_sort_dirty;
 
bool _query_string_active;
 

	
 
typedef struct LandInfoData {
 
	Town *town;
 
	int32 costclear;
 
	AcceptedCargo ac;
 
	uint tile;
 
	TileIndex tile;
 
	TileDesc td;
 
} LandInfoData;
 

	
 
static void LandInfoWndProc(Window *w, WindowEvent *e)
 
{
 
	LandInfoData *lid;
 
@@ -112,13 +112,13 @@ static const WindowDesc _land_info_desc 
 
	WC_LAND_INFO,0,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
 
	_land_info_widgets,
 
	LandInfoWndProc
 
};
 

	
 
static void Place_LandInfo(uint tile)
 
static void Place_LandInfo(TileIndex tile)
 
{
 
	Player *p;
 
	static LandInfoData lid;
 
	Window *w;
 
	int64 old_money;
 

	
network_data.c
Show inline comments
 
@@ -393,13 +393,13 @@ void NetworkAddCommandQueue(NetworkClien
 
		while (c->next != NULL) c = c->next;
 
		c->next = new_cp;
 
	}
 
}
 

	
 
// Prepare a DoCommand to be send over the network
 
void NetworkSend_Command(uint32 tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback)
 
void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback)
 
{
 
	CommandPacket *c = malloc(sizeof(CommandPacket));
 
	byte temp_callback;
 

	
 
	c->player = _local_player;
 
	c->next = NULL;
network_data.h
Show inline comments
 
@@ -34,13 +34,13 @@ typedef struct Packet {
 
typedef struct CommandPacket {
 
	struct CommandPacket *next;
 
	byte player;   /// player that is executing the command (PlayerID)
 
	uint32 cmd;    /// command being executed
 
	uint32 p1;     /// parameter p1
 
	uint32 p2;     /// parameter p2
 
	uint32 tile;   /// tile command being executed on ; always make it uint32, so it is bigmap compatible (TileIndex)
 
	TileIndex tile; /// tile command being executed on
 
	char text[80];
 
	uint32 frame;  /// the frame in which this packet is executed
 
	byte callback; /// any callback function executed upon successful completion of the command
 
} CommandPacket;
 

	
 
typedef enum {
openttd.c
Show inline comments
 
@@ -1178,13 +1178,13 @@ void BeforeSaveGame(void)
 
		_saved_scrollpos_zoom = w->viewport->zoom;
 
	}
 
}
 

	
 
static void ConvertTownOwner(void)
 
{
 
	uint tile;
 
	TileIndex tile;
 

	
 
	for (tile = 0; tile != MapSize(); tile++) {
 
		if (IsTileType(tile, MP_STREET)) {
 
			if (IsLevelCrossing(tile) && _map3_lo[tile] & 0x80)
 
				_map3_lo[tile] = OWNER_TOWN;
 

	
openttd.h
Show inline comments
 
@@ -113,13 +113,13 @@ typedef enum TransportTypes {
 
typedef struct TileInfo {
 
	uint x;
 
	uint y;
 
	uint tileh;
 
	uint type;
 
	uint map5;
 
	uint tile;
 
	TileIndex tile;
 
	uint z;
 
} TileInfo;
 

	
 
enum {
 
	NG_EDGE = 1,
 
};
 
@@ -285,15 +285,15 @@ typedef struct {
 
} ViewportSign;
 

	
 
typedef int32 CommandProc(int x, int y, uint32 flags, uint32 p1, uint32 p2);
 

	
 
typedef void DrawTileProc(TileInfo *ti);
 
typedef uint GetSlopeZProc(TileInfo *ti);
 
typedef int32 ClearTileProc(uint tile, byte flags);
 
typedef void GetAcceptedCargoProc(uint tile, AcceptedCargo res);
 
typedef void GetTileDescProc(uint tile, TileDesc *td);
 
typedef int32 ClearTileProc(TileIndex tile, byte flags);
 
typedef void GetAcceptedCargoProc(TileIndex tile, AcceptedCargo res);
 
typedef void GetTileDescProc(TileIndex tile, TileDesc *td);
 
/* GetTileTrackStatusProcs return a value that contains the possible tracks
 
 * that can be taken on a given tile by a given transport. The return value is
 
 * composed as follows: 0xaabbccdd. ccdd and aabb are bitmasks of trackdirs,
 
 * where bit n corresponds to trackdir n. ccdd are the trackdirs that are
 
 * present in the tile (1==present, 0==not present), aabb is the signal
 
 * status, if applicable (0==green/no signal, 1==red, note that this is
 
@@ -307,24 +307,24 @@ typedef void GetTileDescProc(uint tile, 
 
 *
 
 * A trackdir is combination of a track and a dir, where the lower three bits
 
 * are a track, the fourth bit is the direction. these give 12 (or 14)
 
 * possible options: 0-5 and 8-13, so we need 14 bits for a trackdir bitmask
 
 * above.
 
 */
 
typedef uint32 GetTileTrackStatusProc(uint tile, TransportType mode);
 
typedef void GetProducedCargoProc(uint tile, byte *b);
 
typedef void ClickTileProc(uint tile);
 
typedef void AnimateTileProc(uint tile);
 
typedef void TileLoopProc(uint tile);
 
typedef void ChangeTileOwnerProc(uint tile, byte old_player, byte new_player);
 
typedef uint32 GetTileTrackStatusProc(TileIndex tile, TransportType mode);
 
typedef void GetProducedCargoProc(TileIndex tile, byte *b);
 
typedef void ClickTileProc(TileIndex tile);
 
typedef void AnimateTileProc(TileIndex tile);
 
typedef void TileLoopProc(TileIndex tile);
 
typedef void ChangeTileOwnerProc(TileIndex tile, byte old_player, byte new_player);
 
/* Return value has bit 0x2 set, when the vehicle enters a station. Then,
 
 * result << 8 contains the id of the station entered. If the return value has
 
 * bit 0x8 set, the vehicle could not and did not enter the tile. Are there
 
 * other bits that can be set? */
 
typedef uint32 VehicleEnterTileProc(Vehicle *v, uint tile, int x, int y);
 
typedef void VehicleLeaveTileProc(Vehicle *v, uint tile, int x, int y);
 
typedef uint32 VehicleEnterTileProc(Vehicle *v, TileIndex tile, int x, int y);
 
typedef void VehicleLeaveTileProc(Vehicle *v, TileIndex tile, int x, int y);
 
typedef uint GetSlopeTilehProc(TileInfo *ti);
 

	
 
typedef struct {
 
	DrawTileProc *draw_tile_proc;
 
	GetSlopeZProc *get_slope_z_proc;
 
	ClearTileProc *clear_tile_proc;
 
@@ -518,13 +518,13 @@ enum SpecialStrings {
 
	SPECSTR_SCREENSHOT_END = 0x715F,
 

	
 
	STR_SPEC_SCREENSHOT_NAME = 0xF800,
 
	STR_SPEC_USERSTRING = 0xF801,
 
};
 

	
 
typedef void PlaceProc(uint tile);
 
typedef void PlaceProc(TileIndex tile);
 

	
 
VARDEF byte _savegame_sort_order;
 

	
 
#define INVALID_UINT_TILE (uint)0xFFFFFFFF
 
#define INVALID_STRING_ID 0xFFFF
 

	
order_gui.c
Show inline comments
 
@@ -180,13 +180,13 @@ static void DrawOrdersWindow(Window *w)
 
		str = shared_orders ? STR_END_OF_SHARED_ORDERS : STR_882A_END_OF_ORDERS;
 
		color = (i == WP(w,order_d).sel) ? 0xC : 0x10;
 
		DrawString(2, y, str, color);
 
	}
 
}
 

	
 
static Order GetOrderCmdFromTile(Vehicle *v, uint tile)
 
static Order GetOrderCmdFromTile(Vehicle *v, TileIndex tile)
 
{
 
	Order order;
 
	Station *st;
 
	int st_index;
 

	
 
	// check depot first
 
@@ -298,13 +298,13 @@ static bool HandleOrderVehClick(Vehicle 
 
		ResetObjectToPlace();
 
	}
 

	
 
	return true;
 
}
 

	
 
static void OrdersPlaceObj(Vehicle *v, uint tile, Window *w)
 
static void OrdersPlaceObj(Vehicle *v, TileIndex tile, Window *w)
 
{
 
	Order cmd;
 
	Vehicle *u;
 

	
 
	// check if we're clicking on a vehicle first.. clone orders in that case.
 
	u = CheckMouseOverVehicle();
pathfind.c
Show inline comments
 
@@ -2,13 +2,13 @@
 
#include "openttd.h"
 
#include "map.h"
 
#include "tile.h"
 
#include "pathfind.h"
 

	
 
// remember which tiles we have already visited so we don't visit them again.
 
static bool TPFSetTileBit(TrackPathFinder *tpf, uint tile, int dir)
 
static bool TPFSetTileBit(TrackPathFinder *tpf, TileIndex tile, int dir)
 
{
 
	uint hash, val, offs;
 
	TrackPathFinderLink *link, *new_link;
 
	uint bits = 1 << dir;
 

	
 
	if (tpf->disable_tile_hash)
 
@@ -117,17 +117,17 @@ static const byte _otherdir_mask[4] = {
 
	0,
 
	0x5,
 
	0x2A,
 
};
 

	
 
#ifdef DEBUG_TILE_PUSH
 
extern void dbg_push_tile(uint tile, int track);
 
extern void dbg_push_tile(TileIndex tile, int track);
 
extern void dbg_pop_tile();
 
#endif
 

	
 
static void TPFMode2(TrackPathFinder *tpf, uint tile, int direction)
 
static void TPFMode2(TrackPathFinder *tpf, TileIndex tile, int direction)
 
{
 
	uint bits;
 
	int i;
 
	RememberData rd;
 
	int owner = -1;
 

	
 
@@ -208,13 +208,13 @@ continue_here:;
 

	
 
static const int8 _get_tunlen_inc[5] = { -16, 0, 16, 0, -16 };
 

	
 
/* Returns the end tile and the length of a tunnel. The length does not
 
 * include the starting tile (entry), it does include the end tile (exit).
 
 */
 
FindLengthOfTunnelResult FindLengthOfTunnel(uint tile, int direction)
 
FindLengthOfTunnelResult FindLengthOfTunnel(TileIndex tile, int direction)
 
{
 
	FindLengthOfTunnelResult flotr;
 
	int x,y;
 
	byte z;
 

	
 
	flotr.length = 0;
 
@@ -243,13 +243,14 @@ FindLengthOfTunnelResult FindLengthOfTun
 
	flotr.tile = tile;
 
	return flotr;
 
}
 

	
 
static const uint16 _tpfmode1_and[4] = { 0x1009, 0x16, 0x520, 0x2A00 };
 

	
 
static uint SkipToEndOfTunnel(TrackPathFinder *tpf, uint tile, int direction) {
 
static uint SkipToEndOfTunnel(TrackPathFinder *tpf, TileIndex tile, int direction)
 
{
 
	FindLengthOfTunnelResult flotr;
 
	TPFSetTileBit(tpf, tile, 14);
 
	flotr = FindLengthOfTunnel(tile, direction);
 
	tpf->rd.cur_length += flotr.length;
 
	TPFSetTileBit(tpf, flotr.tile, 14);
 
	return flotr.tile;
 
@@ -272,18 +273,18 @@ 16,24,24,26,24,28,28,30,
 
0,32,32,34,32,36,36,38,
 
32,40,40,42,40,44,44,46,
 
32,48,48,50,48,52,52,54,
 
48,56,56,58,56,60,60,62,
 
};
 

	
 
static void TPFMode1(TrackPathFinder *tpf, uint tile, int direction)
 
static void TPFMode1(TrackPathFinder *tpf, TileIndex tile, int direction)
 
{
 
	uint bits;
 
	int i;
 
	RememberData rd;
 
	uint tile_org = tile;
 
	TileIndex tile_org = tile;
 

	
 
	if (IsTileType(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xF0) == 0) {
 
		if ((_map5[tile] & 3) != direction || ((_map5[tile]>>2)&3) != tpf->tracktype)
 
			return;
 
		tile = SkipToEndOfTunnel(tpf, tile, direction);
 
	}
 
@@ -367,13 +368,13 @@ static void TPFMode1(TrackPathFinder *tp
 
			TPFMode1(tpf, tile, _tpf_new_direction[tpf->the_dir]);
 
		}
 
		tpf->rd = rd;
 
	} while (bits != 0);
 
}
 

	
 
void FollowTrack(uint tile, uint16 flags, byte direction, TPFEnumProc *enum_proc, TPFAfterProc *after_proc, void *data)
 
void FollowTrack(TileIndex tile, uint16 flags, byte direction, TPFEnumProc *enum_proc, TPFAfterProc *after_proc, void *data)
 
{
 
	TrackPathFinder tpf;
 

	
 
	assert(direction < 4);
 

	
 
	/* initialize path finder variables */
 
@@ -510,13 +511,13 @@ static inline void HeapifyDown(NewTrackP
 
	}
 
}
 

	
 
// mark a tile as visited and store the length of the path.
 
// if we already had a better path to this tile, return false.
 
// otherwise return true.
 
static bool NtpVisit(NewTrackPathFinder *tpf, uint tile, uint dir, uint length)
 
static bool NtpVisit(NewTrackPathFinder *tpf, TileIndex tile, uint dir, uint length)
 
{
 
	uint hash,head;
 
	HashLink *link, *new_link;
 

	
 
	assert(length < 1024);
 

	
 
@@ -584,13 +585,13 @@ static bool NtpVisit(NewTrackPathFinder 
 
	new_link->next = 0xFFFF;
 

	
 
	link->next = NTP_GET_LINK_OFFS(tpf, new_link);
 
	return true;
 
}
 

	
 
static bool NtpCheck(NewTrackPathFinder *tpf, uint tile, uint dir, uint length)
 
static bool NtpCheck(NewTrackPathFinder *tpf, TileIndex tile, uint dir, uint length)
 
{
 
	uint hash,head,offs;
 
	HashLink *link;
 

	
 
	hash = PATHFIND_HASH_TILE(tile);
 
	head=tpf->hash_head[hash];
 
@@ -614,13 +615,13 @@ static bool NtpCheck(NewTrackPathFinder 
 
		assert(offs != 0xffff);
 
	}
 
}
 

	
 

	
 
// new more optimized pathfinder for trains...
 
static void NTPEnum(NewTrackPathFinder *tpf, uint tile, uint direction)
 
static void NTPEnum(NewTrackPathFinder *tpf, TileIndex tile, uint direction)
 
{
 
	uint bits, tile_org;
 
	int i;
 
	StackedItem si;
 
	FindLengthOfTunnelResult flotr;
 

	
 
@@ -741,13 +742,13 @@ popnext:
 
	direction = _tpf_new_direction[si.track];
 
	goto restart;
 
}
 

	
 

	
 
// new pathfinder for trains. better and faster.
 
void NewTrainPathfind(uint tile, byte direction, TPFEnumProc *enum_proc, void *data, byte *cache)
 
void NewTrainPathfind(TileIndex tile, byte direction, TPFEnumProc *enum_proc, void *data, byte *cache)
 
{
 
	if (!_patches.new_pathfinding) {
 
		FollowTrack(tile, 0x3000 | TRANSPORT_RAIL, direction, enum_proc, NULL, data);
 
	} else {
 
		NewTrackPathFinder tpf;
 
		tpf.userdata = data;
pathfind.h
Show inline comments
 
@@ -2,13 +2,13 @@
 
#define PATHFIND_H
 

	
 
//#define PF_BENCH // perform simple benchmarks on the train pathfinder (not
 
//supported on all archs)
 

	
 
typedef struct TrackPathFinder TrackPathFinder;
 
typedef bool TPFEnumProc(uint tile, void *data, int track, uint length, byte *state);
 
typedef bool TPFEnumProc(TileIndex tile, void *data, int track, uint length, byte *state);
 
typedef void TPFAfterProc(TrackPathFinder *tpf);
 

	
 

	
 
#define PATHFIND_GET_LINK_OFFS(tpf, link) ((byte*)(link) - (byte*)tpf->links)
 
#define PATHFIND_GET_LINK_PTR(tpf, link_offs) (TrackPathFinderLink*)((byte*)tpf->links + (link_offs))
 

	
 
@@ -52,17 +52,17 @@ struct TrackPathFinder {
 
	uint16 hash_head[0x400];
 
	TileIndex hash_tile[0x400]; /* stores the link index when multi link. */
 

	
 
	TrackPathFinderLink links[0x400]; /* hopefully, this is enough. */
 
};
 

	
 
void FollowTrack(uint tile, uint16 flags, byte direction, TPFEnumProc *enum_proc, TPFAfterProc *after_proc, void *data);
 
void FollowTrack(TileIndex tile, uint16 flags, byte direction, TPFEnumProc *enum_proc, TPFAfterProc *after_proc, void *data);
 

	
 
typedef struct {
 
	uint tile;
 
	TileIndex tile;
 
	int length;
 
} FindLengthOfTunnelResult;
 
FindLengthOfTunnelResult FindLengthOfTunnel(uint tile, int direction);
 
FindLengthOfTunnelResult FindLengthOfTunnel(TileIndex tile, int direction);
 

	
 
void NewTrainPathfind(uint tile, byte direction, TPFEnumProc *enum_proc, void *data, byte *cache);
 
void NewTrainPathfind(TileIndex tile, byte direction, TPFEnumProc *enum_proc, void *data, byte *cache);
 

	
 
#endif /* PATHFIND_H */
player.h
Show inline comments
 
@@ -184,13 +184,13 @@ typedef struct Player {
 
	int64 yearly_expenses[3][13];
 
	PlayerEconomyEntry cur_economy;
 
	PlayerEconomyEntry old_economy[24];
 
} Player;
 

	
 
void ChangeOwnershipOfPlayerItems(byte old_player, byte new_player);
 
void GetNameOfOwner(byte owner, uint tile);
 
void GetNameOfOwner(byte owner, TileIndex tile);
 
int64 CalculateCompanyValue(Player *p);
 
void InvalidatePlayerWindows(Player *p);
 
void AiDoGameLoop(Player *p);
 
void UpdatePlayerMoney32(Player *p);
 
#define FOR_ALL_PLAYERS(p) for(p=_players; p != endof(_players); p++)
 

	
players.c
Show inline comments
 
@@ -245,13 +245,13 @@ void UpdatePlayerMoney32(Player *p)
 
	else if (p->money64 > 2000000000)
 
		p->player_money = 2000000000;
 
	else
 
		p->player_money = (int32)p->money64;
 
}
 

	
 
void GetNameOfOwner(byte owner, uint tile)
 
void GetNameOfOwner(byte owner, TileIndex tile)
 
{
 
	SetDParam(2, owner);
 

	
 
	if (owner != OWNER_TOWN) {
 
		if (owner >= 8)
 
			SetDParam(0, STR_0150_SOMEONE);
 
@@ -276,13 +276,13 @@ bool CheckOwnership(byte owner)
 
		return true;
 
	_error_message = STR_013B_OWNED_BY;
 
	GetNameOfOwner(owner, 0);
 
	return false;
 
}
 

	
 
bool CheckTileOwnership(uint tile)
 
bool CheckTileOwnership(TileIndex tile)
 
{
 
	byte owner = GetTileOwner(tile);
 

	
 
	assert(owner <= OWNER_WATER);
 

	
 
	if (owner == _current_player)
 
@@ -294,13 +294,13 @@ bool CheckTileOwnership(uint tile)
 
		GetNameOfOwner(owner, tile);
 
	return false;
 
}
 

	
 
static void GenerateCompanyName(Player *p)
 
{
 
	uint tile;
 
	TileIndex tile;
 
	Town *t;
 
	StringID str;
 
	Player *pp;
 
	uint32 strp;
 
	char buffer[100];
 

	
rail_cmd.c
Show inline comments
 
@@ -18,13 +18,13 @@
 
#include "depot.h"
 
#include "waypoint.h"
 
#include "rail.h"
 

	
 
extern uint16 _custom_sprites_base;
 

	
 
void ShowTrainDepotWindow(uint tile);
 
void ShowTrainDepotWindow(TileIndex tile);
 

	
 
/* Format of rail map5 byte.
 
 * 00 abcdef  => Normal rail
 
 * 01 abcdef  => Rail with signals
 
 * 10 ??????  => Unused
 
 * 11 ????dd  => Depot
 
@@ -949,15 +949,15 @@ int32 CmdRemoveSingleSignal(int x, int y
 
 */
 
int32 CmdRemoveSignalTrack(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	return CmdSignalTrackHelper(x, y, flags, p1, SETBIT(p2, 0));
 
}
 

	
 
typedef int32 DoConvertRailProc(uint tile, uint totype, bool exec);
 
typedef int32 DoConvertRailProc(TileIndex tile, uint totype, bool exec);
 

	
 
static int32 DoConvertRail(uint tile, uint totype, bool exec)
 
static int32 DoConvertRail(TileIndex tile, uint totype, bool exec)
 
{
 
	if (!CheckTileOwnership(tile) || !EnsureNoVehicle(tile))
 
		return CMD_ERROR;
 

	
 
	// tile is already of requested type?
 
	if ( GetRailType(tile) == totype)
 
@@ -969,15 +969,15 @@ static int32 DoConvertRail(uint tile, ui
 
		MarkTileDirtyByTile(tile);
 
	}
 

	
 
	return _price.build_rail / 2;
 
}
 

	
 
extern int32 DoConvertStationRail(uint tile, uint totype, bool exec);
 
extern int32 DoConvertStreetRail(uint tile, uint totype, bool exec);
 
extern int32 DoConvertTunnelBridgeRail(uint tile, uint totype, bool exec);
 
extern int32 DoConvertStationRail(TileIndex tile, uint totype, bool exec);
 
extern int32 DoConvertStreetRail(TileIndex tile, uint totype, bool exec);
 
extern int32 DoConvertTunnelBridgeRail(TileIndex tile, uint totype, bool exec);
 

	
 
/** Convert one rail type to the other. You can convert normal rail to
 
 * monorail/maglev easily or vice-versa.
 
 * @param ex,ey end tile of rail conversion drag
 
 * @param p1 start tile of drag
 
 * @param p2 new railtype to convert to
 
@@ -1023,13 +1023,13 @@ int32 CmdConvertRail(int ex, int ey, uin
 
		}
 
	}
 

	
 
	return (cost == 0) ? CMD_ERROR : cost;
 
}
 

	
 
static int32 RemoveTrainDepot(uint tile, uint32 flags)
 
static int32 RemoveTrainDepot(TileIndex tile, uint32 flags)
 
{
 
	if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER)
 
		return CMD_ERROR;
 

	
 
	if (!EnsureNoVehicle(tile))
 
		return CMD_ERROR;
 
@@ -1534,13 +1534,13 @@ typedef struct SetSignalsData {
 
	// these are used to keep track of the stack that modifies presignals recursively
 
	TileIndex next_tile[NUM_SSD_STACK];
 
	byte next_dir[NUM_SSD_STACK];
 

	
 
} SetSignalsData;
 

	
 
static bool SetSignalsEnumProc(uint tile, SetSignalsData *ssd, int track, uint length, byte *state)
 
static bool SetSignalsEnumProc(TileIndex tile, SetSignalsData *ssd, int track, uint length, byte *state)
 
{
 
	// the tile has signals?
 
	if (IsTileType(tile, MP_RAILWAY)) {
 
		if (HasSignalOnTrack(tile, TrackdirToTrack(track))) {
 
			if ((_map3_lo[tile] & _signals_table[track]) != 0) {
 
				// yes, add the signal to the list of signals
 
@@ -1694,13 +1694,13 @@ static void ChangeSignalStates(SetSignal
 
	//   if no train is in the segment AND
 
	//   there is at least one green exit signal OR
 
	//   there are no exit signals in the segment
 

	
 
	// then mark the signals in the segment accordingly
 
	for(i=0; i!=ssd->cur; i++) {
 
		uint tile = ssd->tile[i];
 
		TileIndex tile = ssd->tile[i];
 
		byte bit = _signals_table[ssd->bit[i]];
 
		uint16 m2 = _map2[tile];
 

	
 
		// presignals don't turn green if there is at least one presignal exit and none are free
 
		if (_map3_hi[tile] & 1) {
 
			int ex = ssd->presignal_exits, exfree = ssd->presignal_exits_free;
 
@@ -1742,13 +1742,13 @@ make_red:
 
		_map2[tile] = m2 ^ bit;
 
		MarkTileDirtyByTile(tile);
 
	}
 
}
 

	
 

	
 
bool UpdateSignalsOnSegment(uint tile, byte direction)
 
bool UpdateSignalsOnSegment(TileIndex tile, byte direction)
 
{
 
	SetSignalsData ssd;
 
	int result = -1;
 

	
 
	ssd.cur_stack = 0;
 
	direction>>=1;
 
@@ -1773,13 +1773,13 @@ bool UpdateSignalsOnSegment(uint tile, b
 
		direction = ssd.next_dir[ssd.cur_stack];
 
	}
 

	
 
	return (bool)result;
 
}
 

	
 
void SetSignalsOnBothDir(uint tile, byte track)
 
void SetSignalsOnBothDir(TileIndex tile, byte track)
 
{
 
	static const byte _search_dir_1[6] = {1, 3, 1, 3, 5, 3};
 
	static const byte _search_dir_2[6] = {5, 7, 7, 5, 7, 1};
 

	
 
	UpdateSignalsOnSegment(tile, _search_dir_1[track]);
 
	UpdateSignalsOnSegment(tile, _search_dir_2[track]);
 
@@ -1830,23 +1830,23 @@ static uint GetSlopeTileh_Track(TileInfo
 
			return 0;
 
		}
 
	}
 
	return ti->tileh;
 
}
 

	
 
static void GetAcceptedCargo_Track(uint tile, AcceptedCargo ac)
 
static void GetAcceptedCargo_Track(TileIndex tile, AcceptedCargo ac)
 
{
 
	/* not used */
 
}
 

	
 
static void AnimateTile_Track(uint tile)
 
static void AnimateTile_Track(TileIndex tile)
 
{
 
	/* not used */
 
}
 

	
 
static void TileLoop_Track(uint tile)
 
static void TileLoop_Track(TileIndex tile)
 
{
 
	byte a2;
 
	byte rail;
 
	uint16 m2;
 
	byte owner;
 

	
 
@@ -1926,13 +1926,14 @@ modify_me:;
 
		_map2[tile] = (_map2[tile] & ~RAIL_MAP2LO_GROUND_MASK) | a2;
 
		MarkTileDirtyByTile(tile);
 
	}
 
}
 

	
 

	
 
static uint32 GetTileTrackStatus_Track(uint tile, TransportType mode) {
 
static uint32 GetTileTrackStatus_Track(TileIndex tile, TransportType mode)
 
{
 
	byte m5, a;
 
	uint16 b;
 
	uint32 ret;
 

	
 
	if (mode != TRANSPORT_RAIL)
 
		return 0;
 
@@ -1971,13 +1972,13 @@ static uint32 GetTileTrackStatus_Track(u
 
		ret = (m5 << 8) + m5;
 
	} else
 
		return 0;
 
	return ret;
 
}
 

	
 
static void ClickTile_Track(uint tile)
 
static void ClickTile_Track(TileIndex tile)
 
{
 
	if (IsTileDepotType(tile, TRANSPORT_RAIL))
 
		ShowTrainDepotWindow(tile);
 
	else if (IsRailWaypoint(_map5[tile]))
 
		ShowRenameWaypointWindow(GetWaypointByTile(tile));
 

	
 
@@ -2008,13 +2009,13 @@ static void GetTileDesc_Track(TileIndex 
 
			td->str = ((_map5[tile] & RAIL_SUBTYPE_MASK) == RAIL_SUBTYPE_DEPOT) ?
 
				STR_1023_RAILROAD_TRAIN_DEPOT : STR_LANDINFO_WAYPOINT;
 
			break;
 
	}
 
}
 

	
 
static void ChangeTileOwner_Track(uint tile, byte old_player, byte new_player)
 
static void ChangeTileOwner_Track(TileIndex tile, byte old_player, byte new_player)
 
{
 
	if (!IsTileOwner(tile, old_player)) return;
 

	
 
	if (new_player != 255) {
 
		SetTileOwner(tile, new_player);
 
	}	else {
 
@@ -2029,13 +2030,13 @@ static const byte _deltacoord_leaveoffse
 
	 0,  1,  0, -1  /* y */
 
};
 
static const byte _enter_directions[4] = {5, 7, 1, 3};
 
static const byte _leave_directions[4] = {1, 3, 5, 7};
 
static const byte _depot_track_mask[4] = {1, 2, 1, 2};
 

	
 
static uint32 VehicleEnter_Track(Vehicle *v, uint tile, int x, int y)
 
static uint32 VehicleEnter_Track(Vehicle *v, TileIndex tile, int x, int y)
 
{
 
	byte fract_coord;
 
	byte fract_coord_leave;
 
	int dir;
 
	int length;
 

	
rail_gui.c
Show inline comments
 
@@ -26,61 +26,61 @@ struct {
 
	byte numtracks;
 
	byte platlength;
 
	bool dragdrop;
 
} _railstation;
 

	
 

	
 
static void HandleStationPlacement(uint start, uint end);
 
static void HandleStationPlacement(TileIndex start, TileIndex end);
 
static void ShowBuildTrainDepotPicker(void);
 
static void ShowBuildWaypointPicker(void);
 
static void ShowStationBuilder(void);
 

	
 
typedef void OnButtonClick(Window *w);
 

	
 
void CcPlaySound1E(bool success, uint tile, uint32 p1, uint32 p2)
 
void CcPlaySound1E(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (success) SndPlayTileFx(SND_20_SPLAT_2, tile);
 
}
 

	
 
static void GenericPlaceRail(uint tile, int cmd)
 
static void GenericPlaceRail(TileIndex tile, int cmd)
 
{
 
	DoCommandP(tile, _cur_railtype, cmd, CcPlaySound1E,
 
		_remove_button_clicked ?
 
		CMD_REMOVE_SINGLE_RAIL | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) | CMD_AUTO | CMD_NO_WATER :
 
		CMD_BUILD_SINGLE_RAIL | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK) | CMD_AUTO | CMD_NO_WATER
 
		);
 
}
 

	
 
static void PlaceRail_N(uint tile)
 
static void PlaceRail_N(TileIndex tile)
 
{
 
	int cmd = _tile_fract_coords.x > _tile_fract_coords.y ? 4 : 5;
 
	GenericPlaceRail(tile, cmd);
 
}
 

	
 
static void PlaceRail_NE(uint tile)
 
static void PlaceRail_NE(TileIndex tile)
 
{
 
	VpStartPlaceSizing(tile, VPM_FIX_Y);
 
}
 

	
 
static void PlaceRail_E(uint tile)
 
static void PlaceRail_E(TileIndex tile)
 
{
 
	int cmd = _tile_fract_coords.x + _tile_fract_coords.y <= 15 ? 2 : 3;
 
	GenericPlaceRail(tile, cmd);
 
}
 

	
 
static void PlaceRail_NW(uint tile)
 
static void PlaceRail_NW(TileIndex tile)
 
{
 
	VpStartPlaceSizing(tile, VPM_FIX_X);
 
}
 

	
 
static void PlaceRail_AutoRail(uint tile)
 
static void PlaceRail_AutoRail(TileIndex tile)
 
{
 
	VpStartPlaceSizing(tile, VPM_RAILDIRS);
 
}
 

	
 
static void PlaceExtraDepotRail(uint tile, uint16 extra)
 
static void PlaceExtraDepotRail(TileIndex tile, uint16 extra)
 
{
 
	byte b = _map5[tile];
 

	
 
	if (b & 0xC0 || !(b & (extra >> 8)))
 
		return;
 

	
 
@@ -91,13 +91,13 @@ static const uint16 _place_depot_extra[1
 
	0x604,		0x2102,		0x1202,		0x505,
 
	0x2400,		0x2801,		0x1800,		0x1401,
 
	0x2203,		0x904,		0x0A05,		0x1103,
 
};
 

	
 

	
 
void CcRailDepot(bool success, uint tile, uint32 p1, uint32 p2)
 
void CcRailDepot(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (success) {
 
		int dir = p2;
 

	
 
		SndPlayTileFx(SND_20_SPLAT_2, tile);
 
		ResetObjectToPlace();
 
@@ -109,36 +109,36 @@ void CcRailDepot(bool success, uint tile
 
			PlaceExtraDepotRail(tile, _place_depot_extra[dir + 4]);
 
			PlaceExtraDepotRail(tile, _place_depot_extra[dir + 8]);
 
		}
 
	}
 
}
 

	
 
static void PlaceRail_Depot(uint tile)
 
static void PlaceRail_Depot(TileIndex tile)
 
{
 
	DoCommandP(tile, _cur_railtype, _build_depot_direction, CcRailDepot,
 
		CMD_BUILD_TRAIN_DEPOT | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_100E_CAN_T_BUILD_TRAIN_DEPOT));
 
}
 

	
 
static void PlaceRail_Waypoint(uint tile)
 
static void PlaceRail_Waypoint(TileIndex tile)
 
{
 
	if (!_remove_button_clicked) {
 
		DoCommandP(tile, (_waypoint_count > 0) ? (0x100 + _cur_waypoint_type) : 0, 0, CcPlaySound1E, CMD_BUILD_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_BUILD_TRAIN_WAYPOINT));
 
	} else {
 
		DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_REMOVE_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_REMOVE_TRAIN_WAYPOINT));
 
	}
 
}
 

	
 
void CcStation(bool success, uint tile, uint32 p1, uint32 p2)
 
void CcStation(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (success) {
 
		SndPlayTileFx(SND_20_SPLAT_2, tile);
 
		ResetObjectToPlace();
 
	}
 
}
 

	
 
static void PlaceRail_Station(uint tile)
 
static void PlaceRail_Station(TileIndex tile)
 
{
 
	if(_remove_button_clicked)
 
		DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION));
 
	else if (_railstation.dragdrop) {
 
		VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED);
 
		VpSetPlaceSizingLimit(_patches.station_spread);
 
@@ -147,13 +147,13 @@ static void PlaceRail_Station(uint tile)
 
		// (and fall back to normal stations if it isn't available).
 
		DoCommandP(tile, _railstation.orientation | (_railstation.numtracks<<8) | (_railstation.platlength<<16),_cur_railtype|1<<4, CcStation,
 
				CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_AUTO | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION));
 
	}
 
}
 

	
 
static void GenericPlaceSignals(uint tile)
 
static void GenericPlaceSignals(TileIndex tile)
 
{
 
	uint trackstat;
 
	int i;
 

	
 
	trackstat = (byte)GetTileTrackStatus(tile, TRANSPORT_RAIL);
 

	
 
@@ -173,44 +173,44 @@ static void GenericPlaceSignals(uint til
 
	} else {
 
		DoCommandP(tile, i, 0, CcPlaySound1E,
 
			CMD_REMOVE_SIGNALS | CMD_AUTO | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM));
 
	}
 
}
 

	
 
static void PlaceRail_Bridge(uint tile)
 
static void PlaceRail_Bridge(TileIndex tile)
 
{
 
	VpStartPlaceSizing(tile, VPM_X_OR_Y);
 
}
 

	
 
void CcBuildRailTunnel(bool success, uint tile, uint32 p1, uint32 p2)
 
void CcBuildRailTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (success) {
 
		SndPlayTileFx(SND_20_SPLAT_2, tile);
 
		ResetObjectToPlace();
 
	} else {
 
		SetRedErrorSquare(_build_tunnel_endtile);
 
	}
 
}
 

	
 
static void PlaceRail_Tunnel(uint tile)
 
static void PlaceRail_Tunnel(TileIndex tile)
 
{
 
	DoCommandP(tile, _cur_railtype, 0, CcBuildRailTunnel,
 
		CMD_BUILD_TUNNEL | CMD_AUTO | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE));
 
}
 

	
 
void PlaceProc_BuyLand(uint tile)
 
void PlaceProc_BuyLand(TileIndex tile)
 
{
 
	DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_PURCHASE_LAND_AREA | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_5806_CAN_T_PURCHASE_THIS_LAND));
 
}
 

	
 
static void PlaceRail_ConvertRail(uint tile)
 
static void PlaceRail_ConvertRail(TileIndex tile)
 
{
 
	VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_ConvertRailArea);
 
}
 

	
 
static void PlaceRail_AutoSignals(uint tile)
 
static void PlaceRail_AutoSignals(TileIndex tile)
 
{
 
	VpStartPlaceSizing(tile, VPM_SIGNALDIRS);
 
}
 

	
 
static void BuildRailClick_N(Window *w)
 
{
 
@@ -470,13 +470,14 @@ static void BuildRailToolbWndProc(Window
 
		if (w != NULL) WP(w,def_d).close=true;
 
		w = FindWindowById(WC_BUILD_DEPOT, 0);
 
		if (w != NULL) WP(w,def_d).close=true;
 
		break;
 

	
 
	case WE_PLACE_PRESIZE: {
 
		uint tile = e->place.tile;
 
		TileIndex tile = e->place.tile;
 

	
 
		DoCommandByTile(tile, 0, 0, DC_AUTO, CMD_BUILD_TUNNEL);
 
		VpSetPresizeRange(tile, _build_tunnel_endtile==0?tile:_build_tunnel_endtile);
 
	} break;
 
	}
 
}
 

	
 
@@ -616,13 +617,13 @@ void ShowBuildRailToolbar(int index, int
 
	if (w != NULL && button >= 0) _build_railroad_button_proc[button](w);
 
}
 

	
 
/* TODO: For custom stations, respect their allowed platforms/lengths bitmasks!
 
 * --pasky */
 

	
 
static void HandleStationPlacement(uint start, uint end)
 
static void HandleStationPlacement(TileIndex start, TileIndex end)
 
{
 
	uint sx = TileX(start);
 
	uint sy = TileY(start);
 
	uint ex = TileX(end);
 
	uint ey = TileY(end);
 
	uint w,h;
road_cmd.c
Show inline comments
 
@@ -18,13 +18,13 @@
 
 * solution just like that... */
 
static bool _road_special_gettrackstatus;
 

	
 
void RoadVehEnterDepot(Vehicle *v);
 

	
 

	
 
static bool HasTileRoadAt(uint tile, int i)
 
static bool HasTileRoadAt(TileIndex tile, int i)
 
{
 
	int mask;
 
	byte b;
 

	
 
	switch (GetTileType(tile)) {
 
	case MP_STREET:
 
@@ -55,13 +55,13 @@ static bool HasTileRoadAt(uint tile, int
 
		return false;
 
	}
 

	
 
	return HASBIT(b, i);
 
}
 

	
 
static bool CheckAllowRemoveRoad(uint tile, uint br, bool *edge_road)
 
static bool CheckAllowRemoveRoad(TileIndex tile, uint br, bool *edge_road)
 
{
 
	int blocks;
 
	byte owner;
 
	uint n;
 
	*edge_road = true;
 

	
 
@@ -476,13 +476,13 @@ do_clear:;
 

	
 
		MarkTileDirtyByTile(tile);
 
	}
 
	return cost;
 
}
 

	
 
int32 DoConvertStreetRail(uint tile, uint totype, bool exec)
 
int32 DoConvertStreetRail(TileIndex tile, uint totype, bool exec)
 
{
 
	// not a railroad crossing?
 
	if (!IsLevelCrossing(tile)) return CMD_ERROR;
 

	
 
	// not owned by me?
 
	if (!CheckTileOwnership(tile) || !EnsureNoVehicle(tile)) return CMD_ERROR;
 
@@ -674,13 +674,14 @@ static int32 RemoveRoadDepot(uint tile, 
 

	
 
	return _price.remove_road_depot;
 
}
 

	
 
#define M(x) (1<<(x))
 

	
 
static int32 ClearTile_Road(uint tile, byte flags) {
 
static int32 ClearTile_Road(TileIndex tile, byte flags)
 
{
 
	int32 ret;
 
	byte m5 = _map5[tile];
 

	
 
	if ( (m5 & 0xF0) == 0) {
 
		byte b = m5 & 0xF;
 

	
 
@@ -926,18 +927,18 @@ static uint GetSlopeTileh_Road(TileInfo 
 
			return 0;
 
		}
 
	}
 
	return ti->tileh;
 
}
 

	
 
static void GetAcceptedCargo_Road(uint tile, AcceptedCargo ac)
 
static void GetAcceptedCargo_Road(TileIndex tile, AcceptedCargo ac)
 
{
 
	/* not used */
 
}
 

	
 
static void AnimateTile_Road(uint tile)
 
static void AnimateTile_Road(TileIndex tile)
 
{
 
	if (IsLevelCrossing(tile)) {
 
		MarkTileDirtyByTile(tile);
 
	}
 
}
 

	
 
@@ -955,13 +956,13 @@ static const byte _town_road_types_2[5][
 
	{3,2},
 
	{3,2},
 
	{3,2},
 
};
 

	
 

	
 
static void TileLoop_Road(uint tile)
 
static void TileLoop_Road(TileIndex tile)
 
{
 
	Town *t;
 
	int grp;
 

	
 
	if (_opt.landscape == LT_HILLY) {
 
		// Fix snow style if the road is above the snowline
 
@@ -1038,26 +1039,27 @@ static void TileLoop_Road(uint tile)
 
		//roadworks finished
 
		_map3_hi[tile] = ((((b& 0x70) >> 4)== 6) ? 1 : 2) << 4;
 
		MarkTileDirtyByTile(tile);
 
	}
 
}
 

	
 
void ShowRoadDepotWindow(uint tile);
 
void ShowRoadDepotWindow(TileIndex tile);
 

	
 
static void ClickTile_Road(uint tile)
 
static void ClickTile_Road(TileIndex tile)
 
{
 
	if ((_map5[tile] & 0xF0) == 0x20) {
 
		ShowRoadDepotWindow(tile);
 
	}
 
}
 

	
 
static const byte _road_trackbits[16] = {
 
	0x0, 0x0, 0x0, 0x10, 0x0, 0x2, 0x8, 0x1A, 0x0, 0x4, 0x1, 0x15, 0x20, 0x26, 0x29, 0x3F,
 
};
 

	
 
static uint32 GetTileTrackStatus_Road(uint tile, TransportType mode)	{
 
static uint32 GetTileTrackStatus_Road(TileIndex tile, TransportType mode)
 
{
 
	if (mode == TRANSPORT_RAIL) {
 
		if (!IsLevelCrossing(tile))
 
			return 0;
 
		return _map5[tile] & 8 ? 0x101 : 0x202;
 
	} else if  (mode == TRANSPORT_ROAD) {
 
		byte b = _map5[tile];
 
@@ -1091,26 +1093,26 @@ static const StringID _road_tile_strings
 
	STR_1814_ROAD,
 
	STR_1816_TREE_LINED_ROAD,
 
	STR_1814_ROAD,
 
	STR_1814_ROAD,
 
};
 

	
 
static void GetTileDesc_Road(uint tile, TileDesc *td)
 
static void GetTileDesc_Road(TileIndex tile, TileDesc *td)
 
{
 
	int i = (_map5[tile] >> 4);
 
	if (i == 0)
 
		i = ((_map3_hi[tile] & 0x70) >> 4) + 3;
 
	td->str = _road_tile_strings[i - 1];
 
	td->owner = GetTileOwner(tile);
 
}
 

	
 
static const byte _roadveh_enter_depot_unk0[4] = {
 
	8, 9, 0, 1
 
};
 

	
 
static uint32 VehicleEnter_Road(Vehicle *v, uint tile, int x, int y)
 
static uint32 VehicleEnter_Road(Vehicle *v, TileIndex tile, int x, int y)
 
{
 
	if (IsLevelCrossing(tile)) {
 
		if (v->type == VEH_Train && (_map5[tile] & 4) == 0) {
 
			/* train crossing a road */
 
			SndPlayVehicleFx(SND_0E_LEVEL_CROSSING, v);
 
			_map5[tile] |= 4;
 
@@ -1124,22 +1126,22 @@ static uint32 VehicleEnter_Road(Vehicle 
 
			}
 
		}
 
	}
 
	return 0;
 
}
 

	
 
static void VehicleLeave_Road(Vehicle *v, uint tile, int x, int y)
 
static void VehicleLeave_Road(Vehicle *v, TileIndex tile, int x, int y)
 
{
 
	if (IsLevelCrossing(tile) && v->type == VEH_Train && v->next == NULL) {
 
		// Turn off level crossing lights
 
		_map5[tile] &= ~4;
 
		MarkTileDirtyByTile(tile);
 
	}
 
}
 

	
 
static void ChangeTileOwner_Road(uint tile, byte old_player, byte new_player)
 
static void ChangeTileOwner_Road(TileIndex tile, byte old_player, byte new_player)
 
{
 
	byte b;
 

	
 
	// road/rail crossing where the road is owned by the current player?
 
	if (old_player == _map3_lo[tile] && IsLevelCrossing(tile)) {
 
		_map3_lo[tile] = (new_player == 0xFF) ? OWNER_NONE : new_player;
road_gui.c
Show inline comments
 
@@ -23,85 +23,85 @@ static bool _build_road_flag;
 

	
 
static byte _place_road_flag;
 

	
 
static byte _road_depot_orientation;
 
static byte _road_station_picker_orientation;
 

	
 
void CcPlaySound1D(bool success, uint tile, uint32 p1, uint32 p2)
 
void CcPlaySound1D(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (success) SndPlayTileFx(SND_1F_SPLAT, tile);
 
}
 

	
 
static void PlaceRoad_NE(uint tile)
 
static void PlaceRoad_NE(TileIndex tile)
 
{
 
	_place_road_flag = (_tile_fract_coords.y >= 8) + 4;
 
	VpStartPlaceSizing(tile, VPM_FIX_X);
 
}
 

	
 
static void PlaceRoad_NW(uint tile)
 
static void PlaceRoad_NW(TileIndex tile)
 
{
 
	_place_road_flag = (_tile_fract_coords.x >= 8) + 0;
 
	VpStartPlaceSizing(tile, VPM_FIX_Y);
 
}
 

	
 
static void PlaceRoad_Bridge(uint tile)
 
static void PlaceRoad_Bridge(TileIndex tile)
 
{
 
	VpStartPlaceSizing(tile, VPM_X_OR_Y);
 
}
 

	
 

	
 
void CcBuildRoadTunnel(bool success, uint tile, uint32 p1, uint32 p2)
 
void CcBuildRoadTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (success) {
 
		SndPlayTileFx(SND_20_SPLAT_2, tile);
 
		ResetObjectToPlace();
 
	} else {
 
		SetRedErrorSquare(_build_tunnel_endtile);
 
	}
 
}
 

	
 
static void PlaceRoad_Tunnel(uint tile)
 
static void PlaceRoad_Tunnel(TileIndex tile)
 
{
 
	DoCommandP(tile, 0x200, 0, CcBuildRoadTunnel, CMD_BUILD_TUNNEL | CMD_AUTO | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE));
 
}
 

	
 
static void BuildRoadOutsideStation(uint tile, int direction)
 
static void BuildRoadOutsideStation(TileIndex tile, int direction)
 
{
 
	static const byte _roadbits_by_dir[4] = {2,1,8,4};
 
	tile += TileOffsByDir(direction);
 
	// if there is a roadpiece just outside of the station entrance, build a connecting route
 
	if (IsTileType(tile, MP_STREET) && !(_map5[tile] & 0x20)) {
 
		DoCommandP(tile, _roadbits_by_dir[direction], 0, NULL, CMD_BUILD_ROAD);
 
	}
 
}
 

	
 
void CcRoadDepot(bool success, uint tile, uint32 p1, uint32 p2)
 
void CcRoadDepot(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (success) {
 
		SndPlayTileFx(SND_1F_SPLAT, tile);
 
		ResetObjectToPlace();
 
		BuildRoadOutsideStation(tile, (int)p1);
 
	}
 
}
 

	
 
static void PlaceRoad_Depot(uint tile)
 
static void PlaceRoad_Depot(TileIndex tile)
 
{
 
	DoCommandP(tile, _road_depot_orientation, 0, CcRoadDepot, CMD_BUILD_ROAD_DEPOT | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1807_CAN_T_BUILD_ROAD_VEHICLE));
 
}
 

	
 
static void PlaceRoad_BusStation(uint tile)
 
static void PlaceRoad_BusStation(TileIndex tile)
 
{
 
	DoCommandP(tile, _road_station_picker_orientation, RS_BUS, CcRoadDepot, CMD_BUILD_ROAD_STOP | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1808_CAN_T_BUILD_BUS_STATION));
 
}
 

	
 
static void PlaceRoad_TruckStation(uint tile)
 
static void PlaceRoad_TruckStation(TileIndex tile)
 
{
 
	DoCommandP(tile, _road_station_picker_orientation, RS_TRUCK, CcRoadDepot, CMD_BUILD_ROAD_STOP | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1809_CAN_T_BUILD_TRUCK_STATION));
 
}
 

	
 
static void PlaceRoad_DemolishArea(uint tile)
 
static void PlaceRoad_DemolishArea(TileIndex tile)
 
{
 
	VpStartPlaceSizing(tile, 4);
 
}
 

	
 
typedef void OnButtonClick(Window *w);
 

	
 
@@ -250,14 +250,15 @@ static void BuildRoadToolbWndProc(Window
 
		VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, sel_method);
 
		return;
 
	}
 

	
 
	case WE_PLACE_MOUSEUP:
 
		if (e->place.pt.x != -1) {
 
			uint start_tile = e->place.starttile;
 
			uint end_tile = e->place.tile;
 
			TileIndex start_tile = e->place.starttile;
 
			TileIndex end_tile = e->place.tile;
 

	
 
			if (e->place.userdata == 0) {
 
				ResetObjectToPlace();
 
				ShowBuildBridgeWindow(start_tile, end_tile, 0x80);
 
			} else if (e->place.userdata != 4) {
 
				DoCommandP(end_tile, start_tile, _place_road_flag, CcPlaySound1D,
 
					_remove_button_clicked ?
 
@@ -267,13 +268,14 @@ static void BuildRoadToolbWndProc(Window
 
				DoCommandP(end_tile, start_tile, _place_road_flag, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
 
			}
 
		}
 
		break;
 

	
 
	case WE_PLACE_PRESIZE: {
 
		uint tile = e->place.tile;
 
		TileIndex tile = e->place.tile;
 

	
 
		DoCommandByTile(tile, 0x200, 0, DC_AUTO, CMD_BUILD_TUNNEL);
 
		VpSetPresizeRange(tile, _build_tunnel_endtile==0?tile:_build_tunnel_endtile);
 
		break;
 
	}
 
	}
 
}
roadveh_cmd.c
Show inline comments
 
@@ -279,22 +279,22 @@ int32 CmdSellRoadVeh(int x, int y, uint3
 

	
 
	return -(int32)v->value;
 
}
 

	
 
typedef struct RoadFindDepotData {
 
	uint best_length;
 
	uint tile;
 
	TileIndex tile;
 
	byte owner;
 
} RoadFindDepotData;
 

	
 
static const byte _road_pf_directions[16] = {
 
	0, 1, 0, 1, 2, 1, 255, 255,
 
	2, 3, 3, 2, 3, 0, 255, 255,
 
};
 

	
 
static bool EnumRoadSignalFindDepot(uint tile, RoadFindDepotData *rfdd, int track, uint length, byte *state)
 
static bool EnumRoadSignalFindDepot(TileIndex tile, RoadFindDepotData *rfdd, int track, uint length, byte *state)
 
{
 
	tile += TileOffsByDir(_road_pf_directions[track]);
 

	
 
	if (IsTileType(tile, MP_STREET) &&
 
			(_map5[tile] & 0xF0) == 0x20 &&
 
			IsTileOwner(tile, rfdd->owner)) {
 
@@ -306,13 +306,13 @@ static bool EnumRoadSignalFindDepot(uint
 
	}
 
	return false;
 
}
 

	
 
static Depot *FindClosestRoadDepot(Vehicle *v)
 
{
 
	uint tile = v->tile;
 
	TileIndex tile = v->tile;
 
	int i;
 

	
 
	if (v->u.road.state == 255) { tile = GetVehicleOutOfTunnelTile(v); }
 

	
 
	if (_patches.new_pathfinding_all) {
 
		NPFFoundTargetData ftd;
 
@@ -469,13 +469,13 @@ static void UpdateRoadVehDeltaXY(Vehicle
 
	v->sprite_width = (byte)(x>>=8);
 
	v->sprite_height = (byte)(x>>=8);
 
}
 

	
 
static void ClearCrashedStation(Vehicle *v)
 
{
 
	uint tile = v->tile;
 
	TileIndex tile = v->tile;
 
	byte *b, bb;
 

	
 
	RoadStop *rs = GetRoadStopByTile(tile, GetRoadStopType(tile));
 
	b = &rs->status;
 

	
 
	bb = *b;
 
@@ -581,13 +581,13 @@ static void RoadVehCrash(Vehicle *v)
 
	ModifyStationRatingAround(v->tile, v->owner, -160, 22);
 
	SndPlayVehicleFx(SND_12_EXPLOSION, v);
 
}
 

	
 
static void RoadVehCheckTrainCrash(Vehicle *v)
 
{
 
	uint tile;
 
	TileIndex tile;
 

	
 
	if (v->u.road.state == 255)
 
		return;
 

	
 
	tile = v->tile;
 

	
 
@@ -898,13 +898,13 @@ static byte RoadVehGetSlidingDirection(V
 
	if (b==((d-2)&7)) return d;
 
	return (d+2)&7;
 
}
 

	
 
typedef struct OvertakeData {
 
	Vehicle *u, *v;
 
	uint tile;
 
	TileIndex tile;
 
	byte tilebits;
 
} OvertakeData;
 

	
 
static void *EnumFindVehToOvertake(Vehicle *v, OvertakeData *od)
 
{
 
	if (v->tile != (TileIndex)od->tile ||
 
@@ -1009,13 +1009,13 @@ static int PickRandomBit(uint bits)
 
typedef struct {
 
	TileIndex dest;
 
	uint maxtracklen;
 
	uint mindist;
 
} FindRoadToChooseData;
 

	
 
static bool EnumRoadTrackFindDist(uint tile, FindRoadToChooseData *frd, int track, uint length, byte *state)
 
static bool EnumRoadTrackFindDist(TileIndex tile, FindRoadToChooseData *frd, int track, uint length, byte *state)
 
{
 
	uint dist = DistanceManhattan(tile, frd->dest);
 
	if (dist <= frd->mindist) {
 
		if (dist != frd->mindist || length < frd->maxtracklen) {
 
			frd->maxtracklen = length;
 
		}
 
@@ -1023,19 +1023,19 @@ static bool EnumRoadTrackFindDist(uint t
 
	}
 
	return false;
 
}
 

	
 
// Returns direction to choose
 
// or -1 if the direction is currently blocked
 
static int RoadFindPathToDest(Vehicle *v, uint tile, int enterdir)
 
static int RoadFindPathToDest(Vehicle *v, TileIndex tile, int enterdir)
 
{
 
#define return_track(x) {best_track = x; goto found_best_track; }
 

	
 
	uint16 signal;
 
	uint bitmask;
 
	uint desttile;
 
	TileIndex desttile;
 
	FindRoadToChooseData frd;
 
	int best_track;
 
	uint best_dist, best_maxlen;
 
	uint i;
 
	byte m5;
 

	
 
@@ -1314,13 +1314,13 @@ static void RoadVehController(Vehicle *v
 
	}
 

	
 
	rd = _road_drive_data[(v->u.road.state + (_opt.road_side<<4)) ^ v->u.road.overtaking][v->u.road.frame+1];
 

	
 
// switch to another tile
 
	if (rd.x & 0x80) {
 
		uint tile = v->tile + TileOffsByDir(rd.x & 3);
 
		TileIndex tile = v->tile + TileOffsByDir(rd.x & 3);
 
		int dir = RoadFindPathToDest(v, tile, rd.x&3);
 
		int tmp;
 
		uint32 r;
 
		byte newdir;
 
		const RoadDriveEntry *rdp;
 

	
roadveh_gui.c
Show inline comments
 
@@ -407,13 +407,13 @@ static void DrawNewRoadVehWindow(Window 
 
		if (selected_id != -1) {
 
			DrawRoadVehPurchaseInfo(2, w->widget[4].top + 1, selected_id);
 
		}
 
	}
 
}
 

	
 
void CcBuildRoadVeh(bool success, uint tile, uint32 p1, uint32 p2)
 
void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 

	
 
	if (!success) return;
 

	
 
	v = GetVehicle(_new_roadveh_id);
 
@@ -523,13 +523,13 @@ static void ShowBuildRoadVehWindow(TileI
 
		w->caption_color = _local_player;
 
	}
 
}
 

	
 
static void DrawRoadDepotWindow(Window *w)
 
{
 
	uint tile;
 
	TileIndex tile;
 
	Vehicle *v;
 
	int num,x,y;
 
	Depot *depot;
 

	
 
	tile = w->window_number;
 

	
 
@@ -750,13 +750,13 @@ static const WindowDesc _road_depot_desc
 
	WC_VEHICLE_DEPOT,0,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
 
	_road_depot_widgets,
 
	RoadDepotWndProc
 
};
 

	
 
void ShowRoadDepotWindow(uint tile)
 
void ShowRoadDepotWindow(TileIndex tile)
 
{
 
	Window *w;
 

	
 
	w = AllocateWindowDescFront(&_road_depot_desc, tile);
 
	if (w) {
 
		w->caption_color = GetTileOwner(w->window_number);
 
@@ -906,13 +906,13 @@ static void PlayerRoadVehWndProc(Window 
 

	
 
				ShowRoadVehViewWindow(v);
 
			}
 
		} break;
 

	
 
		case 9: { /* Build new Vehicle */
 
			uint tile;
 
			TileIndex tile;
 

	
 
			if (!IsWindowOfPrototype(w, _player_roadveh_widgets))
 
				break;
 

	
 
			tile = _last_built_road_depot_tile;
 
			do {
ship_cmd.c
Show inline comments
 
@@ -16,13 +16,14 @@
 
#include "npf.h"
 
#include "depot.h"
 

	
 
static const uint16 _ship_sprites[] = {0x0E5D, 0x0E55, 0x0E65, 0x0E6D};
 
static const byte _ship_sometracks[4] = {0x19, 0x16, 0x25, 0x2A};
 

	
 
static byte GetTileShipTrackStatus(uint tile) {
 
static byte GetTileShipTrackStatus(TileIndex tile)
 
{
 
	uint32 r = GetTileTrackStatus(tile, TRANSPORT_WATER);
 
	return r | r >> 8;
 
}
 

	
 
void DrawShipEngine(int x, int y, int engine, uint32 image_ormod)
 
{
 
@@ -65,14 +66,16 @@ int GetShipImage(const Vehicle *v, byte 
 
}
 

	
 
static Depot *FindClosestShipDepot(Vehicle *v)
 
{
 
	Depot *depot;
 
	Depot *best_depot = NULL;
 
	uint tile, dist, best_dist = (uint)-1;
 
	uint tile2 = v->tile;
 
	uint dist;
 
	uint best_dist = (uint)-1;
 
	TileIndex tile;
 
	TileIndex tile2 = v->tile;
 

	
 
	if (_patches.new_pathfinding_all) {
 
		NPFFoundTargetData ftd;
 
		byte trackdir = GetVehicleTrackdir(v);
 
		ftd = NPFRouteToDepotTrialError(v->tile, trackdir, TRANSPORT_WATER, v->owner);
 
		if (ftd.best_bird_dist == 0)
 
@@ -339,13 +342,13 @@ static const TileIndexDiffC _ship_leave_
 
	{-1,  0},
 
	{ 0, -1}
 
};
 

	
 
static void CheckShipLeaveDepot(Vehicle *v)
 
{
 
	uint tile;
 
	TileIndex tile;
 
	int d;
 
	uint m;
 

	
 
	if (v->u.ship.state != 0x80)
 
		return;
 

	
 
@@ -463,21 +466,21 @@ static void ShipArrivesAt(Vehicle *v, St
 
			v->index,
 
			0);
 
	}
 
}
 

	
 
typedef struct {
 
	uint skiptile;
 
	uint dest_coords;
 
	TileIndex skiptile;
 
	TileIndex dest_coords;
 
	uint best_bird_dist;
 
	uint best_length;
 
} PathFindShip;
 

	
 
//extern void dbg_store_path();
 

	
 
static bool ShipTrackFollower(uint tile, PathFindShip *pfs, int track, uint length, byte *state)
 
static bool ShipTrackFollower(TileIndex tile, PathFindShip *pfs, int track, uint length, byte *state)
 
{
 
	// Found dest?
 
	if (tile == pfs->dest_coords) {
 
		pfs->best_bird_dist = 0;
 

	
 
//		if (length < pfs->best_length)
 
@@ -503,13 +506,13 @@ static const byte _ship_search_direction
 
	{ 3, 2, 9, 9 },
 
	{ 9, 9, 1, 0 },
 
};
 

	
 
static const byte _pick_shiptrack_table[6] = {1, 3, 2, 2, 0, 0};
 

	
 
static uint FindShipTrack(Vehicle *v, uint tile, int dir, uint bits, uint skiptile, int *track)
 
static uint FindShipTrack(Vehicle *v, TileIndex tile, int dir, uint bits, TileIndex skiptile, int *track)
 
{
 
	PathFindShip pfs;
 
	int i, best_track;
 
	uint best_bird_dist = 0;
 
	uint best_length    = 0;
 
	uint r;
 
@@ -558,20 +561,20 @@ bad:;
 
	return best_bird_dist;
 
}
 

	
 
/* returns the track to choose on the next tile, or -1 when it's better to
 
 * reverse. The tile given is the tile we are about to enter, enterdir is the
 
 * direction in which we are entering the tile */
 
static int ChooseShipTrack(Vehicle *v, uint tile, int enterdir, uint tracks)
 
static int ChooseShipTrack(Vehicle *v, TileIndex tile, int enterdir, uint tracks)
 
{
 
	assert(enterdir>=0 && enterdir<=3);
 

	
 
	if (_patches.new_pathfinding_all) {
 
		NPFFindStationOrTileData fstd;
 
		NPFFoundTargetData ftd;
 
		uint src_tile = TILE_ADD(tile, TileOffsByDir(ReverseDiagdir(enterdir)));
 
		TileIndex src_tile = TILE_ADD(tile, TileOffsByDir(ReverseDiagdir(enterdir)));
 
		byte trackdir = GetVehicleTrackdir(v);
 
		assert (trackdir != 0xFF); /* Check that we are not in a depot */
 

	
 
		NPFFillWithOrderData(&fstd, v);
 

	
 
		ftd = NPFRouteToStationOrTile(src_tile, trackdir, &fstd, TRANSPORT_WATER, v->owner);
 
@@ -585,13 +588,13 @@ static int ChooseShipTrack(Vehicle *v, u
 
		else
 
			return -1; /* Already at target, reverse? */
 
	} else {
 
		uint b;
 
		uint tot_dist, dist;
 
		int track;
 
		uint tile2;
 
		TileIndex tile2;
 

	
 
		tile2 = TILE_ADD(tile, -TileOffsByDir(enterdir));
 
		tot_dist = (uint)-1;
 

	
 
		/* Let's find out how far it would be if we would reverse first */
 
		b = GetTileShipTrackStatus(tile2) & _ship_sometracks[ReverseDiagdir(enterdir)] & v->u.ship.state;
 
@@ -612,13 +615,13 @@ static int ChooseShipTrack(Vehicle *v, u
 
static const byte _new_vehicle_direction_table[11] = {
 
	0, 7, 6, 0,
 
	1, 0, 5, 0,
 
	2, 3, 4,
 
};
 

	
 
static int ShipGetNewDirectionFromTiles(uint new_tile, uint old_tile)
 
static int ShipGetNewDirectionFromTiles(TileIndex new_tile, TileIndex old_tile)
 
{
 
	uint offs = (TileY(new_tile) - TileY(old_tile) + 1) * 4 +
 
							TileX(new_tile) - TileX(old_tile) + 1;
 
	assert(offs < 11 && offs != 3 && offs != 7);
 
	return _new_vehicle_direction_table[offs];
 
}
 
@@ -627,13 +630,13 @@ static int ShipGetNewDirection(Vehicle *
 
{
 
	uint offs = (y - v->y_pos + 1) * 4 + (x - v->x_pos + 1);
 
	assert(offs < 11 && offs != 3 && offs != 7);
 
	return _new_vehicle_direction_table[offs];
 
}
 

	
 
static int GetAvailShipTracks(uint tile, int dir)
 
static int GetAvailShipTracks(TileIndex tile, int dir)
 
{
 
	uint32 r = GetTileTrackStatus(tile, TRANSPORT_WATER);
 
	return (byte) ((r | r >> 8)) & _ship_sometracks[dir];
 
}
 

	
 
static const byte _ship_subcoord[4][6][3] = {
ship_gui.c
Show inline comments
 
@@ -299,13 +299,13 @@ static void ShowShipDetailsWindow(Vehicl
 
	_alloc_wnd_parent_num = veh;
 
	w = AllocateWindowDesc(&_ship_details_desc);
 
	w->window_number = veh;
 
	w->caption_color = v->owner;
 
}
 

	
 
void CcBuildShip(bool success, uint tile, uint32 p1, uint32 p2)
 
void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 
	if (!success) return;
 

	
 
	v = GetVehicle(_new_ship_id);
 
	if (v->tile == _backup_orders_tile) {
 
@@ -599,13 +599,13 @@ void ShowShipViewWindow(Vehicle *v)
 
		AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0);
 
	}
 
}
 

	
 
static void DrawShipDepotWindow(Window *w)
 
{
 
	uint tile;
 
	TileIndex tile;
 
	Vehicle *v;
 
	int num,x,y;
 
	Depot *depot;
 

	
 
	tile = w->window_number;
 

	
 
@@ -822,13 +822,13 @@ static const WindowDesc _ship_depot_desc
 
	WC_VEHICLE_DEPOT,0,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
 
	_ship_depot_widgets,
 
	ShipDepotWndProc
 
};
 

	
 
void ShowShipDepotWindow(uint tile)
 
void ShowShipDepotWindow(TileIndex tile)
 
{
 
	Window *w;
 

	
 
	w = AllocateWindowDescFront(&_ship_depot_desc,tile);
 
	if (w) {
 
		w->caption_color = GetTileOwner(w->window_number);
 
@@ -1007,13 +1007,13 @@ static void PlayerShipsWndProc(Window *w
 

	
 
				ShowShipViewWindow(v);
 
			}
 
		} break;
 

	
 
		case 9: { /* Build new Vehicle */
 
			uint tile;
 
			TileIndex tile;
 

	
 
			if (!IsWindowOfPrototype(w, _player_ships_widgets))
 
				break;
 

	
 

	
 
			tile = _last_built_ship_depot_tile;
signs.c
Show inline comments
 
@@ -183,13 +183,13 @@ int32 CmdRenameSign(int x, int y, uint32
 

	
 
/**
 
 *
 
 * Callback function that is called after a sign is placed
 
 *
 
 */
 
void CcPlaceSign(bool success, uint tile, uint32 p1, uint32 p2)
 
void CcPlaceSign(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (success) {
 
		ShowRenameSignWindow(_new_sign_struct);
 
		ResetObjectToPlace();
 
	}
 
}
 
@@ -197,13 +197,13 @@ void CcPlaceSign(bool success, uint tile
 
/**
 
 *
 
 * PlaceProc function, called when someone pressed the button if the
 
 *  sign-tool is selected
 
 *
 
 */
 
void PlaceProc_Sign(uint tile)
 
void PlaceProc_Sign(TileIndex tile)
 
{
 
	DoCommandP(tile, _current_player, 0, CcPlaceSign, CMD_PLACE_SIGN | CMD_MSG(STR_2809_CAN_T_PLACE_SIGN_HERE));
 
}
 

	
 
/**
 
 *
signs.h
Show inline comments
 
@@ -52,12 +52,12 @@ static inline bool IsSignIndex(uint inde
 
VARDEF SignStruct *_new_sign_struct;
 

	
 
VARDEF bool _sign_sort_dirty;
 
VARDEF uint16 *_sign_sort;
 

	
 
void UpdateAllSignVirtCoords(void);
 
void PlaceProc_Sign(uint tile);
 
void PlaceProc_Sign(TileIndex tile);
 

	
 
/* misc.c */
 
void ShowRenameSignWindow(SignStruct *ss);
 

	
 
#endif /* SIGNS_H */
station.h
Show inline comments
 
@@ -184,13 +184,13 @@ static inline uint16 GetRoadStopPoolSize
 

	
 
VARDEF bool _station_sort_dirty[MAX_PLAYERS];
 
VARDEF bool _global_station_sort_dirty;
 

	
 
void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile, int w, int h, int rad);
 
void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile, int w, int h, int rad);
 
uint GetStationPlatforms(Station *st, uint tile);
 
uint GetStationPlatforms(Station *st, TileIndex tile);
 

	
 

	
 
/* Station layout for given dimensions - it is a two-dimensional array
 
 * where index is computed as (x * platforms) + platform. */
 
typedef byte *StationLayout;
 

	
 
@@ -275,13 +275,14 @@ static inline int GetRoadStopType(TileIn
 

	
 
uint GetNumRoadStops(const Station *st, RoadStopType type);
 
RoadStop * GetPrimaryRoadStop(const Station *st, RoadStopType type);
 
RoadStop * AllocateRoadStop( void );
 
void ClearSlot(Vehicle *v, RoadStop *rs);
 

	
 
static inline bool IsTrainStationTile(uint tile) {
 
static inline bool IsTrainStationTile(TileIndex tile)
 
{
 
	return IsTileType(tile, MP_STATION) && IS_BYTE_INSIDE(_map5[tile], 0, 8);
 
}
 

	
 
static inline bool IsCompatibleTrainStationTile(TileIndex tile, TileIndex ref)
 
{
 
	assert(IsTrainStationTile(ref));
 
@@ -311,12 +312,13 @@ static inline bool IsBuoy(const Station*
 
static inline bool IsBuoyTile(TileIndex tile) {
 
	return IsTileType(tile, MP_STATION) && _map5[tile] == 0x52;
 
}
 

	
 
/* Get's the direction the station exit points towards. Ie, returns 0 for a
 
 * station with the exit NE. */
 
static inline byte GetRoadStationDir(uint tile) {
 
static inline byte GetRoadStationDir(TileIndex tile)
 
{
 
	assert(IsRoadStationTile(tile));
 
	return (_map5[tile] - 0x43) & 3;
 
}
 

	
 
#endif /* STATION_H */
station_cmd.c
Show inline comments
 
@@ -59,13 +59,13 @@ MemoryPool _roadstop_pool = { "RoadStop"
 

	
 
// FIXME -- need to be embedded into Airport variable. Is dynamically
 
// deducteable from graphics-tile array, so will not be needed
 
const byte _airport_size_x[] = {4, 6, 1, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
 
const byte _airport_size_y[] = {3, 6, 1, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
 

	
 
void ShowAircraftDepotWindow(uint tile);
 
void ShowAircraftDepotWindow(TileIndex tile);
 
extern void UpdateAirplanesOnNewStation(Station *st);
 

	
 
static void MarkStationDirty(Station *st)
 
{
 
	if (st->sign.width_1 != 0) {
 
		InvalidateWindowWidget(WC_STATION_VIEW, st->index, 1);
 
@@ -169,13 +169,13 @@ static byte FindCatchmentRadius(Station 
 

	
 
	return ret;
 
}
 

	
 
#define CHECK_STATIONS_ERR ((Station*)-1)
 

	
 
static Station *GetStationAround(uint tile, int w, int h, int closest_station)
 
static Station *GetStationAround(TileIndex tile, int w, int h, int closest_station)
 
{
 
	// check around to see if there's any stations there
 
	BEGIN_TILE_LOOP(tile_cur, w + 2, h + 2, tile - TILE_XY(1,1))
 
		if (IsTileType(tile_cur, MP_STATION)) {
 
			int t;
 
			t = _map2[tile_cur];
 
@@ -218,13 +218,13 @@ TileIndex GetStationTileForVehicle(const
 
		default:
 
			assert(false);
 
			return 0;
 
	}
 
}
 

	
 
static bool CheckStationSpreadOut(Station *st, uint tile, int w, int h)
 
static bool CheckStationSpreadOut(Station *st, TileIndex tile, int w, int h)
 
{
 
	StationID station_index = st->index;
 
	uint i;
 
	uint x1 = TileX(tile);
 
	uint y1 = TileY(tile);
 
	uint x2 = x1 + w - 1;
 
@@ -272,13 +272,14 @@ static Station *AllocateStation(void)
 

	
 
	_error_message = STR_3008_TOO_MANY_STATIONS_LOADING;
 
	return NULL;
 
}
 

	
 

	
 
static int CountMapSquareAround(uint tile, byte type, byte min, byte max) {
 
static int CountMapSquareAround(TileIndex tile, byte type, byte min, byte max)
 
{
 
	static const TileIndexDiffC _count_square_table[] = {
 
		{-3, -3}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0},
 
		{-6,  1}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0},
 
		{-6,  1}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0},
 
		{-6,  1}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0},
 
		{-6,  1}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0}, {1, 0},
 
@@ -297,13 +298,13 @@ static int CountMapSquareAround(uint til
 

	
 
	return num;
 
}
 

	
 
#define M(x) ((x) - STR_SV_STNAME)
 

	
 
static bool GenerateStationName(Station *st, uint tile, int flag)
 
static bool GenerateStationName(Station *st, TileIndex tile, int flag)
 
{
 
	static const uint32 _gen_station_name_bits[] = {
 
		0,                                      /* 0 */
 
		1 << M(STR_SV_STNAME_AIRPORT),          /* 1 */
 
		1 << M(STR_SV_STNAME_OILFIELD),         /* 2 */
 
		1 << M(STR_SV_STNAME_DOCKS),            /* 3 */
 
@@ -740,17 +741,17 @@ static void DeleteStationIfEmpty(Station
 
	if (st->facilities == 0) {
 
		st->delete_ctr = 0;
 
		InvalidateWindow(WC_STATION_LIST, st->owner);
 
	}
 
}
 

	
 
static int32 ClearTile_Station(uint tile, byte flags);
 
static int32 ClearTile_Station(TileIndex tile, byte flags);
 

	
 
// Tries to clear the given area. Returns the cost in case of success.
 
// Or an error code if it failed.
 
int32 CheckFlatLandBelow(uint tile, uint w, uint h, uint flags, uint invalid_dirs, int *station)
 
int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, int *station)
 
{
 
	int32 cost = 0, ret;
 

	
 
	uint tileh;
 
	uint z;
 
	int allowed_z = -1;
 
@@ -817,13 +818,13 @@ int32 CheckFlatLandBelow(uint tile, uint
 
	return cost;
 
}
 

	
 
static bool CanExpandRailroadStation(Station *st, uint *fin, int direction)
 
{
 
	uint curw = st->trainst_w, curh = st->trainst_h;
 
	uint tile = fin[0];
 
	TileIndex tile = fin[0];
 
	uint w = fin[1];
 
	uint h = fin[2];
 

	
 
	if (_patches.nonuniform_stations) {
 
		// determine new size of train station region..
 
		int x = min(TileX(st->train_tile), TileX(tile));
 
@@ -1016,13 +1017,13 @@ int32 CmdBuildRailroadStation(int x, int
 

	
 
		if (flags & DC_EXEC)
 
			StationInitialize(st, tile_org);
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		int tile_delta;
 
		TileIndexDiff tile_delta;
 
		byte *layout_ptr;
 
		StationID station_index = st->index;
 
		StationSpec *statspec;
 

	
 
		// Now really clear the land below the station
 
		// It should never return CMD_ERROR.. but you never know ;)
 
@@ -1069,22 +1070,22 @@ int32 CmdBuildRailroadStation(int x, int
 
		InvalidateWindow(WC_STATION_LIST, st->owner);
 
	}
 

	
 
	return cost;
 
}
 

	
 
static bool TileBelongsToRailStation(Station *st, uint tile)
 
static bool TileBelongsToRailStation(Station *st, TileIndex tile)
 
{
 
	return IsTileType(tile, MP_STATION) && _map2[tile] == st->index && _map5[tile] < 8;
 
}
 

	
 
static void MakeRailwayStationAreaSmaller(Station *st)
 
{
 
	uint w = st->trainst_w;
 
	uint h = st->trainst_h;
 
	uint tile = st->train_tile;
 
	TileIndex tile = st->train_tile;
 
	uint i;
 

	
 
restart:
 

	
 
	// too small?
 
	if (w != 0 && h != 0) {
 
@@ -1149,13 +1150,13 @@ int32 CmdRemoveFromRailroadStation(int x
 
		}
 
	}
 
	return _price.remove_rail_station;
 
}
 

	
 
// determine the number of platforms for the station
 
uint GetStationPlatforms(Station *st, uint tile)
 
uint GetStationPlatforms(Station *st, TileIndex tile)
 
{
 
	uint t;
 
	int dir,delta;
 
	int len;
 
	assert(TileBelongsToRailStation(st, tile));
 

	
 
@@ -1386,13 +1387,13 @@ static int32 RemoveRailroadStation(Stati
 
		DeleteStationIfEmpty(st);
 
	}
 

	
 
	return cost;
 
}
 

	
 
int32 DoConvertStationRail(uint tile, uint totype, bool exec)
 
int32 DoConvertStationRail(TileIndex tile, uint totype, bool exec)
 
{
 
	const Station *st = GetStation(_map2[tile]);
 
	if (!CheckOwnership(st->owner) || !EnsureNoVehicle(tile)) return CMD_ERROR;
 

	
 
	// tile is not a railroad station?
 
	if (_map5[tile] >= 8) return CMD_ERROR;
 
@@ -1783,13 +1784,13 @@ END_TILE_LOOP(tile_cur,w,h,tile)
 

	
 
	return cost;
 
}
 

	
 
static int32 RemoveAirport(Station *st, uint32 flags)
 
{
 
	uint tile;
 
	TileIndex tile;
 
	int w,h;
 
	int32 cost;
 

	
 
	if (_current_player != OWNER_WATER && !CheckOwnership(st->owner))
 
		return CMD_ERROR;
 

	
 
@@ -1898,13 +1899,13 @@ static bool CheckShipsOnBuoy(Station *st
 
	}
 
	return false;
 
}
 

	
 
static int32 RemoveBuoy(Station *st, uint32 flags)
 
{
 
	uint tile;
 
	TileIndex tile;
 

	
 
	if (_current_player >= MAX_PLAYERS) {
 
		/* XXX: strange stuff */
 
		return_cmd_error(INVALID_STRING_ID);
 
	}
 

	
 
@@ -2055,13 +2056,14 @@ int32 CmdBuildDock(int x, int y, uint32 
 
	}
 
	return _price.build_dock;
 
}
 

	
 
static int32 RemoveDock(Station *st, uint32 flags)
 
{
 
	uint tile1, tile2;
 
	TileIndex tile1;
 
	TileIndex tile2;
 

	
 
	if (!CheckOwnership(st->owner))
 
		return CMD_ERROR;
 

	
 
	tile1 = st->dock_tile;
 
	tile2 = tile1 + TileOffsByDir(_map5[tile1] - 0x4C);
 
@@ -2191,18 +2193,18 @@ static uint GetSlopeZ_Station(TileInfo *
 

	
 
static uint GetSlopeTileh_Station(TileInfo *ti)
 
{
 
	return 0;
 
}
 

	
 
static void GetAcceptedCargo_Station(uint tile, AcceptedCargo ac)
 
static void GetAcceptedCargo_Station(TileIndex tile, AcceptedCargo ac)
 
{
 
	/* not used */
 
}
 

	
 
static void GetTileDesc_Station(uint tile, TileDesc *td)
 
static void GetTileDesc_Station(TileIndex tile, TileDesc *td)
 
{
 
	byte m5;
 
	StringID str;
 

	
 
	td->owner = GetTileOwner(tile);
 
	td->build_date = GetStation(_map2[tile])->build_date;
 
@@ -2217,13 +2219,14 @@ static void GetTileDesc_Station(uint til
 
	(str=STR_3063_SHIP_DOCK, m5 != 0x52) ||
 
	(str=STR_3069_BUOY, true);
 
	td->str = str;
 
}
 

	
 

	
 
static uint32 GetTileTrackStatus_Station(uint tile, TransportType mode) {
 
static uint32 GetTileTrackStatus_Station(TileIndex tile, TransportType mode)
 
{
 
	uint i = _map5[tile];
 
	uint j = 0;
 

	
 
	switch (mode) {
 
		case TRANSPORT_RAIL:
 
			if (i < 8) {
 
@@ -2244,13 +2247,13 @@ static uint32 GetTileTrackStatus_Station
 
			break;
 
	}
 

	
 
	return j;
 
}
 

	
 
static void TileLoop_Station(uint tile)
 
static void TileLoop_Station(TileIndex tile)
 
{
 
  //FIXME -- GetTileTrackStatus_Station -> animated stationtiles
 
  // hardcoded.....not good
 
  // 0x27 - large big airport (39)
 
  // 0x66 - radar metropolitan airport (102)
 
  // 0x5A - radar international airport (90)
 
@@ -2266,13 +2269,13 @@ static void TileLoop_Station(uint tile)
 
	else if (_map5[tile] == 0x4B)
 
		TileLoop_Water(tile);
 

	
 
}
 

	
 

	
 
static void AnimateTile_Station(uint tile)
 
static void AnimateTile_Station(TileIndex tile)
 
{
 
	byte m5 = _map5[tile];
 
	//FIXME -- AnimateTile_Station -> not nice code, lots of things double
 
  // again hardcoded...was a quick hack
 

	
 
  // turning radar / windsack on airport
 
@@ -2307,13 +2310,13 @@ static void AnimateTile_Station(uint til
 

	
 
		_map5[tile] = m5;
 
		MarkTileDirtyByTile(tile);
 
	}
 
}
 

	
 
static void ClickTile_Station(uint tile)
 
static void ClickTile_Station(TileIndex tile)
 
{
 
  // 0x20 - hangar large airport (32)
 
  // 0x41 - hangar small airport (65)
 
	if (_map5[tile] == 32 || _map5[tile] == 65) {
 
		ShowAircraftDepotWindow(tile);
 
	} else {
 
@@ -2322,13 +2325,13 @@ static void ClickTile_Station(uint tile)
 
}
 

	
 
static const byte _enter_station_speedtable[12] = {
 
	215, 195, 175, 155, 135, 115, 95, 75, 55, 35, 15, 0
 
};
 

	
 
static uint32 VehicleEnter_Station(Vehicle *v, uint tile, int x, int y)
 
static uint32 VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y)
 
{
 
	StationID station_id;
 
	byte dir;
 
	uint16 spd;
 

	
 
	if (v->type == VEH_Train) {
 
@@ -2673,13 +2676,13 @@ int32 CmdRenameStation(int x, int y, uin
 
	}
 

	
 
	return 0;
 
}
 

	
 

	
 
uint MoveGoodsToStation(uint tile, int w, int h, int type, uint amount)
 
uint MoveGoodsToStation(TileIndex tile, int w, int h, int type, uint amount)
 
{
 
	Station *around_ptr[8];
 
	StationID around[8];
 
	StationID st_index;
 
	int i;
 
	Station *st;
 
@@ -2810,13 +2813,13 @@ uint MoveGoodsToStation(uint tile, int w
 
		UpdateStationWaiting(st2, type, amount);
 
	}
 

	
 
	return moved;
 
}
 

	
 
void BuildOilRig(uint tile)
 
void BuildOilRig(TileIndex tile)
 
{
 
	Station *st;
 
	int j;
 

	
 
	FOR_ALL_STATIONS(st) {
 
		if (st->xy == 0) {
 
@@ -2861,13 +2864,13 @@ void BuildOilRig(uint tile)
 
			UpdateStationAcceptance(st, false);
 
			return;
 
		}
 
	}
 
}
 

	
 
void DeleteOilRig(uint tile)
 
void DeleteOilRig(TileIndex tile)
 
{
 
	Station *st = GetStation(_map2[tile]);
 

	
 
	DoClearSquare(tile);
 

	
 
	st->dock_tile = 0;
 
@@ -2875,13 +2878,13 @@ void DeleteOilRig(uint tile)
 
	st->facilities &= ~(FACIL_AIRPORT | FACIL_DOCK);
 
	st->airport_flags = 0;
 
	UpdateStationVirtCoordDirty(st);
 
	DeleteStation(st);
 
}
 

	
 
static void ChangeTileOwner_Station(uint tile, byte old_player, byte new_player)
 
static void ChangeTileOwner_Station(TileIndex tile, byte old_player, byte new_player)
 
{
 
	if (!IsTileOwner(tile, old_player)) return;
 

	
 
	if (new_player != 255) {
 
		Station *st = GetStation(_map2[tile]);
 
		SetTileOwner(tile, new_player);
 
@@ -2890,13 +2893,14 @@ static void ChangeTileOwner_Station(uint
 
		InvalidateWindowClasses(WC_STATION_LIST);
 
	} else {
 
		DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
 
	}
 
}
 

	
 
static int32 ClearTile_Station(uint tile, byte flags) {
 
static int32 ClearTile_Station(TileIndex tile, byte flags)
 
{
 
	byte m5 = _map5[tile];
 
	Station *st;
 

	
 
	if (flags & DC_AUTO) {
 
		if (m5 < 8) return_cmd_error(STR_300B_MUST_DEMOLISH_RAILROAD);
 
		if (m5 < 0x43 || (m5 >= 83 && m5 <= 114)) return_cmd_error(STR_300E_MUST_DEMOLISH_AIRPORT_FIRST);
terraform_gui.c
Show inline comments
 
@@ -9,22 +9,22 @@
 
#include "gfx.h"
 
#include "sound.h"
 
#include "command.h"
 
#include "vehicle.h"
 
#include "signs.h"
 

	
 
void CcTerraform(bool success, uint tile, uint32 p1, uint32 p2)
 
void CcTerraform(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (success) {
 
		SndPlayTileFx(SND_1F_SPLAT, tile);
 
	} else {
 
		SetRedErrorSquare(_terraform_err_tile);
 
	}
 
}
 

	
 
static void GenericRaiseLowerLand(uint tile, int mode)
 
static void GenericRaiseLowerLand(TileIndex tile, int mode)
 
{
 
	if (mode) {
 
		DoCommandP(tile, 8, (uint32)mode, CcTerraform, CMD_TERRAFORM_LAND | CMD_AUTO | CMD_MSG(STR_0808_CAN_T_RAISE_LAND_HERE));
 
	} else {
 
		DoCommandP(tile, 8, (uint32)mode, CcTerraform, CMD_TERRAFORM_LAND | CMD_AUTO | CMD_MSG(STR_0809_CAN_T_LOWER_LAND_HERE));
 
	}
 
@@ -98,33 +98,33 @@ static const uint16 _terraform_keycodes[
 
	'D',
 
	'U',
 
	'I',
 
	'O',
 
};
 

	
 
void PlaceProc_DemolishArea(uint tile)
 
void PlaceProc_DemolishArea(TileIndex tile)
 
{
 
	VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_DemolishArea);
 
}
 

	
 
void PlaceProc_RaiseLand(uint tile)
 
void PlaceProc_RaiseLand(TileIndex tile)
 
{
 
	GenericRaiseLowerLand(tile, 1);
 
}
 

	
 
void PlaceProc_LowerLand(uint tile)
 
void PlaceProc_LowerLand(TileIndex tile)
 
{
 
	GenericRaiseLowerLand(tile, 0);
 
}
 

	
 
void PlaceProc_LevelLand(uint tile)
 
void PlaceProc_LevelLand(TileIndex tile)
 
{
 
	VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_LevelArea);
 
}
 

	
 
static void PlaceProc_PlantTree(uint tile) {}
 
static void PlaceProc_PlantTree(TileIndex tile) {}
 

	
 
static void TerraformClick_Lower(Window *w)
 
{
 
	HandlePlacePushButton(w, 4, ANIMCURSOR_LOWERLAND, 2, PlaceProc_LowerLand);
 
}
 

	
texteff.c
Show inline comments
 
@@ -317,47 +317,47 @@ void DrawTextEffects(DrawPixelInfo *dpi)
 
			AddStringToDraw(te->x, te->y, (StringID)(te->string_id-1), te->params_1, te->params_2, 0);
 
		}
 

	
 
	}
 
}
 

	
 
void DeleteAnimatedTile(uint tile)
 
void DeleteAnimatedTile(TileIndex tile)
 
{
 
	TileIndex *ti;
 

	
 
	for(ti=_animated_tile_list; ti!=endof(_animated_tile_list); ti++) {
 
		if ( (TileIndex)tile == *ti) {
 
		if (tile == *ti) {
 
			/* remove the hole */
 
			memmove(ti, ti+1, endof(_animated_tile_list) - 1 - ti);
 
			/* and clear last item */
 
			endof(_animated_tile_list)[-1] = 0;
 
			MarkTileDirtyByTile(tile);
 
			return;
 
		}
 
	}
 
}
 

	
 
bool AddAnimatedTile(uint tile)
 
bool AddAnimatedTile(TileIndex tile)
 
{
 
	TileIndex *ti;
 

	
 
	for(ti=_animated_tile_list; ti!=endof(_animated_tile_list); ti++) {
 
		if ( (TileIndex)tile == *ti || *ti == 0) {
 
		if (tile == *ti || *ti == 0) {
 
			*ti = tile;
 
			MarkTileDirtyByTile(tile);
 
			return true;
 
		}
 
	}
 

	
 
	return false;
 
}
 

	
 
void AnimateAnimatedTiles(void)
 
{
 
	TileIndex *ti;
 
	uint tile;
 
	TileIndex tile;
 

	
 
	for(ti=_animated_tile_list; ti!=endof(_animated_tile_list) && (tile=*ti) != 0; ti++) {
 
		AnimateTile(tile);
 
	}
 
}
 

	
town.h
Show inline comments
 
@@ -124,13 +124,13 @@ enum {
 

	
 
	RATING_BRIBE_UP_STEP = 200,
 
	RATING_BRIBE_MAXIMUM = 800,
 
	RATING_BRIBE_DOWN_TO = -50 					// XXX SHOULD BE SOMETHING LOWER?
 
};
 

	
 
bool CheckforTownRating(uint tile, uint32 flags, Town *t, byte type);
 
bool CheckforTownRating(TileIndex tile, uint32 flags, Town *t, byte type);
 

	
 
VARDEF uint16 *_town_sort;
 

	
 
extern MemoryPool _town_pool;
 

	
 
/**
town_cmd.c
Show inline comments
 
@@ -49,15 +49,15 @@ enum {
 
	TOWN_HAS_STADIUM    = 0x04
 
};
 

	
 
// Local
 
static int _grow_town_result;
 

	
 
static bool BuildTownHouse(Town *t, uint tile);
 
static void ClearTownHouse(Town *t, uint tile);
 
static void DoBuildTownHouse(Town *t, uint tile);
 
static bool BuildTownHouse(Town *t, TileIndex tile);
 
static void ClearTownHouse(Town *t, TileIndex tile);
 
static void DoBuildTownHouse(Town *t, TileIndex tile);
 

	
 
typedef struct DrawTownTileStruct {
 
	uint32 sprite_1;
 
	uint32 sprite_2;
 

	
 
	byte subtile_x:4;
 
@@ -147,13 +147,13 @@ static uint GetSlopeZ_Town(TileInfo *ti)
 

	
 
static uint GetSlopeTileh_Town(TileInfo *ti)
 
{
 
	return ti->tileh;
 
}
 

	
 
static void AnimateTile_Town(uint tile)
 
static void AnimateTile_Town(TileIndex tile)
 
{
 
	int old;
 
	int i;
 
	int a,b;
 

	
 
	if (_tick_counter & 3)
 
@@ -185,13 +185,13 @@ static void AnimateTile_Town(uint tile)
 

	
 
	MarkTileDirtyByTile(tile);
 
}
 

	
 
static void UpdateTownRadius(Town *t);
 

	
 
static bool IsCloseToTown(uint tile, uint dist)
 
static bool IsCloseToTown(TileIndex tile, uint dist)
 
{
 
	Town *t;
 

	
 
	FOR_ALL_TOWNS(t) {
 
		if (t->xy != 0 && DistanceManhattan(tile, t->xy) < dist)
 
			return true;
 
@@ -239,13 +239,13 @@ uint32 GetWorldPopulation(void)
 
	FOR_ALL_TOWNS(t) {
 
			pop += t->population;
 
	}
 
	return pop;
 
}
 

	
 
static void MakeSingleHouseBigger(uint tile)
 
static void MakeSingleHouseBigger(TileIndex tile)
 
{
 
	byte b;
 

	
 
	assert(IsTileType(tile, MP_HOUSE));
 

	
 
	b = _map5[tile];
 
@@ -262,22 +262,22 @@ static void MakeSingleHouseBigger(uint t
 
	if ( (_map3_lo[tile] & 0xC0) == 0xC0) {
 
		ChangePopulation(GetTown(_map2[tile]), _housetype_population[_map3_hi[tile]]);
 
	}
 
	MarkTileDirtyByTile(tile);
 
}
 

	
 
static void MakeTownHouseBigger(uint tile)
 
static void MakeTownHouseBigger(TileIndex tile)
 
{
 
	uint flags = _house_more_flags[_map3_hi[tile]];
 
	if (flags & 8) MakeSingleHouseBigger(TILE_ADDXY(tile, 0, 0));
 
	if (flags & 4) MakeSingleHouseBigger(TILE_ADDXY(tile, 0, 1));
 
	if (flags & 2) MakeSingleHouseBigger(TILE_ADDXY(tile, 1, 0));
 
	if (flags & 1) MakeSingleHouseBigger(TILE_ADDXY(tile, 1, 1));
 
}
 

	
 
static void TileLoop_Town(uint tile)
 
static void TileLoop_Town(TileIndex tile)
 
{
 
	int house;
 
	Town *t;
 
	uint32 r;
 

	
 
	if ((_map3_lo[tile] & 0xC0) != 0xC0) {
 
@@ -327,18 +327,18 @@ static void TileLoop_Town(uint tile)
 
		}
 

	
 
		_current_player = OWNER_NONE;
 
	}
 
}
 

	
 
static void ClickTile_Town(uint tile)
 
static void ClickTile_Town(TileIndex tile)
 
{
 
	/* not used */
 
}
 

	
 
static int32 ClearTile_Town(uint tile, byte flags)
 
static int32 ClearTile_Town(TileIndex tile, byte flags)
 
{
 
	int house, rating;
 
	int32 cost;
 
	Town *t;
 

	
 
	// safety checks
 
@@ -364,40 +364,40 @@ static int32 ClearTile_Town(uint tile, b
 
		ClearTownHouse(t, tile);
 
	}
 

	
 
	return cost;
 
}
 

	
 
static void GetAcceptedCargo_Town(uint tile, AcceptedCargo ac)
 
static void GetAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac)
 
{
 
	int type = _map3_hi[tile];
 

	
 
	ac[CT_PASSENGERS] = _housetype_cargo_passengers[type];
 
	ac[CT_MAIL] = _housetype_cargo_mail[type];
 
	ac[CT_GOODS] = _housetype_cargo_goods[type];
 
	ac[CT_FOOD] = _housetype_cargo_food[type];
 
}
 

	
 
static void GetTileDesc_Town(uint tile, TileDesc *td)
 
static void GetTileDesc_Town(TileIndex tile, TileDesc *td)
 
{
 
	td->str = _town_tile_names[_map3_hi[tile]];
 
	if ((_map3_lo[tile] & 0xC0) != 0xC0) {
 
		SetDParamX(td->dparam, 0, td->str);
 
		td->str = STR_2058_UNDER_CONSTRUCTION;
 
	}
 

	
 
	td->owner = OWNER_TOWN;
 
}
 

	
 
static uint32 GetTileTrackStatus_Town(uint tile, TransportType mode)
 
static uint32 GetTileTrackStatus_Town(TileIndex tile, TransportType mode)
 
{
 
	/* not used */
 
	return 0;
 
}
 

	
 
static void ChangeTileOwner_Town(uint tile, byte old_player, byte new_player)
 
static void ChangeTileOwner_Town(TileIndex tile, byte old_player, byte new_player)
 
{
 
	/* not used */
 
}
 

	
 

	
 
static const TileIndexDiffC _roadblock_tileadd[] = {
 
@@ -463,13 +463,13 @@ static byte GetTownRoadMask(TileIndex ti
 
	if (b&8) r|=6;
 
	if (b&16) r|=3;
 
	if (b&32) r|=12;
 
	return r;
 
}
 

	
 
static bool IsRoadAllowedHere(uint tile, int dir)
 
static bool IsRoadAllowedHere(TileIndex tile, int dir)
 
{
 
	uint k;
 
	uint slope;
 

	
 
	// If this assertion fails, it might be because the world contains
 
	//  land at the edges. This is not ok.
 
@@ -525,26 +525,26 @@ no_slope:
 
		/* Can somebody explain for what this is needed? :s */
 
		// tile = TILE_ADD(tile, _roadblock_tileadd[dir]);
 
		return true;
 
	}
 
}
 

	
 
static bool TerraformTownTile(uint tile, int edges, int dir)
 
static bool TerraformTownTile(TileIndex tile, int edges, int dir)
 
{
 
	int32 r;
 

	
 
	TILE_ASSERT(tile);
 

	
 
	r = DoCommandByTile(tile, edges, dir, DC_AUTO | DC_NO_WATER, CMD_TERRAFORM_LAND);
 
	if (r == CMD_ERROR || r >= 126*16)
 
		return false;
 
	DoCommandByTile(tile, edges, dir, DC_AUTO | DC_NO_WATER | DC_EXEC, CMD_TERRAFORM_LAND);
 
	return true;
 
}
 

	
 
static void LevelTownLand(uint tile)
 
static void LevelTownLand(TileIndex tile)
 
{
 
	TileInfo ti;
 

	
 
	TILE_ASSERT(tile);
 

	
 
	// Don't terraform if land is plain or if there's a house there.
 
@@ -557,21 +557,21 @@ static void LevelTownLand(uint tile)
 
		TerraformTownTile(tile, ti.tileh & 0xF, 0);
 
	}
 
}
 

	
 
#define IS_WATER_TILE(t) (IsTileType((t), MP_WATER) && _map5[(t)] == 0)
 

	
 
static void GrowTownInTile(uint *tile_ptr, uint mask, int block, Town *t1)
 
static void GrowTownInTile(TileIndex *tile_ptr, uint mask, int block, Town *t1)
 
{
 
	uint16 r;
 
	int a,b,rcmd;
 
	uint tmptile;
 
	TileIndex tmptile;
 
	TileInfo ti;
 
	int i;
 
	int j;
 
	uint tile = *tile_ptr;
 
	TileIndex tile = *tile_ptr;
 

	
 
	TILE_ASSERT(tile);
 

	
 
	if (mask == 0) {
 
		// Tile has no road. First reset the status counter
 
		// to say that this is the last iteration.
 
@@ -708,13 +708,13 @@ build_road_and_exit:
 
	}
 
}
 
#undef IS_WATER_TILE
 

	
 

	
 
// Returns true if a house was built, or no if the build failed.
 
static int GrowTownAtRoad(Town *t, uint tile)
 
static int GrowTownAtRoad(Town *t, TileIndex tile)
 
{
 
	uint mask;
 
	int block = 5; // special case
 

	
 
	TILE_ASSERT(tile);
 

	
 
@@ -769,13 +769,13 @@ static int GenRandomRoadBits(void)
 
}
 

	
 
// Grow the town
 
// Returns true if a house was built, or no if the build failed.
 
bool GrowTown(Town *t)
 
{
 
	uint tile;
 
	TileIndex tile;
 
	const TileIndexDiffC *ptr;
 
	TileInfo ti;
 
	byte old_player;
 

	
 
	static const TileIndexDiffC _town_coord_mod[] = {
 
		{-1,  0},
 
@@ -1062,13 +1062,13 @@ int32 CmdBuildTown(int x, int y, uint32 
 
	}
 
	return 0;
 
}
 

	
 
Town *CreateRandomTown(uint attempts)
 
{
 
	uint tile;
 
	TileIndex tile;
 
	TileInfo ti;
 
	Town *t;
 
	uint32 townnameparts;
 

	
 
	do {
 
		// Generate a tile index not too close from the edge
 
@@ -1118,13 +1118,14 @@ void GenerateTowns(void)
 
	if (num == 0 && CreateRandomTown(10000) == NULL) {
 
		//XXX can we handle that more gracefully?
 
		error("Could not generate any town");
 
	}
 
}
 

	
 
static bool CheckBuildHouseMode(Town *t1, uint tile, uint tileh, int mode) {
 
static bool CheckBuildHouseMode(Town *t1, TileIndex tile, uint tileh, int mode)
 
{
 
	int b;
 
	uint slope;
 

	
 
	static const byte _masks[8] = {
 
		0xC,0x3,0x9,0x6,
 
		0x3,0xC,0x6,0x9,
 
@@ -1140,13 +1141,13 @@ static bool CheckBuildHouseMode(Town *t1
 
	if (b)
 
		return false;
 

	
 
	return DoCommandByTile(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR) != CMD_ERROR;
 
}
 

	
 
int GetTownRadiusGroup(Town *t, uint tile)
 
int GetTownRadiusGroup(Town *t, TileIndex tile)
 
{
 
	uint dist;
 
	int i,smallest;
 

	
 
	dist = DistanceSquare(tile, t->xy);
 
	if (t->fund_buildings_months && dist <= 25)
 
@@ -1158,13 +1159,13 @@ int GetTownRadiusGroup(Town *t, uint til
 
			smallest = i;
 
	}
 

	
 
	return smallest;
 
}
 

	
 
static bool CheckFree2x2Area(Town *t1, uint tile)
 
static bool CheckFree2x2Area(Town *t1, TileIndex tile)
 
{
 
	int i;
 

	
 
	static const TileIndexDiffC _tile_add[] = {
 
		{0    , 0    },
 
		{0 - 0, 1 - 0},
 
@@ -1182,13 +1183,13 @@ static bool CheckFree2x2Area(Town *t1, u
 
			return false;
 
	}
 

	
 
	return true;
 
}
 

	
 
static void DoBuildTownHouse(Town *t, uint tile)
 
static void DoBuildTownHouse(Town *t, TileIndex tile)
 
{
 
	int i;
 
	uint bitmask;
 
	int house;
 
	uint slope;
 
	uint z;
 
@@ -1355,13 +1356,13 @@ static void DoBuildTownHouse(Town *t, ui
 
		}
 
	}
 

	
 
	// ENDING
 
}
 

	
 
static bool BuildTownHouse(Town *t, uint tile)
 
static bool BuildTownHouse(Town *t, TileIndex tile)
 
{
 
	int32 r;
 

	
 
	// make sure it's possible
 
	if (!EnsureNoVehicle(tile)) return false;
 
	if (GetTileSlope(tile, NULL) & 0x10) return false;
 
@@ -1371,20 +1372,21 @@ static bool BuildTownHouse(Town *t, uint
 

	
 
	DoBuildTownHouse(t, tile);
 
	return true;
 
}
 

	
 

	
 
static void DoClearTownHouseHelper(uint tile)
 
static void DoClearTownHouseHelper(TileIndex tile)
 
{
 
	assert(IsTileType(tile, MP_HOUSE));
 
	DoClearSquare(tile);
 
	DeleteAnimatedTile(tile);
 
}
 

	
 
static void ClearTownHouse(Town *t, uint tile) {
 
static void ClearTownHouse(Town *t, TileIndex tile)
 
{
 
	uint house = _map3_hi[tile];
 
	uint eflags;
 

	
 
	assert(IsTileType(tile, MP_HOUSE));
 

	
 
	// need to align the tile to point to the upper left corner of the house
 
@@ -1561,13 +1563,13 @@ static void TownActionRoadRebuild(Town *
 
	SetDParam(2, p->name_2);
 

	
 
	AddNewsItem(STR_2055_TRAFFIC_CHAOS_IN_ROAD_REBUILDING,
 
		NEWS_FLAGS(NM_NORMAL, NF_TILE, NT_GENERAL, 0), t->xy, 0);
 
}
 

	
 
static bool DoBuildStatueOfCompany(uint tile)
 
static bool DoBuildStatueOfCompany(TileIndex tile)
 
{
 
	TileInfo ti;
 
	byte old;
 
	int32 r;
 

	
 
	FindLandscapeHeightByTile(&ti, tile);
 
@@ -1613,13 +1615,13 @@ static void TownActionBuildStatue(Town *
 
		{ 0, 1}, { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1}, { 0, 1},
 
		{ 1, 0}, { 1, 0}, { 1, 0}, { 1, 0}, { 1, 0}, { 1, 0}, { 1, 0}, { 1, 0},
 
		{ 0,-1}, { 0,-1}, { 0,-1}, { 0,-1}, { 0,-1}, { 0,-1}, { 0,-1}, { 0,-1},
 
		{-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0}, {-1, 0},
 
		{ 0, 0}
 
	};
 
	uint tile = t->xy;
 
	TileIndex tile = t->xy;
 
	const TileIndexDiffC *p;
 

	
 
	SETBIT(t->statues, _current_player);
 

	
 
	for (p = _statue_tiles; p != endof(_statue_tiles); ++p) {
 
		if (DoBuildStatueOfCompany(tile))
 
@@ -1808,13 +1810,13 @@ static void UpdateTownUnwanted(Town *t)
 
	FOR_ALL_PLAYERS(p) {
 
		if (t->unwanted[p->index] > 0)
 
			t->unwanted[p->index]--;
 
	}
 
}
 

	
 
bool CheckIfAuthorityAllows(uint tile)
 
bool CheckIfAuthorityAllows(TileIndex tile)
 
{
 
	Town *t;
 

	
 
	if (_current_player >= MAX_PLAYERS)
 
		return true;
 

	
 
@@ -1829,13 +1831,13 @@ bool CheckIfAuthorityAllows(uint tile)
 
	SetDParam(0, t->index);
 

	
 
	return false;
 
}
 

	
 

	
 
Town *ClosestTownFromTile(uint tile, uint threshold)
 
Town *ClosestTownFromTile(TileIndex tile, uint threshold)
 
{
 
	Town *t;
 
	uint dist, best = threshold;
 
	Town *best_town = NULL;
 

	
 
	// XXX - Fix this so for a given tiletype the owner of the type is in the same variable
 
@@ -1889,13 +1891,13 @@ static const int _default_rating_setting
 
	// ROAD_REMOVE, TUNNELBRIDGE_REMOVE, INDUSTRY_REMOVE
 
	{  0, 128, 384},	// Permissive
 
	{ 48, 192, 480},	// Neutral
 
	{ 96, 384, 768},	// Hostile
 
};
 

	
 
bool CheckforTownRating(uint tile, uint32 flags, Town *t, byte type)
 
bool CheckforTownRating(TileIndex tile, uint32 flags, Town *t, byte type)
 
{
 
	int modemod;
 

	
 
	//	if magic_bulldozer cheat is active, town doesn't restrict your destructive actions
 
	if (t == NULL || _current_player >= MAX_PLAYERS || _cheats.magic_bulldozer.value)
 
		return true;
train_cmd.c
Show inline comments
 
@@ -412,13 +412,13 @@ void DrawTrainEngineInfo(int engine, int
 
		SetDParam(5, _cargoc.names_long_p[rvi->cargo_type]);
 
	}
 
	DrawStringMultiCenter(x, y, STR_885B_COST_WEIGHT_T_SPEED_POWER, maxw);
 
}
 

	
 

	
 
static int32 CmdBuildRailWagon(uint engine, uint tile, uint32 flags)
 
static int32 CmdBuildRailWagon(uint engine, TileIndex tile, uint32 flags)
 
{
 
	int32 value;
 
	Vehicle *v;
 
	const RailVehicleInfo *rvi;
 
	int dir;
 
	const Engine *e;
 
@@ -1503,22 +1503,22 @@ int32 CmdRefitRailVehicle(int x, int y, 
 

	
 
	return cost;
 
}
 

	
 
typedef struct TrainFindDepotData {
 
	uint best_length;
 
	uint tile;
 
	TileIndex tile;
 
	byte owner;
 
	/**
 
	 * true if reversing is necesarry for the train to get to this depot This
 
	 * value is unused when new depot finding and NPF are both disabled
 
	 */
 
	bool reverse;
 
} TrainFindDepotData;
 

	
 
static bool TrainFindDepotEnumProc(uint tile, TrainFindDepotData *tfdd, int track, uint length, byte *state)
 
static bool TrainFindDepotEnumProc(TileIndex tile, TrainFindDepotData *tfdd, int track, uint length, byte *state)
 
{
 
	if (IsTileType(tile, MP_RAILWAY) && IsTileOwner(tile, tfdd->owner)) {
 
		if ((_map5[tile] & ~0x3) == 0xC0) {
 
			if (length < tfdd->best_length) {
 
				tfdd->best_length = length;
 
				tfdd->tile = tile;
 
@@ -1540,13 +1540,13 @@ static bool TrainFindDepotEnumProc(uint 
 
// returns the tile of a depot to goto to. The given vehicle must not be
 
// crashed!
 
static TrainFindDepotData FindClosestTrainDepot(Vehicle *v)
 
{
 
	int i;
 
	TrainFindDepotData tfdd;
 
	uint tile = v->tile;
 
	TileIndex tile = v->tile;
 

	
 
	assert(!(v->vehstatus & VS_CRASHED));
 

	
 
	tfdd.owner = v->owner;
 
	tfdd.best_length = (uint)-1;
 
	tfdd.reverse = false;
 
@@ -1804,13 +1804,14 @@ typedef struct TrainTrackFollowerData {
 
	StationID station_index; // station index we're heading for
 
	uint best_bird_dist;
 
	uint best_track_dist;
 
	byte best_track;
 
} TrainTrackFollowerData;
 

	
 
static bool TrainTrackFollower(uint tile, TrainTrackFollowerData *ttfd, int track, uint length, byte *state){
 
static bool TrainTrackFollower(TileIndex tile, TrainTrackFollowerData *ttfd, int track, uint length, byte *state)
 
{
 
	if (IsTileType(tile, MP_RAILWAY) && (_map5[tile]&0xC0) == 0x40) {
 
		// the tile has a signal
 
		byte m3 = _map3_lo[tile];
 
		if (!(m3 & SignalAlongTrackdir(track))) {
 
			// if one way signal not pointing towards us, stop going in this direction.
 
			if (m3 & SignalAgainstTrackdir(track))
 
@@ -1904,13 +1905,13 @@ unsigned int rdtsc()
 
     return low;
 
}
 
#endif
 

	
 

	
 
/* choose a track */
 
static byte ChooseTrainTrack(Vehicle *v, uint tile, int enterdir, TrackdirBits trackdirbits)
 
static byte ChooseTrainTrack(Vehicle *v, TileIndex tile, int enterdir, TrackdirBits trackdirbits)
 
{
 
	TrainTrackFollowerData fd;
 
	uint best_track;
 
#if PF_BENCHMARK
 
	int time = rdtsc();
 
	static float f;
 
@@ -2381,13 +2382,13 @@ static byte AfterSetTrainPos(Vehicle *v,
 
static const byte _new_vehicle_direction_table[11] = {
 
	0, 7, 6, 0,
 
	1, 0, 5, 0,
 
	2, 3, 4,
 
};
 

	
 
static int GetNewVehicleDirectionByTile(uint new_tile, uint old_tile)
 
static int GetNewVehicleDirectionByTile(TileIndex new_tile, TileIndex old_tile)
 
{
 
	uint offs = (TileY(new_tile) - TileY(old_tile) + 1) * 4 +
 
							TileX(new_tile) - TileX(old_tile) + 1;
 
	assert(offs < 11);
 
	return _new_vehicle_direction_table[offs];
 
}
 
@@ -2503,13 +2504,13 @@ static void AffectSpeedByZChange(Vehicle
 

	
 
static const byte _otherside_signal_directions[14] = {
 
	1, 3, 1, 3, 5, 3, 0, 0,
 
	5, 7, 7, 5, 7, 1,
 
};
 

	
 
static void TrainMovedChangeSignals(uint tile, int dir)
 
static void TrainMovedChangeSignals(TileIndex tile, int dir)
 
{
 
	int i;
 
	if (IsTileType(tile, MP_RAILWAY) && (_map5[tile] & 0xC0) == 0x40) {
 
		i = FindFirstBit2x64((_map5[tile]+(_map5[tile]<<8)) & _reachable_tracks[dir]);
 
		UpdateSignalsOnSegment(tile, _otherside_signal_directions[i]);
 
	}
 
@@ -3002,13 +3003,13 @@ static void HandleBrokenTrain(Vehicle *v
 
static const byte _breakdown_speeds[16] = {
 
	225, 210, 195, 180, 165, 150, 135, 120, 105, 90, 75, 60, 45, 30, 15, 15
 
};
 

	
 
static bool TrainCheckIfLineEnds(Vehicle *v)
 
{
 
	uint tile;
 
	TileIndex tile;
 
	uint x,y;
 
	int t;
 
	uint32 ts;
 

	
 
	if ((uint)(t=v->breakdown_ctr) > 1) {
 
		v->vehstatus |= VS_TRAIN_SLOWING;
 
@@ -3205,13 +3206,13 @@ static const byte _depot_track_ind[4] = 
 
static bool ValidateTrainInDepot( uint data_a, uint data_b )
 
{
 
	Vehicle *v = GetVehicle(data_a);
 
	return  (v->u.rail.track == 0x80 && (v->vehstatus | VS_STOPPED));
 
}
 

	
 
void TrainEnterDepot(Vehicle *v, uint tile)
 
void TrainEnterDepot(Vehicle *v, TileIndex tile)
 
{
 
	SetSignalsOnBothDir(tile, _depot_track_ind[_map5[tile]&3]);
 

	
 
	if (v->subtype != TS_Front_Engine)
 
		v = GetFirstVehicleInChain(v);
 

	
train_gui.c
Show inline comments
 
@@ -105,13 +105,13 @@ void DrawTrainWagonPurchaseInfo(int x, i
 
	SetDParam(1, rvi->capacity);
 
	SetDParam(2, refittable ? STR_9842_REFITTABLE : STR_EMPTY);
 
	DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0);
 
	y += 10;
 
}
 

	
 
void CcBuildWagon(bool success, uint tile, uint32 p1, uint32 p2)
 
void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v,*found;
 

	
 
	if (!success)
 
		return;
 

	
 
@@ -133,13 +133,13 @@ void CcBuildWagon(bool success, uint til
 
		// put the new wagon at the end of the loco.
 
		DoCommandP(0, _new_wagon_id | (found->index<<16), 0, NULL, CMD_MOVE_RAIL_VEHICLE);
 
		RebuildVehicleLists();
 
	}
 
}
 

	
 
void CcBuildLoco(bool success, uint tile, uint32 p1, uint32 p2)
 
void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 

	
 
	if (!success)
 
		return;
 

	
 
@@ -301,13 +301,13 @@ static const WindowDesc _new_rail_vehicl
 
	WC_BUILD_VEHICLE,0,
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
 
	_new_rail_vehicle_widgets,
 
	NewRailVehicleWndProc
 
};
 

	
 
static void ShowBuildTrainWindow(uint tile)
 
static void ShowBuildTrainWindow(TileIndex tile)
 
{
 
	Window *w;
 

	
 
	DeleteWindowById(WC_BUILD_VEHICLE, tile);
 

	
 
	w = AllocateWindowDesc(&_new_rail_vehicle_desc);
 
@@ -351,13 +351,13 @@ static void DrawTrainImage(const Vehicle
 
			break;
 
	} while (x < max_x);
 
}
 

	
 
static void DrawTrainDepotWindow(Window *w)
 
{
 
	uint tile;
 
	TileIndex tile;
 
	Vehicle *v, *u;
 
	int num,x,y,i, hnum;
 
	Depot *depot;
 

	
 
	tile = w->window_number;
 

	
 
@@ -698,13 +698,13 @@ static const WindowDesc _train_depot_des
 
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
 
	_train_depot_widgets,
 
	TrainDepotWndProc
 
};
 

	
 

	
 
void ShowTrainDepotWindow(uint tile)
 
void ShowTrainDepotWindow(TileIndex tile)
 
{
 
	Window *w;
 

	
 
	w = AllocateWindowDescFront(&_train_depot_desc, tile);
 
	if (w) {
 
		w->caption_color = GetTileOwner(w->window_number);
 
@@ -1388,13 +1388,13 @@ static void PlayerTrainsWndProc(Window *
 

	
 
				ShowTrainViewWindow(v);
 
			}
 
		} break;
 

	
 
		case 9: { /* Build new Vehicle */
 
			uint tile;
 
			TileIndex tile;
 

	
 
			if (!IsWindowOfPrototype(w, _player_trains_widgets))
 
				break;
 

	
 
			tile = _last_built_train_depot_tile;
 
			do {
tree_cmd.c
Show inline comments
 
@@ -32,13 +32,13 @@ static int GetRandomTreeType(TileIndex t
 

	
 
		default:
 
			return (seed * 9 >> 8) + 32;
 
	}
 
}
 

	
 
static void PlaceTree(uint tile, uint32 r, byte m5_or)
 
static void PlaceTree(TileIndex tile, uint32 r, byte m5_or)
 
{
 
	int tree = GetRandomTreeType(tile, (r >> 24));
 
	byte m5;
 

	
 
	if (tree >= 0) {
 
		m5 = (byte)(r >> 16);
 
@@ -63,21 +63,22 @@ static void PlaceTree(uint tile, uint32 
 

	
 
		// make it tree class
 
		SetTileType(tile, MP_TREES);
 
	}
 
}
 

	
 
static void DoPlaceMoreTrees(uint tile)
 
static void DoPlaceMoreTrees(TileIndex tile)
 
{
 
	int i = 1000;
 
	int x,y;
 
	uint cur_tile;
 
	int dist;
 

	
 
	do {
 
		uint32 r = Random();
 
		TileIndex cur_tile;
 

	
 
		x = (r & 0x1F) - 16;
 
		y = ((r>>8) & 0x1F) - 16;
 

	
 
		dist = myabs(x) + myabs(y);
 

	
 
		cur_tile = TILE_MASK(tile + TILE_XY(x,y));
 
@@ -100,13 +101,13 @@ static void PlaceMoreTrees(void)
 
}
 

	
 
void PlaceTreesRandomly(void)
 
{
 
	int i;
 
	uint32 r;
 
	uint tile;
 
	TileIndex tile;
 

	
 
	i = ScaleByMapSize(1000);
 
	do {
 
		r = Random();
 
		tile = TILE_MASK(r);
 
		/* Only on clear tiles, and NOT on farm-tiles or rocks */
 
@@ -364,13 +365,14 @@ static uint GetSlopeZ_Trees(TileInfo *ti
 
}
 

	
 
static uint GetSlopeTileh_Trees(TileInfo *ti) {
 
	return ti->tileh;
 
}
 

	
 
static int32 ClearTile_Trees(uint tile, byte flags) {
 
static int32 ClearTile_Trees(TileIndex tile, byte flags)
 
{
 
	int num;
 

	
 
	if (flags & DC_EXEC && _current_player < MAX_PLAYERS) {
 
		Town *t = ClosestTownFromTile(tile, _patches.dist_local_authority);
 
		if (t != NULL)
 
			ChangeTownRating(t, RATING_TREE_DOWN_STEP, RATING_TREE_MINIMUM);
 
@@ -383,18 +385,18 @@ static int32 ClearTile_Trees(uint tile, 
 
	if (flags & DC_EXEC)
 
		DoClearSquare(tile);
 

	
 
	return num * _price.remove_trees;
 
}
 

	
 
static void GetAcceptedCargo_Trees(uint tile, AcceptedCargo ac)
 
static void GetAcceptedCargo_Trees(TileIndex tile, AcceptedCargo ac)
 
{
 
	/* not used */
 
}
 

	
 
static void GetTileDesc_Trees(uint tile, TileDesc *td)
 
static void GetTileDesc_Trees(TileIndex tile, TileDesc *td)
 
{
 
	byte b;
 
	StringID str;
 

	
 
	td->owner = GetTileOwner(tile);
 

	
 
@@ -402,25 +404,25 @@ static void GetTileDesc_Trees(uint tile,
 
	(str=STR_2810_CACTUS_PLANTS, b==0x1B) ||
 
	(str=STR_280F_RAINFOREST, IS_BYTE_INSIDE(b, 0x14, 0x1A+1)) ||
 
	(str=STR_280E_TREES, true);
 
	td->str = str;
 
}
 

	
 
static void AnimateTile_Trees(uint tile)
 
static void AnimateTile_Trees(TileIndex tile)
 
{
 
	/* not used */
 
}
 

	
 
static SoundFx _desert_sounds[] = {
 
	SND_42_LOON_BIRD,
 
	SND_43_LION,
 
	SND_44_MONKEYS,
 
	SND_48_DISTANT_BIRD
 
};
 

	
 
static void TileLoopTreesDesert(uint tile)
 
static void TileLoopTreesDesert(TileIndex tile)
 
{
 
	byte b;
 

	
 
	if ((b=GetMapExtraBits(tile)) == 2) {
 
		uint32 r;
 

	
 
@@ -433,13 +435,13 @@ static void TileLoopTreesDesert(uint til
 
			_map2[tile] |= 0xE0;
 
			MarkTileDirtyByTile(tile);
 
		}
 
	}
 
}
 

	
 
static void TileLoopTreesAlps(uint tile)
 
static void TileLoopTreesAlps(TileIndex tile)
 
{
 
	byte tmp, m2;
 
	int k;
 

	
 
	/* distance from snow line, in steps of 8 */
 
	k = GetTileZ(tile) - _opt.snow_line;
 
@@ -481,13 +483,13 @@ static void TileLoopTreesAlps(uint tile)
 

	
 
	_map2[tile] &= 0xF;
 
	_map2[tile] |= m2;
 
	MarkTileDirtyByTile(tile);
 
}
 

	
 
static void TileLoop_Trees(uint tile)
 
static void TileLoop_Trees(TileIndex tile)
 
{
 
	byte m5;
 
	uint16 m2;
 

	
 
	static const TileIndexDiffC _tileloop_trees_dir[] = {
 
		{-1, -1},
 
@@ -591,13 +593,13 @@ static void TileLoop_Trees(uint tile)
 
	MarkTileDirtyByTile(tile);
 
}
 

	
 
void OnTick_Trees(void)
 
{
 
	uint32 r;
 
	uint tile;
 
	TileIndex tile;
 
	byte m;
 
	int tree;
 

	
 
	/* place a tree at a random rainforest spot */
 
	if (_opt.landscape == LT_DESERT &&
 
			(r=Random(),tile=TILE_MASK(r),GetMapExtraBits(tile)==2) &&
 
@@ -643,23 +645,23 @@ void OnTick_Trees(void)
 
			_map3_hi[tile] & ~3,
 
			0
 
		);
 
	}
 
}
 

	
 
static void ClickTile_Trees(uint tile)
 
static void ClickTile_Trees(TileIndex tile)
 
{
 
	/* not used */
 
}
 

	
 
static uint32 GetTileTrackStatus_Trees(uint tile, TransportType mode)
 
static uint32 GetTileTrackStatus_Trees(TileIndex tile, TransportType mode)
 
{
 
	return 0;
 
}
 

	
 
static void ChangeTileOwner_Trees(uint tile, byte old_player, byte new_player)
 
static void ChangeTileOwner_Trees(TileIndex tile, byte old_player, byte new_player)
 
{
 
	/* not used */
 
}
 

	
 
void InitializeTrees(void)
 
{
tunnelbridge_cmd.c
Show inline comments
 
@@ -8,13 +8,13 @@
 
#include "viewport.h"
 
#include "command.h"
 
#include "player.h"
 
#include "town.h"
 
#include "sound.h"
 

	
 
extern void DrawCanalWater(uint tile);
 
extern void DrawCanalWater(TileIndex tile);
 

	
 
static const byte _bridge_available_year[MAX_BRIDGES] = {
 
	0, 0, 10, 0, 10, 10, 10, 10, 10, 10, 75, 85, 90
 
};
 

	
 
static const byte _bridge_minlen[MAX_BRIDGES] = {
 
@@ -397,18 +397,16 @@ not_valid_below:;
 
		cost += ((int64)bridge_len * _price.build_bridge * _bridge_type_price_mod[bridge_type]) >> 8;
 
	}
 

	
 
	return cost;
 
}
 

	
 
static bool DoCheckTunnelInWay(uint tile, uint z, uint dir)
 
static bool DoCheckTunnelInWay(TileIndex tile, uint z, uint dir)
 
{
 
	TileIndexDiff delta = TileOffsByDir(dir);
 
	TileInfo ti;
 
	int delta;
 

	
 
	delta = TileOffsByDir(dir);
 

	
 
	do {
 
		tile -= delta;
 
		FindLandscapeHeightByTile(&ti, tile);
 
	} while (z < ti.z);
 

	
 
@@ -417,13 +415,13 @@ static bool DoCheckTunnelInWay(uint tile
 
		return false;
 
	}
 

	
 
	return true;
 
}
 

	
 
bool CheckTunnelInWay(uint tile, int z)
 
bool CheckTunnelInWay(TileIndex tile, int z)
 
{
 
	return DoCheckTunnelInWay(tile,z,0) &&
 
		DoCheckTunnelInWay(tile,z,1) &&
 
		DoCheckTunnelInWay(tile,z,2) &&
 
		DoCheckTunnelInWay(tile,z,3);
 
}
 
@@ -590,13 +588,13 @@ int32 CmdBuildTunnel(int x, int y, uint3
 
TileIndex CheckTunnelBusy(TileIndex tile, uint *length)
 
{
 
	uint z = GetTileZ(tile);
 
	byte m5 = _map5[tile];
 
	int delta = TileOffsByDir(m5 & 3);
 
	uint len = 0;
 
	uint starttile = tile;
 
	TileIndex starttile = tile;
 
	Vehicle *v;
 

	
 
	do {
 
		tile += delta;
 
		len++;
 
	} while (
 
@@ -614,13 +612,13 @@ TileIndex CheckTunnelBusy(TileIndex tile
 
	}
 

	
 
	if (length != NULL) *length = len;
 
	return tile;
 
}
 

	
 
static int32 DoClearTunnel(uint tile, uint32 flags)
 
static int32 DoClearTunnel(TileIndex tile, uint32 flags)
 
{
 
	Town *t;
 
	TileIndex endtile;
 
	uint length;
 
	static const byte _updsignals_tunnel_dir[4] = { 5, 7, 1, 3};
 

	
 
@@ -659,16 +657,16 @@ static int32 DoClearTunnel(uint tile, ui
 
		if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR)
 
			ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM);
 
	}
 
	return  _price.clear_tunnel * (length + 1);
 
}
 

	
 
static uint FindEdgesOfBridge(uint tile, uint *endtile)
 
static TileIndex FindEdgesOfBridge(TileIndex tile, TileIndex *endtile)
 
{
 
	int direction = _map5[tile] & 1;
 
	uint start;
 
	TileIndex start;
 

	
 
	// find start of bridge
 
	for(;;) {
 
		if (IsTileType(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xE0) == 0x80)
 
			break;
 
		tile += direction ? TILE_XY(0,-1) : TILE_XY(-1,0);
 
@@ -685,15 +683,15 @@ static uint FindEdgesOfBridge(uint tile,
 

	
 
	*endtile = tile;
 

	
 
	return start;
 
}
 

	
 
static int32 DoClearBridge(uint tile, uint32 flags)
 
static int32 DoClearBridge(TileIndex tile, uint32 flags)
 
{
 
	uint endtile;
 
	TileIndex endtile;
 
	Vehicle *v;
 
	Town *t;
 
	int direction;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 

	
 
@@ -808,13 +806,14 @@ clear_it:;
 

	
 
	}
 

	
 
	return ((((endtile - tile) >> (direction?8:0))&0xFF)+1) * _price.clear_bridge;
 
}
 

	
 
static int32 ClearTile_TunnelBridge(uint tile, byte flags) {
 
static int32 ClearTile_TunnelBridge(TileIndex tile, byte flags)
 
{
 
	byte m5 = _map5[tile];
 

	
 
	if ((m5 & 0xF0) == 0) {
 
		if (flags & DC_AUTO)
 
			return_cmd_error(STR_5006_MUST_DEMOLISH_TUNNEL_FIRST);
 

	
 
@@ -826,13 +825,13 @@ static int32 ClearTile_TunnelBridge(uint
 
		return DoClearBridge(tile, flags);
 
	}
 

	
 
	return CMD_ERROR;
 
}
 

	
 
int32 DoConvertTunnelBridgeRail(uint tile, uint totype, bool exec)
 
int32 DoConvertTunnelBridgeRail(TileIndex tile, uint totype, bool exec)
 
{
 
	TileIndex endtile;
 
	uint length;
 
	Vehicle *v;
 

	
 
	if ((_map5[tile] & 0xFC) == 0x00) {
 
@@ -1226,13 +1225,13 @@ static uint GetSlopeZ_TunnelBridge(TileI
 
static uint GetSlopeTileh_TunnelBridge(TileInfo *ti) {
 
	// not accurate, but good enough for slope graphics drawing
 
	return 0;
 
}
 

	
 

	
 
static void GetAcceptedCargo_TunnelBridge(uint tile, AcceptedCargo ac)
 
static void GetAcceptedCargo_TunnelBridge(TileIndex tile, AcceptedCargo ac)
 
{
 
	/* not used */
 
}
 

	
 
static const StringID _bridge_tile_str[(MAX_BRIDGES + 3) + (MAX_BRIDGES + 3)] = {
 
	STR_501F_WOODEN_RAIL_BRIDGE,
 
@@ -1263,13 +1262,13 @@ static const StringID _bridge_tile_str[(
 
	STR_5028_TUBULAR_ROAD_BRIDGE,
 
	STR_5028_TUBULAR_ROAD_BRIDGE,
 
	STR_5028_TUBULAR_ROAD_BRIDGE,
 
	0,0,0,
 
};
 

	
 
static void GetTileDesc_TunnelBridge(uint tile, TileDesc *td)
 
static void GetTileDesc_TunnelBridge(TileIndex tile, TileDesc *td)
 
{
 
	int delta;
 

	
 
	if ((_map5[tile] & 0x80) == 0) {
 
		td->str = STR_5017_RAILROAD_TUNNEL + ((_map5[tile] >> 2) & 3);
 
	} else {
 
@@ -1282,18 +1281,18 @@ static void GetTileDesc_TunnelBridge(uin
 
		}
 
	}
 
	td->owner = GetTileOwner(tile);
 
}
 

	
 

	
 
static void AnimateTile_TunnelBridge(uint tile)
 
static void AnimateTile_TunnelBridge(TileIndex tile)
 
{
 
	/* not used */
 
}
 

	
 
static void TileLoop_TunnelBridge(uint tile)
 
static void TileLoop_TunnelBridge(TileIndex tile)
 
{
 
	if (_opt.landscape == LT_HILLY) {
 
		if ( GetTileZ(tile) > _opt.snow_line) {
 
			if (!(_map3_hi[tile] & 0x80)) {
 
				_map3_hi[tile] |= 0x80;
 
				MarkTileDirtyByTile(tile);
 
@@ -1312,19 +1311,19 @@ static void TileLoop_TunnelBridge(uint t
 
	}
 

	
 
	// if it's a bridge with water below, call tileloop_water on it.
 
	if ((_map5[tile] & 0xF8) == 0xC8) TileLoop_Water(tile);
 
}
 

	
 
static void ClickTile_TunnelBridge(uint tile)
 
static void ClickTile_TunnelBridge(TileIndex tile)
 
{
 
	/* not used */
 
}
 

	
 

	
 
static uint32 GetTileTrackStatus_TunnelBridge(uint tile, TransportType mode)
 
static uint32 GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType mode)
 
{
 
	uint32 result;
 
	byte m5 = _map5[tile];
 

	
 
	if ((m5 & 0xF0) == 0) {
 
		/* This is a tunnel */
 
@@ -1365,13 +1364,13 @@ static uint32 GetTileTrackStatus_TunnelB
 
	} else {
 
		assert(0); /* This should never occur */
 
	}
 
	return 0;
 
}
 

	
 
static void ChangeTileOwner_TunnelBridge(uint tile, byte old_player, byte new_player)
 
static void ChangeTileOwner_TunnelBridge(TileIndex tile, byte old_player, byte new_player)
 
{
 
	if (!IsTileOwner(tile, old_player)) return;
 

	
 
	if (new_player != 255) {
 
		SetTileOwner(tile, new_player);
 
	}	else {
 
@@ -1401,13 +1400,13 @@ static const byte _road_exit_tunnel_fram
 

	
 
static const byte _tunnel_fractcoord_4[4] = {0x52, 0x85, 0x98, 0x29};
 
static const byte _tunnel_fractcoord_5[4] = {0x92, 0x89, 0x58, 0x25};
 
static const byte _tunnel_fractcoord_6[4] = {0x92, 0x89, 0x56, 0x45};
 
static const byte _tunnel_fractcoord_7[4] = {0x52, 0x85, 0x96, 0x49};
 

	
 
static uint32 VehicleEnter_TunnelBridge(Vehicle *v, uint tile, int x, int y)
 
static uint32 VehicleEnter_TunnelBridge(Vehicle *v, TileIndex tile, int x, int y)
 
{
 
	int z;
 
	int dir, vdir;
 
	byte fc;
 

	
 
	if ((_map5[tile] & 0xF0) == 0) {
unmovable_cmd.c
Show inline comments
 
@@ -55,13 +55,13 @@ int32 DestroyCompanyHQ(TileIndex tile, u
 

	
 
/** Build or relocate the HQ. This depends if the HQ is already built or not
 
 * @param x,y the coordinates where the HQ will be built or relocated to
 
 * @param p1 relocate HQ (set to some value, usually 1 or true)
 
 * @param p2 unused
 
 */
 
 extern int32 CheckFlatLandBelow(uint tile, uint w, uint h, uint flags, uint invalid_dirs, int *);
 
extern int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, int *);
 
int32 CmdBuildCompanyHQ(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	TileIndex tile = TILE_FROM_XY(x,y);
 
	Player *p = GetPlayer(_current_player);
 
	int cost;
 

	
 
@@ -190,13 +190,13 @@ static uint GetSlopeZ_Unmovable(TileInfo
 

	
 
static uint GetSlopeTileh_Unmovable(TileInfo *ti)
 
{
 
	return 0;
 
}
 

	
 
static int32 ClearTile_Unmovable(uint tile, byte flags)
 
static int32 ClearTile_Unmovable(TileIndex tile, byte flags)
 
{
 
	byte m5 = _map5[tile];
 

	
 
	if (m5 & 0x80) {
 
		if (_current_player == OWNER_WATER) return DestroyCompanyHQ(tile, DC_EXEC);
 
		return_cmd_error(STR_5804_COMPANY_HEADQUARTERS_IN);
 
@@ -213,13 +213,13 @@ static int32 ClearTile_Unmovable(uint ti
 
		DoClearSquare(tile);
 
	}
 

	
 
	return 0;
 
}
 

	
 
static void GetAcceptedCargo_Unmovable(uint tile, AcceptedCargo ac)
 
static void GetAcceptedCargo_Unmovable(TileIndex tile, AcceptedCargo ac)
 
{
 
	byte m5 = _map5[tile];
 
	uint level; // HQ level (depends on company performance) in the range 1..5.
 

	
 
	if (!(m5 & 0x80)) {
 
		/* not used */
 
@@ -247,26 +247,26 @@ static const StringID _unmovable_tile_st
 
	STR_5801_TRANSMITTER,
 
	STR_5802_LIGHTHOUSE,
 
	STR_2016_STATUE,
 
	STR_5805_COMPANY_OWNED_LAND,
 
};
 

	
 
static void GetTileDesc_Unmovable(uint tile, TileDesc *td)
 
static void GetTileDesc_Unmovable(TileIndex tile, TileDesc *td)
 
{
 
	int i = _map5[tile];
 
	if (i & 0x80) i = -1;
 
	td->str = _unmovable_tile_str[i + 1];
 
	td->owner = GetTileOwner(tile);
 
}
 

	
 
static void AnimateTile_Unmovable(uint tile)
 
static void AnimateTile_Unmovable(TileIndex tile)
 
{
 
	/* not used */
 
}
 

	
 
static void TileLoop_Unmovable(uint tile)
 
static void TileLoop_Unmovable(TileIndex tile)
 
{
 
	byte m5 = _map5[tile];
 
	byte level; // HQ level (depends on company performance) in the range 1..5.
 
	uint32 r;
 

	
 
	if (!(m5 & 0x80)) {
 
@@ -297,18 +297,18 @@ static void TileLoop_Unmovable(uint tile
 
		if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
 
		MoveGoodsToStation(tile, 2, 2, CT_MAIL, amt);
 
	}
 
}
 

	
 

	
 
static uint32 GetTileTrackStatus_Unmovable(uint tile, TransportType mode)
 
static uint32 GetTileTrackStatus_Unmovable(TileIndex tile, TransportType mode)
 
{
 
	return 0;
 
}
 

	
 
static void ClickTile_Unmovable(uint tile)
 
static void ClickTile_Unmovable(TileIndex tile)
 
{
 
	if (_map5[tile] & 0x80) {
 
		ShowPlayerCompany(GetTileOwner(tile));
 
	}
 
}
 

	
 
@@ -317,15 +317,15 @@ static const TileIndexDiffC _tile_add[] 
 
	{ 0,  1},
 
	{-1,  0},
 
	{ 0, -1}
 
};
 

	
 
/* checks, if a radio tower is within a 9x9 tile square around tile */
 
static bool checkRadioTowerNearby(uint tile)
 
static bool checkRadioTowerNearby(TileIndex tile)
 
{
 
	uint tile_s;
 
	TileIndex tile_s;
 

	
 
	tile_s = TILE_XY(TileX(tile) - 4, TileY(tile) - 4);
 

	
 
	BEGIN_TILE_LOOP(tile, 9, 9, tile_s)
 
		// already a radio tower here?
 
		if (IsTileType(tile, MP_UNMOVABLE) && _map5[tile] == 0)
 
@@ -334,13 +334,13 @@ static bool checkRadioTowerNearby(uint t
 
	return true;
 
}
 

	
 
void GenerateUnmovables(void)
 
{
 
	int i,j;
 
	uint tile;
 
	TileIndex tile;
 
	uint32 r;
 
	int dir;
 
	uint h;
 

	
 
	if (_opt.landscape == LT_CANDY)
 
		return;
 
@@ -391,13 +391,13 @@ restart:
 
		SetTileType(tile, MP_UNMOVABLE);
 
		_map5[tile] = 1;
 
		SetTileOwner(tile, OWNER_NONE);
 
	} while (--i);
 
}
 

	
 
static void ChangeTileOwner_Unmovable(uint tile, byte old_player, byte new_player)
 
static void ChangeTileOwner_Unmovable(TileIndex tile, byte old_player, byte new_player)
 
{
 
	if (!IsTileOwner(tile, old_player)) return;
 

	
 
	if (_map5[tile]==3 && new_player != 255) {
 
		SetTileOwner(tile, new_player);
 
	}	else {
variables.h
Show inline comments
 
@@ -310,13 +310,13 @@ VARDEF uint _fullscreen_bpp;
 
VARDEF bool _fast_forward;
 
VARDEF bool _rightclick_emulate;
 

	
 
// IN/OUT parameters to commands
 
VARDEF byte _yearly_expenses_type;
 
VARDEF TileIndex _terraform_err_tile;
 
VARDEF uint _build_tunnel_endtile;
 
VARDEF TileIndex _build_tunnel_endtile;
 
VARDEF bool _generating_world;
 
VARDEF int _new_town_size;
 
VARDEF uint _returned_refit_amount;
 

	
 
// Deals with the type of the savegame, independent of extension
 
typedef struct {
vehicle.c
Show inline comments
 
@@ -1772,15 +1772,15 @@ Trackdir GetVehicleTrackdir(const Vehicl
 
	}
 
}
 
/* Return value has bit 0x2 set, when the vehicle enters a station. Then,
 
 * result << 8 contains the id of the station entered. If the return value has
 
 * bit 0x8 set, the vehicle could not and did not enter the tile. Are there
 
 * other bits that can be set? */
 
uint32 VehicleEnterTile(Vehicle *v, uint tile, int x, int y)
 
uint32 VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y)
 
{
 
	uint old_tile = v->tile;
 
	TileIndex old_tile = v->tile;
 
	uint32 result = _tile_type_procs[GetTileType(tile)]->vehicle_enter_tile_proc(v, tile, x, y);
 

	
 
	/* When vehicle_enter_tile_proc returns 8, that apparently means that
 
	 * we cannot enter the tile at all. In that case, don't call
 
	 * leave_tile. */
 
	if (!(result & 8) && old_tile != tile) {
vehicle.h
Show inline comments
 
@@ -272,13 +272,13 @@ void InitializeTrains(void);
 

	
 
bool CanFillVehicle(Vehicle *v);
 
bool CanRefitTo(const Vehicle *v, CargoID cid_to);
 

	
 
void ViewportAddVehicles(DrawPixelInfo *dpi);
 

	
 
void TrainEnterDepot(Vehicle *v, uint tile);
 
void TrainEnterDepot(Vehicle *v, TileIndex tile);
 

	
 
void AddRearEngineToMultiheadedTrain(Vehicle *v, Vehicle *u, bool building) ;
 

	
 
/* train_cmd.h */
 
int GetTrainImage(const Vehicle *v, byte direction);
 
int GetAircraftImage(const Vehicle *v, byte direction);
 
@@ -286,20 +286,20 @@ int GetRoadVehImage(const Vehicle *v, by
 
int GetShipImage(const Vehicle *v, byte direction);
 

	
 
Vehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicle type);
 
Vehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicle type);
 
Vehicle *CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, EffectVehicle type);
 

	
 
uint32 VehicleEnterTile(Vehicle *v, uint tile, int x, int y);
 
uint32 VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y);
 

	
 
void VehicleInTheWayErrMsg(Vehicle *v);
 
Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z);
 
TileIndex GetVehicleOutOfTunnelTile(const Vehicle *v);
 

	
 
bool UpdateSignalsOnSegment(uint tile, byte direction);
 
void SetSignalsOnBothDir(uint tile, byte track);
 
bool UpdateSignalsOnSegment(TileIndex tile, byte direction);
 
void SetSignalsOnBothDir(TileIndex tile, byte track);
 

	
 
Vehicle *CheckClickOnVehicle(ViewPort *vp, int x, int y);
 
//uint GetVehicleWeight(Vehicle *v);
 

	
 
void DecreaseVehicleValue(Vehicle *v);
 
void CheckVehicleBreakdown(Vehicle *v);
 
@@ -323,14 +323,14 @@ int32 GetTrainRunningCost(const Vehicle 
 
int CheckTrainStoppedInDepot(const Vehicle *v);
 

	
 
bool VehicleNeedsService(const Vehicle *v);
 

	
 
typedef struct GetNewVehiclePosResult {
 
	int x,y;
 
	uint old_tile;
 
	uint new_tile;
 
	TileIndex old_tile;
 
	TileIndex new_tile;
 
} GetNewVehiclePosResult;
 

	
 
/**
 
 * Returns the Trackdir on which the vehicle is currently located.
 
 * Works for trains and ships.
 
 * Currently works only sortof for road vehicles, since they have a fuzzy
viewport.c
Show inline comments
 
@@ -546,28 +546,28 @@ void *AddStringToDraw(int x, int y, Stri
 
}
 

	
 
/* Debugging code */
 

	
 
#ifdef DEBUG_TILE_PUSH
 
static int _num_push;
 
static uint _pushed_tile[200];
 
static TileIndex _pushed_tile[200];
 
static int _pushed_track[200];
 

	
 
static uint _stored_tile[200];
 
static TileIndex _stored_tile[200];
 
static int _stored_track[200];
 
static int _num_stored;
 

	
 
void dbg_store_path(void)
 
{
 
	memcpy(_stored_tile, _pushed_tile, sizeof(_stored_tile));
 
	memcpy(_stored_track, _pushed_track, sizeof(_stored_tile));
 
	_num_stored = _num_push;
 
	MarkWholeScreenDirty();
 
}
 

	
 
void dbg_push_tile(uint tile, int track)
 
void dbg_push_tile(TileIndex tile, int track)
 
{
 
	_pushed_tile[_num_push] = tile;
 
	_pushed_track[_num_push++] = track;
 
	dbg_store_path();
 
}
 

	
 
@@ -681,13 +681,13 @@ static void DrawTileSelection(const Tile
 

	
 
			if (_thd.make_square_red) image |= PALETTE_SEL_TILE_RED;
 
			DrawSelectionSprite(image, ti);
 

	
 
		} else if (IsPartOfAutoLine(ti->x, ti->y)) { // autorail highlighting long line
 
				int dir = _thd.drawstyle & ~0xF0;
 
				uint start = TILE_FROM_XY(_thd.selstart.x, _thd.selstart.y);
 
				TileIndex start = TILE_FROM_XY(_thd.selstart.x, _thd.selstart.y);
 
				int diffx, diffy;
 
				int side;
 

	
 
				diffx = myabs(TileX(start)-TileX(ti->tile));
 
				diffy = myabs(TileY(start)-TileY(ti->tile));
 

	
 
@@ -1695,16 +1695,14 @@ static bool CheckClickOnWaypoint(ViewPor
 
}
 

	
 

	
 
static void CheckClickOnLandscape(ViewPort *vp, int x, int y)
 
{
 
	Point pt = TranslateXYToTileCoord(vp,x,y);
 
	if (pt.x != -1) {
 
		uint tile = TILE_FROM_XY(pt.x, pt.y);
 
		ClickTile(tile);
 
	}
 

	
 
	if (pt.x != -1) ClickTile(TILE_FROM_XY(pt.x, pt.y));
 
}
 

	
 
void HandleClickOnTrain(Vehicle *v);
 
void HandleClickOnRoadVeh(Vehicle *v);
 
void HandleClickOnAircraft(Vehicle *v);
 
void HandleClickOnShip(Vehicle *v);
 
@@ -1939,13 +1937,13 @@ void UpdateTileSelection(void)
 
		// draw the new selection?
 
		if (_thd.new_drawstyle) SetSelectionTilesDirty();
 
	}
 
}
 

	
 
// highlighting tiles while only going over them with the mouse
 
void VpStartPlaceSizing(uint tile, int user)
 
void VpStartPlaceSizing(TileIndex tile, int user)
 
{
 
	_thd.userdata = user;
 
	_thd.selend.x = TileX(tile) * 16;
 
	_thd.selstart.x = TileX(tile) * 16;
 
	_thd.selend.y = TileY(tile) * 16;
 
	_thd.selstart.y = TileY(tile) * 16;
viewport.h
Show inline comments
 
@@ -37,13 +37,13 @@ void EndSpriteCombine(void);
 
void HandleViewportClicked(ViewPort *vp, int x, int y);
 
void PlaceObject(void);
 
void SetRedErrorSquare(TileIndex tile);
 
void SetTileSelectSize(int w, int h);
 
void SetTileSelectBigSize(int ox, int oy, int sx, int sy);
 

	
 
void VpStartPlaceSizing(uint tile, int user);
 
void VpStartPlaceSizing(TileIndex tile, int user);
 
void VpStartPreSizing(void);
 
void VpSetPresizeRange(uint from, uint to);
 
void VpSetPlaceSizingLimit(int limit);
 

	
 
Vehicle *CheckMouseOverVehicle(void);
 

	
water_cmd.c
Show inline comments
 
@@ -12,13 +12,13 @@
 
#include "sound.h"
 
#include "depot.h"
 
#include "vehicle_gui.h"
 

	
 
static void FloodVehicle(Vehicle *v);
 

	
 
static bool IsClearWaterTile(uint tile)
 
static bool IsClearWaterTile(TileIndex tile)
 
{
 
	TileInfo ti;
 
	FindLandscapeHeightByTile(&ti, tile);
 
	return (ti.type == MP_WATER && ti.tileh == 0 && ti.map5 == 0);
 
}
 

	
 
@@ -74,15 +74,15 @@ int32 CmdBuildShipDepot(int x, int y, ui
 
		);
 
	}
 

	
 
	return cost + _price.build_ship_depot;
 
}
 

	
 
static int32 RemoveShipDepot(uint tile, uint32 flags)
 
static int32 RemoveShipDepot(TileIndex tile, uint32 flags)
 
{
 
	uint tile2;
 
	TileIndex tile2;
 

	
 
	if (!CheckTileOwnership(tile))
 
		return CMD_ERROR;
 

	
 
	if (!EnsureNoVehicle(tile))
 
		return CMD_ERROR;
 
@@ -102,13 +102,13 @@ static int32 RemoveShipDepot(uint tile, 
 
	}
 

	
 
	return _price.remove_ship_depot;
 
}
 

	
 
// build a shiplift
 
static int32 DoBuildShiplift(uint tile, int dir, uint32 flags)
 
static int32 DoBuildShiplift(TileIndex tile, int dir, uint32 flags)
 
{
 
	int32 ret;
 
	int delta;
 

	
 
	// middle tile
 
	ret = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 
@@ -131,13 +131,13 @@ static int32 DoBuildShiplift(uint tile, 
 
		ModifyTile(tile + delta, MP_SETTYPE(MP_WATER) | MP_MAPOWNER | MP_MAP5 | MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR, OWNER_WATER, 0x18 + dir);
 
	}
 

	
 
	return _price.clear_water * 22 >> 3;
 
}
 

	
 
static int32 RemoveShiplift(uint tile, uint32 flags)
 
static int32 RemoveShiplift(TileIndex tile, uint32 flags)
 
{
 
	TileIndexDiff delta = TileOffsByDir(_map5[tile] & 3);
 

	
 
	// make sure no vehicle is on the tile.
 
	if (!EnsureNoVehicle(tile) || !EnsureNoVehicle(tile + delta) || !EnsureNoVehicle(tile - delta))
 
		return CMD_ERROR;
 
@@ -148,13 +148,13 @@ static int32 RemoveShiplift(uint tile, u
 
		DoClearSquare(tile - delta);
 
	}
 

	
 
	return _price.clear_water * 2;
 
}
 

	
 
static void MarkTilesAroundDirty(uint tile)
 
static void MarkTilesAroundDirty(TileIndex tile)
 
{
 
	MarkTileDirtyByTile(TILE_ADDXY(tile, 0, 1));
 
	MarkTileDirtyByTile(TILE_ADDXY(tile, 0, -1));
 
	MarkTileDirtyByTile(TILE_ADDXY(tile, 1, 0));
 
	MarkTileDirtyByTile(TILE_ADDXY(tile, -1, 0));
 
}
 
@@ -248,13 +248,14 @@ int32 CmdBuildCanal(int x, int y, uint32
 
			}
 
	} END_TILE_LOOP(tile, size_x, size_y, 0);
 

	
 
	return (cost == 0) ? CMD_ERROR : cost;
 
}
 

	
 
static int32 ClearTile_Water(uint tile, byte flags) {
 
static int32 ClearTile_Water(TileIndex tile, byte flags)
 
{
 
	byte m5 = _map5[tile];
 
	uint slope;
 

	
 
	if (m5 <= 1) { // water and shore
 
		// Allow building on water? It's ok to build on shores.
 
		if (flags & DC_NO_WATER && m5 != 1)
 
@@ -336,13 +337,13 @@ static bool IsWateredTile(TileIndex tile
 
		default:
 
			return false;
 
	}
 
}
 

	
 
// draw a canal styled water tile with dikes around
 
void DrawCanalWater(uint tile)
 
void DrawCanalWater(TileIndex tile)
 
{
 
	uint wa;
 

	
 
	// determine the edges around with water.
 
	wa = IsWateredTile(TILE_ADDXY(tile, -1, 0)) << 0;
 
	wa += IsWateredTile(TILE_ADDXY(tile, 0, 1)) << 1;
 
@@ -444,18 +445,18 @@ static uint GetSlopeZ_Water(TileInfo *ti
 

	
 
static uint GetSlopeTileh_Water(TileInfo *ti)
 
{
 
	return ti->tileh;
 
}
 

	
 
static void GetAcceptedCargo_Water(uint tile, AcceptedCargo ac)
 
static void GetAcceptedCargo_Water(TileIndex tile, AcceptedCargo ac)
 
{
 
	/* not used */
 
}
 

	
 
static void GetTileDesc_Water(uint tile, TileDesc *td)
 
static void GetTileDesc_Water(TileIndex tile, TileDesc *td)
 
{
 
	if (_map5[tile] == 0 && TilePixelHeight(tile) == 0)
 
		td->str = STR_3804_WATER;
 
	else if (_map5[tile] == 0)
 
		td->str = STR_LANDINFO_CANAL;
 
	else if (_map5[tile] == 1)
 
@@ -465,13 +466,13 @@ static void GetTileDesc_Water(uint tile,
 
	else
 
		td->str = STR_3806_SHIP_DEPOT;
 

	
 
	td->owner = GetTileOwner(tile);
 
}
 

	
 
static void AnimateTile_Water(uint tile)
 
static void AnimateTile_Water(TileIndex tile)
 
{
 
	/* not used */
 
}
 

	
 
static void TileLoopWaterHelper(TileIndex tile, const TileIndexDiffC *offs)
 
{
 
@@ -599,13 +600,13 @@ static void FloodVehicle(Vehicle *v)
 
	CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE); // show cool destruction effects
 
	SndPlayVehicleFx(SND_12_EXPLOSION, v); // create sound
 
	}
 
}
 

	
 
// called from tunnelbridge_cmd
 
void TileLoop_Water(uint tile)
 
void TileLoop_Water(TileIndex tile)
 
{
 
	int i;
 
	static const TileIndexDiffC _tile_loop_offs_array[][5] = {
 
		// tile to mod																shore?				shore?
 
		{{-1,  0}, {0, 0}, {0, 1}, {-1,  0}, {-1,  1}},
 
		{{ 0,  1}, {0, 1}, {1, 1}, { 0,  2}, { 1,  2}},
 
@@ -638,13 +639,13 @@ void TileLoop_Water(uint tile)
 
}
 

	
 

	
 
static const byte _coast_tracks[16] = {0, 32, 4, 0, 16, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0};
 
static const byte _shipdepot_tracks[4] = {1,1,2,2};
 
static const byte _shiplift_tracks[12] = {1,2,1,2,1,2,1,2,1,2,1,2};
 
static uint32 GetTileTrackStatus_Water(uint tile, TransportType mode)
 
static uint32 GetTileTrackStatus_Water(TileIndex tile, TransportType mode)
 
{
 
	uint m5;
 
	uint b;
 

	
 
	if (mode != TRANSPORT_WATER)
 
		return 0;
 
@@ -668,37 +669,37 @@ static uint32 GetTileTrackStatus_Water(u
 
		return 0;
 

	
 
	b = _shipdepot_tracks[m5 & 0x7F];
 
	return b + (b<<8);
 
}
 

	
 
extern void ShowShipDepotWindow(uint tile);
 
extern void ShowShipDepotWindow(TileIndex tile);
 

	
 
static void ClickTile_Water(uint tile)
 
static void ClickTile_Water(TileIndex tile)
 
{
 
	byte m5 = _map5[tile] - 0x80;
 

	
 
	if (IS_BYTE_INSIDE(m5, 0, 3+1)) {
 
		if (m5 & 1)
 
			tile += (m5==1) ? TILE_XY(-1,0) : TILE_XY(0,-1);
 
		ShowShipDepotWindow(tile);
 
	}
 
}
 

	
 
static void ChangeTileOwner_Water(uint tile, byte old_player, byte new_player)
 
static void ChangeTileOwner_Water(TileIndex tile, byte old_player, byte new_player)
 
{
 
	if (!IsTileOwner(tile, old_player)) return;
 

	
 
	if (new_player != 255) {
 
		SetTileOwner(tile, new_player);
 
	} else {
 
		DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
 
	}
 
}
 

	
 
static uint32 VehicleEnter_Water(Vehicle *v, uint tile, int x, int y)
 
static uint32 VehicleEnter_Water(Vehicle *v, TileIndex tile, int x, int y)
 
{
 
	return 0;
 
}
 

	
 
void InitializeDock(void)
 
{
waypoint.c
Show inline comments
 
@@ -126,13 +126,13 @@ void MakeDefaultWaypointName(Waypoint *w
 

	
 
	wp->string = STR_NULL;
 
	wp->town_cn = i;
 
}
 

	
 
/* Find a deleted waypoint close to a tile. */
 
static Waypoint *FindDeletedWaypointCloseTo(uint tile)
 
static Waypoint *FindDeletedWaypointCloseTo(TileIndex tile)
 
{
 
	Waypoint *wp, *best = NULL;
 
	uint thres = 8, cur_dist;
 

	
 
	FOR_ALL_WAYPOINTS(wp) {
 
		if (wp->deleted && wp->xy) {
 
@@ -240,13 +240,13 @@ void WaypointsDailyLoop(void)
 
			DoDeleteWaypoint(wp);
 
		}
 
	}
 
}
 

	
 
/* Remove a waypoint */
 
int32 RemoveTrainWaypoint(uint tile, uint32 flags, bool justremove)
 
int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove)
 
{
 
	Waypoint *wp;
 

	
 
	/* Make sure it's a waypoint */
 
	if (!IsTileType(tile, MP_RAILWAY) || !IsRailWaypoint(_map5[tile]))
 
		return CMD_ERROR;
 
@@ -332,13 +332,13 @@ int32 CmdRenameWaypoint(int x, int y, ui
 
		}
 
	}
 
	return 0;
 
}
 

	
 
/* This hacks together some dummy one-shot Station structure for a waypoint. */
 
Station *ComposeWaypointStation(uint tile)
 
Station *ComposeWaypointStation(TileIndex tile)
 
{
 
	Waypoint *wp = GetWaypointByTile(tile);
 
	static Station stat;
 

	
 
	stat.train_tile = stat.xy = wp->xy;
 
	stat.town = GetTown(wp->town_index);
waypoint.h
Show inline comments
 
@@ -50,14 +50,14 @@ static inline bool IsWaypointIndex(uint 
 

	
 
static inline bool IsRailWaypoint(byte m5)
 
{
 
	return (m5 & 0xFC) == 0xC4;
 
}
 

	
 
int32 RemoveTrainWaypoint(uint tile, uint32 flags, bool justremove);
 
Station *ComposeWaypointStation(uint tile);
 
int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove);
 
Station *ComposeWaypointStation(TileIndex tile);
 
Waypoint *GetWaypointByTile(TileIndex tile);
 
void ShowRenameWaypointWindow(Waypoint *cp);
 
void DrawWaypointSprite(int x, int y, int image, int railtype);
 
void UpdateWaypointSign(Waypoint *cp);
 
void FixOldWaypoints(void);
 
void UpdateAllWaypointSigns(void);
window.h
Show inline comments
 
@@ -81,14 +81,14 @@ union WindowEvent {
 
		int widget;
 
	} click;
 

	
 
	struct {
 
		byte event;
 
		Point pt;
 
		uint tile;
 
		uint starttile;
 
		TileIndex tile;
 
		TileIndex starttile;
 
		int userdata;
 
	} place;
 

	
 
	struct {
 
		byte event;
 
		Point pt;
0 comments (0 inline, 0 general)