Cafu Engine
ClientStateInGame.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_CLIENT_STATE_INGAME_HPP_INCLUDED
8 #define CAFU_CLIENT_STATE_INGAME_HPP_INCLUDED
9 
10 #include "ClientState.hpp"
11 #include "Graphs.hpp"
12 #include "ScrlInfo.hpp"
13 #include "Fonts/Font.hpp"
14 #include "Network/Network.hpp"
15 #include "../../Games/PlayerCommand.hpp"
16 
17 
18 struct lua_State;
19 class CaClientWorldT;
20 struct CaKeyboardEventT;
21 struct CaMouseEventT;
22 class ClientT;
23 class PathRecorderT;
24 
25 
26 /// This class implements the state of the client when it is fully connected and thus "in-game".
28 {
29  public:
30 
31  ClientStateInGameT(ClientT& Client_);
33 
34  // Implement the ClientStateT interface.
35  int GetID() const override;
36  bool ProcessInputEvent(const CaKeyboardEventT& KE) override;
37  bool ProcessInputEvent(const CaMouseEventT& ME) override;
38  void Render(float FrameTime) override;
39  void MainLoop(float FrameTime) override;
40 
41 
42  static int ConFunc_say_Callback(lua_State* LuaState);
43  static int ConFunc_chatPrint_Callback(lua_State* LuaState);
44  static int ConFunc_showPath_Callback(lua_State* LuaState);
45  static int ConFunc_recordPath_Callback(lua_State* LuaState);
46 
47 
48  private:
49 
50  ClientStateInGameT(const ClientStateInGameT&); ///< Use of the Copy Constructor is not allowed.
51  void operator = (const ClientStateInGameT&); ///< Use of the Assignment Operator is not allowed.
52 
53  void ProcessConnectionLessPacket(NetDataT& InData, const NetAddressT& SenderAddress);
54  void ParseServerPacket (NetDataT& InData);
55  static void ParseServerPacketHelper(NetDataT& InData, unsigned long /*LastIncomingSequenceNr*/);
56 
57 
58  ClientT& Client;
59 
60  GameProtocol1T GameProtocol;
61  ArrayT< ArrayT<char> > ReliableDatas;
62  NetDataT UnreliableData;
63 
64  FontT Font_v;
65  FontT Font_f;
66  CaClientWorldT* World;
67  bool IsLoadingWorld; ///< True while the world is loaded, false at all other times. This is relevant only because cf::GuiSys::GuiMan->Yield() is called while loading, which in turn calls our Render() method.
68  bool WasLMBOnceUp; ///< The left mouse button must be in the released (non-pressed, up) state after the world has been loaded. This variable is false until this has been the case!
69 
70  ScrollInfoT ChatScrollInfo;
71  ScrollInfoT SystemScrollInfo;
72  GraphsT Graphs;
73  unsigned long ClientFrameNr; ///< Counts the calls to Render(). Only used with Graphs; should be integrated there.
74  PlayerCommandT PlayerCommand; ///< The player command structure that collects the input until the next call to MainLoop().
75  unsigned int m_PlayerCommandCount; ///< The unique number of the next player command that is sent to the server (and locally processed for prediction).
76  PathRecorderT* m_PathRecorder; ///< Records the path of this client in a pointfile that can be loaded into CaWE.
77 };
78 
79 #endif
Network address consisting of an IP4 address and port number.
Definition: Network.hpp:98
This class implements a mixture of a reliable and unreliable, bi-directional network protocol for Caf...
Definition: Network.hpp:391
This class records the path that an entity takes through a level into a file.
Definition: PathRecorder.hpp:15
This struct describes a mouse event.
Definition: OpenGLWindow.hpp:185
A class for MatSys-based font rendering.
Definition: Font.hpp:19
This struct represents per-frame player inputs for controlling human player entities.
Definition: PlayerCommand.hpp:32
Definition: ClientWorld.hpp:37
This class implements the state of the client when it is fully connected and thus "in-game"...
Definition: ClientStateInGame.hpp:27
Class that allows easy and portable handling, sending and receiving of data over a network...
Definition: Network.hpp:181
Definition: ScrlInfo.hpp:17
This struct describes a keyboard event.
Definition: OpenGLWindow.hpp:20
int GetID() const override
Returns some client-specific, unique ID for this state.
Definition: ClientStateInGame.cpp:190
Definition: Client.hpp:24
This is the base class for the concrete classes that implement the states of the client.
Definition: ClientState.hpp:18
Definition: Graphs.hpp:13
Definition: Renderer.hpp:16