Planeshift

pscharacterloader.h

Go to the documentation of this file.
00001 /*
00002  * pscharacterloader.h
00003  *
00004  * Copyright (C) 2001 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 
00020 
00021 
00022 
00023 #ifndef __PSCHARACTERLOADER_H__
00024 #define __PSCHARACTERLOADER_H__
00025 
00026 //=============================================================================
00027 // Crystal Space Includes
00028 //=============================================================================
00029 
00030 //=============================================================================
00031 // Project Includes
00032 //=============================================================================
00033 #include "util/gameevent.h"
00034 
00035 #include <idal.h>      // Database Abstraction Layer Interface
00036 
00037 #include "../gem.h"
00038 
00039 //=============================================================================
00040 // Local Includes
00041 //=============================================================================
00042 
00043 
00044 class csMutex;
00045 class psCharacterList;
00046 class psSectorInfo;
00047 class psCharacter;
00048 class psItem;
00049 class psItemStats;
00050 class gemActor;
00051 
00056 /*  Why isn't there a LoadItem() call here?
00057  *
00058  *  At the time of initial design the circumstances under which an item entry will be loaded are unclear.
00059  *  It is virtually guaranteed that item entries will need to be loaded when a character is loaded as the character's
00060  *    inventory (list of items) will be necessary.
00061  *  It is undecided wether some, all or no items in the world and not on a character will be saved to the database.
00062  *    If they are saved it is likely that many items will be loaded all at once - possibly based on location data
00063  *    (x,y,z,sector), possibly based on some other criteria.
00064  */
00065 
00084 class psCharacterLoader
00085 {
00086 public:
00090     psCharacterLoader();
00091 
00095     ~psCharacterLoader();
00096 
00102     bool Initialize();
00103 
00107     psCharacterList* LoadCharacterList(AccountID accountid);
00108 
00109 
00110     psCharacter** LoadAllNPCCharacterData(psSectorInfo* sector,int &count);
00111 
00122     psCharacter* LoadCharacterData(PID pid, bool forceReload);
00123 
00127     psCharacter* QuickLoadCharacterData(PID pid, bool noInventory);
00128 
00142     bool NewCharacterData(AccountID accountid, psCharacter* chardata);
00143     bool NewNPCCharacterData(AccountID accountid,psCharacter* chardata);
00144     unsigned int InsertNewCharacterData(const char** fieldnames, psStringArray &fieldvalues);
00145 
00160     bool SaveCharacterData(psCharacter* chardata,gemActor* actor,bool charRecordOnly=false);
00161 
00171     bool DeleteCharacterData(PID pid, csString &error);
00172 
00173 
00183     PID FindCharacterID(const char* character_name, bool excludeNPCs=true);
00184 
00195     PID FindCharacterID(AccountID accountID, const char* character_name);
00196 
00204     bool AccountOwner(const char* characterName, AccountID accountID);
00205 
00209     bool UpdateCharacterSkill(PID pid, unsigned int skill_id,
00210                               unsigned int skill_z, unsigned int skill_y, unsigned int skill_rank);
00211 
00212 
00213 private:
00214 
00215     bool ClearCharacterAdvantages(PID pid);
00216     bool SaveCharacterAdvantage(PID pid, unsigned int advantage_id);
00217     bool ClearCharacterSkills(PID pid);
00218     bool ClearCharacterTraits(PID pid);
00219     bool SaveCharacterSkill(PID pid,unsigned int skill_id,
00220                             unsigned int skill_z, unsigned int skill_y, unsigned int skill_rank);
00221     bool SaveCharacterTrait(PID pid, unsigned int trait_id);
00222     bool UpdateQuestAssignments(psCharacter* chr);
00223     bool ClearCharacterSpell(psCharacter* character);
00224     bool SaveCharacterSpell(psCharacter* character);
00225 
00226 };
00227 
00228 //-----------------------------------------------------------------------------
00229 
00230 
00239 class psSaveCharEvent : public psGameEvent, public iDeleteObjectCallback
00240 {
00241 public:
00242     enum Type
00243     {
00244         SAVE_PERIOD = 600000
00245     };
00246 
00247     gemActor* actor;     
00248 
00254     psSaveCharEvent(gemActor* actor);
00255 
00259     ~psSaveCharEvent();
00260 
00264     virtual void Trigger();  // Abstract event processing function
00265 
00272     virtual void DeleteObjectCallback(iDeleteNotificationObject* object);
00273 };
00274 
00277 #endif
00278