Index: src/settings.cpp
===================================================================
--- src/settings.cpp	(revision 13683)
+++ src/settings.cpp	(working copy)
@@ -63,8 +63,12 @@
 #include "gamelog.h"
 #include "station_func.h"
 
+#include "sharedinfrastructure.h"
+
 #include "table/strings.h"
 
+#include "core/smallvec_type.hpp"
+
 ClientSettings _settings_client;
 GameSettings _settings_game;
 GameSettings _settings_newgame;
@@ -1462,6 +1466,7 @@
 	if (strcmp(_settings_client.network.rcon_password, "*") == 0) {
 		_settings_client.network.rcon_password[0] = '\0';
 	}
+	InvalidateWindow(WC_GAME_OPTIONS, 0);
 
 	return 0;
 }
@@ -1657,6 +1662,7 @@
 	SDT_CONDBOOL(GameSettings, construction.road_stop_on_town_road,             47, SL_MAX_VERSION, 0, 0,  true,                    STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD,      NULL),
 	SDT_CONDBOOL(GameSettings, station.adjacent_stations,                       62, SL_MAX_VERSION, 0, 0,  true,                    STR_CONFIG_PATCHES_ADJACENT_STATIONS,      NULL),
 	SDT_CONDBOOL(GameSettings, economy.station_noise_level,                     96, SL_MAX_VERSION, 0, 0, false,                    STR_CONFIG_PATCHES_NOISE_LEVEL,            InvalidateTownViewWindow),
+	SDT_CONDBOOL(GameSettings, construction.one_tile_terraform,					 SL_VERSION_PATCH, SL_MAX_VERSION, 0, 0, false,					STR_CONFIG_PATCHES_ONE_TILE_TERRAFORM,	   NULL),
 
 	    SDT_BOOL(GameSettings, economy.inflation,                                                   0, 0,  true,                    STR_CONFIG_PATCHES_INFLATION,              NULL),
 	     SDT_VAR(GameSettings, construction.raw_industry_construction, SLE_UINT8,                   0,MS,     0,     0,       2, 0, STR_CONFIG_PATCHES_RAW_INDUSTRY_CONSTRUCTION_METHOD, InvalidateBuildIndustryWindow),
@@ -1744,10 +1750,33 @@
 	     SDT_VAR(GameSettings, game_creation.map_x,                           SLE_UINT8,                     S, 0,     8,                     6,      11, 0, STR_CONFIG_PATCHES_MAP_X,                 NULL),
 	     SDT_VAR(GameSettings, game_creation.map_y,                           SLE_UINT8,                     S, 0,     8,                     6,      11, 0, STR_CONFIG_PATCHES_MAP_Y,                 NULL),
 
+	SDT_CONDBOOL(GameSettings, construction.disable_tree_growth,			SL_VERSION_PATCH, SL_MAX_VERSION, 0, 0, false,					STR_CONFIG_PATCHES_TREE_GROWTH,            NULL),
+
+
  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),
 
+
 	/***************************************************************************/
+	/* Shared Infrastructure configure patches window */
+	SDT_CONDBOOL(GameSettings, sharing.shared_railway_stations,         SL_VERSION_PATCH,SL_MAX_VERSION,   0, D0, false,            STR_CONFIG_PATCHES_SHARED_RAILWAY_STATIONS, SettingsEnableSharedRailwayStations),
+	SDT_CONDBOOL(GameSettings, sharing.shared_railway_tracks,           SL_VERSION_PATCH,SL_MAX_VERSION,   0, D0, false,            STR_CONFIG_PATCHES_SHARED_RAILWAY_TRACKS, SettingsEnableSharedRailwayTracks),
+	SDT_CONDBOOL(GameSettings, sharing.shared_railway_depots,           SL_VERSION_PATCH,SL_MAX_VERSION,   0, D0, false,            STR_CONFIG_PATCHES_SHARED_RAILWAY_DEPOTS, SettingsEnableSharedRailwayStations),
+	SDT_CONDBOOL(GameSettings, sharing.shared_road_depots,              SL_VERSION_PATCH,SL_MAX_VERSION,   0, D0, false,            STR_CONFIG_PATCHES_SHARED_ROAD_DEPOTS, NULL),
+	SDT_CONDBOOL(GameSettings, sharing.shared_road_stops,               SL_VERSION_PATCH,SL_MAX_VERSION,   0, D0, false,            STR_CONFIG_PATCHES_SHARED_ROAD_STOPS, NULL),
+	SDT_CONDBOOL(GameSettings, sharing.shared_water_depots,             SL_VERSION_PATCH,SL_MAX_VERSION,   0, D0, false,            STR_CONFIG_PATCHES_SHARED_WATER_DEPOTS, NULL),
+	SDT_CONDBOOL(GameSettings, sharing.shared_harbours,                 SL_VERSION_PATCH,SL_MAX_VERSION,   0, D0, false,            STR_CONFIG_PATCHES_SHARED_HARBOURS, NULL),
+	SDT_CONDBOOL(GameSettings, sharing.shared_airports,                 SL_VERSION_PATCH,SL_MAX_VERSION,   0, D0, false,            STR_CONFIG_PATCHES_SHARED_AIRPORTS, NULL),
+	SDT_CONDVAR (GameSettings, sharing.shared_provision, SLE_UINT8,     SL_VERSION_PATCH,SL_MAX_VERSION,   0, 0,  10,  0,  100,  5, STR_CONFIG_PATCHES_SHARED_PROVISION, NULL),
+	SDT_CONDVAR (GameSettings, sharing.shared_tontile_cost, SLE_UINT16, SL_VERSION_PATCH,SL_MAX_VERSION,   0, CR, 30,  0,  250,  5, STR_CONFIG_PATCHES_SHARED_TONTILE_COST, NULL),
+	SDT_CONDVAR (GameSettings, sharing.shared_landing_fee, SLE_UINT16,  SL_VERSION_PATCH,SL_MAX_VERSION,   0, CR, 50,  0, 1000, 20, STR_CONFIG_PATCHES_SHARED_LANDING_FEE, NULL),
+	SDT_CONDVAR (GameSettings, sharing.shared_road_stops_fee, SLE_UINT8,SL_VERSION_PATCH,SL_MAX_VERSION,  0, CR,  5,  0,   50,  1, STR_CONFIG_PATCHES_SHARED_ROAD_STOPS_FEE, NULL),
+	SDT_CONDVAR (GameSettings, sharing.shared_harbours_fee,  SLE_UINT8, SL_VERSION_PATCH,SL_MAX_VERSION,   0, CR, 10,  0,  200,  5, STR_CONFIG_PATCHES_SHARED_HARBOURS_FEE, NULL),
+	SDT_CONDBOOL(GameSettings, sharing.shared_player_level,             SL_VERSION_PATCH,SL_MAX_VERSION,   0, D0, false,            STR_CONFIG_PATCHES_SHARED_PLAYER_LEVEL, NULL),
+	SDT_CONDVAR (GameSettings, sharing.shared_delay, SLE_UINT8,         SL_VERSION_PATCH,SL_MAX_VERSION,   0, 0,  6,   0,   60,  1, STR_CONFIG_PATCHES_SHARED_DELAY, 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),
@@ -1769,6 +1798,7 @@
 	 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),
 	 SDTC_BOOL(gui.timetable_in_ticks,                   S,  0, false,                        STR_CONFIG_PATCHES_TIMETABLE_IN_TICKS,          NULL),
+	 SDTC_BOOL(gui.quick_goto,                           S,  0,  true,                        STR_CONFIG_PATCHES_QUICKGOTO,                   NULL),
 	  SDTC_VAR(gui.loading_indicators,        SLE_UINT8, S, MS,     1,        0,        2, 0, STR_CONFIG_PATCHES_LOADING_INDICATORS,          RedrawScreen),
 	  SDTC_VAR(gui.default_rail_type,         SLE_UINT8, S, MS,     4,        0,        6, 0, STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE,           NULL),
 	 SDTC_BOOL(gui.enable_signal_gui,                    S,  0, false,                        STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI,           CloseSignalGUI),
@@ -1819,6 +1849,9 @@
 	  SDTC_VAR(network.last_port,            SLE_UINT16, S,  0,     0,     0,  UINT16_MAX, 0, STR_NULL,                                       NULL),
 #endif /* ENABLE_NETWORK */
 
+	// allowed terraform bitmask, serverside, nosave
+	 SDT_VAR(GameSettings, construction.allow_terraform, SLE_UINT16, S, 0, 65535,     0,    65535, 0, STR_NULL,                                       NULL),
+
 	/*
 	 * Since the network code (CmdChangePatchSetting and friends) use the index in this array to decide
 	 * which patch the server is talking about all conditional compilation of this array must be at the
@@ -1830,7 +1863,6 @@
 	/* We might need to emulate a right mouse button on mac */
 	 SDTC_VAR(gui.right_mouse_btn_emulation, SLE_UINT8, S, MS, 0, 0, 2, 0, STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU, NULL),
 #endif
-
 	SDT_END()
 };
 
@@ -2101,6 +2133,54 @@
 	ini_free(ini);
 }
 
+typedef SmallVector<char *, 8> PresetList;
+PresetList _grf_preset_list;
+
+void GetGRFPresetList()
+{
+	/* Clear out the list of old entries */
+	for (uint i = 0; i < _grf_preset_list.Length(); i++) {
+		free(_grf_preset_list[i]);
+	}
+
+	_grf_preset_list.Clear();
+
+	IniFile *ini = ini_load(_config_file);
+	IniGroup *group;
+	for (group = ini->group; group != NULL; group = group->next) {
+		if (strncmp(group->name, "preset-", 7) == 0) {
+			*_grf_preset_list.Append() = strdup(group->name + 7);
+		}
+	}
+
+	_grf_preset_list.Compact();
+
+	ini_free(ini);
+}
+
+GRFConfig *LoadGRFPresetFromConfig(const char *config_name)
+{
+	char section[MAX_PATH];
+	snprintf(section, lengthof(section), "preset-%s", config_name);
+
+	IniFile *ini = ini_load(_config_file);
+	GRFConfig *config = GRFLoadConfig(ini, section, false);
+	ini_free(ini);
+
+	return config;
+}
+
+void SaveGRFPresetToConfig(const char *config_name, GRFConfig *config)
+{
+	char section[MAX_PATH];
+	snprintf(section, lengthof(section), "preset-%s", config_name);
+
+	IniFile *ini = ini_load(_config_file);
+	GRFSaveConfig(ini, section, config);
+	ini_save(_config_file, ini);
+	ini_free(ini);
+}
+
 static const SettingDesc *GetSettingDescription(uint index)
 {
 	if (index >= lengthof(_patch_settings)) return NULL;
@@ -2181,6 +2261,11 @@
 	if (!_networking || (_networking && _network_server)) {
 		return DoCommandP(0, index, value, NULL, CMD_CHANGE_PATCH_SETTING);
 	}
+	if (_networking && !_network_server && _settings_client.network.rcon_password[0] != '\0') {
+		char patch_rcon_command[70];
+		sprintf(patch_rcon_command, "patch %s %d", _patch_settings[index].desc.name, value);
+		NetworkClientSendRcon(_settings_client.network.rcon_password, patch_rcon_command);
+	}
 	return false;
 }
 
Index: src/bridge_gui.cpp
===================================================================
--- src/bridge_gui.cpp	(revision 13683)
+++ src/bridge_gui.cpp	(working copy)
@@ -287,6 +287,16 @@
 	 *      7..0 = type of bridge */
 	uint32 type = (transport_type << 15) | (bridge_type << 8);
 
+	/* When Ctrl is beeing pressed, just build the fastest available bridge and return */
+	if (_ctrl_pressed) {
+		BridgeType fastest_type = GetFastestAvailableBridgeType(GetTunnelBridgeLength(end, start));
+		if (fastest_type < MAX_BRIDGES)
+			DoCommandP(end, start,
+				type | fastest_type, CcBuildBridge,
+				CMD_BUILD_BRIDGE | CMD_MSG(STR_5015_CAN_T_BUILD_BRIDGE_HERE));
+		return;
+	}
+
 	/* only query bridge building possibility once, result is the same for all bridges!
 	 * returns CMD_ERROR on failure, and price on success */
 	StringID errmsg = INVALID_STRING_ID;
Index: src/toolbar_gui.cpp
===================================================================
--- src/toolbar_gui.cpp	(revision 13683)
+++ src/toolbar_gui.cpp	(working copy)
@@ -41,6 +41,7 @@
 
 #include "network/network.h"
 #include "network/network_gui.h"
+#include "network/network_func.h"
 
 #include "table/strings.h"
 #include "table/sprites.h"
@@ -184,8 +185,13 @@
 
 static void ToolbarPauseClick(Window *w)
 {
-	if (_networking && !_network_server) return; // only server can pause the game
-
+	if (!(_networking && (_network_server || _settings_client.network.rcon_password[0] != '\0'))) return; // you can only pause the game if you have the rcon password or are the server
+	if (_networking && !_network_server && _settings_client.network.rcon_password[0] != '\0') {
+		NetworkClientSendRcon(_settings_client.network.rcon_password, (_pause_game ? "unpause" : "pause"));
+		SndPlayFx(SND_15_BEEP);
+	}
+	
+	if (_networking && !_network_server) return; // only server can pause the game using this command
 	if (DoCommandP(0, _pause_game ? 0 : 1, 0, NULL, CMD_PAUSE)) SndPlayFx(SND_15_BEEP);
 }
 
@@ -884,7 +890,6 @@
 struct MainToolbarWindow : Window {
 	MainToolbarWindow(const WindowDesc *desc) : Window(desc)
 	{
-		this->SetWidgetDisabledState(TBN_PAUSE, _networking && !_network_server); // if not server, disable pause button
 		this->SetWidgetDisabledState(TBN_FASTFORWARD, _networking); // if networking, disable fast-forward button
 
 		CLRBITS(this->flags4, WF_WHITE_BORDER_MASK);
@@ -900,6 +905,7 @@
 		GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB2);
 		GfxFillRect(0, 0, this->width - 1, this->height - 1, 0xB4, FILLRECT_CHECKER);
 
+		this->SetWidgetDisabledState(TBN_PAUSE, !(_networking && (_network_server || _settings_client.network.rcon_password[0] != '\0'))); // if not server, disable pause button
 		/* If spectator, disable all construction buttons
 		* ie : Build road, rail, ships, airports and landscaping
 		* Since enabled state is the default, just disable when needed */
Index: src/depot_base.h
===================================================================
--- src/depot_base.h	(revision 13683)
+++ src/depot_base.h	(working copy)
@@ -27,6 +27,8 @@
 	return index < GetDepotPoolSize() && GetDepot(index)->IsValid();
 }
 
+static const DepotID INVALID_DEPOT = 0xFFFF;
+
 Depot *GetDepotByTile(TileIndex tile);
 
 #define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1U < GetDepotPoolSize()) ? GetDepot(d->index + 1U) : NULL) if (d->IsValid())
Index: src/tile_cmd.h
===================================================================
--- src/tile_cmd.h	(revision 13683)
+++ src/tile_cmd.h	(working copy)
@@ -52,6 +52,8 @@
 	Owner owner[4];
 	StringID owner_type[4];
 	Date build_date;
+	StringID grfclass;
+	StringID grfname;
 	uint64 dparam[2];
 };
 
Index: src/lang/german.txt
===================================================================
--- src/lang/german.txt	(revision 13683)
+++ src/lang/german.txt	(working copy)
@@ -1121,6 +1121,7 @@
 STR_CONFIG_PATCHES_LOADING_INDICATORS_ALL                       :Alle Firmen
 STR_CONFIG_PATCHES_TIMETABLE_ALLOW                              :{LTBLUE}Fahrpläne für Fahrzeuge aktivieren: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_TIMETABLE_IN_TICKS                           :{LTBLUE}Zeitpläne in Ticks anstatt in Tagen anzeigen: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_QUICKGOTO                                    :{LTBLUE}Schnelles erstellen von Fahrzeugaufträgen: {ORANGE}{STRING1}
 STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE                            :{LTBLUE}Standard-Gleistyp (bei Spielbeginn/geladenem Spiel): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_RAIL                       :normales Gleis
 STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_ELRAIL                     :elektrifiziertes Gleis
@@ -1651,6 +1652,8 @@
 STR_RAILROAD_TRACK_WITH_PRE_COMBOSIGNALS                        :Gleise mit Vor-  und Kombinationssignalen
 STR_RAILROAD_TRACK_WITH_EXIT_COMBOSIGNALS                       :Gleise mit Ausfahr- und Kombinationssignalen
 STR_MUST_REMOVE_RAILWAY_STATION_FIRST                           :{WHITE}Bahnhof muss erst abgerissen werden
+STR_CREATE_SPLITTED_STATION                                     :{YELLOW}Baue eine separate Station
+STR_SELECT_STATION_TO_JOIN                                      :{BLACK}Stationen verbinden
 
 
 
Index: src/lang/english.txt
===================================================================
--- src/lang/english.txt	(revision 13683)
+++ src/lang/english.txt	(working copy)
@@ -1126,6 +1126,7 @@
 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_QUICKGOTO                                    :{LTBLUE}Quick creation of vehicle orders: {ORANGE}{STRING1}
 STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE                            :{LTBLUE}Default rail type (after new game/game load): {ORANGE}{STRING1}
 STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_RAIL                       :Normal Rail
 STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_ELRAIL                     :Electrified Rail
@@ -1179,6 +1180,10 @@
 STR_CONFIG_PATCHES_TOWN_LAYOUT_3X3_GRID                         :3x3 grid
 STR_CONFIG_PATCHES_TOWN_LAYOUT_RANDOM                           :random
 
+STR_CONFIG_PATCHES_TREE_GROWTH                                  :{LTBLUE}Disable Tree Growth: {ORANGE}{STRING1}
+
+STR_CONFIG_PATCHES_ONE_TILE_TERRAFORM							:{LTBLUE}Enable One-tile terraform: {ORANGE}{STRING1}
+
 STR_CONFIG_PATCHES_TOOLBAR_POS                                  :{LTBLUE}Position of main toolbar: {ORANGE}{STRING1}
 STR_CONFIG_PATCHES_TOOLBAR_POS_LEFT                             :Left
 STR_CONFIG_PATCHES_TOOLBAR_POS_CENTER                           :Centre
@@ -1583,6 +1588,8 @@
 STR_NETWORK_CLIENTLIST_SPEAK_TO_ALL                             :Speak to all
 STR_NETWORK_CLIENTLIST_SPEAK_TO_COMPANY                         :Speak to company
 STR_NETWORK_CLIENTLIST_SPEAK_TO_CLIENT                          :Private message
+STR_NETWORK_CLIENTLIST_MOVE                                     :Move
+STR_NETWORK_CLIENTLIST_MUTE                                     :Mute
 
 
 STR_NETWORK_SEND                                                :{BLACK}Send
@@ -1672,6 +1679,8 @@
 STR_RAILROAD_TRACK_WITH_PRE_COMBOSIGNALS                        :Railway track with pre- and combo-signals
 STR_RAILROAD_TRACK_WITH_EXIT_COMBOSIGNALS                       :Railway track with exit- and combo-signals
 STR_MUST_REMOVE_RAILWAY_STATION_FIRST                           :{WHITE}Must remove railway station first
+STR_CREATE_SPLITTED_STATION                                     :{YELLOW}Build a separate Station
+STR_SELECT_STATION_TO_JOIN                                      :{BLACK}Join Station
 
 
 
@@ -2247,10 +2256,12 @@
 STR_7015_AIRCRAFT_RUNNING_COSTS                                 :{GOLD}Aircraft Running Costs
 STR_7016_SHIP_RUNNING_COSTS                                     :{GOLD}Ship Running Costs
 STR_7017_PROPERTY_MAINTENANCE                                   :{GOLD}Property Maintenance
+STR_7017_SHARED_INF_COSTS                                       :{GOLD}Shared Structure Costs
 STR_7018_TRAIN_INCOME                                           :{GOLD}Train Income
 STR_7019_ROAD_VEHICLES_INCOME                                   :{GOLD}Road Vehicle Income
 STR_701A_AIRCRAFT_INCOME                                        :{GOLD}Aircraft Income
 STR_701B_SHIP_INCOME                                            :{GOLD}Ship Income
+STR_701B_SHARED_INF_INCOME                                      :{GOLD}Shared Structure Income
 STR_701C_LOAN_INTEREST                                          :{GOLD}Loan Interest
 STR_701D_OTHER                                                  :{GOLD}Other
 STR_701E                                                        :{BLACK}-{CURRENCY}
@@ -2336,8 +2347,12 @@
 STR_7070_BUILD_COMPANY_HEADQUARTERS                             :{BLACK}Build company headquarters / view company headquarters
 STR_RELOCATE_COMPANY_HEADQUARTERS                               :{BLACK}Rebuild company headquarters elsewhere for 1% cost of company value
 STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS                       :{WHITE}Can't build company headquarters...
+STR_PLAYER_CENTER_VIEWPORT                                      :{BLACK}Center viewport to place where player built last time
+STR_PLAYER_OPEN_VIEWPORT                                        :{BLACK}Open new viewport to watch player's actions
 STR_7072_VIEW_HQ                                                :{BLACK}View HQ
 STR_RELOCATE_HQ                                                 :{BLACK}Relocate HQ
+STR_PLAYER_CENTER                                               :{BLACK}Center view
+STR_PLAYER_OPEN                                                 :{BLACK}Open window
 STR_COMPANY_PASSWORD                                            :{BLACK}Password
 STR_COMPANY_PASSWORD_TOOLTIP                                    :{BLACK}Password-protect your company to prevent unauthorised users from joining.
 STR_SET_COMPANY_PASSWORD                                        :{BLACK}Set company password
@@ -2359,7 +2374,10 @@
 STR_707D_OWNED_BY                                               :{WHITE}({COMMA}% owned by {COMPANY})
 STR_707F_HAS_BEEN_TAKEN_OVER_BY                                 :{BLACK}{BIGFONT}{COMPANY} has been taken over by {COMPANY}!
 STR_PROTECTED                                                   :{WHITE}This company is not old enough to trade shares yet...
+STR_COMPANY_SHARING                                             :{BLACK}Sharing
+STR_SET_COMPANY_SHARING                                         :{BLACK}Settings for shared infrastructures.
 
+
 STR_LIVERY_DEFAULT                                              :Standard Livery
 STR_LIVERY_STEAM                                                :Steam Engine
 STR_LIVERY_DIESEL                                               :Diesel Engine
@@ -3113,6 +3131,9 @@
 STR_BRIBE_FAILED_2                                              :{WHITE}discovered by a regional investigator
 STR_BUILD_DATE                                                  :{BLACK}Built: {LTBLUE}{DATE_LONG}
 
+STR_TILEDESC_STATION_CLASS                                      :{BLACK}Station class: {LTBLUE}{STRING}
+STR_TILEDESC_STATION_TYPE                                       :{BLACK}Station type: {LTBLUE}{STRING}
+
 STR_PERFORMANCE_DETAIL                                          :{WHITE}Detailed performance rating
 STR_PERFORMANCE_DETAIL_KEY                                      :{BLACK}Detail
 STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY                          :{BLACK}({CURRCOMPACT}/{CURRCOMPACT})
@@ -3168,6 +3189,10 @@
 STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED                        :Too many NewGRFs are loaded.
 STR_NEWGRF_ERROR_STATIC_GRF_CAUSES_DESYNC                       :Loading {STRING} as static NewGRF with {STRING} could cause desyncs.
 
+STR_NEWGRF_PRESET_LIST_TIP                                      :{BLACK}Load the selected preset
+STR_NEWGRF_PRESET_SAVE                                          :{BLACK}Save preset
+STR_NEWGRF_PRESET_SAVE_TIP                                      :{BLACK}Save the current list as a preset
+STR_NEWGRF_PRESET_SAVE_QUERY                                    :{BLACK}Enter name for preset
 STR_NEWGRF_ADD                                                  :{BLACK}Add
 STR_NEWGRF_ADD_TIP                                              :{BLACK}Add a NewGRF file to the list
 STR_NEWGRF_REMOVE                                               :{BLACK}Remove
@@ -3226,6 +3251,10 @@
 STR_SCHEDULED_AIRCRAFT_TIP                                      :{BLACK}Show all aircraft which have this station on their schedule
 STR_SCHEDULED_SHIPS_TIP                                         :{BLACK}Show all ships which have this station on their schedule
 
+STR_CLOSE_AIRPORT                                               :{BLACK}Close airport
+STR_CLOSE_AIRPORT_TIP                                           :{BLACK}Prevent aircraft from landing on this airport
+STR_CLOSE_AIRPORT_ERROR                                         :{WHITE}Cannot open/close airport...
+
 STR_VEH_WITH_SHARED_ORDERS_LIST                                 :{WHITE}Shared orders of {COMMA} Vehicle{P "" s}
 STR_VEH_WITH_SHARED_ORDERS_LIST_TIP                             :{BLACK}Show all vehicles that share this schedule
 
@@ -3570,3 +3599,77 @@
 STR_NOISE_IN_TOWN                                               :{BLACK}Noise limit in town: {ORANGE}{COMMA}{BLACK}  max: {ORANGE}{COMMA}
 STR_STATION_NOISE                                               :{BLACK}Noise generated: {GOLD}{COMMA}
 ########
+ 
+############ move player gui
+STR_MOVE_PLAYER_CAPTION                                         :{WHITE}Move client to...
+STR_MOVE_PLAYER_SPECTATORS                                      :{WHITE}Spectators
+STR_MOVE_PLAYER_TOOLTIP                                         :{BLACK}Click here to move the client to this company
+########
+
+############ mute player gui
+STR_MUTE_PLAYER_CAPTION                                         :{WHITE}Mute client
+STR_MUTE_PLAYER_ALL                                             :{WHITE}All
+STR_MUTE_PLAYER_TEAM                                            :{WHITE}Team
+STR_MUTE_PLAYER_PRIVATE                                         :{WHITE}Private
+STR_MUTE_PLAYER_TOOLTIP                                         :{BLACK}Click here to mute the client for this chattype
+########
+
+############ Sharing
+STR_CONFIG_PATCHES_SHARED_RAILWAY_STATIONS                      :{LTBLUE}Enable shared railway stations: {ORANGE}{STRING1}
+STR_CONFIG_PATCHES_SHARED_RAILWAY_TRACKS                        :{LTBLUE}Enable shared railway tracks: {ORANGE}{STRING1}
+STR_CONFIG_PATCHES_SHARED_RAILWAY_DEPOTS                        :{LTBLUE}Enable shared railway depots: {ORANGE}{STRING1}
+STR_CONFIG_PATCHES_SHARED_ROAD_DEPOTS                           :{LTBLUE}Enable shared road depots: {ORANGE}{STRING1}
+STR_CONFIG_PATCHES_SHARED_ROAD_STOPS                            :{LTBLUE}Enable shared road stops: {ORANGE}{STRING1}
+STR_CONFIG_PATCHES_SHARED_WATER_DEPOTS                          :{LTBLUE}Enable shared water depots: {ORANGE}{STRING1}
+STR_CONFIG_PATCHES_SHARED_HARBOURS                              :{LTBLUE}Enable shared harbours: {ORANGE}{STRING1}
+STR_CONFIG_PATCHES_SHARED_AIRPORTS                              :{LTBLUE}Enable shared airports: {ORANGE}{STRING1}
+STR_CONFIG_PATCHES_SHARED_PROVISION                             :{LTBLUE}Enable depot owner provision: {ORANGE}{STRING1}%
+STR_CONFIG_PATCHES_SHARED_TONTILE_COST                          :{LTBLUE}Cost of 1000 tontiles on shared track: {ORANGE}{STRING1}
+STR_CONFIG_PATCHES_SHARED_LANDING_FEE                           :{LTBLUE}Landing fee per tons of cargo capacity : {ORANGE}{STRING1}
+STR_CONFIG_PATCHES_SHARED_ROAD_STOPS_FEE                        :{LTBLUE}Road stops fee per tons of cargo capacity : {ORANGE}{STRING1}
+STR_CONFIG_PATCHES_SHARED_HARBOURS_FEE                          :{LTBLUE}Harbours fee per tons of cargo capacity : {ORANGE}{STRING1}
+STR_CONFIG_PATCHES_SHARED_PLAYER_LEVEL                          :{LTBLUE}Enable individual sharing settings: {ORANGE}{STRING1}
+STR_CONFIG_PATCHES_SHARED                                       :{BLACK}Sharing
+STR_CONFIG_PATCHES_SHARED_DELAY                                 :{LTBLUE}Delay for individual settings:{ORANGE}{STRING1} month(s)
+
+STR_SHARED_INFRASTRUCTURE_SELECTION                             :{WHITE}Shared Infrastructure
+
+STR_SHARED_RAILWAY_STATIONS                                     :{BLACK}Share railway stations
+STR_SHARED_RAILWAY_TRACKS                                       :{BLACK}Share railway tracks
+STR_SHARED_RAILWAY_DEPOTS                                       :{BLACK}Share railway depots
+STR_SHARED_ROAD_DEPOTS                                          :{BLACK}Share road depots
+STR_SHARED_ROAD_STOPS                                           :{BLACK}Share road stops
+STR_SHARED_WATER_DEPOTS                                         :{BLACK}Share water depots
+STR_SHARED_HARBOURS                                             :{BLACK}Share harbours
+STR_SHARED_AIRPORTS                                             :{BLACK}Share airports
+STR_SHARED_DEPOT_PROVISION                                      :{BLACK}Depot provision (building cost %)
+STR_SHARED_TONTILE_COST                                         :{BLACK}Cost of 1000 tontiles on shared track
+STR_SHARED_LANDING_FEE                                          :{BLACK}Landing fee per tons of cargo capacity
+STR_SHARED_ROAD_STOPS_FEE                                       :{BLACK}Road stops fee per tons of cargo capacity
+STR_SHARED_HARBOURS_FEE                                         :{BLACK}Harbours fee per tons of cargo capacity
+STR_SHARED_ACCEPT                                               :{BLACK}Accept new settings (will reset previous counter if any)
+
+STR_SHARED_CHANGE_INT_VALUE                                     :{BLACK}{BIGFONT}{PLAYERNAME} has set new access prices ! check {COMPANY} for details.
+STR_SHARED_CHANGE_BOOL_VALUE                                    :{BLACK}{BIGFONT}{PLAYERNAME} has set new access conditions ! check {COMPANY} for details.
+
+STR_CONFIG_PLAYER_SHARED_RAILWAY_STATIONS                       :{GOLD}Railway stations:
+STR_CONFIG_PLAYER_SHARED_RAILWAY_TRACKS                         :{GOLD}Railway tracks:
+STR_CONFIG_PLAYER_SHARED_RAILWAY_DEPOTS                         :{GOLD}Railway depots:
+STR_CONFIG_PLAYER_SHARED_ROAD_DEPOTS                            :{GOLD}Road depots:
+STR_CONFIG_PLAYER_SHARED_ROAD_STOPS                             :{GOLD}Road stops:
+STR_CONFIG_PLAYER_SHARED_WATER_DEPOTS                           :{GOLD}Water depots:
+STR_CONFIG_PLAYER_SHARED_HARBOURS                               :{GOLD}Harbours:
+STR_CONFIG_PLAYER_SHARED_AIRPORTS                               :{GOLD}Airports:
+STR_CONFIG_PLAYER_SHARED_DEPOT_PROVISION                        :{GOLD}Depot provision: 
+STR_CONFIG_PLAYER_SHARED_TONTILE_COST                           :{GOLD}Tracks renting:
+STR_CONFIG_PLAYER_SHARED_LANDING_FEE                            :{GOLD}Landing fee:
+STR_CONFIG_PLAYER_SHARED_ROAD_STOPS_FEE                         :{GOLD}Road stops fee:
+STR_CONFIG_PLAYER_SHARED_HARBOURS_FEE                           :{GOLD}Harbours fee:
+STR_CONFIG_PLAYER_SHARED_NO_CHANGE                              :{GOLD}No change recorded for next {WHITE}{NUM}{GOLD} month(s)
+STR_CONFIG_PLAYER_SHARED_CHANGE_MONTHS                          :{GOLD}Change recorded and planned in {WHITE}{NUM}{GOLD} month(s)
+
+STR_JUST_VELOCITY												:{VELOCITY}
+STR_JUST_CURRENCY												:{CURRENCY}
+STR_JUST_PERCENT                                                :{NUM}%
+########
+
Index: src/lang/english_US.txt
===================================================================
--- src/lang/english_US.txt	(revision 13683)
+++ src/lang/english_US.txt	(working copy)
@@ -1116,6 +1116,7 @@
 STR_CONFIG_PATCHES_LOADING_INDICATORS_ALL                       :All companies
 STR_CONFIG_PATCHES_TIMETABLE_ALLOW                              :{LTBLUE}Enable timetabling for vehicles: {ORANGE}{STRING}
 STR_CONFIG_PATCHES_TIMETABLE_IN_TICKS                           :{LTBLUE}Show timetable in ticks rather than days: {ORANGE}{STRING}
+STR_CONFIG_PATCHES_QUICKGOTO                                    :{LTBLUE}Quick creation of vehicle orders: {ORANGE}{STRING1}
 STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE                            :{LTBLUE}Default rail type (after new game/game load): {ORANGE}{STRING}
 STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_RAIL                       :Normal Rail
 STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_ELRAIL                     :Electrified Rail
Index: src/settings_gui.cpp
===================================================================
--- src/settings_gui.cpp	(revision 13683)
+++ src/settings_gui.cpp	(working copy)
@@ -611,6 +611,7 @@
 	"gui.advanced_vehicle_list",
 	"gui.loading_indicators",
 	"gui.timetable_in_ticks",
+	"gui.quick_goto",
 	"gui.default_rail_type",
 	"gui.always_build_infrastructure",
 };
@@ -626,6 +627,8 @@
 	"gui.drag_signals_density",
 	"game_creation.oil_refinery_limit",
 	"gui.semaphore_build_before",
+	"construction.disable_tree_growth",
+	"construction.one_tile_terraform",
 };
 
 static const char *_patches_stations[] = {
@@ -705,6 +708,24 @@
 	"vehicle.dynamic_engines",
 };
 
+static const char *_patches_shared_infrastructure[] = {
+		"shared_railway_stations",
+		"shared_railway_tracks",
+		"shared_railway_depots",
+		"shared_road_stops",
+		"shared_road_depots",
+		"shared_harbours",
+		"shared_water_depots",
+		"shared_airports",
+		"shared_provision",
+		"shared_tontile_cost",
+		"shared_landing_fee",
+		"shared_road_stops_fee",
+		"shared_harbours_fee",
+		"shared_player_level",
+		"shared_delay",
+};
+
 struct PatchEntry {
 	const SettingDesc *setting;
 	uint index;
@@ -726,6 +747,7 @@
 	{_patches_stations,     NULL, lengthof(_patches_stations)},
 	{_patches_economy,      NULL, lengthof(_patches_economy)},
 	{_patches_ai,           NULL, lengthof(_patches_ai)},
+	{_patches_shared_infrastructure, NULL, lengthof(_patches_shared_infrastructure)},
 };
 
 enum PatchesSelectionWidgets {
@@ -735,7 +757,8 @@
 	PATCHSEL_VEHICLES,
 	PATCHSEL_STATIONS,
 	PATCHSEL_ECONOMY,
-	PATCHSEL_COMPETITORS
+	PATCHSEL_COMPETITORS,
+	PATCHSEL_SHARING
 };
 
 struct PatchesSelectionWindow : Window {
@@ -803,7 +826,11 @@
 			bool disabled = false;
 
 			// We do not allow changes of some items when we are a client in a networkgame
-			if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) editable = false;
+			if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) {
+					if (!_network_server && _settings_client.network.rcon_password[0] == '\0') {
+						editable = false;
+					}
+				}
 			if ((sdb->flags & SGF_NETWORK_ONLY) && !_networking) editable = false;
 			if ((sdb->flags & SGF_NO_NETWORK) && _networking) editable = false;
 
@@ -865,7 +892,12 @@
 				sd = page->entries[btn].setting;
 
 				/* return if action is only active in network, or only settable by server */
-				if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) return;
+				if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) {
+					if (!_network_server && _settings_client.network.rcon_password[0] == '\0') {
+						return;
+					}
+				}
+
 				if ((sd->desc.flags & SGF_NETWORK_ONLY) && !_networking) return;
 				if ((sd->desc.flags & SGF_NO_NETWORK) && _networking) return;
 
@@ -931,6 +963,7 @@
 
 			case PATCHSEL_INTERFACE: case PATCHSEL_CONSTRUCTION: case PATCHSEL_VEHICLES:
 			case PATCHSEL_STATIONS:  case PATCHSEL_ECONOMY:      case PATCHSEL_COMPETITORS:
+			case PATCHSEL_SHARING:
 				this->RaiseWidget(this->page + PATCHSEL_INTERFACE);
 				this->page = widget - PATCHSEL_INTERFACE;
 				this->LowerWidget(this->page + PATCHSEL_INTERFACE);
@@ -977,6 +1010,7 @@
 {    WWT_TEXTBTN,   RESIZE_NONE,     3,   271,   357,    16,    27, STR_CONFIG_PATCHES_STATIONS,     STR_NULL},
 {    WWT_TEXTBTN,   RESIZE_NONE,     3,    10,    96,    28,    39, STR_CONFIG_PATCHES_ECONOMY,      STR_NULL},
 {    WWT_TEXTBTN,   RESIZE_NONE,     3,    97,   183,    28,    39, STR_CONFIG_PATCHES_AI,           STR_NULL},
+{    WWT_TEXTBTN,   RESIZE_NONE,     3,   184,   270,    28,    39, STR_CONFIG_PATCHES_SHARED,       STR_NULL},
 {   WIDGETS_END},
 };
 
Index: src/console_cmds.cpp
===================================================================
--- src/console_cmds.cpp	(revision 13683)
+++ src/console_cmds.cpp	(working copy)
@@ -119,6 +119,18 @@
 	return true;
 }
 
+DEF_CONSOLE_CMD(ConResetEconomy)
+{
+	if (argc == 0) {
+		IConsoleHelp("Reset cargo payment rates and prices. It might solve issues with unpaid cargo transports. Usage: 'reseteconomy'");
+		return true;
+	}
+
+	StartupEconomy();
+	InitializeLandscapeVariables(false);
+	return true;
+}
+
 #ifdef _DEBUG
 DEF_CONSOLE_CMD(ConResetTile)
 {
@@ -592,6 +604,48 @@
 	return true;
 }
 
