2025-07-31 08:22 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000875Spring engineGeneralpublic2008-04-29 16:24
Reporterrattle 
Assigned ToILMTitan 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusresolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0000875: [patch] brakeRate for ground units
Description- ground units use the brakeRate tag instead of 3*accelRate to brake
- brakeRate now defaults to 3*accelRate for compability reasons
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files
  • patch file icon brakerate_for_ground_units.patch (3,696 bytes) 2008-03-25 01:22 -
    Index: Sim/MoveTypes/GroundMoveType.cpp
    ===================================================================
    --- Sim/MoveTypes/GroundMoveType.cpp	(revision 5605)
    +++ Sim/MoveTypes/GroundMoveType.cpp	(working copy)
    @@ -37,7 +37,8 @@
     		CR_MEMBER(baseTurnRate),
     		CR_MEMBER(turnRate),
     		CR_MEMBER(accRate),
    -
    +		CR_MEMBER(decRate),
    +		
     		CR_MEMBER(wantedSpeed),
     		CR_MEMBER(currentSpeed),
     		CR_MEMBER(deltaSpeed),
    @@ -120,6 +121,7 @@
     CGroundMoveType::CGroundMoveType(CUnit* owner)
     :	AMoveType(owner),
     	accRate(0.01f),
    +	decRate(0.01f),
     	turnRate(0.1f),
     	baseTurnRate(0.1f),
     //	maxSpeed(0.2f),
    @@ -535,27 +537,28 @@
     		logOutput.Print("Acceleration is zero on unit %s\n",owner->unitDef->name.c_str());
     		accRate=0.01f;
     	}
    -
    -	if(fabs(dif)<0.05f){		//good speed
    -		deltaSpeed=dif/8;
    -		nextDeltaSpeedUpdate=gs->frameNum+8;
    -
    -	} else if(dif>0){				//accelerate
    -		if(dif<accRate){
    +	if(fabs(dif) < 0.05f) {		//good speed
    +		deltaSpeed = dif / 8;
    +		nextDeltaSpeedUpdate = gs->frameNum + 8;
    +	}
    +	else if(dif > 0) {				//accelerate
    +		if(dif < accRate) {
     			deltaSpeed = dif;
    -			nextDeltaSpeedUpdate=gs->frameNum;
    +			nextDeltaSpeedUpdate = gs->frameNum;
     		} else {
    -			deltaSpeed=accRate;
    -			nextDeltaSpeedUpdate=(int)(gs->frameNum+min((float)8,dif/accRate));
    +			deltaSpeed = accRate;
    +			nextDeltaSpeedUpdate = (int)(gs->frameNum + min((float) 8, dif / accRate));
     		}
    -	}else {		//break, Breakrate = -3*accRate
    -		if(dif > -3*accRate){
    +	}
    +	else {	// decRate = 0.1*brakeRate, I guess this is for aircraft
    +		if(dif > -10*decRate){
     			deltaSpeed = dif;
    -			nextDeltaSpeedUpdate=gs->frameNum+1;
    -		} else {
    -			deltaSpeed = -3*accRate;
    -			nextDeltaSpeedUpdate=(int)(gs->frameNum+min((float)8,dif/(-3*accRate)));
    +			nextDeltaSpeedUpdate = gs->frameNum + 1;
     		}
    +		else {
    +			deltaSpeed = -10*decRate;
    +			nextDeltaSpeedUpdate = (int)(gs->frameNum + min((float) 8, dif / (-10*decRate)));
    +		}
     	}
     	//float3 temp=UpVector*wSpeed;
     	//temp.CheckInBounds();
    Index: Sim/MoveTypes/GroundMoveType.h
    ===================================================================
    --- Sim/MoveTypes/GroundMoveType.h	(revision 5605)
    +++ Sim/MoveTypes/GroundMoveType.h	(working copy)
    @@ -38,6 +38,7 @@
     	float baseTurnRate;
     	float turnRate;
     	float accRate;
    +	float decRate;
     
     	float wantedSpeed;
     	float currentSpeed;
    Index: Sim/Units/UnitDefHandler.cpp
    ===================================================================
    --- Sim/Units/UnitDefHandler.cpp	(revision 5605)
    +++ Sim/Units/UnitDefHandler.cpp	(working copy)
    @@ -351,8 +351,8 @@
     	ud.selfDCountdown = udTable.GetInt("selfDestructCountdown", 5);
     
     	ud.speed    = udTable.GetFloat("maxVelocity",  0.0f) * 30.0f;
    -	ud.maxAcc   = udTable.GetFloat("acceleration", 0.5f);
    -	ud.maxDec   = udTable.GetFloat("brakeRate",    0.5f) * 0.1f;
    +	ud.maxAcc   = fabs(udTable.GetFloat("acceleration", 0.5f)); // no negative values
    +	ud.maxDec   = fabs(udTable.GetFloat("brakeRate",    3.0f*ud.maxAcc) * 0.1f); // no negative values
     	ud.turnRate = udTable.GetFloat("turnRate",     0.0f);
     
     	ud.buildRange3D = udTable.GetBool("buildRange3D", false);
    Index: Sim/Units/UnitLoader.cpp
    ===================================================================
    --- Sim/Units/UnitLoader.cpp	(revision 5605)
    +++ Sim/Units/UnitLoader.cpp	(working copy)
    @@ -218,6 +218,7 @@
     			logOutput << "acceleration of " << ud->name.c_str() << " is zero!!\n";
     		mt->moveType=ud->moveType;
     		mt->accRate=ud->maxAcc;
    +		mt->decRate=ud->maxDec;
     		mt->floatOnWater=ud->movedata->moveType==MoveData::Hover_Move || ud->movedata->moveType==MoveData::Ship_Move;
     		if(!unit->beingBuilt)
     			unit->mass=ud->mass;	//otherwise set this when finished building instead
    
    patch file icon brakerate_for_ground_units.patch (3,696 bytes) 2008-03-25 01:22 +

-Relationships
+Relationships

-Notes

~0002183

ILMTitan (reporter)

Comitted. Thank you.
+Notes

-Issue History
Date Modified Username Field Change
2008-03-25 01:22 rattle New Issue
2008-03-25 01:22 rattle File Added: brakerate_for_ground_units.patch
2008-04-01 22:43 ILMTitan Status new => assigned
2008-04-01 22:43 ILMTitan Assigned To => ILMTitan
2008-04-29 16:24 ILMTitan Status assigned => resolved
2008-04-29 16:24 ILMTitan Resolution open => fixed
2008-04-29 16:24 ILMTitan Note Added: 0002183
+Issue History