summaryrefslogtreecommitdiffstats
path: root/src/vehicles/HandlingMgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/vehicles/HandlingMgr.cpp160
1 files changed, 67 insertions, 93 deletions
diff --git a/src/vehicles/HandlingMgr.cpp b/src/vehicles/HandlingMgr.cpp
index 8438c5c9..b5dc7658 100644
--- a/src/vehicles/HandlingMgr.cpp
+++ b/src/vehicles/HandlingMgr.cpp
@@ -42,6 +42,7 @@ const char VehicleNames[NUMHANDLINGS][14] = {
"RHINO",
"BARRACKS",
"TRAIN",
+ "FERRY",
"HELI",
"DODO",
"COACH",
@@ -54,66 +55,40 @@ const char VehicleNames[NUMHANDLINGS][14] = {
"DEADDODO",
"FLATBED",
"YANKEE",
- "GOLFCART",
- "VOODOO",
- "WASHING",
- "CUBAN",
- "ROMERO",
- "PACKER",
- "ADMIRAL",
- "GANGBUR",
- "ZEBRA",
- "TOPFUN",
- "GLENDALE",
- "OCEANIC",
- "HERMES",
- "SABRE1",
- "SABRETUR",
- "PHEONIX",
- "WALTON",
- "REGINA",
- "COMET",
- "DELUXO",
- "BURRITO",
- "SPAND",
- "BAGGAGE",
- "KAUFMAN",
- "RANCHER",
- "FBIRANCH",
- "VIRGO",
- "GREENWOO",
- "HOTRING",
- "SANDKING",
- "BLISTAC",
- "BOXVILLE",
- "BENSON",
- "DESPERAD",
- "LOVEFIST",
- "BLOODRA",
- "BLOODRB",
+ "BLISTA",
+ "BELLYUP",
+ "MRWONGS",
+ "YARDIE",
+ "YAKUZA",
+ "DIABLOS",
+ "COLUMB",
+ "HOODS",
+ "PANLANT",
+ "BORGNINE",
+ "CAMPVAN",
+ "BALLOT",
+ "SPIDER",
+ "SHELBY",
+ "PONTIAC",
+ "ESPRIT",
+ "MINI",
+ "HOTROD",
+ "SINDACCO",
+ "FORELLI",
"BIKE",
"MOPED",
"DIRTBIKE",
"ANGEL",
+ "DIRTBIK2",
+ "ANGE2",
"FREEWAY",
"PREDATOR",
"SPEEDER",
"REEFER",
- "RIO",
- "SQUALO",
- "TROPIC",
- "COASTGRD",
- "DINGHY",
- "MARQUIS",
- "CUPBOAT",
- "SEAPLANE",
- "SPARROW",
- "SEASPAR",
"MAVERICK",
"COASTMAV",
"POLMAV",
"HUNTER",
- "RCBARON",
"RCGOBLIN",
"RCCOPTER"
};
@@ -138,18 +113,17 @@ void
cHandlingDataMgr::LoadHandlingData(void)
{
char *start, *end;
- char line[201]; // weird value
+ char line[300];
char delim[4]; // not sure
char *word;
int field, handlingId;
- int keepGoing;
tHandlingData *handling;
tFlyingHandlingData *flyingHandling;
tBoatHandlingData *boatHandling;
tBikeHandlingData *bikeHandling;
CFileMgr::SetDir("DATA");
- CFileMgr::LoadFile(HandlingFilename, work_buff, sizeof(work_buff), "r");
+ ssize_t filesz = CFileMgr::LoadFile(HandlingFilename, work_buff, sizeof(work_buff), "r");
CFileMgr::SetDir("");
start = (char*)work_buff;
@@ -158,21 +132,18 @@ cHandlingDataMgr::LoadHandlingData(void)
flyingHandling = nil;
boatHandling = nil;
bikeHandling = nil;
- keepGoing = 1;
- while(keepGoing){
+ while(start < (char*)&work_buff[filesz]){
// find end of line
while(*end != '\n') end++;
// get line
strncpy(line, start, end - start);
line[end - start] = '\0';
- start = end+1;
- end = start+1;
// yeah, this is kinda crappy
if(strcmp(line, ";the end") == 0)
- keepGoing = 0;
+ break;
else if(line[0] != ';'){
if(line[0] == '!'){
// Bike data
@@ -286,19 +257,19 @@ cHandlingDataMgr::LoadHandlingData(void)
handling->nIdentifier = (tVehicleType)handlingId;
break;
case 1: handling->fMass = atof(word); break;
- case 2: handling->Dimension.x = atof(word); break;
- case 3: handling->Dimension.y = atof(word); break;
- case 4: handling->Dimension.z = atof(word); break;
- case 5: handling->CentreOfMass.x = atof(word); break;
- case 6: handling->CentreOfMass.y = atof(word); break;
- case 7: handling->CentreOfMass.z = atof(word); break;
- case 8: handling->nPercentSubmerged = atoi(word); break;
- case 9: handling->fTractionMultiplier = atof(word); break;
- case 10: handling->fTractionLoss = atof(word); break;
- case 11: handling->fTractionBias = atof(word); break;
- case 12: handling->Transmission.nNumberOfGears = atoi(word); break;
- case 13: handling->Transmission.fMaxVelocity = atof(word); break;
- case 14: handling->Transmission.fEngineAcceleration = atof(word) * 0.4; break;
+ case 2: handling->fTurnMass = atof(word); break;
+ case 3: handling->fDragMult = atof(word); break;
+ case 4: handling->CentreOfMass.x = atof(word); break;
+ case 5: handling->CentreOfMass.y = atof(word); break;
+ case 6: handling->CentreOfMass.z = atof(word); break;
+ case 7: handling->nPercentSubmerged = atoi(word); break;
+ case 8: handling->fTractionMultiplier = atof(word); break;
+ case 9: handling->fTractionLoss = atof(word); break;
+ case 10: handling->fTractionBias = atof(word); break;
+ case 11: handling->Transmission.nNumberOfGears = atoi(word); break;
+ case 12: handling->Transmission.fMaxVelocity = atof(word); break;
+ case 13: handling->Transmission.fEngineAcceleration = atof(word) * 0.4; break;
+ case 14: handling->Transmission.fEngineInertia = atof(word); break;
case 15: handling->Transmission.nDriveType = word[0]; break;
case 16: handling->Transmission.nEngineType = word[0]; break;
case 17: handling->fBrakeDeceleration = atof(word); break;
@@ -307,25 +278,28 @@ cHandlingDataMgr::LoadHandlingData(void)
case 20: handling->fSteeringLock = atof(word); break;
case 21: handling->fSuspensionForceLevel = atof(word); break;
case 22: handling->fSuspensionDampingLevel = atof(word); break;
- case 23: handling->fSeatOffsetDistance = atof(word); break;
- case 24: handling->fCollisionDamageMultiplier = atof(word); break;
- case 25: handling->nMonetaryValue = atoi(word); break;
- case 26: handling->fSuspensionUpperLimit = atof(word); break;
- case 27: handling->fSuspensionLowerLimit = atof(word); break;
- case 28: handling->fSuspensionBias = atof(word); break;
- case 29: handling->fSuspensionAntidiveMultiplier = atof(word); break;
- case 30:
+ // case 23: // fSuspensionHighSpdComDamp unused
+ case 24: handling->fSuspensionUpperLimit = atof(word); break;
+ case 25: handling->fSuspensionLowerLimit = atof(word); break;
+ case 26: handling->fSuspensionBias = atof(word); break;
+ case 27: handling->fSuspensionAntidiveMultiplier = atof(word); break;
+ case 28: handling->fSeatOffsetDistance = atof(word); break;
+ case 29: handling->fCollisionDamageMultiplier = atof(word); break;
+ case 30: handling->nMonetaryValue = atoi(word); break;
+ case 31:
sscanf(word, "%x", &handling->Flags);
- handling->Transmission.Flags = handling->Flags;
+ // handling->Transmission.Flags = handling->Flags;
break;
- case 31: handling->FrontLights = atoi(word); break;
- case 32: handling->RearLights = atoi(word); break;
+ case 32: handling->FrontLights = atoi(word); break;
+ case 33: handling->RearLights = atoi(word); break;
}
field++;
}
ConvertDataToGameUnits(handling);
}
}
+ start = end+1;
+ end = start+1;
}
}
@@ -353,12 +327,9 @@ cHandlingDataMgr::ConvertDataToGameUnits(tHandlingData *handling)
handling->Transmission.fEngineAcceleration *= 1.0f/(50.0f*50.0f);
handling->Transmission.fMaxVelocity *= 1000.0f/(60.0f*60.0f * 50.0f);
handling->fBrakeDeceleration *= 1.0f/(50.0f*50.0f);
- handling->fTurnMass = (sq(handling->Dimension.x) + sq(handling->Dimension.y)) * handling->fMass / 12.0f;
- if(handling->fTurnMass < 10.0f)
- handling->fTurnMass *= 5.0f;
- handling->fInvMass = 1.0f/handling->fMass;
- handling->fCollisionDamageMultiplier *= 2000.0f/handling->fMass;
- handling->fBuoyancy = 100.0f/handling->nPercentSubmerged * GRAVITY*handling->fMass;
+ handling->fInvMass = 1.0f/handling->GetMass();
+ handling->fCollisionDamageMultiplier = handling->GetCollisionDamageMultiplier() * 2000.0f/handling->GetMass();
+ handling->fBuoyancy = 100.0f/handling->nPercentSubmerged * GRAVITY*handling->GetMass();
// Don't quite understand this. What seems to be going on is that
// we calculate a drag (air resistance) deceleration for a given velocity and
@@ -371,10 +342,13 @@ cHandlingDataMgr::ConvertDataToGameUnits(tHandlingData *handling)
velocity -= 0.01f;
// what's the 1/6?
a = handling->Transmission.fEngineAcceleration/6.0f;
- // no density or drag coefficient here...
- float a_drag = 0.5f*SQR(velocity) * handling->Dimension.x*handling->Dimension.z / handling->fMass;
- // can't make sense of this... maybe v - v/(drag + 1) ? but that doesn't make so much sense either
- b = -velocity * (1.0f/(a_drag + 1.0f) - 1.0f);
+ // no idea what's happening here
+ float drag;
+ if(handling->fDragMult < 0.01f)
+ drag = 1.0f - 1.0f/(SQR(velocity)*handling->fDragMult + 1.0f);
+ else
+ drag = 0.0005f*handling->fDragMult * velocity;
+ b = velocity * drag;
}
if(handling->nIdentifier == HANDLING_RCBANDIT){
@@ -420,15 +394,15 @@ cHandlingDataMgr::GetHandlingId(const char *name)
tFlyingHandlingData*
cHandlingDataMgr::GetFlyingPointer(uint8 id)
{
- if(id >= HANDLING_SEAPLANE && id <= HANDLING_RCCOPTER)
- return &FlyingHandlingData[id-HANDLING_SEAPLANE];
+ if(id >= HANDLING_MAVERICK && id <= HANDLING_RCCOPTER)
+ return &FlyingHandlingData[id-HANDLING_MAVERICK];
return &FlyingHandlingData[0];
}
tBoatHandlingData*
cHandlingDataMgr::GetBoatPointer(uint8 id)
{
- if(id >= HANDLING_PREDATOR && id <= HANDLING_SEAPLANE)
+ if(id >= HANDLING_PREDATOR && id <= HANDLING_MAVERICK)
return &BoatHandlingData[id-HANDLING_PREDATOR];
return &BoatHandlingData[0];
}