My Project
Public Member Functions | List of all members
ParaEngine::CNpcDatabase Class Reference

NPC data provider. More...

#include <NpcDatabase.h>

Public Member Functions

bool IsValid ()
 whether db is opened. More...
 
void Cleanup ()
 delete the database and set everything to NULL
 
DBEntityGetDBEntity ()
 get the database object associated with this provider
 
void SetDBEntity (const string &sConnectionstring)
 replace the current database with current one. More...
 
void ResetDatabase ()
 reset the database to blank
 
void ValidateDatabase ()
 ensure that the database has been set up properly. More...
 
bool SelectNPCByID (int nNPCID, CNpcDbItem &pOut)
 
bool SelectNPCByName (const string &sName, CNpcDbItem &pOut)
 
bool SelectNPCListByRegion (NPCDBItemList *pOut, const Vector3 &vMin, const Vector3 &vMax)
 return all NPC whose position is within a AABB region More...
 
bool InsertNPC (CNpcDbItem &npc)
 
int GetNPCIDByName (const string &name)
 get NPC ID by name More...
 
int GetNPCCount ()
 the total number of NPC in the database. More...
 
bool DeleteNPCByID (int nNPCID)
 delete the NPC from database More...
 
bool DeleteNPCByName (const string &sName)
 delete the NPC from database More...
 
bool UpdateNPC (const CNpcDbItem &npc, DWORD dwFields)
 Selectively update the data fields of NPC. More...
 

Detailed Description

NPC data provider.

Member Function Documentation

§ DeleteNPCByID()

bool CNpcDatabase::DeleteNPCByID ( int  nNPCID)

delete the NPC from database

Parameters
nNPCIDNPC ID
Returns
true if succeed

§ DeleteNPCByName()

bool CNpcDatabase::DeleteNPCByName ( const string &  sName)

delete the NPC from database

Parameters
sName
Returns
true if succeed

§ GetNPCCount()

int CNpcDatabase::GetNPCCount ( )

the total number of NPC in the database.

There is no statement cached for this call.

Returns

§ GetNPCIDByName()

int CNpcDatabase::GetNPCIDByName ( const string &  name)

get NPC ID by name

Parameters
namename of character
Returns
id is returned if found in database; otherwise non-positive value(-1) is returned.

§ InsertNPC()

bool CNpcDatabase::InsertNPC ( CNpcDbItem npc)
Parameters
npcinsert the new character to the database, the ID of npc will be ignored and filled with actual ID if inserted successfully
Returns
true if succeed

§ IsValid()

bool ParaEngine::CNpcDatabase::IsValid ( )
inline

whether db is opened.

§ SelectNPCByID()

bool CNpcDatabase::SelectNPCByID ( int  nNPCID,
CNpcDbItem pOut 
)
Parameters
nNPCIDcharacter ID in the database
pOut: the structure will be filled with data in the database
Returns
true if succeed

§ SelectNPCByName()

bool CNpcDatabase::SelectNPCByName ( const string &  sName,
CNpcDbItem pOut 
)
Parameters
sNamecharacter name
pOut: the structure will be filled with data in the database
Returns
true if succeed

§ SelectNPCListByRegion()

bool CNpcDatabase::SelectNPCListByRegion ( NPCDBItemList *  pOut,
const Vector3 vMin,
const Vector3 vMax 
)

return all NPC whose position is within a AABB region

Parameters
pOut: the list will be filled with data in the database that meat the criterion.
vMinmin point in world coordinate system, y component is ignored
vMaxmax point in world coordinate system, y component is ignored
Returns
true if succeed

§ SetDBEntity()

void CNpcDatabase::SetDBEntity ( const string &  sConnectionstring)

replace the current database with current one.

the old one is closed and the new once will be opened.

Parameters
sConnectionstringthe file path

§ UpdateNPC()

bool CNpcDatabase::UpdateNPC ( const CNpcDbItem npc,
DWORD  dwFields 
)

Selectively update the data fields of NPC.

Parameters
npceither the ID or name of the npc must be valid.
dwFields: a bitwise of database fields specifying which data is to be updated. If it is ALL_ATTRIBUTES(0xffffffff), all data will be updated. please refer to CNpcDbItem::UPDATE_FIELDS for the meaning of the data fields which can be selectively updated.
Returns
true if succeed

§ ValidateDatabase()

void CNpcDatabase::ValidateDatabase ( )

ensure that the database has been set up properly.

If not, ResetDatabase() is called to reset the database to blank


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