00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00024 #ifndef __DATABASE_H
00025 #define __DATABASE_H
00026
00027 #include <sql.h>
00028 #include <sqlext.h>
00029 #include <sstream>
00030 #include <vector>
00031
00032 #include "Account.h"
00033 #include "Shared.h"
00034
00035 class cAvatar;
00036
00037 class cDatabase
00038 {
00039
00040 public:
00041
00042 static HENV m_hEnv;
00043 static HDBC m_hDBC;
00044 static HSTMT m_hStmt;
00045 static int wMaxModel;
00046 static char szModelName[1000][5];
00047 static char szModelNumber[1000][3];
00048 static char szDBIP[16];
00049 static char szDBNAME[20];
00050 static char szDBUSER[20];
00051 static char szDBPASSWORD[20];
00052 static int intDBType;
00053
00058 static void Load ( );
00059 static void Unload ( );
00060 static void GetError ( SQLSMALLINT type, SQLHANDLE *hptr );
00061 static int InitializeSQLEnvironment( );
00062 static int FreeSQLEnvironment ( );
00063 static void cDatabase::InitializeMaxModel( );
00064 static void cDatabase::LoadModelList( );
00065 static void InitializeAvatarGUIDs ( DWORD &dwGUIDCycle_Avatar );
00066 static void InitializeObjectGUIDs ( DWORD &dwGUIDCycle_Object );
00067 static void InitializeAllegIDs ( DWORD &dwIDAllegiance );
00068 static BOOL VerifyAccount ( char* szUserName, char* szPassword, DWORD &dwAccountID, BOOL fCreate );
00069 static BOOL CreateAccount ( char* szUserName, char* szPassword, DWORD &dwAccountID );
00070 static void LoadAvatarList ( DWORD dwAccountID, std::vector< cAvatarList > &AvatarList );
00071 static BOOL CreateAvatar ( DWORD dwAccountID, CreateCharacterMessage &ccm, DWORD &dwNewAvatarGUID );
00072 static void DeleteAvatar ( DWORD dwAvatarGUID );
00073 static void LoadAvatar ( cAvatar* pcAvatar );
00074 static BOOL LoadDungeonList ( char strName, std::vector< cDungeonList > &DungeonList );
00075 static void SetupDB ( int DBType, char* szDBIP, char* szDBNAME, char* szDBUSER, char* szDBPASSWORD );
00077
00078
00079 static void AddToInventoryDB ( DWORD dwAvatarGUID, cObject* pcObj );
00080 static void RemoveFromInventoryDB ( DWORD dwAvatarGUID, DWORD dwObjectGUID );
00081
00082
00083 static void AddSpell ( DWORD dwAvatarGUID, int SpellCount, int SpellID );
00084 static void AddSpellToTab (DWORD dwAvatarGUID, int SpellID, int SpellCount, int TabID);
00085
00086
00087 static void AddGeneralItems (DWORD dwAvatarGUID);
00088 static void AddRaceItemsAluvian (DWORD dwAvatarGUID);
00089 static void AddRaceItemsGharundim (DWORD dwAvatarGUID);
00090 static void AddRaceItemsSho (DWORD dwAvatarGUID);
00091
00092 static void AddCasterItems (DWORD dwAvatarGUID);
00093 static void AddFoci (DWORD dwAvatarGUID, CreateCharacterMessage &ccm);
00094 static void AddProfessionItems (DWORD dwAvatarGUID, CreateCharacterMessage &ccm);
00095
00096 static void SaveCharacterFlags (DWORD dwAvatarGUID, DWORD Flags);
00097
00098
00099 static float Hex2Float (DWORD hexValue);
00100 static DWORD Float2Hex (float floatValue);
00101
00102 static inline char *ReturnClass( DWORD dwClass )
00103 {
00104 switch ( dwClass )
00105 {
00106 case CHARDATA_CLASS_CUSTOM: return "Custom";
00107 case CHARDATA_CLASS_BOW_HUNTER: return "Bow Hunter";
00108 case CHARDATA_CLASS_SWASHBUCKLER: return "Swashbuckler";
00109 case CHARDATA_CLASS_LIFE_CASTER: return "Life Caster";
00110 case CHARDATA_CLASS_WAR_MAGE: return "War Mage";
00111 case CHARDATA_CLASS_WAYFARER: return "Wayfarer";
00112 case CHARDATA_CLASS_SOLDIER: return "Soldier";
00113 default: return NULL;
00114 }
00115 }
00116
00117 static inline char *ReturnGender( DWORD dwGender )
00118 {
00119 switch ( dwGender )
00120 {
00121 case CHARDATA_SEX_FEMALE: return "Female";
00122 case CHARDATA_SEX_MALE: return "Male";
00123 default: return NULL;
00124 }
00125 }
00126
00127 static inline char *ReturnRace( DWORD dwRace )
00128 {
00129 switch ( dwRace )
00130 {
00131 case CHARDATA_RACE_ALUVIAN: return "Aluvian";
00132 case CHARDATA_RACE_GHARU: return "Gharu'ndim";
00133 case CHARDATA_RACE_SHO: return "Sho";
00134 default: return NULL;
00135 }
00136 }
00137
00138 static inline char *ReturnNamePrefix( BYTE bLevel )
00139 {
00140 switch ( bLevel )
00141 {
00142 case eDeveloper: return "+Developer ";
00143 case eAdmin: return "+Envoy ";
00144 case eUeber: return "+Uber ";
00145 case eSentinel: return "+Sentinel ";
00146 case eAdvocate: return "+Advocate ";
00147 case eStaff: return "+";
00148 case eVIP: return "*";
00149 case eNormal: return "";
00150 default: return NULL;
00151 }
00152 }
00153 private:
00154
00155 };
00156
00157 #endif // #ifndef __DATABSE_H