EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
AgentDB.cpp
Go to the documentation of this file.
1 
14 #include "eve-server.h"
15 
16 #include "agents/AgentDB.h"
17 #include "StaticDataMgr.h"
18 
19 
21 {
22  DBQueryResult res;
23  if(!sDatabase.RunQuery(res,
24  "SELECT"
25  " agt.agentTypeID,"
26  " agt.divisionID,"
27  " agt.level,"
28  " agt.quality,"
29  " agt.corporationID,"
30  " agt.locationID, " //5
31  " agt.isLocator,"
32  " chr.solarSystemID,"
33  " chr.stationID,"
34  " chr.gender,"
35  " bl.bloodlineID," //10
36  " itm.typeID, "
37  " crp.friendID, "
38  " crp.enemyID, "
39  " crp.factionID, "
40  " chr.characterName " //15
41  " FROM agtAgents AS agt"
42  " LEFT JOIN chrNPCCharacters AS chr ON chr.characterID = agt.agentID"
43  " LEFT JOIN crpNPCCorporations AS crp ON crp.corporationID = agt.corporationID"
44  " LEFT JOIN bloodlineTypes AS bl ON bl.typeID = chr.typeID"
45  " LEFT JOIN mapDenormalize AS itm ON itm.itemID = agt.locationID"
46  " WHERE agt.agentID = %u", agentID))
47  {
48  codelog(DATABASE__ERROR, "Error in GetAgents query: %s", res.error.c_str());
49  return;
50  }
51 
53  DBResultRow row;
54  if (res.GetRow(row)) {
55  if (row.GetUInt(10) == 0) {
56  _log(DATABASE__MESSAGE, "No charTypeID for Agent %u", agentID);
57  return;
58  }
59  data.typeID = row.GetUInt(0);
60  data.divisionID = row.GetUInt(1);
61  data.level = row.GetUInt(2);
62  data.quality = row.GetInt(3);
63  data.corporationID = row.GetUInt(4);
64  data.locationID = row.GetUInt(5);
65  data.locator = row.GetBool(6);
66  data.solarSystemID = row.GetUInt(7);
67  data.stationID = row.GetUInt(8);
68  data.gender = row.GetBool(9);
69  data.bloodlineID = row.GetUInt(10);
70  data.locationTypeID = row.GetUInt(11);
71  data.friendCorp = (row.IsNull(12) ? 0 : row.GetInt(12));
72  data.enemyCorp = (row.IsNull(13) ? 0 : row.GetInt(13));
73  data.factionID = row.GetInt(14);
74  data.raceID = sDataMgr.GetFactionRace(data.factionID);
75  data.name = row.GetText(15);
76  data.research = (data.typeID == Agents::Type::Research);
77  }
78 }
79 
80 void AgentDB::LoadAgentSkills(uint32 agentID, std::map< uint16, uint8 >& data)
81 {
82  // SELECT typeID, level FROM agtSkillLevel WHERE agentID = %u
83  DBQueryResult res;
84  if (!sDatabase.RunQuery(res, "SELECT typeID, level FROM agtSkillLevel WHERE agentID = %u", agentID))
85  codelog(DATABASE__ERROR, "Error in LoadAgentSkills query: %s", res.error.c_str());
86 
87  DBResultRow row;
88  while (res.GetRow(row))
89  data[row.GetInt(0)] = row.GetInt(1);
90 }
uint16 locationTypeID
Definition: EVE_Agent.h:21
uint32 friendCorp
Definition: EVE_Agent.h:26
#define sDatabase
Definition: dbcore.h:199
const char * GetText(uint32 index) const
Definition: dbcore.h:104
#define _log(type, fmt,...)
Definition: logsys.h:124
uint32 locationID
Definition: EVE_Agent.h:25
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
std::string name
Definition: EVE_Agent.h:29
uint32 GetUInt(uint32 index) const
Definition: dbcore.cpp:658
bool gender
Definition: EVE_Agent.h:12
uint32 stationID
Definition: EVE_Agent.h:24
int8 quality
Definition: EVE_Agent.h:15
static void LoadAgentSkills(uint32 agentID, std::map< uint16, uint8 > &data)
Definition: AgentDB.cpp:80
uint8 level
Definition: EVE_Agent.h:16
uint16 typeID
Definition: EVE_Agent.h:20
bool locator
Definition: EVE_Agent.h:13
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
bool GetBool(uint32 index) const
Definition: dbcore.cpp:647
const char * c_str() const
Definition: dbcore.h:48
bool research
Definition: EVE_Agent.h:14
#define codelog(type, fmt,...)
Definition: logsys.h:128
uint8 divisionID
Definition: EVE_Agent.h:18
uint32 factionID
Definition: EVE_Agent.h:28
bool IsNull(uint32 index) const
Definition: dbcore.h:102
uint32 corporationID
Definition: EVE_Agent.h:22
unsigned __int32 uint32
Definition: eve-compat.h:50
static void LoadAgentData(uint32 agentID, AgentData &data)
Definition: AgentDB.cpp:20
DBerror error
Definition: dbcore.h:69
uint8 raceID
Definition: EVE_Agent.h:17
uint32 solarSystemID
Definition: EVE_Agent.h:23
uint32 enemyCorp
Definition: EVE_Agent.h:27
uint8 bloodlineID
Definition: EVE_Agent.h:19
#define sDataMgr