I have created a patch to the code which gives effect to suggestion no. 1. I have tested it briefly, and the code compiles, and runs without either crashing or being noticeably or measurably slower than the default version. I have noticed, however, that, on Pak128 (which I am using for testing), with the older vehicles downloaded from addons.simutrans.com installed, the speed bonus settings are far too low: the road speed bonus in 1900, for instance, is 21kph, whereas the ordinary 'busses have a maximum speed of 88kph, giving a m****ive speed bonus to all 'bus traffic. Reducing the effect of the speed bonus locally then means that that bonus is reduced, having the opposite effect desired. For this patch to have the desired effect, the settings in speedbonus.tab will have to be set more accurately to reflect the speeds of the available vehicles in the era. If that is done, the "local_bonus_supplement" value can then be reduced.
Edit: I have now found how to create a patch file: it is here. Here is the code (all in the simvehikel.cc file):
(1) Field declarations
//@author: jamespetts
//These values should in due course be read from simuconf.tab, not just hard-coded.
long min_bonus_max_distance = 16;
long max_bonus_min_distance = 256;
float local_bonus_multiplier = 0.75; // 0 = No local bonus. 1 = full speed bonus automatically applied to all local transport (below min_bonus_max_distance, proportionate thereafter).
uint16 local_bonus_supplement = 0; //A supplementary bonus for local transportation, if needed, to compensate for not having the effect of the long-distance speed bonus
(2) Revenue calculations:
while( iter.next() ) {
const ware_t & ware = iter.get_current();
if(ware.menge==0 || !ware.gib_zwischenziel().is_bound()) {
continue;
}
// now only use the real gain in difference for the revenue (may as well be negative!)
const koord zwpos = ware.gib_zwischenziel()->gib_basis_pos();
const long dist = abs(zwpos.x - start.x) + abs(zwpos.y - start.y) - (abs(end.x - zwpos.x) + abs(end.y - zwpos.y));
const sint32 grundwert128 = ware.gib_besch()->gib_preis()<<7; // bonus price will be always at least 0.128 of the real price
//@author: jamespetts
const uint16 base_bonus = ware.gib_besch()->gib_speed_bonus();
uint16 adjusted_bonus = 0;
local_bonus_supplement = local_bonus_multiplier * base_bonus;
if(dist <= min_bonus_max_distance)
{
//If distance of journey too low, disapply speed bonus entirely, but apply local bonus supplement instead.
adjusted_bonus = local_bonus_supplement;
}
else if(dist > min_bonus_max_distance && dist < max_bonus_min_distance)
{
//Apply proportionate mix of local bonus supplement and conventional speed bonus.
//The effect of this code is that, if the local supplement is set to 1, a 100% speed bonus is applied until max_bonus_min_distance is reached.
//For that reason, it is better not to set local supplement to 1.
float proportion_distance = dist / (max_bonus_min_distance - min_bonus_max_distance);
uint16 intermediate_bonus = base_bonus * proportion_distance;
uint16 intermediate_local_supplement = local_bonus_supplement * (1 / proportion_distance);
adjusted_bonus = intermediate_bonus + intermediate_local_supplement;
}
else if(dist >= max_bonus_min_distance)
{
//Apply full speed bonus in conventional way.
adjusted_bonus = base_bonus;
}
const sint32 grundwert_bonus = (ware.gib_besch()->gib_preis()*(1000+speed_base*adjusted_bonus));
sint64 price = (sint64)(grundwert128>grundwert_bonus ? grundwert128 : grundwert_bonus) * (sint64)dist * (sint64)ware.menge;
// sum up new price
value += price;
}
// Hajo: Rounded value, in cents
// prissi: Why on earth 1/3???
return (value+1500ll)/3000ll;
}
I hope that I have adequately complied with the coding style guidelines - I could not find the post setting them out, so do excuse me if I have made any mistakes.
Edit: I have now posted an updated version of the patch here, which reads the values from simuconf.tab.