Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
BoostHandler.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 "CharacterBoost.h"
7#include "WorldSession.h"
8
9void WorldSession::SetBoosting(bool boost, bool saveToDB)
10{
11 m_hasBoost = boost;
12
13 if (!saveToDB)
14 return;
15
16 PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_BOOST);
17 stmt->setBool(0, boost);
18 stmt->setUInt32(1, _accountId);
19 LoginDatabase.Execute(stmt);
20}
21
22void WorldSession::SendBattlePayDistributionUpdate(uint64 playerGuid, int8 bonusId, int32 bonusFlag, int32 textId, std::string const& bonusText, std::string const& bonusText2)
23{
24 ObjectGuid guid = GUID_LOPART(playerGuid);
25 ObjectGuid guid2 = 0;
26
27 WorldPacket data(SMSG_BATTLE_PAY_DISTRIBUTION_UPDATE, 8 + 4 + 8 + bonusText.length() + bonusText2.length() + 8 + 1 + 4 + 4 + 8 + 4 + 4 + 4);
28 data.WriteGuidMask(guid2, 5, 0);
29 data.WriteBit(1); // HasBattlePayProduct
30 data.WriteBit(guid2[1]);
31 data.WriteGuidMask(guid, 4, 7, 0);
32 data.WriteBit(0); // Revoked
33 data.WriteGuidMask(guid, 1, 2);
34 // if (unkBool)
35 // {
36 data.WriteBits(1, 2);
37 data.WriteBits(0, 20);
38 data.WriteBit(1); // HasBattlepayDisplayInfo
39 // if (HasBattlepayDisplayInfo)
40 // {
41 data.WriteBits(0, 10);
42 data.WriteBit(0);
43 data.WriteBits(bonusText2.length(), 10);
44 data.WriteBit(0);
45 data.WriteBit(0);
46 data.WriteBits(bonusText.length(), 13);
47 data.WriteBit(0); // bool11
48 // }
49// }
50
51 data.WriteBit(guid2[7]);
52 data.WriteBit(guid[6]);
53 data.WriteBit(guid2[2]);
54 data.WriteBit(guid[5]);
55 data.WriteGuidMask(guid2, 3, 6);
56 data.WriteBit(guid[3]);
57 data.WriteBit(guid2[4]);
58 data.FlushBits();
59
60 // if (unkBool)
61 // {
62 data << int32(0);
63 data << int64(0);
64 data.WriteString(bonusText);
65 data.WriteString(bonusText2);
66 // if (bool11)
67 //data << int32(0);
68 data << int64(0);
69 data << int8(bonusId);
70 data << int32(0);
71 // }
72
73 data << int32(textId);
74 data.WriteByteSeq(guid[4]);
75 data << int64(0);
76 data.WriteGuidBytes(guid, 1, 5);
77 data.WriteGuidBytes(guid2, 2, 4, 1, 0);
78 data << int32(0);
79 data.WriteByteSeq(guid2[7]);
80 data.WriteGuidBytes(guid, 0, 7);
81 data << int32(0);
82 data << int32(bonusFlag);
83 data.WriteByteSeq(guid[6]);
84 data.WriteGuidBytes(guid2, 5, 6, 3);
85 data.WriteGuidBytes(guid, 3, 2);
86
87 SendPacket(&data);
88}
89
91{
92 if (!HasBoost())
93 {
94 SF_LOG_ERROR("network", "WorldSession::HandleBattleCharBoost called, but player has not allowed boost");
95 recvData.rfinish();
96 return;
97 }
98
99 ObjectGuid CharacterGUID, guid;
100 bool hasCharInfo = false;
101
102 recvData.read_skip<uint32>();
103 guid[1] = recvData.ReadBit();
104 CharacterGUID[0] = recvData.ReadBit();
105 recvData.ReadGuidMask(guid, 5, 4);
106 CharacterGUID[3] = recvData.ReadBit();
107 recvData.ReadGuidMask(guid, 6, 0);
108 CharacterGUID[5] = recvData.ReadBit();
109 recvData.ReadGuidMask(guid, 3, 7);
110 CharacterGUID[1] = recvData.ReadBit();
111 guid[2] = recvData.ReadBit();
112 CharacterGUID[2] = recvData.ReadBit();
113 hasCharInfo = !recvData.ReadBit();
114 recvData.ReadGuidMask(CharacterGUID, 7, 4, 6);
115
116 recvData.ReadByteSeq(CharacterGUID[2]);
117 recvData.ReadByteSeq(guid[0]);
118 recvData.ReadGuidBytes(CharacterGUID, 0, 7);
119 recvData.ReadByteSeq(guid[7]);
120 recvData.ReadByteSeq(CharacterGUID[3]);
121 recvData.ReadGuidBytes(guid, 6, 4, 5);
122 recvData.ReadGuidBytes(CharacterGUID, 1, 6, 4);
123 recvData.ReadGuidBytes(guid, 1, 2, 3);
124 recvData.ReadByteSeq(CharacterGUID[5]);
125
126 if (hasCharInfo)
127 {
128 uint32 charInfo;
129 recvData >> charInfo;
130
132 m_charBooster->SetBoostedCharInfo(CharacterGUID, CHARACTER_BOOST_ITEMS, (charInfo & CHARACTER_BOOST_SPEC_MASK), (charInfo & CHARACTER_BOOST_FACTION_ALLIANCE));
133
135
136 data.WriteGuidMask(CharacterGUID, 6, 2, 5, 4, 7, 0, 3, 1);
137 data.WriteGuidBytes(CharacterGUID, 4, 1, 6, 0, 7, 5, 2, 3);
138
139 SendPacket(&data);
140 }
141}
std::int32_t int32
Definition Define.h:73
std::uint32_t uint32
Definition Define.h:77
std::int8_t int8
Definition Define.h:75
std::uint64_t uint64
Definition Define.h:76
std::int64_t int64
Definition Define.h:72
#define SF_LOG_ERROR(filterType__,...)
Definition Log.h:143
@ LOGIN_UPD_ACCOUNT_BOOST
uint32 GUID_LOPART(uint64 x)
#define CHARACTER_BOOST_BONUS_TEXT2
@ CHARACTER_BOOST_CHOOSED
@ CHARACTER_BOOST
@ CHARACTER_BOOST_SPEC_MASK
@ CHARACTER_BOOST_FACTION_ALLIANCE
@ CHARACTER_BOOST_ITEMS
@ CHARACTER_BOOST_TEXT_ID
#define CHARACTER_BOOST_BONUS_TEXT
void WriteGuidBytes(const ObjectGuid &guid, Offsets... offsets)
Definition ByteBuffer.h:264
bool WriteBit(uint32 bit)
Definition ByteBuffer.h:164
void read_skip()
Definition ByteBuffer.h:502
void WriteGuidMask(const ObjectGuid &guid, Offsets... offsets)
Definition ByteBuffer.h:248
void WriteString(std::string const &str)
Definition ByteBuffer.h:578
void ReadGuidBytes(ObjectGuid &guid, Offsets... offsets)
Definition ByteBuffer.h:256
void ReadByteSeq(uint8 &b)
Definition ByteBuffer.h:215
void rfinish()
Definition ByteBuffer.h:478
void ReadGuidMask(ObjectGuid &guid, Offsets... offsets)
Definition ByteBuffer.h:240
void WriteBits(T value, size_t bits)
Definition ByteBuffer.h:192
void WriteByteSeq(uint8 b)
Definition ByteBuffer.h:227
void FlushBits()
Definition ByteBuffer.h:154
bool ReadBit()
Definition ByteBuffer.h:180
void setBool(const uint8 index, const bool value)
void setUInt32(const uint8 index, const uint32 value)
void SetBoosting(bool boost, bool saveToDB=true)
bool HasBoost() const
void HandleBattleCharBoost(WorldPacket &recvPacket)
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
CharacterBooster * m_charBooster
void SendBattlePayDistributionUpdate(uint64 playerGuid, int8 bonusId, int32 bonusFlag, int32 textId, std::string const &bonusText, std::string const &bonusText2)
@ SMSG_BATTLE_PAY_DISTRIBUTION_UPDATE
Definition Opcodes.h:552
@ SMSG_CHARACTER_UPGRADE_STARTED
Definition Opcodes.h:604
LoginDatabaseWorkerPool LoginDatabase
Definition Main.cpp:54