35 std::string nameEsc, titleEsc, descriptionEsc;
42 "INSERT INTO chrCharacters"
43 " (accountID, characterName, typeID, locationID, description, balance, aurBalance,"
44 " logonDateTime, baseID, corpAccountKey, createDateTime, title,"
45 " ancestryID, bloodlineID, raceID, careerID, schoolID, careerSpecialityID, gender,"
46 " stationID, solarSystemID, constellationID, regionID, freeRespecs)"
48 " (%u,'%s', %u, %u, '%s', %f, %f,"
49 " %f, %u, %u, %f, '%s',"
50 " %u, %u, %u, %u, %u, %u, %u,"
51 " %u, %u, %u, %u, 2)",
57 codelog(DATABASE__ERROR,
"Failed to insert character %s.", err.
c_str());
69 std::string titleEsc, descriptionEsc;
74 "UPDATE chrCharacters"
77 " description = '%s',"
81 " securityRating = %f,"
86 " solarSystemID = %u,"
87 " constellationID = %u,"
89 " WHERE characterID = %u",
93 codelog(DATABASE__ERROR,
"Failed to save character %u: %s.", characterID, err.
c_str());
104 "UPDATE chrCharacters"
106 " corporationID = %u, "
109 " corpAccountKey = %i,"
111 " rolesAtBase = %li,"
113 " rolesAtOther = %li,"
114 " grantableRoles = %li,"
115 " grantableRolesAtBase = %li,"
116 " grantableRolesAtHQ = %li,"
117 " grantableRolesAtOther = %" PRIi64
118 " WHERE characterID = %u",
122 codelog(DATABASE__ERROR,
"Failed to update corp member info of character %u: %s.", characterID, err.
c_str());
138 sDatabase.RunQuery(err,
"DELETE FROM eveMailDetails"
139 " USING eveMail, eveMailDetails"
140 " WHERE eveMail.messageID = eveMailDetails.messageID"
141 " AND (senderID = %u OR channelID = %u)", characterID, characterID);
142 sDatabase.RunQuery(err,
"DELETE FROM eveMail WHERE (senderID = %u OR channelID = %u)", characterID, characterID);
143 sDatabase.RunQuery(err,
"DELETE FROM bookmarks WHERE ownerID = %u", characterID);
144 sDatabase.RunQuery(err,
"DELETE FROM bookmarkFolders WHERE ownerID = %u", characterID);
146 sDatabase.RunQuery(err,
"DELETE FROM mktOrders WHERE ownerID = %u", characterID);
147 sDatabase.RunQuery(err,
"DELETE FROM mktTransactions WHERE clientID = %u", characterID);
148 sDatabase.RunQuery(err,
"DELETE FROM repStandings WHERE (fromID = %u OR toID = %u)", characterID, characterID);
149 sDatabase.RunQuery(err,
"DELETE FROM repStandingChanges WHERE (fromID = %u OR toID = %u)", characterID, characterID);
150 sDatabase.RunQuery(err,
"DELETE FROM chrCertificates WHERE characterID=%u", characterID);
151 sDatabase.RunQuery(err,
"DELETE FROM chrCharacters WHERE characterID=%u", characterID);
152 sDatabase.RunQuery(err,
"DELETE FROM chrEmployment WHERE characterID=%u", characterID);
153 sDatabase.RunQuery(err,
"DELETE FROM jnlCharacters WHERE ownerID=%u", characterID);
154 sDatabase.RunQuery(err,
"DELETE FROM crpShares WHERE shareholderID=%u", characterID);
155 sDatabase.RunQuery(err,
"DELETE FROM chrSkillHistory WHERE characterID=%u", characterID);
156 sDatabase.RunQuery(err,
"DELETE FROM chrSkillQueue WHERE characterID=%u", characterID);
157 sDatabase.RunQuery(err,
"DELETE FROM crpApplications WHERE characterID=%u", characterID);
158 sDatabase.RunQuery(err,
"DELETE FROM chrCharacterAttributes WHERE charID = %u", characterID);
159 sDatabase.RunQuery(err,
"DELETE FROM chrPausedSkillQueue WHERE characterID = %u", characterID);
160 sDatabase.RunQuery(err,
"DELETE FROM entity_attributes"
161 " WHERE itemID IN (SELECT itemID FROM entity WHERE ownerID = %u)", characterID);
162 sDatabase.RunQuery(err,
"DELETE FROM entity WHERE ownerID = %u", characterID);
163 sDatabase.RunQuery(err,
"DELETE FROM avatar_colors WHERE charID = %u", characterID);
164 sDatabase.RunQuery(err,
"DELETE FROM avatar_modifiers WHERE charID = %u", characterID);
165 sDatabase.RunQuery(err,
"DELETE FROM avatar_sculpts WHERE charID = %u", characterID);
166 sDatabase.RunQuery(err,
"DELETE FROM avatars WHERE charID = %u", characterID);
172 if (!
sDatabase.RunQuery(error,
"UPDATE chrCharacters SET freeRespecs = freeRespecs - 1, lastRespecDateTime = %f, nextRespecDateTime = %li WHERE characterId = %u",
181 if (!
sDatabase.RunQuery(res,
"SELECT freeRespecs, lastRespecDateTime, nextRespecDateTime FROM chrCharacters WHERE characterID = %u", characterId))
205 sDatabase.RunQuery(error, affectedRows,
"UPDATE chrCharacters SET deletePrepareDateTime = %li WHERE accountID = %u AND characterID = %u", deleteTime, accountID, charID);
206 if (affectedRows != 1)
216 sDatabase.RunQuery(error, affectedRows,
"UPDATE chrCharacters SET deletePrepareDateTime = 0 WHERE accountID = %u AND characterID = %u", accountID, charID);
217 if (affectedRows != 1)
218 _log(CLIENT__ERROR,
"Failed to cancel character deletion, affected rows: %u", affectedRows);
227 " deletePrepareDateTime,"
230 " FROM chrCharacters"
231 " WHERE accountID=%u", accountID))
254 return new PyInt(-1);
255 if (name.length() < 3)
256 return new PyInt(-1);
257 if (name.length() > 37)
258 return new PyInt(-2);
260 if (!
sDatabase.IsSafeString(name.c_str()))
261 return new PyInt(-5);
265 return new PyInt(-5);
269 return new PyInt(-5);
273 return new PyInt(-7);
276 int found = name.find(
" ");
277 if (found != name.npos) {
278 found = name.find(
" ", found + 1, 1);
279 if (found != name.npos)
280 return new PyInt(-6);
284 sDatabase.DoEscapeString(eName, name.c_str());
286 sDatabase.RunQuery(res,
"SELECT characterID FROM chrCharacters WHERE characterName LIKE '%s' ", eName.c_str() );
288 return new PyInt(-101);
334 if (name.length() < 3)
338 if (name.length() > 37)
339 throw UserError (
"CharNameInvalidMaxLength");
350 throw UserError (
"CharNameInvalidBannedWord");
353 throw UserError (
"CharNameInvalidSomeChar");
356 int found = name.find(
" ");
357 if (found != name.npos) {
358 found = name.find(
" ", found + 1, 1);
359 if (found != name.npos)
360 throw UserError (
"CharNameInvalidMaxSpaces");
364 sDatabase.DoEscapeString(eName, name.c_str());
366 sDatabase.RunQuery(res,
"SELECT characterID FROM chrCharacters WHERE characterName LIKE '%s' ", eName.c_str() );
368 throw UserError (
"CharNameInvalidTaken");
377 "INSERT INTO chrEmployment"
378 " (characterID, corporationID, startDate, deleted)"
381 codelog(DATABASE__ERROR,
"Error in employment insert query: %s", err.
c_str());
384 if (!
sDatabase.RunQuery(err,
"UPDATE chrCharacters SET startDateTime = %f, corporationID = %u WHERE characterID = %u",
GetFileTimeNow(), corpID, charID))
385 codelog(DATABASE__ERROR,
"Error in character insert query: %s", err.
c_str());
389 if (!
sDatabase.RunQuery(err,
"UPDATE crpCorporation SET memberCount = memberCount-1 WHERE corporationID = %u", oldCorpID))
390 codelog(CORP__DB_ERROR,
"Error in prev corp member decrease query: %s", err.
c_str());
393 if (!
sDatabase.RunQuery(err,
"UPDATE crpCorporation SET memberCount = memberCount+1 WHERE corporationID = %u", corpID))
394 codelog(CORP__DB_ERROR,
"Error in new corp member increase query: %s", err.
c_str());
399 std::string shipName =
"My Ship";
403 if (!
sDatabase.RunQuery(res,
"SELECT itemName, typeID FROM entity WHERE itemID = (SELECT shipID FROM chrCharacters WHERE characterID = %u)", characterID)) {
404 _log(CHARACTER__WARNING,
"Unable to get current ship: %s", res.
error.
c_str());
418 uint32 unreadMailCount = 0;
419 uint32 upcomingEventCount = 0;
420 uint32 unprocessedNotifications = 0;
425 " %u AS unreadMailCount,"
426 " %u AS upcomingEventCount, "
427 " %u AS unprocessedNotifications, "
435 " 0 AS worldSpaceID, "
441 " 0 AS allianceMemberStartDate,"
442 " 'none' AS shortName, "
444 " skillQueueEndTime, "
446 " %u AS shipTypeID, "
447 " '%s' AS shipName, "
455 " FROM chrCharacters"
456 " WHERE characterID=%u",
457 unreadMailCount, upcomingEventCount, unprocessedNotifications,
458 shipTypeID, shipName.c_str(), characterID))
468 sLog.Error(
"CharacterDB::GetCharPublicInfo()",
"Character %u is NPC.", characterID);
484 " ch.careerSpecialityID,"
486 " ch.createDateTime,"
491 " FROM chrCharacters AS ch"
492 " LEFT JOIN chrSchools AS cs USING (schoolID) "
493 " WHERE ch.characterID=%u", characterID))
501 codelog(DATABASE__ERROR,
"Error in GetCharPublicInfo query: no data for char %d", characterID);
515 " ch.corporationID, "
517 " ch.solarSystemID, "
518 " ch.constellationID, "
522 " ch.corpAccountKey, "
536 " FROM chrCharacters AS ch"
537 " LEFT JOIN crpCorporation AS co USING (corporationID) "
538 " WHERE characterID = %u", charID))
540 sLog.Error(
"CharacterDB::GetCharacterData()",
"Failed to query HQ of character's %u corporation: %s.", charID, res.
error.
c_str());
545 sLog.Error(
"CharacterDB::GetCharacterData()",
"No valid rows were returned by the database query.");
549 characterDataMap[
"corporationID"] = row.
GetUInt(0);
550 characterDataMap[
"stationID"] = row.
GetUInt(1);
551 characterDataMap[
"solarSystemID"] = row.
GetUInt(2);
552 characterDataMap[
"constellationID"] = row.
GetUInt(3);
553 characterDataMap[
"regionID"] = row.
GetUInt(4);
554 characterDataMap[
"corporationHQ"] = row.
GetUInt(5);
555 characterDataMap[
"corpRole"] = row.
GetInt64(6);
556 characterDataMap[
"corpAccountKey"] = row.
GetInt(7);
557 characterDataMap[
"rolesAtAll"] = row.
GetInt64(8);
558 characterDataMap[
"rolesAtBase"] = row.
GetInt64(9);
559 characterDataMap[
"rolesAtHQ"] = row.
GetInt64(10);
560 characterDataMap[
"rolesAtOther"] = row.
GetInt64(11);
561 characterDataMap[
"shipID"] = row.
GetUInt(12);
562 characterDataMap[
"gender"] = row.
GetInt(13);
563 characterDataMap[
"bloodlineID"] = row.
GetUInt(14);
564 characterDataMap[
"raceID"] = row.
GetUInt(15);
565 characterDataMap[
"locationID"] = row.
GetUInt(16);
566 characterDataMap[
"baseID"] = row.
GetInt(17);
567 characterDataMap[
"allianceID"] = row.
GetInt(18);
568 characterDataMap[
"warFactionID"] = row.
GetInt(19);
580 characterDataMap[
"cloneStationID"] = stationID;
593 " FROM chrCharacters "
594 " WHERE characterID=%u", charID))
612 " FROM chrCharacters "
613 " WHERE characterID=%u", charID))
630 " ch.corporationID AS corpID,"
633 " FROM chrCharacters AS ch"
634 " LEFT JOIN crpCorporation AS co USING (corporationID)"
635 " WHERE characterID=%u", characterID))
643 codelog(DATABASE__ERROR,
"Expected at least one row when getting character corp info\n");
653 if (!
sDatabase.RunQuery(res,
"SELECT characterName FROM chrCharacters WHERE characterID=%u", characterID)) {
660 _log(DATABASE__MESSAGE,
"Name not found for CharacterID %u.", characterID);
672 "SELECT contactID, inWatchlist, relationshipID, labelMask"
673 " FROM chrContacts WHERE ownerID = %u and blocked = %u", charID, blocked))
686 "INSERT INTO chrContacts (ownerID, contactID, relationshipID, "
687 " inWatchlist, labelMask, blocked) VALUES "
688 " (%u, %u, %i, %i, 0, 0) ",
689 ownerID, charID, standing, inWatchlist);
696 "UPDATE chrContacts SET relationshipID=%i "
697 " WHERE contactID=%u AND ownerID=%u ",
698 standing, charID, ownerID);
705 "UPDATE chrContacts SET blocked=%u "
706 " WHERE contactID=%u AND ownerID=%u ",
707 blocked, charID, ownerID);
714 "DELETE from chrContacts "
715 " WHERE contactID=%u AND ownerID=%u ",
727 " WHERE ownerID = %u",
730 _log(DATABASE__ERROR,
"Failed to query items of char %u: %s.", characterID, res.
error.
c_str());
736 into.push_back(row.
GetUInt(0));
747 " LEFT JOIN invTypes USING (typeID)"
748 " LEFT JOIN invGroups USING (groupID)"
749 " WHERE e.ownerID = %u"
750 " AND locationID = %u"
751 " AND categoryID = %u"
765 if (!
sDatabase.RunQuery(err,
"UPDATE chrCharacters SET shipID = %u WHERE characterID = %u", shipID, charID))
766 _log(DATABASE__ERROR,
"Failed to save ship %u for character %u: %s.", shipID, charID, err.
c_str());
772 if (!
sDatabase.RunQuery(err,
"UPDATE chrCharacters SET capsuleID = %u WHERE characterID = %u", podID, charID))
773 _log(DATABASE__ERROR,
"Failed to save pod %u for character %u: %s.", podID, charID, err.
c_str());
779 if (!
sDatabase.RunQuery(res,
"SELECT itemID FROM entity WHERE ownerID = %u AND flag='400'", characterID)) {
780 _log(DATABASE__ERROR,
"Failed to query clones of char %u: %s.", characterID, res.
error.
c_str());
786 into.push_back(row.
GetUInt(0));
798 " WHERE ownerID = %u"
802 _log(DATABASE__ERROR,
"Failed to query active clone of char %u: %s.", characterID, res.
error.
c_str());
824 " WHERE ownerID = %u"
828 _log(DATABASE__ERROR,
"Failed to query active clone of char %u: %s.", characterID, res.
error.
c_str());
848 " WHERE ownerID = %u"
852 _log(CHARACTER__ERROR,
"Could't get clone location for char %u", characterID );
874 _log(DATABASE__ERROR,
"Failed to change clone type of char %u: %s.", characterID, res.
error.
c_str());
881 sLog.Error(
"CharacterDB::ChangeCloneType()",
"Could not find Clone typeID = %u in invTypes table.", typeID );
884 std::string typeNameString = row.
GetText(0);
889 "SET typeID=%u, itemName='%s' "
893 typeNameString.
c_str(),
896 _log(DATABASE__ERROR,
"Failed to change clone type of char %u: %s.", characterID, res.
error.
c_str());
899 sLog.Debug(
"CharacterDB",
"Clone upgrade successful" );
906 if (!
sDatabase.RunQuery(res.
error,
"UPDATE entity SET locationID=%u WHERE ownerID=%u AND flag=400", locationID, characterID)) {
907 _log(DATABASE__ERROR,
"Failed to change location of clone %u: %s.", characterID, res.
error.
c_str());
919 " intelligence, charisma, perception, memory, willpower "
920 " FROM chrAncestries "
921 " WHERE ancestryID = %u ", ancestryID))
929 codelog(DATABASE__ERROR,
"Failed to find ancestry information for ancestry %u", ancestryID);
933 intelligence += row.
GetUInt(0);
945 "SELECT raceID, careerID FROM careers WHERE schoolID = %u", schoolID)) {
952 codelog(DATABASE__ERROR,
"Failed to find matching career for school %u", schoolID);
963 if (!
sDatabase.RunQuery(res,
"SELECT corporationID FROM chrSchools WHERE schoolID = %u", schoolID)) {
970 codelog(DATABASE__ERROR,
"Failed to find matching corporation for school %u", schoolID);
973 corporationID = row.
GetInt(0);
984 " cs.corporationID, "
987 " st.solarSystemID, "
988 " st.constellationID, "
991 " LEFT JOIN chrSchools AS cs USING (schoolID)"
992 " LEFT JOIN crpCorporation AS co ON cs.corporationID = co.corporationID"
993 " LEFT JOIN staStations AS st USING (stationID)"
994 " WHERE c.careerID = %u", cdata.
careerID))
1006 corporationID = row.
GetUInt(0);
1022 " FROM careers AS c"
1023 " LEFT JOIN chrSchools AS cs USING (schoolID)"
1024 " LEFT JOIN crpCorporation AS co ON cs.corporationID = co.corporationID"
1025 " WHERE c.careerID = %u", careerID))
1033 codelog(DATABASE__ERROR,
"Failed to find station for career %u", careerID);
1045 " FROM crpCorporation"
1046 " WHERE corporationID = %u", corpID))
1059 "INSERT INTO avatars (charID, hairDarkness)"
1063 codelog(DATABASE__ERROR,
"Error in query: %s", err.
c_str());
1071 "INSERT INTO avatar_colors (charID, colorID, colorNameA, colorNameBC, weight, gloss)"
1072 " VALUES (%u, %u, %u, %u, %f, %f)",
1073 charID, colorID, colorNameA, colorNameBC, weight, gloss))
1075 codelog(DATABASE__ERROR,
"Error in query: %s", err.
c_str());
1083 "INSERT INTO avatar_modifiers (charID, modifierLocationID, paperdollResourceID, paperdollResourceVariation)"
1084 " VALUES (%u, %u, %u, %u)",
1088 paperdollResourceVariation->
IsInt() ? paperdollResourceVariation->
AsInt()->
value() : 0 ))
1090 codelog(DATABASE__ERROR,
"Error in query: %s", err.
c_str());
1098 "INSERT INTO avatar_sculpts (charID, sculptLocationID, weightUpDown, weightLeftRight, weightForwardBack)"
1099 " VALUES (%u, %u, %f, %f, %f)",
1106 codelog(DATABASE__ERROR,
"Error in query: %s", err.
c_str());
1114 "INSERT INTO chrPortraitData "
1115 " (charID, backgroundID, lightID, lightColorID, cameraX, cameraY, cameraZ, cameraPoiX, cameraPoiY, cameraPoiZ,"
1116 " headLookTargetX, headLookTargetY, headLookTargetZ, lightIntensity, headTilt, orientChar, browLeftCurl, browLeftTighten,"
1117 " browLeftUpDown, browRightCurl, browRightTighten, browRightUpDown, eyeClose, eyesLookVertical, eyesLookHorizontal,"
1118 " squintLeft, squintRight, jawSideways, jawUp, puckerLips, frownLeft, frownRight, smileLeft, smileRight, "
1119 " cameraFieldOfView, portraitPoseNumber) VALUES"
1120 " (%u,%u,%u,%u,%f,%f,%f,%f,%f,%f,"
1121 " %f,%f,%f,%f,%f,%f,%f,%f,"
1122 " %f,%f,%f,%f,%f,%f,%f,"
1123 " %f,%f,%f,%f,%f,%f,%f,%f,%f,"
1125 charID, data.
backgroundID, data.
lightID, data.
lightColorID, data.
cameraX, data.
cameraY, data.
cameraZ, data.
cameraPoiX, data.
cameraPoiY, data.
cameraPoiZ,
1131 codelog(DATABASE__ERROR,
"Error in query: %s", err.
c_str());
1137 if (!
sDatabase.RunQuery(res,
"SELECT skillTypeID, level FROM sklBaseSkills")) {
1151 if (!
sDatabase.RunQuery(res,
"SELECT skillTypeID, level FROM sklRaceSkills WHERE raceID = %u ", raceID)) {
1157 while (res.
GetRow(row)) {
1158 if (into.find(row.
GetUInt(0)) == into.end()) {
1175 " skillTypeID, level"
1176 " FROM sklCareerSkills"
1177 " WHERE careerID = %u", careerID))
1184 while (res.
GetRow(row)) {
1185 if (into.find(row.
GetUInt(0)) == into.end()) {
1200 if (!
sDatabase.RunQuery(res,
"SELECT note FROM chrNotes WHERE ownerID = %u AND itemID = %u", ownerID, itemID)) {
1213 if (str[0] ==
'\0') {
1216 "DELETE FROM chrNotes "
1217 " WHERE itemID = %u AND ownerID = %u LIMIT 1",
1221 codelog(DATABASE__ERROR,
"Error on query: %s", err.
c_str());
1226 std::string escaped;
1230 "REPLACE INTO chrNotes ( ownerID, itemID, note)"
1231 " VALUES (%u, %u, '%s')",
1232 ownerID, itemID, escaped.
c_str())
1235 codelog(DATABASE__ERROR,
"Error on query: %s", err.
c_str());
1250 sDatabase.DoEscapeString(contS, content);
1253 "INSERT INTO chrOwnerNote (ownerID, label, note) VALUES (%u, '%s', '%s');",
1254 charID, lblS.
c_str(), contS.c_str()))
1256 codelog(DATABASE__ERROR,
"Error on query: %s", err.
c_str());
1266 sDatabase.DoEscapeString(contS, content);
1269 "UPDATE chrOwnerNote SET note = '%s' WHERE ownerID = %u AND noteID = %u;",
1270 contS.
c_str(), charID, noteID))
1272 codelog(DATABASE__ERROR,
"Error on query: %s", err.
c_str());
1281 if (!
sDatabase.RunQuery(res,
"SELECT noteID, label FROM chrOwnerNote WHERE ownerID = %u", charID))
1321 if (!
sDatabase.RunQuery(res,
"SELECT note FROM chrOwnerNote WHERE ownerID = %u AND noteID = %u", charID, noteID))
1336 sDatabase.RunQuery(res,
"UPDATE chrLabels SET color = %u, name = '%s' WHERE ownerID = %u AND labelID = %u", color, eName.c_str(), charID, labelID);
1342 if (!
sDatabase.RunQuery(res,
"SELECT labelID, color, name FROM chrLabels WHERE ownerID = %u", charID)) {
1356 sDatabase.RunQuery(res,
"INSERT INTO chrLabels (color, name, ownerID) VALUES (%u, '%s', %u)", color, eName.c_str(), charID);
1362 sDatabase.RunQuery(err,
"DELETE FROM chrLabels WHERE ownerID = %u AND labelID = %u", charID, labelID);
1367 if (!
sDatabase.RunQuery( res,
"SELECT typeID, level, startTime, endTime FROM chrSkillQueue WHERE characterID = %u ORDER BY orderIndex ASC", characterID)) {
1368 _log(DATABASE__ERROR,
"Failed to query skill queue of character %u: %s.", characterID, res.
error.
c_str());
1373 while (res.
GetRow(row)) {
1379 into.push_back( qs );
1387 if (!
sDatabase.RunQuery( res,
"SELECT typeID, level FROM chrPausedSkillQueue WHERE characterID = %u ORDER BY orderIndex ASC", characterID)) {
1388 _log(DATABASE__ERROR,
"Failed to query paused skill queue of character %u: %s.", characterID, res.
error.
c_str());
1393 while (res.
GetRow(row)) {
1397 into.push_back( qs );
1402 if (!
sDatabase.RunQuery(err,
"DELETE FROM chrPausedSkillQueue WHERE characterID = %u", characterID)) {
1403 _log(DATABASE__ERROR,
"Failed to delete skill queue of character %u: %s.", characterID, err.
c_str());
1412 if (!
sDatabase.RunQuery(err,
"DELETE FROM chrSkillQueue WHERE characterID = %u", characterID)) {
1413 _log(DATABASE__ERROR,
"Failed to delete skill queue of character %u: %s.", characterID, err.
c_str());
1422 for (
uint8 i = 0; i < data.size(); i++) {
1425 snprintf( buf,
sizeof(buf),
"(%u, %u, %u, %u, %li, %li)", characterID, i, qs.
typeID, qs.
level, qs.
startTime, qs.
endTime );
1433 "INSERT INTO chrSkillQueue (characterID, orderIndex, typeID, level, startTime, endTime)"
1434 " VALUES %s",query.
c_str()))
1436 _log(DATABASE__ERROR,
"SaveSkillQueue - unable to save data - %s", err.
c_str());
1444 if (!
sDatabase.RunQuery(err,
"DELETE FROM chrPausedSkillQueue WHERE characterID = %u", characterID)) {
1445 _log(DATABASE__ERROR,
"Failed to delete paused skill queue of character %u: %s.", characterID, err.
c_str());
1454 for (
uint8 i = 0; i < data.size(); i++) {
1465 "INSERT INTO chrPausedSkillQueue (characterID, orderIndex, typeID, level)"
1466 " VALUES %s",query.
c_str()))
1468 _log(DATABASE__ERROR,
"SavePausedSkillQueue - unable to save data - %s", err.
c_str());
1478 "INSERT INTO chrSkillHistory (eventTypeID, logDate, characterID, skillTypeID, skillLevel, absolutePoints)"
1479 " VALUES (%u, %f, %u, %u, %u, %u)", eventID, logDate, characterID, skillTypeID, skillLevel, absolutePoints ))
1480 _log(DATABASE__ERROR,
"Failed to set chrSkillHistory for character %u: %s", characterID, err.
c_str());
1486 "SELECT logDate, eventTypeID, skillTypeID, absolutePoints"
1487 " FROM chrSkillHistory"
1488 " WHERE characterID = %u"
1489 " ORDER BY logDate DESC"
1501 sDatabase.RunQuery( err,
"UPDATE chrCharacters SET skillQueueEndTime = %li WHERE characterID = %u ", endtime, charID );
1507 sDatabase.RunQuery(err,
"UPDATE chrCharacters SET logonDateTime = %f WHERE characterID = %u",
GetFileTimeNow(), charID );
1513 sDatabase.RunQuery(err,
"UPDATE chrCharacters SET logoffDateTime = %f WHERE characterID = %u",
GetFileTimeNow(), charID );
1519 "INSERT INTO cacheOwners(ownerID, ownerName, typeID)"
1520 " VALUES (%u, '%s', %u)",
1526 sDatabase.RunQuery(res,
"SELECT characterID, bounty FROM webBounties WHERE characterID = %u OR ownerID = %u", charID, ownerID);
1533 "SELECT c.characterID, c.bounty, c.online, o.characterName AS ownerName"
1534 " FROM webBounties AS b"
1535 " LEFT JOIN chrCharacters AS c ON c.characterID = b.characterID"
1536 " LEFT JOIN chrCharacters AS o ON o.characterID = b.ownerID"
1537 " ORDER BY c.bounty DESC"
1544 sDatabase.RunQuery(err,
"UPDATE chrCharacters SET bounty = bounty + %u WHERE characterID = %u", amount, charID);
1546 "INSERT INTO webBounties(characterID, ownerID, bounty, timePlaced)"
1547 " VALUES (%u, %u, %u, UNIX_TIMESTAMP(CURRENT_TIMESTAMP) )",
1548 charID, ownerID, amount );
1566 " victimCharacterID,"
1567 " victimCorporationID,"
1568 " victimAllianceID,"
1570 " victimShipTypeID,"
1571 " finalCharacterID,"
1572 " finalCorporationID,"
1576 " finalWeaponTypeID,"
1579 " victimDamageTaken,"
1580 " finalSecurityStatus,"
1583 " FROM chrKillTable"
1584 " WHERE ((victimCharacterID = %u) OR (finalCharacterID = %u))", charID, charID))
1591 _log(DATABASE__RESULTS,
"GetKillOrLoss for %u returned %u items", charID, res.
GetRowCount());
1599 sDatabase.RunQuery(err,
"UPDATE chrCharacters SET corpRole = %li WHERE characterID = %u", role, charID);
1605 if (!
sDatabase.RunQuery(res,
"SELECT corpRole FROM chrCharacters WHERE characterID = %u", charID)) {
1606 sLog.Error(
"CharacterDB::GetCorpRole()",
"Failed to query role of character %u: %s.", charID, res.
error.
c_str());
1612 sLog.Error(
"CharacterDB::GetCorpRole()",
"No valid rows were returned by the database query.");
1622 if (!
sDatabase.RunQuery(res,
"SELECT corporationID FROM chrCharacters WHERE characterID = %u", charID)) {
1623 sLog.Error(
"CharacterDB::GetCorpID()",
"Failed to query corpID of character %u: %s.", charID, res.
error.
c_str());
1629 sLog.Error(
"CharacterDB::GetCorpID()",
"No valid rows were returned by the database query.");
1640 "SELECT taxRate FROM crpCorporation WHERE corporationID = (SELECT corporationID FROM chrCharacters WHERE characterID = %u)", charID))
1656 if (!
sDatabase.RunQuery(res,
"SELECT solarSystemID AS locationID, characterID FROM chrCharacters WHERE corporationID = %u", corpID)) {
1657 sLog.Error(
"CharacterDB::GetMyCorpMates()",
"Failed to query corpMates for corpID %u: %s.", corpID, res.
error.
c_str());
1667 "INSERT INTO chrVisitedSystems (characterID, solarSystemID, visits, lastDateTime)"
1668 "VALUES (%u, %u, 1, %f)"
1669 " ON DUPLICATE KEY UPDATE"
1670 " visits = visits +1,"
1687 " e.flag AS flagID, "
1688 " e.quantity AS stacksize, "
1694 " LEFT JOIN invTypes USING (typeID)"
1695 " LEFT JOIN invGroups AS g USING (groupID)"
1696 "WHERE e.ownerID=%u AND e.locationID < %u", ownerID,
maxStation))
1719 "SELECT o.stationID, COUNT(e.itemID) as blueprintCount"
1721 " LEFT JOIN invTypes USING (typeID)"
1722 " LEFT JOIN invGroups AS g USING (groupID)"
1723 " LEFT JOIN staOffices as o ON o.itemID = e.locationID"
1724 " WHERE e.ownerID=%u AND e.flag IN (%s) AND g.categoryID = %u AND (e.locationID >= %u AND e.locationID <= %u)"
1732 "SELECT e.locationID AS stationID, COUNT(e.itemID) as blueprintCount"
1734 " LEFT JOIN invTypes USING (typeID)"
1735 " LEFT JOIN invGroups AS g USING (groupID)"
1736 " WHERE e.ownerID=%u AND e.flag IN (%s) AND g.categoryID = %u AND e.locationID <= %u"
1747 "SELECT o.stationID, COUNT(e.itemID) as itemCount"
1749 " LEFT JOIN staOffices as o ON o.itemID = e.locationID"
1750 " WHERE e.ownerID=%u AND e.flag IN (%s) AND (e.locationID >= %u AND e.locationID <= %u)"
1758 "SELECT locationID AS stationID, COUNT(itemID) as itemCount"
1759 " FROM entity WHERE ownerID=%u AND flag IN (%s) AND locationID <= %u"
1760 " GROUP BY locationID", ownerID, flagIDs.str().c_str(),
maxStation))
1769 rsp->
Dump(CLIENT__RSP_DUMP,
" ");
1785 " e.flag AS flagID, "
1786 " e.quantity AS stacksize, "
1792 " LEFT JOIN invTypes USING (typeID)"
1793 " LEFT JOIN invGroups AS g USING (groupID)"
1794 "WHERE e.ownerID=%u AND e.locationID=%u AND e.flag=4",
1795 ownerID, stationID))
1802 rsp->
Dump(CLIENT__RSP_DUMP,
" ");
1818 " o.stationID AS locationID, "
1819 " e.flag AS flagID, "
1820 " e.quantity AS stacksize, "
1825 " b.pLevel AS productivityLevel,"
1826 " b.mLevel AS materialLevel,"
1828 " b.runs AS licensedProductionRunsRemaining"
1830 " LEFT JOIN invTypes USING (typeID)"
1831 " LEFT JOIN invGroups AS g USING (groupID)"
1832 " LEFT JOIN invBlueprints AS b USING (itemID)"
1833 " LEFT JOIN staOffices as o ON e.locationID = o.itemID"
1834 " WHERE e.ownerID=%u AND o.stationID=%u AND g.categoryID = %u",
1848 " e.flag AS flagID,"
1849 " e.quantity AS stacksize,"
1854 " b.pLevel AS productivityLevel,"
1855 " b.mLevel AS materialLevel,"
1857 " b.runs AS licensedProductionRunsRemaining"
1859 " LEFT JOIN invTypes USING (typeID)"
1860 " LEFT JOIN invGroups AS g USING (groupID)"
1861 " LEFT JOIN invBlueprints AS b USING (itemID)"
1862 " WHERE e.ownerID=%u AND e.locationID=%u AND e.flag=4 AND g.categoryID = %u",
1872 rsp->
Dump(CLIENT__RSP_DUMP,
" ");
1881 "SELECT valueInt FROM entity_attributes WHERE attributeID= %u AND itemID= "
1882 "(SELECT itemID FROM entity WHERE locationID = %u AND typeID = %u)",
PyRep * GetCharPrivateInfo(uint32 charID)
#define sConfig
A macro for easier access to the singleton.
bool LoadSkillQueue(uint32 charID, SkillQueue &into)
bool GetCharClones(uint32 charID, std::vector< uint32 > &into)
bool SetNote(uint32 ownerID, uint32 itemID, const char *str)
static bool ChangeCloneLocation(uint32 charID, uint32 locationID)
const char * GetText(uint32 index) const
static float GetCorpTaxRate(uint32 charID)
#define _log(type, fmt,...)
static bool SaveCorpData(uint32 charID, const CorpData &data)
float GetFloat(uint32 index) const
void SetAvatarColors(uint32 charID, uint32 colorID, uint32 colorNameA, uint32 colorNameBC, double weight, double gloss)
bool SaveSkillQueue(uint32 charID, SkillQueue &queue)
PyObjectEx * DBResultToCRowset(DBQueryResult &result)
uint32 PickAlternateShip(uint32 charID, uint32 locationID)
PyRep * GetCharSelectInfo(uint32 charID)
int32 GetInt(uint32 index) const
void SetAvatarModifiers(uint32 charID, PyRep *modifierLocationID, PyRep *paperdollResourceID, PyRep *paperdollResourceVariation)
PyRep * GetRespecInfo(uint32 characterId)
static bool SaveCharacter(uint32 charID, const CharacterData &data)
bool EditOwnerNote(uint32 charID, uint32 noteID, const std::string &label, const std::string &content)
uint32 GetUInt(uint32 index) const
static bool GetCharHomeStation(uint32 charID, uint32 &stationID)
PyRep * GetCharacterList(uint32 accountID)
PyRep * GetOwnerNoteLabels(uint32 charID)
static const std::array< std::string, 18 > badChars
bool GetCharItems(uint32 charID, std::vector< uint32 > &into)
static PyRep * GetMyCorpMates(uint32 corpID)
PyRep * GetBounty(uint32 charID, uint32 ownerID)
void UpdateContact(int32 standing, uint32 charID, uint32 ownerID)
bool DoesCorporationExist(uint32 corpID)
void UpdateSkillQueueEndTime(int64 endtime, uint32 charID)
void SetLogOffTime(uint32 charID)
PyRep * GetSkillHistory(uint32 charID)
PyObjectEx * DBResultToCIndexedRowset(DBQueryResult &result, const char *key)
void Dump(FILE *into, const char *pfx) const
Dumps object to file.
PyRep * GetKillOrLoss(uint32 charID)
void AddContact(uint32 ownerID, uint32 charID, int32 standing, bool inWatchlist)
PyRep * GetCharPublicInfo(uint32 charID)
void CancelCharacterDeletePrepare(uint32 accountID, uint32 charID)
static PyRep * ListStations(uint32 ownerID, std::ostringstream &flagIDs, bool forCorp=false, bool bpOnly=false)
void DeleteCharacter(uint32 charID)
bool GetRow(DBResultRow &into)
void addOwnerCache(uint32 ownerID, std::string ownerName, uint32 typeID)
static uint32 GetStartingStationByCareer(uint32 careerID)
#define is_log_enabled(type)
#define sLog
Evaluates to a NewLog instance.
static PyRep * GetInfoWindowDataForChar(uint32 charID)
bool GetAttributesFromAncestry(uint32 ancestryID, uint8 &intelligence, uint8 &charisma, uint8 &perception, uint8 &memory, uint8 &willpower)
int64 PrepareCharacterForDelete(uint32 accountID, uint32 charID)
static const std::array< std::string, 28 > badWords
void SetCurrentShip(uint32 charID, uint32 shipID)
bool SavePausedSkillQueue(uint32 charID, SkillQueue &queue)
const char * c_str() const
void VisitSystem(uint32 solarSystemID, uint32 charID)
#define codelog(type, fmt,...)
static uint8 GetSkillLevel(uint32 charID, uint16 skillTypeID)
void SetBlockContact(uint32 charID, uint32 ownerID, bool blocked)
PyObject * DBResultToRowset(DBQueryResult &result)
static PyRep * ListStationBlueprintItems(uint32 ownerID, uint32 stationID, bool forCorp=false)
uint32 locationID() const
bool GetCareerBySchool(uint32 schoolID, uint8 &raceID, uint32 &careerID)
static bool GetActiveCloneID(uint32 charID, uint32 &itemID)
static uint32 GetCorpID(uint32 charID)
Python object "ccp_exceptions.UserError".
PyRep * GetLabels(uint32 charID)
void AddBounty(uint32 charID, uint32 ownerID, uint32 amount)
bool GetSkillsByRace(uint32 raceID, std::map< uint32, uint8 > &into)
void EditLabel(uint32 charID, uint32 labelID, uint32 color, std::string name)
PyRep * GetContacts(uint32 charID, bool blocked)
PyRep * GetOwnerNote(uint32 charID, uint32 noteID)
bool LoadPausedSkillQueue(uint32 charID, SkillQueue &into)
PyRep * GetCharPublicInfo3(uint32 charID)
PyObject * DBResultToIndexRowset(DBQueryResult &result, const char *key)
uint32 AddOwnerNote(uint32 charID, const std::string &label, const std::string &content)
static int64 GetCorpRole(uint32 charID)
bool GetActiveCloneType(uint32 charID, uint32 &typeID)
void SetAvatarSculpts(uint32 charID, PyRep *sculptLocationID, PyRep *weightUpDown, PyRep *weightLeftRight, PyRep *weightForwardBack)
void SetPortraitInfo(uint32 charID, PortraitInfo &data)
static PyRep * ListStationItems(uint32 ownerID, uint32 stationID)
void SetLogInTime(uint32 charID)
std::string GetCharName(uint32 charID)
static void GetCharacterData(uint32 charID, std::map< std::string, int64 > &characterDataMap)
void SetLabel(uint32 charID, uint32 color, std::string name)
void RemoveContact(uint32 charID, uint32 ownerID)
void SetAvatar(uint32 charID, PyRep *hairDarkness)
bool GetBaseSkills(std::map< uint32, uint8 > &into)
static uint32 NewCharacter(const CharacterData &data, const CorpData &corpData)
std::vector< QueuedSkill > SkillQueue
bool ReportRespec(uint32 characterId)
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
static void AddEmployment(uint32 charID, uint32 corpID, uint32 oldCorpID=0)
PyRep * ValidateCharNameRep(std::string name)
bool GetSkillsByCareer(uint32 careerID, std::map< uint32, uint8 > &into)
PyPackedRow * DBRowToPackedRow(DBResultRow &row)
bool GetCorporationBySchool(uint32 schoolID, uint32 &corporationID)
PyObject * DBRowToKeyVal(DBResultRow &row)
int64 grantableRolesAtBase
void SetCurrentPod(uint32 charID, uint32 podID)
int64 GetInt64(uint32 index) const
int64 grantableRolesAtOther
static void SetCorpRole(uint32 charID, int64 role)
static PyRep * List(uint32 ownerID)
void DeleteLabel(uint32 charID, uint32 labelID)
bool GetLocationCorporationByCareer(CharacterData &cdata, uint32 &corporationID)
PyString * GetNote(uint32 ownerID, uint32 itemID)
void SetItemString(const char *key, PyRep *value)
SetItemString adds or sets a database entry.
uint32 careerSpecialityID
bool ChangeCloneType(uint32 charID, uint32 typeID)
bool icontains(std::string data, std::string toSearch, size_t pos=0)
void ValidateCharName(std::string name)
void SaveSkillHistory(uint16 eventID, double logDate, uint32 characterID, uint32 skillTypeID, uint8 skillLevel, uint32 absolutePoints)