yes
http://simutrans-germany.com/~patches/upload/startingmoney-2295.patch
Index: dataobj/einstellungen.cc
===================================================================
--- dataobj/einstellungen.cc (revision 2295)
+++ dataobj/einstellungen.cc (working copy)
@@ -518,7 +518,54 @@
show_pax = contents.get_int("stop_pedestrians", show_pax ) != 0;
stadtauto_duration = contents.get_int("default_citycar_life", stadtauto_duration); // ten normal years
+ // starting money
starting_money = contents.get_int("starting_money", starting_money );
+ // up to ten blocks year, money, interpolation={0,1} are possible:
+ // starting_money[i]=y,m,int
+ // y .. year
+ // m .. money (in 1/100 Cr)
+ // int .. interpolation: 0 - no interpolation, !=0 linear interpolated
+ // (m) is the starting money for player start after (y), if (i)!=0, the starting money
+ // is linearly interpolated between (y) and the next greater year given in another entry.
+ // starting money for given year is:
+ //
+ int j=0;
+ for( int i = 0; i<10; i++ ) {
+ char name[32];
+ sprintf( name, "starting_money[%i]", i );
+ int *test = contents.get_ints(name);
+ if ((test[0]>1) && (test[0]<=3)) {
+ // insert sorted by years
+ int k=0;
+ for (k=0; k<i; k++) {
+ if (startingmoneyperyear[k].year > test[1]) {
+ for (int l=j; l>=k; l--)
+ memcpy( &startingmoneyperyear[l+1], &startingmoneyperyear[l], sizeof(yearmoney));
+ break;
+ }
+ }
+ startingmoneyperyear[k].year = test[1];
+ startingmoneyperyear[k].money = test[2];
+ if (test[0]==3) {
+ startingmoneyperyear[k].interpol = test[3]!=0;
+ }
+ else {
+ startingmoneyperyear[k].interpol = false;
+ }
+ j++;
+ }
+ else {
+ // invalid entry
+ }
+ delete [] test;
+ }
+ // fill remaining entries
+ for (int i=j+1; i<10; i++) {
+ startingmoneyperyear[i].year = 0;
+ startingmoneyperyear[i].money = 0;
+ startingmoneyperyear[i].interpol = 0;
+ }
+
maint_building = contents.get_int("maintenance_building", maint_building);
numbered_stations = contents.get_int("numbered_stations", numbered_stations ) != 0;
@@ -617,3 +664,53 @@
simuconf.close();
}
+
+
+sint64 einstellungen_t::get_starting_money(sint16 year) const {
+ // search entry with startingmoneyperyear[i].year >= year
+ int i; bool found = false;
+ for (i=0; i<10; i++) {
+ if (startingmoneyperyear[i].year!=0) {
+ if (startingmoneyperyear[i].year>=year) {
+ found = true;
+ break;
+ }
+ }
+ else {
+ // nothing found
+ if (i==0) {
+ // no 'starting_money[%i]'-entries in simuconf
+ // use the plain startingmoney variable
+ return starting_money;
+ }
+ else {
+ // year is behind the latest given date
+ return startingmoneyperyear[i-1].money;
+ }
+ }
+ }
+ if (i==0) {
+ if (startingmoneyperyear[0].year==year) {
+ return startingmoneyperyear[0].money;
+ }
+ else {
+ // before any given date
+ // use the plain startingmoney variable
+ return starting_money;
+ }
+ }
+ else {
+ // now: startingmoneyperyear[i-1].year <= year <= startingmoneyperyear[i].year
+ if (startingmoneyperyear[i-1].interpol) {
+ // linear interpolation
+ return startingmoneyperyear[i-1].money +
+ (startingmoneyperyear[i].money-startingmoneyperyear[i-1].money)
+ * (year-startingmoneyperyear[i-1].year) /(startingmoneyperyear[i].year-startingmoneyperyear[i-1].year);
+ }
+ else {
+ // no interpolation
+ return startingmoneyperyear[i-1].money;
+ }
+
+ }
+}
\ No newline at end of file
Index: dataobj/einstellungen.h
===================================================================
--- dataobj/einstellungen.h (revision 2295)
+++ dataobj/einstellungen.h (working copy)
@@ -100,7 +100,14 @@
bool freeplay;
sint64 starting_money;
+
+ typedef struct {
+ sint16 year;
+ sint64 money;
+ bool interpol; } yearmoney;
+ yearmoney startingmoneyperyear[10];
+
/**
* Use numbering for stations?
*
@@ -293,6 +300,7 @@
sint32 get_max_transfers() const { return max_transfers; }
sint64 get_starting_money() const { return starting_money; }
+ sint64 get_starting_money(sint16 year) const;
bool get_random_pedestrians() const { return fussgaenger; }
void set_random_pedestrians( bool f ) { fussgaenger = f; } // NETWORK!
Index: player/ai.cc
===================================================================
--- player/ai.cc (revision 2295)
+++ player/ai.cc (working copy)
@@ -348,7 +348,7 @@
if(besch!=NULL) {
// cost is negative!
sint64 cost = welt->get_einstellungen()->cst_multiply_headquarter*besch->get_level()*besch->get_b()*besch->get_h();
- if( konto+cost > welt->get_einstellungen()->get_starting_money() ) {
+ if( konto+cost > starting_money ) {
// and enough money left ...
koord place = get_headquarter_pos();
if(place!=koord::invalid) {
Index: player/ai_p****enger.cc
===================================================================
--- player/ai_p****enger.cc (revision 2295)
+++ player/ai_p****enger.cc (working copy)
@@ -941,7 +941,7 @@
* The second condition may happen due to extensive replacement operations;
* in such a case it is save enough to expand anyway.
*/
- if(!(konto>0 || finance_history_month[0][COST_****ETS]+konto>welt->get_einstellungen()->get_starting_money()) ) {
+ if(!(konto>0 || finance_history_month[0][COST_****ETS]+konto>starting_money) ) {
return;
}
@@ -1207,7 +1207,7 @@
// despite its name: try airplane
case NR_BAUE_AIRPORT_ROUTE:
// try airline (if we are wealthy enough) ...
- if( !air_transport || finance_history_month[1][COST_CASH]<welt->get_einstellungen()->get_starting_money() || !create_air_transport_vehikel( start_stadt, end_stadt )) {
+ if( !air_transport || finance_history_month[1][COST_CASH]<starting_money || !create_air_transport_vehikel( start_stadt, end_stadt )) {
state = NR_BAUE_CLEAN_UP;
}
else {
Index: player/simplay.cc
===================================================================
--- player/simplay.cc (revision 2295)
+++ player/simplay.cc (working copy)
@@ -81,7 +81,8 @@
player_nr = nr;
set_player_color( nr*8, nr*8+24 );
- konto = welt->get_einstellungen()->get_starting_money();
+ konto = welt->get_einstellungen()->get_starting_money(welt->get_last_year());
+ starting_money = konto;
konto_ueberzogen = 0;
automat = false; // Start nicht als automatischer Spieler
@@ -98,7 +99,7 @@
for (int cost_type=0; cost_type<MAX_PLAYER_COST; cost_type++) {
finance_history_year[year][cost_type] = 0;
if ((cost_type == COST_CASH) || (cost_type == COST_NETWEALTH)) {
- finance_history_year[year][cost_type] = welt->get_einstellungen()->get_starting_money();
+ finance_history_year[year][cost_type] = starting_money;
}
}
}
@@ -107,7 +108,7 @@
for (int cost_type=0; cost_type<MAX_PLAYER_COST; cost_type++) {
finance_history_month[month][cost_type] = 0;
if ((cost_type == COST_CASH) || (cost_type == COST_NETWEALTH)) {
- finance_history_month[month][cost_type] = welt->get_einstellungen()->get_starting_money();
+ finance_history_month[month][cost_type] = starting_money;
}
}
}
Index: player/simplay.h
===================================================================
--- player/simplay.h (revision 2295)
+++ player/simplay.h (working copy)
@@ -104,6 +104,9 @@
*/
sint64 konto;
+ // remember the starting money
+ sint64 starting_money;
+
/**
* Zählt wie viele Monate das Konto schon ueberzogen ist
*