41 " regionName, 3 AS typeID, factionID, 1 AS locationID, 0 AS flag, 0 AS contraband,"
42 " 1 AS singleton, 1 AS quantity, x, y, z, '' AS customInfo"
44 " WHERE regionID=%u", itemID))
46 codelog(DATABASE__ERROR,
"Error in query for region %u: %s", itemID, res.
error.
c_str());
53 " constellationName, 4 AS typeID, factionID, regionID, 0 AS flag, 0 AS contraband,"
54 " 1 AS singleton, 1 AS quantity, x, y, z, '' AS customInfo"
55 " FROM mapConstellations"
56 " WHERE constellationID=%u", itemID))
58 codelog(DATABASE__ERROR,
"Error in query for contellation %u: %s", itemID, res.
error.
c_str());
61 }
else if (
sDataMgr.IsSolarSystem(itemID)) {
65 " solarSystemName, 5 AS typeID, factionID, constellationID, 0 AS flag, 0 AS contraband,"
66 " 1 AS singleton, 1 AS quantity, x, y, z, '' AS customInfo"
67 " FROM mapSolarSystems"
68 " WHERE solarSystemID=%u", itemID))
70 codelog(DATABASE__ERROR,
"Error in query for solar system %u: %s", itemID, res.
error.
c_str());
77 " itemName, typeID, factionID, solarSystemID, 0 AS flag, 0 AS contraband,"
78 " 1 AS singleton, 1 AS quantity, mapDenormalize.x, mapDenormalize.y, mapDenormalize.z, '' AS customInfo"
79 " FROM mapDenormalize"
80 " LEFT JOIN mapSolarSystems USING (solarSystemID)"
81 " WHERE itemID=%u", itemID))
83 codelog(DATABASE__ERROR,
"Error in query for stargate %u: %s", itemID, res.
error.
c_str());
86 }
else if (
sDataMgr.IsStation(itemID)) {
90 " stationName, stationTypeID, corporationID, solarSystemID, 0 AS flag, 0 AS contraband,"
91 " 1 AS singleton, 1 AS quantity, x, y, z, '' AS customInfo"
93 " WHERE stationID=%u", itemID))
95 codelog(DATABASE__ERROR,
"Error in query for station %u: %s", itemID, res.
error.
c_str());
102 " itemName, typeID, 1 AS ownerID, solarSystemID, 0 AS flag, 0 AS contraband,"
103 " 1 AS singleton, 1 AS quantity, x, y, z, '' AS customInfo"
104 " FROM mapDenormalize"
105 " WHERE itemID=%u", itemID))
107 codelog(DATABASE__ERROR,
"Error in query for universe celestial %u: %s", itemID, res.
error.
c_str());
114 " itemName, typeID, 1 AS ownerID, systemID, 0 AS flag, 0 AS contraband,"
115 " 1 AS singleton, quantity, x, y, z, '' AS customInfo"
117 " WHERE itemID=%u", itemID))
119 codelog(DATABASE__ERROR,
"Error in query for asteroid %u: %s", itemID, res.
error.
c_str());
126 " characterName, typeID, 1 AS ownerID, solarSystemID, flag, 0 AS contraband,"
127 " 1 AS singleton, 1 AS quantity, 0 AS x, 0 AS y, 0 AS z, '' AS customInfo"
128 " FROM chrCharacters"
129 " WHERE characterID=%u", itemID))
131 codelog(DATABASE__ERROR,
"Error in query for character %u: %s", itemID, res.
error.
c_str());
138 " name, typeID, corporationID, solarSystemID, flag, 0 AS contraband,"
139 " 1 AS singleton, 1 AS quantity, 0 AS x, 0 AS y, 0 AS z, '' AS customInfo"
141 " WHERE itemID=%u", itemID))
143 codelog(DATABASE__ERROR,
"Error in query for character %u: %s", itemID, res.
error.
c_str());
150 " itemName, typeID, ownerID, locationID, flag, contraband,"
151 " singleton, quantity, x, y, z, customInfo"
152 " FROM entity WHERE itemID=%u", itemID))
154 codelog(DATABASE__ERROR,
"Error in query for item %u: %s", itemID, res.
error.
c_str());
161 _log(DATABASE__MESSAGE,
"ItemDB::GetItem() - Item %u not found.", itemID);
191 std::string nameEsc, customInfoEsc;
196 "INSERT INTO entity ("
197 " itemName, typeID, ownerID, locationID, flag,"
198 " contraband, singleton, quantity, x, y, z,"
200 "VALUES('%s', %u, %u, %u, %u,%u,"
201 " %u, %u, %f, %f, %f, '%s' )",
205 codelog(DATABASE__ERROR,
"Failed to insert new entity: %s", err.
c_str());
215 sDatabase.RunQuery(err,
"UPDATE entity SET locationID = %u, flag = %u WHERE itemID = %u", \
216 locationID, (
uint16)flag, itemID);
222 _log(ITEM__ERROR,
"Refusing to modify static map object %u.", itemID);
230 std::string nameEsc, customInfoEsc;
244 " x = %f, y = %f, z = %f,"
246 " WHERE itemID = %u",
254 customInfoEsc.c_str(),
257 codelog(DATABASE__ERROR,
"Error in query: %s.", err.
c_str());
266 std::ostringstream Inserts;
268 Inserts <<
"INSERT INTO entity";
269 Inserts <<
" (itemID, typeID, ownerID, locationID, flag, contraband, singleton, quantity, x, y, z, customInfo)";
271 for (
auto cur : data) {
272 if (cur.position.isNaN() or cur.position.isInf()) {
273 _log(DATABASE__ERROR,
"ItemDB::SaveItems() - %u has invalid position", cur.itemID);
276 if (cur.locationID == 0) {
277 _log(DATABASE__ERROR,
"ItemDB::SaveItems() - %u has invalid location", cur.itemID);
281 Inserts <<
" VALUES ";
286 Inserts <<
"(" << cur.itemID <<
", " << cur.typeID <<
", " << cur.ownerID <<
", " << cur.locationID <<
", ";
287 Inserts << cur.flag <<
", " << cur.contraband <<
", " << (cur.singleton ? 1 : 0) <<
", ";
288 Inserts << cur.quantity <<
", " << std::to_string(cur.position.x) <<
", " << std::to_string(cur.position.y) <<
", " << std::to_string(cur.position.z);
289 Inserts <<
", '" << cur.customInfo <<
"')";
293 Inserts <<
"ON DUPLICATE KEY UPDATE ";
294 Inserts <<
"quantity=VALUES(quantity), ";
295 Inserts <<
"ownerID=VALUES(ownerID), ";
296 Inserts <<
"locationID=VALUES(locationID), ";
297 Inserts <<
"flag=VALUES(flag), ";
298 Inserts <<
"singleton=VALUES(singleton), ";
299 Inserts <<
"quantity=VALUES(quantity), ";
300 Inserts <<
"x=VALUES(x), ";
301 Inserts <<
"y=VALUES(y), ";
302 Inserts <<
"z=VALUES(z), ";
303 Inserts <<
"customInfo=VALUES(customInfo) ";
306 _log(DATABASE__ERROR,
"SaveItems - unable to save data - %s", err.
c_str());
312 std::ostringstream Inserts;
316 sDatabase.RunQuery(err,
"DELETE FROM chrCharacterAttributes WHERE charID = %u", data[0].
itemID);
317 Inserts <<
"INSERT INTO chrCharacterAttributes";
318 Inserts <<
" (charID, attributeID, valueInt, valueFloat)";
320 Inserts <<
"INSERT INTO entity_attributes";
321 Inserts <<
" (itemID, attributeID, valueInt, valueFloat)";
324 for (
auto cur : data) {
326 Inserts <<
" VALUES ";
330 Inserts <<
"(" << cur.itemID <<
", " << cur.attrID <<
", ";
332 Inserts <<
"NULL, " << cur.valueFloat <<
")";
334 Inserts << cur.valueInt <<
", NULL)";
339 Inserts <<
"ON DUPLICATE KEY UPDATE ";
340 Inserts <<
"valueInt=VALUES(valueInt), ";
341 Inserts <<
"valueFloat=VALUES(valueFloat)";
344 _log(DATABASE__ERROR,
"SaveItems - unable to save data - %s", err.
c_str());
350 _log(ITEM__ERROR,
"Refusing to delete static map object %u.", itemID);
355 if (!
sDatabase.RunQuery(err,
"DELETE FROM entity WHERE itemID = %u", itemID)) {
356 codelog(DATABASE__ERROR,
"Failed to delete item %u: %s", itemID, err.
c_str());
360 if (!
sDatabase.RunQuery(err,
"DELETE FROM entity_attributes WHERE itemID=%u", itemID)) {
361 codelog(DATABASE__ERROR,
"Failed to delete item %u: %s", itemID, err.
c_str());
379 " WHERE categoryID = %u)",
382 codelog(DATABASE__ERROR,
"Failed to query types for catID %u: %s.", catID, res.
error.
c_str());
static bool SaveItem(uint32 itemID, const ItemData &data)
#define IsConstellationID(itemID)
const char * GetText(uint32 index) const
#define IsAsteroidID(itemID)
#define _log(type, fmt,...)
int32 GetInt(uint32 index) const
uint32 GetUInt(uint32 index) const
#define IsCelestialID(itemID)
double GetDouble(uint32 index) const
static void SaveItems(std::vector< Inv::SaveData > &data)
GaExpInl bool isNaN() const
bool GetRow(DBResultRow &into)
const char * c_str() const
#define codelog(type, fmt,...)
static uint32 NewItem(const ItemData &data)
bool IsNull(uint32 index) const
GaExpInl bool isInf() const
#define IsCharacterID(itemID)
static void SaveAttributes(bool isChar, std::vector< Inv::AttrData > &data)
static void UpdateLocation(uint32 itemID, uint32 locationID, EVEItemFlags flag)
#define IsOfficeID(itemID)
static bool DeleteItem(uint32 itemID)
#define IsStaticMapItem(itemID)
typeID Spawn an NPC with the specified type text Search for items matching the specified query() type()() itemID() copy() materialLevel()() itemID(attributeID)-Retrieves attribute value." ) COMMAND( setattr
#define IsStargateID(itemID)
#define IsRegionID(itemID)
static bool GetItem(uint32 itemID, ItemData &into)
static void GetItems(uint16 catID, std::map< uint16, std::string > &typeIDs)