File diff r9353:bc33456736f9 → r9354:358e967da2ca
src/economy.cpp
Show inline comments
 
@@ -654,7 +654,7 @@ static void AddInflation()
 
	 * inflation doesn't add anything after that either; it even makes playing
 
	 * it impossible due to the diverging cost and income rates.
 
	 */
 
	if ((_cur_year - _patches.starting_year) >= (ORIGINAL_MAX_YEAR - ORIGINAL_BASE_YEAR)) return;
 
	if ((_cur_year - _settings.game_creation.starting_year) >= (ORIGINAL_MAX_YEAR - ORIGINAL_BASE_YEAR)) return;
 

	
 
	/* Approximation for (100 + infl_amount)% ** (1 / 12) - 100%
 
	 * scaled by 65536
 
@@ -1208,7 +1208,7 @@ static void DeliverGoodsToIndustry(TileI
 
	 * XXX - Think of something better to
 
	 *       1) Only deliver to industries which are withing the catchment radius
 
	 *       2) Distribute between industries if more then one is present */
 
	best_dist = (_patches.station_spread + 8) * 2;
 
	best_dist = (_settings.station.station_spread + 8) * 2;
 
	FOR_ALL_INDUSTRIES(ind) {
 
		indspec = GetIndustrySpec(ind->type);
 
		uint i;
 
@@ -1481,7 +1481,7 @@ static void LoadUnloadVehicle(Vehicle *v
 

	
 
	/* We have not waited enough time till the next round of loading/unloading */
 
	if (--v->load_unload_time_rem != 0) {
 
		if (_patches.improved_load && (v->current_order.GetLoadType() & OLFB_FULL_LOAD)) {
 
		if (_settings.order.improved_load && (v->current_order.GetLoadType() & OLFB_FULL_LOAD)) {
 
			/* 'Reserve' this cargo for this vehicle, because we were first. */
 
			for (; v != NULL; v = v->Next()) {
 
				if (v->cargo_cap != 0) cargo_left[v->cargo_type] -= v->cargo_cap - v->cargo.Count();
 
@@ -1517,7 +1517,7 @@ static void LoadUnloadVehicle(Vehicle *v
 
		if (v->cargo_cap == 0) continue;
 

	
 
		byte load_amount = EngInfo(v->engine_type)->load_amount;
 
		if (_patches.gradual_loading && HasBit(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_LOAD_AMOUNT)) {
 
		if (_settings.order.gradual_loading && HasBit(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_LOAD_AMOUNT)) {
 
			uint16 cb_load_amount = GetVehicleCallback(CBID_VEHICLE_LOAD_AMOUNT, 0, 0, v->engine_type, v);
 
			if (cb_load_amount != CALLBACK_FAILED && GB(cb_load_amount, 0, 8) != 0) load_amount = GB(cb_load_amount, 0, 8);
 
		}
 
@@ -1526,7 +1526,7 @@ static void LoadUnloadVehicle(Vehicle *v
 

	
 
		if (HasBit(v->vehicle_flags, VF_CARGO_UNLOADING) && (u->current_order.GetUnloadType() & OUFB_NO_UNLOAD) == 0) {
 
			uint cargo_count = v->cargo.Count();
 
			uint amount_unloaded = _patches.gradual_loading ? min(cargo_count, load_amount) : cargo_count;
 
			uint amount_unloaded = _settings.order.gradual_loading ? min(cargo_count, load_amount) : cargo_count;
 
			bool remaining; // Are there cargo entities in this vehicle that can still be unloaded here?
 

	
 
			if (HasBit(ge->acceptance_pickup, GoodsEntry::ACCEPTANCE) && !(u->current_order.GetUnloadType() & OUFB_TRANSFER)) {
 
@@ -1552,7 +1552,7 @@ static void LoadUnloadVehicle(Vehicle *v
 
			unloading_time += amount_unloaded;
 

	
 
			anything_unloaded = true;
 
			if (_patches.gradual_loading && remaining) {
 
			if (_settings.order.gradual_loading && remaining) {
 
				completely_emptied = false;
 
			} else {
 
				/* We have finished unloading (cargo count == 0) */
 
@@ -1586,14 +1586,14 @@ static void LoadUnloadVehicle(Vehicle *v
 

	
 
			/* Skip loading this vehicle if another train/vehicle is already handling
 
			 * the same cargo type at this station */
 
			if (_patches.improved_load && cargo_left[v->cargo_type] <= 0) {
 
			if (_settings.order.improved_load && cargo_left[v->cargo_type] <= 0) {
 
				SetBit(cargo_not_full, v->cargo_type);
 
				continue;
 
			}
 

	
 
			if (cap > count) cap = count;
 
			if (_patches.gradual_loading) cap = min(cap, load_amount);
 
			if (_patches.improved_load) {
 
			if (_settings.order.gradual_loading) cap = min(cap, load_amount);
 
			if (_settings.order.improved_load) {
 
				/* Don't load stuff that is already 'reserved' for other vehicles */
 
				cap = min((uint)cargo_left[v->cargo_type], cap);
 
				cargo_left[v->cargo_type] -= cap;
 
@@ -1637,7 +1637,7 @@ static void LoadUnloadVehicle(Vehicle *v
 
	 * all wagons at the same time instead of using the same 'improved'
 
	 * loading algorithm for the wagons (only fill wagon when there is
 
	 * enough to fill the previous wagons) */
 
	if (_patches.improved_load && (u->current_order.GetLoadType() & OLFB_FULL_LOAD)) {
 
	if (_settings.order.improved_load && (u->current_order.GetLoadType() & OLFB_FULL_LOAD)) {
 
		/* Update left cargo */
 
		for (v = u; v != NULL; v = v->Next()) {
 
			if (v->cargo_cap != 0) cargo_left[v->cargo_type] -= v->cargo_cap - v->cargo.Count();
 
@@ -1647,7 +1647,7 @@ static void LoadUnloadVehicle(Vehicle *v
 
	v = u;
 

	
 
	if (anything_loaded || anything_unloaded) {
 
		if (_patches.gradual_loading) {
 
		if (_settings.order.gradual_loading) {
 
			/* The time it takes to load one 'slice' of cargo or passengers depends
 
			* on the vehicle type - the values here are those found in TTDPatch */
 
			const uint gradual_loading_wait_time[] = { 40, 20, 10, 20 };
 
@@ -1684,11 +1684,11 @@ static void LoadUnloadVehicle(Vehicle *v
 

	
 
	/* Calculate the loading indicator fill percent and display
 
	 * In the Game Menu do not display indicators
 
	 * If _patches.loading_indicators == 2, show indicators (bool can be promoted to int as 0 or 1 - results in 2 > 0,1 )
 
	 * if _patches.loading_indicators == 1, _local_player must be the owner or must be a spectator to show ind., so 1 > 0
 
	 * if _patches.loading_indicators == 0, do not display indicators ... 0 is never greater than anything
 
	 * If _settings.gui.loading_indicators == 2, show indicators (bool can be promoted to int as 0 or 1 - results in 2 > 0,1 )
 
	 * if _settings.gui.loading_indicators == 1, _local_player must be the owner or must be a spectator to show ind., so 1 > 0
 
	 * if _settings.gui.loading_indicators == 0, do not display indicators ... 0 is never greater than anything
 
	 */
 
	if (_game_mode != GM_MENU && (_patches.loading_indicators > (uint)(v->owner != _local_player && _local_player != PLAYER_SPECTATOR))) {
 
	if (_game_mode != GM_MENU && (_settings.gui.loading_indicators > (uint)(v->owner != _local_player && _local_player != PLAYER_SPECTATOR))) {
 
		StringID percent_up_down = STR_NULL;
 
		int percent = CalcPercentVehicleFilled(v, &percent_up_down);
 
		if (v->fill_percent_te_id == INVALID_TE_ID) {
 
@@ -1736,7 +1736,7 @@ void LoadUnloadStation(Station *st)
 
void PlayersMonthlyLoop()
 
{
 
	PlayersGenStatistics();
 
	if (_patches.inflation && _cur_year < MAX_YEAR)
 
	if (_settings.economy.inflation && _cur_year < MAX_YEAR)
 
		AddInflation();
 
	PlayersPayInterest();
 
	/* Reset the _current_player flag */
 
@@ -1802,7 +1802,7 @@ CommandCost CmdBuyShareInCompany(TileInd
 

	
 
	/* Check if buying shares is allowed (protection against modified clients) */
 
	/* Cannot buy own shares */
 
	if (!IsValidPlayer((PlayerID)p1) || !_patches.allow_shares || _current_player == (PlayerID)p1) return CMD_ERROR;
 
	if (!IsValidPlayer((PlayerID)p1) || !_settings.economy.allow_shares || _current_player == (PlayerID)p1) return CMD_ERROR;
 

	
 
	p = GetPlayer((PlayerID)p1);
 

	
 
@@ -1851,7 +1851,7 @@ CommandCost CmdSellShareInCompany(TileIn
 

	
 
	/* Check if selling shares is allowed (protection against modified clients) */
 
	/* Cannot sell own shares */
 
	if (!IsValidPlayer((PlayerID)p1) || !_patches.allow_shares || _current_player == (PlayerID)p1) return CMD_ERROR;
 
	if (!IsValidPlayer((PlayerID)p1) || !_settings.economy.allow_shares || _current_player == (PlayerID)p1) return CMD_ERROR;
 

	
 
	p = GetPlayer((PlayerID)p1);