equal
deleted
inserted
replaced
1211 static const int MIN_TIME_FACTOR = 31; |
1211 static const int MIN_TIME_FACTOR = 31; |
1212 static const int MAX_TIME_FACTOR = 255; |
1212 static const int MAX_TIME_FACTOR = 255; |
1213 |
1213 |
1214 const int days1 = cs->transit_days[0]; |
1214 const int days1 = cs->transit_days[0]; |
1215 const int days2 = cs->transit_days[1]; |
1215 const int days2 = cs->transit_days[1]; |
1216 const int days_over_days1 = transit_days - days1; |
1216 const int days_over_days1 = max( transit_days - days1, 0); |
|
1217 const int days_over_days2 = max(days_over_days1 - days2, 0); |
1217 |
1218 |
1218 /* |
1219 /* |
1219 * The time factor is calculated based on the time it took |
1220 * The time factor is calculated based on the time it took |
1220 * (transit_days) compared two cargo-depending values. The |
1221 * (transit_days) compared two cargo-depending values. The |
1221 * range is divided into three parts: |
1222 * range is divided into three parts: |
1223 * - constant for fast transits |
1224 * - constant for fast transits |
1224 * - linear decreasing with time with a slope of -1 for medium transports |
1225 * - linear decreasing with time with a slope of -1 for medium transports |
1225 * - linear decreasing with time with a slope of -2 for slow transports |
1226 * - linear decreasing with time with a slope of -2 for slow transports |
1226 * |
1227 * |
1227 */ |
1228 */ |
1228 int time_factor; |
1229 const int time_factor = max(MAX_TIME_FACTOR - days_over_days1 - days_over_days2, MIN_TIME_FACTOR); |
1229 if (days_over_days1 <= 0) { |
|
1230 time_factor = MAX_TIME_FACTOR; |
|
1231 } else if (days_over_days1 <= days2) { |
|
1232 time_factor = MAX_TIME_FACTOR - days_over_days1; |
|
1233 } else { |
|
1234 time_factor = MAX_TIME_FACTOR - 2 * days_over_days1 + days2; |
|
1235 } |
|
1236 |
|
1237 if (time_factor < MIN_TIME_FACTOR) time_factor = MIN_TIME_FACTOR; |
|
1238 |
1230 |
1239 return BigMulS(dist * time_factor * num_pieces, _cargo_payment_rates[cargo_type], 21); |
1231 return BigMulS(dist * time_factor * num_pieces, _cargo_payment_rates[cargo_type], 21); |
1240 } |
1232 } |
1241 |
1233 |
1242 |
1234 |