Changeset - r10532:23a12232250b
[Not reviewed]
master
0 20 0
rubidium - 16 years ago 2009-01-02 22:42:05
rubidium@openttd.org
(svn r14789) -Feature: allow scrolling with the left mouse button pressed (if enabled). Primarily useful for systems with touch screen (aapo)
20 files changed with 59 insertions and 31 deletions:
0 comments (0 inline, 0 general)
src/clear_cmd.cpp
Show inline comments
 
@@ -301,27 +301,28 @@ void GenerateClearTile()
 
				SetClearGroundDensity(tile, CLEAR_ROCKS, 3);
 
				do {
 
					if (--j == 0) goto get_out;
 
					tile_new = tile + TileOffsByDiagDir((DiagDirection)GB(Random(), 0, 2));
 
				} while (!IsTileType(tile_new, MP_CLEAR) || IsClearGround(tile_new, CLEAR_DESERT));
 
				tile = tile_new;
 
			}
 
get_out:;
 
		}
 
	} while (--i);
 
}
 

	
 
static void ClickTile_Clear(TileIndex tile)
 
static bool ClickTile_Clear(TileIndex tile)
 
{
 
	/* not used */
 
	return false;
 
}
 

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

	
 
static const StringID _clear_land_str[] = {
 
	STR_080D_GRASS,
 
	STR_080B_ROUGH_LAND,
 
	STR_080A_ROCKS,
 
	STR_080E_FIELDS,
src/dummy_land.cpp
Show inline comments
 
@@ -45,27 +45,28 @@ static void GetTileDesc_Dummy(TileIndex 
 
}
 

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

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

	
 
static void ClickTile_Dummy(TileIndex tile)
 
static bool ClickTile_Dummy(TileIndex tile)
 
{
 
	/* not used */
 
	return false;
 
}
 

	
 
static void ChangeTileOwner_Dummy(TileIndex tile, Owner old_owner, Owner new_owner)
 
{
 
	/* not used */
 
}
 

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

	
src/industry_cmd.cpp
Show inline comments
 
@@ -828,27 +828,28 @@ static void TileLoop_Industry(TileIndex 
 
		break;
 

	
 
	case GFX_TOFFEE_QUARY:
 
		AddAnimatedTile(tile);
 
		break;
 

	
 
	case GFX_SUGAR_MINE_SIEVE:
 
		if (Chance16(1, 3)) AddAnimatedTile(tile);
 
		break;
 
	}
 
}
 

	
 
static void ClickTile_Industry(TileIndex tile)
 
static bool ClickTile_Industry(TileIndex tile)
 
{
 
	ShowIndustryViewWindow(GetIndustryIndex(tile));
 
	return true;
 
}
 

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

	
 
static void GetProducedCargo_Industry(TileIndex tile, CargoID *b)
 
