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 
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 
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 
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;
141 };
142 
144 {
145 protected:
149 
150 public:
151  AdviceSession* adviceSession;
152 
154  int delayticks,
155  gemActor* advisee,
156  AdviceSession* adviceRequest);
157 
159 
160  virtual void DeleteObjectCallback(iDeleteNotificationObject* object);
161 
162  virtual void Trigger();
163 };
164 
166 {
167 protected:
171 
172 public:
173  AdviceSession* adviceSession;
174 
176  int delayticks,
177  gemActor* advisee,
178  AdviceSession* adviceRequest);
179 
181 
182  virtual void DeleteObjectCallback(iDeleteNotificationObject* object);
183 
184  virtual void Trigger();
185 };
186 
187 #endif
188 
189 
190 
csArray< AdvisorStruct > advisors
Holds data on an &#39;advisor&#39; in the world.
Definition: advicemanager.h:60
The structure of 1 queue entry (pointer to a message)
Definition: message.h:143
csString request
Definition: advicemanager.h:63
Any semi-autonomous object, either a player or an NPC.
Definition: gem.h:1170
iDataConnection * db
Global connection to the Database. Set from the psDatabase class.
csHash< AdviceSession * > AdviseeList
This class automatically implements timed events which depend on the existence and validity of a gemO...
Definition: gem.h:2164
This class collects data of a netclient.
Definition: client.h:95
AdviceManager keeps track of all the invitations of any kind that are pending, using a collection of ...
Definition: advicemanager.h:77
psDatabase * database
Provides a manager to facilitate subscriptions.
Definition: msgmanager.h:106