2010-10-07 15:35:36 +02:00
|
|
|
/*
|
2012-01-01 00:32:13 +01:00
|
|
|
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
|
2010-10-07 15:35:36 +02:00
|
|
|
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
|
* option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
|
* more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-10-02 16:23:55 -05:00
|
|
|
*/
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
#include "Common.h"
|
|
|
|
|
#include "WorldPacket.h"
|
|
|
|
|
#include "WorldSession.h"
|
|
|
|
|
#include "Log.h"
|
|
|
|
|
#include "Opcodes.h"
|
|
|
|
|
#include "UpdateData.h"
|
|
|
|
|
#include "Player.h"
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket)
|
|
|
|
|
{
|
|
|
|
|
uint64 guid;
|
2011-11-07 11:18:00 -06:00
|
|
|
Player* player;
|
2011-09-15 14:08:17 +02:00
|
|
|
Player* plTarget;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-09-05 14:54:19 +02:00
|
|
|
recvPacket >> guid;
|
|
|
|
|
|
2010-04-07 19:14:10 +02:00
|
|
|
if (!GetPlayer()->duel) // ignore accept from duel-sender
|
2008-10-02 16:23:55 -05:00
|
|
|
return;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-11-07 11:18:00 -06:00
|
|
|
player = GetPlayer();
|
|
|
|
|
plTarget = player->duel->opponent;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-11-07 11:18:00 -06:00
|
|
|
if (player == player->duel->initiator || !plTarget || player == plTarget || player->duel->startTime != 0 || plTarget->duel->startTime != 0)
|
2008-10-02 16:23:55 -05:00
|
|
|
return;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-02-20 20:16:34 +01:00
|
|
|
//sLog->outDebug(LOG_FILTER_PACKETIO, "WORLD: Received CMSG_DUEL_ACCEPTED");
|
2011-11-07 11:18:00 -06:00
|
|
|
sLog->outStaticDebug("Player 1 is: %u (%s)", player->GetGUIDLow(), player->GetName());
|
2011-04-29 20:47:02 +02:00
|
|
|
sLog->outStaticDebug("Player 2 is: %u (%s)", plTarget->GetGUIDLow(), plTarget->GetName());
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2009-12-24 10:20:15 +01:00
|
|
|
time_t now = time(NULL);
|
2011-11-07 11:18:00 -06:00
|
|
|
player->duel->startTimer = now;
|
2008-10-02 16:23:55 -05:00
|
|
|
plTarget->duel->startTimer = now;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-11-07 11:18:00 -06:00
|
|
|
player->SendDuelCountdown(3000);
|
2009-12-17 11:06:50 +01:00
|
|
|
plTarget->SendDuelCountdown(3000);
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
void WorldSession::HandleDuelCancelledOpcode(WorldPacket& recvPacket)
|
|
|
|
|
{
|
2011-09-05 14:54:19 +02:00
|
|
|
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_DUEL_CANCELLED");
|
|
|
|
|
uint64 guid;
|
|
|
|
|
recvPacket >> guid;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
// no duel requested
|
2010-04-07 19:14:10 +02:00
|
|
|
if (!GetPlayer()->duel)
|
2008-10-02 16:23:55 -05:00
|
|
|
return;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
// player surrendered in a duel using /forfeit
|
2010-04-07 19:14:10 +02:00
|
|
|
if (GetPlayer()->duel->startTime != 0)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
|
|
|
|
GetPlayer()->CombatStopWithPets(true);
|
2010-04-07 19:14:10 +02:00
|
|
|
if (GetPlayer()->duel->opponent)
|
2008-10-02 16:23:55 -05:00
|
|
|
GetPlayer()->duel->opponent->CombatStopWithPets(true);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-02-15 18:23:39 +01:00
|
|
|
GetPlayer()->CastSpell(GetPlayer(), 7267, true); // beg
|
2008-10-02 16:23:55 -05:00
|
|
|
GetPlayer()->DuelComplete(DUEL_WON);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2011-05-11 11:17:20 +06:00
|
|
|
GetPlayer()->DuelComplete(DUEL_INTERRUPTED);
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|