+DEF_CONSOLE_CMD(ConMoveClient)
+{
+	NetworkClientInfo *ci;
+	uint16 index;
+	PlayerID new_player;
+
+	if (argc < 2) {
+		IConsoleHelp("Move a player to another company. Usage: move <client-id> [<company-id>]");
+		IConsoleHelp("For client-id see 'clients', company-id must be between 1 and 8, ommit if moving to spectators");
+		return true;
+	}
+
+	index = atoi(argv[1]);
+	new_player = (argc == 3) ? (PlayerID)(atoi(argv[2])-1) : PLAYER_SPECTATOR; 
+	
+	if (index == NETWORK_SERVER_INDEX) {
+		IConsoleError("Silly boy, you can not move the server!");
+		return true;
+	}
+
+	ci = NetworkFindClientInfoFromIndex(index);
+	if (ci == NULL) {
+		IConsoleError("Invalid client");
+		return true;
+	}
+
+	if (!IsValidPlayer(new_player) && new_player != PLAYER_SPECTATOR) {
+		IConsoleError("Company does not exist, see command 'players'.");
+		return true;
+	}
+
+	/* safe to update, update first the actual client, then all clients */
+	ci->client_playas = new_player;
+	NetworkServerSendMove(index, new_player);
+	NetworkUpdateClientInfo(index);
+
+	IConsolePrintF(CC_DEFAULT, "[move] client %d to company %d.", index, min(new_player+1, PLAYER_SPECTATOR));
+	if (!_network_dedicated) InvalidateWindow(WC_MOVE_PLAYER, 0);
+	if (!_network_dedicated) InvalidateWindow(WC_CLIENT_LIST, 0);
+	return true;
+}
+
 DEF_CONSOLE_CMD(ConResetCompany)
 {
 	const Player *p;
@@ -707,6 +761,49 @@
 	return true;
 }
 
+DEF_CONSOLE_CMD(ConMute)
+{
+	NetworkClientInfo *ci;
+	
+	if (argc != 3 && argc != 2) {
+		IConsoleHelp("Mute a specific client. Usage: 'mute <clientid> <mutetype>'");
+		IConsoleHelp("Types are 1.broadcast 2.team and 3.private");
+		return true;
+	}
+	uint16 client_index = atoi(argv[1]);
+	
+	ci = NetworkFindClientInfoFromIndex(client_index);
+	if (ci == NULL) {
+		IConsoleError("Invalid client");
+		return true;
+	}
+	
+	if (client_index == NETWORK_SERVER_INDEX) {
+		IConsoleError("Silly boy, you can not mute the server");
+		return true;
+	}
+
+	if (argc == 3) {
+		switch (atoi(argv[2]) - 1) {
+			case DESTTYPE_BROADCAST:
+				ToggleBit(ci->mute, 1);
+				break;
+			case DESTTYPE_TEAM:
+				ToggleBit(ci->mute, 2);
+				break;
+			case DESTTYPE_CLIENT:
+				ToggleBit(ci->mute, 3);
+				break;
+			default: return false;
+		}
+	}
+	IConsolePrintF(CC_DEFAULT, "Current muted status of client %d: %s %s %s", client_index, (HasBit(ci->mute, 1) ? "public" : ""), (HasBit(ci->mute, 2) ? "team" : ""), (HasBit(ci->mute, 3) ? "private" : ""));
+	NetworkServerSendMuteStatus(client_index);
+	if (!_network_dedicated) InvalidateWindow(WC_MUTE_PLAYER, 0);
+	return true;
+	
+}
+
 #endif /* ENABLE_NETWORK */
 
 /* ******************************** */
@@ -1358,6 +1455,7 @@
 	IConsoleCmdRegister("getdate",      ConGetDate);
 	IConsoleCmdRegister("quit",         ConExit);
 	IConsoleCmdRegister("resetengines", ConResetEngines);
+	IConsoleCmdRegister("reseteconomy", ConResetEconomy);
 	IConsoleCmdRegister("return",       ConReturn);
 	IConsoleCmdRegister("screenshot",   ConScreenShot);
 	IConsoleCmdRegister("script",       ConScript);
@@ -1412,6 +1510,8 @@
 	IConsoleCmdRegister("rcon",            ConRcon);
 	IConsoleCmdHookAdd("rcon",             ICONSOLE_HOOK_ACCESS, ConHookNeedNetwork);
 
+	IConsoleCmdRegister("move",            ConMoveClient);
+	IConsoleCmdHookAdd("move",             ICONSOLE_HOOK_ACCESS, ConHookServerOnly);
 	IConsoleCmdRegister("reset_company",   ConResetCompany);
 	IConsoleCmdHookAdd("reset_company",    ICONSOLE_HOOK_ACCESS, ConHookServerOnly);
 	IConsoleAliasRegister("clean_company", "reset_company %A");
@@ -1428,6 +1528,8 @@
 	IConsoleCmdHookAdd("pause",            ICONSOLE_HOOK_ACCESS, ConHookServerOnly);
 	IConsoleCmdRegister("unpause",         ConUnPauseGame);
 	IConsoleCmdHookAdd("unpause",          ICONSOLE_HOOK_ACCESS, ConHookServerOnly);
+	IConsoleCmdRegister("mute",         ConMute);
+	IConsoleCmdHookAdd("mute",          ICONSOLE_HOOK_ACCESS, ConHookServerOnly);
 
 	/*** Networking variables ***/
 	IConsoleVarStringRegister("company_pw",      NULL, 0, "Set a password for your company, so no one without the correct password can join. Use '*' to clear the password");
Index: src/npf.cpp
===================================================================
--- src/npf.cpp	(revision 13683)
+++ src/npf.cpp	(working copy)
@@ -24,6 +24,7 @@
 #include "vehicle_base.h"
 #include "settings_type.h"
 #include "tunnelbridge.h"
+#include "sharedinfrastructure.h"
 
 static AyStar _npf_aystar;
 
@@ -465,25 +466,37 @@
  */
 static bool CanEnterTileOwnerCheck(Owner owner, TileIndex tile, DiagDirection enterdir)
 {
-	if (IsTileType(tile, MP_RAILWAY) ||             /* Rail tile (also rail depot) */
-			IsRailwayStationTile(tile) ||   /* Rail station tile */
-			IsRoadDepotTile(tile) ||        /* Road depot tile */
-			IsStandardRoadStopTile(tile)) { /* Road station tile (but not drive-through stops) */
-		return IsTileOwner(tile, owner); /* You need to own these tiles entirely to use them */
-	}
+	unsigned char tileOwner = IsTileOwner(tile,owner);
+	if(IsTileType(tile, MP_RAILWAY) && !IsRailwayStation(tile))
+		return ( tileOwner || SharedTracks(tile,owner));
 
+	if (IsRailwayStation(tile))
+	  	return ( tileOwner || SharedRailwayStations(tile,owner));
+
+	if (IsDepotTypeTile(tile, TRANSPORT_RAIL))
+		return ( tileOwner || SharedRailwayDepots(tile,owner));
+
+	if (IsDepotTypeTile(tile, TRANSPORT_ROAD))
+		return ( tileOwner || SharedRoadDepots(tile,owner));
+
+	if (IsStandardRoadStopTile(tile))
+		return ( tileOwner || SharedRoadStops(tile,owner));
+
+	if (IsDepotTypeTile(tile, TRANSPORT_WATER))
+		return ( tileOwner || SharedWaterDepots(tile,owner));
+
 	switch (GetTileType(tile)) {
 		case MP_ROAD:
 			/* rail-road crossing : are we looking at the railway part? */
 			if (IsLevelCrossing(tile) &&
 					DiagDirToAxis(enterdir) != GetCrossingRoadAxis(tile)) {
-				return IsTileOwner(tile, owner); /* Railway needs owner check, while the street is public */
+ 				return (tileOwner || SharedTracks(tile,owner)); /* Railway needs owner check, while the street is public */
 			}
 			break;
 
 		case MP_TUNNELBRIDGE:
 			if (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) {
-				return IsTileOwner(tile, owner);
+ 				return (tileOwner || SharedTracks(tile,owner));
 			}
 			break;
 
@@ -880,7 +893,7 @@
 	FOR_ALL_DEPOTS(depot) {
 		/* Check if this is really a valid depot, it is of the needed type and
 		 * owner */
-		if (IsDepotTypeTile(depot->xy, type) && IsTileOwner(depot->xy, owner))
+		if (IsDepotTypeTile(depot->xy, type) && ((IsTileOwner(depot->xy, owner)||SharedDepotTransport(depot->xy,owner,type))))
 			/* If so, let's add it to the queue, sorted by distance */
 			depots.push(&depots, depot, DistanceManhattan(tile, depot->xy));
 	}
Index: src/terraform_cmd.cpp
===================================================================
--- src/terraform_cmd.cpp	(revision 13683)
+++ src/terraform_cmd.cpp	(working copy)
@@ -12,6 +12,7 @@
 #include "variables.h"
 #include "functions.h"
 #include "economy_func.h"
+#include "settings_type.h"
 
 #include "table/strings.h"
 
@@ -206,9 +207,13 @@
 			if (abs(height_diff) > 1) {
 				/* Terraform the neighboured corner. The resulting height difference should be 1. */
 				height_diff += (height_diff < 0 ? 1 : -1);
-				CommandCost cost = TerraformTileHeight(ts, tile, r + height_diff);
-				if (CmdFailed(cost)) return cost;
-				total_cost.AddCost(cost);
+				if (_settings_game.construction.one_tile_terraform) {
+					return CMD_ERROR;
+				} else {
+					CommandCost cost = TerraformTileHeight(ts, tile, r + height_diff);
+					if (CmdFailed(cost)) return cost;
+					total_cost.AddCost(cost);
+				}
 			}
 		}
 	}
@@ -301,10 +306,7 @@
 				return_cmd_error(STR_1002_EXCAVATION_WOULD_DAMAGE);
 			}
 			/* Check tiletype-specific things, and add extra-cost */
-			const bool curr_gen = _generating_world;
-			if (_game_mode == GM_EDITOR) _generating_world = true; // used to create green terraformed land
 			CommandCost cost = _tile_type_procs[GetTileType(tile)]->terraform_tile_proc(tile, flags | DC_AUTO, z_min * TILE_HEIGHT, tileh);
-			_generating_world = curr_gen;
 			if (CmdFailed(cost)) {
 				_terraform_err_tile = tile;
 				return cost;
@@ -371,6 +373,9 @@
 
 	int size_x = ex - sx + 1;
 	int size_y = ey - sy + 1;
+	
+	/* make sure that the terraform region is not larger than 2x2, if one-tile terraform enabled */
+	if ((size_x > 2 || size_y > 2) && _settings_game.construction.one_tile_terraform) { return CMD_ERROR; }
 
 	Money money = GetAvailableMoneyForCommand();
 	CommandCost cost(EXPENSES_CONSTRUCTION);
Index: src/saveload.cpp
===================================================================
--- src/saveload.cpp	(revision 13683)
+++ src/saveload.cpp	(working copy)
@@ -36,7 +36,7 @@
 
 #include "table/strings.h"
 
-extern const uint16 SAVEGAME_VERSION = 98;
+extern const uint16 SAVEGAME_VERSION = SL_VERSION_PATCH;
 
 SavegameType _savegame_type; ///< type of savegame we are loading
 
Index: src/misc_gui.cpp
===================================================================
--- src/misc_gui.cpp	(revision 13683)
+++ src/misc_gui.cpp	(working copy)
@@ -72,7 +72,7 @@
 
 class LandInfoWindow : public Window {
 	enum {
-		LAND_INFO_CENTERED_LINES   = 9,                        ///< Up to 9 centered lines
+		LAND_INFO_CENTERED_LINES   = 11,                       ///< Up to 11 centered lines
 		LAND_INFO_MULTICENTER_LINE = LAND_INFO_CENTERED_LINES, ///< One multicenter line
 		LAND_INFO_LINE_END,
 
@@ -127,6 +127,9 @@
 		td.owner[2] = OWNER_NONE;
 		td.owner[3] = OWNER_NONE;
 
+		td.grfclass = STR_NULL;
+		td.grfname = STR_NULL;
+
 		GetAcceptedCargo(tile, ac);
 		GetTileDesc(tile, &td);
 
@@ -181,6 +184,18 @@
 			line_nr++;
 		}
 
+		if (td.grfclass != STR_NULL) {
+			SetDParam(0, td.grfclass);
+			GetString(this->landinfo_data[line_nr], STR_TILEDESC_STATION_CLASS, lastof(this->landinfo_data[line_nr]));
+			line_nr++;
+		}
+
+		if (td.grfname != STR_NULL) {
+			SetDParam(0, td.grfname);
+			GetString(this->landinfo_data[line_nr], STR_TILEDESC_STATION_TYPE, lastof(this->landinfo_data[line_nr]));
+			line_nr++;
+		}
+
 		/* Mark last line empty */
 		this->landinfo_data[line_nr][0] = '\0';
 
Index: src/rail_cmd.cpp
===================================================================
--- src/rail_cmd.cpp	(revision 13683)
+++ src/rail_cmd.cpp	(working copy)
@@ -296,7 +296,7 @@
 	   ) return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
 
 	Foundation f_old = GetRailFoundation(tileh, existing);
-	return CommandCost(EXPENSES_CONSTRUCTION, f_new != f_old ? _price.terraform : (Money)0);
+	return CommandCost(EXPENSES_CONSTRUCTION, f_new != f_old ? (_price.build_rail <<3) : (Money)0);
 }
 
 /* Validate functions for rail building */
@@ -2286,7 +2286,16 @@
 	byte fract_coord_leave;
 	DiagDirection dir;
 	int length;
+	Owner trackowner;
 
+	/* Account for use of shared tracks */
+	if (v->tile != tile && IsFrontEngine(v)) {
+		trackowner = GetTileOwner(tile);
+		if (trackowner != v->owner) {
+			v->shared_tontiles[trackowner] += v->u.rail.cached_weight;
+		}
+	}
+
 	/* this routine applies only to trains in depot tiles */
 	if (v->type != VEH_TRAIN || !IsRailDepotTile(tile)) return VETSB_CONTINUE;
 
@@ -2363,7 +2372,7 @@
 		case TRACK_BIT_UPPER: track_corner = CORNER_N; break;
 
 		/* Surface slope must not be changed */
-		default: return (((z_old != z_new) || (tileh_old != tileh_new)) ? CMD_ERROR : CommandCost(EXPENSES_CONSTRUCTION, _price.terraform));
+		default: return (((z_old != z_new) || (tileh_old != tileh_new)) ? CMD_ERROR : CommandCost(EXPENSES_CONSTRUCTION, (_price.build_rail <<3)));
 	}
 
 	/* The height of the track_corner must not be changed. The rest ensures GetRailFoundation() already. */
@@ -2371,7 +2380,7 @@
 	z_new += GetSlopeZInCorner(RemoveHalftileSlope(tileh_new), track_corner);
 	if (z_old != z_new) return CMD_ERROR;
 
-	CommandCost cost = CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
+	CommandCost cost = CommandCost(EXPENSES_CONSTRUCTION, (_price.build_rail <<3));
 	/* Make the ground dirty, if surface slope has changed */
 	if (tileh_old != tileh_new) {
 		/* If there is flat water on the lower halftile add the cost for clearing it */
@@ -2431,7 +2440,7 @@
 				}
 
 				case RAIL_TILE_DEPOT:
-					if (AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, GetRailDepotDirection(tile))) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
+					if (AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, GetRailDepotDirection(tile))) return CommandCost(EXPENSES_CONSTRUCTION, (_price.build_rail <<3));
 					break;
 
 				default: NOT_REACHED();
Index: src/smallmap_gui.cpp
===================================================================
--- src/smallmap_gui.cpp	(revision 13683)
+++ src/smallmap_gui.cpp	(working copy)
@@ -1230,7 +1230,7 @@
 	_extra_view_port_widgets,
 };
 
-void ShowExtraViewPortWindow(TileIndex tile)
+int ShowExtraViewPortWindow(TileIndex tile)
 {
 	int i = 0;
 
@@ -1238,6 +1238,8 @@
 	while (FindWindowById(WC_EXTRA_VIEW_PORT, i) != NULL) i++;
 
 	new ExtraViewportWindow(&_extra_view_port_desc, i, tile);
+
+	return i;
 }
 
 bool ScrollMainWindowTo(int x, int y, bool instant)
Index: src/date.cpp
===================================================================
--- src/date.cpp	(revision 13683)
+++ src/date.cpp	(working copy)
@@ -170,6 +170,8 @@
 extern void TownsMonthlyLoop();
 extern void IndustryMonthlyLoop();
 extern void StationMonthlyLoop();
+extern void SharedTracksPayment();
+extern void SharedSettingDelay();
 
 extern void PlayersYearlyLoop();
 extern void TrainsYearlyLoop();
@@ -265,6 +267,9 @@
 #ifdef ENABLE_NETWORK
 		if (_network_server) NetworkServerMonthlyLoop();
 #endif /* ENABLE_NETWORK */
+ 		SharedTracksPayment();
+ 		SharedSettingDelay();
+
 	}
 
 	/* check if we entered a new year? */
Index: src/station_gui.h
===================================================================
--- src/station_gui.h	(revision 13683)
+++ src/station_gui.h	(working copy)
@@ -5,6 +5,9 @@
 #ifndef STATION_GUI_H
 #define STATION_GUI_H
 
+#include "command_type.h"
+#include "station_type.h"
+
 /** Enum for PlayerStations, referring to _player_stations_widgets */
 enum StationListWidgets {
 	SLW_CLOSEBOX       =  0, ///< Close 'X' button
@@ -46,6 +49,7 @@
 	SVW_PLANES,          ///< List of scheduled planes button
 	SVW_SHIPS,           ///< List of scheduled ships button
 	SVW_RESIZE,          ///< Resize button
+	SVW_CLOSEAIRPORT,    ///< Close airport button
 };
 
 enum StationCoverageType {
@@ -59,4 +63,7 @@
 
 extern bool _station_show_coverage;
 
+void ShowSelectStation(CommandContainer cmd, StationType stationType, bool lockPos, bool lockSize);
+bool StationJoinerNeeded(TileIndex tile, int w, int h);
+
 #endif /* STATION_GUI_H */
Index: src/build_vehicle_gui.cpp
===================================================================
--- src/build_vehicle_gui.cpp	(revision 13683)
+++ src/build_vehicle_gui.cpp	(working copy)
@@ -39,6 +39,7 @@
 	BUILD_VEHICLE_WIDGET_CAPTION,
 	BUILD_VEHICLE_WIDGET_SORT_ASSENDING_DESCENDING,
 	BUILD_VEHICLE_WIDGET_SORT_DROPDOWN,
+	BUILD_VEHICLE_WIDGET_CARGO_DROPDOWN,
 	BUILD_VEHICLE_WIDGET_LIST,
 	BUILD_VEHICLE_WIDGET_SCROLLBAR,
 	BUILD_VEHICLE_WIDGET_PANEL,
@@ -50,19 +51,30 @@
 
 static const Widget _build_vehicle_widgets[] = {
 	{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW },
-	{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   239,     0,    13, 0x0,                     STR_018C_WINDOW_TITLE_DRAG_THIS },
-	{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    80,    14,    25, STR_SORT_BY,             STR_SORT_ORDER_TIP},
-	{   WWT_DROPDOWN,  RESIZE_RIGHT,    14,    81,   239,    14,    25, 0x0,                     STR_SORT_CRITERIA_TIP},
-	{     WWT_MATRIX,     RESIZE_RB,    14,     0,   227,    26,    39, 0x101,                   STR_NULL },
-	{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   228,   239,    26,    39, 0x0,                     STR_0190_SCROLL_BAR_SCROLLS_LIST },
-	{      WWT_PANEL,    RESIZE_RTB,    14,     0,   239,    40,   161, 0x0,                     STR_NULL },
+	{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   293,     0,    13, 0x0,                     STR_018C_WINDOW_TITLE_DRAG_THIS },
+	{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,    60,    14,    25, STR_SORT_BY,             STR_SORT_ORDER_TIP},
+	{   WWT_DROPDOWN,   RESIZE_NONE,    14,    61,   190,    14,    25, 0x0,                     STR_SORT_CRITERIA_TIP},
+	{   WWT_DROPDOWN,  RESIZE_RIGHT,    14,   191,   293,    14,    25, 0x0,                     STR_SORT_CRITERIA_TIP},
+	{     WWT_MATRIX,     RESIZE_RB,    14,     0,   281,    26,    39, 0x101,                   STR_NULL },
+	{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   282,   293,    26,    39, 0x0,                     STR_0190_SCROLL_BAR_SCROLLS_LIST },
+	{      WWT_PANEL,    RESIZE_RTB,    14,     0,   293,    40,   161, 0x0,                     STR_NULL },
 
-	{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   114,   162,   173, 0x0,                     STR_NULL },
-	{ WWT_PUSHTXTBTN,    RESIZE_RTB,    14,   115,   227,   162,   173, 0x0,                     STR_NULL },
-	{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   228,   239,   162,   173, 0x0,                     STR_RESIZE_BUTTON },
+	{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   114,   162,   173, 0x0,                         STR_NULL },
+	{ WWT_PUSHTXTBTN,    RESIZE_RTB,    14,   115,   281,   162,   173, 0x0,                         STR_NULL },
+	{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   282,   293,   162,   173, 0x0,                         STR_RESIZE_BUTTON },
 	{   WIDGETS_END},
 };
 
+enum cargo_filter {
+	CF_SHOW_ALL = NUM_CARGO
+};
+
+static int _cargo_filter_train = CF_SHOW_ALL;
+static int _cargo_filter_road = CF_SHOW_ALL;
+static int _cargo_filter_ship = CF_SHOW_ALL;
+static int _cargo_filter_aircraft = CF_SHOW_ALL;
+static StringID _cargos_name_list[NUM_CARGO + 1];
+static int _cargos_dropdown_pos[NUM_CARGO + 1];
 static bool _internal_sort_order; // descending/ascending
 static byte _last_sort_criteria[]    = {0, 0, 0, 0};
 static bool _last_sort_order[]       = {false, false, false, false};
@@ -826,6 +838,21 @@
 		this->sel_engine      = INVALID_ENGINE;
 		this->regenerate_list = false;
 
+		/* Create cargo filter list  */
+		_cargos_name_list[0] = STR_PURCHASE_INFO_ALL_TYPES;
+		_cargos_dropdown_pos[CF_SHOW_ALL] = 0;
+
+		uint i = 1;
+		for (CargoID c = 0; c < NUM_CARGO; c++) {
+			if (!GetCargo(c)->IsValid()) continue;
+
+			_cargos_name_list[i] = GetCargo(c)->name;
+			_cargos_dropdown_pos[c] = i;
+
+			i++;
+		}
+		_cargos_name_list[i] = INVALID_STRING_ID;
+
 		this->sort_criteria         = _last_sort_criteria[type];
 		this->descending_sort_order = _last_sort_order[type];
 
@@ -920,6 +947,9 @@
 			if (this->filter.railtype != RAILTYPE_END && !HasPowerOnRail(rvi->railtype, this->filter.railtype)) continue;
 			if (!IsEngineBuildable(eid, VEH_TRAIN, _local_player)) continue;
 
+			uint32 cmask = EngInfo(eid)->refit_mask;
+			if (!((_cargo_filter_train == rvi->cargo_type && rvi->capacity > 0) || (HasBit(cmask, _cargo_filter_train))) && (_cargo_filter_train > CF_SHOW_ALL )) continue;
+
 			*this->eng_list.Append() = eid;
 
 			if (rvi->railveh_type != RAILVEH_WAGON) {
@@ -955,8 +985,11 @@
 		const Engine *e;
 		FOR_ALL_ENGINES_OF_TYPE(e, VEH_ROAD) {
 			EngineID eid = e->index;
+			const RoadVehicleInfo *rvi = RoadVehInfo(eid);
 			if (!IsEngineBuildable(eid, VEH_ROAD, _local_player)) continue;
 			if (!HasBit(this->filter.roadtypes, HasBit(EngInfo(eid)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD)) continue;
+			uint32 cmask = EngInfo(eid)->refit_mask;
+			if (!((_cargo_filter_road == rvi->cargo_type && rvi->capacity > 0) || (HasBit(cmask, _cargo_filter_road))) && (_cargo_filter_road > CF_SHOW_ALL )) continue;
 			*this->eng_list.Append() = eid;
 
 			if (eid == this->sel_engine) sel_id = eid;
@@ -973,7 +1006,10 @@
 		const Engine *e;
 		FOR_ALL_ENGINES_OF_TYPE(e, VEH_SHIP) {
 			EngineID eid = e->index;
+			const ShipVehicleInfo *svi = ShipVehInfo(eid);
 			if (!IsEngineBuildable(eid, VEH_SHIP, _local_player)) continue;
+			uint32 cmask = EngInfo(eid)->refit_mask;
+			if (!((_cargo_filter_ship == svi->cargo_type && svi->capacity > 0) || (HasBit(cmask, _cargo_filter_ship))) && (_cargo_filter_ship > CF_SHOW_ALL )) continue;
 			*this->eng_list.Append() = eid;
 
 			if (eid == this->sel_engine) sel_id = eid;
@@ -995,10 +1031,13 @@
 		const Engine *e;
 		FOR_ALL_ENGINES_OF_TYPE(e, VEH_AIRCRAFT) {
 			EngineID eid = e->index;
+			const AircraftVehicleInfo *avi = AircraftVehInfo(eid);
 			if (!IsEngineBuildable(eid, VEH_AIRCRAFT, _local_player)) continue;
 			/* First VEH_END window_numbers are fake to allow a window open for all different types at once */
 			if (this->window_number > VEH_END && !CanAircraftUseStation(eid, this->window_number)) continue;
 
+			uint32 cmask = EngInfo(eid)->refit_mask;
+			if (!((_cargo_filter_aircraft == CT_PASSENGERS && avi->passenger_capacity > 0) || (_cargo_filter_aircraft == CT_MAIL && avi->mail_capacity > 0) || (HasBit(cmask, _cargo_filter_aircraft))) && (_cargo_filter_aircraft > CF_SHOW_ALL )) continue;
 			*this->eng_list.Append() = eid;
 			if (eid == this->sel_engine) sel_id = eid;
 		}
@@ -1050,6 +1089,19 @@
 				ShowDropDownMenu(this, _sort_listing[this->vehicle_type], this->sort_criteria, BUILD_VEHICLE_WIDGET_SORT_DROPDOWN, 0, 0);
 				break;
 
+			case BUILD_VEHICLE_WIDGET_CARGO_DROPDOWN: {
+				int cargo_filter = CF_SHOW_ALL;
+				switch (this->vehicle_type) {
+					default: NOT_REACHED();
+					case VEH_TRAIN:    cargo_filter = _cargo_filter_train;    break;
+					case VEH_ROAD:     cargo_filter = _cargo_filter_road;     break;
+					case VEH_SHIP:     cargo_filter = _cargo_filter_ship;     break;
+					case VEH_AIRCRAFT: cargo_filter = _cargo_filter_aircraft; break;
+				}
+				ShowDropDownMenu(this, _cargos_name_list, _cargos_dropdown_pos[cargo_filter], BUILD_VEHICLE_WIDGET_CARGO_DROPDOWN, 0, 0);
+				break;
+			}
+
 			case BUILD_VEHICLE_WIDGET_BUILD: {
 				EngineID sel_eng = this->sel_engine;
 				if (sel_eng != INVALID_ENGINE) {
@@ -1108,6 +1160,15 @@
 
 		uint max = min(this->vscroll.pos + this->vscroll.cap, this->eng_list.Length());
 
+		int cargo_filter = CF_SHOW_ALL;
+		switch (this->vehicle_type) {
+			default: NOT_REACHED();
+			case VEH_TRAIN:    cargo_filter = _cargo_filter_train;    break;
+			case VEH_ROAD:     cargo_filter = _cargo_filter_road;     break;
+			case VEH_SHIP:     cargo_filter = _cargo_filter_ship;     break;
+			case VEH_AIRCRAFT: cargo_filter = _cargo_filter_aircraft; break;
+		}
+
 		this->SetWidgetDisabledState(BUILD_VEHICLE_WIDGET_BUILD, this->window_number <= VEH_END);
 
 		SetVScrollCount(this, this->eng_list.Length());
@@ -1115,6 +1176,7 @@
 
 		/* Set text of sort by dropdown */
 		this->widget[BUILD_VEHICLE_WIDGET_SORT_DROPDOWN].data = _sort_listing[this->vehicle_type][this->sort_criteria];
+		this->widget[BUILD_VEHICLE_WIDGET_CARGO_DROPDOWN].data = _cargos_name_list[_cargos_dropdown_pos[cargo_filter]];
 
 		this->DrawWidgets();
 
@@ -1160,11 +1222,41 @@
 
 	virtual void OnDropdownSelect(int widget, int index)
 	{
-		if (this->sort_criteria != index) {
-			this->sort_criteria = index;
-			_last_sort_criteria[this->vehicle_type] = this->sort_criteria;
-			this->regenerate_list = true;
-		}
+		switch (widget) {
+			case BUILD_VEHICLE_WIDGET_SORT_DROPDOWN:
+				if (this->sort_criteria != index) {
+					this->sort_criteria = index;
+					_last_sort_criteria[this->vehicle_type] = this->sort_criteria;
+				}
+				break;
+
+			case BUILD_VEHICLE_WIDGET_CARGO_DROPDOWN:
+				CargoID c;
+				int cargo_filter;
+
+				if (index > 0) {
+					int i = 1;
+					for (c = 0; c < NUM_CARGO; c++) {
+						if (!GetCargo(c)->IsValid()) continue;
+						if (index == i) break;
+						i++;
+					}
+					cargo_filter = c;
+				}
+				else {
+					cargo_filter = CF_SHOW_ALL;
+				}
+
+				switch (this->vehicle_type) {
+					default: NOT_REACHED();
+					case VEH_TRAIN:    _cargo_filter_train = cargo_filter;    break;
+					case VEH_ROAD:     _cargo_filter_road = cargo_filter;     break;
+					case VEH_SHIP:     _cargo_filter_ship = cargo_filter;     break;
+					case VEH_AIRCRAFT: _cargo_filter_aircraft = cargo_filter; break;
+				}				
+				break;
+		}	
+		this->regenerate_list = true;
 		this->SetDirty();
 	}
 
@@ -1179,7 +1271,7 @@
 };
 
 static const WindowDesc _build_vehicle_desc = {
-	WDP_AUTO, WDP_AUTO, 240, 174, 240, 256,
+	WDP_AUTO, WDP_AUTO, 294, 174, 294, 256,
 	WC_BUILD_VEHICLE, WC_NONE,
 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
 	_build_vehicle_widgets,
Index: src/station_cmd.cpp
===================================================================
--- src/station_cmd.cpp	(revision 13683)
+++ src/station_cmd.cpp	(working copy)
@@ -706,7 +706,7 @@
 			    (HasBit(invalid_dirs, DIAGDIR_NW) && !(tileh & SLOPE_NW))) {
 				return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
 			}
-			cost.AddCost(_price.terraform);
+			cost.AddCost((_price.build_rail <<3));
 			flat_z += TILE_HEIGHT;
 		}
 
@@ -854,23 +854,24 @@
  * @param tile_org starting position of station dragging/placement
  * @param flags operation to perform
  * @param p1 various bitstuffed elements
- * - p1 = (bit  0)    - orientation (Axis)
+ * - p1 = (bit  0- 3) - railtype (p2 & 0xF)
+ * - p1 = (bit  4)    - orientation (Axis)
  * - p1 = (bit  8-15) - number of tracks
  * - p1 = (bit 16-23) - platform length
  * - p1 = (bit 24)    - allow stations directly adjacent to other stations.
  * @param p2 various bitstuffed elements
- * - p2 = (bit  0- 3) - railtype (p2 & 0xF)
- * - p2 = (bit  8-15) - custom station class
- * - p2 = (bit 16-23) - custom station id
+ * - p2 = (bit  0- 7) - custom station class
+ * - p2 = (bit  8-15) - custom station id
+ * - p2 = (bit 16-31) - station ID to join (INVALID_STATION if build new one)
  */
 CommandCost CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1, uint32 p2)
 {
 	/* Does the authority allow this? */
 	if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile_org)) return CMD_ERROR;
-	if (!ValParamRailtype((RailType)(p2 & 0xF))) return CMD_ERROR;
+	if (!ValParamRailtype((RailType)(p1 & 0xF))) return CMD_ERROR;
 
 	/* unpack parameters */
-	Axis axis = Extract<Axis, 0>(p1);
+	Axis axis = Extract<Axis, 4>(p1);
 	uint numtracks = GB(p1,  8, 8);
 	uint plat_len  = GB(p1, 16, 8);
 
@@ -883,6 +884,9 @@
 		w_org = numtracks;
 	}
 
+	StationID station_to_join = GB(p2, 16, 16);
+	bool distant_join = (station_to_join != INVALID_STATION);
+
 	if (h_org > _settings_game.station.station_spread || w_org > _settings_game.station.station_spread) return CMD_ERROR;
 
 	/* these values are those that will be stored in train_tile and station_platforms */
@@ -905,7 +909,7 @@
 
 	if (_settings_game.station.adjacent_stations) {
 		if (est != INVALID_STATION) {
-			if (HasBit(p1, 24)) {
+			if (HasBit(p1, 24) && (est != station_to_join)) {
 				/* You can't build an adjacent station over the top of one that
 				 * already exists. */
 				return_cmd_error(STR_MUST_REMOVE_RAILWAY_STATION_FIRST);
@@ -928,6 +932,11 @@
 		if (st == CHECK_STATIONS_ERR) return CMD_ERROR;
 	}
 
+	/* Distant join */
+	if ((st == NULL) && (distant_join)) {
+		st = GetStation(station_to_join);
+	}
+
 	/* See if there is a deleted station close to us. */
 	if (st == NULL) st = GetClosestStationFromTile(tile_org);
 
@@ -963,10 +972,10 @@
 	}
 
 	/* Check if the given station class is valid */
-	if (GB(p2, 8, 8) >= GetNumStationClasses()) return CMD_ERROR;
+	if (GB(p2, 0, 8) >= GetNumStationClasses()) return CMD_ERROR;
 
 	/* Check if we can allocate a custom stationspec to this station */
-	const StationSpec *statspec = GetCustomStationSpec((StationClassID)GB(p2, 8, 8), GB(p2, 16, 8));
+	const StationSpec *statspec = GetCustomStationSpec((StationClassID)GB(p2, 0, 8), GB(p2, 8, 8));
 	int specindex = AllocateSpecToStation(statspec, st, flags & DC_EXEC);
 	if (specindex == -1) return CMD_ERROR;
 
@@ -1023,7 +1032,7 @@
 			int w = plat_len;
 			do {
 				byte layout = *layout_ptr++;
-				MakeRailStation(tile, st->owner, st->index, axis, layout & ~1, (RailType)GB(p2, 0, 4));
+				MakeRailStation(tile, st->owner, st->index, axis, layout & ~1, (RailType)GB(p1, 0, 4));
 				SetCustomStationSpecIndex(tile, specindex);
 				SetStationTileRandomBits(tile, GB(Random(), 0, 4));
 				SetStationAnimationFrame(tile, 0);
@@ -1294,6 +1303,7 @@
  *           bit 1: 0 for normal, 1 for drive-through
  *           bit 2..4: the roadtypes
  *           bit 5: allow stations directly adjacent to other stations.
+ *           bit 16-31: station ID to join (INVALID_STATION if build new one)
  */
 CommandCost CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
@@ -1302,6 +1312,8 @@
 	bool build_over_road  = is_drive_through && IsNormalRoadTile(tile);
 	bool town_owned_road  = false;
 	RoadTypes rts = (RoadTypes)GB(p2, 2, 3);
+	StationID station_to_join = GB(p2, 16, 16);
+	bool distant_join = (station_to_join != INVALID_STATION);
 
 	if (!AreValidRoadTypes(rts) || !HasRoadTypesAvail(_current_player, rts)) return CMD_ERROR;
 
@@ -1355,6 +1367,11 @@
 		if (st == CHECK_STATIONS_ERR) return CMD_ERROR;
 	}
 
+	/* Distant join */
+	if ((st == NULL) && (distant_join)) {
+		st = GetStation(station_to_join);
+	}
+
 	/* Find a station close to us */
 	if (st == NULL) st = GetClosestStationFromTile(tile);
 
@@ -1697,10 +1714,13 @@
  * @param flags operation to perform
  * @param p1 airport type, @see airport.h
  * @param p2 (bit 0) - allow airports directly adjacent to other airports.
+ * @param p2 - bit 16-31: station ID to join (INVALID_STATION if build new one)
  */
 CommandCost CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
 	bool airport_upgrade = true;
+	StationID station_to_join = GB(p2, 16, 16);
+	bool distant_join = (station_to_join != INVALID_STATION);
 
 	/* Check if a valid, buildable airport was chosen for construction */
 	if (p1 > lengthof(_airport_sections) || !HasBit(GetValidAirports(), p1)) return CMD_ERROR;
@@ -1753,6 +1773,11 @@
 		st = NULL;
 	}
 
+	/* Distant join */
+	if ((st == NULL) && (distant_join)) {
+		st = GetStation(station_to_join);
+	}
+
 	/* Find a station close to us */
 	if (st == NULL) st = GetClosestStationFromTile(tile);
 
@@ -1820,6 +1845,7 @@
 		UpdateStationAcceptance(st, false);
 		InvalidateWindowData(WC_STATION_LIST, st->owner, 0);
 		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_PLANES);
+		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_CLOSEAIRPORT);
 
 		if (_settings_game.economy.station_noise_level) {
 			InvalidateWindow(WC_TOWN_VIEW, st->town->index);
@@ -1875,8 +1901,10 @@
 
 		st->airport_tile = 0;
 		st->facilities &= ~FACIL_AIRPORT;
+		st->airport_flags = 0;
 
 		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_PLANES);
+		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_CLOSEAIRPORT);
 
 		if (_settings_game.economy.station_noise_level) {
 			InvalidateWindow(WC_TOWN_VIEW, st->town->index);
@@ -1889,6 +1917,32 @@
 	return cost;
 }
 
+/** Open/close an airport.
+ * @param tile unused
+ * @param flags type of operation
+ * @param p1 station ID of the airport
+ * @param p2 new status (0 open, 1 closed)
+ */
+CommandCost CmdOpenCloseAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
+{
+	if (!IsValidStationID(p1)) return CMD_ERROR;
+	Station *st = GetStation(p1);
+
+	if (!(st->facilities & FACIL_AIRPORT)) return CMD_ERROR;
+	if (!CheckOwnership(st->owner)) return CMD_ERROR;
+
+	if (flags & DC_EXEC) {
+		if (p2) {
+			SETBITS(st->airport_flags, AIRPORT_CLOSED_block);
+		} else {
+			CLRBITS(st->airport_flags, AIRPORT_CLOSED_block);
+		}
+		InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_CLOSEAIRPORT);
+	}
+
+	return CommandCost();
+}
+
 /** Build a buoy.
  * @param tile tile where to place the bouy
  * @param flags operation to perform
@@ -2003,10 +2057,13 @@
  * @param tile tile where dock will be built
  * @param flags operation to perform
  * @param p1 (bit 0) - allow docks directly adjacent to other docks.
- * @param p2 unused
+ * @param p2 bit 16-31: station ID to join (INVALID_STATION if build new one)
  */
 CommandCost CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
