SFMLHelper: Simplify 64-bit packet reading function and remove 64-bit write function
Now that SFML's packet class can properly handle 64-bit values, we don't need a helper function just to write values to the packets.
This commit is contained in:
parent
3130d388db
commit
d10a0b440f
|
@ -26,13 +26,8 @@ u32 PacketReadU32(sf::Packet& packet)
|
|||
|
||||
u64 PacketReadU64(sf::Packet& packet)
|
||||
{
|
||||
u32 low, high;
|
||||
packet >> low >> high;
|
||||
return low | (static_cast<u64>(high) << 32);
|
||||
}
|
||||
|
||||
void PacketWriteU64(sf::Packet& packet, const u64 value)
|
||||
{
|
||||
packet << static_cast<u32>(value) << static_cast<u32>(value >> 32);
|
||||
sf::Uint64 value;
|
||||
packet >> value;
|
||||
return value;
|
||||
}
|
||||
} // namespace Common
|
||||
|
|
|
@ -19,5 +19,4 @@ struct BigEndianValue;
|
|||
u16 PacketReadU16(sf::Packet& packet);
|
||||
u32 PacketReadU32(sf::Packet& packet);
|
||||
u64 PacketReadU64(sf::Packet& packet);
|
||||
void PacketWriteU64(sf::Packet& packet, u64 value);
|
||||
} // namespace Common
|
||||
|
|
|
@ -1769,11 +1769,11 @@ void NetPlayClient::SendTimeBase()
|
|||
|
||||
if (netplay_client->m_timebase_frame % 60 == 0)
|
||||
{
|
||||
u64 timebase = SystemTimers::GetFakeTimeBase();
|
||||
const sf::Uint64 timebase = SystemTimers::GetFakeTimeBase();
|
||||
|
||||
sf::Packet packet;
|
||||
packet << static_cast<MessageId>(NP_MSG_TIMEBASE);
|
||||
Common::PacketWriteU64(packet, timebase);
|
||||
packet << timebase;
|
||||
packet << netplay_client->m_timebase_frame;
|
||||
|
||||
netplay_client->SendAsync(std::move(packet));
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "Core/NetPlayServer.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cinttypes>
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
#include <memory>
|
||||
|
@ -989,7 +990,7 @@ bool NetPlayServer::StartGame()
|
|||
|
||||
m_first_pad_status_received.fill(false);
|
||||
|
||||
const u64 initial_rtc = GetInitialNetPlayRTC();
|
||||
const sf::Uint64 initial_rtc = GetInitialNetPlayRTC();
|
||||
|
||||
const std::string region = SConfig::GetDirectoryForRegion(
|
||||
SConfig::ToGameCubeRegion(m_dialog->FindGameFile(m_selected_game)->GetRegion()));
|
||||
|
@ -1052,7 +1053,7 @@ bool NetPlayServer::StartGame()
|
|||
spac << m_settings.m_ArbitraryMipmapDetectionThreshold;
|
||||
spac << m_settings.m_EnableGPUTextureDecoding;
|
||||
spac << m_settings.m_StrictSettingsSync;
|
||||
Common::PacketWriteU64(spac, initial_rtc);
|
||||
spac << initial_rtc;
|
||||
spac << m_settings.m_SyncSaveData;
|
||||
spac << region;
|
||||
|
||||
|
@ -1142,7 +1143,7 @@ bool NetPlayServer::SyncSaveData()
|
|||
else
|
||||
{
|
||||
// No file, so we'll say the size is 0
|
||||
Common::PacketWriteU64(pac, 0);
|
||||
pac << sf::Uint64{0};
|
||||
}
|
||||
|
||||
SendAsyncToClients(std::move(pac));
|
||||
|
@ -1201,7 +1202,7 @@ bool NetPlayServer::SyncSaveData()
|
|||
pac << true; // save exists
|
||||
|
||||
// Header
|
||||
Common::PacketWriteU64(pac, header->tid);
|
||||
pac << sf::Uint64{header->tid};
|
||||
pac << header->banner_size << header->permissions << header->unk1;
|
||||
for (size_t i = 0; i < header->md5.size(); i++)
|
||||
pac << header->md5[i];
|
||||
|
@ -1215,7 +1216,7 @@ bool NetPlayServer::SyncSaveData()
|
|||
<< bk_header->total_size;
|
||||
for (size_t i = 0; i < bk_header->unk3.size(); i++)
|
||||
pac << bk_header->unk3[i];
|
||||
Common::PacketWriteU64(pac, bk_header->tid);
|
||||
pac << sf::Uint64{bk_header->tid};
|
||||
for (size_t i = 0; i < bk_header->mac_address.size(); i++)
|
||||
pac << bk_header->mac_address[i];
|
||||
|
||||
|
@ -1252,8 +1253,8 @@ bool NetPlayServer::CompressFileIntoPacket(const std::string& file_path, sf::Pac
|
|||
return false;
|
||||
}
|
||||
|
||||
const u64 size = file.GetSize();
|
||||
Common::PacketWriteU64(packet, size);
|
||||
const sf::Uint64 size = file.GetSize();
|
||||
packet << size;
|
||||
|
||||
if (size == 0)
|
||||
return true;
|
||||
|
@ -1314,8 +1315,8 @@ bool NetPlayServer::CompressFileIntoPacket(const std::string& file_path, sf::Pac
|
|||
|
||||
bool NetPlayServer::CompressBufferIntoPacket(const std::vector<u8>& in_buffer, sf::Packet& packet)
|
||||
{
|
||||
const u64 size = in_buffer.size();
|
||||
Common::PacketWriteU64(packet, size);
|
||||
const sf::Uint64 size = in_buffer.size();
|
||||
packet << size;
|
||||
|
||||
if (size == 0)
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue