EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SovereigntyDB.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: James
24 */
25 
27 
28  //TODO: For now, we return 0 as stationCount since such system is not implemented
29  //TODO: Handle militaryPoints and industrialPoints, but for now they are 5 by default since we don't have a mechanism for determining them
30 
32 {
33  if (!sDatabase.RunQuery(res,
34  "SELECT mapSystemSovInfo.solarSystemID, mapSolarSystems.constellationID, mapSolarSystems.regionID, corporationID, "
35  " allianceID, claimStructureID, claimTime, "
36  " hubID, contested, 0 as stationCount, "
37  " 5 as militaryPoints, 5 as industrialPoints, claimID, beaconID, jammerID"
38  " FROM mapSystemSovInfo "
39  " INNER JOIN mapSolarSystems ON mapSolarSystems.solarSystemID=mapSystemSovInfo.solarSystemID"))
40  {
41  codelog(SOV__ERROR, "Error in query: %s", res.error.c_str());
42  }
43 }
44 
46 {
47  if (!sDatabase.RunQuery(res,
48  "SELECT mapSystemSovInfo.solarSystemID, mapSolarSystems.constellationID, mapSolarSystems.regionID, corporationID, "
49  " allianceID, claimStructureID, claimTime, "
50  " hubID, contested, 0 as stationCount, "
51  " 5 as militaryPoints, 5 as industrialPoints, claimID, beaconID, jammerID"
52  " FROM mapSystemSovInfo "
53  " INNER JOIN mapSolarSystems ON mapSolarSystems.solarSystemID=mapSystemSovInfo.solarSystemID"
54  " WHERE mapSystemSovInfo.solarSystemID=%u ", systemID))
55  {
56  codelog(SOV__ERROR, "Error in query: %s", res.error.c_str());
57  }
58 }
59 
61 {
62  DBerror err;
63  if (!sDatabase.RunQueryLID(err, claimID,
64  "INSERT into mapSystemSovInfo (solarSystemID, corporationID, "
65  " allianceID, claimStructureID, claimTime, hubID, contested) "
66  " VALUES (%u, %u, %u, %u, %f, %u, %u)", data.solarSystemID,
67  data.corporationID, data.allianceID, data.claimStructureID,
68  GetFileTimeNow(), data.hubID, data.contested))
69  {
70  codelog(SOV__ERROR, "Error in adding new claim: %s", err.c_str());
71  }
72 }
73 
75 {
76  DBerror err;
77  if (!sDatabase.RunQuery(err,
78  "DELETE from mapSystemSovInfo WHERE solarSystemID=%u", systemID))
79  {
80  codelog(SOV__ERROR, "Error in removing claim: %s", err.c_str());
81  }
82 }
83 
84 void SovereigntyDB::SetContested(uint32 systemID, bool contested)
85 {
86  DBerror err;
87  if (!sDatabase.RunQuery(err,
88  "UPDATE mapSystemSovInfo SET contested=%u WHERE solarSystemID=%u", int(contested), systemID))
89  {
90  codelog(SOV__ERROR, "Error in changing contested state: %s", err.c_str());
91  }
92 }
93 
94 void SovereigntyDB::SetHubID(uint32 systemID, uint32 hubID)
95 {
96  DBerror err;
97  if (!sDatabase.RunQuery(err,
98  "UPDATE mapSystemSovInfo SET hubID=%u WHERE solarSystemID=%u", hubID, systemID))
99  {
100  codelog(SOV__ERROR, "Error in changing IHub ID: %s", err.c_str());
101  }
102 }
103 
104 void SovereigntyDB::SetJammerID(uint32 systemID, uint32 jammerID)
105 {
106  DBerror err;
107  if (!sDatabase.RunQuery(err,
108  "UPDATE mapSystemSovInfo SET jammerID=%u WHERE solarSystemID=%u", jammerID, systemID))
109  {
110  codelog(SOV__ERROR, "Error in changing Jammer ID: %s", err.c_str());
111  }
112 }
113 
114 void SovereigntyDB::SetBeaconID(uint32 systemID, uint32 beaconID)
115 {
116  DBerror err;
117  if (!sDatabase.RunQuery(err,
118  "UPDATE mapSystemSovInfo SET beaconID=%u WHERE solarSystemID=%u", beaconID, systemID))
119  {
120  codelog(SOV__ERROR, "Error in changing Beacon ID: %s", err.c_str());
121  }
122 }
static void RemoveSovereigntyData(uint32 systemID)
#define sDatabase
Definition: dbcore.h:199
static void SetBeaconID(uint32 systemID, uint32 beaconID)
static void SetJammerID(uint32 systemID, uint32 jammerID)
static void AddSovereigntyData(SovereigntyData data, uint32 &claimID)
const char * c_str() const
Definition: dbcore.h:48
#define codelog(type, fmt,...)
Definition: logsys.h:128
unsigned __int32 uint32
Definition: eve-compat.h:50
double GetFileTimeNow()
Definition: utils_time.cpp:84
DBerror error
Definition: dbcore.h:69
static void SetContested(uint32 systemID, bool contested)
static void SetHubID(uint32 systemID, uint32 hubID)
static void GetSovereigntyDataForSystem(DBQueryResult &res, uint32 systemID)
static void GetSovereigntyData(DBQueryResult &res)
Definition: dbcore.h:39