mirror of
https://github.com/DarkflameUniverse/DarkflameServer
synced 2024-08-30 18:43:58 +00:00
chore: Convert EchoSyncSkill to use BitStream references (#1473)
This commit is contained in:
parent
5c1ed332c4
commit
ab937055e7
@ -256,7 +256,7 @@ bool BehaviorContext::CalculateUpdate(const float deltaTime) {
|
|||||||
|
|
||||||
BitStreamUtils::WriteHeader(message, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
|
BitStreamUtils::WriteHeader(message, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
|
||||||
message.Write(this->originator);
|
message.Write(this->originator);
|
||||||
echo.Serialize(&message);
|
echo.Serialize(message);
|
||||||
|
|
||||||
Game::server->Send(&message, UNASSIGNED_SYSTEM_ADDRESS, true);
|
Game::server->Send(&message, UNASSIGNED_SYSTEM_ADDRESS, true);
|
||||||
}
|
}
|
||||||
|
@ -21,40 +21,40 @@ public:
|
|||||||
uiSkillHandle = _uiSkillHandle;
|
uiSkillHandle = _uiSkillHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
EchoSyncSkill(RakNet::BitStream* stream) : EchoSyncSkill() {
|
EchoSyncSkill(RakNet::BitStream& stream) : EchoSyncSkill() {
|
||||||
Deserialize(stream);
|
Deserialize(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
~EchoSyncSkill() {
|
~EchoSyncSkill() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Serialize(RakNet::BitStream* stream) {
|
void Serialize(RakNet::BitStream& stream) {
|
||||||
stream->Write(eGameMessageType::ECHO_SYNC_SKILL);
|
stream.Write(eGameMessageType::ECHO_SYNC_SKILL);
|
||||||
|
|
||||||
stream->Write(bDone);
|
stream.Write(bDone);
|
||||||
uint32_t sBitStreamLength = sBitStream.length();
|
uint32_t sBitStreamLength = sBitStream.length();
|
||||||
stream->Write(sBitStreamLength);
|
stream.Write(sBitStreamLength);
|
||||||
for (uint32_t k = 0; k < sBitStreamLength; k++) {
|
for (uint32_t k = 0; k < sBitStreamLength; k++) {
|
||||||
stream->Write(sBitStream[k]);
|
stream.Write(sBitStream[k]);
|
||||||
}
|
}
|
||||||
|
|
||||||
stream->Write(uiBehaviorHandle);
|
stream.Write(uiBehaviorHandle);
|
||||||
stream->Write(uiSkillHandle);
|
stream.Write(uiSkillHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Deserialize(RakNet::BitStream* stream) {
|
bool Deserialize(RakNet::BitStream& stream) {
|
||||||
stream->Read(bDone);
|
stream.Read(bDone);
|
||||||
|
|
||||||
uint32_t sBitStreamLength{};
|
uint32_t sBitStreamLength{};
|
||||||
stream->Read(sBitStreamLength);
|
stream.Read(sBitStreamLength);
|
||||||
for (unsigned int k = 0; k < sBitStreamLength; k++) {
|
for (unsigned int k = 0; k < sBitStreamLength; k++) {
|
||||||
unsigned char character;
|
unsigned char character;
|
||||||
stream->Read(character);
|
stream.Read(character);
|
||||||
sBitStream.push_back(character);
|
sBitStream.push_back(character);
|
||||||
}
|
}
|
||||||
|
|
||||||
stream->Read(uiBehaviorHandle);
|
stream.Read(uiBehaviorHandle);
|
||||||
stream->Read(uiSkillHandle);
|
stream.Read(uiSkillHandle);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
|||||||
echo.uiBehaviorHandle = sync.uiBehaviorHandle;
|
echo.uiBehaviorHandle = sync.uiBehaviorHandle;
|
||||||
echo.uiSkillHandle = sync.uiSkillHandle;
|
echo.uiSkillHandle = sync.uiSkillHandle;
|
||||||
|
|
||||||
echo.Serialize(&bitStreamLocal);
|
echo.Serialize(bitStreamLocal);
|
||||||
|
|
||||||
Game::server->Send(&bitStreamLocal, sysAddr, true);
|
Game::server->Send(&bitStreamLocal, sysAddr, true);
|
||||||
} break;
|
} break;
|
||||||
|
Loading…
Reference in New Issue
Block a user