Core/Misc: Fix a crash in CalendarMgr::AddAction and initialize some wild pointers.

This commit is contained in:
kaelima
2012-03-02 12:23:16 +01:00
parent 254256668b
commit 394dbf0cdc
3 changed files with 20 additions and 26 deletions
+5 -2
View File
@@ -375,7 +375,7 @@ void CalendarMgr::AddAction(CalendarAction const& action)
uint64 eventId = action.Invite.GetEventId(); uint64 eventId = action.Invite.GetEventId();
uint64 inviteId = action.Invite.GetInviteId(); uint64 inviteId = action.Invite.GetInviteId();
CalendarEvent* calendarEvent; CalendarEvent* calendarEvent = NULL;
if (action.GetInviteId() != action.Invite.GetInviteId()) if (action.GetInviteId() != action.Invite.GetInviteId())
calendarEvent = CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_MODERATOR); calendarEvent = CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_MODERATOR);
else else
@@ -395,7 +395,7 @@ void CalendarMgr::AddAction(CalendarAction const& action)
uint64 eventId = action.Invite.GetEventId(); uint64 eventId = action.Invite.GetEventId();
uint64 inviteId = action.Invite.GetInviteId(); uint64 inviteId = action.Invite.GetInviteId();
CalendarEvent* calendarEvent; CalendarEvent* calendarEvent = NULL;
if (action.GetInviteId() != action.Invite.GetInviteId()) if (action.GetInviteId() != action.Invite.GetInviteId())
calendarEvent = CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_OWNER); calendarEvent = CheckPermisions(eventId, action.GetPlayer(), action.GetInviteId(), CALENDAR_RANK_OWNER);
else else
@@ -420,6 +420,9 @@ void CalendarMgr::AddAction(CalendarAction const& action)
// already checked in CheckPermisions // already checked in CheckPermisions
CalendarInvite* invite = GetInvite(inviteId); CalendarInvite* invite = GetInvite(inviteId);
if (!invite)
return;
if (calendarEvent->GetCreatorGUID() == invite->GetInvitee()) if (calendarEvent->GetCreatorGUID() == invite->GetInvitee())
{ {
action.GetPlayer()->GetSession()->SendCalendarCommandResult(CALENDAR_ERROR_DELETE_CREATOR_FAILED); action.GetPlayer()->GetSession()->SendCalendarCommandResult(CALENDAR_ERROR_DELETE_CREATOR_FAILED);
+2 -13
View File
@@ -784,20 +784,9 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam
// last damage from duel opponent // last damage from duel opponent
if (duel_hasEnded) if (duel_hasEnded)
{ {
Player* he; Player* he = duel_wasMounted ? victim->GetCharmer()->ToPlayer() : victim->ToPlayer();
if (duel_wasMounted) ASSERT(he && he->duel);
{
ASSERT(victim->GetCharmer()->GetTypeId() == TYPEID_PLAYER);
he = victim->GetCharmer()->ToPlayer();
}
else
{
ASSERT(victim->GetTypeId() == TYPEID_PLAYER);
he = victim->ToPlayer();
}
ASSERT(he->duel);
if (duel_wasMounted) // In this case victim==mount if (duel_wasMounted) // In this case victim==mount
victim->SetHealth(1); victim->SetHealth(1);
+13 -11
View File
@@ -116,19 +116,21 @@ Map* MapInstanced::CreateInstanceForPlayer(const uint32 mapId, Player* player)
return NULL; return NULL;
Map* map = NULL; Map* map = NULL;
uint32 NewInstanceId = 0; // instanceId of the resulting map uint32 newInstanceId = 0; // instanceId of the resulting map
if (IsBattlegroundOrArena()) if (IsBattlegroundOrArena())
{ {
// instantiate or find existing bg map for player // instantiate or find existing bg map for player
// the instance id is set in battlegroundid // the instance id is set in battlegroundid
NewInstanceId = player->GetBattlegroundId(); newInstanceId = player->GetBattlegroundId();
if (!NewInstanceId) return NULL; if (!newInstanceId)
map = sMapMgr->FindMap(mapId, NewInstanceId); return NULL;
map = sMapMgr->FindMap(mapId, newInstanceId);
if (!map) if (!map)
{ {
if (Battleground* bg = player->GetBattleground()) if (Battleground* bg = player->GetBattleground())
map = CreateBattleground(NewInstanceId, bg); map = CreateBattleground(newInstanceId, bg);
else else
{ {
player->TeleportToBGEntryPoint(); player->TeleportToBGEntryPoint();
@@ -158,24 +160,24 @@ Map* MapInstanced::CreateInstanceForPlayer(const uint32 mapId, Player* player)
if (pSave) if (pSave)
{ {
// solo/perm/group // solo/perm/group
NewInstanceId = pSave->GetInstanceId(); newInstanceId = pSave->GetInstanceId();
map = FindInstanceMap(NewInstanceId); map = FindInstanceMap(newInstanceId);
// it is possible that the save exists but the map doesn't // it is possible that the save exists but the map doesn't
if (!map) if (!map)
map = CreateInstance(NewInstanceId, pSave, pSave->GetDifficulty()); map = CreateInstance(newInstanceId, pSave, pSave->GetDifficulty());
} }
else else
{ {
// if no instanceId via group members or instance saves is found // if no instanceId via group members or instance saves is found
// the instance will be created for the first time // 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()); 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 //Seems it is now possible, but I do not know if it should be allowed
//ASSERT(!FindInstanceMap(NewInstanceId)); //ASSERT(!FindInstanceMap(NewInstanceId));
map = FindInstanceMap(NewInstanceId); map = FindInstanceMap(newInstanceId);
if (!map) if (!map)
map = CreateInstance(NewInstanceId, NULL, diff); map = CreateInstance(newInstanceId, NULL, diff);
} }
} }