+	StationID station_to_join = GB(p2, 16, 16);
+	bool distant_join = (station_to_join != INVALID_STATION);
+
 	DiagDirection direction = GetInclinedSlopeDirection(GetTileSlope(tile, NULL));
 	if (direction == INVALID_DIAGDIR) return_cmd_error(STR_304B_SITE_UNSUITABLE);
 	direction = ReverseDiagDir(direction);
@@ -2048,6 +2105,11 @@
 		if (st == CHECK_STATIONS_ERR) return CMD_ERROR;
 	}
 
+	/* Distant join */
+	if ((st == NULL) && (distant_join)) {
+		st = GetStation(station_to_join);
+	}
+
 	/* Find a station close to us */
 	if (st == NULL) st = GetClosestStationFromTile(tile);
 
@@ -2309,6 +2371,13 @@
 	}
 	td->build_date = GetStationByTile(tile)->build_date;
 
+	const StationSpec *spec = GetStationSpec(tile);
+
+	if (spec != NULL) {
+		td->grfclass = GetStationClassName(spec->sclass);
+		td->grfname = spec->name;
+	}
+
 	StringID str;
 	switch (GetStationType(tile)) {
 		default: NOT_REACHED();
@@ -3084,11 +3153,11 @@
 					DiagDirection direction = AxisToDiagDir(GetRailStationAxis(tile));
 					if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, direction)) break;
 					if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, ReverseDiagDir(direction))) break;
-					return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
+					return CommandCost(EXPENSES_CONSTRUCTION, (_price.build_rail <<3));
 				}
 
 				case STATION_AIRPORT:
-					return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
+					return CommandCost(EXPENSES_CONSTRUCTION, (_price.build_rail <<3));
 
 				case STATION_TRUCK:
 				case STATION_BUS: {
@@ -3097,7 +3166,7 @@
 					if (IsDriveThroughStopTile(tile)) {
 						if (!AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, ReverseDiagDir(direction))) break;
 					}
-					return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
+					return CommandCost(EXPENSES_CONSTRUCTION, (_price.build_rail <<3));
 				}
 
 				default: break;
@@ -3253,10 +3322,10 @@
 				cp->source          = (CheckSavegameVersion(7) && _cargo_source == 0xFF) ? INVALID_STATION : _cargo_source;
 				cp->count           = GB(_waiting_acceptance, 0, 12);
 				cp->days_in_transit = _cargo_days;
-				cp->feeder_share    = _cargo_feeder_share;
+				cp->feeder_share[0] = _cargo_feeder_share;
 				cp->source_xy       = _cargo_source_xy;
 				cp->days_in_transit = _cargo_days;
-				cp->feeder_share    = _cargo_feeder_share;
+				cp->feeder_share[0] = _cargo_feeder_share;
 				SB(ge->acceptance_pickup, GoodsEntry::PICKUP, 1, 1);
 				ge->cargo.Append(cp);
 			}
Index: src/news_type.h
===================================================================
--- src/news_type.h	(revision 13683)
+++ src/news_type.h	(working copy)
@@ -42,6 +42,7 @@
 	NS_COMPANY_MERGER,   ///< NT_COMPANY_INFO (merger)
 	NS_COMPANY_BANKRUPT, ///< NT_COMPANY_INFO (bankrupt)
 	NS_COMPANY_NEW,      ///< NT_COMPANY_INFO (new company)
+	NS_COMPANY_SHARING,  ///< NT_COMPANY_INFO (change sharing)
 	NS_OPENCLOSE,        ///< NT_OPENCLOSE
 	NS_ECONOMY,          ///< NT_ECONOMY
 	NS_INDUSTRY_PLAYER,  ///< NT_INDUSTRY_PLAYER
Index: src/airport_gui.cpp
===================================================================
--- src/airport_gui.cpp	(revision 13683)
+++ src/airport_gui.cpp	(working copy)
@@ -39,7 +39,15 @@
 
 static void PlaceAirport(TileIndex tile)
 {
-	DoCommandP(tile, _selected_airport_type, _ctrl_pressed, CcBuildAirport, CMD_BUILD_AIRPORT | CMD_NO_WATER | CMD_MSG(STR_A001_CAN_T_BUILD_AIRPORT_HERE));
+	uint32 p2 = _ctrl_pressed;
+	SB(p2, 16, 16, INVALID_STATION); // no station to join
+
+	if (StationJoinerNeeded(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE)) {
+		CommandContainer cmd = {tile, _selected_airport_type, p2, CcBuildAirport, CMD_BUILD_AIRPORT | CMD_NO_WATER | CMD_MSG(STR_A001_CAN_T_BUILD_AIRPORT_HERE)};
+		ShowSelectStation(cmd, STATION_AIRPORT, true, true);
+	} else {
+		DoCommandP(tile, _selected_airport_type, p2, CcBuildAirport, CMD_BUILD_AIRPORT | CMD_NO_WATER | CMD_MSG(STR_A001_CAN_T_BUILD_AIRPORT_HERE));
+	}
 }
 
 
@@ -123,6 +131,7 @@
 		this->RaiseButtons();
 
 		delete FindWindowById(WC_BUILD_STATION, 0);
+		delete FindWindowById(WC_SELECT_STATION, 0);
 	}
 };
 
Index: src/ship_cmd.cpp
===================================================================
--- src/ship_cmd.cpp	(revision 13683)
+++ src/ship_cmd.cpp	(working copy)
@@ -41,6 +41,7 @@
 #include "settings_type.h"
 #include "order_func.h"
 #include "effectvehicle_func.h"
+#include "sharedinfrastructure.h"
 
 #include "table/strings.h"
 
@@ -342,6 +343,9 @@
 
 static void ShipArrivesAt(const Vehicle* v, Station* st)
 {
+	/* check station fee for shared harbours */
+	if (st->owner != v->owner) SharedStationFee(st->owner, v->index);
+
 	/* Check if station was ever visited before */
 	if (!(st->had_vehicle_of_type & HVOT_SHIP)) {
 		st->had_vehicle_of_type |= HVOT_SHIP;
@@ -764,7 +768,7 @@
 	/* The ai_new queries the vehicle cost before building the route,
 	 * so we must check against cheaters no sooner than now. --pasky */
 	if (!IsShipDepotTile(tile)) return CMD_ERROR;
-	if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
+	if (!IsTileOwner(tile, _current_player) && !SharedWaterDepots(tile, _current_player)) return CMD_ERROR;
 
 	unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_SHIP);
 
@@ -834,6 +838,8 @@
 		GetPlayer(_current_player)->num_engines[p1]++;
 	}
 
+	SharedDepotProvision(value, GetTileOwner(tile), flags);
+
 	return value;
 }
 
Index: src/newgrf_gui.cpp
===================================================================
--- src/newgrf_gui.cpp	(revision 13683)
+++ src/newgrf_gui.cpp	(working copy)
@@ -15,11 +15,16 @@
 #include "core/alloc_func.hpp"
 #include "string_func.h"
 #include "gfx_func.h"
+#include "settings_func.h"
+#include "widgets/dropdown_type.h"
 #include "gamelog.h"
 
 #include "table/strings.h"
 #include "table/sprites.h"
 
+#include "core/smallvec_type.hpp"
+
+
 /** Parse an integerlist string and set each found value
  * @param p the string to be parsed. Each element in the list is seperated by a
  * comma or a space character
@@ -253,7 +258,27 @@
 	_newgrf_add_dlg_widgets,
 };
 
+/* YUM WE LIKE GLOBALS OH YES */             
+typedef SmallVector<char *, 8> PresetList;
+extern PresetList _grf_preset_list;
 
+class DropDownListPresetItem : public DropDownListItem {
+public:
+	DropDownListPresetItem(int result) : DropDownListItem(result, false) {}
+
+	virtual ~DropDownListPresetItem() {}
+
+	virtual StringID String() const
+	{
+		return STR_EMPTY;
+	}
+
+	virtual void Draw(int x, int y, uint width, uint height, bool sel) const
+	{
+		DoDrawStringTruncated(_grf_preset_list[this->result], x + 2, y, sel ? TC_WHITE : TC_BLACK, x + width);
+	}
+};
+
 static void NewGRFConfirmationCallback(Window *w, bool confirmed);
 
 /**
@@ -264,7 +289,10 @@
 	enum ShowNewGRFStateWidgets {
 		SNGRFS_CLOSEBOX = 0,
 		SNGRFS_CAPTION,
-		SNGRFS_BACKGROUND,
+		SNGRFS_BACKGROUND1,
+		SNGRFS_PRESET_LIST,
+		SNGRFS_PRESET_SAVE,
+		SNGRFS_BACKGROUND2,
 		SNGRFS_ADD,
 		SNGRFS_REMOVE,
 		SNGRFS_MOVE_UP,
@@ -283,6 +311,8 @@
 	bool editable;         ///< is the window editable
 	bool show_params;      ///< are the grf-parameters shown in the info-panel
 	bool execute;          ///< on pressing 'apply changes' are grf changes applied immediately, or only list is updated
+	int query_widget;      ///< widget that opened a query
+	int preset;            ///< selected preset
 
 	NewGRFWindow(const WindowDesc *desc, bool editable, bool show_params, bool exec_changes, GRFConfig **config) : Window(desc, 0)
 	{
@@ -293,6 +323,7 @@
 		this->editable    = editable;
 		this->execute     = exec_changes;
 		this->show_params = show_params;
+		this->preset      = -1;
 
 		CopyGRFConfigList(&this->list, *config, false);
 
@@ -322,8 +353,12 @@
 		this->vscroll.cap = (this->widget[SNGRFS_FILE_LIST].bottom - this->widget[SNGRFS_FILE_LIST].top) / 14 + 1;
 		SetVScrollCount(this, i);
 
-		this->SetWidgetDisabledState(SNGRFS_ADD, !this->editable);
-		this->SetWidgetDisabledState(SNGRFS_APPLY_CHANGES, !this->editable);
+		this->SetWidgetsDisabledState(!this->editable,
+			SNGRFS_PRESET_LIST,
+			SNGRFS_ADD,
+			SNGRFS_APPLY_CHANGES,
+			WIDGET_LIST_END
+		);
 	}
 
 	virtual void OnPaint()
@@ -345,6 +380,12 @@
 			if (this->sel->IsOpenTTDBaseGRF()) this->DisableWidget(SNGRFS_REMOVE);
 		}
 
+		if (this->preset == -1) {
+			this->widget[SNGRFS_PRESET_LIST].data = STR_02BF_CUSTOM;
+		} else {
+			this->widget[SNGRFS_PRESET_LIST].data = BindCString(_grf_preset_list[this->preset]);
+		}
+
 		this->DrawWidgets();
 
 		/* Draw NewGRF list */
@@ -397,6 +438,27 @@
 	virtual void OnClick(Point pt, int widget)
 	{
 		switch (widget) {
+			case SNGRFS_PRESET_LIST: {
+				GetGRFPresetList();
+
+				DropDownList *list = new DropDownList();
+
+				/* Add 'None' option for clearing list */
+				list->push_back(new DropDownListStringItem(STR_NONE, -1, false));
+
+				for (uint i = 0; i < _grf_preset_list.Length(); i++) {
+					list->push_back(new DropDownListPresetItem(i));
+				}
+
+				ShowDropDownList(this, list, -1, SNGRFS_PRESET_LIST);
+				break;
+			}
+
+			case SNGRFS_PRESET_SAVE:
+				this->query_widget = widget;
+				ShowQueryString(STR_EMPTY, STR_NEWGRF_PRESET_SAVE_QUERY, 32, 100, this, CS_ALPHANUMERAL);
+				break;
+
 			case SNGRFS_ADD: // Add GRF
 				DeleteWindowByClass(WC_SAVELOAD);
 				new NewGRFAddWindow(&_newgrf_add_dlg_desc, &this->list);
@@ -421,6 +483,7 @@
 				}
 
 				this->sel = newsel;
+				this->preset = -1;
 				this->SetupNewGRFWindow();
 				this->SetDirty();
 				break;
@@ -438,6 +501,7 @@
 						break;
 					}
 				}
+				this->preset = -1;
 				this->SetDirty();
 				break;
 			}
@@ -454,6 +518,7 @@
 						break;
 					}
 				}
+				this->preset = -1;
 				this->SetDirty();
 				break;
 			}
@@ -487,6 +552,8 @@
 			case SNGRFS_SET_PARAMETERS: { // Edit parameters
 				if (this->sel == NULL) break;
 
+				this->query_widget = widget;
+
 				char buff[512];
 				GRFBuildParamList(buff, this->sel, lastof(buff));
 				ShowQueryString(BindCString(buff), STR_NEWGRF_PARAMETER_QUERY, 63, 250, this, CS_ALPHANUMERAL);
@@ -495,18 +562,48 @@
 		}
 	}
 
+	virtual void OnDropdownSelect(int widget, int index)
+	{
+		if (index == -1) {
+			ClearGRFConfigList(&this->list);
+			this->preset = -1;
+		} else {
+			GRFConfig *c = LoadGRFPresetFromConfig(_grf_preset_list[index]);
+
+			if (c != NULL) {
+				this->sel = NULL;
+				ClearGRFConfigList(&this->list);
+				this->list = c;
+				this->preset = index;
+			}
+		}
+
+		this->SetupNewGRFWindow();
+		this->SetDirty();
+	}
+
 	virtual void OnQueryTextFinished(char *str)
 	{
 		if (str == NULL) return;
 
-		/* Parse our new "int list" */
-		GRFConfig *c = this->sel;
-		c->num_params = parse_intlist(str, (int*)c->param, lengthof(c->param));
+		switch (this->query_widget) {
+			case SNGRFS_PRESET_SAVE:
+				SaveGRFPresetToConfig(str, this->list);
+				break;
 
-		/* parse_intlist returns -1 on error */
-		if (c->num_params == (byte)-1) c->num_params = 0;
+			case SNGRFS_SET_PARAMETERS: {
+				/* Parse our new "int list" */
+				GRFConfig *c = this->sel;
+				c->num_params = parse_intlist(str, (int*)c->param, lengthof(c->param));
 
-		this->SetDirty();
+				/* parse_intlist returns -1 on error */
+				if (c->num_params == (byte)-1) c->num_params = 0;
+
+				this->preset = -1;
+				this->SetDirty();
+				break;
+			}
+		}
 	}
 
 	virtual void OnResize(Point new_size, Point delta)
@@ -524,6 +621,7 @@
 
 	virtual void OnInvalidateData(int data = 0)
 	{
+		this->preset = -1;
 		this->SetupNewGRFWindow();
 	}
 };
