Files
DarkflameServer/dGame/dGameMessages/SyncSkill.h
David Markowitz f5d33a773a fix: security fixes (#1974)
* fix: security fixes

dont print passwords for worlds
bound strings from clients
actually enable encryption between rakpeers
dont allow underflow when reading a string

Tested that packets are encrypted
tested that models can still be built
tested that combat still works

* add check

* use c++ nullptr instead of NULL

* initialize to 0

* globalize constant (should be in a namespace at least in the future)

* Update GameMessages.cpp

* check bounds
2026-05-17 14:21:22 -05:00

69 lines
1.5 KiB
C++

#ifndef __SYNCSKILL__H__
#define __SYNCSKILL__H__
#include <cstdint>
#include <string>
#include "BitStream.h"
#include "MessageType/Game.h"
/* Message to synchronize a skill cast */
class SyncSkill {
public:
SyncSkill() {
bDone = false;
}
SyncSkill(std::string _sBitStream, uint32_t _uiBehaviorHandle, uint32_t _uiSkillHandle, bool _bDone = false) {
bDone = _bDone;
sBitStream = _sBitStream;
uiBehaviorHandle = _uiBehaviorHandle;
uiSkillHandle = _uiSkillHandle;
}
SyncSkill(RakNet::BitStream& stream) : SyncSkill() {
Deserialize(stream);
}
~SyncSkill() {
}
void Serialize(RakNet::BitStream& stream) {
stream.Write(MessageType::Game::SYNC_SKILL);
stream.Write(bDone);
uint32_t sBitStreamLength = sBitStream.length();
stream.Write(sBitStreamLength);
for (unsigned int k = 0; k < sBitStreamLength; k++) {
stream.Write(sBitStream[k]);
}
stream.Write(uiBehaviorHandle);
stream.Write(uiSkillHandle);
}
bool Deserialize(RakNet::BitStream& stream) {
stream.Read(bDone);
uint32_t sBitStreamLength{};
stream.Read(sBitStreamLength);
if (sBitStreamLength > MAX_MESSAGE_LENGTH) return false;
for (uint32_t k = 0; k < sBitStreamLength; k++) {
unsigned char character;
stream.Read(character);
sBitStream.push_back(character);
}
stream.Read(uiBehaviorHandle);
stream.Read(uiSkillHandle);
return true;
}
bool bDone{};
std::string sBitStream{};
uint32_t uiBehaviorHandle{};
uint32_t uiSkillHandle{};
};
#endif //!__SYNCSKILL__H__