Planeshift
creationmanager.h
Go to the documentation of this file.
1 /*
2  * creationmanager.h - author: Andrew Craig
3  *
4  * Copyright (C) 2003 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 PS_CHAR_CREATION_MANAGER_H
20 #define PS_CHAR_CREATION_MANAGER_H
21 //=============================================================================
22 // Crystal Space Includes
23 //=============================================================================
24 
25 //=============================================================================
26 // Project Space Includes
27 //=============================================================================
28 #include "net/charmessages.h"
29 
30 
31 //=============================================================================
32 // Local Space Includes
33 //=============================================================================
34 #include "msgmanager.h"
35 
36 #define MAX_PLAYER_NAME_LENGTH 27
37 
39 
47 class CharCreationManager : public MessageManager<CharCreationManager>
48 {
49 public:
50  CharCreationManager(GEMSupervisor* gemsupervisor, CacheManager* cachemanager, EntityManager* entitymanager);
51  virtual ~CharCreationManager();
52 
55  bool Initialize();
56 
57  bool Validate(psCharUploadMessage &mesg, csString &errorMsg);
58 
64  static bool IsUnique(const char* playerName, bool dbUniqueness = false);
65 
72  static bool IsLastNameAvailable(const char* lastname, AccountID requestingAcct = 0);
73 
74  // Returns true if the name is ok
75  static bool FilterName(const char* name);
76 
77 protected:
78 
80  bool LoadCPValues();
81 
83  bool LoadCreationChoices();
84 
85  bool LoadLifeEvents();
86 
87  int raceCPValuesLength; // length of the raceCPValues array
88 
96  int ConvertAreaToInt(const char* area);
97 
102  void HandleParents(MsgEntry* me,Client* client);
103 
104  void HandleChildhood(MsgEntry* me,Client* client);
105 
106  void HandleLifeEvents(MsgEntry* me,Client* client);
107 
108  void HandleTraits(MsgEntry* me,Client* client);
109 
110  void HandleUploadMessage(MsgEntry* me, Client* client);
111 
114  void HandleCharCreateCP(MsgEntry* me, Client* client);
115 
122  void HandleName(MsgEntry* me ,Client* client);
123 
126  void HandleCharDelete(MsgEntry* me, Client* client);
127 
128  int CalculateCPChoices(csArray<uint32_t> &choices, int fatherMod, int motherMod);
129  int CalculateCPLife(csArray<uint32_t> &events);
130 
136  void AssignScript(psCharacter* chardata);
137 
148  int IsReserved(const char* playerName, AccountID acctID);
149  bool PlayerHasFinishedTutorial(AccountID acctID, uint32 tutorialsecid);
150 
151 private:
152  // Structure to hold the initial CP race values.
153  struct RaceCP
154  {
155  int id;
156  int value;
157  };
158 
160  // Structure for cached character creation choices
162  struct CreationChoice
163  {
164  int id;
165  csString name;
166  csString description;
167  int choiceArea;
168  int cpCost;
169  csString eventScript;
170  };
172 
173 
175  // Structure for cached character creation life event
177  class LifeEventChoiceServer : public LifeEventChoice
178  {
179  public:
180  csString eventScript;
181  };
183 
184  LifeEventChoiceServer* FindLifeEvent(int id);
185  CreationChoice* FindChoice(int id);
186 
187 
188  RaceCP* raceCPValues;
189 
191  csPDelArray<CreationChoice> parentData;
192  csPDelArray<CreationChoice> childhoodData;
193  csPDelArray<LifeEventChoiceServer> lifeEvents;
194 
195  GEMSupervisor* gemSupervisor;
196  CacheManager* cacheManager;
197  EntityManager* entityManager;
198 };
199 
200 
201 
202 #endif
void HandleName(MsgEntry *me, Client *client)
Handles a check on a name.
Defines the structure needed to send a life event across the network.
Definition: charmessages.h:296
Manages CEL entities on the server.
Definition: entitymanager.h:77
ReservedNames
bool LoadCreationChoices()
Caches in creation choices from the database.
virtual ~CharCreationManager()
bool Validate(psCharUploadMessage &mesg, csString &errorMsg)
bool LoadCPValues()
Cache in the data about the race CP starting values.
The structure of 1 queue entry (pointer to a message)
Definition: message.h:143
void HandleLifeEvents(MsgEntry *me, Client *client)
int IsReserved(const char *playerName, AccountID acctID)
Check to see if a name is on the reserve list for database migration.
void AssignScript(psCharacter *chardata)
Assign a script to a character.
void HandleCharDelete(MsgEntry *me, Client *client)
Handles the deletion of a character from the char pick screen.
bool PlayerHasFinishedTutorial(AccountID acctID, uint32 tutorialsecid)
static bool FilterName(const char *name)
This class collects data of a netclient.
Definition: client.h:95
void HandleParents(MsgEntry *me, Client *client)
Handle and incomming message from a client about parents.
bool Initialize()
Caches the data from the database needed for character creation.
static bool IsLastNameAvailable(const char *lastname, AccountID requestingAcct=0)
Check whether a given last name is available.
int CalculateCPChoices(csArray< uint32_t > &choices, int fatherMod, int motherMod)
Server manager for character creation.
This class manages the caching of data that is unchanging during server operation.
Definition: cachemanager.h:234
This class holds the refs to the core factories, etc in CEL.
Definition: gem.h:126
CharCreationManager(GEMSupervisor *gemsupervisor, CacheManager *cachemanager, EntityManager *entitymanager)
void HandleCharCreateCP(MsgEntry *me, Client *client)
Handles the creation of a character from the char creation screen.
void HandleTraits(MsgEntry *me, Client *client)
static bool IsUnique(const char *playerName, bool dbUniqueness=false)
Check to see a name is unique in the characters table.
void HandleUploadMessage(MsgEntry *me, Client *client)
int ConvertAreaToInt(const char *area)
Takes a string name of a choice and converts it to it&#39;s enum value.
void HandleChildhood(MsgEntry *me, Client *client)
int CalculateCPLife(csArray< uint32_t > &events)
Provides a manager to facilitate subscriptions.
Definition: msgmanager.h:106