# cDatabase Class Reference

List of all members.

## Static Public Member Functions

static void | AddToInventoryDB (DWORD dwAvatarGUID, cObject *pcObj)
static void | RemoveFromInventoryDB (DWORD dwAvatarGUID, DWORD dwObjectGUID)
static void | AddSpell (DWORD dwAvatarGUID, int SpellCount, int SpellID)
static void | AddSpellToTab (DWORD dwAvatarGUID, int SpellID, int SpellCount, int TabID)
static void | AddGeneralItems (DWORD dwAvatarGUID)
static void | AddRaceItemsAluvian (DWORD dwAvatarGUID)
static void | AddRaceItemsGharundim (DWORD dwAvatarGUID)
static void | AddRaceItemsSho (DWORD dwAvatarGUID)
static void | AddCasterItems (DWORD dwAvatarGUID)
static void | AddFoci (DWORD dwAvatarGUID, CreateCharacterMessage &ccm)
static void | AddProfessionItems (DWORD dwAvatarGUID, CreateCharacterMessage &ccm)
static void | SaveCharacterFlags (DWORD dwAvatarGUID, DWORD Flags)
static float | Hex2Float (DWORD hexValue)
static DWORD | Float2Hex (float floatValue)
static char * | ReturnClass (DWORD dwClass)
static char * | ReturnGender (DWORD dwGender)
static char * | ReturnRace (DWORD dwRace)
static char * | ReturnNamePrefix (BYTE bLevel)
Database Initialization and Loading
Functions to initialize or load objects using database information
static void | Load ()
static void | Unload ()
static void | GetError (SQLSMALLINT type, SQLHANDLE *hptr)
static int | InitializeSQLEnvironment ()
static int | FreeSQLEnvironment ()
static void | InitializeMaxModel ()
static void | LoadModelList ()
static void | InitializeAvatarGUIDs (DWORD &dwGUIDCycle_Avatar)
static void | InitializeObjectGUIDs (DWORD &dwGUIDCycle_Object)
static void | InitializeAllegIDs (DWORD &dwIDAllegiance)
static BOOL | VerifyAccount (char *szUserName, char *szPassword, DWORD &dwAccountID, BOOL fCreate)
static BOOL | CreateAccount (char *szUserName, char *szPassword, DWORD &dwAccountID)
static void | LoadAvatarList (DWORD dwAccountID, std::vector< cAvatarList > &AvatarList)
static BOOL | CreateAvatar (DWORD dwAccountID, CreateCharacterMessage &ccm, DWORD &dwNewAvatarGUID)
static void | DeleteAvatar (DWORD dwAvatarGUID)
static void | LoadAvatar (cAvatar *pcAvatar)
static BOOL | LoadDungeonList (char strName, std::vector< cDungeonList > &DungeonList)
static void | SetupDB (int DBType, char *szDBIP, char *szDBNAME, char *szDBUSER, char *szDBPASSWORD)

## Static Public Attributes

static HENV | m_hEnv = 0
static HDBC | m_hDBC = 0
static HSTMT | m_hStmt = 0
static int | wMaxModel = 0
static char | szModelName [1000][5]
static char | szModelNumber [1000][3]
static char | szDBIP [16]
static char | szDBNAME [20]
static char | szDBUSER [20]
static char | szDBPASSWORD [20]
static int | intDBType

## Member Function Documentation

void cDatabase::AddSpell | ( | DWORD | dwAvatarGUID,
|  | int | SpellCount,
|  | int | SpellID |
| ) |  |  | `[static]`

Adds spells to the avatars spell book.

Parameters:

  | dwAvatarGUID | = The Avatar GUID
  | SpellCount | = Total spell count for this Avatar
  | SpellID | = The ID of the spell to add

Author: k109

void cDatabase::AddSpellToTab | ( | DWORD | dwAvatarGUID,
|  | int | SpellID,
|  | int | SpellCount,
|  | int | TabID |
| ) |  |  | `[static]`

Adds spells to the avatar's spell tab.

