11-05-2006, 10:58 AM,
|
|
rookie1
Member
|
Posts: 231
Threads: 32
Joined: Nov 2006
|
|
Automatic transmission
I've tried to implement automatic transmission. Nothing fancy, just by checking the engine speed, and shift up when greater than peak engine speed, shift down when less than a fixed value (using 200 rad/s now).
I'd like to add an option for user to select whether to use manual or automatic transmission. My question is, should we use a combined setting for autoclutch/auto transmission, or do you prefer to separate these 2 settings?
|
|
11-05-2006, 07:19 PM,
|
|
reece146
Member
|
Posts: 187
Threads: 26
Joined: Oct 2006
|
|
x2 on keeping auto-clutch and auto-trans separate.
|
|
11-05-2006, 08:50 PM,
|
|
rookie1
Member
|
Posts: 231
Threads: 32
Joined: Nov 2006
|
|
Ok. I'll create a new option for auto transmission. Will submit a patch once I'm done.
|
|
11-06-2006, 12:17 AM,
|
|
rookie1
Member
|
Posts: 231
Threads: 32
Joined: Nov 2006
|
|
Here is the patch
Code: Index: include/vamosworld.h
===================================================================
--- include/vamosworld.h (revision 1323)
+++ include/vamosworld.h (working copy)
@@ -109,6 +109,7 @@
bool camneedupdate;
bool MPH;
bool auto_clutch;
+ bool auto_trans;
bool display_hud;
bool input_graph_enabled;
bool car_shadows_enabled;
Index: src/vamosworld.cc
===================================================================
--- src/vamosworld.cc (revision 1323)
+++ src/vamosworld.cc (working copy)
@@ -1432,6 +1432,36 @@
DoOp(GetCar(CONT_PLAYERLOCAL), "clutch", autoclutch, 0.0, true, timefactor, fps);
}
}
+
+ // Automatic Transmission
+ if (auto_trans)
+ {
+ // only autoshift when no shift pending and we are not in neutral or reverse gear
+ if (!GetCar(CONT_PLAYERLOCAL)->car->ShiftPending() &&
+ GetCar(CONT_PLAYERLOCAL)->car->gear() > 0)
+ {
+ // shift up when engine speed exceeds peak speed
+ if (GetCar(CONT_PLAYERLOCAL)->car->engine()->rotational_speed() >
+ GetCar(CONT_PLAYERLOCAL)->car->engine()->peak_engine_speed()
+ &&
+ GetCar(CONT_PLAYERLOCAL)->car->engine()->last_rotational_speed() <GetCar>car->engine()->peak_engine_speed())
+ {
+ GetCar(CONT_PLAYERLOCAL)->car->shift_up();
+ }
+
+ // shift down when engine speed below fixed value
+ // however, we do not auto shift down from 1st gear to neutral
+ if (GetCar(CONT_PLAYERLOCAL)->car->gear() > 1
+ &&
+ GetCar(CONT_PLAYERLOCAL)->car->engine()->rotational_speed() <200>car->engine()->last_rotational_speed() > 200.0)
+ {
+ GetCar(CONT_PLAYERLOCAL)->car->shift_down();
+ }
+ }
+ }
}
void VAMOSWORLD::DoOp(Vamos_World::Car_Information * c, string dofunction, float dovalue, float dotime, bool held, float timefactor, float fps)
@@ -2096,6 +2126,7 @@
settings.Get( "display.show_hud", display_hud );
settings.Get( "display.mph", MPH );
settings.Get( "control.autoclutch", auto_clutch );
+ settings.Get( "control.autotrans", auto_trans );
settings.Get( "display.input_graph", input_graph_enabled );
settings.Get( "display.car_shadows", car_shadows_enabled );
settings.Get( "control.button_ramp", button_ramp );
Index: data/settings/options.config
===================================================================
--- data/settings/options.config (revision 1323)
+++ data/settings/options.config (working copy)
@@ -1,4 +1,4 @@
-num_options = 41
+num_options = 42
[ option-00 ]
cat = game
@@ -520,3 +520,14 @@
default = 1
values = replays
+[ option-41 ]
+cat = control
+name = autotrans
+title = AutoTransmission
+desc = Enable/disable automatic transmission
+type = bool
+default = true
+values = bool
+true = On
+false = Off
+
Index: data/skins/simple/menus/ControlsOptions
===================================================================
--- data/skins/simple/menus/ControlsOptions (revision 1323)
+++ data/skins/simple/menus/ControlsOptions (working copy)
@@ -1,5 +1,5 @@
name = ControlsOptions
-widgets = 11
+widgets = 12
background = box.png
dialog = false
@@ -21,7 +21,7 @@
name = TouchCompWheel
setting = joystick.touchcomp
values = options
-center = 0.5, 0.29
+center = 0.5, 0.25
width = auto
height = auto
fontsize = 6
@@ -32,6 +32,20 @@
[ widget-02 ]
type = toggle
+name = AutoTransToggle
+setting = control.autotrans
+values = options
+center = 0.5, 0.29
+width = auto
+height = auto
+fontsize = 6
+enabled = 1
+selected = 0
+default = 0
+cancel = 0
+
+[ widget-03 ]
+type = toggle
name = AutoClutchToggle
setting = control.autoclutch
values = options
@@ -44,7 +58,7 @@
default = 0
cancel = 0
-[ widget-03 ]
+[ widget-04 ]
type = toggle
name = ABSToggle
setting = game.antilock
@@ -58,7 +72,7 @@
default = 0
cancel = 0
-[ widget-04 ]
+[ widget-05 ]
type = toggle
name = TCSToggle
setting = game.traction_control
@@ -72,7 +86,7 @@
default = 0
cancel = 0
-[ widget-05 ]
+[ widget-06 ]
type = floatwheel
name = ButtonRampWheel
setting = control.button_ramp
@@ -86,7 +100,7 @@
default = 0
cancel = 0
-[ widget-06 ]
+[ widget-07 ]
type = button
name = ActionControlMapButton
text = Assign Controls
@@ -102,7 +116,7 @@
default = 0
cancel = 0
-[ widget-07 ]
+[ widget-08 ]
type = button
name = JoystickOptionsButton
text = Joystick Options
@@ -118,7 +132,7 @@
default = 0
cancel = 0
-[ widget-08 ]
+[ widget-09 ]
type = button
name = MouseOptionsButton
text = Mouse Options
@@ -134,7 +148,7 @@
default = 0
cancel = 0
-[ widget-09 ]
+[ widget-10 ]
type = button
name = ControlsOptionsOKButton
text = OK
@@ -150,7 +164,7 @@
default = 1
cancel = 0
-[ widget-10 ]
+[ widget-11 ]
type = button
name = ControlsOptionsCancelButton
text = Cancel
Index: data/skins/simple/menus/InGameControlsOptions
===================================================================
--- data/skins/simple/menus/InGameControlsOptions (revision 1323)
+++ data/skins/simple/menus/InGameControlsOptions (working copy)
@@ -1,5 +1,5 @@
name = InGameControlsOptions
-widgets = 11
+widgets = 12
background = box.png
dialog = false
@@ -21,7 +21,7 @@
name = InGameTouchCompWheel
setting = joystick.touchcomp
values = options
-center = 0.5, 0.29
+center = 0.5, 0.25
width = auto
height = auto
fontsize = 6
@@ -32,6 +32,20 @@
[ widget-02 ]
type = toggle
+name = InGameAutoTransToggle
+setting = control.autotrans
+values = options
+center = 0.5, 0.29
+width = auto
+height = auto
+fontsize = 6
+enabled = 1
+selected = 0
+default = 0
+cancel = 0
+
+[ widget-03 ]
+type = toggle
name = InGameAutoClutchToggle
setting = control.autoclutch
values = options
@@ -44,7 +58,7 @@
default = 0
cancel = 0
-[ widget-03 ]
+[ widget-04 ]
type = toggle
name = InGameABSToggle
setting = game.antilock
@@ -58,7 +72,7 @@
default = 0
cancel = 0
-[ widget-04 ]
+[ widget-05 ]
type = toggle
name = InGameTCSToggle
setting = game.traction_control
@@ -72,7 +86,7 @@
default = 0
cancel = 0
-[ widget-05 ]
+[ widget-06 ]
type = floatwheel
name = InGameButtonRampWheel
setting = control.button_ramp
@@ -86,7 +100,7 @@
default = 0
cancel = 0
-[ widget-06 ]
+[ widget-07 ]
type = button
name = InGameActionControlMapButton
text = Assign Controls
@@ -102,7 +116,7 @@
default = 0
cancel = 0
-[ widget-07 ]
+[ widget-08 ]
type = button
name = InGameJoystickOptionsButton
text = Joystick Options
@@ -118,7 +132,7 @@
default = 0
cancel = 0
-[ widget-08 ]
+[ widget-09 ]
type = button
name = InGameMouseOptionsButton
text = Mouse Options
@@ -134,7 +148,7 @@
default = 0
cancel = 0
-[ widget-09 ]
+[ widget-10 ]
type = button
name = InGameControlsOptionsOKButton
text = OK
@@ -150,7 +164,7 @@
default = 1
cancel = 0
-[ widget-10 ]
+[ widget-11 ]
type = button
name = InGameControlsOptionsCancelButton
text = Cancel
|
|
11-06-2006, 01:03 AM,
|
|
rookie1
Member
|
Posts: 231
Threads: 32
Joined: Nov 2006
|
|
That's strange. I've tested using 3S, CS, XS. And it's working fine.
Do you expect an autoshift from neutral to 1st gear? Base on real world car, I've decided that shifting from neutral to 1st gear should be manual. So you have to manually shift to 1st gear before auto shifting will kick in.
|
|
11-06-2006, 02:07 AM,
|
|
rookie1
Member
|
Posts: 231
Threads: 32
Joined: Nov 2006
|
|
Looking forward to other's comments.
Regarding your observation on shift down, it's because i just hardcoded 200 rad/s (around 2000RPM) as the shift down threshold. We certainly need a better algorithm for this.
On the patching probelm, what is the issue that you have to do it manually? I've done a 'patch -p0 < vdrift.diff' against a prestine svn copy. The patch applied cleanly.
|
|
|