Skip to content

Commit

Permalink
[12350] Calendar, correct a server freeze when gquit. Olso correct a …
Browse files Browse the repository at this point in the history
…memleak and optimise a little bit CalendarEventInvite handler by not send sql request when player is online to get his ignored char list.
  • Loading branch information
Cyberium committed Jan 31, 2013
1 parent 2de4e7f commit 1a191a2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/game/Calendar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,10 @@ void CalendarMgr::RemoveGuildCalendar(ObjectGuid const& playerGuid, uint32 Guild

// event not owned by playerGuid but an guild invite can still be found
if (event->GuildId != GuildId || !(event->IsGuildEvent() || event->IsGuildAnnouncement()))
{
++itr;
continue;
}

event->RemoveInviteByGuid(playerGuid);
++itr;
Expand Down
26 changes: 17 additions & 9 deletions src/game/CalendarHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recv_data)
ObjectGuid inviteeGuid;
uint32 inviteeTeam = 0;
uint32 inviteeGuildId = 0;
bool isIgnored = false;

recv_data >> eventId >> inviteId >> name >> isPreInvite >> isGuildEvent;

Expand All @@ -431,6 +432,8 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recv_data)
inviteeGuid = player->GetObjectGuid();
inviteeTeam = player->GetTeam();
inviteeGuildId = player->GetGuildId();
if (player->GetSocial()->HasIgnore(playerGuid))
isIgnored = true;
}
else
{
Expand All @@ -444,6 +447,15 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recv_data)
inviteeTeam = Player::TeamForRace(fields[1].GetUInt8());
inviteeGuildId = Player::GetGuildIdFromDB(inviteeGuid);
delete result;

result = CharacterDatabase.PQuery("SELECT flags FROM character_social WHERE guid = %u AND friend = %u", inviteeGuid.GetCounter(), playerGuid.GetCounter());
if (result)
{
Field* fields = result->Fetch();
if (fields[0].GetUInt8() & SOCIAL_FLAG_IGNORED)
isIgnored = true;
delete result;
}
}
}

Expand All @@ -453,20 +465,16 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recv_data)
return;
}

if (_player->GetTeam() != inviteeTeam && !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CALENDAR))
if (isIgnored)
{
sCalendarMgr.SendCalendarCommandResult(_player, CALENDAR_ERROR_NOT_ALLIED);
sCalendarMgr.SendCalendarCommandResult(_player, CALENDAR_ERROR_IGNORING_YOU_S, name.c_str());
return;
}

if (QueryResult* result = CharacterDatabase.PQuery("SELECT flags FROM character_social WHERE guid = %u AND friend = %u", inviteeGuid.GetCounter(), playerGuid.GetCounter()))
if (_player->GetTeam() != inviteeTeam && !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CALENDAR))
{
Field* fields = result->Fetch();
if (fields[0].GetUInt8() & SOCIAL_FLAG_IGNORED)
{
sCalendarMgr.SendCalendarCommandResult(_player, CALENDAR_ERROR_IGNORING_YOU_S, name.c_str());
return;
}
sCalendarMgr.SendCalendarCommandResult(_player, CALENDAR_ERROR_NOT_ALLIED);
return;
}

if (!isPreInvite)
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "12349"
#define REVISION_NR "12350"
#endif // __REVISION_NR_H__

0 comments on commit 1a191a2

Please sign in to comment.