SuperTuxKart
game_events_protocol.hpp
1 #ifndef GAME_EVENTS_PROTOCOL_HPP
2 #define GAME_EVENTS_PROTOCOL_HPP
3 
4 #include "network/protocol.hpp"
5 #include "utils/cpp2011.hpp"
6 
7 class AbstractKart;
8 
10 {
11 public:
12  enum GameEventType : uint8_t
13  {
14  GE_KART_FINISHED_RACE = 1,
15  GE_STARTUP_BOOST = 2,
16  GE_BATTLE_KART_SCORE = 3,
17  GE_CTF_SCORED = 4,
18  GE_RESET_BALL = 5,
19  GE_PLAYER_GOAL = 6,
20  GE_CHECK_LINE = 7
21  }; // GameEventType
22 private:
23  int m_last_finished_position;
24 
25  void eliminatePlayer(const NetworkString &ns);
26 
27 public:
29  virtual ~GameEventsProtocol();
30 
31  virtual bool notifyEvent(Event* event) OVERRIDE;
32  void kartFinishedRace(AbstractKart *kart, float time);
33  void kartFinishedRace(const NetworkString &ns);
34  void sendStartupBoost(uint8_t kart_id);
35  virtual void setup() OVERRIDE {}
36  virtual void update(int ticks) OVERRIDE;
37  virtual void asynchronousUpdate() OVERRIDE {}
38  // ------------------------------------------------------------------------
39  virtual bool notifyEventAsynchronous(Event* event) OVERRIDE
40  {
41  return false;
42  } // notifyEventAsynchronous
43 
44 }; // class GameEventsProtocol
45 
46 #endif // GAME_EVENTS_PROTOCOL_HPP
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
Class representing an event that need to pass trough the system. This is used to remove ENet dependen...
Definition: event.hpp:73
Definition: game_events_protocol.hpp:10
void kartFinishedRace(AbstractKart *kart, float time)
This function is called from the server when a kart finishes a race.
Definition: game_events_protocol.cpp:161
GameEventsProtocol()
This class handles all 'major' game events.
Definition: game_events_protocol.cpp:31
virtual void setup() OVERRIDE
Called when the protocol is going to start.
Definition: game_events_protocol.hpp:35
virtual bool notifyEvent(Event *event) OVERRIDE
Notify a protocol matching the Event type of that event.
Definition: game_events_protocol.cpp:49
virtual bool notifyEventAsynchronous(Event *event) OVERRIDE
Notify a protocol matching the Event type of that event.
Definition: game_events_protocol.hpp:39
virtual void asynchronousUpdate() OVERRIDE
Called by the protocol listener as often as possible.
Definition: game_events_protocol.hpp:37
virtual void update(int ticks) OVERRIDE
Called by the protocol listener, synchronously with the main loop.
Definition: game_events_protocol.cpp:42
A new implementation of NetworkString, which has a fixed format: Byte 0: The type of the message,...
Definition: network_string.hpp:422
Abstract class used to define the global protocol functions.
Definition: protocol.hpp:68
Generic protocols declarations.