Planeshift
hiremanager.h
Go to the documentation of this file.
1 /*
2  * hiremanager.h creator <andersr@pvv.org>
3  *
4  * Copyright (C) 2013 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 #ifndef HIRE_MANAGER_HEADER
20 #define HIRE_MANAGER_HEADER
21 
22 //====================================================================================
23 // Crystal Space Includes
24 //====================================================================================
25 #include <csutil/list.h>
26 
27 //====================================================================================
28 // Project Includes
29 //====================================================================================
30 
31 //====================================================================================
32 // Local Includes
33 //====================================================================================
34 #include "msgmanager.h" // Subscriber class
35 #include "hiresession.h"
36 
37 //------------------------------------------------------------------------------------
38 // Forward Declarations
39 //------------------------------------------------------------------------------------
40 
41 
49 class HireManager : public MessageManager<HireManager>
50 {
51 public:
54  HireManager();
55 
58  virtual ~HireManager();
59 
66  bool Initialize();
67 
75  bool StartHire(gemActor* owner);
76 
84  bool SetHireType(gemActor* owner, const csString &name, const csString &npcType);
85 
91  bool SetHireMasterPID(gemActor* owner, PID masterPID);
92 
97  gemActor* ConfirmHire(gemActor* owner);
98 
108  bool HandleScriptMessageRequest(uint32_t clientnum, gemActor* owner, gemNPC* hiredNPC);
109 
119  bool ReleaseHire(gemActor* owner, gemNPC* hiredNPC);
120 
123  bool AddHiredNPC(gemNPC* hiredNPC);
124 
127  bool AddOwner(gemActor* owner);
128 
131  bool CheckWorkLocationResult(gemNPC* hiredNPC, bool valid, const char* errorMessage);
132 
133 protected:
134 private:
137  bool Load();
138 
144  bool AllowedToHire(gemActor* owner);
145 
150  HireSession* CreateHireSession(gemActor* owner);
151 
156  HireSession* GetPendingHire(gemActor* owner);
157 
160  HireSession* GetSessionByHirePID(PID hiredPID);
161 
164  HireSession* GetSessionByPIDs(PID ownerPID, PID hiredPID);
165 
168  void RemovePendingHire(gemActor* owner);
169 
172  void HandleScriptMessage(MsgEntry* me, Client* client);
173 
176  bool ValidateScript(PID ownerPID, PID hiredPID, const csString &script, csString &errorMessage);
177 
180  bool HandleScriptMessageCommit(uint32_t clientnum, PID ownerPID, PID hiredPID);
181 
184  bool CancelScript(PID ownerPID, PID hiredPID);
185 
188  bool WorkLocation(gemActor* owner, gemNPC* hiredNPC);
189 
192  Location* CreateUpdateLocation(const char* type, const char* name,
193  iSector* sector, const csVector3 &position, float angle);
194 
195  // Private data
196 
197  csList<HireSession*> hires; // List of all hire sessions in the manager.
198 
199  csHash<HireSession*,PID> pendingHires; // List of all pending hires by owner PID.
200 
201 };
202 
203 #endif
The Hire Sessin will manage all aspects related to a specefic hiring of a NPC.
Definition: hiresession.h:45
bool SetHireType(gemActor *owner, const csString &name, const csString &npcType)
Set the type of NPC to hire for a pending hire.
bool CheckWorkLocationResult(gemNPC *hiredNPC, bool valid, const char *errorMessage)
Result from work location check.
bool Initialize()
Initialize the Hire Manager.
bool ReleaseHire(gemActor *owner, gemNPC *hiredNPC)
Release the hire.
bool AddOwner(gemActor *owner)
Register an owner with the hire manager.
virtual ~HireManager()
Destructor.
bool AddHiredNPC(gemNPC *hiredNPC)
Register a hired NPC with the hire manager.
The structure of 1 queue entry (pointer to a message)
Definition: message.h:143
HireManager()
Constructor.
Any semi-autonomous object, either a player or an NPC.
Definition: gem.h:1170
bool HandleScriptMessageRequest(uint32_t clientnum, gemActor *owner, gemNPC *hiredNPC)
Start Scripting the hire.
This class collects data of a netclient.
Definition: client.h:95
Definition: gem.h:1910
The Hire Manager will manage all aspects related to hiring of NPCs.
Definition: hiremanager.h:49
bool SetHireMasterPID(gemActor *owner, PID masterPID)
Set the PID of the master NPC to use when hiring for a pending hire.
A Location is a named place on the map, located dynamically by NPCs as scripted.
Definition: location.h:48
gemActor * ConfirmHire(gemActor *owner)
Confirm the hire.
bool StartHire(gemActor *owner)
Start a new Hire Session.
Provides a manager to facilitate subscriptions.
Definition: msgmanager.h:106