mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-09 09:48:20 +00:00
chore: Convert LeaderboardManager to use BitStream refs (#1469)
This commit is contained in:
parent
27d20dd8fa
commit
9e0dd05d42
@ -43,9 +43,9 @@ inline void WriteLeaderboardRow(std::ostringstream& leaderboard, const uint32_t&
|
|||||||
leaderboard << "\nResult[0].Row[" << index << "]." << data->GetString();
|
leaderboard << "\nResult[0].Row[" << index << "]." << data->GetString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Leaderboard::Serialize(RakNet::BitStream* bitStream) const {
|
void Leaderboard::Serialize(RakNet::BitStream& bitStream) const {
|
||||||
bitStream->Write(gameID);
|
bitStream.Write(gameID);
|
||||||
bitStream->Write(infoType);
|
bitStream.Write(infoType);
|
||||||
|
|
||||||
std::ostringstream leaderboard;
|
std::ostringstream leaderboard;
|
||||||
|
|
||||||
@ -64,12 +64,12 @@ void Leaderboard::Serialize(RakNet::BitStream* bitStream) const {
|
|||||||
|
|
||||||
// Serialize the thing to a BitStream
|
// Serialize the thing to a BitStream
|
||||||
uint32_t leaderboardSize = leaderboard.tellp();
|
uint32_t leaderboardSize = leaderboard.tellp();
|
||||||
bitStream->Write<uint32_t>(leaderboardSize);
|
bitStream.Write<uint32_t>(leaderboardSize);
|
||||||
// Doing this all in 1 call so there is no possbility of a dangling pointer.
|
// Doing this all in 1 call so there is no possbility of a dangling pointer.
|
||||||
bitStream->WriteAlignedBytes(reinterpret_cast<const unsigned char*>(GeneralUtils::ASCIIToUTF16(leaderboard.str()).c_str()), leaderboardSize * sizeof(char16_t));
|
bitStream.WriteAlignedBytes(reinterpret_cast<const unsigned char*>(GeneralUtils::ASCIIToUTF16(leaderboard.str()).c_str()), leaderboardSize * sizeof(char16_t));
|
||||||
if (leaderboardSize > 0) bitStream->Write<uint16_t>(0);
|
if (leaderboardSize > 0) bitStream.Write<uint16_t>(0);
|
||||||
bitStream->Write0();
|
bitStream.Write0();
|
||||||
bitStream->Write0();
|
bitStream.Write0();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Leaderboard::QueryToLdf(std::unique_ptr<sql::ResultSet>& rows) {
|
void Leaderboard::QueryToLdf(std::unique_ptr<sql::ResultSet>& rows) {
|
||||||
|
@ -88,7 +88,7 @@ public:
|
|||||||
*
|
*
|
||||||
* Expensive! Leaderboards are very string intensive so be wary of performatnce calling this method.
|
* Expensive! Leaderboards are very string intensive so be wary of performatnce calling this method.
|
||||||
*/
|
*/
|
||||||
void Serialize(RakNet::BitStream* bitStream) const;
|
void Serialize(RakNet::BitStream& bitStream) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the leaderboard from the database based on the associated gameID
|
* Builds the leaderboard from the database based on the associated gameID
|
||||||
|
@ -1666,7 +1666,7 @@ void GameMessages::SendActivitySummaryLeaderboardData(const LWOOBJID& objectID,
|
|||||||
bitStream.Write(objectID);
|
bitStream.Write(objectID);
|
||||||
bitStream.Write(eGameMessageType::SEND_ACTIVITY_SUMMARY_LEADERBOARD_DATA);
|
bitStream.Write(eGameMessageType::SEND_ACTIVITY_SUMMARY_LEADERBOARD_DATA);
|
||||||
|
|
||||||
leaderboard->Serialize(&bitStream);
|
leaderboard->Serialize(bitStream);
|
||||||
SEND_PACKET;
|
SEND_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user