Planeshift
advicemanager.h
Go to the documentation of this file.
1
/*
2
* Advicemanager.h
3
*
4
* Copyright (C) 2003 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
21
#ifndef __ADVICEMANAGER_H__
22
#define __ADVICEMANAGER_H__
23
24
//=============================================================================
25
// Crystal Space Includes
26
//=============================================================================
27
28
//=============================================================================
29
// Project Includes
30
//=============================================================================
31
32
//=============================================================================
33
// Local Includes
34
//=============================================================================
35
#include "
msgmanager.h
"
// parent class
36
#include "
gem.h
"
37
38
class
psAdviceRequestTimeoutGameEvent
;
39
class
psAdviceSessionTimeoutGameEvent
;
40
class
Client
;
41
class
psDatabase
;
42
class
AdviceManager
;
43
class
AdviceSession;
44
45
#define ADVICE_QUESTION_TIMEOUT 120000
46
#define ADVICE_QUESTION_RETRIES 5
47
#define ADVICE_SESSION_TIMEOUT 300000
48
49
#define SESSION_STATUS_UNKNOWN 0
50
#define SESSION_STATUS_CLAIMED 1
51
#define SESSION_STATUS_OWNED 2
52
60
struct
AdvisorStruct
61
{
62
uint32_t
id
;
63
csString
request
;
64
bool
ready
;
65
bool
GM
;
66
};
67
68
69
77
class
AdviceManager
:
public
MessageManager
<AdviceManager>
78
{
79
public
:
80
81
AdviceManager
(
psDatabase
*
db
);
82
virtual
~
AdviceManager
();
83
84
void
HandleAdviceMessage(
MsgEntry
* pMsg,
Client
* client);
85
91
void
AddAdvisor(
Client
* client);
92
99
void
RemoveAdvisor(uint32_t
id
,
int
connectionId);
100
106
void
AdviceRequestTimeout(AdviceSession* adviceSession);
107
115
void
CancelAdvisorSession(
gemActor
* who, AdviceSession* adviceSession,
const
char
* msg);
116
117
void
RemoveSession(AdviceSession* adviceSession);
118
125
bool
GetAdvisorMode(
int
id
,
int
connectionId);
126
127
protected
:
128
129
void
HandleAdviceRequest(
Client
* advisee, csString message);
130
void
HandleAdviceResponse(
Client
* advisee, csString sAdvisee, csString message);
131
void
HandleAdviceList(
Client
* advisor);
132
void
HandleAdviseeList(
Client
* advisor);
133
void
HandleListAdvisors(
Client
* advisor);
134
135
bool
FloodControl(csString &newmessage,
Client
* client);
136
137
csHash<AdviceSession*>
AdviseeList
;
138
csArray<AdvisorStruct>
advisors
;
139
size_t
advisorPos
;
140
psDatabase
*
database
;
141
};
142
143
class
psAdviceSessionTimeoutGameEvent
:
public
psGEMEvent
144
{
145
protected
:
146
AdviceManager
*
advicemanager
;
147
gemActor
*
adviseeActor
;
148
gemActor
*
advisorActor
;
149
150
public
:
151
AdviceSession*
adviceSession
;
152
153
psAdviceSessionTimeoutGameEvent
(
AdviceManager
* mgr,
154
int
delayticks,
155
gemActor
* advisee,
156
AdviceSession* adviceRequest);
157
158
virtual
~
psAdviceSessionTimeoutGameEvent
();
159
160
virtual
void
DeleteObjectCallback(
iDeleteNotificationObject
*
object
);
161
162
virtual
void
Trigger();
163
};
164
165
class
psAdviceRequestTimeoutGameEvent
:
public
psGEMEvent
166
{
167
protected
:
168
AdviceManager
*
advicemanager
;
169
gemActor
*
adviseeActor
;
170
gemActor
*
advisorActor
;
171
172
public
:
173
AdviceSession*
adviceSession
;
174
175
psAdviceRequestTimeoutGameEvent
(
AdviceManager
* mgr,
176
int
delayticks,
177
gemActor
* advisee,
178
AdviceSession* adviceRequest);
179
180
virtual
~
psAdviceRequestTimeoutGameEvent
();
181
182
virtual
void
DeleteObjectCallback(
iDeleteNotificationObject
*
object
);
183
184
virtual
void
Trigger();
185
};
186
187
#endif
188
189
190
psAdviceSessionTimeoutGameEvent::advisorActor
gemActor * advisorActor
Definition:
advicemanager.h:148
AdviceManager::advisors
csArray< AdvisorStruct > advisors
Definition:
advicemanager.h:138
AdvisorStruct
Holds data on an 'advisor' in the world.
Definition:
advicemanager.h:60
gem.h
msgmanager.h
MsgEntry
The structure of 1 queue entry (pointer to a message)
Definition:
message.h:143
AdvisorStruct::request
csString request
Definition:
advicemanager.h:63
psAdviceRequestTimeoutGameEvent::adviseeActor
gemActor * adviseeActor
Definition:
advicemanager.h:169
psAdviceSessionTimeoutGameEvent::adviceSession
AdviceSession * adviceSession
Definition:
advicemanager.h:151
gemActor
Any semi-autonomous object, either a player or an NPC.
Definition:
gem.h:1170
db
iDataConnection * db
Global connection to the Database. Set from the psDatabase class.
AdvisorStruct::ready
bool ready
Definition:
advicemanager.h:64
iDeleteNotificationObject
Definition:
deleteobjcallback.h:27
psAdviceRequestTimeoutGameEvent
Definition:
advicemanager.h:165
AdviceManager::AdviseeList
csHash< AdviceSession * > AdviseeList
Definition:
advicemanager.h:137
psGEMEvent
This class automatically implements timed events which depend on the existence and validity of a gemO...
Definition:
gem.h:2164
psAdviceSessionTimeoutGameEvent
Definition:
advicemanager.h:143
Client
This class collects data of a netclient.
Definition:
client.h:95
AdviceManager::advisorPos
size_t advisorPos
Definition:
advicemanager.h:139
AdviceManager
AdviceManager keeps track of all the invitations of any kind that are pending, using a collection of ...
Definition:
advicemanager.h:77
AdvisorStruct::GM
bool GM
Definition:
advicemanager.h:65
psAdviceSessionTimeoutGameEvent::advicemanager
AdviceManager * advicemanager
Definition:
advicemanager.h:146
psDatabase
Definition:
psdatabase.h:45
AdvisorStruct::id
uint32_t id
Definition:
advicemanager.h:62
psAdviceRequestTimeoutGameEvent::advicemanager
AdviceManager * advicemanager
Definition:
advicemanager.h:168
psAdviceRequestTimeoutGameEvent::advisorActor
gemActor * advisorActor
Definition:
advicemanager.h:170
AdviceManager::database
psDatabase * database
Definition:
advicemanager.h:140
psAdviceSessionTimeoutGameEvent::adviseeActor
gemActor * adviseeActor
Definition:
advicemanager.h:147
psAdviceRequestTimeoutGameEvent::adviceSession
AdviceSession * adviceSession
Definition:
advicemanager.h:173
MessageManager
Provides a manager to facilitate subscriptions.
Definition:
msgmanager.h:106
server
advicemanager.h
Generated on Sat Jun 19 2021 05:00:33 for Planeshift by
1.8.11