EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
APIAccountDB.cpp
Go to the documentation of this file.
1 /*
2  ------------------------------------------------------------------------------------
3  LICENSE:
4  ------------------------------------------------------------------------------------
5  This file is part of EVEmu: EVE Online Server Emulator
6  Copyright 2006 - 2021 The EVEmu Team
7  For the latest information visit https://evemu.dev
8  ------------------------------------------------------------------------------------
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License along with
19  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20  Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21  http://www.gnu.org/copyleft/lesser.txt.
22  ------------------------------------------------------------------------------------
23  Author: Aknor Jaden
24 */
25 
26 #include "eve-server.h"
27 
28 #include "apiserver/APIAccountDB.h"
29 
31 {
32 }
33 
34 bool APIAccountDB::GetCharactersList(uint32 accountID, std::vector<std::string> & charIDList, std::vector<std::string> & charNameList,
35  std::vector<std::string> & charCorpIDList, std::vector<std::string> & charCorpNameList)
36 {
37  DBQueryResult res;
38 
39  // Get list of characters and their corporation info from the accountID:
40  if( !sDatabase.RunQuery(res,
41  " SELECT "
42  " character_.characterID, "
43  " character_.corporationID, "
44  " corporation.corporationName, "
45  " entity.itemName AS name "
46  " FROM `character_` "
47  " LEFT JOIN corporation ON corporation.corporationID = character_.corporationID "
48  " LEFT JOIN entity ON entity.itemID = character_.characterID "
49  " WHERE `accountID` = %u ", accountID ))
50  {
51  sLog.Error( "APIAccountDB::GetCharactersList()", "Cannot find accountID %u", accountID );
52  return false;
53  }
54 
55  DBResultRow row;
56  std::map<std::string, std::string> charInfo;
57  while( res.GetRow( row ) )
58  {
59  charIDList.push_back( std::string(row.GetText(0)) );
60  charCorpIDList.push_back( std::string(row.GetText(1)) );
61  charCorpNameList.push_back( std::string(row.GetText(2)) );
62  charNameList.push_back( std::string(row.GetText(3)) );
63  }
64 
65  return true;
66 }
67 
68 
69 bool APIAccountDB::GetAccountInfo(uint32 accountID, std::vector<std::string> & accountInfoList)
70 {
71  DBQueryResult res;
72 
73  // Get account table info using the accountID:
74  if( !sDatabase.RunQuery(res,
75  " SELECT "
76  " online, "
77  " banned, "
78  " logonCount, "
79  " lastLogin "
80  " FROM account "
81  " WHERE `accountID` = %u ", accountID ))
82  {
83  sLog.Error( "APIAccountDB::GetAccountInfo()", "Cannot find accountID %u", accountID );
84  return false;
85  }
86 
87  DBResultRow row;
88  if( !res.GetRow(row) )
89  {
90  sLog.Error( "APIServiceDB::GetAccountInfo()", "res.GetRow(row) failed for unknown reason." );
91  return false;
92  }
93 
94  accountInfoList.push_back( std::string(row.GetText(0)) );
95  accountInfoList.push_back( std::string(row.GetText(1)) );
96  accountInfoList.push_back( std::string(row.GetText(2)) );
97  accountInfoList.push_back( std::string(row.GetText(3)) );
98 
99  return true;
100 }
#define sDatabase
Definition: dbcore.h:199
const char * GetText(uint32 index) const
Definition: dbcore.h:104
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
bool GetAccountInfo(uint32 accountID, std::vector< std::string > &accountInfoList)
?
bool GetCharactersList(uint32 accountID, std::vector< std::string > &charIDList, std::vector< std::string > &charNameList, std::vector< std::string > &charCorpIDList, std::vector< std::string > &charCorpNameList)
?
unsigned __int32 uint32
Definition: eve-compat.h:50