~ubuntu-branches/ubuntu/precise/supertuxkart/precise

« back to all changes in this revision

Viewing changes to src/physics_parameters.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Gonéri Le Bouder, Gonéri Le Bouder, Eddy Petrişor
  • Date: 2006-09-08 22:59:25 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060908225925-3spug0pnh9ekwlpw
Tags: 0.2-1
[ Gonéri Le Bouder ]
* new upstream release candidate
 + Closes: #388021
 + remove supertuxkart.sh
 + add supertuxkart(|-data).install
 + clean up
 + remove deps on ${shlibs:Depends}, ${misc:Depends} for supertuxkart-data
* fix French comment was tagged de_DE
* fix not-binnmuable-any-depends-all
* fix FTBFS on 64bit arch
 + Closes: #370810

[ Eddy Petrişor ]
* added Romanian translation to desktop file

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  $Id: physics_parameters.cpp 714 2006-09-01 06:59:39Z hiker $
 
2
//
 
3
//  SuperTuxKart - a fun racing game with go-kart
 
4
//  Copyright (C) 2006 Joerg Henrichs
 
5
//
 
6
//  This program is free software; you can redistribute it and/or
 
7
//  modify it under the terms of the GNU General Public License
 
8
//  as published by the Free Software Foundation; either version 2
 
9
//  of the License, or (at your option) any later version.
 
10
//
 
11
//  This program is distributed in the hope that it will be useful,
 
12
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
//  GNU General Public License for more details.
 
15
//
 
16
//  You should have received a copy of the GNU General Public License
 
17
//  along with this program; if not, write to the Free Software
 
18
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
19
 
 
20
#include "physics_parameters.hpp"
 
21
 
 
22
PhysicsParameters* physicsParameters=0;
 
23
 
 
24
// -----------------------------------------------------------------------------
 
25
void PhysicsParameters::load(const char* filename, char *node) {
 
26
 
 
27
  KartProperties::load(filename, node);
 
28
 
 
29
  // Check that all necessary values are indeed set physics.data file
 
30
 
 
31
 
 
32
#define CHECK_NEG(  a,strA) if(a<-99) {                                    \
 
33
             fprintf(stderr,"Missing default value for '%s' in '%s'.\n",   \
 
34
                     strA,filename);exit(-1);                       \
 
35
             }
 
36
 
 
37
  CHECK_NEG(corn_r,   "corn_r"   );CHECK_NEG(wheel_base,     "wheel-base"     );
 
38
  CHECK_NEG(heightCOG,"heightCOG");CHECK_NEG(engine_power,   "engine-power"   );
 
39
  CHECK_NEG(mass,     "mass"     );CHECK_NEG(air_resistance, "air-resistance" );
 
40
  CHECK_NEG(tire_grip,"tire-grip");CHECK_NEG(max_steer_angle,"max-steer-angle");
 
41
  CHECK_NEG(corn_f,   "corn_f"   );CHECK_NEG(roll_resistance,"roll-resistance");
 
42
  CHECK_NEG(inertia,  "inertia"  );CHECK_NEG(magnetRangeSQ,  "magnet-range"   );
 
43
  CHECK_NEG(brake_factor,        "brake-factor"           );
 
44
  CHECK_NEG(jumpImpulse,         "jump-impulse"           );
 
45
  CHECK_NEG(airResReduce[1],     "reduce-air-resistance-driver");
 
46
  CHECK_NEG(airResReduce[2],     "reduce-air-resistance-racer" );
 
47
  CHECK_NEG(wheelieMaxSpeedRatio,"wheelie-max-speed-ratio");
 
48
  CHECK_NEG(wheelieMaxPitch,     "wheelie-max-pitch"      );
 
49
  CHECK_NEG(wheeliePitchRate,    "wheelie-pitch-rate"     );
 
50
  CHECK_NEG(wheelieRestoreRate,  "wheelie-restore-rate"   );
 
51
  CHECK_NEG(wheelieSpeedBoost,   "wheelie-speed-boost"    );
 
52
  CHECK_NEG(magnetMinRangeSQ,    "magnet-min-range"       );
 
53
  CHECK_NEG(parachuteFriction,   "parachute-friction"     );
 
54
  CHECK_NEG(time_full_steer,     "time-full-steer"        );
 
55
 
 
56
  // Precompute some handy values to reduce work later
 
57
  magnetRangeSQ    = magnetRangeSQ   *magnetRangeSQ;
 
58
  magnetMinRangeSQ = magnetMinRangeSQ*magnetMinRangeSQ;
 
59
}   // load
 
60
 
 
61
// -----------------------------------------------------------------------------
 
62
// Init all values with invalid defaults, which are tested later. This 
 
63
// guarantees that all parameters will indeed be initialised, and helps
 
64
// finding typos.
 
65
void PhysicsParameters::init_defaults() {
 
66
  wheel_base         = heightCOG         = magnetMinRangeSQ  = roll_resistance = 
 
67
    mass             = corn_r            =
 
68
    air_resistance   = tire_grip         = max_steer_angle   = corn_f          = 
 
69
    inertia          = anvilWeight       = parachuteFriction = engine_power    =
 
70
    magnetRangeSQ    = jumpImpulse       = brake_factor      = anvilSpeedFactor=
 
71
    time_full_steer  = wheelieMaxPitch   = wheelieMaxSpeedRatio                =
 
72
    wheeliePitchRate = wheelieRestoreRate= wheelieSpeedBoost = airResReduce[2] =
 
73
    airResReduce[1]  = -99.9; 
 
74
  airResReduce[0]    = 1.0;
 
75
}   // init_defaults
 
76
 
 
77
// -----------------------------------------------------------------------------
 
78
void PhysicsParameters::getAllData(const lisp::Lisp* lisp) {
 
79
 
 
80
  // Get the values which are not part of the default KartProperties
 
81
  // ---------------------------------------------------------------
 
82
  lisp->get("anvil-weight",                 anvilWeight         );
 
83
  lisp->get("anvil-speed-factor",           anvilSpeedFactor    );
 
84
  lisp->get("parachute-friction",           parachuteFriction   );
 
85
  lisp->get("magnet-range",                 magnetRangeSQ       );
 
86
  lisp->get("magnet-min-range",             magnetMinRangeSQ    );
 
87
  lisp->get("jump-impulse",                 jumpImpulse         );
 
88
  lisp->get("reduce-air-resistance-racer",  airResReduce[2]     );
 
89
  lisp->get("reduce-air-resistance-driver", airResReduce[1]     );
 
90
 
 
91
  // Get the default KartProperties
 
92
  // ------------------------------
 
93
  KartProperties::getAllData(lisp->getLisp("kart-defaults"));
 
94
}   // getAllData