{
 
	const Industry *i = GetIndustryByTile(tile);
 

	
 
	b[0] = i->produced_cargo[0];
src/landscape.cpp
Show inline comments
 
@@ -510,27 +510,27 @@ void ChangeTileOwner(TileIndex tile, Own
 

	
 
void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac)
 
{
 
	memset(ac, 0, sizeof(AcceptedCargo));
 
	_tile_type_procs[GetTileType(tile)]->get_accepted_cargo_proc(tile, ac);
 
}
 

	
 
void AnimateTile(TileIndex tile)
 
{
 
	_tile_type_procs[GetTileType(tile)]->animate_tile_proc(tile);
 
}
 

	
 
void ClickTile(TileIndex tile)
 
bool ClickTile(TileIndex tile)
 
{
 
	_tile_type_procs[GetTileType(tile)]->click_tile_proc(tile);
 
	return _tile_type_procs[GetTileType(tile)]->click_tile_proc(tile);
 
}
 

	
 
void GetTileDesc(TileIndex tile, TileDesc *td)
 
{
 
	_tile_type_procs[GetTileType(tile)]->get_tile_desc_proc(tile, td);
 
}
 

	
 
/**
 
 * Has a snow line table already been loaded.
 
 * @return true if the table has been loaded already.
 
 * @ingroup SnowLineGroup
 
 */
src/lang/english.txt
Show inline comments
 
@@ -1117,24 +1117,26 @@ STR_CONFIG_PATCHES_LIVERIES_ALL         
 
STR_CONFIG_PATCHES_PREFER_TEAMCHAT                              :{LTBLUE}Prefer team chat with <ENTER>: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLLING                        :{LTBLUE}Function of scrollwheel: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_SCROLLWHEEL_ZOOM                             :Zoom map
 
STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLL                           :Scroll map
 
STR_CONFIG_PATCHES_SCROLLWHEEL_OFF                              :Off
 
STR_CONFIG_PATCHES_SCROLLWHEEL_MULTIPLIER                       :{LTBLUE}Map scrollwheel speed: {ORANGE}{STRING1}
 

	
 
STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU                          :{LTBLUE}Right-click emulation: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_COMMAND                  :Command-click
 
STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_CONTROL                  :Control-click
 
STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_OFF                      :Off
 

	
 
STR_CONFIG_PATCHES_LEFT_MOUSE_BTN_SCROLLING                     :{LTBLUE}Left-click scrolling: {ORANGE}{STRING1}
 

	
 
STR_CONFIG_PATCHES_PAUSE_ON_NEW_GAME                            :{LTBLUE}Automatically pause when starting a new game: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS                       :{LTBLUE}Use the advanced vehicle list: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_OFF                   :Off
 
STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_OWN                   :Own company
 
STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_ALL                   :All companies
 
STR_CONFIG_PATCHES_LOADING_INDICATORS                           :{LTBLUE}Use loading indicators: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_LOADING_INDICATORS_OFF                       :Off
 
STR_CONFIG_PATCHES_LOADING_INDICATORS_OWN                       :Own company
 
STR_CONFIG_PATCHES_LOADING_INDICATORS_ALL                       :All companies
 
STR_CONFIG_PATCHES_TIMETABLE_ALLOW                              :{LTBLUE}Enable timetabling for vehicles: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_TIMETABLE_IN_TICKS                           :{LTBLUE}Show timetable in ticks rather than days: {ORANGE}{STRING1}
 
STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE                            :{LTBLUE}Default rail type (after new game/game load): {ORANGE}{STRING1}
src/rail_cmd.cpp
Show inline comments
 
@@ -2323,30 +2323,30 @@ static TrackStatus GetTileTrackStatus_Tr
 
			trackbits = DiagDirToDiagTrackBits(dir);
 
			break;
 
		}
 

	
 
		case RAIL_TILE_WAYPOINT:
 
			trackbits = GetRailWaypointBits(tile);
 
			break;
 
	}
 

	
 
	return CombineTrackStatus(TrackBitsToTrackdirBits(trackbits), red_signals);
 
}
 

	
 
static void ClickTile_Track(TileIndex tile)
 
static bool ClickTile_Track(TileIndex tile)
 
{
 
	switch (GetRailTileType(tile)) {
 
		case RAIL_TILE_DEPOT:    ShowDepotWindow(tile, VEH_TRAIN);            break;
 
		case RAIL_TILE_WAYPOINT: ShowWaypointWindow(GetWaypointByTile(tile)); break;
 
		default: break;
 
		case RAIL_TILE_DEPOT:    ShowDepotWindow(tile, VEH_TRAIN);            return true;
 
		case RAIL_TILE_WAYPOINT: ShowWaypointWindow(GetWaypointByTile(tile)); return true;
 
		default: return false;
 
	}
 
}
 

	
 
static void GetTileDesc_Track(TileIndex tile, TileDesc *td)
 