@@ -532,23 +630,26 @@
 static const Widget _newgrf_widgets[] = {
 {   WWT_CLOSEBOX,  RESIZE_NONE, 10,   0,  10,   0,  13, STR_00C5,                    STR_018B_CLOSE_WINDOW },            // SNGRFS_CLOSEBOX
 {    WWT_CAPTION, RESIZE_RIGHT, 10,  11, 299,   0,  13, STR_NEWGRF_SETTINGS_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS },  // SNGRFS_CAPTION
-{      WWT_PANEL, RESIZE_RIGHT, 10,   0, 299,  14,  29, STR_NULL,                    STR_NULL },                         // SNGRFS_BACKGROUND
-{ WWT_PUSHTXTBTN,  RESIZE_NONE,  3,  10,  79,  16,  27, STR_NEWGRF_ADD,              STR_NEWGRF_ADD_TIP },               // SNGRFS_ADD
-{ WWT_PUSHTXTBTN,  RESIZE_NONE,  3,  80, 149,  16,  27, STR_NEWGRF_REMOVE,           STR_NEWGRF_REMOVE_TIP },            // SNGRFS_REMOVE
-{ WWT_PUSHTXTBTN,  RESIZE_NONE,  3, 150, 219,  16,  27, STR_NEWGRF_MOVEUP,           STR_NEWGRF_MOVEUP_TIP },            // SNGRFS_MOVE_UP
-{ WWT_PUSHTXTBTN, RESIZE_RIGHT,  3, 220, 289,  16,  27, STR_NEWGRF_MOVEDOWN,         STR_NEWGRF_MOVEDOWN_TIP },          // SNGRFS_MOVE_DOWN
-{     WWT_MATRIX,    RESIZE_RB, 10,   0, 287,  30,  99, 0x501,                       STR_NEWGRF_FILE_TIP },              // SNGRFS_FILE_LIST
-{  WWT_SCROLLBAR,   RESIZE_LRB, 10, 288, 299,  30,  99, 0x0,                         STR_0190_SCROLL_BAR_SCROLLS_LIST }, // SNGRFS_SCROLLBAR
-{      WWT_PANEL,   RESIZE_RTB, 10,   0, 299, 100, 212, STR_NULL,                    STR_NULL },                         // SNGRFS_NEWGRF_INFO
-{ WWT_PUSHTXTBTN,    RESIZE_TB, 10,   0, 143, 213, 224, STR_NEWGRF_SET_PARAMETERS,   STR_NULL },                         // SNGRFS_SET_PARAMETERS
-{ WWT_PUSHTXTBTN,   RESIZE_RTB, 10, 144, 287, 213, 224, STR_NEWGRF_APPLY_CHANGES,    STR_NULL },                         // SNGRFS_APPLY_CHANGES
-{  WWT_RESIZEBOX,  RESIZE_LRTB, 10, 288, 299, 213, 224, 0x0,                         STR_RESIZE_BUTTON },                // SNGRFS_RESIZE
+{      WWT_PANEL, RESIZE_RIGHT, 10,   0, 299,  14,  41, STR_NULL,                    STR_NULL },                         // SNGRFS_BACKGROUND1
+{   WWT_DROPDOWN, RESIZE_RIGHT,  3,  10, 219,  16,  27, STR_EMPTY,                   STR_NEWGRF_PRESET_LIST_TIP },       // SNGRFS_PRESET_LIST
+{ WWT_PUSHTXTBTN,    RESIZE_LR,  3, 220, 289,  16,  27, STR_NEWGRF_PRESET_SAVE,      STR_NEWGRF_PRESET_SAVE_TIP },       // SNGRFS_PRESET_SAVE
+{      WWT_PANEL, RESIZE_RIGHT, 10,   0, 299,  30,  45, STR_NULL,                    STR_NULL },                         // SNGRFS_BACKGROUND
+{ WWT_PUSHTXTBTN,  RESIZE_NONE,  3,  10,  79,  32,  43, STR_NEWGRF_ADD,              STR_NEWGRF_ADD_TIP },               // SNGRFS_ADD
+{ WWT_PUSHTXTBTN,  RESIZE_NONE,  3,  80, 149,  32,  43, STR_NEWGRF_REMOVE,           STR_NEWGRF_REMOVE_TIP },            // SNGRFS_REMOVE
+{ WWT_PUSHTXTBTN,  RESIZE_NONE,  3, 150, 219,  32,  43, STR_NEWGRF_MOVEUP,           STR_NEWGRF_MOVEUP_TIP },            // SNGRFS_MOVE_UP
+{ WWT_PUSHTXTBTN, RESIZE_RIGHT,  3, 220, 289,  32,  43, STR_NEWGRF_MOVEDOWN,         STR_NEWGRF_MOVEDOWN_TIP },          // SNGRFS_MOVE_DOWN
+{     WWT_MATRIX,    RESIZE_RB, 10,   0, 287,  46, 115, 0x501,                       STR_NEWGRF_FILE_TIP },              // SNGRFS_FILE_LIST
+{  WWT_SCROLLBAR,   RESIZE_LRB, 10, 288, 299,  46, 115, 0x0,                         STR_0190_SCROLL_BAR_SCROLLS_LIST }, // SNGRFS_SCROLLBAR
+{      WWT_PANEL,   RESIZE_RTB, 10,   0, 299, 116, 228, STR_NULL,                    STR_NULL },                         // SNGRFS_NEWGRF_INFO
+{ WWT_PUSHTXTBTN,    RESIZE_TB, 10,   0, 143, 229, 240, STR_NEWGRF_SET_PARAMETERS,   STR_NULL },                         // SNGRFS_SET_PARAMETERS
+{ WWT_PUSHTXTBTN,   RESIZE_RTB, 10, 144, 287, 229, 240, STR_NEWGRF_APPLY_CHANGES,    STR_NULL },                         // SNGRFS_APPLY_CHANGES
+{  WWT_RESIZEBOX,  RESIZE_LRTB, 10, 288, 299, 229, 240, 0x0,                         STR_RESIZE_BUTTON },                // SNGRFS_RESIZE
 { WIDGETS_END },
 };
 
 /* Window definition of the manage newgrfs window */
 static const WindowDesc _newgrf_desc = {
-	WDP_CENTER, WDP_CENTER, 300, 225, 300, 225,
+	WDP_CENTER, WDP_CENTER, 300, 241, 300, 241,
 	WC_GAME_OPTIONS, WC_NONE,
 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
 	_newgrf_widgets,
Index: src/order_cmd.cpp
===================================================================
--- src/order_cmd.cpp	(revision 13683)
+++ src/order_cmd.cpp	(working copy)
@@ -27,6 +27,7 @@
 #include "vehicle_func.h"
 #include "oldpool_func.h"
 #include "depot_base.h"
+#include "sharedinfrastructure.h"
 
 #include "table/strings.h"
 
@@ -342,7 +343,7 @@
 
 			const Station *st = GetStation(new_order.GetDestination());
 
-			if (st->owner != OWNER_NONE && !CheckOwnership(st->owner)) {
+			if (st->owner != OWNER_NONE && ((!CheckOwnership(st->owner))&&!SharedStation(st->xy,v->owner,v->type))) {
 				return CMD_ERROR;
 			}
 
@@ -397,18 +398,18 @@
 
 					const Station *st = GetStation(new_order.GetDestination());
 
-					if (!CheckOwnership(st->owner) ||
-							!(st->facilities & FACIL_AIRPORT) ||
-							st->Airport()->nof_depots == 0 ||
-							!CanAircraftUseStation(v->engine_type, st)) {
-						return CMD_ERROR;
-					}
-				} else {
+				if (((!CheckOwnership(st->owner))&&(!SharedAirports(st->xy,v->owner))) ||
+						!(st->facilities & FACIL_AIRPORT) ||
+						st->Airport()->nof_depots == 0 ||
+						!CanAircraftUseStation(v->engine_type, st)) {
+					return CMD_ERROR;
+				}
+			} else {
 					if (!IsValidDepotID(new_order.GetDestination())) return CMD_ERROR;
 
 					const Depot *dp = GetDepot(new_order.GetDestination());
 
-					if (!CheckOwnership(GetTileOwner(dp->xy))) return CMD_ERROR;
+				if ((!CheckOwnership(GetTileOwner(dp->xy)))&&(!SharedDepotVehicleType(dp->xy,v->owner,v->type))) return CMD_ERROR;
 
 					switch (v->type) {
 						case VEH_TRAIN:
@@ -443,7 +444,7 @@
 			if (!IsValidWaypointID(new_order.GetDestination())) return CMD_ERROR;
 			const Waypoint *wp = GetWaypoint(new_order.GetDestination());
 
-			if (!CheckOwnership(GetTileOwner(wp->xy))) return CMD_ERROR;
+			if ((!CheckOwnership(GetTileOwner(wp->xy)))&&(!SharedTracks(wp->xy,v->owner))) return CMD_ERROR;
 
 			/* Order flags can be any of the following for waypoints:
 			 * [non-stop]
Index: src/window_type.h
===================================================================
--- src/window_type.h	(revision 13683)
+++ src/window_type.h	(working copy)
@@ -94,6 +94,10 @@
 	WC_BUILD_SIGNAL,
 	WC_COMPANY_PASSWORD_WINDOW,
 	WC_OSK,
+	WC_SHARED_INFRASTRUCTURE,
+ 	WC_MOVE_PLAYER,
+ 	WC_MUTE_PLAYER,
+ 	WC_SELECT_STATION,
 
 	WC_INVALID = 0xFFFF
 };
Index: src/sharedinfrastructure.cpp
===================================================================
--- src/sharedinfrastructure.cpp	(revision 0)
+++ src/sharedinfrastructure.cpp	(revision 0)
@@ -0,0 +1,941 @@
+/* $Id: sharedinfrastructure.cpp $ */
+
+/** @file sharedinfrastructure.cpp
+ * This file deals with using shared infrastructures and relative cost/income */
+
+#include "stdafx.h"
+#include "openttd.h"
+#include "bridge_map.h"
+#include "debug.h"
+#include "functions.h"
+#include "landscape.h"
+#include "npf.h"
+#include "aystar.h"
+#include "pathfind.h"
+#include "station_map.h"
+#include "tile_type.h"
+#include "depot_base.h"
+#include "tunnel_map.h"
+#include "network/network.h"
+#include "water_map.h"
+#include "sharedinfrastructure.h"
+#include "variables.h"
+#include "settings_type.h"
+#include "player_func.h"
+#include "player_base.h"
+#include "vehicle_base.h"
+#include "cargotype.h"
+#include "newgrf_cargo.h"
+#include "aircraft.h"
+#include "news_func.h"
+#include "strings_func.h"
+#include "station_base.h"
+#include "depot_map.h"
+#include "window_func.h"
+#include "command_func.h"
+#include "vehicle_func.h"
+#include "train.h"
+
+#include "table/strings.h"
+
+/* variables for player's shared infrastructure GUI */
+bool _si_railway_tracks;
+bool _si_railway_stations;
+bool _si_railway_depots;
+bool _si_airports;
+bool _si_road_depots;
+bool _si_road_stops;
+bool _si_water_depots;
+bool _si_harbours;
+uint16 _si_tontile_cost;
+uint16 _si_landing_fee;
+uint8 _si_provision;
+uint8 _si_road_stops_fee;
+uint8 _si_harbours_fee;
+
+/** Fonctions to check if vehicle can enter tiles
+ * @param tile Tile to enter
+ * @param owner Vehicle's owner
+ */
+
+bool SharedTracks(TileIndex tile, Owner owner)
+{
+	Owner player = GetTileOwner(tile);
+	if (!IsValidPlayer (player)) return true;  // no owner ? just go then, and don't assert on next line
+	Player *p = GetPlayer(player);
+
+	return _settings_game.sharing.shared_player_level ? p->shared_railway_tracks[0] : _settings_game.sharing.shared_railway_tracks;
+}
+
+bool SharedRailwayStations(TileIndex tile, Owner owner)
+{
+	Owner player = GetTileOwner(tile);
+	if (!IsValidPlayer (player)) return true;
+	Player *p = GetPlayer(player);
+	return _settings_game.sharing.shared_player_level ? p->shared_railway_stations[0] : _settings_game.sharing.shared_railway_stations;
+}
+
+bool SharedRailwayDepots(TileIndex tile, Owner owner)
+{
+	Owner player = GetTileOwner(tile);
+	if (!IsValidPlayer (player)) return true;
+	Player *p = GetPlayer(player);
+	return _settings_game.sharing.shared_player_level ? p->shared_railway_depots[0] : _settings_game.sharing.shared_railway_depots;
+}
+
+bool SharedRoadDepots(TileIndex tile, Owner owner)
+{
+	Owner player = GetTileOwner(tile);
+	if (!IsValidPlayer (player)) return true;
+	Player *p = GetPlayer(player);
+	return _settings_game.sharing.shared_player_level ? p->shared_road_depots[0] : _settings_game.sharing.shared_road_depots;
+}
+
+bool SharedRoadStops(TileIndex tile, Owner owner)
+{
+	Owner player = GetTileOwner(tile);
+	if (!IsValidPlayer (player)) return true;
+	Player *p = GetPlayer(player);
+	return _settings_game.sharing.shared_player_level ? p->shared_road_stops[0] : _settings_game.sharing.shared_road_stops;
+}
+
+bool SharedWaterDepots(TileIndex tile, Owner owner)
+{
+	Owner player = GetTileOwner(tile);
+	if (!IsValidPlayer (player)) return true;
+	Player *p = GetPlayer(player);
+	return _settings_game.sharing.shared_player_level ? p->shared_water_depots[0] : _settings_game.sharing.shared_water_depots;
+}
+
+bool SharedHarbours(TileIndex tile, Owner owner)
+{
+	Owner player = GetTileOwner(tile);
+	if (!IsValidPlayer (player)) return true;
+	Player *p = GetPlayer(player);
+	return _settings_game.sharing.shared_player_level ? p->shared_harbours[0] : _settings_game.sharing.shared_harbours;
+}
+
+bool SharedAirports(TileIndex tile, Owner owner)
+{
+	Owner player = GetTileOwner(tile);
+	if (!IsValidPlayer (player)) return true;
+	Player *p = GetPlayer(player);
+	return _settings_game.sharing.shared_player_level ? p->shared_airports[0] : _settings_game.sharing.shared_airports;
+}
+
+bool SharedDepotTransport(TileIndex tile, Owner owner, TransportType type)
+{
+  switch (type) {
+	  case TRANSPORT_RAIL: return SharedRailwayDepots(tile,owner);
+			       break;
+	  case TRANSPORT_ROAD: return SharedRoadDepots(tile,owner);
+			       break;
+	  case TRANSPORT_WATER: return SharedWaterDepots(tile,owner);
+				break;
+	  default:
+		  return false;
+		  break;
+  }
+  return false;
+}
+
+bool SharedDepotVehicleType(TileIndex tile, Owner owner, VehicleType type)
+{
+  switch (type) {
+	  case VEH_TRAIN: return SharedRailwayDepots(tile,owner);
+			       break;
+	  case VEH_ROAD: return SharedRoadDepots(tile,owner);
+			       break;
+	  case VEH_SHIP: return SharedWaterDepots(tile,owner);
+				break;
+	  case VEH_AIRCRAFT: return SharedAirports(tile,owner);
+				break;
+	  default: return 0;
+  }
+  return 0;
+}
+
+
+bool SharedStation(TileIndex tile, Owner owner, VehicleType type)
+{
+  switch (type) {
+	  case VEH_TRAIN: return SharedRailwayStations(tile,owner);
+			       break;
+	  case VEH_ROAD: return SharedRoadStops(tile,owner);
+			       break;
+	  case VEH_SHIP: return SharedHarbours(tile,owner);
+				break;
+	  case VEH_AIRCRAFT: return SharedAirports(tile,owner);
+				break;
+	  default: return 0;
+  }
+  return 0;
+}
+
+/** Calculate provision for action in shared depots.
+ * @param cost Command cost
+ * @param owner Depot owner
+ * @param flags Command flag
+ */
+void SharedDepotProvision(CommandCost cost, Owner owner, uint32 flags)
+{	
+	if ((_current_player != owner) && (!(flags & DC_QUERY_COST)) && (flags & DC_EXEC)) {
+	  	PlayerByte curr = _current_player;
+		if (IsValidPlayer (owner)) {
+			Player *p = GetPlayer(owner);
+
+			uint16 provision_percent = _settings_game.sharing.shared_player_level ? p->shared_provision[0] : _settings_game.sharing.shared_provision;
+			OverflowSafeInt64 provision = (cost.GetCost() * (int64)provision_percent) / 100;
+
+			_current_player = owner;
+			SubtractMoneyFromPlayer(CommandCost(EXPENSES_SHARED_INF_INC,-provision));
+
+			_current_player = curr;
+			SubtractMoneyFromPlayer(CommandCost(EXPENSES_SHARED_INF_RUN,provision));
+		}
+	}
+}
+
+/** Fonctions to activate/desactivate simultaneously railway tracks and stations sharing.
+ * used in patch setting menu
+ */
+int32 SettingsEnableSharedRailwayStations(int32 p1)
+{
+  GameSettings *ptc = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings_game;
+  if(p1)
+    ptc->sharing.shared_railway_tracks=1;
+  return 0;
+}
+
+int32 SettingsEnableSharedRailwayTracks(int32 p1)
+{
+  GameSettings *ptc = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings_game;
+  if(!p1)
+  {
+  	 ptc->sharing.shared_railway_stations=0;
+  	 ptc->sharing.shared_railway_depots=0;
+  }
+  return 0;
+}
+
+/** Calculate track sharing cost & income for all players
+ * called each month
+ */
+void SharedTracksPayment()
+{	
+	Vehicle *v;
+	Player *p;
+	OverflowSafeInt64 tontile_total_income[MAX_PLAYERS]={ 0 };
+	OverflowSafeInt64 tontile_total_cost[MAX_PLAYERS]={ 0 };
+	
+	FOR_ALL_VEHICLES(v) {
+		PlayerID old_player = _current_player;
+		FOR_ALL_PLAYERS(p) {
+			OverflowSafeInt64 cost = 0;
+			if (v->shared_tontiles[p->index] > 0) {
+				uint16 ton_cost = _settings_game.sharing.shared_player_level ? p->shared_tontile_cost[0] : _settings_game.sharing.shared_tontile_cost;
+				cost = max (((v->shared_tontiles[p->index] * ton_cost) / 1000), (OverflowSafeInt64)ton_cost);
+
+				v->profit_this_year -= cost << 8;
+
+				_current_player = v->owner;
+				SubtractMoneyFromPlayer(CommandCost(EXPENSES_SHARED_INF_RUN,cost));
+				tontile_total_cost[v->owner]+=cost;
+
+				_current_player = p->index;
+				SubtractMoneyFromPlayer(CommandCost(EXPENSES_SHARED_INF_INC,-cost));
+				tontile_total_income[p->index]+=cost;
+
+				v->shared_tontiles[p->index] = 0;
+			}
+		}
+		_current_player = old_player;
+	}
+
+	PlayerID old_player = _current_player;
+	FOR_ALL_PLAYERS(p) {
+		/* Show total shared tracks cost & income animation above HQ */
+		if (p->location_of_house != 0) {
+			_current_player = p->index;
+			TileIndex tile = p->location_of_house;
+			uint hq_x = TileX(tile) * 16;
+			uint hq_y = TileY(tile) * 16;
+			uint hq_z= GetSlopeZ(TileX(tile), TileX(tile)) + 80; // show animation above HQ, not inside.
+			if (tontile_total_income[p->index] > 0)
+				ShowCostOrIncomeAnimation( hq_x, hq_y, hq_z, -tontile_total_income[p->index]);
+			if (tontile_total_cost[p->index] > 0)
+				ShowCostOrIncomeAnimation( hq_x, hq_y + 10 , hq_z, tontile_total_cost[p->index]); // show cost under income
+		}
+		_current_player = old_player;
+	}
+}
+
+/** Calculate station entrance fee for vehicle
+ * @param station_owner Station owner
+ * @param vehicle_owner Vehicle owner
+ * @param cargo_capacity maximum cargo of vehicle
+ */
+void SharedStationFee(Owner station_owner, VehicleID vehicle)
+{	
+	PlayerID old_player = _current_player;	
+	if (IsValidPlayer (station_owner)) {
+		Player *p = GetPlayer(station_owner);
+		Vehicle *v = GetVehicle(vehicle);
+		uint16 ton_cost = 0, cargo_capacity = 0;
+		const AircraftVehicleInfo *avi;
+
+		switch (v->type) {
+			case VEH_TRAIN:
+				break;
+			case VEH_ROAD:
+				/* count 10 passengers for 1 ton of cargo */
+				cargo_capacity = (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) ? (v->cargo_cap / 10) : v->cargo_cap;
+				ton_cost = _settings_game.sharing.shared_player_level ? p->shared_road_stops_fee[0] : _settings_game.sharing.shared_road_stops_fee;
+				break;
+			case VEH_SHIP: 
+				cargo_capacity = v->cargo_cap;
+				ton_cost = _settings_game.sharing.shared_player_level ? p->shared_harbours_fee[0] : _settings_game.sharing.shared_harbours_fee;
+				break;
+			case VEH_AIRCRAFT:
+				/* count cargo capacity relative to goods */
+				avi = AircraftVehInfo(v->engine_type);
+				cargo_capacity = AircraftDefaultCargoCapacity(CT_GOODS, avi);
+				ton_cost = _settings_game.sharing.shared_player_level ? p->shared_landing_fee[0] : _settings_game.sharing.shared_landing_fee;
+				break;
+			default: break;
+		}
+
+		OverflowSafeInt64 station_fee = (cargo_capacity * ton_cost);
+	
+		_current_player = station_owner;
+		SubtractMoneyFromPlayer(CommandCost(EXPENSES_SHARED_INF_INC, -station_fee));
+	
+		_current_player = v->owner;
+		SubtractMoneyFromPlayer(CommandCost(EXPENSES_SHARED_INF_RUN, station_fee));
+
+		_current_player = old_player;
+
+		if (station_fee > 0) {
+			/* remove station fee from vehicle profit */
+			v->profit_this_year -= station_fee << 8;
+
+			/** show vehicle cost animation for every player
+			 * (do not show it as income animation, even for station owner
+			 * as it can be confusing)
+			 */
+			ShowCostOrIncomeAnimation(v->x_pos, v->y_pos + 10 , v->z_pos, station_fee);
+		}
+	}
+}
+
+/* return closing infrastructure as bitmask */
+uint GetSharedCloseBits(PlayerID player)
+{
+	Player *p = GetPlayer(player);
+	uint close_bits = 0;
+	if ((p->shared_railway_tracks[0]) && !(p->shared_railway_tracks[1])) close_bits |= SHARED_RAILWAY_TRACKS;
+	if ((p->shared_railway_stations[0]) && !(p->shared_railway_stations[1])) close_bits |= SHARED_RAILWAY_STATIONS;
+	if ((p->shared_railway_depots[0]) && !(p->shared_railway_depots[1])) close_bits |= SHARED_RAILWAY_DEPOTS;
+	if ((p->shared_airports[0]) && !(p->shared_airports[1])) close_bits |= SHARED_AIRPORTS;
+	if ((p->shared_road_depots[0]) && !(p->shared_road_depots[1])) close_bits |= SHARED_ROAD_DEPOTS;
+	if ((p->shared_road_stops[0]) && !(p->shared_road_stops[1])) close_bits |= SHARED_ROAD_STOPS;
+	if ((p->shared_water_depots[0]) && !(p->shared_water_depots[1])) close_bits |= SHARED_WATER_DEPOTS;
+	if ((p->shared_harbours[0]) && !(p->shared_harbours[1])) close_bits |= SHARED_HARBOURS;
+	return close_bits;
+}
+
+/* set player sharing settings at end of activation delay */
+void SharedSettingDelay()
+{	
+	Player *p;
+	uint close_bits = 0;
+	
+	FOR_ALL_PLAYERS(p) {
+		switch (p->shared_change_months) {
+			case 0:
+				break;
+
+			case 1:
+				/* get closing infrastructure(s) */
+				close_bits = GetSharedCloseBits(p->index);
+				/* remove vehicle from closing infrastructure(s) */
+				OnSharedClose(p->index, close_bits);
+				/* time to change settings ! */
+				p->shared_railway_tracks[0] = p->shared_railway_tracks[1];
+				p->shared_railway_stations[0] = p->shared_railway_stations[1];
+				p->shared_railway_depots[0] = p->shared_railway_depots[1];
+				p->shared_tontile_cost[0] = p->shared_tontile_cost[1];
+				p->shared_road_stops_fee[0] = p->shared_road_stops_fee[1];
+				p->shared_harbours_fee[0] = p->shared_harbours_fee[1];
+				p->shared_airports[0] = p->shared_airports[1];
+				p->shared_landing_fee[0] = p->shared_landing_fee[1];
+				p->shared_road_depots[0] = p->shared_road_depots[1];
+				p->shared_road_stops[0] = p->shared_road_stops[1];
+				p->shared_water_depots[0] = p->shared_water_depots[1];
+				p->shared_harbours[0] = p->shared_harbours[1];
+				p->shared_provision[0] = p->shared_provision[1];
+
+				p->shared_change_months = 0;
+				break;
+
+			default :
+				p->shared_change_months--;
+				break;
+		}
+	}
+}
+
+/** Change player shared bool setting.
+ * @param tile unused
+ * @param flags unused
+ * @param p1 packed new boolean values
+ * @param p2 unused
+ */
+CommandCost CmdSetSharedBoolValues(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
+{
+	Player *p = GetPlayer(_current_player);
+
+	/* fix : do not send news twice if values are already updated */
+	uint32 check = (uint)p->shared_railway_tracks[1] | (uint)p->shared_railway_stations[1] << 1 | (uint)p->shared_railway_depots[1] << 2
+		 | (uint)p->shared_airports[1] << 3 | (uint)p->shared_road_depots[1] << 4 | (uint)p->shared_road_stops[1] << 5
+		 | (uint)p->shared_water_depots[1] << 6 | (uint)p->shared_harbours[1] << 7;
+	
+	/* set new value */
+	p->shared_railway_tracks[1]= HasBit(p1, 0);
+	p->shared_railway_stations[1]= HasBit(p1, 1);
+	p->shared_railway_depots[1]= HasBit(p1, 2);
+	p->shared_airports[1]= HasBit(p1, 3);
+	p->shared_road_depots[1]= HasBit(p1, 4);
+	p->shared_road_stops[1]= HasBit(p1, 5);
+	p->shared_water_depots[1]= HasBit(p1, 6);
+	p->shared_harbours[1]= HasBit(p1, 7);
+
+	/* reset timer for setting sharing value */
+	p->shared_change_months = _settings_game.sharing.shared_delay;
+
+	/* immediatly apply setting if patch delay is set to 0 */
+	if (_settings_game.sharing.shared_delay == 0) {
+		/* get closing infrastructure and remove vehicle */
+		if (check != p1) {
+			uint close_bits = GetSharedCloseBits(p->index);
+			OnSharedClose(p->index, close_bits);
+		}
+		/* update settings */
+		p->shared_railway_tracks[0]= HasBit(p1, 0);
+		p->shared_railway_stations[0]= HasBit(p1, 1);
+		p->shared_railway_depots[0]= HasBit(p1, 2);
+		p->shared_airports[0]= HasBit(p1, 3);
+		p->shared_road_depots[0]= HasBit(p1, 4);
+		p->shared_road_stops[0]= HasBit(p1, 5);
+		p->shared_water_depots[0]= HasBit(p1, 6);
+		p->shared_harbours[0]= HasBit(p1, 7);
+	}
+
+	/* send a news message to all players about this change */
+	if (check != p1) {
+		TileIndex t_news = p->location_of_house > 0 ? p->location_of_house : p->last_build_coordinate;
+		SetDParam(0, p->index);
+		SetDParam(1, p->index);
+		AddNewsItem(STR_SHARED_CHANGE_BOOL_VALUE,
+			NS_COMPANY_SHARING,
+			t_news,
+			0);
+	}
+
+	return CommandCost();
+}
+
+/** Change player shared int setting.
+ * @param tile unused
+ * @param flags unused
+ * @param p1 packed new int values (tontile_cost, road_stops_fee, harbours_fee)
+ * @param p2 packed new int values (landing_fee, depot_provision)
+ */
+CommandCost CmdSetSharedIntValues(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
+{
+	Player *p = GetPlayer(_current_player);
+
+	/* fix : do not send news twice if values are already updated */
+	uint32 check = p->shared_tontile_cost[1] | p->shared_road_stops_fee[1] << 16 | p->shared_harbours_fee[1] << 24;
+	uint32 check2 = p->shared_landing_fee[1] | p->shared_provision[1] << 16;
+
+	/* set new value from p1 */
+	p->shared_tontile_cost[1] = GB(p1, 0, 16);
+	p->shared_road_stops_fee[1] = GB(p1, 16, 8);
+	p->shared_harbours_fee[1] = GB(p1, 24, 8);
+	/* set new value from p2 */
+	p->shared_landing_fee[1] = GB(p2, 0, 16);
+	p->shared_provision[1] = GB(p2, 16, 8);
+
+	/* reset timer for setting sharing value */
+	p->shared_change_months = _settings_game.sharing.shared_delay;
+
+	/* immediatly apply setting if patch delay is set to 0 */
+	if (_settings_game.sharing.shared_delay == 0) {
+		p->shared_tontile_cost[0] = GB(p1, 0, 16);
+		p->shared_road_stops_fee[0] = GB(p1, 16, 8);
+		p->shared_harbours_fee[0] = GB(p1, 24, 8);
+		p->shared_landing_fee[0] = GB(p2, 0, 16);
+		p->shared_provision[0] = GB(p2, 16, 8);
+	}
+
+	/* send a news message to all players about this change */
+	if (check != p1 || check2 != p2) {
+		TileIndex t_news = p->location_of_house > 0 ? p->location_of_house : p->last_build_coordinate;
+		SetDParam(0, p->index);
+		SetDParam(1, p->index);
+		AddNewsItem(STR_SHARED_CHANGE_INT_VALUE,
+			NS_COMPANY_SHARING,
+			t_news,
+			0);
+	}
+
+	return CommandCost();
+}
+
+/* borrowed */
+static const byte _vehicle_initial_x_fract[4] = {10, 8, 4,  8};
+static const byte _vehicle_initial_y_fract[4] = { 8, 4, 8, 10};
+static void TrainMovedChangeSignals(TileIndex tile, DiagDirection dir)
+{
+	if (IsTileType(tile, MP_RAILWAY) &&
+			GetRailTileType(tile) == RAIL_TILE_SIGNALS) {
+		TrackdirBits tracks = TrackBitsToTrackdirBits(GetTrackBits(tile)) & DiagdirReachesTrackdirs(dir);
+		Trackdir trackdir = FindFirstTrackdir(tracks);
+		UpdateSignalsOnSegment(tile, TrackdirToExitdir(trackdir), GetTileOwner(tile));
+	}
+}
+
+bool SharedCloseDepotTeleport (VehicleID vehicle, DepotID depot)
+{
+	if (IsValidDepotID(depot)) {
+		Vehicle *v = GetVehicle(vehicle);
+		Depot *d = GetDepot(depot);
+		/* max train lenght = 100 */ 
+		TileIndex old_tile[100];
+		DiagDirection old_dir[100];
+		uint counter;
+		uint x;
+		uint y;
+		switch (v->type) {
+			case VEH_TRAIN:
+				//old_tile[] = v->tile;
+				//old_dir[] = DirToDiagDir(v->direction);
+				counter = 0;
+				for (; v != NULL; v = GetNextVehicle(v)) {					
+					old_tile[counter] = v->tile;
+					old_dir[counter] = DirToDiagDir(v->direction);
+					counter++;
+
+					DiagDirection dir = GetRailDepotDirection(d->xy);
+					MarkSingleVehicleDirty(v);
+					v->direction = DiagDirToDir(dir);
+					v->tile = d->xy;
+					x = TileX(d->xy) * TILE_SIZE | _vehicle_initial_x_fract[dir];
+					y = TileY(d->xy) * TILE_SIZE | _vehicle_initial_y_fract[dir];
+					v->x_pos = x;
+					v->y_pos = y;
+					v->z_pos = GetSlopeZ(x, y);
+					v->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL;
+					v->u.rail.track = TRACK_BIT_DEPOT;
+					v->cur_speed = 0;
+
+					DEBUG (misc, 4, "3- Teleport v %d in depot %d", v->index, d->index);
+				}
+				/* now that vehicle is removed, clear signal */
+				for (uint i = 0; i < counter; i++) {
+					DEBUG(misc, 4, "3- update signal (dir : %d) at tile %d,%d", old_dir[i], TileX(old_tile[i]), TileY(old_tile[i]) );
+					if (i != counter) {
+						TrainMovedChangeSignals(old_tile[i], old_dir[i]);
+						//UpdateSignalsOnSegment(old_tile[i], old_dir[i], GetTileOwner(old_tile[i]));
+					} else {
+						//UpdateSignalsOnSegment(old_tile[i], ReverseDiagDir(old_dir[i]), GetTileOwner(old_tile[i]));
+						TrainMovedChangeSignals(old_tile[i], ReverseDiagDir(old_dir[i]));
+					}
+				}
+				break;
+			case VEH_ROAD:
+				MarkSingleVehicleDirty(v);
+				v->tile = d->xy;
+				x = TileX(d->xy) * TILE_SIZE + TILE_SIZE / 2;
+				y = TileY(d->xy) * TILE_SIZE + TILE_SIZE / 2;
+				v->x_pos = x;
+				v->y_pos = y;
+				v->z_pos = GetSlopeZ(x, y);
+				v->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL;
+				v->u.road.state = RVSB_IN_DEPOT;	
+				v->cur_speed = 0;
+				DEBUG (misc, 4, "3- Teleport v %d in depot %d", v->index, d->index);
+				InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
+				break;
+			case VEH_SHIP:
+				v->tile = d->xy;
+				x = TileX(d->xy) * TILE_SIZE + TILE_SIZE / 2;
+				y = TileY(d->xy) * TILE_SIZE + TILE_SIZE / 2;
+				v->x_pos = x;
+				v->y_pos = y;
+				v->z_pos = GetSlopeZ(x, y);
+				v->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL;
+				v->u.ship.state = TRACK_BIT_DEPOT;	
+				v->cur_speed = 0;
+				DEBUG (misc, 4, "3- Teleport v %d in depot %d", v->index, d->index);
+				InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
+				break;
+			default: break;
+		}
+		return true;
+	}
+	return false;
+}
+
+bool SharedCloseHangarTeleport (VehicleID vehicle, StationID station)
+{
+	if (IsValidStationID(station)) {
+		Vehicle *v = GetVehicle(vehicle);
+		Station *st = GetStation(station);
+		const AirportFTAClass *apc = st->Airport();
+		uint x;
+		uint y;
+
+		/* get tile of first hangar */
+		TileIndex tile = st->airport_tile + ToTileIndexDiff(apc->airport_depots[0]);
+		
+		/* we need to handle shadow & rotor */
+		Vehicle *u = v->next;
+
+		v->direction = DIR_SE;
+		v->tile = tile;
+
+		x = TileX(tile) * TILE_SIZE + 5;
+		y = TileY(tile) * TILE_SIZE + 3;
+
+		v->x_pos = u->x_pos = x;
+		v->y_pos = u->y_pos = y;
+		u->z_pos = GetSlopeZ(x, y);
+		v->z_pos = u->z_pos + 1;
+
+		v->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL;
+		u->vehstatus |= VS_HIDDEN;
+		v->UpdateDeltaXY(INVALID_DIR);
+		u->UpdateDeltaXY(INVALID_DIR);
+
+		/* set v position to first hangar */
+		v->u.air.pos = apc->layout[0].position;
+		v->u.air.state = HANGAR;
+		v->u.air.previous_pos = v->u.air.pos;
+		v->u.air.targetairport = GetStationIndex(tile);
+
+		/* handle rotor */
+		u = u->Next();
+		if (u != NULL) {
+			u->vehstatus |= VS_HIDDEN;
+			u->cur_speed = 0;
+		}
+		InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
+		return true;
+	}
+	return false;
+}
+
+DepotID SharedCloseGetFirstDepot (PlayerID old_player, VehicleID vehicle, bool just_old_player)
+{
+	Vehicle *v = GetVehicle(vehicle);
+	Depot *depot;
+	DEBUG (misc, 4, "1- Starting search of depot for v %d", v->index);
+	FOR_ALL_DEPOTS(depot) {
+		bool owner_check = just_old_player ? (GetTileOwner(depot->xy) == old_player) : (GetTileOwner(depot->xy) != old_player);
+		switch (v->type) {
+			case VEH_TRAIN:
+				/* and check rail type */
+				if (owner_check && IsRailDepotTile(depot->xy) &&
+					(IsFreeWagon(v) || IsFrontEngine(v)) &&
+					(HasBit(v->u.rail.compatible_railtypes, GetRailType(depot->xy)))) {
+					DEBUG (misc, 4, "1- Check if v %d can access depot %d", v->index, depot->index);
+					if (SharedRailwayDepots(depot->xy, v->owner)) return depot->index;
+				}
+				break;
+			case VEH_ROAD:
+				/* tram use special depot */
+				if (owner_check && IsRoadDepotTile(depot->xy) &&
+					(HasTileRoadType(depot->xy, ROADTYPE_TRAM) == HasBit(EngInfo(v->engine_type)->misc_flags, EF_ROAD_TRAM))) {
+					DEBUG (misc, 4, "1- Check if v %d can access depot %d", v->index, depot->index);
+					if (SharedRoadDepots(depot->xy, v->owner)) return depot->index;
+				}
+				break;
+			case VEH_SHIP:
+				/* tram use special depot */
+				if (owner_check && IsShipDepotTile(depot->xy)) {
+					DEBUG (misc, 4, "1- Check if v %d can access depot %d", v->index, depot->index);
+					if (SharedWaterDepots(depot->xy, v->owner)) return depot->index;
+				}
+				break;
+			default: break;
+		}
+	}
+	DEBUG (misc, 4, "1- No valid depot for v %d", v->index);
+	return INVALID_DEPOT;
+}
+
+StationID SharedCloseGetFirstHangar(PlayerID old_player, VehicleID vehicle, bool check_player)
+{	
+	Vehicle *v = GetVehicle(vehicle);
+	Station *st;
+	DEBUG (misc, 4, "1- Starting search of hangar for v %d", v->index);
+	FOR_ALL_STATIONS(st) {
+		if (((st->owner == old_player) || (!SharedAirports(st->xy, v->owner))) || !(st->facilities & FACIL_AIRPORT)) continue;
+		DEBUG (misc, 4, "1- Check if airport %d is compatible with v %d", st->index, v->owner);
+		const AirportFTAClass *afc = st->Airport();
+		if (afc->flags & (v->subtype == AIR_HELICOPTER ? AirportFTAClass::HELICOPTERS : AirportFTAClass::AIRPLANES) &&
+			afc->nof_depots > 0) return st->index;
+	}
+	return INVALID_STATION;
+}
+
+void UpdateSharedOnRemove(VehicleID vehicle)
+{
+	Vehicle *v = GetVehicle(vehicle);
+	switch (v->type) {
+		case VEH_TRAIN:
+			if (v->current_order.IsType(OT_LOADING)) {
+				DEBUG (misc, 4, "2- v %d was loading, clear station", v->index);
+				v->LeaveStation();
+				v->load_unload_time_rem = 0;
+			}
+			break;
+		case VEH_ROAD:
+			if (v->current_order.IsType(OT_LOADING)) {
+				DEBUG (misc, 4, "2- v %d was loading, clear station", v->index);
+				v->LeaveStation();
+			}
+			ClearSlot(v);
+			break;
+		case VEH_SHIP:
+			/* ship does not block station */
+			break;			
+		case VEH_AIRCRAFT:
+			if (v->u.air.state != FLYING && v->u.air.state != HANGAR) {
+				DEBUG (misc, 4, "2- v %d was on ground, clear station", v->index);
+				Station *old_st = GetStation (v->u.air.targetairport);
+				const AirportFTAClass *apc = old_st->Airport();
+				CLRBITS(old_st->airport_flags, apc->layout[v->u.air.pos].block);
+			}
+			break;
+		default: NOT_REACHED();
+	}
+
+}
+
+void SharedCloseOnLand (PlayerID old_player, VehicleID vehicle)
+{
+	DEBUG (misc, 4, "1- find first available depot for v %d", vehicle);
+	DepotID depot = SharedCloseGetFirstDepot (old_player, vehicle, false);
+	Vehicle *v = GetVehicle(vehicle);
+	PlayerID curr = _current_player;
+	bool handled = false;
+	DEBUG (misc, 4, "1- save vehicle position : tile %d", v->tile);
+	TileIndex old_tile = v->tile;
+	uint command;
+
+	/* vehicle and infrastructure need some resetting */
+	UpdateSharedOnRemove(vehicle);
+
+	DEBUG (misc, 4, "2- start handling of v %d (type : %d) for depot %d", v->index, v->type, depot);
+
+	if (IsValidDepotID(depot)) {
+		/* try to send vehicle to new depot, on fail try another way */
+		DEBUG (misc, 4, "2- try to send v %d to depot %d", v->index, depot);
+		handled = SharedCloseDepotTeleport(vehicle, depot);
+	} else {
+		/* sell vehicle */
+		int sell_cmd = 0;
+		switch (v->type) {
+			case VEH_TRAIN:
+				if (IsFrontEngine(v)) sell_cmd = 1;
+				command = CMD_SELL_RAIL_WAGON;
+				break;
+			case VEH_ROAD:
+				command = CMD_SELL_ROAD_VEH;
+				break;
+			case VEH_SHIP:
+				command = CMD_SELL_SHIP;
+				break;
+			default:
+				NOT_REACHED();
+				command = 0;
+		}
+		_current_player = v->owner;
+		/* already in old_player depot ? then sell vehicle */
+		if (v->IsStoppedInDepot()) {		
+			DEBUG (misc, 4, "3- sending to shared depot failed, v %d already in closing depot, trying to sell", v->index, depot);	
+			CommandCost cost = DoCommand(0, v->index, sell_cmd, DC_EXEC, command);
+			SubtractMoneyFromPlayer(cost);
+			if (v->owner == _local_player && cost.GetCost() != 0) {
+				ShowCostOrIncomeAnimation(v->x_pos, v->y_pos, v->z_pos, cost.GetCost());
+			}
+			handled = CmdSucceeded(cost);
+		} else {
+			/* We have already tested all depots except old_player's. do it now */ 
+			DEBUG (misc, 4, "3- sending to shared depot failed for v %d, trying closing depot", v->index, depot);
+			DepotID depot = SharedCloseGetFirstDepot (old_player, vehicle, true);
+			if (SharedCloseDepotTeleport(vehicle, depot)) {
+				/* vehicule finally in depot now ? sell it */
+				DEBUG (misc, 4, "3- try to sell v %d in closing depot", v->index, depot);
+				CommandCost cost = DoCommand(0, v->index, sell_cmd, DC_EXEC, command);
+				SubtractMoneyFromPlayer(cost);
+				if (v->owner == _local_player && cost.GetCost() != 0) {
+					ShowCostOrIncomeAnimation(v->x_pos, v->y_pos, v->z_pos, cost.GetCost());
+				}
+				handled = CmdSucceeded(cost);
+			}
+		}
+	}
+	if (!handled) {
+		/* tried everything possible to save it, without success, now just delete this vehicle */
+		DEBUG (misc, 4, "4- tried anything, deleting v %d (subtype %d)", v->index, v->subtype);
+		DeleteWindowById(WC_VEHICLE_VIEW, v->index);
+		DeleteWindowById(WC_VEHICLE_DETAILS, v->index);
+		DeleteWindowById(WC_VEHICLE_ORDERS, v->index);
+		switch (v->type) {
+			case VEH_TRAIN:
+				if (IsFrontEngine(v)) for (; v != NULL; v = GetNextVehicle(v)) {
+					DEBUG (misc, 4, "4- tried anything, deleting v %d in chain", v->index);
+					old_tile = v->tile;
+					DiagDirection old_dir = DirToDiagDir(v->direction);
+					delete v;
+					/* now that vehicle is removed, clear signal */
+					DEBUG(misc, 4, "dir : %d", old_dir);
+					UpdateSignalsOnSegment(old_tile, old_dir, GetTileOwner(old_tile));
+					DEBUG (misc, 4, "4- tried anything, v %d deleted in chain", v->index);
+				} else {
+					DEBUG (misc, 4, "4- tried anything, deleting v %d alone", v->index);
+					old_tile = v->tile;
+					DiagDirection old_dir = DirToDiagDir(v->direction);
+					delete v;
+					/* now that vehicle is removed, clear signal */
+					DEBUG(misc, 4, "dir : %d", old_dir);
+					UpdateSignalsOnSegment(old_tile, old_dir, GetTileOwner(old_tile));
+					DEBUG (misc, 4, "4- tried anything, v %d deleted alone", v->index);
+				}
+				break;
+			case VEH_ROAD:
+			case VEH_SHIP:
+				DEBUG (misc, 4, "4- tried anything, deleting v %d", v->index);
+				delete v;
+				DEBUG (misc, 4, "4- tried anything, v %d deleted", v->index);
+				break;
+			default: NOT_REACHED(); command = 0;
+		}
+
+	}
+	_current_player = curr;
+	/* clean some more infrastructure */
+
+	DEBUG (misc, 4, "5- end of handling v %d", vehicle);
+}
+
+void SharedCloseOnAir (PlayerID old_player, VehicleID vehicle)
+{
+	DEBUG (misc, 4, "1- find first available hangar for v %d", vehicle);
+	StationID airport = SharedCloseGetFirstHangar(old_player, vehicle, false);
+	Vehicle *v = GetVehicle(vehicle);
+	PlayerID curr = _current_player;
+	bool handled = false;
+
+	/* vehicle on airport need some resetting */
+	UpdateSharedOnRemove(vehicle);
+
+	DEBUG (misc, 4, "2- start handling of v %d (type : %d) for airport %d", v->index, v->type, airport);
+
+	if (IsValidStationID(airport)) {
+		/* try to send vehicle to new depot, on fail try another way */
+		DEBUG (misc, 4, "2- try to send v %d to airport %d", v->index, airport);
+		handled = SharedCloseHangarTeleport(vehicle, airport);
+	} else {
+		/* sell vehicle */
+		_current_player = v->owner;
+		/* already in old_player depot ? then sell vehicle */
+		if (v->IsStoppedInDepot()) {		
+			DEBUG (misc, 4, "3- sending to shared hangar failed, v %d already in closing hangar, trying to sell", v->index, airport);	
+			handled = CmdSucceeded(DoCommand(0, v->index, 0, DC_EXEC, CMD_SELL_AIRCRAFT));
+		} else {
+			/* We have already tested all depots except old_player's. do it now */ 
+			DEBUG (misc, 4, "3- sending to shared hangar failed for v %d, trying closing hangar", v->index, airport);
+			airport = SharedCloseGetFirstHangar (old_player, vehicle, true);
+			if (SharedCloseHangarTeleport(vehicle, airport)) {
+				/* vehicule finally in depot now ? sell it */
+				DEBUG (misc, 4, "3- try to sell v %d in closing hangar", v->index, airport);
+				handled = CmdSucceeded(DoCommand(0, v->index, 0, DC_EXEC, CMD_SELL_AIRCRAFT));
+			}
+		}
+	}
+	if (!handled) {
+		/* tried everything possible to save it, without success, now just delete this vehicle */
+		DEBUG (misc, 4, "4- tried anything, deleting v %d (subtype %d)", v->index, v->subtype);
+		DeleteWindowById(WC_VEHICLE_VIEW, v->index);
+		DeleteWindowById(WC_VEHICLE_DETAILS, v->index);
+		DeleteWindowById(WC_VEHICLE_ORDERS, v->index);
+
+		DEBUG (misc, 4, "4- tried anything, deleting v %d", v->index);
+		DeleteVehicleChain(v);
+		DEBUG (misc, 4, "4- tried anything, v %d deleted", v->index);
+
+	} else {
+		/* post-teleport */
+
+	}
+	_current_player = curr;
+	DEBUG (misc, 4, "5- end of handling v %d", vehicle);
+
+}
+
+/** Take care of vehicle on closed shared infrastructure.
+ * @param old_player bankrupt player
+ */
+void OnSharedClose(PlayerID old_player, uint close_bits)
+{	
+	DEBUG (misc, 4, "0- player %d is closing those bits : %d", old_player, close_bits);
+	Vehicle *v;	
+	Station *st = NULL;
+	FOR_ALL_VEHICLES(v) {
+		switch (v->type){
+			case VEH_TRAIN:
+				/* attached wagons are handled with front engines later */
+				if (GetTileOwner(v->tile) == old_player && (IsFrontEngine(v) || IsFreeWagon(v)) &&
+					((HASBITS(close_bits, SHARED_RAILWAY_TRACKS))
+					|| (HASBITS(close_bits, SHARED_RAILWAY_STATIONS) && IsTileType(v->tile, MP_STATION))
+					|| (HASBITS(close_bits, SHARED_RAILWAY_DEPOTS) && IsDepotTypeTile(v->tile, TRANSPORT_RAIL) ))) {
+					DEBUG (misc, 4, "0- v %d is TRAIN, owned by player %d in tile %d,%d", v->index, v->owner, TileX(v->tile),TileY(v->tile));
+					SharedCloseOnLand (old_player, v->index);
+				}
+				break;
+			case VEH_ROAD:
+				/* road won't be removed, check only in depot and stations */
+				if (GetTileOwner(v->tile) == old_player && 
+					((IsDepotTypeTile(v->tile, TRANSPORT_ROAD) && HASBITS(close_bits, SHARED_ROAD_DEPOTS))
+					|| ((IsTileType(v->tile, MP_STATION)) && HASBITS(close_bits, SHARED_ROAD_STOPS)))) {
+					DEBUG (misc, 4, "0- v %d is ROAD, owned by player %d in tile %d,%d", v->index, v->owner, TileX(v->tile),TileY(v->tile));
+					SharedCloseOnLand (old_player, v->index);
+				}
+				break;
+			case VEH_SHIP: 
+				/* remove ships in shared depots */
+				if (GetTileOwner(v->tile) == old_player && (IsDepotTypeTile(v->tile, TRANSPORT_WATER))
+					&& HASBITS(close_bits, SHARED_WATER_DEPOTS)) {
+					DEBUG (misc, 4, "0- v %d is SHIP, owned by player %d in tile %d,%d", v->index, v->owner, TileX(v->tile),TileY(v->tile));
+					SharedCloseOnLand (old_player, v->index); // TODO : find another name to this function
+				}
+				break;
+			case VEH_AIRCRAFT:
+				/* don't land on closing airports */
+				st = GetStation(v->u.air.targetairport);
+				if (((v->u.air.state == LANDING && st->owner == old_player) ||
+					(v->u.air.state != FLYING && (GetTileOwner(v->tile) == old_player)))
+					&& HASBITS(close_bits, SHARED_AIRPORTS)) {
+					DEBUG (misc, 4, "0- v %d is AIRCRAFT, owned by player %d in tile %d,%d", v->index, v->owner, TileX(v->tile),TileY(v->tile));
+					SharedCloseOnAir (old_player, v->index);
+				}
+				break;
+			default: break;
+		}
+	}
+}
Index: src/train_cmd.cpp
===================================================================
--- src/train_cmd.cpp	(revision 13683)
+++ src/train_cmd.cpp	(working copy)
@@ -39,6 +39,7 @@
 #include "tunnelbridge_map.h"
 #include "strings_func.h"
 #include "functions.h"
+#include "sharedinfrastructure.h"
 #include "window_func.h"
 #include "date_func.h"
 #include "vehicle_func.h"
@@ -51,6 +52,7 @@
 #include "order_func.h"
 #include "newgrf_station.h"
 #include "effectvehicle_func.h"
+#include <stack>
 
 #include "table/strings.h"
 #include "table/train_cmd.h"
@@ -697,15 +699,22 @@
 	 * to the player. Doesn't matter if only the cost is queried */
 	if (!(flags & DC_QUERY_COST)) {
 		if (!IsRailDepotTile(tile)) return CMD_ERROR;
-		if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
+		if (!IsTileOwner(tile, _current_player) && !SharedRailwayDepots(tile, _current_player)) return CMD_ERROR;
 	}
 
 	const RailVehicleInfo *rvi = RailVehInfo(p1);
 
-	if (rvi->railveh_type == RAILVEH_WAGON) return CmdBuildRailWagon(p1, tile, flags);
+	CommandCost value;
+	if (rvi->railveh_type == RAILVEH_WAGON) {
+		value = CmdBuildRailWagon(p1, tile, flags);
+		SharedDepotProvision(value, GetTileOwner(tile), flags);
 
-	CommandCost value = EstimateTrainCost(p1, rvi);
+		return value;
+	}
 
+	value = EstimateTrainCost(p1, rvi);
+
+
 	uint num_vehicles =
 		(rvi->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1) +
 		CountArticulatedParts(p1, false);
@@ -812,7 +821,7 @@
 			GetPlayer(_current_player)->num_engines[p1]++;
 		}
 	}
-
+	SharedDepotProvision(value, GetTileOwner(tile), flags);
 	return value;
 }
 
@@ -1290,7 +1299,7 @@
 
 	Vehicle *v = GetVehicle(p1);
 
-	if (v->type != VEH_TRAIN || !CheckOwnership(v->owner)) return CMD_ERROR;
+	if (v->type != VEH_TRAIN || !IsTileOwner(tile, _current_player)) return CMD_ERROR;
 
 	/* Check if this train can be started/stopped. The callback will fail or
 	 * return 0xFF if it can. */
@@ -1858,7 +1867,8 @@
 
 	Vehicle *v = GetVehicle(p1);
 
-	if (v->type != VEH_TRAIN || !CheckOwnership(v->owner)) return CMD_ERROR;
+	/* In order to sort out jams on your tracks you have to be able to turn trains */
+	if (v->type != VEH_TRAIN || !IsTileOwner(tile, _current_player)) return CMD_ERROR;
 
 	if (p2 != 0) {
 		/* turn a single unit around */
@@ -1907,7 +1917,10 @@
 
 	Vehicle *v = GetVehicle(p1);
 
-	if (v->type != VEH_TRAIN || !CheckOwnership(v->owner)) return CMD_ERROR;
+	/** A track owner must stay in control of his tracks so others cannot 
+	 *  produce forcefully crashes there
+	 */
+	if (v->type != VEH_TRAIN || !IsTileOwner(tile, _current_player)) return CMD_ERROR;
 
 	if (flags & DC_EXEC) v->u.rail.force_proceed = 0x50;
 
@@ -2731,7 +2744,8 @@
 static inline bool CheckCompatibleRail(const Vehicle *v, TileIndex tile)
 {
 	return
-		IsTileOwner(tile, v->owner) && (
+		(IsTileOwner(tile, v->owner) || 
+			(SharedTracks(tile, v->owner))) && (
 			!IsFrontEngine(v) ||
 			HasBit(v->u.rail.compatible_railtypes, GetRailType(tile))
 		);
@@ -3623,7 +3637,6 @@
 					v->index,
 					0);
 			}
-
 			v->profit_last_year = v->profit_this_year;
 			v->profit_this_year = 0;
 			InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
Index: src/road_cmd.cpp
===================================================================
--- src/road_cmd.cpp	(revision 13683)
+++ src/road_cmd.cpp	(working copy)
@@ -329,7 +329,7 @@
 
 			/* If we change the foundation we have to pay for it. */
 			return CommandCost(EXPENSES_CONSTRUCTION, CountBits(pieces) * _price.remove_road +
-					((GetRoadFoundation(tileh, present) != f) ? _price.terraform : (Money)0));
+					((GetRoadFoundation(tileh, present) != f) ? (_price.build_rail <<3) : (Money)0));
 		}
 
 		case ROAD_TILE_CROSSING: {
@@ -410,7 +410,7 @@
 		existing |= other;
 
 		if ((existing == ROAD_NONE || existing == *pieces) && IsStraightRoad(*pieces)) {
-			return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
+			return CommandCost(EXPENSES_CONSTRUCTION, (_price.build_rail <<3));
 		}
 		return CMD_ERROR;
 	}
@@ -422,7 +422,7 @@
 	if (_settings_game.construction.build_on_slopes && (_invalid_tileh_slopes_road[0][tileh] & (other | type_bits)) == ROAD_NONE) {
 
 		/* If we add leveling we've got to pay for it */
-		if ((other | existing) == ROAD_NONE) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
+		if ((other | existing) == ROAD_NONE) return CommandCost(EXPENSES_CONSTRUCTION, (_price.build_rail <<3));
 
 		return CommandCost();
 	}
@@ -442,12 +442,12 @@
 			if (_settings_game.construction.build_on_slopes) {
 
 				/* If we add foundation we've got to pay for it */
-				if ((other | existing) == ROAD_NONE) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
+				if ((other | existing) == ROAD_NONE) return CommandCost(EXPENSES_CONSTRUCTION, (_price.build_rail <<3));
 
 				return CommandCost();
 			}
 		} else {
-			if (CountBits(existing) == 1) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
+			if (CountBits(existing) == 1) return CommandCost(EXPENSES_CONSTRUCTION, (_price.build_rail <<3));
 			return CommandCost();
 		}
 	}
@@ -1575,11 +1575,11 @@
 	if (_settings_game.construction.build_on_slopes && AutoslopeEnabled()) {
 		switch (GetRoadTileType(tile)) {
 			case ROAD_TILE_CROSSING:
-				if (!IsSteepSlope(tileh_new) && (GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new)) && HasBit(VALID_LEVEL_CROSSING_SLOPES, tileh_new)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
+				if (!IsSteepSlope(tileh_new) && (GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new)) && HasBit(VALID_LEVEL_CROSSING_SLOPES, tileh_new)) return CommandCost(EXPENSES_CONSTRUCTION, (_price.build_rail <<3));
 				break;
 
 			case ROAD_TILE_DEPOT:
-				if (AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, GetRoadDepotDirection(tile))) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
+				if (AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, GetRoadDepotDirection(tile))) return CommandCost(EXPENSES_CONSTRUCTION, (_price.build_rail <<3));
 				break;
 
 			case ROAD_TILE_NORMAL: {
@@ -1597,7 +1597,7 @@
 						z_new += ApplyFoundationToSlope(GetRoadFoundation(tileh_new, bits), &tileh_new);
 
 						/* The surface slope must not be changed */
-						if ((z_old == z_new) && (tileh_old == tileh_new)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
+						if ((z_old == z_new) && (tileh_old == tileh_new)) return CommandCost(EXPENSES_CONSTRUCTION, (_price.build_rail <<3));
 					}
 				}
 				break;
Index: src/command.cpp
===================================================================
--- src/command.cpp	(revision 13683)
+++ src/command.cpp	(working copy)
@@ -18,6 +18,9 @@
 #include "town.h"
 #include "date_func.h"
 #include "debug.h"
+#include "window_func.h"
+#include "viewport_type.h"
+#include "viewport_func.h"
 #include "player_func.h"
 #include "player_base.h"
 #include "signal_func.h"
@@ -198,6 +201,11 @@
 DEF_COMMAND(CmdChangeTimetable);
 DEF_COMMAND(CmdSetVehicleOnTime);
 DEF_COMMAND(CmdAutofillTimetable);
+
+DEF_COMMAND(CmdSetSharedBoolValues);
+DEF_COMMAND(CmdSetSharedIntValues);
+
+DEF_COMMAND(CmdOpenCloseAirport);
 #undef DEF_COMMAND
 
 /**
@@ -346,6 +354,11 @@
 	{CmdChangeTimetable,                     0}, /* CMD_CHANGE_TIMETABLE */
 	{CmdSetVehicleOnTime,                    0}, /* CMD_SET_VEHICLE_ON_TIME */
 	{CmdAutofillTimetable,                   0}, /* CMD_AUTOFILL_TIMETABLE */
+
+	{CmdSetSharedBoolValues,                 0}, /* CMD_SET_SHARED_BOOL_VALUES */
+	{CmdSetSharedIntValues,                  0}, /* CMD_SET_SHARED_INT_VALUES */
+ 
+ 	{CmdOpenCloseAirport,                    0}, /* CMD_OPEN_CLOSE_AIRPORT */
 };
 
 /*!
@@ -449,7 +462,17 @@
 		SubtractMoneyFromPlayer(res);
 		/* XXX - Old AI hack which doesn't use DoCommandDP; update last build coord of player */
 		if (tile != 0 && IsValidPlayer(_current_player)) {
-			GetPlayer(_current_player)->last_build_coordinate = tile;
+			Player *p = GetPlayer(_current_player);
+			if (p->last_build_coordinate != tile) {
+				p->last_build_coordinate = tile;
+				if (p->window != -1) {
+					Window *w = FindWindowById(WC_EXTRA_VIEW_PORT, p->window);
+					if (w != NULL)
+						ScrollWindowTo(TileX(tile) * TILE_SIZE + TILE_SIZE / 2, TileY(tile) * TILE_SIZE + TILE_SIZE / 2, w, true);
+					else
+						p->window = -1;  // TODO: player initiated to '0'
+				}
+			}
 		}
 	}
 
@@ -609,7 +632,17 @@
 
 	/* update last build coordinate of player. */
 	if (tile != 0 && IsValidPlayer(_current_player)) {
-		GetPlayer(_current_player)->last_build_coordinate = tile;
+		Player *p = GetPlayer(_current_player);
+		if (p->last_build_coordinate != tile) {
+			p->last_build_coordinate = tile;
+			if (p->window != -1) {
+				Window *w = FindWindowById(WC_EXTRA_VIEW_PORT, p->window);
+				if (w != NULL)
+					ScrollWindowTo(TileX(tile) * TILE_SIZE + TILE_SIZE / 2, TileY(tile) * TILE_SIZE + TILE_SIZE / 2, w, true);
+				else
+					p->window = -1;  // TODO: player initiated to '0'
+			}
+		}
 	}
 
 	/* Actually try and execute the command. If no cost-type is given
Index: src/settings_func.h
===================================================================
--- src/settings_func.h	(revision 13683)
+++ src/settings_func.h	(working copy)
@@ -14,4 +14,10 @@
 void SaveToConfig();
 void CheckConfig();
 
+/* Functions to load and save NewGRF settings to a separate
+ * configuration file, used for presets. */
+void GetGRFPresetList();
+struct GRFConfig *LoadGRFPresetFromConfig(const char *config_name);
+void SaveGRFPresetToConfig(const char *config_name, struct GRFConfig *config);
+
 #endif /* SETTINGS_FUNC_H */
Index: src/tree_cmd.cpp
===================================================================
--- src/tree_cmd.cpp	(revision 13683)
+++ src/tree_cmd.cpp	(working copy)
@@ -650,6 +650,8 @@
 	}
 	SetTreeCounter(tile, 0);
 
