blob: 68ea0024d1d5256e408d860f7bdd3ec619b138ae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
/*
* Copyright (C) 2008-2019 TrinityCore <https://www.trinitycore.org/>
*
* 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/>.
*/
#include "WorldSession.h"
#include "Log.h"
#include "ObjectAccessor.h"
#include "Player.h"
#include "World.h"
void WorldSession::HandleGrantLevel(WorldPacket& recvData)
{
TC_LOG_DEBUG("network", "WORLD: CMSG_GRANT_LEVEL");
ObjectGuid guid;
recvData >> guid.ReadAsPacked();
Player* target = ObjectAccessor::GetPlayer(*_player, guid);
// check cheating
uint8 levels = _player->GetGrantableLevels();
uint8 error = 0;
if (!target)
error = ERR_REFER_A_FRIEND_NO_TARGET;
else if (levels == 0)
error = ERR_REFER_A_FRIEND_INSUFFICIENT_GRANTABLE_LEVELS;
else if (GetRecruiterId() != target->GetSession()->GetAccountId())
error = ERR_REFER_A_FRIEND_NOT_REFERRED_BY;
else if (target->GetTeamId() != _player->GetTeamId())
error = ERR_REFER_A_FRIEND_DIFFERENT_FACTION;
else if (target->GetLevel() >= _player->GetLevel())
error = ERR_REFER_A_FRIEND_TARGET_TOO_HIGH;
else if (target->GetLevel() >= sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL))
error = ERR_REFER_A_FRIEND_GRANT_LEVEL_MAX_I;
else if (target->GetGroup() != _player->GetGroup())
error = ERR_REFER_A_FRIEND_NOT_IN_GROUP;
if (error)
{
WorldPacket data(SMSG_REFER_A_FRIEND_FAILURE, 24);
data << uint32(error);
if (error == ERR_REFER_A_FRIEND_NOT_IN_GROUP)
data << target->GetName();
SendPacket(&data);
return;
}
WorldPacket data2(SMSG_PROPOSE_LEVEL_GRANT, 8);
data2 << _player->GetPackGUID();
target->SendDirectMessage(&data2);
}
void WorldSession::HandleAcceptGrantLevel(WorldPacket& recvData)
{
TC_LOG_DEBUG("network", "WORLD: CMSG_ACCEPT_LEVEL_GRANT");
ObjectGuid guid;
recvData >> guid.ReadAsPacked();
Player* other = ObjectAccessor::GetPlayer(*_player, guid);
if (!(other && other->GetSession()))
return;
if (GetAccountId() != other->GetSession()->GetRecruiterId())
return;
if (other->GetGrantableLevels())
other->SetGrantableLevels(other->GetGrantableLevels() - 1);
else
return;
_player->GiveLevel(_player->GetLevel() + 1);
}
|