Skip to content

Commit

Permalink
[9650] Some corpse related clean ups.
Browse files Browse the repository at this point in the history
Old bones remove code anyway was dead, so remove it.

Signed-off-by: hunuza <hunuza@gmail.com>
  • Loading branch information
hunuza committed Mar 31, 2010
1 parent a7f642d commit b6128ce
Show file tree
Hide file tree
Showing 19 changed files with 34 additions and 207 deletions.
10 changes: 9 additions & 1 deletion src/game/Corpse.cpp
Expand Up @@ -267,4 +267,12 @@ bool Corpse::IsFriendlyTo( Unit const* unit ) const
return owner->IsFriendlyTo(unit);
else
return true;
}
}

bool Corpse::IsExpired(time_t t) const
{
if(m_type == CORPSE_BONES)
return m_time < t - 60*MINUTE;
else
return m_time < t - 3*DAY;
}
2 changes: 2 additions & 0 deletions src/game/Corpse.h
Expand Up @@ -91,6 +91,8 @@ class Corpse : public WorldObject
GridReference<Corpse> &GetGridRef() { return m_gridRef; }

bool isActiveObject() const { return false; }

bool IsExpired(time_t t) const;
private:
GridReference<Corpse> m_gridRef;

Expand Down
86 changes: 0 additions & 86 deletions src/game/GlobalEvents.cpp

This file was deleted.

29 changes: 0 additions & 29 deletions src/game/GlobalEvents.h

This file was deleted.

3 changes: 1 addition & 2 deletions src/game/Level2.cpp
Expand Up @@ -41,7 +41,6 @@
#include <iostream>
#include <fstream>
#include <map>
#include "GlobalEvents.h"

#include "TargetedMovementGenerator.h" // for HandleNpcUnFollowCommand

Expand Down Expand Up @@ -4200,7 +4199,7 @@ bool ChatHandler::LookupPlayerSearchCommand(QueryResult* result, int32 limit)
/// Triggering corpses expire check in world
bool ChatHandler::HandleServerCorpsesCommand(const char* /*args*/)
{
CorpsesErase();
sObjectAccessor.RemoveOldCorpses();
return true;
}

Expand Down
2 changes: 0 additions & 2 deletions src/game/Makefile.am
Expand Up @@ -124,8 +124,6 @@ libmangosgame_a_SOURCES = \
GameEventMgr.h \
GameObject.cpp \
GameObject.h \
GlobalEvents.cpp \
GlobalEvents.h \
GMTicketHandler.cpp \
GMTicketMgr.cpp \
GMTicketMgr.h \
Expand Down
36 changes: 0 additions & 36 deletions src/game/Map.cpp
Expand Up @@ -765,42 +765,6 @@ void Map::Remove(Player *player, bool remove)
DeleteFromWorld(player);
}

bool Map::RemoveBones(uint64 guid, float x, float y)
{
if (IsRemovalGrid(x, y))
{
Corpse* corpse = ObjectAccessor::GetCorpseInMap(guid,GetId());
if (!corpse)
return false;

CellPair p = MaNGOS::ComputeCellPair(x,y);
if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP )
{
sLog.outError("Map::RemoveBones: invalid coordinates supplied X:%f Y:%f grid cell [%u:%u]", x, y, p.x_coord, p.y_coord);
return false;
}

CellPair q = MaNGOS::ComputeCellPair(corpse->GetPositionX(),corpse->GetPositionY());
if(q.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || q.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP )
{
sLog.outError("Map::RemoveBones: object (GUID: %u TypeId: %u) has invalid coordinates X:%f Y:%f grid cell [%u:%u]", corpse->GetGUIDLow(), corpse->GetTypeId(), corpse->GetPositionX(), corpse->GetPositionY(), q.x_coord, q.y_coord);
return false;
}

int32 dx = int32(p.x_coord) - int32(q.x_coord);
int32 dy = int32(p.y_coord) - int32(q.y_coord);

if (dx <= -2 || dx >= 2 || dy <= -2 || dy >= 2)
return false;

if(corpse && corpse->GetTypeId() == TYPEID_CORPSE && corpse->GetType() == CORPSE_BONES)
corpse->DeleteBonesFromWorld();
else
return false;
}
return true;
}