+ 	if (_settings_game.construction.disable_tree_growth == false)
+ 	{
 	switch (GetTreeGrowth(tile)) {
 		case 3: /* regular sized tree */
 			if (_settings_game.game_creation.landscape == LT_TROPIC &&
@@ -714,12 +716,14 @@
 			AddTreeGrowth(tile, 1);
 			break;
 	}
-
+	}
 	MarkTileDirtyByTile(tile);
 }
 
 void OnTick_Trees()
 {
+ 	if (_settings_game.construction.disable_tree_growth == false)
+ 	{
 	uint32 r;
 	TileIndex tile;
 	TreeType tree;
@@ -741,6 +745,7 @@
 	if (CanPlantTreesOnTile(tile, false) && (tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TREE_INVALID) {
 		PlantTreesOnTile(tile, tree, 0, 0);
 	}
+	}
 }
 
 static void ClickTile_Trees(TileIndex tile)
Index: src/player_base.h
===================================================================
--- src/player_base.h	(revision 13683)
+++ src/player_base.h	(working copy)
@@ -62,6 +62,8 @@
 	bool is_active;
 	bool is_ai;
 
+	int window;
+
 	Money yearly_expenses[3][EXPENSES_END];
 	PlayerEconomyEntry cur_economy;
 	PlayerEconomyEntry old_economy[24];
@@ -71,6 +73,26 @@
 	int16 engine_renew_months;
 	uint32 engine_renew_money;
 	uint16 *num_engines; ///< caches the number of engines of each type the player owns (no need to save this)
+
+	/** Shared infrastructure
+	 * first element is actual value
+	 * second is value to be set at end of shared_change_months counter
+	 * (see patch value of shared_delay)
+	 */
+	bool shared_railway_tracks[2];
+	bool shared_railway_stations[2];
+	bool shared_railway_depots[2];
+	uint16 shared_tontile_cost[2];
+	uint8 shared_road_stops_fee[2];
+	uint8 shared_harbours_fee[2];
+	bool shared_airports[2];
+	uint16 shared_landing_fee[2];
+	bool shared_road_depots[2];
+	bool shared_road_stops[2];
+	bool shared_water_depots[2];
+	bool shared_harbours[2];
+	uint8 shared_provision[2];
+	uint8 shared_change_months;
 };
 
 struct PlayerMoneyBackup {
Index: src/rail_gui.cpp
===================================================================
--- src/rail_gui.cpp	(revision 13683)
+++ src/rail_gui.cpp	(working copy)
@@ -184,10 +184,21 @@
 		VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_STATION);
 		VpSetPlaceSizingLimit(_settings_game.station.station_spread);
 	} else {
-		DoCommandP(tile,
-				_railstation.orientation | (_railstation.numtracks << 8) | (_railstation.platlength << 16) | (_ctrl_pressed << 24),
-				_cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), CcStation,
-				CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION));
+		int w = _railstation.numtracks;
+		int h = _railstation.platlength;
+		if (!_railstation.orientation) Swap(w, h);
+
+		uint32 p1 = _cur_railtype | (_railstation.orientation << 4) | (_railstation.numtracks << 8) | (_railstation.platlength << 16) | (_ctrl_pressed << 24);
+		uint32 p2 = _railstation.station_class | (_railstation.station_type << 8) | (INVALID_STATION << 16);
+
+		if (StationJoinerNeeded(tile, w, h)) {
+			CommandContainer cmd = {tile, p1, p2, CcStation,
+					CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION)};
+			ShowSelectStation(cmd, STATION_RAIL, true, true);
+		} else {
+			DoCommandP(tile, p1, p2, CcStation,
+					CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION));
+		}
 	}
 }
 
@@ -752,6 +763,7 @@
 		delete FindWindowById(WC_BUILD_SIGNAL, 0);
 		delete FindWindowById(WC_BUILD_STATION, 0);
 		delete FindWindowById(WC_BUILD_DEPOT, 0);
+		delete FindWindowById(WC_SELECT_STATION, 0);
 	}
 
 	virtual void OnPlacePresize(Point pt, TileIndex tile)
@@ -872,12 +884,21 @@
 	if (sy > ey) Swap(sy, ey);
 	w = ex - sx + 1;
 	h = ey - sy + 1;
-	if (!_railstation.orientation) Swap(w, h);
 
-	DoCommandP(TileXY(sx, sy),
-			_railstation.orientation | (w << 8) | (h << 16) | (_ctrl_pressed << 24),
-			_cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), CcStation,
+	uint32 p1 = _cur_railtype | (_railstation.orientation << 4) | (_ctrl_pressed << 24);
+	uint32 p2 = _railstation.station_class | (_railstation.station_type << 8) | (INVALID_STATION << 16);
+
+	if (StationJoinerNeeded(TileXY(sx, sy), w, h)) {
+		if (!_railstation.orientation) Swap(w, h);
+		CommandContainer cmd = {TileXY(sx, sy), p1 | (w << 8) | (h << 16), p2,
+			CcStation,
+			CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION)};
+		ShowSelectStation(cmd, STATION_RAIL, true, true);
+	} else {
+		if (!_railstation.orientation) Swap(w, h);
+		DoCommandP(TileXY(sx, sy), p1 | (w << 8) | (h << 16), p2, CcStation,
 			CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION));
+	}
 }
 
 struct BuildRailStationWindow : public PickerWindowBase {
Index: src/tunnelbridge_cmd.cpp
===================================================================
--- src/tunnelbridge_cmd.cpp	(revision 13683)
+++ src/tunnelbridge_cmd.cpp	(working copy)
@@ -93,6 +93,28 @@
 }
 
 /**
+ * Returns the fastest currently available BridgeType for given length.
+ */
+BridgeType GetFastestAvailableBridgeType(uint bridge_len)
+{
+	BridgeType fastest_type = MAX_BRIDGES;
+	uint16 fastest_speed = 0;
+
+	for (BridgeType brd_type = 0; brd_type != MAX_BRIDGES; brd_type++) {
+		if (CheckBridge_Stuff(brd_type, bridge_len)) {
+			/* bridge is available, compare speeds */
+			const BridgeSpec *b = GetBridgeSpec(brd_type);
+			if (b->speed >= fastest_speed) {
+				fastest_type = brd_type;
+				fastest_speed = b->speed;
+			}
+		}
+	}
+
+	return fastest_type;
+}
+
+/**
  * Determines if the track on a bridge ramp is flat or goes up/down.
  *
  * @param tileh Slope of the tile under the bridge head
@@ -136,7 +158,7 @@
 
 	if (f == FOUNDATION_NONE) return CommandCost();
 
-	return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
+	return CommandCost(EXPENSES_CONSTRUCTION, (_price.build_rail <<3));
 }
 
 /**
@@ -157,7 +179,7 @@
 
 	if (f == FOUNDATION_NONE) return CommandCost();
 
-	return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
+	return CommandCost(EXPENSES_CONSTRUCTION, (_price.build_rail <<3));
 }
 
 bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len, uint32 flags)
@@ -1446,7 +1468,7 @@
 		}
 
 		/* Surface slope is valid and remains unchanged? */
-		if (!CmdFailed(res) && (z_old == z_new) && (tileh_old == tileh_new)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
+		if (!CmdFailed(res) && (z_old == z_new) && (tileh_old == tileh_new)) return CommandCost(EXPENSES_CONSTRUCTION, (_price.build_rail <<3));
 	}
 
 	return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
Index: src/settings_type.h
===================================================================
--- src/settings_type.h	(revision 13683)
+++ src/settings_type.h	(working copy)
@@ -71,6 +71,7 @@
 	Year   ending_year;                      ///< end of the game (just show highscore)
 	Year   colored_news_year;                ///< when does newspaper become colored?
 	bool   timetable_in_ticks;               ///< whether to show the timetable in ticks rather than days
+	bool   quick_goto;                       ///< Allow quick access to 'goto button' in vehicle orders window
 	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
@@ -148,6 +149,9 @@
 	bool   extra_dynamite;                   ///< extra dynamite
 	bool   road_stop_on_town_road;           ///< allow building of drive-through road stops on town owned roads
 	uint8  raw_industry_construction;        ///< type of (raw) industry construction (none, "normal", prospecting)
+	bool   disable_tree_growth;				 ///< If trees are allowed to grow
+	bool   one_tile_terraform;               ///< allow only terraform of size "1 tile"
+	uint16 allow_terraform;                  ///< bitmask for companies allowed to terraform (only effective for network server)
 };
 
 /** Settings related to the AI. */
@@ -304,6 +308,25 @@
 	byte   station_spread;                   ///< amount a station may spread
 };
 
+ /** Shared Infrastructure **/
+struct SharingSettings {
+  	bool shared_railway_stations;          ///< allow railway stations sharing
+  	bool shared_railway_tracks;            ///< allow railway tracks sharing
+  	bool shared_railway_depots;            ///< allow railway depots sharing
+  	bool shared_road_depots;               ///< allow road depots sharing
+  	bool shared_road_stops;                ///< allow road stops sharing
+  	bool shared_water_depots;              ///< allow water depots sharing
+  	bool shared_harbours;                  ///< allow harbours sharing
+  	bool shared_airports;                  ///< allow airports sharing
+  	int8 shared_provision;                 ///< default value for depots provision (buy cost %)
+  	uint16 shared_tontile_cost;            ///< default value for tracks sharing payment (per 1000 tons per tiles)
+  	uint16 shared_landing_fee;             ///< default value for airports landing fee (per tons of cargo capacity)
+  	int8 shared_road_stops_fee;            ///< default value for entering road stops (per tons of cargo capacity)
+  	int8 shared_harbours_fee;              ///< default value for entering harbours (per tons of cargo capacity)
+  	bool shared_player_level;              ///< allow players to set individual sharing settings
+  	uint8 shared_delay;                    ///< delay before activating individual sharing settings 
+};  
+
 /** All settings together for the game. */
 struct GameSettings {
 	DifficultySettings   difficulty;         ///< settings related to the difficulty
@@ -315,6 +338,7 @@
 	VehicleSettings      vehicle;            ///< options for vehicles
 	EconomySettings      economy;            ///< settings to change the economy
 	StationSettings      station;            ///< settings related to station management
+ 	SharingSettings		 sharing;            ///< settings related to infrastructure sharing
 	LocaleSettings       locale;             ///< settings related to used currency/unit system in the current game
 };
 
Index: src/depot_gui.cpp
===================================================================
--- src/depot_gui.cpp	(revision 13683)
+++ src/depot_gui.cpp	(working copy)
@@ -27,6 +27,7 @@
 #include "tilehighlight_func.h"
 #include "window_gui.h"
 #include "vehiclelist.h"
+#include "sharedinfrastructure.h"
 
 #include "table/strings.h"
 #include "table/sprites.h"
@@ -314,7 +315,7 @@
 		uint16 boxes_in_each_row = this->widget[DEPOT_WIDGET_MATRIX].data & 0xFF;
 
 		/* setup disabled buttons */
-		this->SetWidgetsDisabledState(!IsTileOwner(tile, _local_player),
+		this->SetWidgetsDisabledState(!IsTileOwner(tile, _local_player) && !SharedDepotVehicleType(tile,_local_player, this->type),
 			DEPOT_WIDGET_STOP_ALL,
 			DEPOT_WIDGET_START_ALL,
 			DEPOT_WIDGET_SELL,
Index: src/command_type.h
===================================================================
--- src/command_type.h	(revision 13683)
+++ src/command_type.h	(working copy)
@@ -278,6 +278,10 @@
 	CMD_CHANGE_TIMETABLE,             ///< change the timetable for a vehicle
 	CMD_SET_VEHICLE_ON_TIME,          ///< set the vehicle on time feature (timetable)
 	CMD_AUTOFILL_TIMETABLE,           ///< autofill the timetable
+	CMD_SET_SHARED_BOOL_VALUES,       ///< set shared infrastructure player bool value
+	CMD_SET_SHARED_INT_VALUES,        ///< set shared infrastructure player int value
+ 
+ 	CMD_OPEN_CLOSE_AIRPORT,           ///< open/close an airport
 };
 
 /**
@@ -375,4 +379,15 @@
  */
 typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2);
 
+/**
+ * Structure for buffering the build command when selecting a station to join.
+ */
+struct CommandContainer {
+	TileIndex tile;
+	uint32 p1;
+	uint32 p2;
+	CommandCallback *callback;
+	uint32 cmd;
+};
+
 #endif /* COMMAND_TYPE_H */
Index: src/station_gui.cpp
===================================================================
--- src/station_gui.cpp	(revision 13683)
+++ src/station_gui.cpp	(working copy)
@@ -25,6 +25,11 @@
 #include "gfx_func.h"
 #include "widgets/dropdown_func.h"
 #include "newgrf_cargo.h"
+#include "map_func.h"
+#include "settings_type.h"
+#include "tile_map.h"
+#include "station_map.h"
+#include "tilehighlight_func.h"
 #include "string_func.h"
 
 #include "table/strings.h"
@@ -613,14 +618,15 @@
 {      WWT_PANEL,     RESIZE_RB,    14,     0,   236,    14,    65, 0x0,               STR_NULL},                             // SVW_WAITING
 {  WWT_SCROLLBAR,    RESIZE_LRB,    14,   237,   248,    14,    65, 0x0,               STR_0190_SCROLL_BAR_SCROLLS_LIST},
 {      WWT_PANEL,    RESIZE_RTB,    14,     0,   248,    66,    97, 0x0,               STR_NULL},                             // SVW_ACCEPTLIST / SVW_RATINGLIST
-{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,    59,    98,   109, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION}, // SVW_LOCATION
-{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,    60,   120,    98,   109, STR_3032_RATINGS,  STR_3054_SHOW_STATION_RATINGS},        // SVW_RATINGS / SVW_ACCEPTS
-{ WWT_PUSHTXTBTN,    RESIZE_RTB,    14,   121,   180,    98,   109, STR_0130_RENAME,   STR_3055_CHANGE_NAME_OF_STATION},      // SVW_RENAME
-{ WWT_PUSHTXTBTN,   RESIZE_LRTB,    14,   181,   194,    98,   109, STR_TRAIN,         STR_SCHEDULED_TRAINS_TIP },            // SVW_TRAINS
-{ WWT_PUSHTXTBTN,   RESIZE_LRTB,    14,   195,   208,    98,   109, STR_LORRY,         STR_SCHEDULED_ROAD_VEHICLES_TIP },     // SVW_ROADVEHS
-{ WWT_PUSHTXTBTN,   RESIZE_LRTB,    14,   209,   222,    98,   109, STR_PLANE,         STR_SCHEDULED_AIRCRAFT_TIP },          // SVW_PLANES
-{ WWT_PUSHTXTBTN,   RESIZE_LRTB,    14,   223,   236,    98,   109, STR_SHIP,          STR_SCHEDULED_SHIPS_TIP },             // SVW_SHIPS
-{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   237,   248,    98,   109, 0x0,               STR_RESIZE_BUTTON},
+{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,    59,   110,   121, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION}, // SVW_LOCATION
+{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,    60,   120,   110,   121, STR_3032_RATINGS,  STR_3054_SHOW_STATION_RATINGS},        // SVW_RATINGS / SVW_ACCEPTS
+{ WWT_PUSHTXTBTN,    RESIZE_RTB,    14,   121,   180,   110,   121, STR_0130_RENAME,   STR_3055_CHANGE_NAME_OF_STATION},      // SVW_RENAME
+{ WWT_PUSHTXTBTN,   RESIZE_LRTB,    14,   181,   194,   110,   121, STR_TRAIN,         STR_SCHEDULED_TRAINS_TIP },            // SVW_TRAINS
+{ WWT_PUSHTXTBTN,   RESIZE_LRTB,    14,   195,   208,   110,   121, STR_LORRY,         STR_SCHEDULED_ROAD_VEHICLES_TIP },     // SVW_ROADVEHS
+{ WWT_PUSHTXTBTN,   RESIZE_LRTB,    14,   209,   222,   110,   121, STR_PLANE,         STR_SCHEDULED_AIRCRAFT_TIP },          // SVW_PLANES
+{ WWT_PUSHTXTBTN,   RESIZE_LRTB,    14,   223,   236,   110,   121, STR_SHIP,          STR_SCHEDULED_SHIPS_TIP },             // SVW_SHIPS
+{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   237,   248,   110,   121, 0x0,               STR_RESIZE_BUTTON},
+{ WWT_PUSHTXTBTN,   RESIZE_LRTB,    14,     0,   248,    98,   109, STR_CLOSE_AIRPORT, STR_CLOSE_AIRPORT_TIP},                // SVW_CLOSEAIRPORT
 {   WIDGETS_END},
 };
 
@@ -758,6 +764,13 @@
 		this->SetWidgetDisabledState(SVW_ROADVEHS, !(st->facilities & FACIL_TRUCK_STOP) && !(st->facilities & FACIL_BUS_STOP));
 		this->SetWidgetDisabledState(SVW_PLANES,   !(st->facilities & FACIL_AIRPORT));
 		this->SetWidgetDisabledState(SVW_SHIPS,    !(st->facilities & FACIL_DOCK));
+		if (st->facilities & FACIL_AIRPORT) {
+			this->SetWidgetDisabledState(SVW_CLOSEAIRPORT, st->owner != _local_player);
+			this->SetWidgetLoweredState(SVW_CLOSEAIRPORT, HASBITS(st->airport_flags, AIRPORT_CLOSED_block));
+		} else {
+			this->DisableWidget(SVW_CLOSEAIRPORT);
+			this->RaiseWidget(SVW_CLOSEAIRPORT);
+		}
 
 		SetDParam(0, st->index);
 		SetDParam(1, st->facilities);
@@ -938,6 +951,12 @@
 				ShowVehicleListWindow(owner, VEH_SHIP, (StationID)this->window_number);
 				break;
 			}
+
+			case SVW_CLOSEAIRPORT: { // Open/close airport
+				const Station *st = GetStation(this->window_number);
+				DoCommandP(0, st->index, HASBITS(st->airport_flags, AIRPORT_CLOSED_block) ? 0 : 1, NULL, CMD_OPEN_CLOSE_AIRPORT | CMD_MSG(STR_CLOSE_AIRPORT_ERROR));
+				break;
+			}
 		}
 	}
 