{
 
	td->owner[0] = GetTileOwner(tile);
 
	switch (GetRailTileType(tile)) {
 
		case RAIL_TILE_NORMAL:
 
			td->str = STR_1021_RAILROAD_TRACK;
 
			break;
 

	
 
		case RAIL_TILE_SIGNALS: {
src/road_cmd.cpp
Show inline comments
 
@@ -1421,27 +1421,30 @@ static void TileLoop_Road(TileIndex tile
 
			const RoadBits old_rb = GetAnyRoadBits(tile, ROADTYPE_ROAD);
 
			const RoadBits new_rb = CleanUpRoadBits(tile, old_rb);
 

	
 
			if (old_rb != new_rb) {
 
				RemoveRoad(tile, DC_EXEC | DC_AUTO | DC_NO_WATER, (old_rb ^ new_rb), ROADTYPE_ROAD, true);
 
			}
 
		}
 

	
 
		MarkTileDirtyByTile(tile);
 
	}
 
}
 

	
 
static void ClickTile_Road(TileIndex tile)
 
static bool ClickTile_Road(TileIndex tile)
 
{
 
	if (IsRoadDepot(tile)) ShowDepotWindow(tile, VEH_ROAD);
 
	if (!IsRoadDepot(tile)) return false;
 

	
 
	ShowDepotWindow(tile, VEH_ROAD);
 
	return true;
 
}
 

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

	
 
static TrackStatus GetTileTrackStatus_Road(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 
{
 
	TrackdirBits trackdirbits = TRACKDIR_BIT_NONE;
 
	TrackdirBits red_signals = TRACKDIR_BIT_NONE; // crossing barred
 
	switch (mode) {
src/settings.cpp
Show inline comments
 
@@ -1415,24 +1415,25 @@ const SettingDesc _patch_settings[] = {
 
 SDT_CONDOMANY(GameSettings, locale.currency,                               SLE_UINT8, 97, SL_MAX_VERSION, N, 0, 0, CUSTOM_CURRENCY_ID, "GBP|USD|EUR|YEN|ATS|BEF|CHF|CZK|DEM|DKK|ESP|FIM|FRF|GRD|HUF|ISK|ITL|NLG|NOK|PLN|ROL|RUR|SIT|SEK|YTL|SKK|BRR|custom", STR_NULL, NULL, NULL),
 
 SDT_CONDOMANY(GameSettings, locale.units,                                  SLE_UINT8, 97, SL_MAX_VERSION, N, 0, 1, 2, "imperial|metric|si", STR_NULL, NULL, NULL),
 

	
 
	/***************************************************************************/
 
	/* Unsaved patch variables. */
 
	SDTC_OMANY(gui.autosave,                  SLE_UINT8, S,  0, 1, 4, "off|monthly|quarterly|half year|yearly", STR_NULL,                     NULL),
 
	 SDTC_BOOL(gui.vehicle_speed,                        S,  0,  true,                        STR_CONFIG_PATCHES_VEHICLESPEED,                NULL),
 
	 SDTC_BOOL(gui.status_long_date,                     S,  0,  true,                        STR_CONFIG_PATCHES_LONGDATE,                    NULL),
 
	 SDTC_BOOL(gui.show_finances,                        S,  0,  true,                        STR_CONFIG_PATCHES_SHOWFINANCES,                NULL),
 
	 SDTC_BOOL(gui.autoscroll,                           S,  0, false,                        STR_CONFIG_PATCHES_AUTOSCROLL,                  NULL),
 
	 SDTC_BOOL(gui.reverse_scroll,                       S,  0, false,                        STR_CONFIG_PATCHES_REVERSE_SCROLLING,           NULL),
 
	 SDTC_BOOL(gui.smooth_scroll,                        S,  0, false,                        STR_CONFIG_PATCHES_SMOOTH_SCROLLING,            NULL),
 
	 SDTC_BOOL(gui.left_mouse_btn_scrolling,             S,  0, false,                        STR_CONFIG_PATCHES_LEFT_MOUSE_BTN_SCROLLING,    NULL),
 
	 SDTC_BOOL(gui.measure_tooltip,                      S,  0, false,                        STR_CONFIG_PATCHES_MEASURE_TOOLTIP,             NULL),
 
	  SDTC_VAR(gui.errmsg_duration,           SLE_UINT8, S,  0,     5,        0,       20, 0, STR_CONFIG_PATCHES_ERRMSG_DURATION,             NULL),
 
	  SDTC_VAR(gui.toolbar_pos,               SLE_UINT8, S, MS,     0,        0,        2, 0, STR_CONFIG_PATCHES_TOOLBAR_POS,                 v_PositionMainToolbar),
 
	  SDTC_VAR(gui.window_snap_radius,        SLE_UINT8, S, D0,    10,        1,       32, 0, STR_CONFIG_PATCHES_SNAP_RADIUS,                 NULL),
 
	 SDTC_BOOL(gui.population_in_label,                  S,  0,  true,                        STR_CONFIG_PATCHES_POPULATION_IN_LABEL,         PopulationInLabelActive),
 
	 SDTC_BOOL(gui.link_terraform_toolbar,               S,  0, false,                        STR_CONFIG_PATCHES_LINK_TERRAFORM_TOOLBAR,      NULL),
 
	  SDTC_VAR(gui.liveries,                  SLE_UINT8, S, MS,     2,        0,        2, 0, STR_CONFIG_PATCHES_LIVERIES,                    RedrawScreen),
 
	 SDTC_BOOL(gui.prefer_teamchat,                      S,  0, false,                        STR_CONFIG_PATCHES_PREFER_TEAMCHAT,             NULL),
 
	  SDTC_VAR(gui.scrollwheel_scrolling,     SLE_UINT8, S, MS,     0,        0,        2, 0, STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLLING,       NULL),
 
	  SDTC_VAR(gui.scrollwheel_multiplier,    SLE_UINT8, S,  0,     5,        1,       15, 1, STR_CONFIG_PATCHES_SCROLLWHEEL_MULTIPLIER,      NULL),
 
	 SDTC_BOOL(gui.pause_on_newgame,                     S,  0, false,                        STR_CONFIG_PATCHES_PAUSE_ON_NEW_GAME,           NULL),
 
	  SDTC_VAR(gui.advanced_vehicle_list,     SLE_UINT8, S, MS,     1,        0,        2, 0, STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS,      NULL),
src/settings_gui.cpp
Show inline comments
 
@@ -605,24 +605,25 @@ static const char *_patches_ui[] = {
 
	"gui.scrollwheel_multiplier",
 
#ifdef __APPLE__
 
	/* We might need to emulate a right mouse button on mac */
 
	"gui.right_mouse_btn_emulation",
 
#endif
 
	"gui.pause_on_newgame",
 
	"gui.advanced_vehicle_list",
 
	"gui.loading_indicators",
 
	"gui.timetable_in_ticks",
 
	"gui.default_rail_type",
 
	"gui.always_build_infrastructure",
 
	"gui.show_track_reservation",
 
	"gui.left_mouse_btn_scrolling",
 
};
 

	
 
static const char *_patches_construction[] = {
 
	"construction.build_on_slopes",
 
	"construction.autoslope",
 
	"construction.extra_dynamite",
 
	"construction.longbridges",
 
	"construction.signal_side",
 
	"station.always_small_airport",
 
	"gui.enable_signal_gui",
 
	"gui.drag_signals_density",
 
	"game_creation.oil_refinery_limit",
src/settings_type.h
Show inline comments
 
@@ -57,24 +57,25 @@ struct GUISettings {
 
	uint8  default_rail_type;                ///< the default rail type for the rail GUI
 
	uint8  toolbar_pos;                      ///< position of toolbars, 0=left, 1=center, 2=right
 
	uint8  window_snap_radius;               ///< windows snap at each other if closer than this
 
	bool   always_build_infrastructure;      ///< always allow building of infrastructure, even when you do not have the vehicles for it
 
	byte   autosave;                         ///< how often should we do autosaves?
 
	bool   keep_all_autosave;                ///< name the autosave in a different way
 
	bool   autosave_on_exit;                 ///< save an autosave when you quit the game, but do not ask "Do you really want to quit?"
 
	byte   max_num_autosaves;                ///< controls how many autosavegames are made before the game starts to overwrite (names them 0 to max_num_autosaves - 1)
 
	bool   population_in_label;              ///< show the population of a town in his label?
 
	uint8  right_mouse_btn_emulation;        ///< should we emulate right mouse clicking?
 
	uint8  scrollwheel_scrolling;            ///< scrolling using the scroll wheel?
 
	uint8  scrollwheel_multiplier;           ///< how much 'wheel' per incoming event from the OS?
 
	bool   left_mouse_btn_scrolling;         ///< left mouse button scroll
 
	bool   pause_on_newgame;                 ///< whether to start new games paused or not
 
	bool   enable_signal_gui;                ///< show the signal GUI when the signal button is pressed
 
	Year   colored_news_year;                ///< when does newspaper become colored?
 
	bool   timetable_in_ticks;               ///< whether to show the timetable in ticks rather than days
 
	bool   bridge_pillars;                   ///< show bridge pillars for high bridges
 
	bool   auto_euro;                        ///< automatically switch to euro in 2002
 
	byte   drag_signals_density;             ///< many signals density
 
	Year   semaphore_build_before;           ///< build semaphore signals automatically before this year
 
	bool   autorenew;                        ///< should autorenew be enabled for new companies?
 
	int16  autorenew_months;                 ///< how many months from EOL of vehicles should autorenew trigger for new companies?
 
	int32  autorenew_money;                  ///< how much money before autorenewing for new companies?
 
	byte   news_message_timeout;             ///< how much longer than the news message "age" should we keep the message in the history
src/station_cmd.cpp
Show inline comments
 
@@ -2560,31 +2560,32 @@ static void AnimateTile_Station(TileInde
 
	for (const AnimData *i = data; i != endof(data); i++) {
 
		if (i->from <= gfx && gfx <= i->to) {
 
			if ((_tick_counter & i->delay) == 0) {
 
				SetStationGfx(tile, gfx < i->to ? gfx + 1 : i->from);
 
				MarkTileDirtyByTile(tile);
 
			}
 
			break;
 
		}
 
	}
 
}
 

	
 

	
 
static void ClickTile_Station(TileIndex tile)
 
static bool ClickTile_Station(TileIndex tile)
 
{
 
	if (IsHangar(tile)) {
 
		ShowDepotWindow(tile, VEH_AIRCRAFT);
 
	} else {
 
		ShowStationViewWindow(GetStationIndex(tile));
 
	}
 
	return true;
 
}
 

	
 
static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y)
 
{
 
	StationID station_id = GetStationIndex(tile);
 

	
 
	if (v->type == VEH_TRAIN) {
 
		if (!v->current_order.ShouldStopAtStation(v, station_id)) return VETSB_CONTINUE;
 
		if (IsRailwayStation(tile) && IsFrontEngine(v) &&
 
				!IsCompatibleTrainStationTile(tile + TileOffsByDiagDir(DirToDiagDir(v->direction)), tile)) {
 
			DiagDirection dir = DirToDiagDir(v->direction);
 

	
src/tile_cmd.h
Show inline comments
 
@@ -94,25 +94,25 @@ typedef void GetTileDescProc(TileIndex t
 
 * @param mode     the mode of transportation
 
 * @param sub_mode used to differentiate between different kinds within the mode
 
 * @return the track status information
 
 */
 
typedef TrackStatus GetTileTrackStatusProc(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side);
 

	
 
/**
 
 * Tile callback function signature for obtaining the produced cargo of a tile.
 
 * @param tile Tile being queried
 
 * @param b    Destination array of produced cargo
 
 */
 
typedef void GetProducedCargoProc(TileIndex tile, CargoID *b);
 
typedef void ClickTileProc(TileIndex tile);
 
typedef bool ClickTileProc(TileIndex tile);
 
typedef void AnimateTileProc(TileIndex tile);
 
typedef void TileLoopProc(TileIndex tile);
 
typedef void ChangeTileOwnerProc(TileIndex tile, Owner old_owner, Owner new_owner);
 

	
 
/** @see VehicleEnterTileStatus to see what the return values mean */
 
typedef VehicleEnterTileStatus VehicleEnterTileProc(Vehicle *v, TileIndex tile, int x, int y);
 
typedef Foundation GetFoundationProc(TileIndex tile, Slope tileh);
 

	
 
/**
 
 * Tile callback function signature of the terraforming callback.
 
 *
 
 * The function is called when a tile is affected by a terraforming operation.
 
@@ -147,16 +147,16 @@ struct TileTypeProcs {
 
	VehicleEnterTileProc *vehicle_enter_tile_proc; ///< Called when a vehicle enters a tile
 
	GetFoundationProc *get_foundation_proc;
 
	TerraformTileProc *terraform_tile_proc;        ///< Called when a terraforming operation is about to take place
 
};
 

	
 
extern const TileTypeProcs * const _tile_type_procs[16];
 

	
 
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side = INVALID_DIAGDIR);
 
VehicleEnterTileStatus VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y);
 
void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac);
 
void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner);
 
void AnimateTile(TileIndex tile);
 
void ClickTile(TileIndex tile);
 
bool ClickTile(TileIndex tile);
 
void GetTileDesc(TileIndex tile, TileDesc *td);
 

	
 
#endif /* TILE_CMD_H */
src/town_cmd.cpp
Show inline comments
 
@@ -513,27 +513,28 @@ static void TileLoop_Town(TileIndex tile
 

	
 
		/* Rebuild with another house? */
 
		if (GB(r, 24, 8) >= 12) BuildTownHouse(t, tile);
 
	}
 

	
 
	_current_company = OWNER_NONE;
 
}
 

	
 
/**
 
 * Dummy tile callback function for handling tile clicks in towns
 
 * @param tile unused
 
 */
 
static void ClickTile_Town(TileIndex tile)
 
static bool ClickTile_Town(TileIndex tile)
 
{
 
	/* not used */
 
	return false;
 
}
 

	
 
static CommandCost ClearTile_Town(TileIndex tile, byte flags)
 
{
 
	if ((flags & DC_AUTO) && !(flags & DC_AI_BUILDING)) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED);
 
	if (!CanDeleteHouse(tile)) return CMD_ERROR;
 

	
 
	const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile));
 

	
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 
	cost.AddCost(hs->GetRemovalCost());
 

	
src/tree_cmd.cpp
Show inline comments
 
@@ -735,27 +735,28 @@ void OnTick_Trees()
 

	
 
	/* byte underflow */
 
	if (--_trees_tick_ctr != 0) return;
 

	
 
	/* place a tree at a random spot */
 
	r = Random();
 
	tile = TILE_MASK(r);
 
	if (CanPlantTreesOnTile(tile, false) && (tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TREE_INVALID) {
 
		PlantTreesOnTile(tile, tree, 0, 0);
 
	}
 
}
 

	
 
static void ClickTile_Trees(TileIndex tile)
 
static bool ClickTile_Trees(TileIndex tile)
 
{
 
	/* not used */
 
	return false;
 
}
 

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

	
 
static void ChangeTileOwner_Trees(TileIndex tile, Owner old_owner, Owner new_owner)
 
{
 
	/* not used */
 
}
 

	
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -1273,27 +1273,28 @@ static void TileLoop_TunnelBridge(TileIn
 
		case LT_TROPIC:
 
			if (GetTropicZone(tile) == TROPICZONE_DESERT && !snow_or_desert) {
 
				SetTunnelBridgeSnowOrDesert(tile, true);
 
				MarkTileDirtyByTile(tile);
 
			}
 
			break;
 

	
 
		default:
 
			break;
 
	}
 
}
 

	
 
static void ClickTile_TunnelBridge(TileIndex tile)
 
static bool ClickTile_TunnelBridge(TileIndex tile)
 
{
 
	/* not used */
 
	return false;
 
}
 

	
 

	
 
static TrackStatus GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 
{
 
	TransportType transport_type = GetTunnelBridgeTransportType(tile);
 
	if (transport_type != mode || (transport_type == TRANSPORT_ROAD && (GetRoadTypes(tile) & sub_mode) == 0)) return 0;
 

	
 
	DiagDirection dir = GetTunnelBridgeDirection(tile);
 
	if (side != INVALID_DIAGDIR && side != ReverseDiagDir(dir)) return 0;
 
	return CombineTrackStatus(TrackBitsToTrackdirBits(DiagDirToDiagTrackBits(dir)), TRACKDIR_BIT_NONE);
 
}
src/unmovable_cmd.cpp
Show inline comments
 
@@ -346,27 +346,30 @@ static void TileLoop_Unmovable(TileIndex
 
		uint amt = GB(r, 8, 8) / 8 / 4 + 1;
 
		if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
 
		MoveGoodsToStation(tile, 2, 2, CT_MAIL, amt);
 
	}
 
}
 

	
 

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

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

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

	
 

	
 
/* checks, if a radio tower is within a 9x9 tile square around tile */
 
static bool IsRadioTowerNearby(TileIndex tile)
 
{
 
	TileIndex tile_s = tile - TileDiffXY(4, 4);
 

	
 
	BEGIN_TILE_LOOP(tile, 9, 9, tile_s)
 
		if (IsTransmitterTile(tile)) return true;
 
	END_TILE_LOOP(tile, 9, 9, tile_s)
 

	
src/viewport.cpp
Show inline comments
 
@@ -1977,29 +1977,30 @@ static bool CheckClickOnWaypoint(const V
 
					return true;
 
				}
 
			}
 
			break;
 

	
 
		default: NOT_REACHED();
 
	}
 

	
 
	return false;
 
}
 

	
 

	
 
static void CheckClickOnLandscape(const ViewPort *vp, int x, int y)
 
static bool CheckClickOnLandscape(const ViewPort *vp, int x, int y)
 
{
 
	Point pt = TranslateXYToTileCoord(vp, x, y);
 

	
 
	if (pt.x != -1) ClickTile(TileVirtXY(pt.x, pt.y));
 
	if (pt.x != -1) return ClickTile(TileVirtXY(pt.x, pt.y));
 
	return true;
 
}
 

	
 

	
 
static void SafeShowTrainViewWindow(const Vehicle* v)
 
{
 
	if (!IsFrontEngine(v)) v = v->First();
 
	ShowVehicleViewWindow(v);
 
}
 

	
 
static void SafeShowRoadVehViewWindow(const Vehicle *v)
 
{
 
	if (!IsRoadVehFront(v)) v = v->First();
 
@@ -2009,39 +2010,41 @@ static void SafeShowRoadVehViewWindow(co
 
static void Nop(const Vehicle *v) {}
 

	
 
typedef void OnVehicleClickProc(const Vehicle *v);
 
static OnVehicleClickProc* const _on_vehicle_click_proc[] = {
 
	SafeShowTrainViewWindow,
 
	SafeShowRoadVehViewWindow,
 
	ShowVehicleViewWindow,
 
	ShowVehicleViewWindow,
 
	Nop, // Special vehicles
 
	Nop  // Disaster vehicles
 
};
 

	
 
void HandleViewportClicked(const ViewPort *vp, int x, int y)
 
bool HandleViewportClicked(const ViewPort *vp, int x, int y)
 
{
 
	const Vehicle *v;
 

	
 
	if (CheckClickOnTown(vp, x, y)) return;
 
	if (CheckClickOnStation(vp, x, y)) return;
 
	if (CheckClickOnSign(vp, x, y)) return;
 
	if (CheckClickOnWaypoint(vp, x, y)) return;
 
	if (CheckClickOnTown(vp, x, y)) return true;
 
	if (CheckClickOnStation(vp, x, y)) return true;
 
	if (CheckClickOnSign(vp, x, y)) return true;
 
	if (CheckClickOnWaypoint(vp, x, y)) return true;
 
	CheckClickOnLandscape(vp, x, y);
 

	
 
	v = CheckClickOnVehicle(vp, x, y);
 
	if (v != NULL) {
 
		DEBUG(misc, 2, "Vehicle %d (index %d) at %p", v->unitnumber, v->index, v);
 
		_on_vehicle_click_proc[v->type](v);
 
		return true;
 
	}
 
	return CheckClickOnLandscape(vp, x, y);
 
}
 

	
 
Vehicle *CheckMouseOverVehicle()
 
{
 
	const Window *w;
 
	const ViewPort *vp;
 

	
 
	int x = _cursor.pos.x;
 
	int y = _cursor.pos.y;
 

	
 
	w = FindWindowFromPt(x, y);
 
	if (w == NULL) return NULL;
src/viewport_func.h
Show inline comments
 
@@ -34,25 +34,25 @@ static inline void MaxZoomInOut(int how,
 
void OffsetGroundSprite(int x, int y);
 

	
 
void DrawGroundSprite(SpriteID image, SpriteID pal, const SubSprite *sub = NULL);
 
void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, byte z, const SubSprite *sub = NULL);
 
void AddSortableSpriteToDraw(SpriteID image, SpriteID pal, int x, int y, int w, int h, int dz, int z, bool transparent = false, int bb_offset_x = 0, int bb_offset_y = 0, int bb_offset_z = 0, const SubSprite *sub = NULL);
 
void AddStringToDraw(int x, int y, StringID string, uint64 params_1, uint64 params_2, uint16 color = 0, uint16 width = 0);
 
void AddChildSpriteScreen(SpriteID image, SpriteID pal, int x, int y, bool transparent = false, const SubSprite *sub = NULL);
 

	
 

	
 
void StartSpriteCombine();
 
void EndSpriteCombine();
 

	
 
void HandleViewportClicked(const ViewPort *vp, int x, int y);
 
bool HandleViewportClicked(const ViewPort *vp, int x, int y);
 
void PlaceObject();
 
void SetRedErrorSquare(TileIndex tile);
 
void SetTileSelectSize(int w, int h);
 
void SetTileSelectBigSize(int ox, int oy, int sx, int sy);
 

	
 
Vehicle *CheckMouseOverVehicle();
 

	
 
void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom);
 

	
 
bool ScrollWindowTo(int x, int y, Window *w, bool instant = false);
 

	
 
bool ScrollMainWindowToTile(TileIndex tile, bool instant = false);
src/water_cmd.cpp
Show inline comments
 
@@ -1195,31 +1195,33 @@ static TrackStatus GetTileTrackStatus_Wa
 
	}
 
	if (TileX(tile) == 0) {
 
		/* NE border: remove tracks that connects NE tile edge */
 
		ts &= ~(TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_RIGHT);
 
	}
 
	if (TileY(tile) == 0) {
 
		/* NW border: remove tracks that connects NW tile edge */
 
		ts &= ~(TRACK_BIT_Y | TRACK_BIT_LEFT | TRACK_BIT_UPPER);
 
	}
 
	return CombineTrackStatus(TrackBitsToTrackdirBits(ts), TRACKDIR_BIT_NONE);
 
}
 

	
 
static void ClickTile_Water(TileIndex tile)
 
static bool ClickTile_Water(TileIndex tile)
 
{
 
	if (GetWaterTileType(tile) == WATER_TILE_DEPOT) {
 
		TileIndex tile2 = GetOtherShipDepotTile(tile);
 

	
 
		ShowDepotWindow(tile < tile2 ? tile : tile2, VEH_SHIP);
 
		return true;
 
	}
 
	return false;
 
}
 

	
 
static void ChangeTileOwner_Water(TileIndex tile, Owner old_owner, Owner new_owner)
 
{
 
	if (!IsTileOwner(tile, old_owner)) return;
 

	
 
	if (new_owner != INVALID_OWNER) {
 
		SetTileOwner(tile, new_owner);
 
		return;
 
	}
 

	
 
	/* Remove depot */
src/window.cpp
Show inline comments
 
@@ -1572,39 +1572,39 @@ static bool HandleScrollbarScrolling()
 
	_scrolling_scrollbar = false;
 
	return false;
 
}
 

	
 
static bool HandleViewportScroll()
 
{
 
	bool scrollwheel_scrolling = _settings_client.gui.scrollwheel_scrolling == 1 && (_cursor.v_wheel != 0 || _cursor.h_wheel != 0);
 

	
 
	if (!_scrolling_viewport) return true;
 

	
 
	Window *w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y);
 

	
 
	if (!(_right_button_down || scrollwheel_scrolling) || w == NULL) {
 
	if (!(_right_button_down || scrollwheel_scrolling || (_settings_client.gui.left_mouse_btn_scrolling && _left_button_down)) || w == NULL) {
 
		_cursor.fix_at = false;
 
		_scrolling_viewport = false;
 
		return true;
 
	}
 

	
 
	if (w == FindWindowById(WC_MAIN_WINDOW, 0) && w->viewport->follow_vehicle != INVALID_VEHICLE) {
 
		/* If the main window is following a vehicle, then first let go of it! */
 
		const Vehicle *veh = GetVehicle(w->viewport->follow_vehicle);
 
		ScrollMainWindowTo(veh->x_pos, veh->y_pos, true); /* This also resets follow_vehicle */
 
		return true;
 
	}
 

	
 
	Point delta;
 
	if (_settings_client.gui.reverse_scroll) {
 
	if (_settings_client.gui.reverse_scroll || (_settings_client.gui.left_mouse_btn_scrolling && _left_button_down)) {
 
		delta.x = -_cursor.delta.x;
 
		delta.y = -_cursor.delta.y;
 
	} else {
 
		delta.x = _cursor.delta.x;
 
		delta.y = _cursor.delta.y;
 
	}
 

	
 
	if (scrollwheel_scrolling) {
 
		/* We are using scrollwheels for scrolling */
 
		delta.x = _cursor.h_wheel;
 
		delta.y = _cursor.v_wheel;
 
		_cursor.v_wheel = 0;
 
@@ -1906,25 +1906,30 @@ void MouseLoop(MouseClick click, int mou
 
			case MC_LEFT:
 
				DEBUG(misc, 2, "Cursor: 0x%X (%d)", _cursor.sprite, _cursor.sprite);
 
				if (_thd.place_mode != VHM_NONE &&
 
						/* query button and place sign button work in pause mode */
 
						_cursor.sprite != SPR_CURSOR_QUERY &&
 
						_cursor.sprite != SPR_CURSOR_SIGN &&
 
						_pause_game != 0 &&
 
						!_cheats.build_in_pause.value) {
 
					return;
 
				}
 

	
 
				if (_thd.place_mode == VHM_NONE) {
 
					HandleViewportClicked(vp, x, y);
 
					if (!HandleViewportClicked(vp, x, y) &&
 
							!(w->flags4 & WF_DISABLE_VP_SCROLL) &&
 
							_settings_client.gui.left_mouse_btn_scrolling) {
 
						_scrolling_viewport = true;
 
						_cursor.fix_at = false;
 
					}
 
				} else {
 
					PlaceObject();
 
				}
 
				break;
 

	
 
			case MC_RIGHT:
 
				if (!(w->flags4 & WF_DISABLE_VP_SCROLL)) {
 
					_scrolling_viewport = true;
 
					_cursor.fix_at = true;
 
				}
 
				break;
 

	
0 comments (0 inline, 0 general)