Planeshift

creationmanager.h

Go to the documentation of this file.
00001 /*
00002  * creationmanager.h - author: Andrew Craig
00003  *
00004  * Copyright (C) 2003 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 PS_CHAR_CREATION_MANAGER_H
00020 #define PS_CHAR_CREATION_MANAGER_H
00021 //=============================================================================
00022 // Crystal Space Includes
00023 //=============================================================================
00024 
00025 //=============================================================================
00026 // Project Space Includes
00027 //=============================================================================
00028 #include "net/charmessages.h"
00029 
00030 
00031 //=============================================================================
00032 // Local Space Includes
00033 //=============================================================================
00034 #include "msgmanager.h"
00035 
00036 #define MAX_PLAYER_NAME_LENGTH 27
00037 
00038 enum ReservedNames {NAME_RESERVED_FOR_YOU, NAME_RESERVED, NAME_AVAILABLE};
00039 
00047 class CharCreationManager : public MessageManager<CharCreationManager>
00048 {
00049 public:
00050     CharCreationManager(GEMSupervisor* gemsupervisor, CacheManager* cachemanager, EntityManager* entitymanager);
00051     virtual ~CharCreationManager();
00052 
00055     bool Initialize();
00056 
00057     bool Validate(psCharUploadMessage &mesg, csString &errorMsg);
00058 
00064     static bool IsUnique(const char* playerName,  bool dbUniqueness = false);
00065 
00072     static bool IsLastNameAvailable(const char* lastname, AccountID requestingAcct = 0);
00073 
00074     // Returns true if the name is ok
00075     static bool FilterName(const char* name);
00076 
00077 protected:
00078 
00080     bool LoadCPValues();
00081 
00083     bool LoadCreationChoices();
00084 
00085     bool LoadLifeEvents();
00086 
00087     int raceCPValuesLength;    // length of the raceCPValues array
00088 
00096     int ConvertAreaToInt(const char* area);
00097 
00102     void HandleParents(MsgEntry* me,Client* client);
00103 
00104     void HandleChildhood(MsgEntry* me,Client* client);
00105 
00106     void HandleLifeEvents(MsgEntry* me,Client* client);
00107 
00108     void HandleTraits(MsgEntry* me,Client* client);
00109 
00110     void HandleUploadMessage(MsgEntry* me, Client* client);
00111 
00114     void HandleCharCreateCP(MsgEntry* me, Client* client);
00115 
00122     void HandleName(MsgEntry* me ,Client* client);
00123 
00126     void HandleCharDelete(MsgEntry* me, Client* client);
00127 
00128     int CalculateCPChoices(csArray<uint32_t> &choices, int fatherMod, int motherMod);
00129     int CalculateCPLife(csArray<uint32_t> &events);
00130 
00136     void AssignScript(psCharacter* chardata);
00137 
00148     int IsReserved(const char* playerName, AccountID acctID);
00149     bool PlayerHasFinishedTutorial(AccountID acctID, uint32 tutorialsecid);
00150 
00151 private:
00152     // Structure to hold the initial CP race values.
00153     struct RaceCP
00154     {
00155         int id;
00156         int value;
00157     };
00158 
00160     // Structure for cached character creation choices
00162     struct CreationChoice
00163     {
00164         int id;
00165         csString name;
00166         csString description;
00167         int choiceArea;
00168         int cpCost;
00169         csString eventScript;
00170     };
00172 
00173 
00175     // Structure for cached character creation life event
00177     class LifeEventChoiceServer : public LifeEventChoice
00178     {
00179     public:
00180         csString eventScript;
00181     };
00183 
00184     LifeEventChoiceServer* FindLifeEvent(int id);
00185     CreationChoice* FindChoice(int id);
00186 
00187 
00188     RaceCP* raceCPValues;
00189 
00191     csPDelArray<CreationChoice> parentData;
00192     csPDelArray<CreationChoice>  childhoodData;
00193     csPDelArray<LifeEventChoiceServer> lifeEvents;
00194 
00195     GEMSupervisor* gemSupervisor;
00196     CacheManager* cacheManager;
00197     EntityManager* entityManager;
00198 };
00199 
00200 
00201 
00202 #endif