@@ -959,7 +978,7 @@
 
 
 static const WindowDesc _station_view_desc = {
-	WDP_AUTO, WDP_AUTO, 249, 110, 249, 110,
+	WDP_AUTO, WDP_AUTO, 249, 122, 249, 122,
 	WC_STATION_VIEW, WC_NONE,
 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
 	_station_view_widgets,
@@ -974,3 +993,246 @@
 {
 	AllocateWindowDescFront<StationViewWindow>(&_station_view_desc, station);
 }
+
+static CommandContainer _selectStationCommand;
+static StationType _stationType;
+
+static void addStationID(StationID st)
+{
+	for (int i = 0; i < _stations_Nearby_Count; i++) {
+		if (_stations_Nearby_List[i] == st) return;
+	}
+
+	if ((_stations_Nearby_Count < sizeof(_stations_Nearby_List)/sizeof(_stations_Nearby_List[0])) &&
+			(GetStation(st)->owner == _current_player)) {
+		_stations_Nearby_List[_stations_Nearby_Count] = st;
+		_stations_Nearby_Count++;
+	}
+}
+
+// This doen't check wrapping!
+static bool InsideMap(TileIndex t)
+{
+	return (t < MapSize());
+}
+
+
+/**
+ * Do not laugh :)
+ * This approach (while not nice and correct) has some benefits:
+ * -stations appear nearly in order of distance
+ * -no sorting needed
+ * -no need to retrieve all stations within range, and discard the far away ones
+**/
+static Station* FindStationsNearby(TileIndex tile, int w, int h, bool distant_join)
+{
+	/* We start "above" supplied tile, then move in circles around w/h */
+	TileIndex tile_cur = tile;
+	int32 count;
+	int32 dist = 0;
+	int32 max_dist = distant_join ? _settings_game.station.station_spread : 1;
+
+	_stations_Nearby_Count = 0;
+
+	while (dist < max_dist) {
+		/* Move one up, one right */
+		tile_cur += TileDiffXY(-1, -1);
+
+		/* move down: */
+		count = h + (dist * 2) + 1;
+		while (count > 0) {
+			tile_cur += TileDiffXY(0, 1);
+
+			/* Check this tile for a station: */
+			if (InsideMap(tile_cur)) {
+				if (IsTileType(tile_cur, MP_STATION)) {
+					addStationID(GetStationIndex(tile_cur));
+				}
+			}
+			count--;
+		}
+		/* move left: */
+		count = w + (dist * 2) + 1;
+		while (count > 0) {
+			tile_cur += TileDiffXY(1, 0);
+
+			/* Check this tile for a station: */
+			if (InsideMap(tile_cur)) {
+				if (IsTileType(tile_cur, MP_STATION)) {
+					addStationID(GetStationIndex(tile_cur));
+				}
+			}
+			count--;
+		}
+		/* move up: */
+		count = h + (dist * 2) + 1;
+		while (count > 0) {
+			tile_cur += TileDiffXY(0, -1);
+
+			/* Check this tile for a station: */
+			if (InsideMap(tile_cur)) {
+				if (IsTileType(tile_cur, MP_STATION)) {
+					addStationID(GetStationIndex(tile_cur));
+				}
+			}
+			count--;
+		}
+		/* move right: */
+		count = w + (dist * 2) + 1;
+		while (count > 0) {
+			tile_cur += TileDiffXY(-1, 0);
+
+			/* Check this tile for a station: */
+			if (InsideMap(tile_cur)) {
+				if (IsTileType(tile_cur, MP_STATION)) {
+					addStationID(GetStationIndex(tile_cur));
+				}
+			}
+			count--;
+		}
+		dist++;
+	}
+
+	/* Now we check the inside, to return, if we sit on another station
+	 * correct: we need to check inside + 1 around.
+	 */
+	{
+		int x;
+		int y;
+		Station *st = NULL;
+		tile_cur = tile;
+		for (y = 0; y < h; y++) {
+			for (x = 0; x < w; x++) {
+				if (InsideMap(tile_cur)) {
+					if (IsTileType(tile_cur, MP_STATION)) {
+						st = GetStationByTile(tile_cur);
+					}
+				}
+				tile_cur += TileDiffXY(1, 0);
+			}
+			tile_cur += TileDiffXY(-w, 1);
+		}
+		/* Empty list, if ontop of another station */
+		if (st != NULL) _stations_Nearby_Count = 0;
+		return st;
+	}
+}
+
+enum JoinStationWidgets {
+	JSW_WIDGET_CLOSEBOX = 0,
+	JSW_WIDGET_CAPTION,
+	JSW_PANEL,
+};
+
+static const Widget _select_station_widgets[] = {
+{   WWT_CLOSEBOX,   RESIZE_NONE,    7,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
+{    WWT_CAPTION,   RESIZE_NONE,    7,    11,   199,     0,    13, STR_SELECT_STATION_TO_JOIN,      STR_018C_WINDOW_TITLE_DRAG_THIS},
+{      WWT_PANEL,   RESIZE_NONE,    7,     0,   199,    14,   179, 0x0,                             STR_NULL},
+
+{   WIDGETS_END},
+};
+
+struct SelectStationWindow : Window {
+	SelectStationWindow(const WindowDesc *desc, WindowNumber window_number = 0) : Window(desc, window_number)
+	{
+		FindStationsNearby(TileVirtXY(_thd.pos.x, _thd.pos.y), _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE, true);
+	}
+
+	~SelectStationWindow()
+	{
+		_thd.lockPos = false;
+		_thd.lockSize = false;
+	}
+
+	virtual void OnPaint()
+	{
+		int y = 17;
+		int i = 0;
+		Station *st;
+
+		this->DrawWidgets();
+
+		DrawString(3, y, STR_CREATE_SPLITTED_STATION, 0);
+		y+= 10;
+		while (i < _stations_Nearby_Count) {
+			st = GetStation(_stations_Nearby_List[i]);
+			SetDParam(0, st->index);
+			SetDParam(1, st->facilities);
+			DrawString(3, y, STR_3049_0, 0);
+
+			i++;
+			y+= 10;
+		}
+	}
+
+	virtual void OnClick(Point pt, int widget)
+	{
+		if (widget == JSW_PANEL) {
+			uint32 st_index = (pt.y - 16) / 10;
+			bool distant_join = (st_index > 0);
+			if (distant_join) st_index--;
+			if ((st_index < _stations_Nearby_Count) || (!distant_join)) {
+
+				/* Insert station to be joined into stored command */
+				SB(_selectStationCommand.p2, 16, 16,
+					(distant_join ? _stations_Nearby_List[st_index] : INVALID_STATION));
+
+				/* Execute stored Command */
+				DoCommandP(_selectStationCommand.tile,
+					_selectStationCommand.p1, _selectStationCommand.p2,
+					_selectStationCommand.callback, _selectStationCommand.cmd);
+
+				/* Close Window. */
+				//this->~SelectStationWindow();
+			}
+		}
+	}
+
+	virtual void OnTick()
+	{
+		if (_thd.dirty & 2) {
+			_thd.dirty &= ~2;
+			this->SetDirty();
+		}
+	}
+};
+
+static const WindowDesc _select_station_desc = {
+	WDP_AUTO, WDP_AUTO, 200, 180, 200, 180,
+	WC_SELECT_STATION, WC_NONE,
+	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
+	_select_station_widgets,
+};
+
+void ShowSelectStation(CommandContainer cmd, StationType stationType, bool lockPos, bool lockSize)
+{
+	Window *w = FindWindowById(WC_SELECT_STATION, 0);
+	if (w == NULL) {
+		_thd.lockPos = lockPos;
+		_thd.lockSize = lockSize;
+		_selectStationCommand = cmd;
+		_stationType = stationType;
+		// AllocateWindowDesc(&_select_station_desc);
+		new SelectStationWindow(&_select_station_desc);
+	}
+}
+
+bool StationJoinerNeeded(TileIndex tile, int w, int h)
+{
+	/* If a window is already opened, we always return true */
+	Window *window = FindWindowById(WC_SELECT_STATION, 0);
+	if (window != NULL) return true;
+
+	/* only show the popup, if we press ctrl */
+	if (!_ctrl_pressed) return false;
+
+	/* Test if a station joiner is needed: */
+	FindStationsNearby(tile, w, h, false);
+	int neighbourStationCount = _stations_Nearby_Count;
+	Station *st = FindStationsNearby(tile, w, h, true);
+	if (_settings_game.station.adjacent_stations) {
+		return (neighbourStationCount == 0 || _stations_Nearby_Count > 1) && (st == NULL);
+	} else {
+		return (neighbourStationCount == 0) && (_stations_Nearby_Count > 0) && (st == NULL);
+	}
+}
Index: src/airport.h
===================================================================
--- src/airport.h	(revision 13683)
+++ src/airport.h	(working copy)
@@ -113,8 +113,10 @@
 	OUT_WAY_block2           = 1ULL << 31,
 /* end of new blocks */
 
-	NOTHING_block            = 1ULL << 30;
+	NOTHING_block            = 1ULL << 30,
 
+	AIRPORT_CLOSED_block     = 1ULL << 32;
+
 struct AirportMovingData {
 	int16 x;
 	int16 y;
Index: src/order_gui.cpp
===================================================================
--- src/order_gui.cpp	(revision 13683)
+++ src/order_gui.cpp	(working copy)
@@ -31,6 +31,7 @@
 #include "string_func.h"
 #include "depot_base.h"
 #include "tilehighlight_func.h"
+#include "sharedinfrastructure.h"
 
 #include "table/sprites.h"
 #include "table/strings.h"
@@ -271,7 +272,7 @@
 	if (_settings_game.order.gotodepot) {
 		switch (GetTileType(tile)) {
 			case MP_RAILWAY:
-				if (v->type == VEH_TRAIN && IsTileOwner(tile, _local_player)) {
+ 				if (v->type == VEH_TRAIN && (IsTileOwner(tile, _local_player) || SharedRailwayDepots(tile, _local_player))) {
 					if (IsRailDepot(tile)) {
 						order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS);
 						if (_settings_client.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
@@ -281,7 +282,7 @@
 				break;
 
 			case MP_ROAD:
-				if (IsRoadDepot(tile) && v->type == VEH_ROAD && IsTileOwner(tile, _local_player)) {
+				if (IsRoadDepot(tile) && v->type == VEH_ROAD && (IsTileOwner(tile, _local_player) || SharedRoadDepots(tile, _local_player))) {
 					order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS);
 					if (_settings_client.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
 					return order;
@@ -290,7 +291,7 @@
 
 			case MP_STATION:
 				if (v->type != VEH_AIRCRAFT) break;
-				if (IsHangar(tile) && IsTileOwner(tile, _local_player)) {
+				if (IsHangar(tile) && (IsTileOwner(tile, _local_player) || SharedAirports(tile, _local_player))) {
 					order.MakeGoToDepot(GetStationIndex(tile), ODTFB_PART_OF_ORDERS);
 					return order;
 				}
@@ -298,9 +299,8 @@
 
 			case MP_WATER:
 				if (v->type != VEH_SHIP) break;
-				if (IsShipDepot(tile) && IsTileOwner(tile, _local_player)) {
+				if (IsShipDepot(tile) && (IsTileOwner(tile, _local_player)||SharedWaterDepots(tile, _local_player))) {
 					TileIndex tile2 = GetOtherShipDepotTile(tile);
-
 					order.MakeGoToDepot(GetDepotByTile(tile < tile2 ? tile : tile2)->index, ODTFB_PART_OF_ORDERS);
 					return order;
 				}
@@ -313,7 +313,7 @@
 	/* check waypoint */
 	if (IsTileType(tile, MP_RAILWAY) &&
 			v->type == VEH_TRAIN &&
-			IsTileOwner(tile, _local_player) &&
+			(IsTileOwner(tile, _local_player)||SharedTracks(tile, _local_player)) &&
 			IsRailWaypoint(tile)) {
 		order.MakeGoToWaypoint(GetWaypointByTile(tile)->index);
 		if (_settings_client.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
@@ -324,19 +324,23 @@
 		StationID st_index = GetStationIndex(tile);
 		const Station *st = GetStation(st_index);
 
-		if (st->owner == _current_player || st->owner == OWNER_NONE) {
 			byte facil;
 			(facil = FACIL_DOCK, v->type == VEH_SHIP) ||
 			(facil = FACIL_TRAIN, v->type == VEH_TRAIN) ||
 			(facil = FACIL_AIRPORT, v->type == VEH_AIRCRAFT) ||
 			(facil = FACIL_BUS_STOP, v->type == VEH_ROAD && IsCargoInClass(v->cargo_type, CC_PASSENGERS)) ||
 			(facil = FACIL_TRUCK_STOP, 1);
-			if (st->facilities & facil) {
-				order.MakeGoToStation(st_index);
-				if (_settings_client.gui.new_nonstop && (v->type == VEH_TRAIN || v->type == VEH_ROAD)) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
-				return order;
+			if(((facil==FACIL_DOCK) && ((st->owner == _current_player) || SharedHarbours(tile, _current_player))) ||
+  			   ((facil==FACIL_TRAIN) && ((st->owner == _current_player) || SharedRailwayStations(tile, _current_player))) ||
+  			   ((facil==FACIL_AIRPORT) && ((st->owner == _current_player) || SharedAirports(tile, _current_player))) ||
+  			   (((facil==FACIL_BUS_STOP)||(facil==FACIL_TRUCK_STOP)) && ((st->owner == _current_player) || SharedRoadStops(tile, _current_player)))) {
+  					if (st->facilities & facil) {
+  						order.MakeGoToStation(st_index);
+						if (_ctrl_pressed) order.SetLoadType(OLFB_FULL_LOAD);
+  						if (_settings_client.gui.new_nonstop && (v->type == VEH_TRAIN || v->type == VEH_ROAD)) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
+  						return order;
+  					}
 			}
-		}
 	}
 
 	/* not found */
@@ -604,6 +608,25 @@
 		this->resize.step_height = 10;
 		this->selected_order = -1;
 		this->vehicle = v;
+
+		if (_settings_client.gui.quick_goto) {
+			/*
+			 *  on order window popup:
+			 *  if only 1 or 2 station order entries -> goto button is active
+			 */
+
+			int n_st = 0;
+			const Order *order;
+			FOR_VEHICLE_ORDERS(v, order) {
+				if (order->IsType(OT_GOTO_STATION)) {
+					n_st++;
+				}
+			}
+			if (n_st < 2) {
+				OrderClick_Goto(this, 0);
+			}
+		}
+
 		if (_settings_game.order.timetabling) {
 			this->widget[ORDER_WIDGET_CAPTION].right -= 61;
 		} else {
@@ -984,7 +1007,8 @@
 
 			if (DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 16), cmd.Pack(), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER))) {
 				if (this->selected_order != -1) this->selected_order++;
-				ResetObjectToPlace();
+				/* quickgoto: GoTo button stays active */
+				if (!_settings_client.gui.quick_goto) ResetObjectToPlace();
 			}
 		}
 	}
Index: src/cargopacket.h
===================================================================
--- src/cargopacket.h	(revision 13683)
+++ src/cargopacket.h	(working copy)
@@ -7,6 +7,7 @@
 
 #include "oldpool.h"
 #include "economy_type.h"
+#include "player_type.h"
 #include "tile_type.h"
 #include "station_type.h"
 #include <list>
@@ -24,7 +25,7 @@
  * Container for cargo from the same location and time
  */
 struct CargoPacket : PoolItem<CargoPacket, CargoPacketID, &_CargoPacket_pool> {
-	Money feeder_share;     ///< Value of feeder pickup to be paid for on delivery of cargo
+	Money feeder_share[MAX_PLAYERS];     ///< Value of feeder pickup to be paid for on delivery of cargo
 	TileIndex source_xy;    ///< The origin of the cargo (first station in feeder chain)
 	TileIndex loaded_at_xy; ///< Location where this cargo has been loaded into the vehicle
 	StationID source;       ///< The station where the cargo came from first
Index: src/water_cmd.cpp
===================================================================
--- src/water_cmd.cpp	(revision 13683)
+++ src/water_cmd.cpp	(working copy)
@@ -344,7 +344,7 @@
  * @param tile end tile of stretch-dragging
  * @param flags type of operation
  * @param p1 start tile of stretch-dragging
- * @param p2 specifies canal (0), water (1) or river (2); last two can only be built in scenario editor
+ * @param p2 specifies canal (0), water (1) or river (2); water can only be built in scenario editor
  */
 CommandCost CmdBuildCanal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
@@ -356,8 +356,8 @@
 
 	if (p1 >= MapSize()) return CMD_ERROR;
 
-	/* Outside of the editor you can only build canals, not oceans */
-	if (p2 != 0 && _game_mode != GM_EDITOR) return CMD_ERROR;
+	/* Outside of the editor you may not build oceans */
+	if (p2 == 1 && _game_mode != GM_EDITOR) return CMD_ERROR;
 
 	x = TileX(tile);
 	y = TileY(tile);
@@ -380,8 +380,8 @@
 			return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
 		}
 
-		/* can't make water of water! */
-		if (IsTileType(tile, MP_WATER) && (!IsTileOwner(tile, OWNER_WATER) || p2 == 1)) continue;
+		/* skip tile if it already has the right type */
+		if (IsTileType(tile, MP_WATER) && (p2 == 1 && IsSea(tile) || (p2 == 0 && IsCanal(tile)) || (p2 == 2 && IsRiver(tile)))) continue;
 
 		ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 		if (CmdFailed(ret)) return ret;
@@ -400,6 +400,7 @@
 		}
 
 		cost.AddCost(_price.clear_water);
+		if (p2 == 2) cost.AddCost(_price.clear_water * 3);
 	} END_TILE_LOOP(tile, size_x, size_y, 0);
 
 	if (cost.GetCost() == 0) {
Index: src/economy.cpp
===================================================================
--- src/economy.cpp	(revision 13683)
+++ src/economy.cpp	(working copy)
@@ -45,6 +45,7 @@
 #include "gfx_func.h"
 #include "autoreplace_func.h"
 #include "player_gui.h"
+#include "sharedinfrastructure.h"
 
 #include "table/strings.h"
 #include "table/sprites.h"
@@ -383,6 +384,8 @@
 					DeleteWindowById(WC_VEHICLE_VIEW, v->index);
 					DeleteWindowById(WC_VEHICLE_DETAILS, v->index);
 					DeleteWindowById(WC_VEHICLE_ORDERS, v->index);
+					/* clean shared infrastructure */
+					UpdateSharedOnRemove(v->index);
 
 					if (v->IsPrimaryVehicle() || (v->type == VEH_TRAIN && IsFreeWagon(v))) {
 						switch (v->type) {
@@ -392,7 +395,11 @@
 								Vehicle *u = v;
 								do {
 									Vehicle *next = GetNextVehicle(u);
+									TileIndex old_tile = v->tile;
+									DiagDirection old_dir = DirToDiagDir(v->direction);
 									delete u;
+									/* now that vehicle is removed, clear signal */
+									UpdateSignalsOnSegment(old_tile, old_dir, GetTileOwner(old_tile));
 									u = next;
 								} while (u != NULL);
 							} break;
@@ -423,6 +430,12 @@
 			}
 		}
 	}
+	
+	/** take care of other players vehicles on bankrupt company's shared structure
+	 * at this point, there should be no vehicle left to old_player */
+	if (new_player == PLAYER_SPECTATOR) {
+		OnSharedClose(old_player, SHARED_ALL);
+	}
 
 	/*  Change ownership of tiles */
 	{
@@ -1362,8 +1375,10 @@
 	int result = 0;
 
 	Money vehicle_profit = 0; // Money paid to the train
-	Money route_profit   = 0; // The grand total amount for the route. A-D of transfer chain A-B-C-D
+	Money route_profit[MAX_PLAYERS] = {0};  // The grand total amount for the route. A-D of transfer chain A-B-C-D
+	bool route_profit_change = false;
 	Money virtual_profit = 0; // The virtual profit for entire vehicle chain
+	const Player* p;
 
 	StationID last_visited = front_v->last_station_visited;
 	Station *st = GetStation(last_visited);
@@ -1403,8 +1418,13 @@
 				/* handle end of route payment */
 				Money profit = DeliverGoods(cp->count, v->cargo_type, cp->source, last_visited, cp->source_xy, cp->days_in_transit);
 				cp->paid_for = true;
-				route_profit   += profit; // display amount paid for final route delivery, A-D of a chain A-B-C-D
-				vehicle_profit += profit - cp->feeder_share;                    // whole vehicle is not payed for transfers picked up earlier
+				FOR_ALL_PLAYERS(p) {   // display amount paid for final route delivery, A-D of a chain A-B-C-D
+					route_profit[p->index] += cp->feeder_share[p->index];
+					profit -= cp->feeder_share[p->index]; // whole vehicle is not payed for transfers picked up earlier
+				}
+				route_profit[v->owner] += profit;
+				vehicle_profit += profit;
+				route_profit_change = true;
 
 				result |= 1;
 
@@ -1420,7 +1440,7 @@
 
 					front_v->profit_this_year += profit << 8;
 					virtual_profit   += profit; // accumulate transfer profits for whole vehicle
-					cp->feeder_share += profit; // account for the (virtual) profit already made for the cargo packet
+					cp->feeder_share[front_v->owner] += profit; // account for the (virtual) profit already made for the cargo packet
 					cp->paid_for      = true;   // record that the cargo has been paid for to eliminate double counting
 				}
 				result |= 2;
@@ -1435,9 +1455,13 @@
 		ShowFeederIncomeAnimation(front_v->x_pos, front_v->y_pos, front_v->z_pos, virtual_profit);
 	}
 
-	if (route_profit != 0) {
+	if (route_profit_change) {
 		front_v->profit_this_year += vehicle_profit << 8;
-		SubtractMoneyFromPlayer(CommandCost(front_v->GetExpenseType(true), -route_profit));
+		FOR_ALL_PLAYERS(p) {
+			_current_player = p->index;
+			SubtractMoneyFromPlayer(CommandCost(front_v->GetExpenseType(true), -route_profit[p->index]));
+		}
+		_current_player = front_v->owner;
 
 		if (IsLocalPlayer() && !PlayVehicleSound(front_v, VSE_LOAD_UNLOAD)) {
 			SndPlayVehicleFx(SND_14_CASHTILL, front_v);
Index: src/variables.h
===================================================================
--- src/variables.h	(revision 13683)
+++ src/variables.h	(working copy)
@@ -69,6 +69,10 @@
 /* landscape.cpp */
 extern const byte _tileh_to_sprite[32];
 
+/* station_gui.c */
+VARDEF uint16 _stations_Nearby_List[15];
+VARDEF uint8 _stations_Nearby_Count;
+
 /* misc */
 VARDEF char _screenshot_name[128];
 VARDEF byte _vehicle_design_names;
Index: src/news_gui.cpp
===================================================================
--- src/news_gui.cpp	(revision 13683)
+++ src/news_gui.cpp	(working copy)
@@ -133,6 +133,7 @@
 	{ NT_COMPANY_INFO,    NM_NORMAL,   NF_NONE,                DrawNewsBankrupcy       }, ///< NS_COMPANY_BANKRUPT
 	{ NT_COMPANY_INFO,    NM_NORMAL,   NF_TILE,                DrawNewsBankrupcy       }, ///< NS_COMPANY_NEW
 	{ NT_OPENCLOSE,       NM_THIN,     NF_VIEWPORT|NF_TILE,    NULL                    }, ///< NS_OPENCLOSE
+	{ NT_COMPANY_INFO,    NM_NORMAL,   NF_VIEWPORT | NF_TILE,  NULL                    }, ///< NS_COMPANY_SHARING
 	{ NT_ECONOMY,         NM_NORMAL,   NF_NONE,                NULL                    }, ///< NS_ECONOMY
 	{ NT_INDUSTRY_PLAYER, NM_THIN,     NF_VIEWPORT|NF_TILE,    NULL                    }, ///< NS_INDUSTRY_PLAYER
 	{ NT_INDUSTRY_OTHER,  NM_THIN,     NF_VIEWPORT|NF_TILE,    NULL                    }, ///< NS_INDUSTRY_OTHER
Index: src/vehicle_gui.cpp
===================================================================
--- src/vehicle_gui.cpp	(revision 13683)
+++ src/vehicle_gui.cpp	(working copy)
@@ -1844,16 +1844,17 @@
 		const Vehicle *v = GetVehicle(this->window_number);
 		StringID str;
 		bool is_localplayer = v->owner == _local_player;
+		TileIndex tile = v->tile;
+		bool is_trackowner  = IsTileOwner(tile,_local_player);
 		bool refitable_and_stopped_in_depot = IsVehicleRefitable(v);
 
 		this->SetWidgetDisabledState(VVW_WIDGET_GOTO_DEPOT, !is_localplayer);
-		this->SetWidgetDisabledState(VVW_WIDGET_REFIT_VEH,
-																!refitable_and_stopped_in_depot || !is_localplayer);
+		this->SetWidgetDisabledState(VVW_WIDGET_REFIT_VEH, !refitable_and_stopped_in_depot || !is_localplayer);
 		this->SetWidgetDisabledState(VVW_WIDGET_CLONE_VEH, !is_localplayer);
 
 		if (v->type == VEH_TRAIN) {
-			this->SetWidgetDisabledState(VVW_WIDGET_FORCE_PROCEED, !is_localplayer);
-			this->SetWidgetDisabledState(VVW_WIDGET_TURN_AROUND, !is_localplayer);
+			this->SetWidgetDisabledState(VVW_WIDGET_FORCE_PROCEED, !is_trackowner);
+			this->SetWidgetDisabledState(VVW_WIDGET_TURN_AROUND, !is_trackowner);
 
 			/* Cargo refit button is disabled, until we know we can enable it below. */
 
Index: src/cargopacket.cpp
===================================================================
--- src/cargopacket.cpp	(revision 13683)
+++ src/cargopacket.cpp	(working copy)
@@ -8,6 +8,7 @@
 #include "cargopacket.h"
 #include "saveload.h"
 #include "oldpool_func.h"
+#include "player_base.h"
 
 /* Initialize the cargopacket-pool */
 DEFINE_OLD_POOL_GENERIC(CargoPacket, CargoPacket)
@@ -21,6 +22,8 @@
 
 CargoPacket::CargoPacket(StationID source, uint16 count)
 {
+	const Player* p;
+
 	if (source != INVALID_STATION) assert(count != 0);
 
 	this->source          = source;
@@ -29,7 +32,8 @@
 
 	this->count           = count;
 	this->days_in_transit = 0;
-	this->feeder_share    = 0;
+	FOR_ALL_PLAYERS(p)
+		this->feeder_share[p->index]= 0;
 	this->paid_for        = false;
 }
 
@@ -49,7 +53,8 @@
 	SLE_VAR(CargoPacket, loaded_at_xy,    SLE_UINT32),
 	SLE_VAR(CargoPacket, count,           SLE_UINT16),
 	SLE_VAR(CargoPacket, days_in_transit, SLE_UINT8),
-	SLE_VAR(CargoPacket, feeder_share,    SLE_INT64),
+	SLE_CONDVAR(CargoPacket, feeder_share[0], SLE_INT64, 0, SL_VERSION_PATCH),
+	SLE_CONDARR(CargoPacket, feeder_share,    SLE_INT64, MAX_PLAYERS, SL_VERSION_PATCH, SL_MAX_VERSION),
 	SLE_VAR(CargoPacket, paid_for,        SLE_BOOL),
 
 	SLE_END()
@@ -142,13 +147,16 @@
 
 void CargoList::Append(CargoPacket *cp)
 {
+	const Player* p;
+
 	assert(cp != NULL);
 	assert(cp->IsValid());
 
 	for (List::iterator it = packets.begin(); it != packets.end(); it++) {
 		if ((*it)->SameSource(cp) && (*it)->count + cp->count <= 65535) {
 			(*it)->count        += cp->count;
-			(*it)->feeder_share += cp->feeder_share;
+			FOR_ALL_PLAYERS(p)
+				(*it)->feeder_share[p->index] += cp->feeder_share[p->index];
 			delete cp;
 
 			InvalidateCache();
@@ -189,6 +197,7 @@
 {
 	assert(mta == MTA_FINAL_DELIVERY || dest != NULL);
 	CargoList tmp;
+	const Player* p;
 
 	while (!packets.empty() && count > 0) {
 		CargoPacket *cp = *packets.begin();
@@ -223,14 +232,16 @@
 				cp_new->loaded_at_xy    = (mta == MTA_CARGO_LOAD) ? data : cp->loaded_at_xy;
 
 				cp_new->days_in_transit = cp->days_in_transit;
-				cp_new->feeder_share    = cp->feeder_share / count;
+				FOR_ALL_PLAYERS(p)
+					cp_new->feeder_share[p->index] = cp->feeder_share[p->index] / count;
 				/* When cargo is moved into another vehicle you have *always* paid for it */
 				cp_new->paid_for        = (mta == MTA_CARGO_LOAD) ? false : cp->paid_for;
 
 				cp_new->count = count;
 				dest->packets.push_back(cp_new);
 
-				cp->feeder_share /= cp->count - count;
+				FOR_ALL_PLAYERS(p)
+					cp->feeder_share[p->index] /= cp->count - count;
 			}
 			cp->count -= count;
 
@@ -260,6 +271,7 @@
 	feeder_share = 0;
 	source = INVALID_STATION;
 	days_in_transit = 0;
+	const Player* p;
 
 	if (empty) return;
 
@@ -268,7 +280,8 @@
 		count        += (*it)->count;
 		unpaid_cargo |= !(*it)->paid_for;
 		dit          += (*it)->days_in_transit * (*it)->count;
-		feeder_share += (*it)->feeder_share;
+		FOR_ALL_PLAYERS(p)
+			feeder_share += (*it)->feeder_share[p->index];
 	}
 	days_in_transit = dit / count;
 	source = (*packets.begin())->source;
Index: src/gui.h
===================================================================
--- src/gui.h	(revision 13683)
+++ src/gui.h	(working copy)
@@ -61,7 +61,7 @@
 void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y);
 
 void ShowSmallMap();
-void ShowExtraViewPortWindow(TileIndex tile = INVALID_TILE);
+int ShowExtraViewPortWindow(TileIndex tile = INVALID_TILE);
 
 void BuildFileList();
 void SetFiosType(const byte fiostype);
Index: src/newgrf_station.cpp
===================================================================
--- src/newgrf_station.cpp	(revision 13683)
+++ src/newgrf_station.cpp	(working copy)
@@ -827,7 +827,7 @@
 }
 
 
-static const StationSpec* GetStationSpec(TileIndex t)
+const StationSpec* GetStationSpec(TileIndex t)
 {
 	const Station* st;
 	uint specindex;
Index: src/pathfind.cpp
===================================================================
--- src/pathfind.cpp	(revision 13683)
+++ src/pathfind.cpp	(working copy)
@@ -17,6 +17,7 @@
 #include "core/random_func.hpp"
 #include "core/alloc_type.hpp"
 #include "tunnelbridge.h"
+#include "sharedinfrastructure.h"
 
 /* remember which tiles we have already visited so we don't visit them again. */
 static bool TPFSetTileBit(TrackPathFinder *tpf, TileIndex tile, int dir)
Index: src/rev.cpp.in
===================================================================
--- src/rev.cpp.in	(revision 13683)
+++ src/rev.cpp.in	(working copy)
@@ -20,7 +20,7 @@
  * norev000 is for non-releases that are made on systems without
  * subversion or sources that are not a checkout of subversion.
  */
-const char _openttd_revision[] = "@@VERSION@@";
+const char _openttd_revision[] = "r13683-wwottdgd2";
 
 /**
  * Let us know if current build was modified. This detection
Index: src/network/network_type.h
===================================================================
--- src/network/network_type.h	(revision 13683)
+++ src/network/network_type.h	(working copy)
@@ -18,7 +18,7 @@
 	 *  players that can really play.. so.. a max of 4 spectators.. gives us..
 	 *  MAX_PLAYERS + 3
 	 */
-	MAX_CLIENTS = MAX_PLAYERS + 3,
+	MAX_CLIENTS = MAX_PLAYERS + 47,
 
 	/** Do not change this next line. It should _ALWAYS_ be MAX_CLIENTS + 1 */
 	MAX_CLIENT_INFO = MAX_CLIENTS + 1,
@@ -57,6 +57,7 @@
 	uint32 client_ip;                               ///< IP-address of the client (so he can be banned)
 	Date join_date;                                 ///< Gamedate the player has joined
 	char unique_id[NETWORK_UNIQUE_ID_LENGTH];       ///< Every play sends an unique id so we can indentify him
+	byte mute;                                       ///< Contains the mute status
 };
 
 enum NetworkPasswordType {
Index: src/network/core/tcp.h
===================================================================
--- src/network/core/tcp.h	(revision 13683)
+++ src/network/core/tcp.h	(working copy)
@@ -55,6 +55,7 @@
 	PACKET_CLIENT_RCON,
 	PACKET_SERVER_CHECK_NEWGRFS,
 	PACKET_CLIENT_NEWGRFS_CHECKED,
+	PACKET_CLIENT_MOVE,
 	PACKET_END                   ///< Must ALWAYS be on the end of this list!! (period)
 };
 
Index: src/network/network_func.h
===================================================================
--- src/network/network_func.h	(revision 13683)
+++ src/network/network_func.h	(working copy)
@@ -53,9 +53,11 @@
 NetworkClientInfo *NetworkFindClientInfoFromIP(const char *ip);
 const char* GetPlayerIP(const NetworkClientInfo *ci);
 
+void NetworkServerSendMove(uint16 client_index, PlayerID new_player);
 void NetworkServerSendRcon(uint16 client_index, ConsoleColour colour_code, const char *string);
 void NetworkServerSendError(uint16 client_index, NetworkErrorCode error);
 void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const char *msg, uint16 from_index);
+void NetworkServerSendMuteStatus(uint16 client_index);
 
 #define FOR_ALL_ACTIVE_CLIENT_INFOS(ci) for (ci = _network_client_info; ci != endof(_network_client_info); ci++) if (ci->client_index != NETWORK_EMPTY_INDEX)
 
Index: src/network/network_server.cpp
===================================================================
--- src/network/network_server.cpp	(revision 13683)
+++ src/network/network_server.cpp	(working copy)
@@ -58,6 +58,7 @@
 		p->Send_uint8 (ci->client_playas);
 		p->Send_string(ci->client_name);
 		p->Send_string(ci->unique_id);
+		p->Send_uint8(ci->mute);
 
 		cs->Send_Packet(p);
 	}
@@ -599,6 +600,17 @@
 	cs->Send_Packet(p);
 }
 
+DEF_SERVER_SEND_COMMAND_PARAM(PACKET_CLIENT_MOVE)(NetworkTCPSocketHandler *cs, uint16 client_index, PlayerID new_player)
+{
+	Packet *p = NetworkSend_Init(PACKET_CLIENT_MOVE);
+
+	DEBUG(net, 0, "[move] client %d to player %d", client_index, min(new_player+1, PLAYER_SPECTATOR));
+
+	p->Send_uint16(client_index);
+	p->Send_uint8(new_player);
+	cs->Send_Packet(p);
+}
+
 // **********
 // Receiving functions
 //   DEF_SERVER_RECEIVE_COMMAND has parameter: NetworkTCPSocketHandler *cs, Packet *p
@@ -893,6 +905,12 @@
 		return;
 	}
 
+	/* handle terraform commands */
+	if ((cp->cmd & 0xff) == CMD_TERRAFORM_LAND || (cp->cmd & 0xff) == CMD_LEVEL_LAND) {
+		if (!HasBit(_settings_game.construction.allow_terraform, cp->player)) return;
+		DEBUG(misc, 1, "Client %u (Player %u) terraformed tile %x", ci->client_index, cp->player, cp->tile);
+	}
+
 	if (!CheckCommandFlags(cp, ci)) {
 		SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_KICKED);
 		free(cp);
@@ -1061,10 +1079,12 @@
 void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, const char *msg, uint16 from_index)
 {
 	NetworkTCPSocketHandler *cs;
-	const NetworkClientInfo *ci, *ci_own, *ci_to;
+	const NetworkClientInfo *ci, *ci_own, *ci_to, *ci_from;
+	ci_from = NetworkFindClientInfoFromIndex(from_index);
 
 	switch (desttype) {
 	case DESTTYPE_CLIENT:
+		if (ci_from != NULL && HasBit(ci_from->mute, 3)) break;
 		/* Are we sending to the server? */
 		if (dest == NETWORK_SERVER_INDEX) {
 			ci = NetworkFindClientInfoFromIndex(from_index);
@@ -1101,6 +1121,7 @@
 	case DESTTYPE_TEAM: {
 		bool show_local = true; // If this is false, the message is already displayed
 														// on the client who did sent it.
+		if (ci_from != NULL && HasBit(ci_from->mute, 2)) break;
 		/* Find all clients that belong to this player */
 		ci_to = NULL;
 		FOR_ALL_CLIENTS(cs) {
@@ -1145,6 +1166,7 @@
 		DEBUG(net, 0, "[server] received unknown chat destination type %d. Doing broadcast instead", desttype);
 		/* fall-through to next case */
 	case DESTTYPE_BROADCAST:
+		if (ci_from != NULL && HasBit(ci_from->mute, 1)) break;
 		FOR_ALL_CLIENTS(cs) {
 			SEND_COMMAND(PACKET_SERVER_CHAT)(cs, action, from_index, false, msg);
 		}
@@ -1284,6 +1306,7 @@
 	RECEIVE_COMMAND(PACKET_CLIENT_RCON),
 	NULL, /*PACKET_CLIENT_CHECK_NEWGRFS,*/
 	RECEIVE_COMMAND(PACKET_CLIENT_NEWGRFS_CHECKED),
+	NULL /*PACKET_CLIENT_MOVE,*/
 };
 
 // If this fails, check the array above with network_data.h
@@ -1676,6 +1699,11 @@
 	}
 }
 
+void NetworkServerSendMove(uint16 client_index, PlayerID new_player)
+{
+	SEND_COMMAND(PACKET_CLIENT_MOVE)(NetworkFindClientStateFromIndex(client_index), client_index, new_player);
+}
+
 void NetworkServerSendRcon(uint16 client_index, ConsoleColour colour_code, const char *string)
 {
 	SEND_COMMAND(PACKET_SERVER_RCON)(NetworkFindClientStateFromIndex(client_index), colour_code, string);
@@ -1696,4 +1724,10 @@
 	}
 	return false;
 }
+
+void NetworkServerSendMuteStatus(uint16 client_index) 
+{
+	if (NetworkFindClientStateFromIndex(client_index)->status != STATUS_ACTIVE) return;
+	NetworkUpdateClientInfo(client_index);
+}
 #endif /* ENABLE_NETWORK */
Index: src/network/network_server.h
===================================================================
--- src/network/network_server.h	(revision 13683)
+++ src/network/network_server.h	(working copy)
@@ -13,6 +13,7 @@
 DEF_SERVER_SEND_COMMAND(PACKET_SERVER_SHUTDOWN);
 DEF_SERVER_SEND_COMMAND(PACKET_SERVER_NEWGAME);
 DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_RCON)(NetworkTCPSocketHandler *cs, uint16 color, const char *command);
+DEF_SERVER_SEND_COMMAND_PARAM(PACKET_CLIENT_MOVE)(NetworkTCPSocketHandler *cs, uint16 client_index, uint8 player_index);
 
 bool NetworkServer_ReadPackets(NetworkTCPSocketHandler *cs);
 void NetworkServer_Tick(bool send_frame);
Index: src/network/network_client.cpp
===================================================================
--- src/network/network_client.cpp	(revision 13683)
+++ src/network/network_client.cpp	(working copy)
@@ -7,6 +7,7 @@
 #include "../stdafx.h"
 #include "../debug.h"
 #include "../openttd.h"
+#include "../gfx_func.h"
 #include "network_internal.h"
 #include "core/tcp.h"
 #include "network_client.h"
@@ -27,7 +28,6 @@
 #include "../player_base.h"
 #include "../player_gui.h"
 #include "../rev.h"
-
 #include "table/strings.h"
 
 // This file handles all the client-commands
@@ -129,6 +129,9 @@
 	_network_join_status = NETWORK_JOIN_STATUS_AUTHORIZING;
 	InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0);
 
+	/* force clients to join as PLAYER_SPECTATOR */
+	_network_playas = PLAYER_SPECTATOR;
+
 	p = NetworkSend_Init(PACKET_CLIENT_JOIN);
 	p->Send_string(_openttd_revision);
 	p->Send_string(_settings_client.network.player_name); // Player name
@@ -396,6 +399,7 @@
 //  which is always an unique number on a server.
 DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO)
 {
+	const Player *player;
 	NetworkClientInfo *ci;
 	uint16 index = p->Recv_uint16();
 	PlayerID playas = (Owner)p->Recv_uint8();
@@ -404,6 +408,7 @@
 
 	p->Recv_string(name, sizeof(name));
 	p->Recv_string(unique_id, sizeof(unique_id));
+	byte muted = (byte)p->Recv_uint8();
 
 	if (MY_CLIENT->has_quit) return NETWORK_RECV_STATUS_CONN_LOST;
 
@@ -416,14 +421,34 @@
 			// Client name changed, display the change
 			NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, false, ci->client_name, "%s", name);
 		} else if (playas != ci->client_playas) {
-			// The player changed from client-player..
-			// Do not display that for now
+			/* Client has been moved to another company or to spectator, show a message. */
+			if (ci->client_playas != PLAYER_NEW_COMPANY && ci->client_playas != PLAYER_INACTIVE_CLIENT) {
+				/* if not valid player, force spectator, else check player exists */
+				if (!IsValidPlayer(playas)) {
+					playas = PLAYER_SPECTATOR;
+				} else {
+					/* only if it's a valid player, actually get the player and check it */
+					player = GetPlayer(playas);
+					if (!player->is_active) {
+						playas = PLAYER_SPECTATOR;
+					}
+				}
+				
+				if (playas == PLAYER_SPECTATOR || playas > MAX_PLAYERS) {
+					NetworkTextMessage(NETWORK_ACTION_SERVER_MESSAGE, CC_DEFAULT, false, ci->client_name, "'%s' Moved To Spectators", ci->client_name);
+				} else {
+					NetworkTextMessage(NETWORK_ACTION_SERVER_MESSAGE, CC_DEFAULT, false, ci->client_name, "'%s' Moved To Company #%d", ci->client_name, playas+1);
+				}
+			}
 		}
 
 		ci->client_playas = playas;
 		ttd_strlcpy(ci->client_name, name, sizeof(ci->client_name));
+		ci->mute = muted;
 
 		InvalidateWindow(WC_CLIENT_LIST, 0);
+		InvalidateWindow(WC_MOVE_PLAYER, 0);
+		InvalidateWindow(WC_MUTE_PLAYER, 0);
 
 		return NETWORK_RECV_STATUS_OKAY;
 	}
@@ -857,6 +882,51 @@
 	return NETWORK_RECV_STATUS_OKAY;
 }
 
+DEF_CLIENT_RECEIVE_COMMAND(PACKET_CLIENT_MOVE)
+{
+	const Player *player;
+	uint16 client_index;
+	PlayerID player_index;
+	
+	/* Nothing more in this packet... */
+	client_index = p->Recv_uint16();
+	player_index = (Owner)p->Recv_uint8();
+	
+	if (client_index == 0) {
+		/* deffinately an invalide client id, debug message and do nothing. */
+		DEBUG(net, 0, "[move] received client index = 0");
+		return NETWORK_RECV_STATUS_OKAY;
+	}
+	
+	const NetworkClientInfo *ci = NetworkFindClientInfoFromIndex(client_index);
+	/* Just make sure we do not try to use a client_index that does not exist */
+	if (ci != NULL) {
+		/* if not valid player, force spectator, else check player exists */
+		if (!IsValidPlayer(player_index)) {
+			player_index = PLAYER_SPECTATOR;
+		} else {
+			/* only if it's a valid player, actually get the player and check it */
+			player = GetPlayer(player_index);
+			if (!player->is_active) {
+				player_index = PLAYER_SPECTATOR;
+			}
+		}
+		
+		if (client_index == _network_own_client_index) {
+			/* this packet is actually for this client... apply the new player_index */
+			DEBUG(net, 0, "[move] client %d to player %d", client_index, min(player_index+1, PLAYER_SPECTATOR));
+			
+			_network_playas = player_index;
+			SetLocalPlayer(player_index);
+			
+			/* Disable any buttons in any windows the client is now not supposed to get to, and do it fast. */
+			/* If this is not done fast enough, it can cause the client to be kicked or have an assert! */
+			MarkWholeScreenDirty();
+		}
+	}
+	
+	return NETWORK_RECV_STATUS_OKAY;
+}
 
 
 // The layout for the receive-functions by the client
@@ -901,6 +971,7 @@
 	NULL, /*PACKET_CLIENT_RCON,*/
 	RECEIVE_COMMAND(PACKET_SERVER_CHECK_NEWGRFS),
 	NULL, /*PACKET_CLIENT_NEWGRFS_CHECKED,*/
+	RECEIVE_COMMAND(PACKET_CLIENT_MOVE),
 };
 
 // If this fails, check the array above with network_data.h
Index: src/network/network_gui.cpp
===================================================================
--- src/network/network_gui.cpp	(revision 13683)
+++ src/network/network_gui.cpp	(working copy)
@@ -31,6 +31,9 @@
 #include "../widgets/dropdown_func.h"
 #include "../querystring_gui.h"
 #include "../sortlist_type.h"
+#include "../player_base.h"
+#include "../debug.h"
+#include "../console_func.h"
 
 #include "table/strings.h"
 #include "../table/sprites.h"
@@ -43,6 +46,10 @@
 static void ShowNetworkStartServerWindow();
 static void ShowNetworkLobbyWindow(NetworkGameList *ngl);
 extern void SwitchMode(int new_mode);
+static void ShowMovePlayerWindow();
+byte _current_move_window_client;
+byte _current_mute_window_client;
+static void ShowMutePlayerWindow();
 
 static const StringID _connection_types_dropdown[] = {
 	STR_NETWORK_LAN_INTERNET,
@@ -1183,10 +1190,10 @@
 
 static const Widget _client_list_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                 STR_018B_CLOSE_WINDOW},
-{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   237,     0,    13, STR_NETWORK_CLIENT_LIST,  STR_018C_WINDOW_TITLE_DRAG_THIS},
-{  WWT_STICKYBOX,   RESIZE_NONE,    14,   238,   249,     0,    13, STR_NULL,                 STR_STICKY_BUTTON},
+{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   287,     0,    13, STR_NETWORK_CLIENT_LIST,  STR_018C_WINDOW_TITLE_DRAG_THIS},
+{  WWT_STICKYBOX,   RESIZE_NONE,    14,   288,   299,     0,    13, STR_NULL,                 STR_STICKY_BUTTON},
 
-{      WWT_PANEL,   RESIZE_NONE,    14,     0,   249,    14,    14 + CLNWND_ROWSIZE + 1, 0x0, STR_NULL},
+{      WWT_PANEL,   RESIZE_NONE,    14,     0,   299,    14,    14 + CLNWND_ROWSIZE + 1, 0x0, STR_NULL},
 {   WIDGETS_END},
 };
 