dwAvatarGUID = The Avatar GUID SpellID = The ID of the spell to add SpellCount = Total spell count for this Avatar TabID = ID of the Spell Tab

Author: k109

void cDatabase::AddToInventoryDB | ( | DWORD | dwAvatarGUID,
|  | cObject * | pcObj |
| ) |  |  | `[static]`

Adds items to the avatar's inventory table

BOOL cDatabase::CreateAccount | ( | char * | szUserName,
|  | char * | szPassword,
|  | DWORD & | dwAccountID |
| ) |  |  | `[static]`

Creates a new account. A given account may create several characters on a given server.

BOOL cDatabase::CreateAvatar | ( | DWORD | dwAccountID,
|  | CreateCharacterMessage & | ccm,
|  | DWORD & | dwNewAvatarGUID |
| ) |  |  | `[static]`

Creates the database information for a newly created avatar.

The following tables are populated: avatar, avatar_skills, avatar_clothing_palettes, avatar_location, avatar_spells.

Determine New Avatar Clothing

void cDatabase::DeleteAvatar | ( | DWORD | dwAvatarGUID | ) | `[static]`

Deletes the database information on a particular avatar.

Entries are deleted from the following tables: avatar, avatar_skills, avatar_location, avatar_spells, avatar_vector_spellbook, avatar_vector_spelltabs, avatar_vector_equipped, avatar_clothing_palettes, items_instance_inventory, avatar_comp_quests.

DWORD cDatabase::Float2Hex | ( | float | floatValue | ) | `[static]`

Converts floating point numbers to 32-bit hexadecimal values.

Expects float input. Returns DWORD.

float cDatabase::Hex2Float | ( | DWORD | hexValue | ) | `[static]`

Converts 32-bit hexadecimal values to floating point numbers.

Expects hexadecimal input. Returns a float value.

void cDatabase::InitializeAllegIDs | ( | DWORD & | dwIDAllegiance | ) | `[static]`

Initializes the starting allegiance ID value.

void cDatabase::InitializeAvatarGUIDs | ( | DWORD & | dwGUIDCycle_Avatar | ) | `[static]`

Initializes the starting avatar GUID value.

As GUIDs must be unique and persistent, saved avatars are consulted for their GUID values. Database tables consulted: avatar.

void cDatabase::InitializeObjectGUIDs | ( | DWORD & | dwGUIDCycle_Object | ) | `[static]`

Initializes the starting item GUID value.

As GUIDs must be unique and persistent, saved items are consulted for their GUID values. Database tables consulted: items_instance_inventory and items_instance_ground.

void cDatabase::Load | ( |  | ) | `[static]`

Loads the proper database driver based upon the selected database type.

void cDatabase::LoadAvatar | ( | cAvatar * | pcAvatar | ) | `[static]`

Loads the database information on a particular avatar during login.

Database tables consulted: avatar, avatar_skills, avatar_location, houses_covenants, avatar_vector_spellbook, avatar_vector_spelltab, items_instance_inventory.

void cDatabase::LoadAvatarList | ( | DWORD | dwAccountID,
|  | std::vector< cAvatarList > & | AvatarList |
| ) |  |  | `[static]`

Loads the list of avatars for a given account. Used to send the client a list of its current characters.

BOOL cDatabase::LoadDungeonList | ( | char | strName,
|  | std::vector< cDungeonList > & | DungeonList |
| ) |  |  | `[static]`

Populates a list with the information on the name and location of dungeons.

void cDatabase::RemoveFromInventoryDB | ( | DWORD | dwAvatarGUID,
|  | DWORD | dwObjectGUID |
| ) |  |  | `[static]`

Removes items from the avatar's inventory table

BOOL cDatabase::VerifyAccount | ( | char * | szUserName,
|  | char * | szPassword,
|  | DWORD & | dwAccountID,
|  | BOOL | fCreate |
| ) |  |  | `[static]`

Verifies the acount login information.

The documentation for this class was generated from the following files:

- E:/uas2/Server/DataBase.h
- E:/uas2/Server/Database.cpp