Planeshift
eventmanager.h
Go to the documentation of this file.
1
/*
2
* eventmanager.h
3
*
4
* Copyright (C) 2001 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5
*
6
*
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation (version 2 of the License)
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
*
18
*/
19
20
#ifndef __EVENTMANAGER_H__
21
#define __EVENTMANAGER_H__
22
23
#include "
util/heap.h
"
24
#include "
net/msghandler.h
"
25
26
class
psGameEvent
;
27
class
MsgHandler
;
28
40
class
EventManager
:
public
MsgHandler
,
public
Singleton
<EventManager>
41
{
42
protected
:
43
CS::Threading::Mutex
mutex
;
44
Heap<psGameEvent>
eventqueue
;
45
46
csTicks
lastTick
;
47
49
bool
stop
;
50
52
void
TrackEventTimes
(csTicks timeTaken,
MsgEntry
*msg);
53
54
public
:
55
EventManager
();
56
virtual
~EventManager
();
57
58
// Thread main loop, handling timed events and inbound messages
59
virtual
void
Run
();
60
61
// Called by external threads to make the Run() loop stop.
62
void
Stop
() { stop =
true
; }
63
65
void
Push
(
psGameEvent
*event);
66
68
csTicks
ProcessEventQueue
();
69
71
virtual
void
SendMessageDelayed
(
MsgEntry
*msg,csTicks msecDelay);
72
};
73
76
#endif
Heap< psGameEvent >
EventManager::Stop
void Stop()
Definition:
eventmanager.h:62
EventManager::lastTick
csTicks lastTick
Definition:
eventmanager.h:46
EventManager::ProcessEventQueue
csTicks ProcessEventQueue()
Check Event Queue for scheduled events which are due.
MsgEntry
The structure of 1 queue entry (pointer to a message)
Definition:
message.h:143
EventManager::EventManager
EventManager()
EventManager::SendMessageDelayed
virtual void SendMessageDelayed(MsgEntry *msg, csTicks msecDelay)
Allows sending of a message not immediately, but after a short delay.
EventManager::~EventManager
virtual ~EventManager()
heap.h
EventManager::Run
virtual void Run()
EventManager::mutex
CS::Threading::Mutex mutex
Definition:
eventmanager.h:43
EventManager::TrackEventTimes
void TrackEventTimes(csTicks timeTaken, MsgEntry *msg)
Helper function to keep a running average of the last 50 events.
EventManager::stop
bool stop
A flag indicating the server is shutting down.
Definition:
eventmanager.h:49
MsgHandler
This class is the client's and server's main interface for either sending network messages out or get...
Definition:
msghandler.h:106
EventManager::eventqueue
Heap< psGameEvent > eventqueue
Definition:
eventmanager.h:44
Singleton
Definition:
singleton.h:26
psGameEvent
All scheduled events must inherit from this class.
Definition:
gameevent.h:36
EventManager
This class handles all queueing and invoking of timed events, such as combat, spells, NPC dialog responses, range weapons, or NPC respawning.
Definition:
eventmanager.h:40
msghandler.h
EventManager::Push
void Push(psGameEvent *event)
Add new event to scheduler queue.
common
util
eventmanager.h
Generated on Sat Jun 19 2021 05:00:30 for Planeshift by
1.8.11