Add company settings to enable competitors' to buy/renew in own depots.

pull/6/merge
Jonathan G Rennison 8 years ago
parent 248ac0e263
commit a27bdbb3e2

@ -1472,6 +1472,10 @@ STR_CONFIG_SETTING_SHARING_FEE_AIR :Terminal fee fo
STR_CONFIG_SETTING_SHARING_PAYMENT_IN_DEBT :Allow companies in debt to pay sharing fees: {STRING2}
STR_CONFIG_SETTING_SHARING_USED_BY_VEHICLES :Can't change this setting, vehicles are using shared infrastructure.
STR_CONFIG_SETTING_SHARING_ORDERS_TO_OTHERS :Can't change this setting, vehicles have orders to destinations of others.
STR_CONFIG_SETTING_INFRA_OTHERS_BUY_IN_DEPOT_RAIL :Enable competitors to buy and renew trains in depots: {STRING2}
STR_CONFIG_SETTING_INFRA_OTHERS_BUY_IN_DEPOT_ROAD :Enable competitors to buy and renew road vehicles in depots: {STRING2}
STR_CONFIG_SETTING_INFRA_OTHERS_BUY_IN_DEPOT_WATER :Enable competitors to buy and renew ships in depots: {STRING2}
STR_CONFIG_SETTING_INFRA_OTHERS_BUY_IN_DEPOT_AIR :Enable competitors to buy and renew aircraft in hangars: {STRING2}
STR_CONFIG_SETTING_SERVINT_ISPERCENT :Service intervals are in percents: {STRING2}
STR_CONFIG_SETTING_SERVINT_ISPERCENT_HELPTEXT :Choose whether servicing of vehicles is triggered by the time passed since last service or by reliability dropping by a certain percentage of the maximum reliability

@ -1586,6 +1586,10 @@ static SettingsContainer &GetSettingsTree()
company->Add(new SettingEntry("vehicle.servint_roadveh"));
company->Add(new SettingEntry("vehicle.servint_ships"));
company->Add(new SettingEntry("vehicle.servint_aircraft"));
company->Add(new SettingEntry("company.infra_others_buy_in_depot[0]"));
company->Add(new SettingEntry("company.infra_others_buy_in_depot[1]"));
company->Add(new SettingEntry("company.infra_others_buy_in_depot[2]"));
company->Add(new SettingEntry("company.infra_others_buy_in_depot[3]"));
}
SettingsPage *accounting = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCOUNTING));

@ -538,6 +538,7 @@ struct CompanySettings {
uint32 engine_renew_money; ///< minimum amount of money before autorenew is used
bool renew_keep_length; ///< sell some wagons if after autoreplace the train is longer than before
VehicleDefaultSettings vehicle; ///< default settings for vehicles
bool infra_others_buy_in_depot[4]; ///< other companies can buy/autorenew in this companies depots (where infra sharing enabled)
};
/** All settings together for the game. */

@ -135,6 +135,38 @@ strhelp = STR_CONFIG_SETTING_SERVINT_AIRCRAFT_HELPTEXT
strval = STR_CONFIG_SETTING_SERVINT_VALUE
proc = UpdateIntervalAircraft
[SDT_BOOL]
base = CompanySettings
var = infra_others_buy_in_depot[0]
guiflags = SGF_PER_COMPANY
def = false
str = STR_CONFIG_SETTING_INFRA_OTHERS_BUY_IN_DEPOT_RAIL
patxname = ""infra_sharing.infra_others_buy_in_depot.rail""
[SDT_BOOL]
base = CompanySettings
var = infra_others_buy_in_depot[1]
guiflags = SGF_PER_COMPANY
def = false
str = STR_CONFIG_SETTING_INFRA_OTHERS_BUY_IN_DEPOT_ROAD
patxname = ""infra_sharing.infra_others_buy_in_depot.road""
[SDT_BOOL]
base = CompanySettings
var = infra_others_buy_in_depot[2]
guiflags = SGF_PER_COMPANY
def = false
str = STR_CONFIG_SETTING_INFRA_OTHERS_BUY_IN_DEPOT_WATER
patxname = ""infra_sharing.infra_others_buy_in_depot.water""
[SDT_BOOL]
base = CompanySettings
var = infra_others_buy_in_depot[3]
guiflags = SGF_PER_COMPANY
def = false
str = STR_CONFIG_SETTING_INFRA_OTHERS_BUY_IN_DEPOT_AIR
patxname = ""infra_sharing.infra_others_buy_in_depot.air""
[SDT_END]

@ -86,9 +86,15 @@ CommandCost CmdBuildAircraft (TileIndex tile, DoCommandFlag flags, const Engin
CommandCost CmdBuildVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
/* Elementary check for valid location. */
if (!IsDepotTile(tile) || !IsTileOwner(tile, _current_company)) return CMD_ERROR;
if (!IsDepotTile(tile)) return CMD_ERROR;
VehicleType type = GetDepotVehicleType(tile);
if (!IsTileOwner(tile, _current_company)) {
if (!_settings_game.economy.infrastructure_sharing[type]) return CMD_ERROR;
const Company *c = Company::GetIfValid(GetTileOwner(tile));
if (c == NULL || !c->settings.infra_others_buy_in_depot[type]) return CMD_ERROR;
}
/* Validate the engine type. */
EngineID eid = GB(p1, 0, 16);

Loading…
Cancel
Save