Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Convert LeaderboardManager to use BitStream refs #1469

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions dGame/LeaderboardManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion dGame/LeaderboardManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Leaderboard {
*
* 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
Expand Down
2 changes: 1 addition & 1 deletion dGame/dGameMessages/GameMessages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1665,7 +1665,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;
}

Expand Down
Loading