mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 22:58:34 +00:00
Merge branch 'master' of https://github.com/EQEmu/Server
This commit is contained in:
+976
-676
File diff suppressed because it is too large
Load Diff
+410
-2
@@ -93,13 +93,417 @@ struct ExtendedProfile_Struct;
|
||||
struct GuildMember_Struct;
|
||||
class PTimerList;
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
/* Conversion Structs */
|
||||
|
||||
namespace Convert {
|
||||
struct BindStruct {
|
||||
/*000*/ uint32 zoneId;
|
||||
/*004*/ float x;
|
||||
/*008*/ float y;
|
||||
/*012*/ float z;
|
||||
/*016*/ float heading;
|
||||
};
|
||||
struct Color_Struct
|
||||
{
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint8 blue;
|
||||
uint8 green;
|
||||
uint8 red;
|
||||
uint8 use_tint; // if there's a tint this is FF
|
||||
} rgb;
|
||||
uint32 color;
|
||||
};
|
||||
};
|
||||
struct AA_Array
|
||||
{
|
||||
uint32 AA;
|
||||
uint32 value;
|
||||
};
|
||||
struct SpellBuff_Struct
|
||||
{
|
||||
/*000*/ uint8 slotid; //badly named... seems to be 2 for a real buff, 0 otherwise
|
||||
/*001*/ uint8 level;
|
||||
/*002*/ uint8 bard_modifier;
|
||||
/*003*/ uint8 effect; //not real
|
||||
/*004*/ uint32 spellid;
|
||||
/*008*/ uint32 duration;
|
||||
/*012*/ uint32 counters;
|
||||
/*016*/ uint32 player_id; //'global' ID of the caster, for wearoff messages
|
||||
/*020*/
|
||||
};
|
||||
struct Tribute_Struct {
|
||||
uint32 tribute;
|
||||
uint32 tier;
|
||||
};
|
||||
struct Disciplines_Struct {
|
||||
uint32 values[MAX_PP_DISCIPLINES];
|
||||
};
|
||||
struct GroupLeadershipAA_Struct {
|
||||
union {
|
||||
struct {
|
||||
uint32 groupAAMarkNPC;
|
||||
uint32 groupAANPCHealth;
|
||||
uint32 groupAADelegateMainAssist;
|
||||
uint32 groupAADelegateMarkNPC;
|
||||
uint32 groupAA4;
|
||||
uint32 groupAA5;
|
||||
uint32 groupAAInspectBuffs;
|
||||
uint32 groupAA7;
|
||||
uint32 groupAASpellAwareness;
|
||||
uint32 groupAAOffenseEnhancement;
|
||||
uint32 groupAAManaEnhancement;
|
||||
uint32 groupAAHealthEnhancement;
|
||||
uint32 groupAAHealthRegeneration;
|
||||
uint32 groupAAFindPathToPC;
|
||||
uint32 groupAAHealthOfTargetsTarget;
|
||||
uint32 groupAA15;
|
||||
};
|
||||
uint32 ranks[MAX_GROUP_LEADERSHIP_AA_ARRAY];
|
||||
};
|
||||
};
|
||||
|
||||
struct RaidLeadershipAA_Struct {
|
||||
union {
|
||||
struct {
|
||||
uint32 raidAAMarkNPC;
|
||||
uint32 raidAANPCHealth;
|
||||
uint32 raidAADelegateMainAssist;
|
||||
uint32 raidAADelegateMarkNPC;
|
||||
uint32 raidAA4;
|
||||
uint32 raidAA5;
|
||||
uint32 raidAA6;
|
||||
uint32 raidAASpellAwareness;
|
||||
uint32 raidAAOffenseEnhancement;
|
||||
uint32 raidAAManaEnhancement;
|
||||
uint32 raidAAHealthEnhancement;
|
||||
uint32 raidAAHealthRegeneration;
|
||||
uint32 raidAAFindPathToPC;
|
||||
uint32 raidAAHealthOfTargetsTarget;
|
||||
uint32 raidAA14;
|
||||
uint32 raidAA15;
|
||||
};
|
||||
uint32 ranks[MAX_RAID_LEADERSHIP_AA_ARRAY];
|
||||
};
|
||||
};
|
||||
|
||||
struct LeadershipAA_Struct {
|
||||
union {
|
||||
struct {
|
||||
Convert::GroupLeadershipAA_Struct group;
|
||||
Convert::RaidLeadershipAA_Struct raid;
|
||||
};
|
||||
uint32 ranks[MAX_LEADERSHIP_AA_ARRAY];
|
||||
};
|
||||
};
|
||||
typedef struct
|
||||
{
|
||||
/*00*/ char Name[64];
|
||||
/*64*/ uint32 Level;
|
||||
/*68*/ uint32 Race;
|
||||
/*72*/ uint32 Class;
|
||||
/*76*/ uint32 Zone;
|
||||
/*80*/ uint32 Time;
|
||||
/*84*/ uint32 Points;
|
||||
/*88*/
|
||||
} PVPStatsEntry_Struct;
|
||||
struct BandolierItem_Struct {
|
||||
uint32 item_id;
|
||||
uint32 icon;
|
||||
char item_name[64];
|
||||
};
|
||||
struct Bandolier_Struct {
|
||||
char name[32];
|
||||
Convert::BandolierItem_Struct items[EmuConstants::BANDOLIER_SIZE];
|
||||
};
|
||||
struct PotionBelt_Struct {
|
||||
Convert::BandolierItem_Struct items[EmuConstants::POTION_BELT_SIZE];
|
||||
};
|
||||
struct SuspendedMinion_Struct
|
||||
{
|
||||
/*000*/ uint16 SpellID;
|
||||
/*002*/ uint32 HP;
|
||||
/*006*/ uint32 Mana;
|
||||
/*010*/ Convert::SpellBuff_Struct Buffs[BUFF_COUNT];
|
||||
/*510*/ uint32 Items[_MaterialCount];
|
||||
/*546*/ char Name[64];
|
||||
/*610*/
|
||||
};
|
||||
|
||||
struct PlayerProfile_Struct {
|
||||
/*0000*/ uint32 checksum; // Checksum from CRC32::SetEQChecksum
|
||||
/*0004*/ char name[64]; // Name of player sizes not right
|
||||
/*0068*/ char last_name[32]; // Last name of player sizes not right
|
||||
/*0100*/ uint32 gender; // Player Gender - 0 Male, 1 Female
|
||||
/*0104*/ uint32 race; // Player race
|
||||
/*0108*/ uint32 class_; // Player class
|
||||
/*0112*/ uint32 unknown0112; //
|
||||
/*0116*/ uint32 level; // Level of player (might be one byte)
|
||||
/*0120*/ Convert::BindStruct binds[5]; // Bind points (primary is first, home city is fifth)
|
||||
/*0220*/ uint32 deity; // deity
|
||||
/*0224*/ uint32 guild_id;
|
||||
/*0228*/ uint32 birthday; // characters bday
|
||||
/*0232*/ uint32 lastlogin; // last login or zone time
|
||||
/*0236*/ uint32 timePlayedMin; // in minutes
|
||||
/*0240*/ uint8 pvp;
|
||||
/*0241*/ uint8 level2; //no idea why this is here, but thats how it is on live
|
||||
/*0242*/ uint8 anon; // 2=roleplay, 1=anon, 0=not anon
|
||||
/*0243*/ uint8 gm;
|
||||
/*0244*/ uint8 guildrank;
|
||||
/*0245*/ uint8 guildbanker;
|
||||
/*0246*/ uint8 unknown0246[6]; //
|
||||
/*0252*/ uint32 intoxication;
|
||||
/*0256*/ uint32 spellSlotRefresh[MAX_PP_REF_MEMSPELL]; //in ms
|
||||
/*0292*/ uint32 abilitySlotRefresh;
|
||||
/*0296*/ uint8 haircolor; // Player hair color
|
||||
/*0297*/ uint8 beardcolor; // Player beard color
|
||||
/*0298*/ uint8 eyecolor1; // Player left eye color
|
||||
/*0299*/ uint8 eyecolor2; // Player right eye color
|
||||
/*0300*/ uint8 hairstyle; // Player hair style
|
||||
/*0301*/ uint8 beard; // Beard type
|
||||
/*0302*/ uint8 ability_time_seconds; //The following four spots are unknown right now.....
|
||||
/*0303*/ uint8 ability_number; //ability used
|
||||
/*0304*/ uint8 ability_time_minutes;
|
||||
/*0305*/ uint8 ability_time_hours; //place holder
|
||||
/*0306*/ uint8 unknown0306[6]; // @bp Spacer/Flag?
|
||||
/*0312*/ uint32 item_material[_MaterialCount]; // Item texture/material of worn/held items
|
||||
/*0348*/ uint8 unknown0348[44];
|
||||
/*0392*/ Convert::Color_Struct item_tint[_MaterialCount];
|
||||
/*0428*/ Convert::AA_Array aa_array[MAX_PP_AA_ARRAY];
|
||||
/*2348*/ float unknown2384; //seen ~128, ~47
|
||||
/*2352*/ char servername[32]; // length probably not right
|
||||
/*2384*/ char title[32]; // length might be wrong
|
||||
/*2416*/ char suffix[32]; // length might be wrong
|
||||
/*2448*/ uint32 guildid2; //
|
||||
/*2452*/ uint32 exp; // Current Experience
|
||||
/*2456*/ uint32 unknown2492;
|
||||
/*2460*/ uint32 points; // Unspent Practice points
|
||||
/*2464*/ uint32 mana; // current mana
|
||||
/*2468*/ uint32 cur_hp; // current hp
|
||||
/*2472*/ uint32 unknown2508; // 0x05
|
||||
/*2476*/ uint32 STR; // Strength
|
||||
/*2480*/ uint32 STA; // Stamina
|
||||
/*2484*/ uint32 CHA; // Charisma
|
||||
/*2488*/ uint32 DEX; // Dexterity
|
||||
/*2492*/ uint32 INT; // Intelligence
|
||||
/*2496*/ uint32 AGI; // Agility
|
||||
/*2500*/ uint32 WIS; // Wisdom
|
||||
/*2504*/ uint8 face; // Player face
|
||||
/*2505*/ uint8 unknown2541[47]; // ?
|
||||
/*2552*/ uint8 languages[MAX_PP_LANGUAGE];
|
||||
/*2580*/ uint8 unknown2616[4];
|
||||
/*2584*/ uint32 spell_book[MAX_PP_REF_SPELLBOOK];
|
||||
/*4504*/ uint8 unknown4540[128]; // Was [428] all 0xff
|
||||
/*4632*/ uint32 mem_spells[MAX_PP_REF_MEMSPELL];
|
||||
/*4668*/ uint8 unknown4704[32]; //
|
||||
/*4700*/ float y; // Player y position
|
||||
/*4704*/ float x; // Player x position
|
||||
/*4708*/ float z; // Player z position
|
||||
/*4712*/ float heading; // Direction player is facing
|
||||
/*4716*/ uint8 unknown4752[4]; //
|
||||
/*4720*/ int32 platinum; // Platinum Pieces on player
|
||||
/*4724*/ int32 gold; // Gold Pieces on player
|
||||
/*4728*/ int32 silver; // Silver Pieces on player
|
||||
/*4732*/ int32 copper; // Copper Pieces on player
|
||||
/*4736*/ int32 platinum_bank; // Platinum Pieces in Bank
|
||||
/*4740*/ int32 gold_bank; // Gold Pieces in Bank
|
||||
/*4744*/ int32 silver_bank; // Silver Pieces in Bank
|
||||
/*4748*/ int32 copper_bank; // Copper Pieces in Bank
|
||||
/*4752*/ int32 platinum_cursor; // Platinum on cursor
|
||||
/*4756*/ int32 gold_cursor; // Gold on cursor
|
||||
/*4760*/ int32 silver_cursor; // Silver on cursor
|
||||
/*4764*/ int32 copper_cursor; // Copper on cursor
|
||||
/*4768*/ int32 platinum_shared; // Platinum shared between characters
|
||||
/*4772*/ uint8 unknown4808[24];
|
||||
/*4796*/ uint32 skills[MAX_PP_SKILL]; // [400] List of skills // 100 dword buffer
|
||||
/*5196*/ uint8 unknown5132[184];
|
||||
/*5380*/ uint32 pvp2; //
|
||||
/*5384*/ uint32 unknown5420; //
|
||||
/*5388*/ uint32 pvptype; //
|
||||
/*5392*/ uint32 unknown5428; //
|
||||
/*5396*/ uint32 ability_down; // Guessing
|
||||
/*5400*/ uint8 unknown5436[8]; //
|
||||
/*5408*/ uint32 autosplit; //not used right now
|
||||
/*5412*/ uint8 unknown5448[8];
|
||||
/*5420*/ uint32 zone_change_count; // Number of times user has zoned in their career (guessing)
|
||||
/*5424*/ uint8 unknown5460[16]; //
|
||||
/*5440*/ uint32 drakkin_heritage; //
|
||||
/*5444*/ uint32 drakkin_tattoo; //
|
||||
/*5448*/ uint32 drakkin_details; //
|
||||
/*5452*/ uint32 expansions; // expansion setting, bit field of expansions avaliable
|
||||
/*5456*/ int32 toxicity; //from drinking potions, seems to increase by 3 each time you drink
|
||||
/*5460*/ char unknown5496[16]; //
|
||||
/*5476*/ int32 hunger_level;
|
||||
/*5480*/ int32 thirst_level;
|
||||
/*5484*/ uint32 ability_up;
|
||||
/*5488*/ char unknown5524[16];
|
||||
/*5504*/ uint16 zone_id; // Current zone of the player
|
||||
/*5506*/ uint16 zoneInstance; // Instance ID
|
||||
/*5508*/ Convert::SpellBuff_Struct buffs[BUFF_COUNT]; // Buffs currently on the player
|
||||
/*6008*/ char groupMembers[6][64];//
|
||||
/*6392*/ char unknown6428[656];
|
||||
/*7048*/ uint32 entityid;
|
||||
/*7052*/ uint32 leadAAActive;
|
||||
/*7056*/ uint32 unknown7092;
|
||||
/*7060*/ int32 ldon_points_guk; //client uses these as signed
|
||||
/*7064*/ int32 ldon_points_mir;
|
||||
/*7068*/ int32 ldon_points_mmc;
|
||||
/*7072*/ int32 ldon_points_ruj;
|
||||
/*7076*/ int32 ldon_points_tak;
|
||||
/*7080*/ int32 ldon_points_available;
|
||||
/*7084*/ int32 ldon_wins_guk;
|
||||
/*7088*/ int32 ldon_wins_mir;
|
||||
/*7092*/ int32 ldon_wins_mmc;
|
||||
/*7096*/ int32 ldon_wins_ruj;
|
||||
/*7100*/ int32 ldon_wins_tak;
|
||||
/*7104*/ int32 ldon_losses_guk;
|
||||
/*7108*/ int32 ldon_losses_mir;
|
||||
/*7112*/ int32 ldon_losses_mmc;
|
||||
/*7116*/ int32 ldon_losses_ruj;
|
||||
/*7120*/ int32 ldon_losses_tak;
|
||||
/*7124*/ uint8 unknown7160[72];
|
||||
/*7196*/ uint32 tribute_time_remaining; //in miliseconds
|
||||
/*7200*/ uint32 showhelm;
|
||||
/*7204*/ uint32 career_tribute_points;
|
||||
/*7208*/ uint32 unknown7244;
|
||||
/*7212*/ uint32 tribute_points;
|
||||
/*7216*/ uint32 unknown7252;
|
||||
/*7220*/ uint32 tribute_active; //1=active
|
||||
/*7224*/ Convert::Tribute_Struct tributes[EmuConstants::TRIBUTE_SIZE];
|
||||
/*7264*/ Convert::Disciplines_Struct disciplines;
|
||||
/*7664*/ uint32 recastTimers[MAX_RECAST_TYPES]; // Timers (GMT of last use)
|
||||
/*7744*/ char unknown7780[160];
|
||||
/*7904*/ uint32 endurance;
|
||||
/*7908*/ uint32 group_leadership_exp; //0-1000
|
||||
/*7912*/ uint32 raid_leadership_exp; //0-2000
|
||||
/*7916*/ uint32 group_leadership_points;
|
||||
/*7920*/ uint32 raid_leadership_points;
|
||||
/*7924*/ Convert::LeadershipAA_Struct leader_abilities;
|
||||
/*8052*/ uint8 unknown8088[132];
|
||||
/*8184*/ uint32 air_remaining;
|
||||
/*8188*/ uint32 PVPKills;
|
||||
/*8192*/ uint32 PVPDeaths;
|
||||
/*8196*/ uint32 PVPCurrentPoints;
|
||||
/*8200*/ uint32 PVPCareerPoints;
|
||||
/*8204*/ uint32 PVPBestKillStreak;
|
||||
/*8208*/ uint32 PVPWorstDeathStreak;
|
||||
/*8212*/ uint32 PVPCurrentKillStreak;
|
||||
/*8216*/ Convert::PVPStatsEntry_Struct PVPLastKill;
|
||||
/*8304*/ Convert::PVPStatsEntry_Struct PVPLastDeath;
|
||||
/*8392*/ uint32 PVPNumberOfKillsInLast24Hours;
|
||||
/*8396*/ Convert::PVPStatsEntry_Struct PVPRecentKills[50];
|
||||
/*12796*/ uint32 aapoints_spent;
|
||||
/*12800*/ uint32 expAA;
|
||||
/*12804*/ uint32 aapoints; //avaliable, unspent
|
||||
/*12808*/ uint8 unknown12844[36];
|
||||
/*12844*/ Convert::Bandolier_Struct bandoliers[EmuConstants::BANDOLIERS_COUNT];
|
||||
/*14124*/ uint8 unknown14160[4506];
|
||||
/*18630*/ Convert::SuspendedMinion_Struct SuspendedMinion; // No longer in use
|
||||
/*19240*/ uint32 timeentitledonaccount;
|
||||
/*19244*/ Convert::PotionBelt_Struct potionbelt; //there should be 3 more of these
|
||||
/*19532*/ uint8 unknown19568[8];
|
||||
/*19540*/ uint32 currentRadCrystals; // Current count of radiant crystals
|
||||
/*19544*/ uint32 careerRadCrystals; // Total count of radiant crystals ever
|
||||
/*19548*/ uint32 currentEbonCrystals;// Current count of ebon crystals
|
||||
/*19552*/ uint32 careerEbonCrystals; // Total count of ebon crystals ever
|
||||
/*19556*/ uint8 groupAutoconsent; // 0=off, 1=on
|
||||
/*19557*/ uint8 raidAutoconsent; // 0=off, 1=on
|
||||
/*19558*/ uint8 guildAutoconsent; // 0=off, 1=on
|
||||
/*19559*/ uint8 unknown19595[5]; // ***Placeholder (6/29/2005)
|
||||
/*19564*/ uint32 RestTimer;
|
||||
/*19568*/
|
||||
};
|
||||
|
||||
|
||||
namespace player_lootitem_temp
|
||||
{
|
||||
struct ServerLootItem_Struct_temp {
|
||||
uint32 item_id;
|
||||
int16 equipSlot;
|
||||
uint8 charges;
|
||||
uint16 lootslot;
|
||||
uint32 aug1;
|
||||
uint32 aug2;
|
||||
uint32 aug3;
|
||||
uint32 aug4;
|
||||
uint32 aug5;
|
||||
};
|
||||
}
|
||||
|
||||
struct DBPlayerCorpse_Struct_temp {
|
||||
uint32 crc;
|
||||
bool locked;
|
||||
uint32 itemcount;
|
||||
uint32 exp;
|
||||
float size;
|
||||
uint8 level;
|
||||
uint8 race;
|
||||
uint8 gender;
|
||||
uint8 class_;
|
||||
uint8 deity;
|
||||
uint8 texture;
|
||||
uint8 helmtexture;
|
||||
uint32 copper;
|
||||
uint32 silver;
|
||||
uint32 gold;
|
||||
uint32 plat;
|
||||
Color_Struct item_tint[9];
|
||||
uint8 haircolor;
|
||||
uint8 beardcolor;
|
||||
uint8 eyecolor1;
|
||||
uint8 eyecolor2;
|
||||
uint8 hairstyle;
|
||||
uint8 face;
|
||||
uint8 beard;
|
||||
uint32 drakkin_heritage;
|
||||
uint32 drakkin_tattoo;
|
||||
uint32 drakkin_details;
|
||||
player_lootitem_temp::ServerLootItem_Struct_temp items[0];
|
||||
};
|
||||
|
||||
namespace classic_db_temp {
|
||||
struct DBPlayerCorpse_Struct_temp {
|
||||
uint32 crc;
|
||||
bool locked;
|
||||
uint32 itemcount;
|
||||
uint32 exp;
|
||||
float size;
|
||||
uint8 level;
|
||||
uint8 race;
|
||||
uint8 gender;
|
||||
uint8 class_;
|
||||
uint8 deity;
|
||||
uint8 texture;
|
||||
uint8 helmtexture;
|
||||
uint32 copper;
|
||||
uint32 silver;
|
||||
uint32 gold;
|
||||
uint32 plat;
|
||||
Color_Struct item_tint[9];
|
||||
uint8 haircolor;
|
||||
uint8 beardcolor;
|
||||
uint8 eyecolor1;
|
||||
uint8 eyecolor2;
|
||||
uint8 hairstyle;
|
||||
uint8 face;
|
||||
uint8 beard;
|
||||
player_lootitem_temp::ServerLootItem_Struct_temp items[0];
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#pragma pack()
|
||||
|
||||
class Database : public DBcore {
|
||||
public:
|
||||
Database();
|
||||
Database(const char* host, const char* user, const char* passwd, const char* database,uint32 port);
|
||||
bool Connect(const char* host, const char* user, const char* passwd, const char* database,uint32 port);
|
||||
~Database();
|
||||
bool ThrowDBError(std::string ErrorMessage, std::string query_title, std::string query);
|
||||
|
||||
|
||||
/*
|
||||
@@ -221,7 +625,11 @@ public:
|
||||
void SetRaidGroupLeaderInfo(uint32 gid, uint32 rid);
|
||||
void ClearRaidLeader(uint32 gid = 0xFFFFFFFF, uint32 rid = 0);
|
||||
|
||||
bool CheckDatabaseConversions();
|
||||
/* Database Conversions*/
|
||||
bool CheckDatabaseConversions();
|
||||
bool CheckDatabaseConvertPPDeblob();
|
||||
bool CheckDatabaseConvertCorpseDeblob();
|
||||
bool CheckDatabaseConvertBotsPostPPDeblob();
|
||||
|
||||
/*
|
||||
* Database Variables
|
||||
|
||||
+11
-90
@@ -4,6 +4,7 @@
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <errmsg.h>
|
||||
#include <mysqld_error.h>
|
||||
@@ -113,6 +114,16 @@ MySQLRequestResult DBcore::QueryDatabase(const char* query, uint32 querylen, boo
|
||||
#ifdef _EQDEBUG
|
||||
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
|
||||
#endif
|
||||
|
||||
/* Implement Logging at the Root */
|
||||
if (mysql_errno(&mysql) > 0 && strlen(query) > 0){
|
||||
std::cout << "\n[MYSQL ERR] " << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << " [Query]: \n" << query << "\n" << std::endl;
|
||||
/* Write to log file */
|
||||
std::ofstream log("eqemu_query_error_log.txt", std::ios_base::app | std::ios_base::out);
|
||||
log << "[MYSQL ERR] " << mysql_error(&mysql) << "\n" << query << "\n";
|
||||
log.close();
|
||||
}
|
||||
|
||||
return MySQLRequestResult(nullptr, 0, 0, 0, 0, mysql_errno(&mysql),errorBuffer);
|
||||
|
||||
}
|
||||
@@ -126,7 +137,6 @@ MySQLRequestResult DBcore::QueryDatabase(const char* query, uint32 querylen, boo
|
||||
|
||||
MySQLRequestResult requestResult(res, (uint32)mysql_affected_rows(&mysql), rowCount, (uint32)mysql_field_count(&mysql), (uint32)mysql_insert_id(&mysql));
|
||||
|
||||
|
||||
#if DEBUG_MYSQL_QUERIES >= 1
|
||||
if (requestResult.Success())
|
||||
{
|
||||
@@ -145,95 +155,6 @@ MySQLRequestResult DBcore::QueryDatabase(const char* query, uint32 querylen, boo
|
||||
return requestResult;
|
||||
}
|
||||
|
||||
bool DBcore::RunQuery(const char* query, uint32 querylen, char* errbuf, MYSQL_RES** result, uint32* affected_rows, uint32* last_insert_id, uint32* errnum, bool retry) {
|
||||
if (errnum)
|
||||
*errnum = 0;
|
||||
if (errbuf)
|
||||
errbuf[0] = 0;
|
||||
bool ret = false;
|
||||
LockMutex lock(&MDatabase);
|
||||
if (pStatus != Connected)
|
||||
Open();
|
||||
|
||||
if (mysql_real_query(&mysql, query, querylen)) {
|
||||
if (mysql_errno(&mysql) == CR_SERVER_GONE_ERROR)
|
||||
pStatus = Error;
|
||||
if (mysql_errno(&mysql) == CR_SERVER_LOST || mysql_errno(&mysql) == CR_SERVER_GONE_ERROR) {
|
||||
if (retry) {
|
||||
std::cout << "Database Error: Lost connection, attempting to recover...." << std::endl;
|
||||
ret = RunQuery(query, querylen, errbuf, result, affected_rows, last_insert_id, errnum, false);
|
||||
if (ret)
|
||||
std::cout << "Reconnection to database successful." << std::endl;
|
||||
}
|
||||
else {
|
||||
pStatus = Error;
|
||||
if (errnum)
|
||||
*errnum = mysql_errno(&mysql);
|
||||
if (errbuf)
|
||||
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (errnum)
|
||||
*errnum = mysql_errno(&mysql);
|
||||
if (errbuf)
|
||||
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||
#ifdef _EQDEBUG
|
||||
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
|
||||
#endif
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (result && mysql_field_count(&mysql)) {
|
||||
*result = mysql_store_result(&mysql);
|
||||
#ifdef _EQDEBUG
|
||||
DBMemLeak::Alloc(*result, query);
|
||||
#endif
|
||||
}
|
||||
else if (result)
|
||||
*result = 0;
|
||||
if (affected_rows)
|
||||
*affected_rows = mysql_affected_rows(&mysql);
|
||||
if (last_insert_id)
|
||||
*last_insert_id = (uint32)mysql_insert_id(&mysql);
|
||||
if (result) {
|
||||
if (*result) {
|
||||
ret = true;
|
||||
}
|
||||
else {
|
||||
#ifdef _EQDEBUG
|
||||
std::cout << "DB Query Error: No Result" << std::endl;
|
||||
#endif
|
||||
if (errnum)
|
||||
*errnum = UINT_MAX;
|
||||
if (errbuf)
|
||||
strcpy(errbuf, "DBcore::RunQuery: No Result");
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
#if DEBUG_MYSQL_QUERIES >= 1
|
||||
if (ret) {
|
||||
std::cout << "query successful";
|
||||
if (result && (*result))
|
||||
std::cout << ", " << (int) mysql_num_rows(*result) << " rows returned";
|
||||
if (affected_rows)
|
||||
std::cout << ", " << (*affected_rows) << " rows affected";
|
||||
std::cout<< std::endl;
|
||||
}
|
||||
else {
|
||||
std::cout << "QUERY: query FAILED" << std::endl;
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
void DBcore::TransactionBegin() {
|
||||
QueryDatabase("START TRANSACTION");
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ public:
|
||||
DBcore();
|
||||
~DBcore();
|
||||
eStatus GetStatus() { return pStatus; }
|
||||
bool RunQuery(const char* query, uint32 querylen, char* errbuf = 0, MYSQL_RES** result = 0, uint32* affected_rows = 0, uint32* last_insert_id = 0, uint32* errnum = 0, bool retry = true);
|
||||
MySQLRequestResult QueryDatabase(const char* query, uint32 querylen, bool retryOnFailureOnce = true);
|
||||
MySQLRequestResult QueryDatabase(std::string query, bool retryOnFailureOnce = true);
|
||||
void TransactionBegin();
|
||||
|
||||
+11
-11
@@ -5209,17 +5209,17 @@ struct MercenaryMerchantResponse_Struct {
|
||||
};
|
||||
|
||||
struct ServerLootItem_Struct {
|
||||
uint32 item_id;
|
||||
int16 equipSlot;
|
||||
uint8 charges;
|
||||
uint16 lootslot;
|
||||
uint32 aug1;
|
||||
uint32 aug2;
|
||||
uint32 aug3;
|
||||
uint32 aug4;
|
||||
uint32 aug5;
|
||||
uint8 minlevel;
|
||||
uint8 maxlevel;
|
||||
uint32 item_id; // uint32 item_id;
|
||||
int16 equip_slot; // int16 equip_slot;
|
||||
uint16 charges; // uint8 charges;
|
||||
uint16 lootslot; // uint16 lootslot;
|
||||
uint32 aug_1; // uint32 aug_1;
|
||||
uint32 aug_2; // uint32 aug_2;
|
||||
uint32 aug_3; // uint32 aug_3;
|
||||
uint32 aug_4; // uint32 aug_4;
|
||||
uint32 aug_5; // uint32 aug_5;
|
||||
uint8 min_level; //
|
||||
uint8 max_level; //
|
||||
};
|
||||
|
||||
//Found in client near a ref to the string:
|
||||
|
||||
+10
-19
@@ -1215,11 +1215,11 @@ ItemInst* SharedDatabase::CreateBaseItem(const Item_Struct* item, int16 charges)
|
||||
}
|
||||
|
||||
int32 SharedDatabase::DeleteStalePlayerCorpses() {
|
||||
if(RuleB(Zone, EnableShadowrest))
|
||||
{
|
||||
std::string query = StringFormat("UPDATE player_corpses SET IsBurried = 1 WHERE IsBurried = 0 AND "
|
||||
"(UNIX_TIMESTAMP() - UNIX_TIMESTAMP(timeofdeath)) > %d AND NOT timeofdeath = 0",
|
||||
(RuleI(Character, CorpseDecayTimeMS) / 1000));
|
||||
if(RuleB(Zone, EnableShadowrest)) {
|
||||
std::string query = StringFormat(
|
||||
"UPDATE `character_corpses` SET `is_buried` = 1 WHERE `is_buried` = 0 AND "
|
||||
"(UNIX_TIMESTAMP() - UNIX_TIMESTAMP(time_of_death)) > %d AND NOT time_of_death = 0",
|
||||
(RuleI(Character, CorpseDecayTimeMS) / 1000));
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
return -1;
|
||||
@@ -1227,8 +1227,9 @@ int32 SharedDatabase::DeleteStalePlayerCorpses() {
|
||||
return results.RowsAffected();
|
||||
}
|
||||
|
||||
std::string query = StringFormat("DELETE FROM player_corpses WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(timeofdeath)) > %d "
|
||||
"AND NOT timeofdeath = 0", (RuleI(Character, CorpseDecayTimeMS) / 1000));
|
||||
std::string query = StringFormat(
|
||||
"DELETE FROM `character_corpses` WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(time_of_death)) > %d "
|
||||
"AND NOT time_of_death = 0", (RuleI(Character, CorpseDecayTimeMS) / 1000));
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
return -1;
|
||||
@@ -1236,16 +1237,6 @@ int32 SharedDatabase::DeleteStalePlayerCorpses() {
|
||||
return results.RowsAffected();
|
||||
}
|
||||
|
||||
int32 SharedDatabase::DeleteStalePlayerBackups() {
|
||||
// 1209600 seconds = 2 weeks
|
||||
const std::string query = "DELETE FROM player_corpses_backup WHERE (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(timeofdeath)) > 1209600";
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
return -1;
|
||||
|
||||
return results.RowsAffected();
|
||||
}
|
||||
|
||||
bool SharedDatabase::GetCommandSettings(std::map<std::string,uint8> &commands) {
|
||||
|
||||
const std::string query = "SELECT command, access FROM commands";
|
||||
@@ -1915,7 +1906,7 @@ const LootDrop_Struct* SharedDatabase::GetLootDrop(uint32 lootdrop_id) {
|
||||
|
||||
void SharedDatabase::LoadCharacterInspectMessage(uint32 character_id, InspectMessage_Struct* message) {
|
||||
std::string query = StringFormat("SELECT `inspect_message` FROM `character_inspect_messages` WHERE `id` = %u LIMIT 1", character_id);
|
||||
auto results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "SharedDatabase::LoadCharacterInspectMessage", query);
|
||||
auto results = QueryDatabase(query);
|
||||
auto row = results.begin();
|
||||
memcpy(message, "", sizeof(InspectMessage_Struct));
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
@@ -1925,7 +1916,7 @@ void SharedDatabase::LoadCharacterInspectMessage(uint32 character_id, InspectMes
|
||||
|
||||
void SharedDatabase::SaveCharacterInspectMessage(uint32 character_id, const InspectMessage_Struct* message) {
|
||||
std::string query = StringFormat("REPLACE INTO `character_inspect_messages` (id, inspect_message) VALUES (%u, '%s')", character_id, EscapeString(message->text).c_str());
|
||||
auto results = QueryDatabase(query); ThrowDBError(results.ErrorMessage(), "SharedDatabase::SaveCharacterInspectMessage", query);
|
||||
auto results = QueryDatabase(query);
|
||||
}
|
||||
|
||||
void SharedDatabase::GetBotInspectMessage(uint32 botid, InspectMessage_Struct* message) {
|
||||
|
||||
@@ -41,7 +41,6 @@ public:
|
||||
uint8 GetGMSpeed(uint32 account_id);
|
||||
bool SetHideMe(uint32 account_id, uint8 hideme);
|
||||
int32 DeleteStalePlayerCorpses();
|
||||
int32 DeleteStalePlayerBackups();
|
||||
void LoadCharacterInspectMessage(uint32 character_id, InspectMessage_Struct* message);
|
||||
void SaveCharacterInspectMessage(uint32 character_id, const InspectMessage_Struct* message);
|
||||
void GetBotInspectMessage(uint32 botid, InspectMessage_Struct* message);
|
||||
|
||||
Reference in New Issue
Block a user