Planeshift
|
00001 /* 00002 * hiremanager.h creator <[email protected]> 00003 * 00004 * Copyright (C) 2013 Atomic Blue ([email protected], http://www.atomicblue.org) 00005 * 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation (version 2 of the License) 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 * 00018 */ 00019 #ifndef HIRE_MANAGER_HEADER 00020 #define HIRE_MANAGER_HEADER 00021 00022 //==================================================================================== 00023 // Crystal Space Includes 00024 //==================================================================================== 00025 #include <csutil/list.h> 00026 00027 //==================================================================================== 00028 // Project Includes 00029 //==================================================================================== 00030 00031 //==================================================================================== 00032 // Local Includes 00033 //==================================================================================== 00034 #include "msgmanager.h" // Subscriber class 00035 #include "hiresession.h" 00036 00037 //------------------------------------------------------------------------------------ 00038 // Forward Declarations 00039 //------------------------------------------------------------------------------------ 00040 00041 00049 class HireManager : public MessageManager<HireManager> 00050 { 00051 public: 00054 HireManager(); 00055 00058 virtual ~HireManager(); 00059 00066 bool Initialize(); 00067 00075 bool StartHire(gemActor* owner); 00076 00084 bool SetHireType(gemActor* owner, const csString &name, const csString &npcType); 00085 00091 bool SetHireMasterPID(gemActor* owner, PID masterPID); 00092 00097 gemActor* ConfirmHire(gemActor* owner); 00098 00108 bool HandleScriptMessageRequest(uint32_t clientnum, gemActor* owner, gemNPC* hiredNPC); 00109 00119 bool ReleaseHire(gemActor* owner, gemNPC* hiredNPC); 00120 00123 bool AddHiredNPC(gemNPC* hiredNPC); 00124 00127 bool AddOwner(gemActor* owner); 00128 00131 bool CheckWorkLocationResult(gemNPC* hiredNPC, bool valid, const char* errorMessage); 00132 00133 protected: 00134 private: 00137 bool Load(); 00138 00144 bool AllowedToHire(gemActor* owner); 00145 00150 HireSession* CreateHireSession(gemActor* owner); 00151 00156 HireSession* GetPendingHire(gemActor* owner); 00157 00160 HireSession* GetSessionByHirePID(PID hiredPID); 00161 00164 HireSession* GetSessionByPIDs(PID ownerPID, PID hiredPID); 00165 00168 void RemovePendingHire(gemActor* owner); 00169 00172 void HandleScriptMessage(MsgEntry* me, Client* client); 00173 00176 bool ValidateScript(PID ownerPID, PID hiredPID, const csString &script, csString &errorMessage); 00177 00180 bool HandleScriptMessageCommit(uint32_t clientnum, PID ownerPID, PID hiredPID); 00181 00184 bool CancelScript(PID ownerPID, PID hiredPID); 00185 00188 bool WorkLocation(gemActor* owner, gemNPC* hiredNPC); 00189 00192 Location* CreateUpdateLocation(const char* type, const char* name, 00193 iSector* sector, const csVector3 &position, float angle); 00194 00195 // Private data 00196 00197 csList<HireSession*> hires; // List of all hire sessions in the manager. 00198 00199 csHash<HireSession*,PID> pendingHires; // List of all pending hires by owner PID. 00200 00201 }; 00202 00203 #endif