EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ReprocessingDB.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: Zhur
24 */
25 
26 #include "eve-server.h"
27 
28 #include "station/ReprocessingDB.h"
29 
30 bool ReprocessingDB::GetRecoverables(const uint32 typeID, std::vector<Recoverable> &into) {
31  DBQueryResult res;
32  DBResultRow row;
33 
34  if (!sDatabase.RunQuery(res,
35  "SELECT requiredTypeID, MIN(quantity) FROM ramTypeRequirements"
36  " LEFT JOIN invBlueprintTypes ON typeID = blueprintTypeID"
37  " WHERE damagePerJob = 1 AND ("
38  " (activityID = 6 AND typeID = %u)"
39  " OR"
40  " (activityID = 1 AND productTypeID = %u))"
41  " GROUP BY requiredTypeID",
42  typeID, typeID, typeID))
43  {
44  _log(DATABASE__ERROR, "Unable to get recoverables for type ID %u: '%s'", typeID, res.error.c_str());
45  return false;
46  }
47 
48 
49  while (res.GetRow(row)) {
50  Recoverable rec = Recoverable();
51  rec.typeID = row.GetInt(0);
52  rec.amountPerBatch = row.GetInt(1);
53  into.push_back(rec);
54  }
55 
56  //eve-dev says tech 2 items contain both basic materials and advanced materials
57  //if(gotFromRamTable) return true;
58 
59  if (!sDatabase.RunQuery(res,
60  "SELECT materialTypeID, quantity"
61  " FROM invTypeMaterials"
62  " WHERE typeID=%u",
63  typeID))
64  {
65  _log(DATABASE__ERROR, "Unable to get recoverables for ore ID %u: '%s'", typeID, res.error.c_str());
66  return false;
67  }
68 
69  while (res.GetRow(row)) {
70  Recoverable rec = Recoverable();
71  rec.typeID = row.GetInt(0);
72  rec.amountPerBatch = row.GetInt(1);
73  into.push_back(rec);
74  }
75 
76  return true;
77 }
#define sDatabase
Definition: dbcore.h:199
#define _log(type, fmt,...)
Definition: logsys.h:124
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
const char * c_str() const
Definition: dbcore.h:48
unsigned __int32 uint32
Definition: eve-compat.h:50
bool GetRecoverables(const uint32 typeID, std::vector< Recoverable > &into)
DBerror error
Definition: dbcore.h:69