template<class T>
void
Map::Remove(T *obj, bool remove)
Expand Down
2 changes: 0 additions & 2 deletions src/game/Map.h
Expand Up @@ -361,8 +361,6 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj

void AddObjectToRemoveList(WorldObject *obj);

virtual bool RemoveBones(uint64 guid, float x, float y);

void UpdateObjectVisibility(WorldObject* obj, Cell cell, CellPair cellpair);
void UpdatePlayerVisibility(Player* player, Cell cell, CellPair cellpair);
void UpdateObjectsVisibilityFor(Player* player, Cell cell, CellPair cellpair);
Expand Down
12 changes: 0 additions & 12 deletions src/game/MapInstanced.cpp
Expand Up @@ -76,18 +76,6 @@ void MapInstanced::RemoveAllObjectsInRemoveList()
Map::RemoveAllObjectsInRemoveList();
}

bool MapInstanced::RemoveBones(uint64 guid, float x, float y)
{
bool remove_result = false;

for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
{
remove_result = remove_result || i->second->RemoveBones(guid, x, y);
}

return remove_result || Map::RemoveBones(guid,x,y);
}

void MapInstanced::UnloadAll(bool pForce)
{
// Unload instanced maps
Expand Down
1 change: 0 additions & 1 deletion src/game/MapInstanced.h
Expand Up @@ -35,7 +35,6 @@ class MANGOS_DLL_DECL MapInstanced : public Map
// functions overwrite Map versions
void Update(const uint32&);
void RemoveAllObjectsInRemoveList();
bool RemoveBones(uint64 guid, float x, float y);
void UnloadAll(bool pForce);

Map* CreateInstance(const uint32 mapId, Player * player);
Expand Down
10 changes: 0 additions & 10 deletions src/game/MapManager.cpp
Expand Up @@ -249,16 +249,6 @@ void MapManager::DeleteInstance(uint32 mapid, uint32 instanceId)
((MapInstanced*)m)->DestroyInstance(instanceId);
}

void MapManager::RemoveBonesFromMap(uint32 mapid, uint64 guid, float x, float y)
{
bool remove_result = _createBaseMap(mapid)->RemoveBones(guid, x, y);

if (!remove_result)
{
sLog.outDebug("Bones %u not found in world. Delete from DB also.", GUID_LOPART(guid));
}
}

void
MapManager::Update(uint32 diff)
{
Expand Down
1 change: 0 additions & 1 deletion src/game/MapManager.h
Expand Up @@ -121,7 +121,6 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::
TransportMap m_TransportsByMap;

bool CanPlayerEnter(uint32 mapid, Player* player);
void RemoveBonesFromMap(uint32 mapid, uint64 guid, float x, float y);
uint32 GenerateInstanceId() { return ++i_MaxInstanceId; }
void InitMaxInstanceId();
void InitializeVisibilityDistanceInfo();
Expand Down
16 changes: 16 additions & 0 deletions src/game/ObjectAccessor.cpp
Expand Up @@ -258,6 +258,22 @@ ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia)
return bones;
}

void ObjectAccessor::RemoveOldCorpses()
{
time_t now = time(NULL);
Player2CorpsesMapType::iterator next;
for(Player2CorpsesMapType::iterator itr = i_player2corpse.begin(); itr != i_player2corpse.end(); itr = next)
{
next = itr;
++next;

if(!itr->second->IsExpired(now))
continue;

ConvertCorpseForPlayer(itr->first);
}
}

/// Define the static member of HashMapHolder

template <class T> UNORDERED_MAP< uint64, T* > HashMapHolder<T>::m_objectMap;
Expand Down
1 change: 1 addition & 0 deletions src/game/ObjectAccessor.h
Expand Up @@ -117,6 +117,7 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor,
void AddCorpse(Corpse* corpse);
void AddCorpsesToGrid(GridPair const& gridpair,GridType& grid,Map* map);
Corpse* ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia = false);
void RemoveOldCorpses();

// For call from Player/Corpse AddToWorld/RemoveFromWorld only
void AddObject(Corpse *object) { HashMapHolder<Corpse>::Insert(object); }
Expand Down
10 changes: 4 additions & 6 deletions src/game/World.cpp
Expand Up @@ -51,7 +51,6 @@
#include "BattleGroundMgr.h"
#include "TemporarySummon.h"
#include "VMapFactory.h"
#include "GlobalEvents.h"
#include "GameEventMgr.h"
#include "PoolManager.h"
#include "Database/DatabaseImpl.h"
Expand Down Expand Up @@ -894,8 +893,8 @@ void World::SetInitialWorldSettings()
uint32 realm_zone = getConfig(CONFIG_UINT32_REALM_ZONE);
loginDatabase.PExecute("UPDATE realmlist SET icon = %u, timezone = %u WHERE id = '%d'", server_type, realm_zone, realmID);

