2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "WorldPacket.h"
21 #include "WorldSession.h"
24 #include "UpdateData.h"
27 void WorldSession::HandleDuelAcceptedOpcode(WorldPacket
& recvPacket
)
29 CHECK_PACKET_SIZE(recvPacket
,8);
35 if(!GetPlayer()->duel
) // ignore accept from duel-sender
41 plTarget
= pl
->duel
->opponent
;
43 if(pl
== pl
->duel
->initiator
|| !plTarget
|| pl
== plTarget
|| pl
->duel
->startTime
!= 0 || plTarget
->duel
->startTime
!= 0)
46 //sLog.outDebug( "WORLD: received CMSG_DUEL_ACCEPTED" );
47 DEBUG_LOG("Player 1 is: %u (%s)", pl
->GetGUIDLow(),pl
->GetName());
48 DEBUG_LOG("Player 2 is: %u (%s)", plTarget
->GetGUIDLow(),plTarget
->GetName());
50 time_t now
= time(NULL
);
51 pl
->duel
->startTimer
= now
;
52 plTarget
->duel
->startTimer
= now
;
54 WorldPacket
data(SMSG_DUEL_COUNTDOWN
, 4);
55 data
<< (uint32
)3000; // 3 seconds
56 pl
->GetSession()->SendPacket(&data
);
57 plTarget
->GetSession()->SendPacket(&data
);
60 void WorldSession::HandleDuelCancelledOpcode(WorldPacket
& recvPacket
)
62 CHECK_PACKET_SIZE(recvPacket
,8);
64 //sLog.outDebug( "WORLD: received CMSG_DUEL_CANCELLED" );
67 if(!GetPlayer()->duel
)
70 // player surrendered in a duel using /forfeit
71 if(GetPlayer()->duel
->startTime
!= 0)
73 GetPlayer()->CombatStopWithPets(true);
74 if(GetPlayer()->duel
->opponent
)
75 GetPlayer()->duel
->opponent
->CombatStopWithPets(true);
77 GetPlayer()->CastSpell(GetPlayer(), 7267, true); // beg
78 GetPlayer()->DuelComplete(DUEL_WON
);
82 // player either discarded the duel using the "discard button"
83 // or used "/forfeit" before countdown reached 0
87 GetPlayer()->DuelComplete(DUEL_INTERUPTED
);