Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
ReferAFriendHandler.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#include "Log.h"
7#include "ObjectMgr.h"
8#include "Opcodes.h"
9#include "Player.h"
10#include "WorldSession.h"
11
13{
14 SF_LOG_DEBUG("network", "WORLD: CMSG_GRANT_LEVEL");
15
16 ObjectGuid guid;
17
18 recvData.ReadGuidMask(guid, 2, 1, 5, 3, 7, 4, 0, 6);
19 recvData.ReadGuidBytes(guid, 1, 4, 2, 7, 5, 3, 6, 0);
20
22
23 // check cheating
24 uint8 levels = _player->GetGrantableLevels();
25 uint8 error = 0;
26 if (!target)
28 else if (levels == 0)
30 else if (GetRecruiterId() != target->GetSession()->GetAccountId())
32 else if (target->GetTeamId() != _player->GetTeamId())
34 else if (target->getLevel() >= _player->getLevel())
38 else if (target->GetGroup() != _player->GetGroup())
40
41 if (error)
42 {
44 data << uint32(error);
46 data << target->GetName();
47
48 SendPacket(&data);
49 return;
50 }
51
53
54 data2.WriteGuidMask(guid, 6, 7, 2, 5, 3, 0, 1, 4);
55 data2.WriteGuidBytes(guid, 2, 5, 6, 7, 1, 4, 3, 0);
56
57 target->GetSession()->SendPacket(&data2);
58}
59
61{
62 SF_LOG_DEBUG("network", "WORLD: CMSG_ACCEPT_LEVEL_GRANT");
63
64 ObjectGuid guid;
65
66 recvData.ReadGuidMask(guid, 2, 7, 5, 4, 3, 0, 1, 6);
67 recvData.ReadGuidBytes(guid, 5, 3, 2, 7, 4, 1, 0, 6);
68
70 if (!(other && other->GetSession()))
71 return;
72
73 if (GetAccountId() != other->GetSession()->GetRecruiterId())
74 return;
75
76 if (other->GetGrantableLevels())
77 other->SetGrantableLevels(other->GetGrantableLevels() - 1);
78 else
79 return;
80
81 _player->GiveLevel(_player->getLevel() + 1);
82}
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
#define SF_LOG_DEBUG(filterType__,...)
Definition Log.h:134
@ ERR_REFER_A_FRIEND_TARGET_TOO_HIGH
Definition Player.h:964
@ ERR_REFER_A_FRIEND_DIFFERENT_FACTION
Definition Player.h:967
@ ERR_REFER_A_FRIEND_NO_TARGET
Definition Player.h:970
@ ERR_REFER_A_FRIEND_INSUFFICIENT_GRANTABLE_LEVELS
Definition Player.h:965
@ ERR_REFER_A_FRIEND_NOT_REFERRED_BY
Definition Player.h:963
@ ERR_REFER_A_FRIEND_NOT_IN_GROUP
Definition Player.h:971
@ ERR_REFER_A_FRIEND_GRANT_LEVEL_MAX_I
Definition Player.h:969
void WriteGuidBytes(const ObjectGuid &guid, Offsets... offsets)
Definition ByteBuffer.h:264
void WriteGuidMask(const ObjectGuid &guid, Offsets... offsets)
Definition ByteBuffer.h:248
void ReadGuidBytes(ObjectGuid &guid, Offsets... offsets)
Definition ByteBuffer.h:256
void ReadGuidMask(ObjectGuid &guid, Offsets... offsets)
Definition ByteBuffer.h:240
static T * GetObjectInWorld(uint64 guid, T *)
uint8 GetGrantableLevels() const
Definition Player.h:2546
void SetGrantableLevels(uint8 val)
Definition Player.h:2550
WorldSession * GetSession() const
Definition Player.h:2417
TeamId GetTeamId() const
Definition Player.h:2531
Group * GetGroup()
Definition Player.h:2972
uint8 getLevel() const
Definition Unit.h:1528
std::string const & GetName() const
Definition Object.h:664
uint32 GetRecruiterId() const
void HandleAcceptGrantLevel(WorldPacket &recvData)
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
uint32 GetAccountId() const
Player * _player
void HandleGrantLevel(WorldPacket &recvData)
@ SMSG_REFER_A_FRIEND_FAILURE
Definition Opcodes.h:932
@ SMSG_PROPOSE_LEVEL_GRANT
Definition Opcodes.h:890
#define sWorld
Definition World.h:910
@ CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL
Definition World.h:240