- fix bug with tires change choice for player
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@8781 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: b704a7a96ca1569b29d7a219d580067a8750f5d8 Former-commit-id: 3f25b52d781696c051109c687393df3ccc338f41
This commit is contained in:
parent
22630d2cd4
commit
87801dc8cf
1 changed files with 40 additions and 30 deletions
|
@ -744,9 +744,9 @@ void HumanDriver::new_race(int index, tCarElt* car, tSituation *s)
|
||||||
}//KEYBOARD
|
}//KEYBOARD
|
||||||
|
|
||||||
}//for i
|
}//for i
|
||||||
|
|
||||||
//initialize the force feedback
|
//initialize the force feedback
|
||||||
forceFeedback.readConfiguration(car->_carName);
|
forceFeedback.readConfiguration(car->_carName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HumanDriver::pause_race(int index, tCarElt* /*car*/, tSituation* /*s*/)
|
void HumanDriver::pause_race(int index, tCarElt* /*car*/, tSituation* /*s*/)
|
||||||
|
@ -1040,7 +1040,7 @@ static void common_drive(const int index, tCarElt* car, tSituation *s)
|
||||||
// pow used to indicate the polarity of 'more turn'
|
// pow used to indicate the polarity of 'more turn'
|
||||||
if (cmd[CMD_LEFTSTEER].pow > 0)
|
if (cmd[CMD_LEFTSTEER].pow > 0)
|
||||||
ax0 = ax0 - cmd[CMD_LEFTSTEER].deadZone;
|
ax0 = ax0 - cmd[CMD_LEFTSTEER].deadZone;
|
||||||
else
|
else
|
||||||
ax0 = 1 - ax0 - cmd[CMD_LEFTSTEER].deadZone;
|
ax0 = 1 - ax0 - cmd[CMD_LEFTSTEER].deadZone;
|
||||||
|
|
||||||
if (ax0 < 0) ax0 = 0;
|
if (ax0 < 0) ax0 = 0;
|
||||||
|
@ -1128,7 +1128,7 @@ static void common_drive(const int index, tCarElt* car, tSituation *s)
|
||||||
// pow used to indicate the polarity of 'more turn'
|
// pow used to indicate the polarity of 'more turn'
|
||||||
if (cmd[CMD_RIGHTSTEER].pow > 0)
|
if (cmd[CMD_RIGHTSTEER].pow > 0)
|
||||||
ax0 = ax0 - cmd[CMD_RIGHTSTEER].deadZone;
|
ax0 = ax0 - cmd[CMD_RIGHTSTEER].deadZone;
|
||||||
else
|
else
|
||||||
ax0 = 1 - ax0 - cmd[CMD_RIGHTSTEER].deadZone;
|
ax0 = 1 - ax0 - cmd[CMD_RIGHTSTEER].deadZone;
|
||||||
|
|
||||||
if (ax0 < 0) ax0 = 0;
|
if (ax0 < 0) ax0 = 0;
|
||||||
|
@ -1202,12 +1202,12 @@ static void common_drive(const int index, tCarElt* car, tSituation *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
car->_steerCmd = leftSteer + rightSteer;
|
car->_steerCmd = leftSteer + rightSteer;
|
||||||
|
|
||||||
//send force feedback effect to the wheel
|
//send force feedback effect to the wheel
|
||||||
//dont' even try to do it if steer command is on a keyboard because it somehow manage to crash (unable to identify the joystic to send FF to?)
|
//dont' even try to do it if steer command is on a keyboard because it somehow manage to crash (unable to identify the joystic to send FF to?)
|
||||||
if(cmd[CMD_LEFTSTEER].type != GFCTRL_TYPE_KEYBOARD && cmd[CMD_LEFTSTEER].type != GFCTRL_TYPE_MOUSE_AXIS){
|
if(cmd[CMD_LEFTSTEER].type != GFCTRL_TYPE_KEYBOARD && cmd[CMD_LEFTSTEER].type != GFCTRL_TYPE_MOUSE_AXIS){
|
||||||
// v<- this controller detenction does not make ->v
|
// v<- this controller detenction does not make ->v
|
||||||
// v<- sense to me ->v
|
// v<- sense to me ->v
|
||||||
HCtx[idx]->lastForceFeedbackIndex = int((cmd[CMD_LEFTSTEER].val) / GFCTRL_JOY_NUMBER);
|
HCtx[idx]->lastForceFeedbackIndex = int((cmd[CMD_LEFTSTEER].val) / GFCTRL_JOY_NUMBER);
|
||||||
HCtx[idx]->lastForceFeedbackLevel = forceFeedback.updateForce(car, s);
|
HCtx[idx]->lastForceFeedbackLevel = forceFeedback.updateForce(car, s);
|
||||||
HCtx[idx]->lastForceFeedbackDir = 0;
|
HCtx[idx]->lastForceFeedbackDir = 0;
|
||||||
|
@ -1215,7 +1215,7 @@ static void common_drive(const int index, tCarElt* car, tSituation *s)
|
||||||
HCtx[idx]->lastForceFeedbackIndex,
|
HCtx[idx]->lastForceFeedbackIndex,
|
||||||
HCtx[idx]->lastForceFeedbackLevel,
|
HCtx[idx]->lastForceFeedbackLevel,
|
||||||
HCtx[idx]->lastForceFeedbackDir );
|
HCtx[idx]->lastForceFeedbackDir );
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GLANCERATE 3 // speed at which the driver turns his head, ~1/3s to full glance
|
#define GLANCERATE 3 // speed at which the driver turns his head, ~1/3s to full glance
|
||||||
newGlance = car->_glance;
|
newGlance = car->_glance;
|
||||||
|
@ -1226,14 +1226,14 @@ static void common_drive(const int index, tCarElt* car, tSituation *s)
|
||||||
|| (cmd[CMD_LEFTGLANCE].type == GFCTRL_TYPE_JOY_ATOB && cmd[CMD_LEFTGLANCE].deadZone != 0))
|
|| (cmd[CMD_LEFTGLANCE].type == GFCTRL_TYPE_JOY_ATOB && cmd[CMD_LEFTGLANCE].deadZone != 0))
|
||||||
{
|
{
|
||||||
newGlance = newGlance - GLANCERATE * s->deltaTime;
|
newGlance = newGlance - GLANCERATE * s->deltaTime;
|
||||||
if (newGlance < -0.5) newGlance=-0.5;
|
if (newGlance < -0.5) newGlance=-0.5;
|
||||||
} else if ((cmd[CMD_RIGHTGLANCE].type == GFCTRL_TYPE_JOY_BUT && joyInfo->levelup[cmd[CMD_RIGHTGLANCE].val])
|
} else if ((cmd[CMD_RIGHTGLANCE].type == GFCTRL_TYPE_JOY_BUT && joyInfo->levelup[cmd[CMD_RIGHTGLANCE].val])
|
||||||
|| (cmd[CMD_RIGHTGLANCE].type == GFCTRL_TYPE_MOUSE_BUT && mouseInfo->button[cmd[CMD_RIGHTGLANCE].val])
|
|| (cmd[CMD_RIGHTGLANCE].type == GFCTRL_TYPE_MOUSE_BUT && mouseInfo->button[cmd[CMD_RIGHTGLANCE].val])
|
||||||
|| (cmd[CMD_RIGHTGLANCE].type == GFCTRL_TYPE_KEYBOARD && keyInfo[lookUpKeyMap(cmd[CMD_RIGHTGLANCE].val)].state)
|
|| (cmd[CMD_RIGHTGLANCE].type == GFCTRL_TYPE_KEYBOARD && keyInfo[lookUpKeyMap(cmd[CMD_RIGHTGLANCE].val)].state)
|
||||||
|| (cmd[CMD_RIGHTGLANCE].type == GFCTRL_TYPE_JOY_ATOB && cmd[CMD_RIGHTGLANCE].deadZone != 0))
|
|| (cmd[CMD_RIGHTGLANCE].type == GFCTRL_TYPE_JOY_ATOB && cmd[CMD_RIGHTGLANCE].deadZone != 0))
|
||||||
{
|
{
|
||||||
newGlance = newGlance + GLANCERATE * s->deltaTime;
|
newGlance = newGlance + GLANCERATE * s->deltaTime;
|
||||||
if (newGlance > 0.5) newGlance=0.5;
|
if (newGlance > 0.5) newGlance=0.5;
|
||||||
} else if (cmd[CMD_RIGHTGLANCE].type == GFCTRL_TYPE_JOY_AXIS && joyInfo->ax[cmd[CMD_RIGHTGLANCE].val] > cmd[CMD_RIGHTGLANCE].min)
|
} else if (cmd[CMD_RIGHTGLANCE].type == GFCTRL_TYPE_JOY_AXIS && joyInfo->ax[cmd[CMD_RIGHTGLANCE].val] > cmd[CMD_RIGHTGLANCE].min)
|
||||||
{
|
{
|
||||||
newGlance = joyInfo->ax[cmd[CMD_RIGHTGLANCE].val];
|
newGlance = joyInfo->ax[cmd[CMD_RIGHTGLANCE].val];
|
||||||
|
@ -1276,10 +1276,10 @@ static void common_drive(const int index, tCarElt* car, tSituation *s)
|
||||||
|| (cmd[CMD_DASHB_NEXT].type == GFCTRL_TYPE_JOY_ATOB && cmd[CMD_DASHB_NEXT].deadZone != 0))
|
|| (cmd[CMD_DASHB_NEXT].type == GFCTRL_TYPE_JOY_ATOB && cmd[CMD_DASHB_NEXT].deadZone != 0))
|
||||||
{
|
{
|
||||||
car->_dashboardActiveItem++;
|
car->_dashboardActiveItem++;
|
||||||
if (car->_dashboardActiveItem >= car->_dashboardInstantNb + car->_dashboardRequestNb)
|
if (car->_dashboardActiveItem >= car->_dashboardInstantNb + car->_dashboardRequestNb)
|
||||||
{car->_dashboardActiveItem = 0;}
|
{car->_dashboardActiveItem = 0;}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((cmd[CMD_DASHB_PREV].type == GFCTRL_TYPE_JOY_BUT && joyInfo->edgeup[cmd[CMD_DASHB_PREV].val])
|
if ((cmd[CMD_DASHB_PREV].type == GFCTRL_TYPE_JOY_BUT && joyInfo->edgeup[cmd[CMD_DASHB_PREV].val])
|
||||||
|| (cmd[CMD_DASHB_PREV].type == GFCTRL_TYPE_MOUSE_BUT && mouseInfo->edgedn[cmd[CMD_DASHB_PREV].val])
|
|| (cmd[CMD_DASHB_PREV].type == GFCTRL_TYPE_MOUSE_BUT && mouseInfo->edgedn[cmd[CMD_DASHB_PREV].val])
|
||||||
|| (cmd[CMD_DASHB_PREV].type == GFCTRL_TYPE_KEYBOARD && keyInfo[lookUpKeyMap(cmd[CMD_DASHB_PREV].val)].edgeDn)
|
|| (cmd[CMD_DASHB_PREV].type == GFCTRL_TYPE_KEYBOARD && keyInfo[lookUpKeyMap(cmd[CMD_DASHB_PREV].val)].edgeDn)
|
||||||
|
@ -1289,7 +1289,7 @@ static void common_drive(const int index, tCarElt* car, tSituation *s)
|
||||||
if (car->_dashboardActiveItem < 0)
|
if (car->_dashboardActiveItem < 0)
|
||||||
{car->_dashboardActiveItem = car->_dashboardInstantNb + car->_dashboardRequestNb - 1;}
|
{car->_dashboardActiveItem = car->_dashboardInstantNb + car->_dashboardRequestNb - 1;}
|
||||||
}
|
}
|
||||||
|
|
||||||
tDashboardItem *item;
|
tDashboardItem *item;
|
||||||
if (car->_dashboardActiveItem < car->_dashboardInstantNb) {
|
if (car->_dashboardActiveItem < car->_dashboardInstantNb) {
|
||||||
item = &(car->_dashboardInstant[car->_dashboardActiveItem]);
|
item = &(car->_dashboardInstant[car->_dashboardActiveItem]);
|
||||||
|
@ -1321,7 +1321,7 @@ static void common_drive(const int index, tCarElt* car, tSituation *s)
|
||||||
car->ctrl.setupChangeCmd = item;
|
car->ctrl.setupChangeCmd = item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((cmd[CMD_DASHB_DEC].type == GFCTRL_TYPE_JOY_BUT && joyInfo->edgeup[cmd[CMD_DASHB_DEC].val])
|
if ((cmd[CMD_DASHB_DEC].type == GFCTRL_TYPE_JOY_BUT && joyInfo->edgeup[cmd[CMD_DASHB_DEC].val])
|
||||||
|| (cmd[CMD_DASHB_DEC].type == GFCTRL_TYPE_MOUSE_BUT && mouseInfo->edgedn[cmd[CMD_DASHB_DEC].val])
|
|| (cmd[CMD_DASHB_DEC].type == GFCTRL_TYPE_MOUSE_BUT && mouseInfo->edgedn[cmd[CMD_DASHB_DEC].val])
|
||||||
|| (cmd[CMD_DASHB_DEC].type == GFCTRL_TYPE_KEYBOARD && keyInfo[lookUpKeyMap(cmd[CMD_DASHB_DEC].val)].edgeDn)
|
|| (cmd[CMD_DASHB_DEC].type == GFCTRL_TYPE_KEYBOARD && keyInfo[lookUpKeyMap(cmd[CMD_DASHB_DEC].val)].edgeDn)
|
||||||
|
@ -1347,8 +1347,8 @@ static void common_drive(const int index, tCarElt* car, tSituation *s)
|
||||||
car->ctrl.setupChangeCmd = item;
|
car->ctrl.setupChangeCmd = item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch (cmd[CMD_BRAKE].type) {
|
switch (cmd[CMD_BRAKE].type) {
|
||||||
case GFCTRL_TYPE_JOY_AXIS:
|
case GFCTRL_TYPE_JOY_AXIS:
|
||||||
brake = joyInfo->ax[cmd[CMD_BRAKE].val];
|
brake = joyInfo->ax[cmd[CMD_BRAKE].val];
|
||||||
|
@ -1681,7 +1681,7 @@ static void common_brake(const int idx, tCarElt* car, tSituation *s)
|
||||||
if (HCtx[idx]->useESP)
|
if (HCtx[idx]->useESP)
|
||||||
{
|
{
|
||||||
float DriftAngle = atan2(car->_speed_Y,car->_speed_X) - car->_yaw;
|
float DriftAngle = atan2(car->_speed_Y,car->_speed_X) - car->_yaw;
|
||||||
FLOAT_NORM_PI_PI(DriftAngle);
|
FLOAT_NORM_PI_PI(DriftAngle);
|
||||||
|
|
||||||
if (DriftAngle > 4.0/180.0*PI)
|
if (DriftAngle > 4.0/180.0*PI)
|
||||||
{
|
{
|
||||||
|
@ -1720,10 +1720,10 @@ static void common_brake(const int idx, tCarElt* car, tSituation *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
car->ctrl.singleWheelBrakeMode = 1;
|
car->ctrl.singleWheelBrakeMode = 1;
|
||||||
car->ctrl.brakeFrontRightCmd = (float) (car->_brakeCmd * HCtx[idx]->brakeRep * HCtx[idx]->brakeRight * HCtx[idx]->brakeFront);
|
car->ctrl.brakeFrontRightCmd = (float) (car->_brakeCmd * HCtx[idx]->brakeRep * HCtx[idx]->brakeRight * HCtx[idx]->brakeFront);
|
||||||
car->ctrl.brakeFrontLeftCmd = (float) (car->_brakeCmd * HCtx[idx]->brakeRep * HCtx[idx]->brakeLeft * HCtx[idx]->brakeFront);
|
car->ctrl.brakeFrontLeftCmd = (float) (car->_brakeCmd * HCtx[idx]->brakeRep * HCtx[idx]->brakeLeft * HCtx[idx]->brakeFront);
|
||||||
car->ctrl.brakeRearRightCmd = (float) (car->_brakeCmd * (1 - HCtx[idx]->brakeRep) * HCtx[idx]->brakeRight * HCtx[idx]->brakeRear);
|
car->ctrl.brakeRearRightCmd = (float) (car->_brakeCmd * (1 - HCtx[idx]->brakeRep) * HCtx[idx]->brakeRight * HCtx[idx]->brakeRear);
|
||||||
car->ctrl.brakeRearLeftCmd = (float) (car->_brakeCmd * (1 - HCtx[idx]->brakeRep) * HCtx[idx]->brakeLeft * HCtx[idx]->brakeRear);
|
car->ctrl.brakeRearLeftCmd = (float) (car->_brakeCmd * (1 - HCtx[idx]->brakeRep) * HCtx[idx]->brakeLeft * HCtx[idx]->brakeRear);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
car->ctrl.singleWheelBrakeMode = 0;
|
car->ctrl.singleWheelBrakeMode = 0;
|
||||||
|
@ -2087,11 +2087,21 @@ int HumanDriver::pit_cmd(int index, tCarElt* car, tSituation *s)
|
||||||
|
|
||||||
//car->_pitRepair = (int)car->_dammage;
|
//car->_pitRepair = (int)car->_dammage;
|
||||||
car->_pitRepair = car->setup.reqRepair.desired_value;
|
car->_pitRepair = car->setup.reqRepair.desired_value;
|
||||||
|
|
||||||
if (car->setup.reqPenalty.desired_value > 0.9) {
|
if (car->setup.reqPenalty.desired_value > 0.9)
|
||||||
|
{
|
||||||
car->_pitStopType = RM_PIT_STOPANDGO;
|
car->_pitStopType = RM_PIT_STOPANDGO;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
car->_pitStopType = RM_PIT_REPAIR;
|
car->_pitStopType = RM_PIT_REPAIR;
|
||||||
|
car->pitcmd.tireChange = tCarPitCmd::TireChange::NONE;
|
||||||
|
|
||||||
|
if (car->setup.reqTireset.desired_value > 0)
|
||||||
|
{
|
||||||
|
GfLogDebug("~ player tyre change asked = %.0f", car->setup.reqTireset.desired_value);
|
||||||
|
car->pitcmd.tireChange = (tCarPitCmd::TireChange::ALL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HCtx[idx]) {
|
if (HCtx[idx]) {
|
||||||
|
@ -2330,7 +2340,7 @@ void HumanDriver::human_prefs(const int robot_index, int player_index)
|
||||||
cmdCtrl[CMD_GEAR_1].type = GFCTRL_TYPE_NOT_AFFECTED;
|
cmdCtrl[CMD_GEAR_1].type = GFCTRL_TYPE_NOT_AFFECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HumanDriver::HumanDriver(const char *robotname)
|
HumanDriver::HumanDriver(const char *robotname)
|
||||||
|
|
Loading…
Reference in a new issue