mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-08 17:28: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();
|
||||
}
|
||||
|
||||
void Leaderboard::Serialize(RakNet::BitStream* bitStream) const {
|
||||
bitStream->Write(gameID);
|
||||
bitStream->Write(infoType);
|
||||
void Leaderboard::Serialize(RakNet::BitStream& bitStream) const {
|
||||
bitStream.Write(gameID);
|
||||
bitStream.Write(infoType);
|
||||
|
||||
std::ostringstream leaderboard;
|
||||
|
||||
@ -64,12 +64,12 @@ void Leaderboard::Serialize(RakNet::BitStream* bitStream) const {
|
||||
|
||||
// Serialize the thing to a BitStream
|
||||
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.
|
||||
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);
|
||||
bitStream->Write0();
|
||||
bitStream->Write0();
|
||||
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);
|
||||
bitStream.Write0();
|
||||
bitStream.Write0();
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
void Serialize(RakNet::BitStream* bitStream) const;
|
||||
void Serialize(RakNet::BitStream& bitStream) const;
|
||||
|
||||
/**
|
||||
* 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(eGameMessageType::SEND_ACTIVITY_SUMMARY_LEADERBOARD_DATA);
|
||||
|
||||
leaderboard->Serialize(&bitStream);
|
||||
leaderboard->Serialize(bitStream);
|
||||
SEND_PACKET;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user