///- Remove the bones after a restart
CharacterDatabase.Execute("DELETE FROM corpse WHERE corpse_type = '0'");
///- Remove the bones (they should not exist in DB though) and old corpses after a restart
CharacterDatabase.PExecute("DELETE FROM corpse WHERE corpse_type = '0' OR time < (UNIX_TIMESTAMP()-'%u')", 3*DAY);

///- Load the DBC files
sLog.outString("Initialize data stores...");
Expand Down Expand Up @@ -1233,8 +1232,7 @@ void World::SetInitialWorldSettings()
m_timers[WUPDATE_AUCTIONS].SetInterval(MINUTE*IN_MILLISECONDS);
m_timers[WUPDATE_UPTIME].SetInterval(m_configUint32Values[CONFIG_UINT32_UPTIME_UPDATE]*MINUTE*IN_MILLISECONDS);
//Update "uptime" table based on configuration entry in minutes.
m_timers[WUPDATE_CORPSES].SetInterval(20*MINUTE*IN_MILLISECONDS);
//erase corpses every 20 minutes
m_timers[WUPDATE_CORPSES].SetInterval(3*HOUR*IN_MILLISECONDS);

//to set mailtimer to return mails every day between 4 and 5 am
//mailtimer is increased when updating auctions
Expand Down Expand Up @@ -1417,7 +1415,7 @@ void World::Update(uint32 diff)
{
m_timers[WUPDATE_CORPSES].Reset();

CorpsesErase();
sObjectAccessor.RemoveOldCorpses();
}

///- Process Game events when necessary
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9649"
#define REVISION_NR "9650"
#endif // __REVISION_NR_H__
2 changes: 0 additions & 2 deletions win/VC100/game.vcxproj
Expand Up @@ -394,7 +394,6 @@
<ClCompile Include="..\..\src\game\FollowerReference.cpp" />
<ClCompile Include="..\..\src\game\GameEventMgr.cpp" />
<ClCompile Include="..\..\src\game\GameObject.cpp" />
<ClCompile Include="..\..\src\game\GlobalEvents.cpp" />
<ClCompile Include="..\..\src\game\GMTicketHandler.cpp" />
<ClCompile Include="..\..\src\game\GMTicketMgr.cpp" />
<ClCompile Include="..\..\src\game\GossipDef.cpp" />
Expand Down Expand Up @@ -543,7 +542,6 @@
<ClInclude Include="..\..\src\game\Formulas.h" />
<ClInclude Include="..\..\src\game\GameEventMgr.h" />
<ClInclude Include="..\..\src\game\GameObject.h" />
<ClInclude Include="..\..\src\game\GlobalEvents.h" />
<ClInclude Include="..\..\src\game\GMTicketMgr.h" />
<ClInclude Include="..\..\src\game\GossipDef.h" />
<ClInclude Include="..\..\src\game\GridDefines.h" />
Expand Down
8 changes: 0 additions & 8 deletions win/VC80/game.vcproj
Expand Up @@ -1469,14 +1469,6 @@
RelativePath="..\..\src\game\DBCStructure.h"
>
</File>
<File
RelativePath="..\..\src\game\GlobalEvents.cpp"
>
</File>
<File
RelativePath="..\..\src\game\GlobalEvents.h"
>
</File>
<File
RelativePath="..\..\src\game\Opcodes.cpp"
>
Expand Down
8 changes: 0 additions & 8 deletions win/VC90/game.vcproj
Expand Up @@ -1470,14 +1470,6 @@
RelativePath="..\..\src\game\DBCStructure.h"
>
</File>
<File
RelativePath="..\..\src\game\GlobalEvents.cpp"
>
</File>
<File
RelativePath="..\..\src\game\GlobalEvents.h"
>
</File>
<File
RelativePath="..\..\src\game\Opcodes.cpp"
>
Expand Down

0 comments on commit b6128ce

Please sign in to comment.