aboutsummaryrefslogtreecommitdiff
path: root/src/game/GlobalEvents.cpp
diff options
context:
space:
mode:
authormaximius <none@none>2009-10-17 15:51:44 -0700
committermaximius <none@none>2009-10-17 15:51:44 -0700
commite585187b248f48b3c6e9247b49fa07c6565d65e5 (patch)
tree637c5b7ddacf41040bef4ea4f75a97da64c6a9bc /src/game/GlobalEvents.cpp
parent26b5e033ffde3d161382fc9addbfa99738379641 (diff)
*Backed out changeset 3be01fb200a5
--HG-- branch : trunk
Diffstat (limited to 'src/game/GlobalEvents.cpp')
-rw-r--r--src/game/GlobalEvents.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/game/GlobalEvents.cpp b/src/game/GlobalEvents.cpp
index 25fd4550d40..a544113f5c8 100644
--- a/src/game/GlobalEvents.cpp
+++ b/src/game/GlobalEvents.cpp
@@ -17,9 +17,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
/** \file
\ingroup world
*/
+
#include "Log.h"
#include "Database/DatabaseEnv.h"
#include "Database/DatabaseImpl.h"
@@ -29,10 +31,12 @@
#include "GlobalEvents.h"
#include "ObjectDefines.h"
#include "Corpse.h"
+
static void CorpsesEraseCallBack(QueryResult *result, bool bones)
{
if(!result)
return;
+
do
{
Field *fields = result->Fetch();
@@ -41,8 +45,11 @@ static void CorpsesEraseCallBack(QueryResult *result, bool bones)
float positionY = fields[2].GetFloat();
uint32 mapid = fields[3].GetUInt32();
uint64 player_guid = MAKE_NEW_GUID(fields[4].GetUInt32(), 0, HIGHGUID_PLAYER);
+
uint64 guid = MAKE_NEW_GUID(guidlow, 0, HIGHGUID_CORPSE);
+
sLog.outDebug("[Global event] Removing %s %u (X:%f Y:%f Map:%u).",(bones?"bones":"corpse"),guidlow,positionX,positionY,mapid);
+
/// Resurrectable - convert corpses to bones
if(!bones)
{
@@ -56,12 +63,15 @@ static void CorpsesEraseCallBack(QueryResult *result, bool bones)
///- or delete bones
{
MapManager::Instance().RemoveBonesFromMap(mapid, guid, positionX, positionY);
+
///- remove bones from the database
CharacterDatabase.PExecute("DELETE FROM corpse WHERE guid = '%u'",guidlow);
}
} while (result->NextRow());
+
delete result;
}
+
/// Handle periodic erase of corpses and bones
static void CorpsesErase(bool bones,uint32 delay)
{
@@ -69,6 +79,7 @@ static void CorpsesErase(bool bones,uint32 delay)
//No SQL injection (uint32 and enum)
CharacterDatabase.AsyncPQuery(&CorpsesEraseCallBack, bones, "SELECT guid,position_x,position_y,map,player FROM corpse WHERE UNIX_TIMESTAMP()-time > '%u' AND corpse_type %s '0'", delay, (bones ? "=" : "<>"));
}
+
/// not thread guarded variant for call from other thread
void CorpsesErase()
{