From d0dcb64b2dafdfd0ee0753dc1c244db04c1df8f0 Mon Sep 17 00:00:00 2001 From: pouillot Date: Sun, 23 Jan 2011 14:46:32 +0000 Subject: [PATCH] Re #139 (car data sheet) Reverted non-SI support for litre=l unit : we MUST treat it as an SI one (conversion coef. = 1), otherwise, robots would no more stay compatible with TORCS) git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3279 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 6767e04338c2ae818ae8b693c9b5d1dc2824ab85 Former-commit-id: 80c59e0a7be408017b459dbf29e8c4baf4565070 --- src/libs/racescreens/carselect.cpp | 2 +- src/libs/tgf/params.cpp | 9 ++++++--- src/libs/tgfdata/cars.h | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/libs/racescreens/carselect.cpp b/src/libs/racescreens/carselect.cpp index b3948cba3..c4efef916 100644 --- a/src/libs/racescreens/carselect.cpp +++ b/src/libs/racescreens/carselect.cpp @@ -264,7 +264,7 @@ void RmCarSelectMenu::resetCarDataSheet(const std::string& strSelCarId) ossSpecValue << "cyl. "; } if (pSelCar->getEngineCapacity() > 0) - ossSpecValue << std::setprecision(1) << pSelCar->getEngineCapacity() * 1000 << " l "; + ossSpecValue << std::setprecision(1) << pSelCar->getEngineCapacity() << " l "; if (pSelCar->isTurboCharged()) ossSpecValue << "turbo"; if (ossSpecValue.str().empty()) diff --git a/src/libs/tgf/params.cpp b/src/libs/tgf/params.cpp index 2ad43bfdb..6b77f1c9f 100644 --- a/src/libs/tgf/params.cpp +++ b/src/libs/tgf/params.cpp @@ -1869,12 +1869,17 @@ evalUnit (char *unit, tdble *dest, int invert) { tdble coeff = 1.0; + // SI units. if (strcmp(unit, "m") == 0) return; if (strcmp(unit, "kg") == 0) return; if (strcmp(unit, "s") == 0) return; if (strcmp(unit, "rad") == 0) return; if (strcmp(unit, "Pa") == 0) return; + // Other non-SI units that are considered as SI ones (backward compatibility with TORCS). + if ((strcmp(unit, "l") == 0) || (strcmp(unit, "litre") == 0)) return; + + // Non-SI units conversion. if ((strcmp(unit, "feet") == 0) || (strcmp(unit, "ft") == 0)) { coeff = 0.304801f; /* m */ } else if (strcmp(unit, "deg") == 0) { @@ -1907,8 +1912,6 @@ evalUnit (char *unit, tdble *dest, int invert) coeff = 0.01f; } else if ((strcmp(unit, "mph") == 0) || (strcmp(unit, "MPH") == 0)) { coeff = 0.44704f; /* m/s */ - } else if ((strcmp(unit, "l") == 0) || (strcmp(unit, "litre") == 0)) { - coeff = 0.001f; /* m3 */ } if (invert) { @@ -1931,7 +1934,6 @@ evalUnit (char *unit, tdble *dest, int invert)
  • lbs converted to kg
  • slug or slugs converted to kg
  • h or hours converted to s
  • -
  • litre or l converted to m3
  • day or days converted to s
  • km converted to m
  • cm converted to m
  • @@ -1941,6 +1943,7 @@ evalUnit (char *unit, tdble *dest, int invert)
  • rpm or RPM converted to rad/s
  • percent or % divided by 100
  • +
    All other units are considered SI, and thus not converted (coef=1) @see GfParmSI2Unit */ tdble diff --git a/src/libs/tgfdata/cars.h b/src/libs/tgfdata/cars.h index 14f12acd1..e72ad33f0 100644 --- a/src/libs/tgfdata/cars.h +++ b/src/libs/tgfdata/cars.h @@ -88,7 +88,7 @@ protected: EDriveTrain _eDriveTrain; unsigned _nGears; // Number of gears. bool _bTurboCharged; // TODO: Move to an enum (Turbo, Compressor, ...) - tdble _fEngineCapacity; // m3 + tdble _fEngineCapacity; // litres unsigned _nCylinders; EEngineShape _eEngineShape; EEnginePosition _eEnginePosition;