@@ -1196,7 +1203,7 @@
 };
 
 static const WindowDesc _client_list_desc = {
-	WDP_AUTO, WDP_AUTO, 250, 1, 250, 1,
+	WDP_AUTO, WDP_AUTO, 300, 1, 300, 1,
 	WC_CLIENT_LIST, WC_NONE,
 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
 	_client_list_widgets,
@@ -1218,12 +1225,28 @@
 // Here we start to define the options out of the menu
 static void ClientList_Kick(byte client_no)
 {
-	if (client_no < MAX_PLAYERS)
-		SEND_COMMAND(PACKET_SERVER_ERROR)(DEREF_CLIENT(client_no), NETWORK_ERROR_KICKED);
+	char kick_rcon_command[15];
+	if (client_no < MAX_PLAYERS) {
+	
+		if (_network_server) {
+			SEND_COMMAND(PACKET_SERVER_ERROR)(DEREF_CLIENT(client_no), NETWORK_ERROR_KICKED);
+		}
+		else if (_networking && _settings_client.network.rcon_password[0] != '\0') {
+			sprintf(kick_rcon_command, "kick %d", DEREF_CLIENT_INFO(DEREF_CLIENT(client_no))->client_index);
+			NetworkClientSendRcon(_settings_client.network.rcon_password, kick_rcon_command);
+		}
+	}
 }
 
 static void ClientList_Ban(byte client_no)
 {
+	char ban_rcon_command[15];
+	if (_networking && _settings_client.network.rcon_password[0] != '\0') {
+		sprintf(ban_rcon_command, "ban %d", DEREF_CLIENT_INFO(DEREF_CLIENT(client_no))->client_index);
+		NetworkClientSendRcon(_settings_client.network.rcon_password, ban_rcon_command);
+		return;
+	}
+	
 	uint32 ip = NetworkFindClientInfo(client_no)->client_ip;
 
 	for (uint i = 0; i < lengthof(_network_ban_list); i++) {
@@ -1264,6 +1287,18 @@
 	ShowNetworkChatQueryWindow(DESTTYPE_BROADCAST, 0);
 }
 
+static void ClientList_Move(byte client_no)
+{
+	_current_move_window_client = client_no;
+	ShowMovePlayerWindow();
+}
+
+static void ClientList_Mute(byte client_no)
+{
+	_current_mute_window_client = client_no;
+	ShowMutePlayerWindow();
+}
+
 static void ClientList_None(byte client_no)
 {
 	/* No action ;) */
@@ -1286,20 +1321,22 @@
 		 * Watch is, max 50 chars long!
 		 */
 
-		const NetworkClientInfo *ci = NetworkFindClientInfo(client_no);
+		const NetworkClientInfo *ci = NetworkFindClientInfo(client_no), *own_ci = NetworkFindClientInfoFromIndex(_network_own_client_index);
 
 		int i = 0;
-		if (_network_own_client_index != ci->client_index) {
+		if (_network_own_client_index != ci->client_index && !HasBit(own_ci->mute, 3)) {
 			GetString(this->action[i], STR_NETWORK_CLIENTLIST_SPEAK_TO_CLIENT, lastof(this->action[i]));
 			this->proc[i++] = &ClientList_SpeakToClient;
 		}
 
-		if (IsValidPlayer(ci->client_playas) || ci->client_playas == PLAYER_SPECTATOR) {
+		if (IsValidPlayer(ci->client_playas) || ci->client_playas == PLAYER_SPECTATOR && !HasBit(own_ci->mute, 2)) {
 			GetString(this->action[i], STR_NETWORK_CLIENTLIST_SPEAK_TO_COMPANY, lastof(this->action[i]));
 			this->proc[i++] = &ClientList_SpeakToCompany;
 		}
-		GetString(this->action[i], STR_NETWORK_CLIENTLIST_SPEAK_TO_ALL, lastof(this->action[i]));
-		this->proc[i++] = &ClientList_SpeakToAll;
+		if (!HasBit(own_ci->mute, 1)) {
+			GetString(this->action[i], STR_NETWORK_CLIENTLIST_SPEAK_TO_ALL, lastof(this->action[i]));
+			this->proc[i++] = &ClientList_SpeakToAll;
+		}
 
 		if (_network_own_client_index != ci->client_index) {
 			/* We are no spectator and the player we want to give money to is no spectator and money gifts are allowed */
@@ -1308,15 +1345,27 @@
 				this->proc[i++] = &ClientList_GiveMoney;
 			}
 		}
+		
 
+
 		/* A server can kick clients (but not himself) */
-		if (_network_server && _network_own_client_index != ci->client_index) {
+		if ((_network_server && _network_own_client_index != ci->client_index) || (_settings_client.network.rcon_password[0] != '\0' && ci->client_index != NETWORK_SERVER_INDEX && ci->client_index != _network_own_client_index)) {
 			GetString(this->action[i], STR_NETWORK_CLIENTLIST_KICK, lastof(this->action[i]));
 			this->proc[i++] = &ClientList_Kick;
 
 			sprintf(this->action[i],"Ban"); // XXX GetString?
 			this->proc[i++] = &ClientList_Ban;
 		}
+		
+		if ((_network_server || (_settings_client.network.rcon_password[0] != 0)) && ci->client_index != NETWORK_SERVER_INDEX) {
+			GetString(this->action[i], STR_NETWORK_CLIENTLIST_MOVE, lastof(this->action[i]));
+			this->proc[i++] = &ClientList_Move;
+		}
+		
+		if (ci->client_index != NETWORK_SERVER_INDEX && _network_own_client_index != ci->client_index && (_network_server || (_settings_client.network.rcon_password[0] != 0))) {
+			GetString(this->action[i], STR_NETWORK_CLIENTLIST_MUTE, lastof(this->action[i]));
+			this->proc[i++] = &ClientList_Mute;
+		}
 
 		if (i == 0) {
 			GetString(this->action[i], STR_NETWORK_CLIENTLIST_NONE, lastof(this->action[i]));
@@ -1493,9 +1542,14 @@
 
 			/* Filter out spectators */
 			if (IsValidPlayer(ci->client_playas)) DrawPlayerIcon(ci->client_playas, 64, y + 1);
+						
+			char id_line[20];
+ 			char name_line[52];
+			sprintf(id_line,"#%d", ci->client_index);
+			sprintf(name_line,": %s", ci->client_name);
+			DoDrawString(id_line, 87, y, colour);
+			DoDrawString(name_line, 127, y, colour);
 
-			DoDrawString(ci->client_name, 81, y, colour);
-
 			y += CLNWND_ROWSIZE;
 		}
 	}
@@ -1876,6 +1930,7 @@
 void ShowNetworkChatQueryWindow(DestType type, int dest)
 {
 	DeleteWindowById(WC_SEND_NETWORK_MSG, 0);
+	if (HasBit(NetworkFindClientInfoFromIndex(_network_own_client_index)->mute, type + 1)) return;
 	new NetworkChatWindow (&_chat_window_desc, type, dest);
 }
 
@@ -1983,9 +2038,171 @@
 
 void ShowNetworkCompanyPasswordWindow(Window *parent)
 {
-	DeleteWindowById(WC_COMPANY_PASSWORD_WINDOW, 0);
+	DeleteWindowById(WC_MOVE_PLAYER, 0);
 
 	new NetworkCompanyPasswordWindow(&_ncp_window_desc, parent);
 }
 
+enum MovePlayerWindowWidgets {
+	MPW_CLOSE,
+	MPW_CAPTION,
+	MPW_BACKGROUND,
+	MPW_SPECTATORS,
+	MPW_FIRST_COMPANY,
+	MPW_LAST_COMPANY = 11
+};
+
+struct MovePlayerWindow : Window {
+	MovePlayerWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
+	{
+		this->FindWindowPlacementAndResize(desc);
+	}
+
+	virtual void OnPaint()
+	{
+		const Player *p;
+
+
+		this->DrawWidgets();
+		NetworkClientInfo *move_ci = DEREF_CLIENT_INFO(DEREF_CLIENT(_current_move_window_client));
+
+		FOR_ALL_PLAYERS(p) {
+			if (!p->is_active) continue;
+
+			DrawPlayerIcon(p->index, 4, 18 + (p->index+1) * 12);
+
+			SetDParam(0, p->index);
+			SetDParam(1, p->index);
+			
+			DrawString(21, 17 + (p->index+1) * 12, STR_7021, TC_WHITE);
+			if (move_ci->client_playas == p->index) this->LowerWidget(p->index + MPW_FIRST_COMPANY);
+		}
+		if (move_ci->client_playas == PLAYER_SPECTATOR) this->LowerWidget(MPW_SPECTATORS);
+		DrawString(21, 17, STR_MOVE_PLAYER_SPECTATORS, TC_WHITE);
+	}
+
+	virtual void OnClick(Point pt, int widget)
+	{
+		if (!IsInsideMM(widget, MPW_SPECTATORS, MPW_LAST_COMPANY + 1)) return;
+		PlayerID PId;
+		char move_rcon_command[20];
+		NetworkClientInfo *move_ci = DEREF_CLIENT_INFO(DEREF_CLIENT(_current_move_window_client));
+		if (widget == MPW_SPECTATORS) PId = PLAYER_SPECTATOR;
+		else {
+			PId = (PlayerID)(widget - 4);
+		}
+		if (PId == move_ci->client_playas) return;
+		if (IsValidPlayer(PId) && GetPlayer(PId)->is_active || PId == PLAYER_SPECTATOR) {
+			DEBUG(misc, 0, "widget: %d playerid: %d", widget, PId);
+			if (PId ==PLAYER_SPECTATOR) sprintf(move_rcon_command, "move %d", move_ci->client_index);
+			else sprintf(move_rcon_command, "move %d %d", move_ci->client_index, PId + 1);
+			if (_network_server) {
+				IConsoleCmdExec(move_rcon_command);
+			}
+			else {
+				NetworkClientSendRcon(_settings_client.network.rcon_password, move_rcon_command);
+			}
+		}
+		else return;
+		DeleteWindowById(WC_MOVE_PLAYER, 0);
+	}
+};
+
+static const Widget _move_player_widgets[] = {
+{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
+{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   249,     0,    13, STR_MOVE_PLAYER_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
+{      WWT_PANEL,   RESIZE_NONE,    14,     0,   249,    14,   125, 0x0,                            STR_NULL},
+{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    16,    27, 0x0,                            STR_MOVE_PLAYER_TOOLTIP},
+{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    28,    39, 0x0,                            STR_MOVE_PLAYER_TOOLTIP},
+{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    40,    51, 0x0,                            STR_MOVE_PLAYER_TOOLTIP},
+{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    52,    63, 0x0,                            STR_MOVE_PLAYER_TOOLTIP},
+{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    64,    75, 0x0,                            STR_MOVE_PLAYER_TOOLTIP},
+{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    76,    87, 0x0,                            STR_MOVE_PLAYER_TOOLTIP},
+{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    88,    99, 0x0,                            STR_MOVE_PLAYER_TOOLTIP},
+{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,   100,   111, 0x0,                            STR_MOVE_PLAYER_TOOLTIP},
+{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,   112,   123, 0x0,                            STR_MOVE_PLAYER_TOOLTIP},
+{   WIDGETS_END},
+};
+
+static const WindowDesc _move_player_desc = {
+	WDP_AUTO, WDP_AUTO, 250, 126, 250, 126,
+	WC_MOVE_PLAYER, WC_NONE,
+	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
+	_move_player_widgets,
+};
+
+static void ShowMovePlayerWindow()
+{
+	DeleteWindowById(WC_MOVE_PLAYER, 0);
+	AllocateWindowDescFront<MovePlayerWindow>(&_move_player_desc, 0);
+}
+
+enum MutePlayerWindowWidgets {
+	MUPW_CLOSE,
+	MUPW_CAPTION,
+	MUPW_BACKGROUND,
+	MUPW_BROADCAST,
+	MUPW_TEAM,
+	MUPW_CLIENT
+};
+
+struct MutePlayerWindow : Window {
+	MutePlayerWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
+	{
+		this->FindWindowPlacementAndResize(desc);
+	}
+
+	virtual void OnPaint()
+	{
+
+		NetworkClientInfo *mute_ci = DEREF_CLIENT_INFO(DEREF_CLIENT(_current_mute_window_client));
+		assert(mute_ci != NULL);
+		this->SetWidgetLoweredState(MUPW_BROADCAST, HasBit(mute_ci->mute, 1));
+		this->SetWidgetLoweredState(MUPW_TEAM, HasBit(mute_ci->mute, 2));
+		this->SetWidgetLoweredState(MUPW_CLIENT, HasBit(mute_ci->mute, 3));
+		this->DrawWidgets();
+		DrawString(21,17 + 0 * 12, STR_MUTE_PLAYER_ALL, TC_WHITE);
+		DrawString(21, 17 + 1 * 12, STR_MUTE_PLAYER_TEAM, TC_WHITE);
+		DrawString(21, 17 + 2 * 12, STR_MUTE_PLAYER_PRIVATE, TC_WHITE);
+	}
+
+	virtual void OnClick(Point pt, int widget)
+	{
+		if (!IsInsideMM(widget, MUPW_BROADCAST, MUPW_CLIENT + 1)) return;
+		NetworkClientInfo *mute_ci = DEREF_CLIENT_INFO(DEREF_CLIENT(_current_mute_window_client));
+		char mute_rcon_command[12];
+		byte clicked = widget - MUPW_BROADCAST + 1;
+		sprintf(mute_rcon_command, "mute %d %d", mute_ci->client_index, clicked);
+		if (_network_server) {
+			IConsoleCmdExec(mute_rcon_command);
+		}
+		else if (_networking && _settings_client.network.rcon_password[0] != '\0'){
+			NetworkClientSendRcon(_settings_client.network.rcon_password, mute_rcon_command);
+		}
+	}
+};
+
+static const Widget _mute_player_widgets[] = {
+{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
+{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   249,     0,    13, STR_MUTE_PLAYER_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
+{      WWT_PANEL,   RESIZE_NONE,    14,     0,   249,    14,   53, 0x0,                                            STR_NULL},
+{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    16,    27, 0x0,                            STR_MUTE_PLAYER_TOOLTIP},
+{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    28,    39, 0x0,                            STR_MUTE_PLAYER_TOOLTIP},
+{      WWT_PANEL,   RESIZE_NONE,    14,     2,   247,    40,    51, 0x0,                            STR_MUTE_PLAYER_TOOLTIP},
+{   WIDGETS_END},
+};
+
+static const WindowDesc _mute_player_desc = {
+	WDP_AUTO, WDP_AUTO, 250, 54, 250, 54,
+	WC_MUTE_PLAYER, WC_NONE,
+	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
+	_mute_player_widgets,
+};
+
+static void ShowMutePlayerWindow()
+{
+	DeleteWindowById(WC_MUTE_PLAYER, 0);
+	AllocateWindowDescFront<MutePlayerWindow>(&_mute_player_desc, 0);
+}
+
 #endif /* ENABLE_NETWORK */
Index: src/yapf/follow_track.hpp
===================================================================
--- src/yapf/follow_track.hpp	(revision 13683)
+++ src/yapf/follow_track.hpp	(working copy)
@@ -6,7 +6,9 @@
 #define  FOLLOW_TRACK_HPP
 
 #include "yapf.hpp"
+#include "../rail_map.h"
 #include "../depot_map.h"
+#include "../sharedinfrastructure.h"
 
 /** Track follower helper template class (can serve pathfinders and vehicle
  *  controllers). See 6 different typedefs below for 3 different transport
@@ -217,12 +219,13 @@
 				return false;
 			}
 		}
-
-		/* single tram bits can only be entered from one direction */
-		DiagDirection single_tram = GetSingleTramBit(m_new_tile);
-		if (single_tram != INVALID_DIAGDIR && single_tram != ReverseDiagDir(m_exitdir)) {
-			m_err = EC_NO_WAY;
-			return false;
+		
+		// waypoints are not accessible to other companies
+		if ( IsTileType(m_new_tile, MP_RAILWAY) && IsRailTT() && (GetTileOwner(m_new_tile) != m_veh->owner)) {
+			if (GetRailTileType(m_new_tile) == RAIL_TILE_WAYPOINT) {
+				m_err = EC_NO_WAY;
+				return false;
+			}
 		}
 
 		// road and rail depots can also be entered from one direction only
@@ -233,25 +236,35 @@
 				return false;
 			}
 			// don't try to enter other player's depots
-			if (GetTileOwner(m_new_tile) != m_veh->owner) {
+			if ((GetTileOwner(m_new_tile) != m_veh->owner)&&(!SharedRoadDepots(m_new_tile,m_veh->owner))) {
 				m_err = EC_OWNER;
 				return false;
 			}
 		}
 		if (IsRailTT() && IsDepotTypeTile(m_new_tile, TT())) {
 			DiagDirection exitdir = GetRailDepotDirection(m_new_tile);
-			if (ReverseDiagDir(exitdir) != m_exitdir) {
+			if ((ReverseDiagDir(exitdir) != m_exitdir)||
+					(((GetTileOwner(m_new_tile) != m_veh->owner)&&
+					  (!SharedRailwayDepots(m_new_tile,m_veh->owner))))) {
 				m_err = EC_NO_WAY;
 				return false;
 			}
 		}
 
 		// rail transport is possible only on tiles with the same owner as vehicle
-		if (IsRailTT() && GetTileOwner(m_new_tile) != m_veh->owner) {
+		if (IsRailTT() && (GetTileOwner(m_new_tile) != m_veh->owner) &&
+				(GetTileOwner(m_old_tile) != GetTileOwner(m_new_tile)) && (!SharedTracks(m_new_tile,m_veh->owner))) {
 			// different owner
 			m_err = EC_NO_WAY;
 			return false;
 		}
+		
+		/* single tram bits can only be entered from one direction */
+		DiagDirection single_tram = GetSingleTramBit(m_new_tile);
+		if (single_tram != INVALID_DIAGDIR && single_tram != ReverseDiagDir(m_exitdir)) {
+			m_err = EC_NO_WAY;
+			return false;
+		}
 
 		// rail transport is possible only on compatible rail types
 		if (IsRailTT()) {
@@ -286,6 +299,11 @@
 
 		// special handling for rail stations - get to the end of platform
 		if (IsRailTT() && m_is_station) {
+			if((GetTileOwner(m_new_tile) != m_veh->owner) && (!SharedRailwayStations(m_new_tile,m_veh->owner)))
+			{
+				m_err = EC_NO_WAY;
+				return false;
+			}
 			// entered railway station
 			// get platform length
 			uint length = GetStationByTile(m_new_tile)->GetPlatformLength(m_new_tile, TrackdirToExitdir(m_old_td));
Index: src/players.cpp
===================================================================
--- src/players.cpp	(revision 13683)
+++ src/players.cpp	(working copy)
@@ -241,13 +241,15 @@
 	if (HasBit(1 << EXPENSES_TRAIN_INC    |
 	           1 << EXPENSES_ROADVEH_INC  |
 	           1 << EXPENSES_AIRCRAFT_INC |
-	           1 << EXPENSES_SHIP_INC, cost.GetExpensesType())) {
+	           1 << EXPENSES_SHIP_INC |
+	           1 << EXPENSES_SHARED_INF_INC, cost.GetExpensesType())) {
 		p->cur_economy.income -= cost.GetCost();
 	} else if (HasBit(1 << EXPENSES_TRAIN_RUN    |
 	                  1 << EXPENSES_ROADVEH_RUN  |
 	                  1 << EXPENSES_AIRCRAFT_RUN |
 	                  1 << EXPENSES_SHIP_RUN     |
 	                  1 << EXPENSES_PROPERTY     |
+	                  1 << EXPENSES_SHARED_INF_RUN |
 	                  1 << EXPENSES_LOAN_INT, cost.GetExpensesType())) {
 		p->cur_economy.expenses -= cost.GetCost();
 	}
@@ -558,6 +560,21 @@
 	free(p->num_engines);
 	p->num_engines = CallocT<uint16>(GetEnginePoolSize());
 
+	p->shared_railway_tracks[0] = p->shared_railway_tracks[1] =_settings_game.sharing.shared_railway_tracks;
+	p->shared_railway_stations[0] = p->shared_railway_stations[1] = _settings_game.sharing.shared_railway_stations;
+	p->shared_railway_depots[0] = p->shared_railway_depots[1] = _settings_game.sharing.shared_railway_depots;
+	p->shared_tontile_cost[0] = p->shared_tontile_cost[1] = _settings_game.sharing.shared_tontile_cost;
+	p->shared_road_stops_fee[0] = p->shared_road_stops_fee[1] = 0; // no limit
+	p->shared_harbours_fee[0] = p->shared_harbours_fee[1] = 0; // no limit
+	p->shared_airports[0] = p->shared_airports[1] = _settings_game.sharing.shared_airports;
+	p->shared_landing_fee[0] = p->shared_landing_fee[1] = _settings_game.sharing.shared_landing_fee;
+	p->shared_road_depots[0] = p->shared_road_depots[1] = _settings_game.sharing.shared_road_depots;
+	p->shared_road_stops[0] = p->shared_road_stops[1] = _settings_game.sharing.shared_road_stops;
+	p->shared_water_depots[0] = p->shared_water_depots[1] = _settings_game.sharing.shared_water_depots;
+	p->shared_harbours[0] = p->shared_harbours[1] = _settings_game.sharing.shared_harbours;
+	p->shared_provision[0] = p->shared_provision[1] = _settings_game.sharing.shared_provision;
+	p->shared_change_months = 0;
+
 	return p;
 }
 
@@ -1184,6 +1201,21 @@
 	SLE_CONDVAR(Player, engine_renew_money,    SLE_UINT32,                 16, SL_MAX_VERSION),
 	SLE_CONDVAR(Player, renew_keep_length,     SLE_BOOL,                    2, SL_MAX_VERSION), // added with 16.1, but was blank since 2
 
+	SLE_CONDARR(Player, shared_railway_tracks,   SLE_BOOL,  2,                SL_VERSION_PATCH, SL_MAX_VERSION),
+	SLE_CONDARR(Player, shared_railway_stations, SLE_BOOL,  2,                SL_VERSION_PATCH, SL_MAX_VERSION),
+	SLE_CONDARR(Player, shared_railway_depots,   SLE_BOOL,  2,                SL_VERSION_PATCH, SL_MAX_VERSION),
+	SLE_CONDARR(Player, shared_airports,         SLE_BOOL,  2,                SL_VERSION_PATCH, SL_MAX_VERSION),
+	SLE_CONDARR(Player, shared_road_depots,      SLE_BOOL,  2,                SL_VERSION_PATCH, SL_MAX_VERSION),
+	SLE_CONDARR(Player, shared_road_stops,       SLE_BOOL,  2,                SL_VERSION_PATCH, SL_MAX_VERSION),
+	SLE_CONDARR(Player, shared_water_depots,     SLE_BOOL,  2,                SL_VERSION_PATCH, SL_MAX_VERSION),
+	SLE_CONDARR(Player, shared_harbours,         SLE_BOOL,  2,                SL_VERSION_PATCH, SL_MAX_VERSION),
+	SLE_CONDARR(Player, shared_tontile_cost,     SLE_INT16, 2,                SL_VERSION_PATCH, SL_MAX_VERSION),
+	SLE_CONDARR(Player, shared_road_stops_fee,   SLE_INT8,  2,                SL_VERSION_PATCH, SL_MAX_VERSION),
+	SLE_CONDARR(Player, shared_harbours_fee,     SLE_INT8,  2,                SL_VERSION_PATCH, SL_MAX_VERSION),
+	SLE_CONDARR(Player, shared_landing_fee,      SLE_INT16, 2,                SL_VERSION_PATCH, SL_MAX_VERSION),
+	SLE_CONDARR(Player, shared_provision,        SLE_INT8,  2,                SL_VERSION_PATCH, SL_MAX_VERSION),
+	SLE_CONDVAR(Player, shared_change_months,    SLE_INT8,                    SL_VERSION_PATCH, SL_MAX_VERSION),
+
 	/* reserve extra space in savegame here. (currently 63 bytes) */
 	SLE_CONDNULL(63, 2, SL_MAX_VERSION),
 
Index: src/dock_gui.cpp
===================================================================
--- src/dock_gui.cpp	(revision 13683)
+++ src/dock_gui.cpp	(working copy)
@@ -46,7 +46,15 @@
 
 static void PlaceDocks_Dock(TileIndex tile)
 {
-	DoCommandP(tile, _ctrl_pressed, 0, CcBuildDocks, CMD_BUILD_DOCK | CMD_MSG(STR_9802_CAN_T_BUILD_DOCK_HERE));
+	uint32 p2 = (INVALID_STATION << 16); // no station to join
+
+	/* tile is always the land tile, so need to evaluate _thd.pos */
+	if (StationJoinerNeeded(TileXY(_thd.pos.x / TILE_SIZE, _thd.pos.y / TILE_SIZE), _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE)) {
+		CommandContainer cmd = {tile, _ctrl_pressed, p2, CcBuildDocks, CMD_BUILD_DOCK | CMD_MSG(STR_9802_CAN_T_BUILD_DOCK_HERE)};
+		ShowSelectStation(cmd, STATION_DOCK, true, true);
+	} else {
+		DoCommandP(tile, _ctrl_pressed, p2, CcBuildDocks, CMD_BUILD_DOCK | CMD_MSG(STR_9802_CAN_T_BUILD_DOCK_HERE));
+	}
 }
 
 static void PlaceDocks_Depot(TileIndex tile)
@@ -87,7 +95,7 @@
 	DTW_CAPTION,                   ///< Window caption
 	DTW_STICKY,                    ///< Sticky window button
 	DTW_BUTTONS_BEGIN,             ///< Begin of clickable buttons (except seperating panel)
-	DTW_CANAL = DTW_BUTTONS_BEGIN, ///< Build canal button
+	DTW_CANAL = DTW_BUTTONS_BEGIN, ///< Build canal button	
 	DTW_LOCK,                      ///< Build lock button
 	DTW_SEPERATOR,                 ///< Seperating panel between lock and demolish
 	DTW_DEMOLISH,                  ///< Demolish aka dynamite button
@@ -136,7 +144,6 @@
 
 static void BuildDocksClick_River(Window *w)
 {
-	if (_game_mode != GM_EDITOR) return;
 	HandlePlacePushButton(w, DTW_RIVER, SPR_CURSOR_RIVER, VHM_RECT, PlaceDocks_BuildRiver);
 }
 
@@ -227,7 +234,6 @@
 				case DDSP_CREATE_RIVER:
 					DoCommandP(end_tile, start_tile, 2, CcBuildCanal, CMD_BUILD_CANAL | CMD_MSG(STR_CANT_PLACE_RIVERS));
 					break;
-
 				default: break;
 			}
 		}
@@ -239,6 +245,7 @@
 
 		delete FindWindowById(WC_BUILD_STATION, 0);
 		delete FindWindowById(WC_BUILD_DEPOT, 0);
+		delete FindWindowById(WC_SELECT_STATION, 0);
 	}
 
 	virtual void OnPlacePresize(Point pt, TileIndex tile_from)
@@ -252,8 +259,8 @@
 
 static const Widget _build_docks_toolb_widgets[] = {
 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},                  // DTW_CLOSEBOX
-{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   147,     0,    13, STR_9801_WATERWAYS_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},        // DTW_CAPTION
-{  WWT_STICKYBOX,   RESIZE_NONE,     7,   148,   159,     0,    13, 0x0,                             STR_STICKY_BUTTON},                      // DTW_STICKY
+{    WWT_CAPTION,   RESIZE_NONE,     7,    11,   168,     0,    13, STR_9801_WATERWAYS_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},        // DTW_CAPTION
+{  WWT_STICKYBOX,   RESIZE_NONE,     7,   169,   180,     0,    13, 0x0,                             STR_STICKY_BUTTON},                      // DTW_STICKY
 {     WWT_IMGBTN,   RESIZE_NONE,     7,     0,    21,    14,    35, SPR_IMG_BUILD_CANAL,             STR_BUILD_CANALS_TIP},                   // DTW_CANAL
 {     WWT_IMGBTN,   RESIZE_NONE,     7,    22,    43,    14,    35, SPR_IMG_BUILD_LOCK,              STR_BUILD_LOCKS_TIP},                    // DTW_LOCK
 
@@ -263,13 +270,13 @@
 {     WWT_IMGBTN,   RESIZE_NONE,     7,    71,    92,    14,    35, SPR_IMG_SHIP_DEPOT,              STR_981E_BUILD_SHIP_DEPOT_FOR_BUILDING}, // DTW_DEPOT
 {     WWT_IMGBTN,   RESIZE_NONE,     7,    93,   114,    14,    35, SPR_IMG_SHIP_DOCK,               STR_981D_BUILD_SHIP_DOCK},               // DTW_STATION
 {     WWT_IMGBTN,   RESIZE_NONE,     7,   115,   136,    14,    35, SPR_IMG_BOUY,                    STR_9834_POSITION_BUOY_WHICH_CAN},       // DTW_BUOY
-{     WWT_EMPTY,    RESIZE_NONE,     0,     0,     0,     0,     0, 0x0,                             STR_NULL},                               // DTW_RIVER
-{     WWT_IMGBTN,   RESIZE_NONE,     7,   137,   159,    14,    35, SPR_IMG_AQUEDUCT,                STR_BUILD_AQUEDUCT},                     // DTW_BUILD_AQUEDUCT
+{     WWT_IMGBTN,   RESIZE_NONE,     7,   137,   158,    14,    35, SPR_IMG_BUILD_RIVER,             STR_CREATE_RIVER},                       // DTW_RIVER
+{     WWT_IMGBTN,   RESIZE_NONE,     7,   159,   180,    14,    35, SPR_IMG_AQUEDUCT,                STR_BUILD_AQUEDUCT},                     // DTW_BUILD_AQUEDUCT
 {   WIDGETS_END},
 };
 
 static const WindowDesc _build_docks_toolbar_desc = {
-	WDP_ALIGN_TBR, 22, 160, 36, 160, 36,
+	WDP_ALIGN_TBR, 22, 181, 36, 181, 36,
 	WC_BUILD_TOOLBAR, WC_NONE,
 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
 	_build_docks_toolb_widgets,
Index: src/road_gui.cpp
===================================================================
--- src/road_gui.cpp	(revision 13683)
+++ src/road_gui.cpp	(working copy)
@@ -205,12 +205,18 @@
 static void PlaceRoadStop(TileIndex tile, uint32 p2, uint32 cmd)
 {
 	uint32 p1 = _road_station_picker_orientation;
+	SB(p2, 16, 16, INVALID_STATION); // no station to join
 
 	if (p1 >= DIAGDIR_END) {
 		SetBit(p2, 1); // It's a drive-through stop
 		p1 -= DIAGDIR_END; // Adjust picker result to actual direction
 	}
-	DoCommandP(tile, p1, p2, CcRoadDepot, cmd);
+	if (StationJoinerNeeded(tile, 1, 1)) {
+		CommandContainer cmdcont = {tile, p1, p2, CcRoadDepot, cmd};
+		ShowSelectStation(cmdcont, STATION_BUS, true, true);
+	} else {
+		DoCommandP(tile, p1, p2, CcRoadDepot, cmd);
+	}
 }
 
 static void PlaceRoad_BusStation(TileIndex tile)
@@ -527,6 +533,7 @@
 		delete FindWindowById(WC_BUS_STATION, 0);
 		delete FindWindowById(WC_TRUCK_STATION, 0);
 		delete FindWindowById(WC_BUILD_DEPOT, 0);
+		delete FindWindowById(WC_SELECT_STATION, 0);
 	}
 
 	virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
Index: src/saveload.h
===================================================================
--- src/saveload.h	(revision 13683)
+++ src/saveload.h	(working copy)
@@ -13,6 +13,9 @@
 
 #define SIZE_MAX ((size_t)-1)
 
+#define SL_VERSION_PATCH	123
+#define SL_VERSION_TRUNK     99
+
 enum SaveOrLoadResult {
 	SL_OK     = 0, ///< completed successfully
 	SL_ERROR  = 1, ///< error that was caught before internal structures were modified
Index: src/roadveh_cmd.cpp
===================================================================
--- src/roadveh_cmd.cpp	(revision 13683)
+++ src/roadveh_cmd.cpp	(working copy)
@@ -43,6 +43,7 @@
 #include "depot_base.h"
 #include "depot_func.h"
 #include "effectvehicle_func.h"
+#include "sharedinfrastructure.h"
 
 #include "table/strings.h"
 
@@ -187,7 +188,7 @@
 	/* The ai_new queries the vehicle cost before building the route,
 	 * so we must check against cheaters no sooner than now. --pasky */
 	if (!IsRoadDepotTile(tile)) return CMD_ERROR;
-	if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
+	if (!IsTileOwner(tile, _current_player) && !SharedRoadDepots(tile, _current_player)) return CMD_ERROR;
 
 	if (HasTileRoadType(tile, ROADTYPE_TRAM) != HasBit(EngInfo(p1)->misc_flags, EF_ROAD_TRAM)) return_cmd_error(STR_DEPOT_WRONG_DEPOT_TYPE);
 
@@ -288,6 +289,7 @@
 		GetPlayer(_current_player)->num_engines[p1]++;
 	}
 
+	SharedDepotProvision(cost, GetTileOwner(tile), flags);
 	return cost;
 }
 
@@ -823,6 +825,7 @@
 
 static void RoadVehArrivesAt(const Vehicle* v, Station* st)
 {
+	if (st->owner != v->owner) SharedStationFee(st->owner, v->index);
 	if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) {
 		/* Check if station was ever visited before */
 		if (!(st->had_vehicle_of_type & HVOT_BUS)) {
@@ -834,7 +837,7 @@
 				v->index,
 				0);
 		}
-	} else {
+	} else {		
 		/* Check if station was ever visited before */
 		if (!(st->had_vehicle_of_type & HVOT_TRUCK)) {
 			st->had_vehicle_of_type |= HVOT_TRUCK;
@@ -1066,14 +1069,14 @@
 	TrackdirBits trackdirs = TrackStatusToTrackdirBits(ts);
 
 	if (IsTileType(tile, MP_ROAD)) {
-		if (IsRoadDepot(tile) && (!IsTileOwner(tile, v->owner) || GetRoadDepotDirection(tile) == enterdir || (GetRoadTypes(tile) & v->u.road.compatible_roadtypes) == 0)) {
+		if (IsRoadDepot(tile) && ((!IsTileOwner(tile, v->owner) && !SharedRoadDepots(tile,v->owner)) || GetRoadDepotDirection(tile) == enterdir || (GetRoadTypes(tile) & v->u.road.compatible_roadtypes) == 0)) {
 			/* Road depot owned by another player or with the wrong orientation */
 			trackdirs = TRACKDIR_BIT_NONE;
 		}
 	} else if (IsTileType(tile, MP_STATION) && IsStandardRoadStopTile(tile)) {
 		/* Standard road stop (drive-through stops are treated as normal road) */
 
-		if (!IsTileOwner(tile, v->owner) || GetRoadStopDir(tile) == enterdir || RoadVehHasArticPart(v)) {
+		if (((!IsTileOwner(tile, v->owner))&& !SharedRoadStops(tile,v->owner)) || GetRoadStopDir(tile) == enterdir || RoadVehHasArticPart(v)) {
 			/* different station owner or wrong orientation or the vehicle has articulated parts */
 			trackdirs = TRACKDIR_BIT_NONE;
 		} else {
Index: src/economy_type.h
===================================================================
--- src/economy_type.h	(revision 13683)
+++ src/economy_type.h	(working copy)
@@ -118,10 +118,12 @@
 	EXPENSES_AIRCRAFT_RUN,
 	EXPENSES_SHIP_RUN,
 	EXPENSES_PROPERTY,
+	EXPENSES_SHARED_INF_RUN,
 	EXPENSES_TRAIN_INC,
 	EXPENSES_ROADVEH_INC,
 	EXPENSES_AIRCRAFT_INC,
 	EXPENSES_SHIP_INC,
+	EXPENSES_SHARED_INF_INC,
 	EXPENSES_LOAN_INT,
 	EXPENSES_OTHER,
 	EXPENSES_END,
Index: src/bridge.h
===================================================================
--- src/bridge.h	(revision 13683)
+++ src/bridge.h	(working copy)
@@ -47,6 +47,8 @@
 bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len, uint32 flags = 0);
 int CalcBridgeLenCostFactor(int x);
 
+BridgeType GetFastestAvailableBridgeType(uint bridge_len);
+
 void ResetBridges();
 
 #endif /* BRIDGE_H */
Index: src/sharedinfrastructure.h
===================================================================
--- src/sharedinfrastructure.h	(revision 0)
+++ src/sharedinfrastructure.h	(revision 0)
@@ -0,0 +1,71 @@
+/* $Id: sharedinfrastructure.h $ */
+
+/** @file sharedinfrastructure.h Various declarations for shared infrastructures */
+
+#ifndef SHAREDINFRASTRUCTURE_H
+#define SHAREDINFRASTRUCTURE_H
+
+#include "openttd.h"
+#include "tile_type.h"
+#include "vehicle_type.h"
+
+/* bitmask of shared infrastructure */
+enum {
+	SHARED_NONE             =  0,             ///< No sharing
+	SHARED_RAILWAY_TRACKS   = (1 << 0),       ///< Railway tracks sharing 
+	SHARED_RAILWAY_STATIONS = (1 << 1),       ///< Railway station sharing
+	SHARED_RAILWAY_DEPOTS   = (1 << 2),       ///< Railway depots sharing
+	SHARED_AIRPORTS         = (1 << 3),       ///< Airports sharing
+	SHARED_ROAD_DEPOTS      = (1 << 4),       ///< Road depots sharing
+	SHARED_ROAD_STOPS       = (1 << 5),       ///< Road stops sharing
+	SHARED_WATER_DEPOTS     = (1 << 6),       ///< Water depots sharing
+	SHARED_HARBOURS         = (1 << 7),       ///< Road depots sharing
+	SHARED_ALL              = SHARED_RAILWAY_TRACKS | SHARED_RAILWAY_STATIONS | SHARED_RAILWAY_DEPOTS | SHARED_AIRPORTS
+					| SHARED_ROAD_DEPOTS | SHARED_ROAD_STOPS | SHARED_WATER_DEPOTS | SHARED_HARBOURS, ///< All sharing
+};
+
+/* variables for player's shared infrastructure GUI */
+extern bool _si_railway_tracks;               ///< allow railway tracks sharing
+extern bool _si_railway_stations;             ///< allow railway stations sharing
+extern bool _si_railway_depots;               ///< allow railway depots sharing
+extern bool _si_airports;                     ///< allow airports sharing
+extern bool _si_road_depots;                  ///< allow road depots sharing
+extern bool _si_road_stops;                   ///< allow road stops sharing
+extern bool _si_water_depots;                 ///< allow water depots sharing
+extern bool _si_harbours;                     ///< allow harbours sharing
+extern uint16 _si_tontile_cost;               ///< cost for tracks sharing payment (per 1000 tons per tiles)
+extern uint16 _si_landing_fee;                ///< cost for airports landing fee (per tons of cargo capacity)
+extern uint8 _si_provision;                   ///< value for depots provision (buy cost %)
+extern uint8 _si_road_stops_fee;              ///< cost for entering road stops (per tons of cargo capacity)
+extern uint8 _si_harbours_fee;                ///< cost for entering harbours (per tons of cargo capacity)
+
+/* shared infrastructure functions */
+bool SharedTracks(TileIndex tile, Owner owner);                               ///< check if tracks on tile are shared
+bool SharedRailwayStations(TileIndex tile, Owner owner);                      ///< check if railway station is shared
+bool SharedRailwayDepots(TileIndex tile, Owner owner);                        ///< check if railway depot is shared
+bool SharedRoadDepots(TileIndex tile, Owner owner);                           ///< check if road depot is shared
+bool SharedRoadStops(TileIndex tile, Owner owner);                            ///< check if road stops is shared
+bool SharedWaterDepots(TileIndex tile, Owner owner);                          ///< check if water depot is shared
+bool SharedHarbours(TileIndex tile, Owner owner);                             ///< check if harbour is shared
+bool SharedAirports(TileIndex tile, Owner owner);                             ///< check if airport is shared
+bool SharedDepotTransport(TileIndex tile, Owner owner, TransportType type);   ///< check if depot for this transport type is shared
+bool SharedDepotVehicleType(TileIndex tile, Owner owner, VehicleType type);   ///< check if depot for this vehicle type is shared
+bool SharedStation(TileIndex tile, Owner owner, VehicleType type);            ///< check if station is shared
+void SharedDepotProvision(CommandCost cost, Owner owner, uint32 flags);       ///< calculate depot provision
+void SharedStationFee(Owner station_owner, VehicleID vehicle);                ///< calculate station fee for this vehicle
+int32 SettingsEnableSharedRailwayStations(int32 p1);                          ///< activate railway tracks sharing when activating railway station sharing
+int32 SettingsEnableSharedRailwayTracks(int32 p1);                            ///< desactivate railway stations and depots sharing when removing tracks sharing
+void UpdateSharedOnRemove(VehicleID vehicle);                                 ///< clean infrastructure when removing vehicle
+void OnSharedClose(PlayerID old_player, uint closing_bit);                    ///< take care of vehicles on closing shared infrastructure
+void SharedCloseOnRoad (PlayerID p, VehicleID v);                             ///< remove road vehicles on closing shared infrastructure
+void SharedCloseOnRail (PlayerID p, VehicleID v);                             ///< remove rail vehicles on closing shared infrastructure
+void SharedCloseOnAir (PlayerID p, VehicleID v);                              ///< remove aircraft on closing shared airports 
+bool SharedCloseDepotTeleport (VehicleID v, uint16 depot);                    ///< teleport vehicle to depot, return false if failed
+bool SharedCloseHangarTeleport (VehicleID v, uint16 depot);                   ///< teleport vehicle to hangar, return false if failed
+uint16 SharedCloseGetFirstDepot (PlayerID p, VehicleID v, bool check_player); ///< get fist available depot to move vehicle on bankrupt company's shared infrastructure
+uint16 SharedCloseGetFirstHangar(PlayerID p, VehicleID v, bool check_player); ///< get fist available hangar to move aircraft on bankrupt company's shared airports
+
+CommandCost CmdSetSharedBoolValues(TileIndex tile, uint32 flags, uint32 p1, uint32 p2);  ///< set shared settings for player
+CommandCost CmdSetSharedIntValues(TileIndex tile, uint32 flags, uint32 p1, uint32 p2);   ///< set int shared settings for player
+
+#endif //SHAREDINFRASTRCUTURE_H
Index: src/signal.cpp
===================================================================
--- src/signal.cpp	(revision 13683)
+++ src/signal.cpp	(working copy)
@@ -18,6 +18,7 @@
 #include "track_func.h"
 #include "signal_func.h"
 #include "player_func.h"
+#include "sharedinfrastructure.h"
 
 
 /** these are the maximums used for updating signal blocks */
@@ -280,7 +281,7 @@
 
 		switch (GetTileType(tile)) {
 			case MP_RAILWAY: {
-				if (GetTileOwner(tile) != owner) continue; // do not propagate signals on others' tiles (remove for tracksharing)
+				if ((GetTileOwner(tile) != owner) && !SharedTracks(GetTileOwner(tile), owner)) continue; // do not propagate signals on tiles of those with whom you are not sharing track
 
 				if (IsRailDepot(tile)) {
 					if (enterdir == INVALID_DIAGDIR) { // from 'inside' - train just entered or left the depot
@@ -354,7 +355,7 @@
 
 			case MP_STATION:
 				if (!IsRailwayStation(tile)) continue;
-				if (GetTileOwner(tile) != owner) continue;
+				if ((GetTileOwner(tile) != owner) && !SharedTracks(GetTileOwner(tile), owner)) continue;
 				if (DiagDirToAxis(enterdir) != GetRailStationAxis(tile)) continue; // different axis
 				if (IsStationTileBlocked(tile)) continue; // 'eye-candy' station tile
 
@@ -364,7 +365,7 @@
 
 			case MP_ROAD:
 				if (!IsLevelCrossing(tile)) continue;
-				if (GetTileOwner(tile) != owner) continue;
+				if ((GetTileOwner(tile) != owner) && (!SharedTracks(GetTileOwner(tile), owner))) continue;
 				if (DiagDirToAxis(enterdir) == GetCrossingRoadAxis(tile)) continue; // different axis
 
 				if (!(flags & SF_TRAIN) && VehicleFromPos(tile, NULL, &TrainOnTileEnum)) flags |= SF_TRAIN;
@@ -372,7 +373,7 @@
 				break;
 
 			case MP_TUNNELBRIDGE: {
-				if (GetTileOwner(tile) != owner) continue;
+				if ((GetTileOwner(tile) != owner) && (!SharedTracks(GetTileOwner(tile), owner))) continue;
 				if (GetTunnelBridgeTransportType(tile) != TRANSPORT_RAIL) continue;
 				DiagDirection dir = GetTunnelBridgeDirection(tile);
 
Index: src/vehicle.cpp
===================================================================
--- src/vehicle.cpp	(revision 13683)
+++ src/vehicle.cpp	(working copy)
@@ -1967,6 +1967,7 @@
 	SLE_CONDNULL(5,                                                         0, 57),
 	    SLE_VAR(Vehicle, engine_type,          SLE_UINT16),
 
+	    SLE_CONDARR(Vehicle, shared_tontiles,  SLE_UINT64, MAX_PLAYERS,     SL_VERSION_PATCH, SL_MAX_VERSION),
 	    SLE_VAR(Vehicle, max_speed,            SLE_UINT16),
 	    SLE_VAR(Vehicle, cur_speed,            SLE_UINT16),
 	    SLE_VAR(Vehicle, subspeed,             SLE_UINT8),
@@ -2255,7 +2256,7 @@
 			cp->source_xy       = _cargo_source_xy;
 			cp->count           = _cargo_count;
 			cp->days_in_transit = _cargo_days;
-			cp->feeder_share    = _cargo_feeder_share;
+			cp->feeder_share[0] = _cargo_feeder_share;
 			cp->loaded_at_xy    = _cargo_loaded_at_xy;
 			v->cargo.Append(cp);
 		}
Index: src/viewport.cpp
===================================================================
--- src/viewport.cpp	(revision 13683)
+++ src/viewport.cpp	(working copy)
@@ -2190,12 +2190,17 @@
 		/* clear the old selection? */
 		if (_thd.drawstyle) SetSelectionTilesDirty();
 
-		_thd.drawstyle = _thd.new_drawstyle;
-		_thd.pos = _thd.new_pos;
-		_thd.size = _thd.new_size;
-		_thd.outersize = _thd.new_outersize;
-		_thd.dirty = 0xff;
+		if (!_thd.lockPos) {
+			_thd.pos = _thd.new_pos;
+			_thd.drawstyle = _thd.new_drawstyle;
+		}
 
+		if (!_thd.lockSize) {
+			_thd.size = _thd.new_size;
+			_thd.outersize = _thd.new_outersize;
+			_thd.dirty = 0xff;
+		}
+
 		/* draw the new selection? */
 		if (_thd.new_drawstyle) SetSelectionTilesDirty();
 	}
@@ -2717,6 +2722,10 @@
 
 void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, WindowClass window_class, WindowNumber window_num)
 {
+	/* unlock position and size */
+	_thd.lockPos = false;
+	_thd.lockSize = false;
+
 	/* undo clicking on button and drag & drop */
 	if (_thd.place_mode != VHM_NONE || _special_mouse_mode == WSM_DRAGDROP) {
 		Window *w = FindWindowById(_thd.window_class, _thd.window_number);
Index: src/genworld.cpp
===================================================================
--- src/genworld.cpp	(revision 13683)
+++ src/genworld.cpp	(working copy)
@@ -35,7 +35,6 @@
 bool GenerateTowns();
 void GenerateTrees();
 
-void StartupEconomy();
 void StartupPlayers();
 void StartupDisasters();
 
Index: src/newgrf_station.h
===================================================================
--- src/newgrf_station.h	(revision 13683)
+++ src/newgrf_station.h	(working copy)
@@ -110,6 +110,7 @@
 StationClassID AllocateStationClass(uint32 cls);
 void SetStationClassName(StationClassID sclass, StringID name);
 StringID GetStationClassName(StationClassID sclass);
+const StationSpec* GetStationSpec(TileIndex t);
 
 uint GetNumStationClasses();
 uint GetNumCustomStations(StationClassID sclass);
Index: src/vehicle_base.h
===================================================================
--- src/vehicle_base.h	(revision 13683)
+++ src/vehicle_base.h	(working copy)
@@ -193,6 +193,7 @@
 extern void AfterLoadVehicles(bool clear_te_id);
 struct LoadgameState;
 extern bool LoadOldVehicle(LoadgameState *ls, int num);
+// extern bool SharedCloseHangarTeleport (VehicleID vehicle, StationID station);
 
 struct Vehicle : PoolItem<Vehicle, VehicleID, &_Vehicle_pool>, BaseVehicle {
 private:
@@ -203,6 +204,7 @@
 	friend const SaveLoad *GetVehicleDescription(VehicleType vt); ///< So we can use private/protected variables in the saveload code
 	friend void AfterLoadVehicles(bool clear_te_id);              ///< So we can set the previous and first pointers while loading
 	friend bool LoadOldVehicle(LoadgameState *ls, int num);       ///< So we can set the proper next pointer while loading
+	friend bool SharedCloseHangarTeleport (VehicleID vehicle, StationID station); ///< So we can set the proper next pointer while teleporting an air vehicle
 
 	Vehicle *depot_list;     ///< NOSAVE: linked list to tell what vehicles entered a depot during the last tick. Used by autoreplace
 
@@ -264,6 +266,8 @@
 	int8 y_offs;             // y offset for vehicle sprite
 	EngineID engine_type;
 
+	OverflowSafeInt64 shared_tontiles[MAX_PLAYERS];  //Amount of tons*tiles traveled on shared tracks
+
 	TextEffectID fill_percent_te_id; // a text-effect id to a loading indicator object
 	UnitID unitnumber;       // unit number, for display purposes only
 
Index: src/tilehighlight_type.h
===================================================================
--- src/tilehighlight_type.h	(revision 13683)
+++ src/tilehighlight_type.h	(working copy)
@@ -70,6 +70,9 @@
 
 	ViewportPlaceMethod select_method;
 	ViewportDragDropSelectionProcess select_proc;
+	
+	bool lockPos;  //if position changes are taken, or not
+	bool lockSize; //if size changes are taken, or not
 
 	TileIndex redsq;
 };
Index: src/player_gui.cpp
===================================================================
--- src/player_gui.cpp	(revision 13683)
+++ src/player_gui.cpp	(working copy)
@@ -29,6 +29,7 @@
 #include "widgets/dropdown_func.h"
 #include "widgets/dropdown_type.h"
 #include "tilehighlight_func.h"
+#include "sharedinfrastructure.h"
 
 #include "table/sprites.h"
 #include "table/strings.h"
@@ -1036,7 +1037,436 @@
 	new SelectPlayerFaceWindow(adv ? &_select_player_face_adv_desc : &_select_player_face_desc, parent, adv, top, left); // simple or advanced window
 }
 
+/** Widget description for the shared infrastructure selection dialog */
+static const Widget _shared_infrastructure_widgets[] = {
+{   WWT_CLOSEBOX,   RESIZE_NONE,   14,     0,   10,     0,   13, STR_00C5,                            STR_018B_CLOSE_WINDOW},              // SI_WIDGET_CLOSEBOX
+{    WWT_CAPTION,   RESIZE_NONE,   14,    11,  269,     0,   13, STR_SHARED_INFRASTRUCTURE_SELECTION, STR_018C_WINDOW_TITLE_DRAG_THIS},    // SI_WIDGET_CAPTION
+{      WWT_PANEL,   RESIZE_NONE,   14,     0,  269,    14,   64, 0x0,                                 STR_NULL},                           // SI_WIDGET_SELECT_SHARING_TRAIN
+{      WWT_PANEL,   RESIZE_NONE,   14,     0,  269,    65,   91, 0x0,                                 STR_NULL},                           // SI_WIDGET_SELECT_SHARING_AIR
+{      WWT_PANEL,   RESIZE_NONE,   14,     0,  269,    92,  130, 0x0,                                 STR_NULL},                           // SI_WIDGET_SELECT_SHARING_ROAD
+{      WWT_PANEL,   RESIZE_NONE,   14,     0,  269,   131,  169, 0x0,                                 STR_NULL},                           // SI_WIDGET_SELECT_SHARING_SHIP
+{      WWT_PANEL,   RESIZE_NONE,   14,     0,  269,   170,  206, 0x0,                                 STR_NULL},                           // SI_WIDGET_SELECT_SHARING_GENERAL
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   14,     0,   94,   195,  206, STR_012E_CANCEL,                     STR_NULL},                           // SI_WIDGET_CANCEL
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   14,    95,  269,   195,  206, STR_012F_OK,                         STR_SHARED_ACCEPT},                  // SI_WIDGET_ACCEPT
+{     WWT_IMGBTN,   RESIZE_NONE,   14,     2,   23,    16,   37, SPR_IMG_TRAINLIST,                   STR_NULL},                           // SI_WIDGET_TRAIN
+{     WWT_IMGBTN,   RESIZE_NONE,   14,     2,   23,    67,   88, SPR_IMG_AIRPLANESLIST,               STR_NULL},                           // SI_WIDGET_PLANE
+{     WWT_IMGBTN,   RESIZE_NONE,   14,     2,   23,    94,  115, SPR_IMG_TRUCKLIST,                   STR_NULL},                           // SI_WIDGET_ROAD
+{     WWT_IMGBTN,   RESIZE_NONE,   14,     2,   23,   133,  154, SPR_IMG_SHIPLIST,                    STR_NULL},                           // SI_WIDGET_SHIP
+{     WWT_IMGBTN,   RESIZE_NONE,   14,     2,   23,   172,  193, SPR_IMG_COMPANY_GENERAL,             STR_NULL},                           // SI_WIDGET_GENERAL
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   14,   175,  267,    16,   27, STR_EMPTY,                           STR_SHARED_RAILWAY_TRACKS},          // SI_WIDGET_SHARED_RAILWAY_TRACKS
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   14,   175,  267,    28,   39, STR_EMPTY,                           STR_SHARED_RAILWAY_STATIONS},        // SI_WIDGET_SHARED_RAILWAY_STATION
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   14,   175,  267,    40,   51, STR_EMPTY,                           STR_SHARED_RAILWAY_DEPOTS},          // SI_WIDGET_SHARED_RAILWAY_DEPOTS
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   14,   175,  267,    67,   78, STR_EMPTY,                           STR_SHARED_AIRPORTS},                // SI_WIDGET_SHARED_AIRPORTS
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   14,   175,  267,    94,  105, STR_EMPTY,                           STR_SHARED_ROAD_DEPOTS},             // SI_WIDGET_SHARED_ROAD_DEPOTS
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   14,   175,  267,   106,  117, STR_EMPTY,                           STR_SHARED_ROAD_STOPS},              // SI_WIDGET_SHARED_ROAD_STOPS
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   14,   175,  267,   133,  144, STR_EMPTY,                           STR_SHARED_WATER_DEPOTS},            // SI_WIDGET_SHARED_WATER_DEPOTS
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   14,   175,  267,   145,  156, STR_EMPTY,                           STR_SHARED_HARBOURS},                // SI_WIDGET_SHARED_HARBOURS
+{ WWT_PUSHIMGBTN,   RESIZE_NONE,   14,   175,  183,    52,   63, SPR_ARROW_LEFT,                      STR_SHARED_TONTILE_COST},            // SI_WIDGET_SHARED_TONTILE_COST_L
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   14,   184,  258,    52,   63, STR_EMPTY,                           STR_SHARED_TONTILE_COST},            // SI_WIDGET_SHARED_TONTILE_COST
+{ WWT_PUSHIMGBTN,   RESIZE_NONE,   14,   259,  267,    52,   63, SPR_ARROW_RIGHT,                     STR_SHARED_TONTILE_COST},            // SI_WIDGET_SHARED_TONTILE_COST_R
+{ WWT_PUSHIMGBTN,   RESIZE_NONE,   14,   175,  183,   118,  129, SPR_ARROW_LEFT,                      STR_SHARED_ROAD_STOPS_FEE},          // SI_WIDGET_SHARED_ROAD_STOPS_FEE_L
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   14,   184,  258,   118,  129, STR_EMPTY,                           STR_SHARED_ROAD_STOPS_FEE},          // SI_WIDGET_SHARED_ROAD_STOPS_FEE
+{ WWT_PUSHIMGBTN,   RESIZE_NONE,   14,   259,  267,   118,  129, SPR_ARROW_RIGHT,                     STR_SHARED_ROAD_STOPS_FEE},          // SI_WIDGET_SHARED_ROAD_STOPS_FEE_R
+{ WWT_PUSHIMGBTN,   RESIZE_NONE,   14,   175,  183,   157,  168, SPR_ARROW_LEFT,                      STR_SHARED_HARBOURS_FEE},         // SI_WIDGET_SHARED_HARBOURS_FEE_L
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   14,   184,  258,   157,  168, STR_EMPTY,                           STR_SHARED_HARBOURS_FEE},         // SI_WIDGET_SHARED_HARBOURS_FEE
+{ WWT_PUSHIMGBTN,   RESIZE_NONE,   14,   259,  267,   157,  168, SPR_ARROW_RIGHT,                     STR_SHARED_HARBOURS_FEE},         // SI_WIDGET_SHARED_HARBOURS_FEE_R
+{ WWT_PUSHIMGBTN,   RESIZE_NONE,   14,   175,  183,    79,   90, SPR_ARROW_LEFT,                      STR_SHARED_LANDING_FEE},             // SI_WIDGET_SHARED_LANDING_FEE_L
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   14,   184,  258,    79,   90, STR_EMPTY,                           STR_SHARED_LANDING_FEE},             // SI_WIDGET_SHARED_LANDING_FEE
+{ WWT_PUSHIMGBTN,   RESIZE_NONE,   14,   259,  267,    79,   90, SPR_ARROW_RIGHT,                     STR_SHARED_LANDING_FEE},             // SI_WIDGET_SHARED_LANDING_FEE_R
+{ WWT_PUSHIMGBTN,   RESIZE_NONE,   14,   175,  183,   172,  183, SPR_ARROW_LEFT,                      STR_SHARED_DEPOT_PROVISION},         // SI_WIDGET_SHARED_DEPOT_PROVISION_L
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,   14,   184,  258,   172,  183, STR_EMPTY,                           STR_SHARED_DEPOT_PROVISION},         // SI_WIDGET_SHARED_DEPOT_PROVISION
+{ WWT_PUSHIMGBTN,   RESIZE_NONE,   14,   259,  267,   172,  183, SPR_ARROW_RIGHT,                     STR_SHARED_DEPOT_PROVISION},         // SI_WIDGET_SHARED_DEPOT_PROVISION_R
+{   WIDGETS_END},
+};
 
