HoverRace  2.0
GameSession.h
Go to the documentation of this file.
1 // GameSession.h
2 //
3 // Copyright (c) 1995-1998 - Richard Langlois and Grokksoft Inc.
4 //
5 // Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
6 // you may not use this file except in compliance with the License.
7 //
8 // A copy of the license should have been attached to the package from which
9 // you have taken this file. If you can not find the license you can not use
10 // this file.
11 //
12 //
13 // The author makes no representations about the suitability of
14 // this software for any purpose. It is provided "as is" "AS IS",
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
16 // implied.
17 //
18 // See the License for the specific language governing permissions
19 // and limitations under the License.
20 //
21 
22 #pragma once
23 
24 #include "../Parcel/RecordFile.h"
25 #include "../Util/WorldCoordinates.h"
26 #include "ContactEffect.h"
27 #include "MazeElement.h"
28 #include "ShapeCollisions.h"
29 
30 #if defined(_WIN32) && defined(HR_ENGINE_SHARED)
31 # ifdef MR_ENGINE
32 # define MR_DllDeclare __declspec( dllexport )
33 # else
34 # define MR_DllDeclare __declspec( dllimport )
35 # endif
36 #else
37 # define MR_DllDeclare
38 #endif
39 
40 namespace HoverRace {
41  namespace Model {
42  class GameOptions;
43  class Level;
44  class Track;
45  }
46 }
47 
48 template<class T>
50 
51 namespace HoverRace {
52 namespace Model {
53 
55 {
56 public:
57  GameSession(bool pAllowRendering = true);
58  ~GameSession();
59 
60  bool LoadNew(const char *pTitle, std::shared_ptr<Track> track,
61  const Model::GameOptions &gameOpts);
62 
63  void SetSimulationTime(MR_SimulationTime);
64  MR_SimulationTime GetSimulationTime() const;
65  void Simulate();
66  void SimulateLateElement(MR_FreeElementHandle pElement,
67  MR_SimulationTime pDuration, int pRoom);
68 
69  Level *GetCurrentLevel() const;
70  const char *GetTitle() const;
71 
72 private:
73  bool LoadLevel(const Model::GameOptions &gameOpts);
74  void Clean(); // Clean up before destruction or clean-up
75 
76  void SimulateFreeElems(MR_SimulationTime pDuration);
77  int SimulateOneFreeElem(MR_SimulationTime pTimeToSimulate,
78  MR_FreeElementHandle pElementHandle, int pRoom);
79  void SimulateSurfaceElems(MR_SimulationTime pDuration);
80 
81  // SimulateFreeElem sub-functions
82  void ComputeShapeContactEffects(int pCurrentRoom,
83  FreeElement *pActor, const RoomContactSpec &pLastSpec,
84  MR_FastArrayBase<int> *pVisitedRooms, int pMaxDepth,
85  MR_SimulationTime pDuration);
86 
87 private:
90 
91  std::string mTitle;
92  std::shared_ptr<Track> track;
93 
96 };
97 
98 } // namespace Model
99 } // namespace HoverRace
100 
101 #undef MR_DllDeclare
Level
Definition: Log.h:62
bool mAllowRendering
Definition: GameSession.h:88
MR_DllDeclare void Clean() noexcept
Must be called at the end of the program.
Definition: DllObjectFactory.cpp:63
int mCurrentLevelNumber
Definition: GameSession.h:89
#define MR_DllDeclare
Definition: GameSession.h:37
MR_Int32 MR_SimulationTime
Definition: WorldCoordinates.h:106
Definition: MazeElement.h:151
std::string mTitle
Definition: GameSession.h:91
Definition: GameSession.h:49
Definition: GameOptions.h:41
std::shared_ptr< Track > track
Definition: GameSession.h:92
Definition: Level.h:74
MR_FreeElementHandleClass * MR_FreeElementHandle
Definition: MazeElement.h:51
MR_SimulationTime mSimulationTime
Time simulated since the session start.
Definition: GameSession.h:94
Definition: Announcement.h:24
Definition: GameSession.h:54
Definition: ShapeCollisions.h:67
Util::OS::timestamp_t mLastSimulateCallTime
Time in ms obtained by timeGetTime.
Definition: GameSession.h:95
MR_Int64 timestamp_t
Definition: OS.h:55