*Add some crash prevention checks.

--HG--
branch : trunk
This commit is contained in:
QAston
2009-08-03 12:52:31 +02:00
parent 71adccb1c7
commit 8777efd03c
10 changed files with 176 additions and 172 deletions
+3 -4
View File
@@ -182,7 +182,7 @@ bool Corpse::LoadFromDB(uint32 guid, QueryResult *result, uint32 InstanceId)
return true;
}*/
bool Corpse::LoadFromDB(uint32 guid, Field *fields, uint32 & mapId, uint32 & instanceId)
bool Corpse::LoadFromDB(uint32 guid, Field *fields)
{
// 0 1 2 3 4 5 6 7 8 9
//result = CharacterDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map,data,time,corpse_type,instance,phaseMask FROM corpse WHERE guid = '%u'",guid);
@@ -199,9 +199,8 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields, uint32 & mapId, uint32 & in
return false;
}
mapId = fields[4].GetUInt32();
SetMapId(mapId);
instanceId = fields[8].GetUInt32();
SetMapId(fields[4].GetUInt32());
SetInstanceId(fields[8].GetUInt32());
m_time = time_t(fields[6].GetUInt64());
m_type = CorpseType(fields[7].GetUInt32());
+5 -2
View File
@@ -62,15 +62,17 @@ class Corpse : public WorldObject
void SaveToDB();
//bool LoadFromDB(uint32 guid, QueryResult *result, uint32 InstanceId);
bool LoadFromDB(uint32 guid, Field *fields, uint32 & mapId, uint32 & instanceId);
bool LoadFromDB(uint32 guid, Field *fields);
void DeleteBonesFromWorld();
void DeleteFromDB();
void SetMap (Map * map) {WorldObject::SetMap(map); m_mapId = map->GetId();}
void SetMap (Map * map) {WorldObject::SetMap(map); m_mapId = map->GetId(); SetInstanceId(map->GetInstanceId());}
// Used to check object existence in unloaded grids
uint32 GetMapId() const {return m_mapId;}
void SetMapId (uint32 id) {m_mapId = id;}
uint32 GetInstanceId() const {return m_instanceId;}
void SetInstanceId (uint32 id) {m_instanceId = id;}
uint64 const& GetOwnerGUID() const { return GetUInt64Value(CORPSE_FIELD_OWNER); }
@@ -101,6 +103,7 @@ class Corpse : public WorldObject
time_t m_time;
GridPair m_grid; // gride for corpse position for fast search
uint32 m_mapId; // map id for fast corpse check at packet requests and in other situations with unloaded map of corpse.
uint32 m_instanceId;
};
#endif
+5 -1
View File
@@ -117,10 +117,14 @@ MapManager::_createBaseMap(uint32 id)
{
m = new MapInstanced(id, i_gridCleanUpDelay);
}
else
else if (entry)
{
m = new Map(id, i_gridCleanUpDelay, 0, 0);
}
else
{
assert(false);
}
i_maps[id] = m;
}
+5 -5
View File
@@ -66,8 +66,6 @@ void WorldSession::HandleMoveWorldportAckOpcode()
GetPlayer()->SetSemaphoreTeleportFar(false);
GetPlayer()->ResetMap();
// relocate the player to the teleport destination
Map * newMap = MapManager::Instance().CreateMap(loc.mapid, GetPlayer(), 0);
// the CanEnter checks are done in TeleporTo but conditions may change
@@ -75,19 +73,21 @@ void WorldSession::HandleMoveWorldportAckOpcode()
if (!newMap || !newMap->CanEnter(GetPlayer()))
{
sLog.outError("Map %d could not be created for player %d, porting player to homebind", loc.mapid, GetPlayer()->GetGUIDLow());
GetPlayer()->RelocateToHomebind(loc.mapid);
newMap = MapManager::Instance().CreateMap(loc.mapid, GetPlayer(), 0);
GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation());
return;
}
else
GetPlayer()->Relocate(loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation);
GetPlayer()->ResetMap();
GetPlayer()->SetMap(newMap);
GetPlayer()->SendInitialPacketsBeforeAddToMap();
if(!GetPlayer()->GetMap()->Add(GetPlayer()))
{
sLog.outError("WORLD: failed to teleport player %s (%d) to map %d because of unknown reason!", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.mapid);
assert(false);
GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation());
return;
}
// battleground state prepare (in case join to BG), at relogin/tele player not invited
+1 -1
View File
@@ -440,7 +440,7 @@ class TRINITY_DLL_SPEC WorldObject : public Object
void GetRandomPoint( float x, float y, float z, float distance, float &rand_x, float &rand_y, float &rand_z ) const;
virtual uint32 GetMapId() const { return m_currMap ? m_currMap->GetId() : 0; }
uint32 GetInstanceId() const { return m_currMap ? m_currMap->GetInstanceId() : 0; }
virtual uint32 GetInstanceId() const { return m_currMap ? m_currMap->GetInstanceId() : 0; }
virtual void SetPhaseMask(uint32 newPhaseMask, bool update);
uint32 GetPhaseMask() const { return m_phaseMask; }
+2 -2
View File
@@ -268,7 +268,7 @@ ObjectAccessor::RemoveCorpse(Corpse *corpse)
}
void
ObjectAccessor::AddCorpse(Corpse *corpse, uint32 mapId, uint32 instanceId)
ObjectAccessor::AddCorpse(Corpse *corpse)
{
assert(corpse && corpse->GetType() != CORPSE_BONES);
@@ -280,7 +280,7 @@ ObjectAccessor::AddCorpse(Corpse *corpse, uint32 mapId, uint32 instanceId)
CellPair cell_pair = Trinity::ComputeCellPair(corpse->GetPositionX(), corpse->GetPositionY());
uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
objmgr.AddCorpseCellData(mapId, cell_id, corpse->GetOwnerGUID(), instanceId);
objmgr.AddCorpseCellData(corpse->GetMapId(), cell_id, corpse->GetOwnerGUID(), corpse->GetInstanceId());
}
void
+1 -1
View File
@@ -229,7 +229,7 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor,
Corpse* GetCorpseForPlayerGUID(uint64 guid);
void RemoveCorpse(Corpse *corpse);
void AddCorpse(Corpse *corpse, uint32 mapId, uint32 instanceId);
void AddCorpse(Corpse *corpse);
void AddCorpsesToGrid(GridPair const& gridpair,GridType& grid,Map* map);
Corpse* ConvertCorpseForPlayer(uint64 player_guid, bool insignia = false);
+2 -4
View File
@@ -6483,16 +6483,14 @@ void ObjectMgr::LoadCorpses()
uint32 guid = fields[result->GetFieldCount()-1].GetUInt32();
uint32 mapId;
uint32 instanceId;
Corpse *corpse = new Corpse;
if(!corpse->LoadFromDB(guid,fields,mapId,instanceId))
if(!corpse->LoadFromDB(guid,fields))
{
delete corpse;
continue;
}
ObjectAccessor::Instance().AddCorpse(corpse,mapId,instanceId);
ObjectAccessor::Instance().AddCorpse(corpse);
++count;
}
+2 -2
View File
@@ -4359,7 +4359,7 @@ void Player::CreateCorpse()
corpse->SaveToDB();
// register for player, but not show
ObjectAccessor::Instance().AddCorpse(corpse, corpse->GetMapId(), corpse->GetInstanceId());
ObjectAccessor::Instance().AddCorpse(corpse);
}
void Player::SpawnCorpseBones()
@@ -19850,7 +19850,7 @@ bool Player::IsAtGroupRewardDistance(WorldObject const* pRewardSource) const
const WorldObject* player = GetCorpse();
if(!player || isAlive())
player = this;
if(player->GetMapId() != pRewardSource->GetMapId() || player->GetInstanceId() != pRewardSource->GetInstanceId())
return false;
+150 -150
View File
@@ -94,6 +94,156 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\framework__$(PlatformName)_$(ConfigurationName)"
IntermediateDirectory=".\framework__$(PlatformName)_$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
ManagedExtensions="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/Zl /MP"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\src\framework;..\..\dep\ACE_wrappers"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_SECURE_SCL=0"
StringPooling="true"
MinimalRebuild="false"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
EnableEnhancedInstructionSet="1"
RuntimeTypeInfo="true"
UsePrecompiledHeader="0"
PrecompiledHeaderFile=".\framework__$(PlatformName)_$(ConfigurationName)\framework.pch"
AssemblerListingLocation=".\framework__$(PlatformName)_$(ConfigurationName)\"
ObjectFile=".\framework__$(PlatformName)_$(ConfigurationName)\"
ProgramDataBaseFileName=".\framework__$(PlatformName)_$(ConfigurationName)\"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
CallingConvention="0"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile=".\framework__$(PlatformName)_$(ConfigurationName)\framework.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug_NoPCH|Win32"
OutputDirectory=".\framework__$(PlatformName)_$(ConfigurationName)"
IntermediateDirectory=".\framework__$(PlatformName)_$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
ManagedExtensions="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/Zl /MP"
Optimization="0"
AdditionalIncludeDirectories="..\..\src\framework;..\..\dep\ACE_wrappers"
PreprocessorDefinitions="WIN32;_DEBUG;TRINITY_DEBUG;_LIB"
MinimalRebuild="false"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
EnableFunctionLevelLinking="true"
RuntimeTypeInfo="true"
UsePrecompiledHeader="0"
PrecompiledHeaderFile=".\framework__$(PlatformName)_$(ConfigurationName)\framework.pch"
AssemblerListingLocation=".\framework__$(PlatformName)_$(ConfigurationName)\"
ObjectFile=".\framework__$(PlatformName)_$(ConfigurationName)\"
ProgramDataBaseFileName=".\framework__$(PlatformName)_$(ConfigurationName)\"
WarningLevel="3"
SuppressStartupBanner="true"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
CallingConvention="0"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile=".\framework__$(PlatformName)_$(ConfigurationName)\framework.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory=".\framework__$(PlatformName)_$(ConfigurationName)"
@@ -170,81 +320,6 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\framework__$(PlatformName)_$(ConfigurationName)"
IntermediateDirectory=".\framework__$(PlatformName)_$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
ManagedExtensions="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/Zl /MP"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\src\framework;..\..\dep\ACE_wrappers"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_SECURE_SCL=0"
StringPooling="true"
MinimalRebuild="false"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
EnableEnhancedInstructionSet="1"
RuntimeTypeInfo="true"
UsePrecompiledHeader="0"
PrecompiledHeaderFile=".\framework__$(PlatformName)_$(ConfigurationName)\framework.pch"
AssemblerListingLocation=".\framework__$(PlatformName)_$(ConfigurationName)\"
ObjectFile=".\framework__$(PlatformName)_$(ConfigurationName)\"
ProgramDataBaseFileName=".\framework__$(PlatformName)_$(ConfigurationName)\"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
CallingConvention="0"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile=".\framework__$(PlatformName)_$(ConfigurationName)\framework.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory=".\framework__$(PlatformName)_$(ConfigurationName)"
@@ -321,81 +396,6 @@
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug_NoPCH|Win32"
OutputDirectory=".\framework__$(PlatformName)_$(ConfigurationName)"
IntermediateDirectory=".\framework__$(PlatformName)_$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
ManagedExtensions="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/Zl /MP"
Optimization="0"
AdditionalIncludeDirectories="..\..\src\framework;..\..\dep\ACE_wrappers"
PreprocessorDefinitions="WIN32;_DEBUG;TRINITY_DEBUG;_LIB"
MinimalRebuild="false"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
EnableFunctionLevelLinking="true"
RuntimeTypeInfo="true"
UsePrecompiledHeader="0"
PrecompiledHeaderFile=".\framework__$(PlatformName)_$(ConfigurationName)\framework.pch"
AssemblerListingLocation=".\framework__$(PlatformName)_$(ConfigurationName)\"
ObjectFile=".\framework__$(PlatformName)_$(ConfigurationName)\"
ProgramDataBaseFileName=".\framework__$(PlatformName)_$(ConfigurationName)\"
WarningLevel="3"
SuppressStartupBanner="true"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
CallingConvention="0"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile=".\framework__$(PlatformName)_$(ConfigurationName)\framework.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug_NoPCH|x64"
OutputDirectory=".\framework__$(PlatformName)_$(ConfigurationName)"