mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 17:54:48 +01:00
Core/Misc: Fix a crash in CalendarMgr::AddAction and initialize some wild pointers.
This commit is contained in:
@@ -375,7 +375,7 @@ void CalendarMgr::AddAction(CalendarAction const& action)
|
||||
uint64 eventId = action.Invite.GetEventId();
|
||||
uint64 inviteId = action.Invite.GetInviteId();
|
||||
|
||||
CalendarEvent* calendarEvent;
|
||||
CalendarEvent* calendarEvent = NULL;
|
||||
if (action.GetInviteId() != action.Invite.GetInviteId())
|
||||
calendarEvent = CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_MODERATOR);
|
||||
else
|
||||
@@ -395,7 +395,7 @@ void CalendarMgr::AddAction(CalendarAction const& action)
|
||||
uint64 eventId = action.Invite.GetEventId();
|
||||
uint64 inviteId = action.Invite.GetInviteId();
|
||||
|
||||
CalendarEvent* calendarEvent;
|
||||
CalendarEvent* calendarEvent = NULL;
|
||||
if (action.GetInviteId() != action.Invite.GetInviteId())
|
||||
calendarEvent = CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_OWNER);
|
||||
else
|
||||
@@ -420,6 +420,9 @@ void CalendarMgr::AddAction(CalendarAction const& action)
|
||||
|
||||
// already checked in CheckPermisions
|
||||
CalendarInvite* invite = GetInvite(inviteId);
|
||||
if (!invite)
|
||||
return;
|
||||
|
||||
if (calendarEvent->GetCreatorGUID() == invite->GetInvitee())
|
||||
{
|
||||
action.GetPlayer()->GetSession()->SendCalendarCommandResult(CALENDAR_ERROR_DELETE_CREATOR_FAILED);
|
||||
|
||||
@@ -784,20 +784,9 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam
|
||||
// last damage from duel opponent
|
||||
if (duel_hasEnded)
|
||||
{
|
||||
Player* he;
|
||||
Player* he = duel_wasMounted ? victim->GetCharmer()->ToPlayer() : victim->ToPlayer();
|
||||
|
||||
if (duel_wasMounted)
|
||||
{
|
||||
ASSERT(victim->GetCharmer()->GetTypeId() == TYPEID_PLAYER);
|
||||
he = victim->GetCharmer()->ToPlayer();
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(victim->GetTypeId() == TYPEID_PLAYER);
|
||||
he = victim->ToPlayer();
|
||||
}
|
||||
|
||||
ASSERT(he->duel);
|
||||
ASSERT(he && he->duel);
|
||||
|
||||
if (duel_wasMounted) // In this case victim==mount
|
||||
victim->SetHealth(1);
|
||||
|
||||
@@ -116,19 +116,21 @@ Map* MapInstanced::CreateInstanceForPlayer(const uint32 mapId, Player* player)
|
||||
return NULL;
|
||||
|
||||
Map* map = NULL;
|
||||
uint32 NewInstanceId = 0; // instanceId of the resulting map
|
||||
uint32 newInstanceId = 0; // instanceId of the resulting map
|
||||
|
||||
if (IsBattlegroundOrArena())
|
||||
{
|
||||
// instantiate or find existing bg map for player
|
||||
// the instance id is set in battlegroundid
|
||||
NewInstanceId = player->GetBattlegroundId();
|
||||
if (!NewInstanceId) return NULL;
|
||||
map = sMapMgr->FindMap(mapId, NewInstanceId);
|
||||
newInstanceId = player->GetBattlegroundId();
|
||||
if (!newInstanceId)
|
||||
return NULL;
|
||||
|
||||
map = sMapMgr->FindMap(mapId, newInstanceId);
|
||||
if (!map)
|
||||
{
|
||||
if (Battleground* bg = player->GetBattleground())
|
||||
map = CreateBattleground(NewInstanceId, bg);
|
||||
map = CreateBattleground(newInstanceId, bg);
|
||||
else
|
||||
{
|
||||
player->TeleportToBGEntryPoint();
|
||||
@@ -158,24 +160,24 @@ Map* MapInstanced::CreateInstanceForPlayer(const uint32 mapId, Player* player)
|
||||
if (pSave)
|
||||
{
|
||||
// solo/perm/group
|
||||
NewInstanceId = pSave->GetInstanceId();
|
||||
map = FindInstanceMap(NewInstanceId);
|
||||
newInstanceId = pSave->GetInstanceId();
|
||||
map = FindInstanceMap(newInstanceId);
|
||||
// it is possible that the save exists but the map doesn't
|
||||
if (!map)
|
||||
map = CreateInstance(NewInstanceId, pSave, pSave->GetDifficulty());
|
||||
map = CreateInstance(newInstanceId, pSave, pSave->GetDifficulty());
|
||||
}
|
||||
else
|
||||
{
|
||||
// if no instanceId via group members or instance saves is found
|
||||
// the instance will be created for the first time
|
||||
NewInstanceId = sMapMgr->GenerateInstanceId();
|
||||
newInstanceId = sMapMgr->GenerateInstanceId();
|
||||
|
||||
Difficulty diff = player->GetGroup() ? player->GetGroup()->GetDifficulty(IsRaid()) : player->GetDifficulty(IsRaid());
|
||||
//Seems it is now possible, but I do not know if it should be allowed
|
||||
//ASSERT(!FindInstanceMap(NewInstanceId));
|
||||
map = FindInstanceMap(NewInstanceId);
|
||||
map = FindInstanceMap(newInstanceId);
|
||||
if (!map)
|
||||
map = CreateInstance(NewInstanceId, NULL, diff);
|
||||
map = CreateInstance(newInstanceId, NULL, diff);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user