1 #pragma once
2 #include "dbl.h"
3 #include "settings.h"
4 #include "pathmanager.h"
5 #include "mathvector.h"
6 #include "quaternion.h"
7 #include "car.h"
8 #include "collision_world.h"
9 #include "collision_contact.h"
10 #include "carcontrolmap_local.h"
11 #include "cartire.h"
12 #include "tracksurface.h"
13 #include "track.h"
14 #include "timer.h"
15 #include "forcefeedback.h"
16 //#include "../sound/SoundMgr.h"
17 #include <OgreTimer.h>
18 #include <boost/thread.hpp>
19 
20 class SoundMgr;  class Sound;
21 
22 
23 class GAME
24 {
25 public:
26 	class App* app;
27 
28 	GAME(SETTINGS* pSettings);
29 
30 	void Start(std::list <std::string>& args);
31 
TickPeriod()32 	double TickPeriod() const {  return framerate;  }
33 	bool OneLoop(double dt);
34 
35 	void ReloadSimData();
36 	bool reloadSimNeed,reloadSimDone;  //for tweak tire save
37 
38 	bool ParseArguments(std::list <std::string>& args);
39 	bool InitializeSound();  void LoadHudSounds();
40 	void End();
41 
42 	void Test();
43 	void Tick(double dt);
44 
45 	void AdvanceGameLogic(double dt);
46 	void UpdateCar(CAR& car, double dt);
47 	void UpdateCarInputs(CAR& car);
48 	void UpdateTimer();
49 
50 	/// ---  new game  ========
51 	void LeaveGame(bool dstTrk);  // call in this order
52 	bool NewGameDoLoadTrack();  // track
53 	bool NewGameDoLoadMisc(float pre_time);  // timer,etc
54 
55 
56 	bool LoadTrack(const std::string& trackname);
57 	CAR* LoadCar(const std::string& pathCar, const std::string& carname,
58 		const MATHVECTOR<float,3>& start_pos, const QUATERNION<float>& start_rot,
59 		bool islocal, bool isRemote/*=false*/, int idCar);
60 
61 	void ProcessNewSettings();
62 	void UpdateForceFeedback(float dt);
63 	float GetSteerRange() const;
64 
65 //  vars
66 
67 	unsigned int frame, displayframe;  // physics, display frame counters
68 	double clocktime, target_time;  // elapsed wall clock time
69 	const double framerate;
70 	float fps_min, fps_max;
71 
72 	bool benchmode, profilingmode, pause;
73 
74 
75 	//  cars  ---
76 	SETTINGS* settings;
77 	TRACK track;
78 
79 	std::vector<CAR*> cars;
80 	std::pair <CAR*, CARCONTROLMAP_LOCAL> controls;
81 
82 	COLLISION_WORLD collision;
83 	bool bResetObj;
84 
85 	TIMER timer;
86 
87 
88 	//  Sound  ---
89 	SoundMgr* snd;
90 	Sound* snd_chk, *snd_chkwr,  *snd_lap, *snd_lapbest,  *snd_stage, *snd_win[3], *snd_fail;
91 	void UpdHudSndVol();
92 
93 
94 	///  New  carsim  -------------
95 	std::vector <CARTIRE> tires;  /// all tires
96 	std::map <std::string, int> tires_map;  // name to tires id
97 	bool LoadTire(CARTIRE& ct, std::string path, std::string& file);
98 	bool LoadTires();
99 
100 	//  ref graphs, tire edit
101 	std::string tire_ref;  int tire_ref_id;
102 	void PickTireRef(std::string name);
103 
104 	std::vector <TRACKSURFACE> surfaces;  /// all surfaces
105 	std::map <std::string, int> surf_map;  // name to surface id
106 	bool LoadAllSurfaces();
107 
108 	std::vector <std::vector <std::pair<double, double> > > suspS,suspD;  /// all suspension factors files (spring, damper)
109 	std::map <std::string, int> suspS_map,suspD_map;  // name to susp id
110 	bool LoadSusp();
111 
112 #ifdef ENABLE_FORCE_FEEDBACK
113 	std::auto_ptr <FORCEFEEDBACK> forcefeedback;
114 	double ff_update_time;
115 #endif
116 };
117