+class SelectSharedInfrastructureWindow : public Window
+{
+	/* check for variable recording */
+	uint32 new_value;
+	uint32 old_value;
+	uint32 new_value2;
+	uint32 old_value2;
+
+	/**
+	 * Shared infrastructure player settings
+	 * Widgets section. Keep them in the same order in the widget array
+	 */
+	enum SharedInfrastructureWindowWidgets {
+		SI_WIDGET_CLOSEBOX = 0,
+		SI_WIDGET_CAPTION,	
+		SI_WIDGET_SELECT_SHARING_TRAIN,
+		SI_WIDGET_SELECT_SHARING_AIR,
+		SI_WIDGET_SELECT_SHARING_ROAD,
+		SI_WIDGET_SELECT_SHARING_SHIP,
+		SI_WIDGET_SELECT_SHARING_GENERAL,
+		SI_WIDGET_CANCEL,
+		SI_WIDGET_ACCEPT,
+		SI_WIDGET_TRAIN,
+		SI_WIDGET_PLANE,
+		SI_WIDGET_ROAD,
+		SI_WIDGET_SHIP,
+		SI_WIDGET_GENERAL,
+		SI_WIDGET_SHARED_RAILWAY_TRACKS,
+		SI_WIDGET_SHARED_RAILWAY_STATIONS,
+		SI_WIDGET_SHARED_RAILWAY_DEPOTS,
+		SI_WIDGET_SHARED_AIRPORTS,
+		SI_WIDGET_SHARED_ROAD_DEPOTS,
+		SI_WIDGET_SHARED_ROAD_STOPS,
+		SI_WIDGET_SHARED_WATER_DEPOTS,
+		SI_WIDGET_SHARED_HARBOURS,
+		SI_WIDGET_SHARED_TONTILE_COST_L,
+		SI_WIDGET_SHARED_TONTILE_COST,
+		SI_WIDGET_SHARED_TONTILE_COST_R,
+		SI_WIDGET_SHARED_ROAD_STOPS_FEE_L,
+		SI_WIDGET_SHARED_ROAD_STOPS_FEE,
+		SI_WIDGET_SHARED_ROAD_STOPS_FEE_R,
+		SI_WIDGET_SHARED_HARBOURS_FEE_L,
+		SI_WIDGET_SHARED_HARBOURS_FEE,
+		SI_WIDGET_SHARED_HARBOURS_FEE_R,
+		SI_WIDGET_SHARED_LANDING_FEE_L,
+		SI_WIDGET_SHARED_LANDING_FEE,
+		SI_WIDGET_SHARED_LANDING_FEE_R,
+		SI_WIDGET_SHARED_DEPOT_PROVISION_L,
+		SI_WIDGET_SHARED_DEPOT_PROVISION,
+		SI_WIDGET_SHARED_DEPOT_PROVISION_R,
+	};
+
+	enum {
+		SI_SETTING_DEFAULT,
+		SI_SETTING_VELOCITY,
+		SI_SETTING_CURRENCY
+	};
+
+	/**
+	 * Draw dynamic a label to the left of the button and a value in the button
+	 *
+	 * @param widget_index   index of this widget in the window
+	 * @param val            the value which will be draw
+	 * @param is_bool_widget is it a bool button
+	 * @param special        value is special (currency, velocity)
+	 */
+	void DrawSharedinfrastructureLabel(byte widget_index, uint16 val, bool is_bool_widget, byte special)
+	{
+		StringID str;
+
+		if (is_bool_widget) {
+			/* if it a bool button write yes or no */
+			str = (val != 0) ? STR_FACE_YES : STR_FACE_NO;
+		} else {
+			/* else write the value */
+			SetDParam(0, val);
+			switch (special) {
+				case SI_SETTING_VELOCITY : str = STR_JUST_VELOCITY; break;
+				case SI_SETTING_CURRENCY : str = STR_JUST_CURRENCY; break;
+				default : str = STR_JUST_INT;
+			}
+		}
+
+		/* Draw the value/bool in white (0xC). If the button clicked adds 1px to x and y text coordinates (IsWindowWidgetLowered()). */
+		DrawStringCentered(this->widget[widget_index].left + (this->widget[widget_index].right - this->widget[widget_index].left) / 2 +
+			this->IsWidgetLowered(widget_index), this->widget[widget_index].top + 1 + this->IsWidgetLowered(widget_index), str, TC_WHITE);
+	}
+
+public:
+	SelectSharedInfrastructureWindow(const WindowDesc *desc, Window *parent) : Window(desc, parent->window_number)
+	{
+		this->parent = parent;
+		this->FindWindowPlacementAndResize(desc);
+		this->caption_color = this->window_number;
+
+		const Player *p = GetPlayer((PlayerID)this->window_number);
+		bool local = this->window_number == _local_player;
+		
+		this->new_value = 0;
+		this->old_value = 0;
+		this->new_value2 = 0;
+		this->old_value2 = 0;
+
+		/* Check if repositioning from default is required */
+		if (top != FIRST_GUI_CALL && left != FIRST_GUI_CALL) {
+			this->top = top;
+			this->left = left;
+		}
+		
+		if (local) {
+			_si_railway_tracks = p->shared_railway_tracks[1];
+			_si_railway_stations = p->shared_railway_stations[1];
+			_si_railway_depots = p->shared_railway_depots[1];
+			_si_tontile_cost = p->shared_tontile_cost[1];
+			_si_road_stops_fee = p->shared_road_stops_fee[1];
+			_si_harbours_fee = p->shared_harbours_fee[1];
+			_si_airports = p->shared_airports[1];
+			_si_landing_fee = p->shared_landing_fee[1];
+			_si_road_depots = p->shared_road_depots[1];
+			_si_road_stops = p->shared_road_stops[1];
+			_si_water_depots = p->shared_water_depots[1];
+			_si_harbours = p->shared_harbours[1];
+			_si_provision = p->shared_provision[1];
+		}	
+	}
+
+	virtual void OnPaint()
+	{
+		const Player *p = GetPlayer((PlayerID)this->window_number);
+		bool local = this->window_number == _local_player;
+
+		uint i;
+
+		/* hide and disabled widget for non-local players */
+		for (i = SI_WIDGET_SHARED_TONTILE_COST_L; i <= SI_WIDGET_SHARED_DEPOT_PROVISION_R; i++) {
+			this->SetWidgetDisabledState(i, !local);
+		}
+		this->SetWidgetHiddenState(SI_WIDGET_CANCEL, !local);
+		this->SetWidgetHiddenState(SI_WIDGET_ACCEPT, !local);
+			
+		/* disabled widget from general (patch) settings */
+		this->SetWidgetDisabledState(SI_WIDGET_SHARED_RAILWAY_TRACKS, !local || !_settings_game.sharing.shared_railway_tracks);
+		this->SetWidgetDisabledState(SI_WIDGET_SHARED_RAILWAY_STATIONS, !local || !_settings_game.sharing.shared_railway_stations);
+		this->SetWidgetDisabledState(SI_WIDGET_SHARED_RAILWAY_DEPOTS, !local || !_settings_game.sharing.shared_railway_depots);
+		this->SetWidgetDisabledState(SI_WIDGET_SHARED_AIRPORTS, !local || !_settings_game.sharing.shared_airports);
+		this->SetWidgetDisabledState(SI_WIDGET_SHARED_ROAD_DEPOTS, !local || !_settings_game.sharing.shared_road_depots);
+		this->SetWidgetDisabledState(SI_WIDGET_SHARED_ROAD_STOPS, !local || !_settings_game.sharing.shared_road_stops);
+		this->SetWidgetDisabledState(SI_WIDGET_SHARED_WATER_DEPOTS, !local || !_settings_game.sharing.shared_water_depots);
+		this->SetWidgetDisabledState(SI_WIDGET_SHARED_HARBOURS, !local || !_settings_game.sharing.shared_harbours);
+
+		this->DrawWidgets();
+
+		/* "shared tracks:" */
+		DrawString(26, 16, STR_CONFIG_PLAYER_SHARED_RAILWAY_TRACKS, TC_FROMSTRING);
+		DrawStringCentered(140, 16, p->shared_railway_tracks[0] ? STR_FACE_YES : STR_FACE_NO, TC_WHITE);
+
+		/* "shared stations:" */
+		DrawString(26, 28, STR_CONFIG_PLAYER_SHARED_RAILWAY_STATIONS, TC_FROMSTRING);
+		DrawStringCentered(140, 28, p->shared_railway_stations[0] ? STR_FACE_YES : STR_FACE_NO, TC_WHITE);
+
+		/* "shared rail depots:" */
+		DrawString(26, 40, STR_CONFIG_PLAYER_SHARED_RAILWAY_DEPOTS, TC_FROMSTRING);
+		DrawStringCentered(140, 40, p->shared_railway_depots[0] ? STR_FACE_YES : STR_FACE_NO, TC_WHITE);
+
+		/* "shared rail tontile:" */
+		DrawString(26, 52, STR_CONFIG_PLAYER_SHARED_TONTILE_COST, TC_FROMSTRING);
+		SetDParam(0, p->shared_tontile_cost[0]);
+		DrawStringCentered(140, 52, STR_JUST_CURRENCY, TC_WHITE);
+
+		/* "shared road stops fee:" */
+		DrawString(26, 118, STR_CONFIG_PLAYER_SHARED_ROAD_STOPS_FEE, TC_FROMSTRING);
+		SetDParam(0, p->shared_road_stops_fee[0]);
+		DrawStringCentered(140, 118, STR_JUST_CURRENCY, TC_WHITE);
+
+		/* "shared harbours fee:" */
+		DrawString(26, 157, STR_CONFIG_PLAYER_SHARED_HARBOURS_FEE, TC_FROMSTRING);
+		SetDParam(0, p->shared_harbours_fee[0]);
+		DrawStringCentered(140, 157, STR_JUST_CURRENCY, TC_WHITE);
+
+		/* "shared airports:" */
+		DrawString(26, 67, STR_CONFIG_PLAYER_SHARED_AIRPORTS, TC_FROMSTRING);
+		DrawStringCentered(140, 67, p->shared_airports[0] ? STR_FACE_YES : STR_FACE_NO, TC_WHITE);
+
+		/* "shared landing fee:" */
+		DrawString(26, 79, STR_CONFIG_PLAYER_SHARED_LANDING_FEE, TC_FROMSTRING);
+		SetDParam(0, p->shared_landing_fee[0]);
+		DrawStringCentered(140, 79, STR_JUST_CURRENCY, TC_WHITE);
+
+		/* "shared road depots:" */
+		DrawString(26, 94, STR_CONFIG_PLAYER_SHARED_ROAD_DEPOTS, TC_FROMSTRING);
+		DrawStringCentered(140, 94, p->shared_road_depots[0] ? STR_FACE_YES : STR_FACE_NO, TC_WHITE);
+
+		/* "shared road stops:" */
+		DrawString(26, 106, STR_CONFIG_PLAYER_SHARED_ROAD_STOPS, TC_FROMSTRING);
+		DrawStringCentered(140, 106, p->shared_road_stops[0] ? STR_FACE_YES : STR_FACE_NO, TC_WHITE);
+
+		/* "shared water depots:" */
+		DrawString(26, 133, STR_CONFIG_PLAYER_SHARED_WATER_DEPOTS, TC_FROMSTRING);
+		DrawStringCentered(140, 133, p->shared_water_depots[0] ? STR_FACE_YES : STR_FACE_NO, TC_WHITE);
+
+		/* "shared harbours:" */
+		DrawString(26, 145, STR_CONFIG_PLAYER_SHARED_HARBOURS, TC_FROMSTRING);
+		DrawStringCentered(140, 145, p->shared_harbours[0] ? STR_FACE_YES : STR_FACE_NO, TC_WHITE);
+
+		/* "shared depot provision:" */
+		DrawString(26, 172, STR_CONFIG_PLAYER_SHARED_DEPOT_PROVISION, TC_FROMSTRING);
+		SetDParam(0, p->shared_provision[0]);
+		DrawStringCentered(140, 172, STR_JUST_PERCENT, TC_WHITE);
+
+		/* "shared planned change:" */
+		if (_settings_game.sharing.shared_delay > 0) {
+			if (p->shared_change_months > 0) {
+				SetDParam(0, p->shared_change_months);
+				DrawString(26, 184, STR_CONFIG_PLAYER_SHARED_CHANGE_MONTHS, TC_FROMSTRING);
+			} else {
+				SetDParam(0, _settings_game.sharing.shared_delay);
+				DrawString(26, 184, STR_CONFIG_PLAYER_SHARED_NO_CHANGE, TC_FROMSTRING);
+			}
+		}
+
+		/**
+		 * Draw value
+		 * use variables for local change
+		 */
+
+		if (local) {
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_RAILWAY_TRACKS, _si_railway_tracks, true, SI_SETTING_DEFAULT );
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_RAILWAY_STATIONS, _si_railway_stations, true, SI_SETTING_DEFAULT );
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_RAILWAY_DEPOTS, _si_railway_depots, true, SI_SETTING_DEFAULT );
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_TONTILE_COST, _si_tontile_cost, false, SI_SETTING_CURRENCY );
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_ROAD_STOPS_FEE, _si_road_stops_fee, false, SI_SETTING_CURRENCY );
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_HARBOURS_FEE, _si_harbours_fee, false , SI_SETTING_CURRENCY);
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_AIRPORTS, _si_airports, true, SI_SETTING_DEFAULT );
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_LANDING_FEE, _si_landing_fee, false , SI_SETTING_CURRENCY);
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_ROAD_DEPOTS, _si_road_depots, true, SI_SETTING_DEFAULT );
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_ROAD_STOPS, _si_road_stops, true, SI_SETTING_DEFAULT );
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_WATER_DEPOTS, _si_water_depots, true, SI_SETTING_DEFAULT );
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_HARBOURS, _si_harbours, true, SI_SETTING_DEFAULT );
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_DEPOT_PROVISION, _si_provision, false, SI_SETTING_DEFAULT );
+		} else {
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_RAILWAY_TRACKS, p->shared_railway_tracks[1], true, SI_SETTING_DEFAULT );
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_RAILWAY_STATIONS, p->shared_railway_stations[1], true, SI_SETTING_DEFAULT );
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_RAILWAY_DEPOTS, p->shared_railway_depots[1], true, SI_SETTING_DEFAULT );
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_TONTILE_COST, p->shared_tontile_cost[1], false, SI_SETTING_CURRENCY );
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_ROAD_STOPS_FEE, p->shared_road_stops_fee[1], false, SI_SETTING_CURRENCY );
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_HARBOURS_FEE, p->shared_harbours_fee[1], false , SI_SETTING_CURRENCY);
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_AIRPORTS, p->shared_airports[1], true, SI_SETTING_DEFAULT );
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_LANDING_FEE, p->shared_landing_fee[1], false , SI_SETTING_CURRENCY);
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_ROAD_DEPOTS, p->shared_road_depots[1], true, SI_SETTING_DEFAULT );
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_ROAD_STOPS, p->shared_road_stops[1], true, SI_SETTING_DEFAULT );
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_WATER_DEPOTS, p->shared_water_depots[1], true, SI_SETTING_DEFAULT );
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_HARBOURS, p->shared_harbours[1], true, SI_SETTING_DEFAULT );
+			this->DrawSharedinfrastructureLabel(SI_WIDGET_SHARED_DEPOT_PROVISION, p->shared_provision[1], false, SI_SETTING_DEFAULT );
+		}
+	}
+
+	virtual void OnClick(Point pt, int widget)
+	{
+		const Player *p = GetPlayer((PlayerID)this->window_number);
+		switch (widget) {
+
+			/* Cancel button */
+			case SI_WIDGET_CANCEL:
+				delete this;
+				break;
+
+			/* OK button */
+			case SI_WIDGET_ACCEPT:
+				/**
+				 * record changed values
+				 * first pack boolean variables
+				 * and check for change before sending command
+				 */
+				new_value = (uint)_si_railway_tracks | (uint)_si_railway_stations << 1 | (uint)_si_railway_depots << 2
+					| (uint)_si_airports << 3 | (uint)_si_road_depots << 4 | (uint)_si_road_stops << 5
+					 | (uint)_si_water_depots << 6 | (uint)_si_harbours << 7;
+				old_value = (uint)p->shared_railway_tracks[1] | (uint)p->shared_railway_stations[1] << 1 | (uint)p->shared_railway_depots[1] << 2
+					 | (uint)p->shared_airports[1] << 3 | (uint)p->shared_road_depots[1] << 4 | (uint)p->shared_road_stops[1] << 5
+					 | (uint)p->shared_water_depots[1] << 6 | (uint)p->shared_harbours[1] << 7;
+
+				if (new_value != old_value) {
+					DoCommandP(0, new_value, 0, NULL, CMD_SET_SHARED_BOOL_VALUES);
+				}
+
+				/* pack other variables and check for change before sending command */
+				new_value = _si_tontile_cost | _si_road_stops_fee << 16 |  _si_harbours_fee << 24;
+				old_value = p->shared_tontile_cost[1] | p->shared_road_stops_fee[1] << 16 | p->shared_harbours_fee[1] << 24;
+
+				new_value2 = _si_landing_fee | _si_provision << 16;
+				old_value2 = p->shared_landing_fee[1] | p->shared_provision[1] << 16;
+
+				if (new_value != old_value || new_value2 != old_value2) {
+					DoCommandP(0, new_value, new_value2, NULL, CMD_SET_SHARED_INT_VALUES);
+				}
+
+				delete this;
+				break;
+
+			default:
+				if (widget >= SI_WIDGET_SHARED_RAILWAY_TRACKS && widget <= SI_WIDGET_SHARED_DEPOT_PROVISION_R) {
+						
+					if (widget < SI_WIDGET_SHARED_TONTILE_COST_L) { 
+						/* Bool buttons */
+						switch (widget - SI_WIDGET_SHARED_RAILWAY_TRACKS) {
+							default: NOT_REACHED();
+							case 0: 
+								_si_railway_tracks = !_si_railway_tracks;
+								/* close railway stations and depots if tracks are closed */
+								if (!_si_railway_tracks) {
+									_si_railway_stations = false;
+									_si_railway_depots = false;
+								}
+								break; 
+							case 1:
+								_si_railway_stations = !_si_railway_stations;
+								/* open tracks when opening railway stations */
+								if (_si_railway_stations) {
+									_si_railway_tracks = true;
+								}
+								break; 
+							case 2:
+								_si_railway_depots = !_si_railway_depots;
+								/* open tracks when opening railway depots */
+								if (_si_railway_depots) {
+									_si_railway_tracks = true;
+								}
+								break; 
+							case 3: _si_airports = !_si_airports; break; 
+							case 4: _si_road_depots = !_si_road_depots; break; 
+							case 5: _si_road_stops = !_si_road_stops; break; 
+							case 6: _si_water_depots = !_si_water_depots; break; 
+							case 7: _si_harbours = !_si_harbours; break; 
+						}
+					} else {
+						/** Value buttons
+						 * - get widget line
+						 * - get button click : 0 == left (_L), 1 == middle or 2 == right (_R)
+						 */
+						int line = (widget - SI_WIDGET_SHARED_TONTILE_COST_L) / 3;
+						bool add = (((widget - SI_WIDGET_SHARED_TONTILE_COST_L) % 3) != 0);
+						switch (line) {
+							default: NOT_REACHED();
+							/* "magic" step and max values based on those in settings.cpp */
+							case 0:
+								_si_tontile_cost += add ? 5 : -5;
+								if (_si_tontile_cost > 250) _si_tontile_cost = _si_tontile_cost > 255 ? 0 : 250;
+								break;
+							case 1:
+								_si_road_stops_fee += add ? 1 : -1;
+								if (_si_road_stops_fee > 50) _si_road_stops_fee = _si_road_stops_fee > 51 ? 0 : 100;
+								break;
+							case 2:
+								_si_harbours_fee += add ? 5 : -5;
+								if (_si_harbours_fee > 200) _si_harbours_fee = _si_harbours_fee > 205 ? 0 : 200;
+								break;
+							case 3:
+								_si_landing_fee += add ? 20 : -20;
+								if (_si_landing_fee > 1000) _si_landing_fee = _si_landing_fee > 1020 ? 0 : 1000;
+								break;
+							case 4:
+								_si_provision += add ? 5 : -5;
+								if (_si_provision > 100) _si_provision = _si_provision > 105 ? 0 : 100;
+								break;
+						}
+					}
+				}
+				this->SetDirty();
+				break;
+			}
+	}
+};
+
+static const WindowDesc _shared_infrastructure_desc = {
+	WDP_AUTO, WDP_AUTO, 270, 207, 270, 207,
+	WC_SHARED_INFRASTRUCTURE, WC_NONE,
+	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, 
+	_shared_infrastructure_widgets, 
+};
+
+
+static void ShowPlayerSharedInfrastructure(Window *parent)
+{
+	if (!IsValidPlayer((PlayerID)parent->window_number)) return;
+
+	if (BringWindowToFrontById(WC_SHARED_INFRASTRUCTURE, parent->window_number)) return;
+	new SelectSharedInfrastructureWindow(&_shared_infrastructure_desc, parent); 
+}
+
 /* Names of the widgets. Keep them in the same order as in the widget array */
 enum PlayerCompanyWindowWidgets {
 	PCW_WIDGET_CLOSEBOX = 0,
@@ -1048,9 +1478,12 @@
 	PCW_WIDGET_COMPANY_NAME,
 	PCW_WIDGET_BUILD_VIEW_HQ,
 	PCW_WIDGET_RELOCATE_HQ,
+	PCW_WIDGET_CENTER,
+	PCW_WIDGET_OPEN,
 	PCW_WIDGET_BUY_SHARE,
 	PCW_WIDGET_SELL_SHARE,
 	PCW_WIDGET_COMPANY_PASSWORD,
+	PCW_WIDGET_COMPANY_SHARING,
 };
 
 static const Widget _player_company_widgets[] = {
@@ -1063,9 +1496,12 @@
 { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   270,   359,   158,   169, STR_7008_COMPANY_NAME,             STR_7033_CHANGE_THE_COMPANY_NAME},
 {    WWT_TEXTBTN,   RESIZE_NONE,    14,   266,   355,    18,    29, STR_7072_VIEW_HQ,                  STR_7070_BUILD_COMPANY_HEADQUARTERS},
 {    WWT_TEXTBTN,   RESIZE_NONE,    14,   266,   355,    32,    43, STR_RELOCATE_HQ,                   STR_RELOCATE_COMPANY_HEADQUARTERS},
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   266,   355,    46,    57, STR_PLAYER_CENTER,                 STR_PLAYER_CENTER_VIEWPORT},
+{ WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   266,   355,    60,    71, STR_PLAYER_OPEN,                   STR_PLAYER_OPEN_VIEWPORT},
 { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,     0,   179,   158,   169, STR_7077_BUY_25_SHARE_IN_COMPANY,  STR_7079_BUY_25_SHARE_IN_THIS_COMPANY},
 { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   180,   359,   158,   169, STR_7078_SELL_25_SHARE_IN_COMPANY, STR_707A_SELL_25_SHARE_IN_THIS_COMPANY},
 { WWT_PUSHTXTBTN,   RESIZE_NONE,    14,   266,   355,   138,   149, STR_COMPANY_PASSWORD,              STR_COMPANY_PASSWORD_TOOLTIP},
+{    WWT_TEXTBTN,   RESIZE_NONE,    14,   266,   355,    46,    57, STR_COMPANY_SHARING,               STR_SET_COMPANY_SHARING},
 {   WIDGETS_END},
 };
 
@@ -1187,6 +1623,7 @@
 		this->SetWidgetHiddenState(PCW_WIDGET_BUY_SHARE,        local);
 		this->SetWidgetHiddenState(PCW_WIDGET_SELL_SHARE,       local);
 		this->SetWidgetHiddenState(PCW_WIDGET_COMPANY_PASSWORD, !local || !_networking);
+		this->SetWidgetHiddenState(PCW_WIDGET_COMPANY_SHARING, !_settings_game.sharing.shared_player_level);
 
 		if (!local) {
 			if (_settings_game.economy.allow_shares) { // Shares are allowed
@@ -1286,6 +1723,20 @@
 				this->InvalidateWidget(PCW_WIDGET_RELOCATE_HQ);
 				break;
 
+			case PCW_WIDGET_CENTER:
+				ScrollMainWindowToTile(GetPlayer((PlayerID)this->window_number)->last_build_coordinate);
+				break;
+
+			case PCW_WIDGET_OPEN: {
+				int window = ShowExtraViewPortWindow();
+				Player *p = GetPlayer((PlayerID)this->window_number);
+				TileIndex tile = p->last_build_coordinate;
+
+				p->window = window;
+				ScrollWindowTo(TileX(tile) * TILE_SIZE + TILE_SIZE / 2, TileY(tile) * TILE_SIZE + TILE_SIZE / 2, FindWindowById(WC_EXTRA_VIEW_PORT, window), true);
+				break;
+			}
+
 			case PCW_WIDGET_BUY_SHARE:
 				DoCommandP(0, this->window_number, 0, NULL, CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_707B_CAN_T_BUY_25_SHARE_IN_THIS));
 				break;
@@ -1293,6 +1744,10 @@
 			case PCW_WIDGET_SELL_SHARE:
 				DoCommandP(0, this->window_number, 0, NULL, CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_707C_CAN_T_SELL_25_SHARE_IN));
 				break;
+					
+			case PCW_WIDGET_COMPANY_SHARING:
+				ShowPlayerSharedInfrastructure(this);
+				break;
 
 #ifdef ENABLE_NETWORK
 			case PCW_WIDGET_COMPANY_PASSWORD:
Index: src/openttd.cpp
===================================================================
--- src/openttd.cpp	(revision 13683)
+++ src/openttd.cpp	(working copy)
@@ -744,7 +744,6 @@
 
 void StartupPlayers();
 void StartupDisasters();
-extern void StartupEconomy();
 
 /**
  * Start Scenario starts a new game based on a scenario.
Index: src/aircraft_cmd.cpp
===================================================================
--- src/aircraft_cmd.cpp	(revision 13683)
+++ src/aircraft_cmd.cpp	(working copy)
@@ -37,6 +37,7 @@
 #include "settings_type.h"
 #include "order_func.h"
 #include "effectvehicle_func.h"
+#include "sharedinfrastructure.h"
 
 #include "table/strings.h"
 #include "table/sprites.h"
@@ -117,7 +118,7 @@
 	TileIndex vtile = TileVirtXY(v->x_pos, v->y_pos);
 
 	FOR_ALL_STATIONS(st) {
-		if (st->owner != v->owner || !(st->facilities & FACIL_AIRPORT)) continue;
+		if (((st->owner != v->owner)&&(!SharedAirports(st->xy,v->owner))) || !(st->facilities & FACIL_AIRPORT)) continue;
 
 		const AirportFTAClass *afc = st->Airport();
 		if (afc->nof_depots == 0 || (
@@ -149,7 +150,7 @@
 
 	FOR_VEHICLE_ORDERS(v, order) {
 		const Station *st = GetStation(order->station);
-		if (st->owner == v->owner && st->facilities & FACIL_AIRPORT) {
+		if (((st->owner == v->owner)&&(!SharedAirports(st->xy,v->owner))) && st->facilities & FACIL_AIRPORT) {
 			/* If an airport doesn't have a hangar, skip it */
 			if (st->Airport()->nof_depots != 0)
 				return true;
@@ -274,7 +275,7 @@
 	/* to just query the cost, it is not neccessary to have a valid tile (automation/AI) */
 	if (flags & DC_QUERY_COST) return value;
 
-	if (!IsHangarTile(tile) || !IsTileOwner(tile, _current_player)) return CMD_ERROR;
+	if (!IsHangarTile(tile) || (!IsTileOwner(tile, _current_player) && !SharedAirports(tile, _current_player))) return CMD_ERROR;
 
 	/* Prevent building aircraft types at places which can't handle them */
 	if (!CanAircraftUseStation(p1, tile)) return CMD_ERROR;
@@ -454,6 +455,8 @@
 		GetPlayer(_current_player)->num_engines[p1]++;
 	}
 
+	SharedDepotProvision(value, GetTileOwner(tile), flags);
+
 	return value;
 }
 
@@ -1684,8 +1687,9 @@
 
 	/* runway busy or not allowed to use this airstation, circle */
 	if (apc->flags & (v->subtype == AIR_HELICOPTER ? AirportFTAClass::HELICOPTERS : AirportFTAClass::AIRPLANES) &&
+			!HASBITS(st->airport_flags, AIRPORT_CLOSED_block) &&
 			st->airport_tile != 0 &&
-			(st->owner == OWNER_NONE || st->owner == v->owner)) {
+			(st->owner == OWNER_NONE || st->owner == v->owner || SharedAirports(st->xy, v->owner))) {
 		// {32,FLYING,NOTHING_block,37}, {32,LANDING,N,33}, {32,HELILANDING,N,41},
 		// if it is an airplane, look for LANDING, for helicopter HELILANDING
 		// it is possible to choose from multiple landing runways, so loop until a free one is found
@@ -1700,6 +1704,10 @@
 				uint16 tsubspeed = v->subspeed;
 				if (!AirportHasBlock(v, current, apc)) {
 					v->u.air.state = landingtype; // LANDING / HELILANDING
+
+					/* check landing fee for shared airports */
+					if (st->owner != v->owner) SharedStationFee(st->owner, v->index);
+
 					/* it's a bit dirty, but I need to set position to next position, otherwise
 					 * if there are multiple runways, plane won't know which one it took (because
 					 * they all have heading LANDING). And also occupy that block! */
Index: src/genworld.h
===================================================================
--- src/genworld.h	(revision 13683)
+++ src/genworld.h	(working copy)
@@ -79,6 +79,7 @@
 void AbortGeneratingWorld();
 bool IsGeneratingWorldAborted();
 void HandleGeneratingWorldAbortion();
+void StartupEconomy();
 
 /* genworld_gui.cpp */
 void SetGeneratingWorldProgress(gwp_class cls, uint total);
Index: src/rail_map.h
===================================================================
--- src/rail_map.h	(revision 13683)
+++ src/rail_map.h	(working copy)
@@ -31,6 +31,8 @@
  */
 static inline RailTileType GetRailTileType(TileIndex t)
 {
+  	if(!IsTileType(t, MP_RAILWAY))
+		printf("tiletype: %i\n",GetTileType(t));
 	assert(IsTileType(t, MP_RAILWAY));
 	return (RailTileType)GB(_m[t].m5, 6, 2);
 }
Index: projects/openttd_vs80.vcproj
===================================================================
--- projects/openttd_vs80.vcproj	(revision 13683)
+++ projects/openttd_vs80.vcproj	(working copy)
@@ -700,6 +700,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\sharedinfrastructure.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\signal.cpp"
 				>
 			</File>
@@ -1368,6 +1372,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\sharedinfrastructure.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\signal_func.h"
 				>
 			</File>
Index: projects/openttd_vs90.vcproj
===================================================================
--- projects/openttd_vs90.vcproj	(revision 13683)
+++ projects/openttd_vs90.vcproj	(working copy)
@@ -697,6 +697,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\sharedinfrastructure.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\signal.cpp"
 				>
 			</File>
@@ -1365,6 +1369,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\sharedinfrastructure.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\signal_func.h"
 				>
 			</File>
Index: source.list
===================================================================
--- source.list	(revision 13683)
+++ source.list	(working copy)
@@ -68,6 +68,7 @@
 	sdl.cpp
 #end
 settings.cpp
+sharedinfrastructure.cpp
 signal.cpp
 signs.cpp
 sound.cpp
@@ -267,6 +268,7 @@
 settings_internal.h
 settings_type.h
 ship.h
+sharedinfrastructure.h
 signal_func.h
 signal_type.h
 signs_base.h
