summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2009-02-02 21:38:36 +0000
committerpeter1138 <peter1138@openttd.org>2009-02-02 21:38:36 +0000
commit48e6e7d586863090ead94e69ac86956fe75d2e36 (patch)
treee125594b96cb2ee338da7ba48aafc55344e61334 /src
parent5105cd2c6bb804d91d5ad81abc0d38be4a591c7c (diff)
downloadopenttd-48e6e7d586863090ead94e69ac86956fe75d2e36.tar.xz
(svn r15320) -Codechange: Increase 'realistic' acceleration 'resolution' by one bit by reducing a division and removing a multiplication: 3/4*2 = 0; 3/2 = 1. And a smidgeon less CPU usage, hah.
Diffstat (limited to 'src')
-rw-r--r--src/train_cmd.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 50c815f6a..0d1b69d47 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -504,9 +504,9 @@ static int GetTrainAcceleration(Vehicle *v, bool mode)
}
if (mode == AM_ACCEL) {
- return (force - resistance) / (mass * 4);
+ return (force - resistance) / (mass * 2);
} else {
- return min((-force - resistance) / (mass * 4), -10000 / (mass * 4));
+ return min((-force - resistance) / mass, -10000 / mass);
}
}
@@ -3255,18 +3255,18 @@ static int UpdateTrainSpeed(Vehicle *v)
if (v->vehstatus & VS_STOPPED || HasBit(v->u.rail.flags, VRF_REVERSING) || HasBit(v->u.rail.flags, VRF_TRAIN_STUCK)) {
switch (_settings_game.vehicle.train_acceleration_model) {
default: NOT_REACHED();
- case TAM_ORIGINAL: accel = v->acceleration * -2; break;
- case TAM_REALISTIC: accel = GetTrainAcceleration(v, AM_BRAKE) * 2; break;
+ case TAM_ORIGINAL: accel = v->acceleration * -4; break;
+ case TAM_REALISTIC: accel = GetTrainAcceleration(v, AM_BRAKE); break;
}
} else {
switch (_settings_game.vehicle.train_acceleration_model) {
default: NOT_REACHED();
- case TAM_ORIGINAL: accel = v->acceleration; break;
+ case TAM_ORIGINAL: accel = v->acceleration * 2; break;
case TAM_REALISTIC: accel = GetTrainAcceleration(v, AM_ACCEL); break;
}
}
- uint spd = v->subspeed + accel * 2;
+ uint spd = v->subspeed + accel;
v->subspeed = (byte)spd;
{
int tempmax = v->max_speed;