Planeshift
pscharacterloader.h
Go to the documentation of this file.
1 /*
2  * pscharacterloader.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 
21 
22 
23 #ifndef __PSCHARACTERLOADER_H__
24 #define __PSCHARACTERLOADER_H__
25 
26 //=============================================================================
27 // Crystal Space Includes
28 //=============================================================================
29 
30 //=============================================================================
31 // Project Includes
32 //=============================================================================
33 #include "util/gameevent.h"
34 
35 #include <idal.h> // Database Abstraction Layer Interface
36 
37 #include "../gem.h"
38 
39 //=============================================================================
40 // Local Includes
41 //=============================================================================
42 
43 
44 class csMutex;
45 class psCharacterList;
46 class psSectorInfo;
47 class psCharacter;
48 class psItem;
49 class psItemStats;
50 class gemActor;
51 
56 /* Why isn't there a LoadItem() call here?
57  *
58  * At the time of initial design the circumstances under which an item entry will be loaded are unclear.
59  * It is virtually guaranteed that item entries will need to be loaded when a character is loaded as the character's
60  * inventory (list of items) will be necessary.
61  * It is undecided wether some, all or no items in the world and not on a character will be saved to the database.
62  * If they are saved it is likely that many items will be loaded all at once - possibly based on location data
63  * (x,y,z,sector), possibly based on some other criteria.
64  */
65 
85 {
86 public:
91 
96 
102  bool Initialize();
103 
107  psCharacterList* LoadCharacterList(AccountID accountid);
108 
109 
110  psCharacter** LoadAllNPCCharacterData(psSectorInfo* sector,int &count);
111 
122  psCharacter* LoadCharacterData(PID pid, bool forceReload);
123 
127  psCharacter* QuickLoadCharacterData(PID pid, bool noInventory);
128 
142  bool NewCharacterData(AccountID accountid, psCharacter* chardata);
143  bool NewNPCCharacterData(AccountID accountid,psCharacter* chardata);
144  unsigned int InsertNewCharacterData(const char** fieldnames, psStringArray &fieldvalues);
145 
160  bool SaveCharacterData(psCharacter* chardata,gemActor* actor,bool charRecordOnly=false);
161 
171  bool DeleteCharacterData(PID pid, csString &error);
172 
173 
183  PID FindCharacterID(const char* character_name, bool excludeNPCs=true);
184 
195  PID FindCharacterID(AccountID accountID, const char* character_name);
196 
204  bool AccountOwner(const char* characterName, AccountID accountID);
205 
209  bool UpdateCharacterSkill(PID pid, unsigned int skill_id,
210  unsigned int skill_z, unsigned int skill_y, unsigned int skill_rank);
211 
212 
213 private:
214 
215  bool ClearCharacterAdvantages(PID pid);
216  bool SaveCharacterAdvantage(PID pid, unsigned int advantage_id);
217  bool ClearCharacterSkills(PID pid);
218  bool ClearCharacterTraits(PID pid);
219  bool SaveCharacterSkill(PID pid,unsigned int skill_id,
220  unsigned int skill_z, unsigned int skill_y, unsigned int skill_rank);
221  bool SaveCharacterTrait(PID pid, unsigned int trait_id);
222  bool UpdateQuestAssignments(psCharacter* chr);
223  bool ClearCharacterSpell(psCharacter* character);
224  bool SaveCharacterSpell(psCharacter* character);
225 
226 };
227 
228 //-----------------------------------------------------------------------------
229 
230 
240 {
241 public:
242  enum Type
243  {
244  SAVE_PERIOD = 600000
245  };
246 
248 
254  psSaveCharEvent(gemActor* actor);
255 
259  ~psSaveCharEvent();
260 
264  virtual void Trigger(); // Abstract event processing function
265 
272  virtual void DeleteObjectCallback(iDeleteNotificationObject* object);
273 };
274 
277 #endif
278 
unsigned int InsertNewCharacterData(const char **fieldnames, psStringArray &fieldvalues)
This class controls loading and saving Characters and Character specific data to and from an iDatabas...
psCharacterLoader()
Construct a new psCharacterLoader, optionally specifying an iDatabase interface to use for database c...
psCharacter ** LoadAllNPCCharacterData(psSectorInfo *sector, int &count)
psCharacterList * LoadCharacterList(AccountID accountid)
Loads the names of characters for a given account for charpick screen on login.
bool SaveCharacterData(psCharacter *chardata, gemActor *actor, bool charRecordOnly=false)
Saves character data to the database.
PID FindCharacterID(const char *character_name, bool excludeNPCs=true)
This function finds a character&#39;s ID given a character name.
Any semi-autonomous object, either a player or an NPC.
Definition: gem.h:1170
This is an event that schedules regular saving of character data.
bool DeleteCharacterData(PID pid, csString &error)
Deletes character data to the database.
bool Initialize()
Initializes settings related to this class.
psCharacter * QuickLoadCharacterData(PID pid, bool noInventory)
Load just enough of the character data to know what it looks like (for selection screen).
psCharacter * LoadCharacterData(PID pid, bool forceReload)
Loads data for a character from the database and constructs and fills a new psCharacter object with t...
~psCharacterLoader()
Destructor.
bool AccountOwner(const char *characterName, AccountID accountID)
Checks to see if the character name is owned by a particular ID.
This huge class stores all the properties of any object a player can have in the game.
Definition: psitemstats.h:463
bool UpdateCharacterSkill(PID pid, unsigned int skill_id, unsigned int skill_z, unsigned int skill_y, unsigned int skill_rank)
Update the skill in the database.
Holds a list of characters associated to one account.
Contains information about sectors from the server perspective.
Definition: pssectorinfo.h:46
A slightly improved version of csStringArray, sporting the handy FormatPush method.
Definition: stringarray.h:33
All scheduled events must inherit from this class.
Definition: gameevent.h:36
bool NewCharacterData(AccountID accountid, psCharacter *chardata)
Creates a new character entry to store the provided character data.
This class generically allows objects to be notified when a gemObject is removed. ...
bool NewNPCCharacterData(AccountID accountid, psCharacter *chardata)
This class embodies item instances in the game.
Definition: psitem.h:238