As explained here, I am trying to develop a patch to increase maintenance costs of obsolete vehicles (and to do so somewhat gradually, instead of imposing a huge penalty the moment that they become obsolete). I wrote some code (in the simconvoi.cc file) to try to acheive this, but it does not seem to work: for some reason, the line:
if(fahr[i]->gib_besch()->is_retired(month_now) && welt->use_timeline())
never evaluates to true (even when "&& welt->use_timeline()" is removed). I have reproduced the code in question below. Any ideas as to how to get it to work would be most welcome.
convoi_t::get_running_cost() const
{
sint32 running_cost = 0;
sint32 vehicle_running_cost = 0;
const int month_now = welt->get_timeline_year_month();
for (unsigned i = 0; i<gib_vehikel_anzahl(); i++) { //"anzahl" = "number" (Babelfish)
vehicle_running_cost = fahr[i]->gib_betriebskosten(); //"get_operatingCost" (Google). "Fahr" = "Drive" (Babelfish)
if(fahr[i]->gib_besch()->is_retired(month_now) && welt->use_timeline()) //If the vehicle is obsolete.
{
//Increase maintenance costs by amount specified in simuconf.tab.
//This system is ugly: if anyone can make a system that calculates this smoothly,
//rather than in steps, then so much the better.
sint32 extra_cost = 0;
float multiplier = 999;
if(!fahr[i]->gib_besch()->is_retired(month_now - 12)) //If has been obsolete for less than one year.
{
multiplier = (umgebung_t::obsolete_less_1_multiplier_percent / 100);
}
else if(!fahr[i]->gib_besch()->is_retired(month_now - 60)) //If has been obsolete for less than five years.
{
multiplier = (umgebung_t::obsolete_less_5_multiplier_percent / 100);
}
else if(!fahr[i]->gib_besch()->is_retired(month_now - 120)) //If has been obsolete for less than ten years.
{
multiplier = (umgebung_t::obsolete_less_10_multiplier_percent / 100);
}
else if(!fahr[i]->gib_besch()->is_retired(month_now - 240)) //If has been obsolete for less than twenty years.
{
multiplier = (umgebung_t::obsolete_less_20_multiplier_percent / 100);
}
else //If has been obsolete for more than 20 years
{
multiplier = (umgebung_t::obsolete_more_20_multiplier_percent / 100);
}
extra_cost = running_cost * multiplier;
vehicle_running_cost += extra_cost;
}
running_cost += vehicle_running_cost;
}
return running_cost;
}
Edit: Further testing has revealed that the real problem is that the get_running_cost() is not used by anything! I commented out all of the significant lines of code in that method, and the running costs behaved in exactly the same way as an unaltered version of Simutrans, downloaded as a binary. I am now extremely confused. Can anybody help?