Removed DBCore::RunQuery

Converted last corpse.cpp function that mixed database code with corpse code
This commit is contained in:
Akkadius
2014-11-23 22:57:46 -06:00
parent c30850f00a
commit e4f45d7b35
6 changed files with 28 additions and 129 deletions
+16 -38
View File
@@ -344,8 +344,7 @@ Corpse::Corpse(Client* client, int32 in_rezexp) : Mob (
iter_queue it;
for(it=client->GetInv().cursor_begin(),i=8001; it!=client->GetInv().cursor_end(); ++it,i++) {
item = *it;
if((item && (!client->IsBecomeNPC())) || (item && client->IsBecomeNPC() && !item->GetItem()->NoRent))
{
if((item && (!client->IsBecomeNPC())) || (item && client->IsBecomeNPC() && !item->GetItem()->NoRent)) {
std::list<uint32> slot_list = MoveItemToCorpse(client, item, i);
removed_list.merge(slot_list);
cursor = true;
@@ -370,7 +369,7 @@ Corpse::Corpse(Client* client, int32 in_rezexp) : Mob (
++iter;
}
ss << ")";
database.RunQuery(ss.str().c_str(), ss.str().length());
database.QueryDatabase(ss.str().c_str());
}
if(cursor) { // all cursor items should be on corpse (client < SoF or RespawnFromHover = false)
@@ -1395,44 +1394,23 @@ void Corpse::AddLooter(Mob* who) {
}
}
void Corpse::LoadPlayerCorpseDecayTime(uint32 dbid){
if(!dbid)
void Corpse::LoadPlayerCorpseDecayTime(uint32 corpse_db_id){
if(!corpse_db_id)
return;
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
if (database.RunQuery(query, MakeAnyLenString(&query, "SELECT (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(time_of_death)) FROM character_corpses WHERE id=%d and not time_of_death=0", dbid), errbuf, &result)) {
safe_delete_array(query);
while ((row = mysql_fetch_row(result))) {
if(atoi(row[0]) > 0 && RuleI(Character, CorpseDecayTimeMS) > (atoi(row[0]) * 1000)) {
corpse_decay_timer.SetTimer(RuleI(Character, CorpseDecayTimeMS) - (atoi(row[0]) * 1000));
/*
if(RuleI(Character, CorpseResTimeMS) > (atoi(row[0]) * 1000)) {
corpse_res_timer.SetTimer(RuleI(Character, CorpseResTimeMS) - (atoi(row[0]) * 1000));
}
else {
corpse_res_timer.Disable();
can_rez = false;
}
*/
}
else {
corpse_decay_timer.SetTimer(2000);
//corpse_res_timer.SetTimer(300000);
}
if(atoi(row[0]) > 0 && RuleI(Zone, GraveyardTimeMS) > (atoi(row[0]) * 1000)) {
corpse_graveyard_timer.SetTimer(RuleI(Zone, GraveyardTimeMS) - (atoi(row[0]) * 1000));
}
else {
corpse_graveyard_timer.SetTimer(3000);
}
}
mysql_free_result(result);
uint32 active_corpse_decay_timer = database.GetCharacterCorpseDecayTimer(corpse_db_id);
if (active_corpse_decay_timer > 0 && RuleI(Character, CorpseDecayTimeMS) > (active_corpse_decay_timer * 1000)) {
corpse_decay_timer.SetTimer(RuleI(Character, CorpseDecayTimeMS) - (active_corpse_decay_timer * 1000));
}
else {
corpse_decay_timer.SetTimer(2000);
}
if (active_corpse_decay_timer > 0 && RuleI(Zone, GraveyardTimeMS) > (active_corpse_decay_timer * 1000)) {
corpse_graveyard_timer.SetTimer(RuleI(Zone, GraveyardTimeMS) - (active_corpse_decay_timer * 1000));
}
else {
corpse_graveyard_timer.SetTimer(3000);
}
else
safe_delete_array(query);
}
/*
+10
View File
@@ -3367,6 +3367,16 @@ uint32 ZoneDatabase::SendCharacterCorpseToGraveyard(uint32 dbid, uint32 zone_id,
return dbid;
}
uint32 ZoneDatabase::GetCharacterCorpseDecayTimer(uint32 corpse_db_id){
std::string query = StringFormat("SELECT(UNIX_TIMESTAMP() - UNIX_TIMESTAMP(time_of_death)) FROM `character_corpses` WHERE `id` = %d AND NOT `time_of_death` = 0", corpse_db_id);
auto results = QueryDatabase(query);
auto row = results.begin();
if (results.Success() && results.RowsAffected() != 0){
return atoll(row[0]);
}
return 0;
}
uint32 ZoneDatabase::UpdateCharacterCorpse(uint32 db_id, uint32 char_id, const char* char_name, uint32 zone_id, uint16 instance_id, PlayerCorpse_Struct* dbpc, float x, float y, float z, float heading, bool is_rezzed) {
std::string query = StringFormat("UPDATE `character_corpses` SET \n"
"`charname` = '%s',\n"
+1
View File
@@ -311,6 +311,7 @@ public:
bool UnburyCharacterCorpse(uint32 dbid, uint32 new_zoneid, uint16 dest_instanceid, float new_x, float new_y, float new_z, float new_heading);
bool LoadCharacterCorpses(uint32 iZoneID, uint16 iInstanceID);
bool DeleteGraveyard(uint32 zone_id, uint32 graveyard_id);
uint32 GetCharacterCorpseDecayTimer(uint32 corpse_db_id);
uint32 GetCharacterBuriedCorpseCount(uint32 char_id);
uint32 SendCharacterCorpseToGraveyard(uint32 dbid, uint32 zoneid, uint16 instanceid, float x, float y, float z, float heading);
uint32 CreateGraveyardRecord(uint32 graveyard_zoneid, float graveyard_x, float graveyard_y, float graveyard_z, float graveyard_heading);