NetPlayProto: Turn MessageID enum into an enum class
Now we can leverage our helper to insert enum values without the need to cast.
This commit is contained in:
parent
07af775afa
commit
af4aaf4609
|
@ -313,143 +313,143 @@ static void ReceiveSyncIdentifier(sf::Packet& spac, SyncIdentifier& sync_identif
|
|||
// called from ---NETPLAY--- thread
|
||||
void NetPlayClient::OnData(sf::Packet& packet)
|
||||
{
|
||||
MessageId mid;
|
||||
MessageID mid;
|
||||
packet >> mid;
|
||||
|
||||
INFO_LOG_FMT(NETPLAY, "Got server message: {:x}", mid);
|
||||
|
||||
switch (mid)
|
||||
{
|
||||
case NP_MSG_PLAYER_JOIN:
|
||||
case MessageID::PlayerJoin:
|
||||
OnPlayerJoin(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_PLAYER_LEAVE:
|
||||
case MessageID::PlayerLeave:
|
||||
OnPlayerLeave(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_CHAT_MESSAGE:
|
||||
case MessageID::ChatMessage:
|
||||
OnChatMessage(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_CHUNKED_DATA_START:
|
||||
case MessageID::ChunkedDataStart:
|
||||
OnChunkedDataStart(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_CHUNKED_DATA_END:
|
||||
case MessageID::ChunkedDataEnd:
|
||||
OnChunkedDataEnd(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_CHUNKED_DATA_PAYLOAD:
|
||||
case MessageID::ChunkedDataPayload:
|
||||
OnChunkedDataPayload(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_CHUNKED_DATA_ABORT:
|
||||
case MessageID::ChunkedDataAbort:
|
||||
OnChunkedDataAbort(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_PAD_MAPPING:
|
||||
case MessageID::PadMapping:
|
||||
OnPadMapping(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_GBA_CONFIG:
|
||||
case MessageID::GBAConfig:
|
||||
OnGBAConfig(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_WIIMOTE_MAPPING:
|
||||
case MessageID::WiimoteMapping:
|
||||
OnWiimoteMapping(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_PAD_DATA:
|
||||
case MessageID::PadData:
|
||||
OnPadData(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_PAD_HOST_DATA:
|
||||
case MessageID::PadHostData:
|
||||
OnPadHostData(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_WIIMOTE_DATA:
|
||||
case MessageID::WiimoteData:
|
||||
OnWiimoteData(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_PAD_BUFFER:
|
||||
case MessageID::PadBuffer:
|
||||
OnPadBuffer(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_HOST_INPUT_AUTHORITY:
|
||||
case MessageID::HostInputAuthority:
|
||||
OnHostInputAuthority(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_GOLF_SWITCH:
|
||||
case MessageID::GolfSwitch:
|
||||
OnGolfSwitch(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_GOLF_PREPARE:
|
||||
case MessageID::GolfPrepare:
|
||||
OnGolfPrepare(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_CHANGE_GAME:
|
||||
case MessageID::ChangeGame:
|
||||
OnChangeGame(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_GAME_STATUS:
|
||||
case MessageID::GameStatus:
|
||||
OnGameStatus(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_START_GAME:
|
||||
case MessageID::StartGame:
|
||||
OnStartGame(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_STOP_GAME:
|
||||
case NP_MSG_DISABLE_GAME:
|
||||
case MessageID::StopGame:
|
||||
case MessageID::DisableGame:
|
||||
OnStopGame(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_POWER_BUTTON:
|
||||
case MessageID::PowerButton:
|
||||
OnPowerButton();
|
||||
break;
|
||||
|
||||
case NP_MSG_PING:
|
||||
case MessageID::Ping:
|
||||
OnPing(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_PLAYER_PING_DATA:
|
||||
case MessageID::PlayerPingData:
|
||||
OnPlayerPingData(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_DESYNC_DETECTED:
|
||||
case MessageID::DesyncDetected:
|
||||
OnDesyncDetected(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_SYNC_GC_SRAM:
|
||||
case MessageID::SyncGCSRAM:
|
||||
OnSyncGCSRAM(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_SYNC_SAVE_DATA:
|
||||
case MessageID::SyncSaveData:
|
||||
OnSyncSaveData(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_SYNC_CODES:
|
||||
case MessageID::SyncCodes:
|
||||
OnSyncCodes(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_COMPUTE_MD5:
|
||||
case MessageID::ComputeMD5:
|
||||
OnComputeMD5(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_MD5_PROGRESS:
|
||||
case MessageID::MD5Progress:
|
||||
OnMD5Progress(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_MD5_RESULT:
|
||||
case MessageID::MD5Result:
|
||||
OnMD5Result(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_MD5_ERROR:
|
||||
case MessageID::MD5Error:
|
||||
OnMD5Error(packet);
|
||||
break;
|
||||
|
||||
case NP_MSG_MD5_ABORT:
|
||||
case MessageID::MD5Abort:
|
||||
OnMD5Abort();
|
||||
break;
|
||||
|
||||
|
@ -547,7 +547,7 @@ void NetPlayClient::OnChunkedDataEnd(sf::Packet& packet)
|
|||
m_dialog->HideChunkedProgressDialog();
|
||||
|
||||
sf::Packet complete_packet;
|
||||
complete_packet << static_cast<MessageId>(NP_MSG_CHUNKED_DATA_COMPLETE);
|
||||
complete_packet << MessageID::ChunkedDataComplete;
|
||||
complete_packet << cid;
|
||||
Send(complete_packet, CHUNKED_DATA_CHANNEL);
|
||||
}
|
||||
|
@ -572,7 +572,7 @@ void NetPlayClient::OnChunkedDataPayload(sf::Packet& packet)
|
|||
m_dialog->SetChunkedProgress(m_local_player->pid, data_packet.getDataSize());
|
||||
|
||||
sf::Packet progress_packet;
|
||||
progress_packet << static_cast<MessageId>(NP_MSG_CHUNKED_DATA_PROGRESS);
|
||||
progress_packet << MessageID::ChunkedDataProgress;
|
||||
progress_packet << cid;
|
||||
progress_packet << sf::Uint64{data_packet.getDataSize()};
|
||||
Send(progress_packet, CHUNKED_DATA_CHANNEL);
|
||||
|
@ -731,13 +731,13 @@ void NetPlayClient::OnGolfSwitch(sf::Packet& packet)
|
|||
if (m_local_player->pid == previous_golfer)
|
||||
{
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(NP_MSG_GOLF_RELEASE);
|
||||
spac << MessageID::GolfRelease;
|
||||
Send(spac);
|
||||
}
|
||||
else if (m_local_player->pid == pid)
|
||||
{
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(NP_MSG_GOLF_ACQUIRE);
|
||||
spac << MessageID::GolfAcquire;
|
||||
Send(spac);
|
||||
|
||||
// Pads are already calibrated so we can just ignore this
|
||||
|
@ -771,7 +771,7 @@ void NetPlayClient::OnChangeGame(sf::Packet& packet)
|
|||
SendGameStatus();
|
||||
|
||||
sf::Packet client_capabilities_packet;
|
||||
client_capabilities_packet << static_cast<MessageId>(NP_MSG_CLIENT_CAPABILITIES);
|
||||
client_capabilities_packet << MessageID::ClientCapabilities;
|
||||
client_capabilities_packet << ExpansionInterface::CEXIIPL::HasIPLDump();
|
||||
client_capabilities_packet << Config::Get(Config::SESSION_USE_FMA);
|
||||
Send(client_capabilities_packet);
|
||||
|
@ -924,7 +924,7 @@ void NetPlayClient::OnPing(sf::Packet& packet)
|
|||
packet >> ping_key;
|
||||
|
||||
sf::Packet response_packet;
|
||||
response_packet << static_cast<MessageId>(NP_MSG_PONG);
|
||||
response_packet << MessageID::Pong;
|
||||
response_packet << ping_key;
|
||||
|
||||
Send(response_packet);
|
||||
|
@ -1643,7 +1643,7 @@ const NetSettings& NetPlayClient::GetNetSettings() const
|
|||
void NetPlayClient::SendChatMessage(const std::string& msg)
|
||||
{
|
||||
sf::Packet packet;
|
||||
packet << static_cast<MessageId>(NP_MSG_CHAT_MESSAGE);
|
||||
packet << MessageID::ChatMessage;
|
||||
packet << msg;
|
||||
|
||||
SendAsync(std::move(packet));
|
||||
|
@ -1666,7 +1666,7 @@ void NetPlayClient::AddPadStateToPacket(const int in_game_pad, const GCPadStatus
|
|||
void NetPlayClient::SendWiimoteState(const int in_game_pad, const WiimoteInput& nw)
|
||||
{
|
||||
sf::Packet packet;
|
||||
packet << static_cast<MessageId>(NP_MSG_WIIMOTE_DATA);
|
||||
packet << MessageID::WiimoteData;
|
||||
packet << static_cast<PadIndex>(in_game_pad);
|
||||
packet << static_cast<u8>(nw.report_id);
|
||||
packet << static_cast<u8>(nw.data.size());
|
||||
|
@ -1678,7 +1678,7 @@ void NetPlayClient::SendWiimoteState(const int in_game_pad, const WiimoteInput&
|
|||
void NetPlayClient::SendStartGamePacket()
|
||||
{
|
||||
sf::Packet packet;
|
||||
packet << static_cast<MessageId>(NP_MSG_START_GAME);
|
||||
packet << MessageID::StartGame;
|
||||
packet << m_current_game;
|
||||
|
||||
SendAsync(std::move(packet));
|
||||
|
@ -1688,7 +1688,7 @@ void NetPlayClient::SendStartGamePacket()
|
|||
void NetPlayClient::SendStopGamePacket()
|
||||
{
|
||||
sf::Packet packet;
|
||||
packet << static_cast<MessageId>(NP_MSG_STOP_GAME);
|
||||
packet << MessageID::StopGame;
|
||||
|
||||
SendAsync(std::move(packet));
|
||||
}
|
||||
|
@ -1760,7 +1760,7 @@ void NetPlayClient::SyncSaveDataResponse(const bool success)
|
|||
if (++m_sync_save_data_success_count >= m_sync_save_data_count)
|
||||
{
|
||||
sf::Packet response_packet;
|
||||
response_packet << static_cast<MessageId>(NP_MSG_SYNC_SAVE_DATA);
|
||||
response_packet << MessageID::SyncSaveData;
|
||||
response_packet << static_cast<MessageId>(SYNC_SAVE_DATA_SUCCESS);
|
||||
|
||||
Send(response_packet);
|
||||
|
@ -1769,7 +1769,7 @@ void NetPlayClient::SyncSaveDataResponse(const bool success)
|
|||
else
|
||||
{
|
||||
sf::Packet response_packet;
|
||||
response_packet << static_cast<MessageId>(NP_MSG_SYNC_SAVE_DATA);
|
||||
response_packet << MessageID::SyncSaveData;
|
||||
response_packet << static_cast<MessageId>(SYNC_SAVE_DATA_FAILURE);
|
||||
|
||||
Send(response_packet);
|
||||
|
@ -1784,7 +1784,7 @@ void NetPlayClient::SyncCodeResponse(const bool success)
|
|||
m_dialog->AppendChat(Common::GetStringT("Error processing codes."));
|
||||
|
||||
sf::Packet response_packet;
|
||||
response_packet << static_cast<MessageId>(NP_MSG_SYNC_CODES);
|
||||
response_packet << MessageID::SyncCodes;
|
||||
response_packet << static_cast<MessageId>(SYNC_CODES_FAILURE);
|
||||
|
||||
Send(response_packet);
|
||||
|
@ -1797,7 +1797,7 @@ void NetPlayClient::SyncCodeResponse(const bool success)
|
|||
m_dialog->AppendChat(Common::GetStringT("Codes received!"));
|
||||
|
||||
sf::Packet response_packet;
|
||||
response_packet << static_cast<MessageId>(NP_MSG_SYNC_CODES);
|
||||
response_packet << MessageID::SyncCodes;
|
||||
response_packet << static_cast<MessageId>(SYNC_CODES_SUCCESS);
|
||||
|
||||
Send(response_packet);
|
||||
|
@ -1960,7 +1960,7 @@ bool NetPlayClient::GetNetPads(const int pad_nb, const bool batching, GCPadStatu
|
|||
{
|
||||
// Tell the server we've acknowledged the message
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(NP_MSG_GOLF_PREPARE);
|
||||
spac << MessageID::GolfPrepare;
|
||||
Send(spac);
|
||||
|
||||
m_wait_on_input_received = false;
|
||||
|
@ -1972,7 +1972,7 @@ bool NetPlayClient::GetNetPads(const int pad_nb, const bool batching, GCPadStatu
|
|||
if (IsFirstInGamePad(pad_nb) && batching)
|
||||
{
|
||||
sf::Packet packet;
|
||||
packet << static_cast<MessageId>(NP_MSG_PAD_DATA);
|
||||
packet << MessageID::PadData;
|
||||
|
||||
bool send_packet = false;
|
||||
const int num_local_pads = NumLocalPads();
|
||||
|
@ -1990,11 +1990,11 @@ bool NetPlayClient::GetNetPads(const int pad_nb, const bool batching, GCPadStatu
|
|||
|
||||
if (!batching)
|
||||
{
|
||||
int local_pad = InGamePadToLocalPad(pad_nb);
|
||||
const int local_pad = InGamePadToLocalPad(pad_nb);
|
||||
if (local_pad < 4)
|
||||
{
|
||||
sf::Packet packet;
|
||||
packet << static_cast<MessageId>(NP_MSG_PAD_DATA);
|
||||
packet << MessageID::PadData;
|
||||
if (PollLocalPad(local_pad, packet))
|
||||
SendAsync(std::move(packet));
|
||||
}
|
||||
|
@ -2208,7 +2208,7 @@ void NetPlayClient::SendPadHostPoll(const PadIndex pad_num)
|
|||
return;
|
||||
|
||||
sf::Packet packet;
|
||||
packet << static_cast<MessageId>(NP_MSG_PAD_HOST_DATA);
|
||||
packet << MessageID::PadHostData;
|
||||
|
||||
if (pad_num < 0)
|
||||
{
|
||||
|
@ -2309,7 +2309,7 @@ void NetPlayClient::RequestStopGame()
|
|||
void NetPlayClient::SendPowerButtonEvent()
|
||||
{
|
||||
sf::Packet packet;
|
||||
packet << static_cast<MessageId>(NP_MSG_POWER_BUTTON);
|
||||
packet << MessageID::PowerButton;
|
||||
SendAsync(std::move(packet));
|
||||
}
|
||||
|
||||
|
@ -2319,7 +2319,7 @@ void NetPlayClient::RequestGolfControl(const PlayerId pid)
|
|||
return;
|
||||
|
||||
sf::Packet packet;
|
||||
packet << static_cast<MessageId>(NP_MSG_GOLF_REQUEST);
|
||||
packet << MessageID::GolfRequest;
|
||||
packet << pid;
|
||||
SendAsync(std::move(packet));
|
||||
}
|
||||
|
@ -2410,7 +2410,7 @@ bool NetPlayClient::IsLocalPlayer(const PlayerId pid) const
|
|||
void NetPlayClient::SendGameStatus()
|
||||
{
|
||||
sf::Packet packet;
|
||||
packet << static_cast<MessageId>(NP_MSG_GAME_STATUS);
|
||||
packet << MessageID::GameStatus;
|
||||
|
||||
SyncIdentifierComparison result;
|
||||
m_dialog->FindGameFile(m_selected_game, &result);
|
||||
|
@ -2436,7 +2436,7 @@ void NetPlayClient::SendTimeBase()
|
|||
const sf::Uint64 timebase = SystemTimers::GetFakeTimeBase();
|
||||
|
||||
sf::Packet packet;
|
||||
packet << static_cast<MessageId>(NP_MSG_TIMEBASE);
|
||||
packet << MessageID::TimeBase;
|
||||
packet << timebase;
|
||||
packet << netplay_client->m_timebase_frame;
|
||||
|
||||
|
@ -2472,7 +2472,7 @@ void NetPlayClient::ComputeMD5(const SyncIdentifier& sync_identifier)
|
|||
if (file.empty() || !File::Exists(file))
|
||||
{
|
||||
sf::Packet packet;
|
||||
packet << static_cast<MessageId>(NP_MSG_MD5_ERROR);
|
||||
packet << MessageID::MD5Error;
|
||||
packet << "file not found";
|
||||
Send(packet);
|
||||
return;
|
||||
|
@ -2483,7 +2483,7 @@ void NetPlayClient::ComputeMD5(const SyncIdentifier& sync_identifier)
|
|||
m_MD5_thread = std::thread([this, file]() {
|
||||
std::string sum = MD5::MD5Sum(file, [&](int progress) {
|
||||
sf::Packet packet;
|
||||
packet << static_cast<MessageId>(NP_MSG_MD5_PROGRESS);
|
||||
packet << MessageID::MD5Progress;
|
||||
packet << progress;
|
||||
SendAsync(std::move(packet));
|
||||
|
||||
|
@ -2491,7 +2491,7 @@ void NetPlayClient::ComputeMD5(const SyncIdentifier& sync_identifier)
|
|||
});
|
||||
|
||||
sf::Packet packet;
|
||||
packet << static_cast<MessageId>(NP_MSG_MD5_RESULT);
|
||||
packet << MessageID::MD5Result;
|
||||
packet << sum;
|
||||
SendAsync(std::move(packet));
|
||||
});
|
||||
|
|
|
@ -120,64 +120,63 @@ struct NetTraversalConfig
|
|||
u16 traversal_port = 0;
|
||||
};
|
||||
|
||||
// messages
|
||||
enum MessageID : u8
|
||||
enum class MessageID : u8
|
||||
{
|
||||
NP_MSG_PLAYER_JOIN = 0x10,
|
||||
NP_MSG_PLAYER_LEAVE = 0x11,
|
||||
PlayerJoin = 0x10,
|
||||
PlayerLeave = 0x11,
|
||||
|
||||
NP_MSG_CHAT_MESSAGE = 0x30,
|
||||
ChatMessage = 0x30,
|
||||
|
||||
NP_MSG_CHUNKED_DATA_START = 0x40,
|
||||
NP_MSG_CHUNKED_DATA_END = 0x41,
|
||||
NP_MSG_CHUNKED_DATA_PAYLOAD = 0x42,
|
||||
NP_MSG_CHUNKED_DATA_PROGRESS = 0x43,
|
||||
NP_MSG_CHUNKED_DATA_COMPLETE = 0x44,
|
||||
NP_MSG_CHUNKED_DATA_ABORT = 0x45,
|
||||
ChunkedDataStart = 0x40,
|
||||
ChunkedDataEnd = 0x41,
|
||||
ChunkedDataPayload = 0x42,
|
||||
ChunkedDataProgress = 0x43,
|
||||
ChunkedDataComplete = 0x44,
|
||||
ChunkedDataAbort = 0x45,
|
||||
|
||||
NP_MSG_PAD_DATA = 0x60,
|
||||
NP_MSG_PAD_MAPPING = 0x61,
|
||||
NP_MSG_PAD_BUFFER = 0x62,
|
||||
NP_MSG_PAD_HOST_DATA = 0x63,
|
||||
NP_MSG_GBA_CONFIG = 0x64,
|
||||
PadData = 0x60,
|
||||
PadMapping = 0x61,
|
||||
PadBuffer = 0x62,
|
||||
PadHostData = 0x63,
|
||||
GBAConfig = 0x64,
|
||||
|
||||
NP_MSG_WIIMOTE_DATA = 0x70,
|
||||
NP_MSG_WIIMOTE_MAPPING = 0x71,
|
||||
WiimoteData = 0x70,
|
||||
WiimoteMapping = 0x71,
|
||||
|
||||
NP_MSG_GOLF_REQUEST = 0x90,
|
||||
NP_MSG_GOLF_SWITCH = 0x91,
|
||||
NP_MSG_GOLF_ACQUIRE = 0x92,
|
||||
NP_MSG_GOLF_RELEASE = 0x93,
|
||||
NP_MSG_GOLF_PREPARE = 0x94,
|
||||
GolfRequest = 0x90,
|
||||
GolfSwitch = 0x91,
|
||||
GolfAcquire = 0x92,
|
||||
GolfRelease = 0x93,
|
||||
GolfPrepare = 0x94,
|
||||
|
||||
NP_MSG_START_GAME = 0xA0,
|
||||
NP_MSG_CHANGE_GAME = 0xA1,
|
||||
NP_MSG_STOP_GAME = 0xA2,
|
||||
NP_MSG_DISABLE_GAME = 0xA3,
|
||||
NP_MSG_GAME_STATUS = 0xA4,
|
||||
NP_MSG_CLIENT_CAPABILITIES = 0xA5,
|
||||
NP_MSG_HOST_INPUT_AUTHORITY = 0xA6,
|
||||
NP_MSG_POWER_BUTTON = 0xA7,
|
||||
StartGame = 0xA0,
|
||||
ChangeGame = 0xA1,
|
||||
StopGame = 0xA2,
|
||||
DisableGame = 0xA3,
|
||||
GameStatus = 0xA4,
|
||||
ClientCapabilities = 0xA5,
|
||||
HostInputAuthority = 0xA6,
|
||||
PowerButton = 0xA7,
|
||||
|
||||
NP_MSG_TIMEBASE = 0xB0,
|
||||
NP_MSG_DESYNC_DETECTED = 0xB1,
|
||||
TimeBase = 0xB0,
|
||||
DesyncDetected = 0xB1,
|
||||
|
||||
NP_MSG_COMPUTE_MD5 = 0xC0,
|
||||
NP_MSG_MD5_PROGRESS = 0xC1,
|
||||
NP_MSG_MD5_RESULT = 0xC2,
|
||||
NP_MSG_MD5_ABORT = 0xC3,
|
||||
NP_MSG_MD5_ERROR = 0xC4,
|
||||
ComputeMD5 = 0xC0,
|
||||
MD5Progress = 0xC1,
|
||||
MD5Result = 0xC2,
|
||||
MD5Abort = 0xC3,
|
||||
MD5Error = 0xC4,
|
||||
|
||||
NP_MSG_READY = 0xD0,
|
||||
NP_MSG_NOT_READY = 0xD1,
|
||||
Ready = 0xD0,
|
||||
NotReady = 0xD1,
|
||||
|
||||
NP_MSG_PING = 0xE0,
|
||||
NP_MSG_PONG = 0xE1,
|
||||
NP_MSG_PLAYER_PING_DATA = 0xE2,
|
||||
Ping = 0xE0,
|
||||
Pong = 0xE1,
|
||||
PlayerPingData = 0xE2,
|
||||
|
||||
NP_MSG_SYNC_GC_SRAM = 0xF0,
|
||||
NP_MSG_SYNC_SAVE_DATA = 0xF1,
|
||||
NP_MSG_SYNC_CODES = 0xF2,
|
||||
SyncGCSRAM = 0xF0,
|
||||
SyncSaveData = 0xF1,
|
||||
SyncCodes = 0xF2,
|
||||
};
|
||||
|
||||
enum
|
||||
|
|
|
@ -242,7 +242,7 @@ void NetPlayServer::ThreadFunc()
|
|||
m_ping_key = Common::Timer::GetTimeMs();
|
||||
|
||||
sf::Packet spac;
|
||||
spac << (MessageId)NP_MSG_PING;
|
||||
spac << MessageID::Ping;
|
||||
spac << m_ping_key;
|
||||
|
||||
m_ping_timer.Start();
|
||||
|
@ -427,7 +427,7 @@ unsigned int NetPlayServer::OnConnect(ENetPeer* socket, sf::Packet& rpac)
|
|||
|
||||
// send join message to already connected clients
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(NP_MSG_PLAYER_JOIN);
|
||||
spac << MessageID::PlayerJoin;
|
||||
spac << player.pid << player.name << player.revision;
|
||||
SendToClients(spac);
|
||||
|
||||
|
@ -441,7 +441,7 @@ unsigned int NetPlayServer::OnConnect(ENetPeer* socket, sf::Packet& rpac)
|
|||
if (!m_selected_game_name.empty())
|
||||
{
|
||||
spac.clear();
|
||||
spac << static_cast<MessageId>(NP_MSG_CHANGE_GAME);
|
||||
spac << MessageID::ChangeGame;
|
||||
SendSyncIdentifier(spac, m_selected_game_identifier);
|
||||
spac << m_selected_game_name;
|
||||
Send(player.socket, spac);
|
||||
|
@ -451,14 +451,14 @@ unsigned int NetPlayServer::OnConnect(ENetPeer* socket, sf::Packet& rpac)
|
|||
{
|
||||
// send the pad buffer value
|
||||
spac.clear();
|
||||
spac << static_cast<MessageId>(NP_MSG_PAD_BUFFER);
|
||||
spac << static_cast<u32>(m_target_buffer_size);
|
||||
spac << MessageID::PadBuffer;
|
||||
spac << m_target_buffer_size;
|
||||
Send(player.socket, spac);
|
||||
}
|
||||
|
||||
// send input authority state
|
||||
spac.clear();
|
||||
spac << static_cast<MessageId>(NP_MSG_HOST_INPUT_AUTHORITY);
|
||||
spac << MessageID::HostInputAuthority;
|
||||
spac << m_host_input_authority;
|
||||
Send(player.socket, spac);
|
||||
|
||||
|
@ -466,12 +466,12 @@ unsigned int NetPlayServer::OnConnect(ENetPeer* socket, sf::Packet& rpac)
|
|||
for (const auto& p : m_players)
|
||||
{
|
||||
spac.clear();
|
||||
spac << static_cast<MessageId>(NP_MSG_PLAYER_JOIN);
|
||||
spac << MessageID::PlayerJoin;
|
||||
spac << p.second.pid << p.second.name << p.second.revision;
|
||||
Send(player.socket, spac);
|
||||
|
||||
spac.clear();
|
||||
spac << static_cast<MessageId>(NP_MSG_GAME_STATUS);
|
||||
spac << MessageID::GameStatus;
|
||||
spac << p.second.pid << static_cast<u32>(p.second.game_status);
|
||||
Send(player.socket, spac);
|
||||
}
|
||||
|
@ -506,7 +506,7 @@ unsigned int NetPlayServer::OnDisconnect(const Client& player)
|
|||
m_is_running = false;
|
||||
|
||||
sf::Packet spac;
|
||||
spac << (MessageId)NP_MSG_DISABLE_GAME;
|
||||
spac << MessageID::DisableGame;
|
||||
// this thread doesn't need players lock
|
||||
SendToClients(spac);
|
||||
break;
|
||||
|
@ -522,7 +522,7 @@ unsigned int NetPlayServer::OnDisconnect(const Client& player)
|
|||
}
|
||||
|
||||
sf::Packet spac;
|
||||
spac << (MessageId)NP_MSG_PLAYER_LEAVE;
|
||||
spac << MessageID::PlayerLeave;
|
||||
spac << pid;
|
||||
|
||||
enet_peer_disconnect(player.socket, 0);
|
||||
|
@ -612,7 +612,7 @@ void NetPlayServer::SetWiimoteMapping(const PadMappingArray& mappings)
|
|||
void NetPlayServer::UpdatePadMapping()
|
||||
{
|
||||
sf::Packet spac;
|
||||
spac << (MessageId)NP_MSG_PAD_MAPPING;
|
||||
spac << MessageID::PadMapping;
|
||||
for (PlayerId mapping : m_pad_map)
|
||||
{
|
||||
spac << mapping;
|
||||
|
@ -624,7 +624,7 @@ void NetPlayServer::UpdatePadMapping()
|
|||
void NetPlayServer::UpdateGBAConfig()
|
||||
{
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(NP_MSG_GBA_CONFIG);
|
||||
spac << MessageID::GBAConfig;
|
||||
for (const auto& config : m_gba_config)
|
||||
{
|
||||
spac << config.enabled << config.has_rom << config.title;
|
||||
|
@ -638,7 +638,7 @@ void NetPlayServer::UpdateGBAConfig()
|
|||
void NetPlayServer::UpdateWiimoteMapping()
|
||||
{
|
||||
sf::Packet spac;
|
||||
spac << (MessageId)NP_MSG_WIIMOTE_MAPPING;
|
||||
spac << MessageID::WiimoteMapping;
|
||||
for (PlayerId mapping : m_wiimote_map)
|
||||
{
|
||||
spac << mapping;
|
||||
|
@ -658,8 +658,8 @@ void NetPlayServer::AdjustPadBufferSize(unsigned int size)
|
|||
{
|
||||
// tell clients to change buffer size
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(NP_MSG_PAD_BUFFER);
|
||||
spac << static_cast<u32>(m_target_buffer_size);
|
||||
spac << MessageID::PadBuffer;
|
||||
spac << m_target_buffer_size;
|
||||
|
||||
SendAsyncToClients(std::move(spac));
|
||||
}
|
||||
|
@ -673,7 +673,7 @@ void NetPlayServer::SetHostInputAuthority(const bool enable)
|
|||
|
||||
// tell clients about the new value
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(NP_MSG_HOST_INPUT_AUTHORITY);
|
||||
spac << MessageID::HostInputAuthority;
|
||||
spac << m_host_input_authority;
|
||||
|
||||
SendAsyncToClients(std::move(spac));
|
||||
|
@ -727,7 +727,7 @@ void NetPlayServer::SendChunkedToClients(sf::Packet&& packet, const PlayerId ski
|
|||
// called from ---NETPLAY--- thread
|
||||
unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
||||
{
|
||||
MessageId mid;
|
||||
MessageID mid;
|
||||
packet >> mid;
|
||||
|
||||
INFO_LOG_FMT(NETPLAY, "Got client message: {:x}", mid);
|
||||
|
@ -737,14 +737,14 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
|
||||
switch (mid)
|
||||
{
|
||||
case NP_MSG_CHAT_MESSAGE:
|
||||
case MessageID::ChatMessage:
|
||||
{
|
||||
std::string msg;
|
||||
packet >> msg;
|
||||
|
||||
// send msg to other clients
|
||||
sf::Packet spac;
|
||||
spac << (MessageId)NP_MSG_CHAT_MESSAGE;
|
||||
spac << MessageID::ChatMessage;
|
||||
spac << player.pid;
|
||||
spac << msg;
|
||||
|
||||
|
@ -752,7 +752,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_CHUNKED_DATA_PROGRESS:
|
||||
case MessageID::ChunkedDataProgress:
|
||||
{
|
||||
u32 cid;
|
||||
packet >> cid;
|
||||
|
@ -762,7 +762,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_CHUNKED_DATA_COMPLETE:
|
||||
case MessageID::ChunkedDataComplete:
|
||||
{
|
||||
u32 cid;
|
||||
packet >> cid;
|
||||
|
@ -775,14 +775,14 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_PAD_DATA:
|
||||
case MessageID::PadData:
|
||||
{
|
||||
// if this is pad data from the last game still being received, ignore it
|
||||
if (player.current_game != m_current_game)
|
||||
break;
|
||||
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(m_host_input_authority ? NP_MSG_PAD_HOST_DATA : NP_MSG_PAD_DATA);
|
||||
spac << (m_host_input_authority ? MessageID::PadHostData : MessageID::PadData);
|
||||
|
||||
while (!packet.endOfPacket())
|
||||
{
|
||||
|
@ -822,14 +822,14 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_PAD_HOST_DATA:
|
||||
case MessageID::PadHostData:
|
||||
{
|
||||
// Kick player if they're not the golfer.
|
||||
if (m_current_golfer != 0 && player.pid != m_current_golfer)
|
||||
return 1;
|
||||
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(NP_MSG_PAD_DATA);
|
||||
spac << MessageID::PadData;
|
||||
|
||||
while (!packet.endOfPacket())
|
||||
{
|
||||
|
@ -853,7 +853,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_WIIMOTE_DATA:
|
||||
case MessageID::WiimoteData:
|
||||
{
|
||||
// if this is Wiimote data from the last game still being received, ignore it
|
||||
if (player.current_game != m_current_game)
|
||||
|
@ -875,7 +875,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
|
||||
// relay to clients
|
||||
sf::Packet spac;
|
||||
spac << (MessageId)NP_MSG_WIIMOTE_DATA;
|
||||
spac << MessageID::WiimoteData;
|
||||
spac << map;
|
||||
spac << size;
|
||||
for (const u8& byte : data)
|
||||
|
@ -885,7 +885,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_GOLF_REQUEST:
|
||||
case MessageID::GolfRequest:
|
||||
{
|
||||
PlayerId pid;
|
||||
packet >> pid;
|
||||
|
@ -900,25 +900,25 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
m_pending_golfer = pid;
|
||||
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(NP_MSG_GOLF_PREPARE);
|
||||
spac << MessageID::GolfPrepare;
|
||||
Send(m_players[pid].socket, spac);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_GOLF_RELEASE:
|
||||
case MessageID::GolfRelease:
|
||||
{
|
||||
if (m_pending_golfer == 0)
|
||||
break;
|
||||
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(NP_MSG_GOLF_SWITCH);
|
||||
spac << static_cast<PlayerId>(m_pending_golfer);
|
||||
spac << MessageID::GolfSwitch;
|
||||
spac << m_pending_golfer;
|
||||
SendToClients(spac);
|
||||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_GOLF_ACQUIRE:
|
||||
case MessageID::GolfAcquire:
|
||||
{
|
||||
if (m_pending_golfer == 0)
|
||||
break;
|
||||
|
@ -928,7 +928,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_GOLF_PREPARE:
|
||||
case MessageID::GolfPrepare:
|
||||
{
|
||||
if (m_pending_golfer == 0)
|
||||
break;
|
||||
|
@ -936,13 +936,13 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
m_current_golfer = 0;
|
||||
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(NP_MSG_GOLF_SWITCH);
|
||||
spac << static_cast<PlayerId>(0);
|
||||
spac << MessageID::GolfSwitch;
|
||||
spac << PlayerId{0};
|
||||
SendToClients(spac);
|
||||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_PONG:
|
||||
case MessageID::Pong:
|
||||
{
|
||||
const u32 ping = (u32)m_ping_timer.GetTimeElapsed();
|
||||
u32 ping_key = 0;
|
||||
|
@ -954,7 +954,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
}
|
||||
|
||||
sf::Packet spac;
|
||||
spac << (MessageId)NP_MSG_PLAYER_PING_DATA;
|
||||
spac << MessageID::PlayerPingData;
|
||||
spac << player.pid;
|
||||
spac << player.ping;
|
||||
|
||||
|
@ -962,13 +962,13 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_START_GAME:
|
||||
case MessageID::StartGame:
|
||||
{
|
||||
packet >> player.current_game;
|
||||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_STOP_GAME:
|
||||
case MessageID::StopGame:
|
||||
{
|
||||
if (!m_is_running)
|
||||
break;
|
||||
|
@ -977,14 +977,14 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
|
||||
// tell clients to stop game
|
||||
sf::Packet spac;
|
||||
spac << (MessageId)NP_MSG_STOP_GAME;
|
||||
spac << MessageID::StopGame;
|
||||
|
||||
std::lock_guard lkp(m_crit.players);
|
||||
SendToClients(spac);
|
||||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_GAME_STATUS:
|
||||
case MessageID::GameStatus:
|
||||
{
|
||||
u32 status;
|
||||
packet >> status;
|
||||
|
@ -993,7 +993,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
|
||||
// send msg to other clients
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(NP_MSG_GAME_STATUS);
|
||||
spac << MessageID::GameStatus;
|
||||
spac << player.pid;
|
||||
spac << status;
|
||||
|
||||
|
@ -1001,22 +1001,22 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_CLIENT_CAPABILITIES:
|
||||
case MessageID::ClientCapabilities:
|
||||
{
|
||||
packet >> m_players[player.pid].has_ipl_dump;
|
||||
packet >> m_players[player.pid].has_hardware_fma;
|
||||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_POWER_BUTTON:
|
||||
case MessageID::PowerButton:
|
||||
{
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(NP_MSG_POWER_BUTTON);
|
||||
spac << MessageID::PowerButton;
|
||||
SendToClients(spac, player.pid);
|
||||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_TIMEBASE:
|
||||
case MessageID::TimeBase:
|
||||
{
|
||||
u64 timebase = Common::PacketReadU64(packet);
|
||||
u32 frame;
|
||||
|
@ -1049,7 +1049,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
}
|
||||
|
||||
sf::Packet spac;
|
||||
spac << (MessageId)NP_MSG_DESYNC_DETECTED;
|
||||
spac << MessageID::DesyncDetected;
|
||||
spac << pid_to_blame;
|
||||
spac << frame;
|
||||
SendToClients(spac);
|
||||
|
@ -1061,13 +1061,13 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_MD5_PROGRESS:
|
||||
case MessageID::MD5Progress:
|
||||
{
|
||||
int progress;
|
||||
packet >> progress;
|
||||
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(NP_MSG_MD5_PROGRESS);
|
||||
spac << MessageID::MD5Progress;
|
||||
spac << player.pid;
|
||||
spac << progress;
|
||||
|
||||
|
@ -1075,13 +1075,13 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_MD5_RESULT:
|
||||
case MessageID::MD5Result:
|
||||
{
|
||||
std::string result;
|
||||
packet >> result;
|
||||
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(NP_MSG_MD5_RESULT);
|
||||
spac << MessageID::MD5Result;
|
||||
spac << player.pid;
|
||||
spac << result;
|
||||
|
||||
|
@ -1089,13 +1089,13 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_MD5_ERROR:
|
||||
case MessageID::MD5Error:
|
||||
{
|
||||
std::string error;
|
||||
packet >> error;
|
||||
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(NP_MSG_MD5_ERROR);
|
||||
spac << MessageID::MD5Error;
|
||||
spac << player.pid;
|
||||
spac << error;
|
||||
|
||||
|
@ -1103,7 +1103,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_SYNC_SAVE_DATA:
|
||||
case MessageID::SyncSaveData:
|
||||
{
|
||||
MessageId sub_id;
|
||||
packet >> sub_id;
|
||||
|
@ -1145,7 +1145,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_SYNC_CODES:
|
||||
case MessageID::SyncCodes:
|
||||
{
|
||||
// Receive Status of Code Sync
|
||||
MessageId sub_id;
|
||||
|
@ -1217,8 +1217,8 @@ void NetPlayServer::OnTraversalStateChanged()
|
|||
void NetPlayServer::SendChatMessage(const std::string& msg)
|
||||
{
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(NP_MSG_CHAT_MESSAGE);
|
||||
spac << static_cast<PlayerId>(0); // server id always 0
|
||||
spac << MessageID::ChatMessage;
|
||||
spac << PlayerId{0}; // server ID always 0
|
||||
spac << msg;
|
||||
|
||||
SendAsyncToClients(std::move(spac));
|
||||
|
@ -1235,7 +1235,7 @@ bool NetPlayServer::ChangeGame(const SyncIdentifier& sync_identifier,
|
|||
|
||||
// send changed game to clients
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(NP_MSG_CHANGE_GAME);
|
||||
spac << MessageID::ChangeGame;
|
||||
SendSyncIdentifier(spac, m_selected_game_identifier);
|
||||
spac << m_selected_game_name;
|
||||
|
||||
|
@ -1248,7 +1248,7 @@ bool NetPlayServer::ChangeGame(const SyncIdentifier& sync_identifier,
|
|||
bool NetPlayServer::ComputeMD5(const SyncIdentifier& sync_identifier)
|
||||
{
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(NP_MSG_COMPUTE_MD5);
|
||||
spac << MessageID::ComputeMD5;
|
||||
SendSyncIdentifier(spac, sync_identifier);
|
||||
|
||||
SendAsyncToClients(std::move(spac));
|
||||
|
@ -1260,10 +1260,9 @@ bool NetPlayServer::ComputeMD5(const SyncIdentifier& sync_identifier)
|
|||
bool NetPlayServer::AbortMD5()
|
||||
{
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(NP_MSG_MD5_ABORT);
|
||||
spac << MessageID::MD5Abort;
|
||||
|
||||
SendAsyncToClients(std::move(spac));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1462,7 +1461,7 @@ bool NetPlayServer::StartGame()
|
|||
g_SRAM_netplay_initialized = true;
|
||||
}
|
||||
sf::Packet srampac;
|
||||
srampac << static_cast<MessageId>(NP_MSG_SYNC_GC_SRAM);
|
||||
srampac << MessageID::SyncGCSRAM;
|
||||
for (size_t i = 0; i < sizeof(g_SRAM) - offsetof(Sram, settings); ++i)
|
||||
{
|
||||
srampac << g_SRAM[offsetof(Sram, settings) + i];
|
||||
|
@ -1471,7 +1470,7 @@ bool NetPlayServer::StartGame()
|
|||
|
||||
// tell clients to start game
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(NP_MSG_START_GAME);
|
||||
spac << MessageID::StartGame;
|
||||
spac << m_current_game;
|
||||
spac << m_settings.m_CPUthread;
|
||||
spac << static_cast<std::underlying_type_t<PowerPC::CPUCore>>(m_settings.m_CPUcore);
|
||||
|
@ -1620,7 +1619,7 @@ bool NetPlayServer::SyncSaveData()
|
|||
|
||||
{
|
||||
sf::Packet pac;
|
||||
pac << static_cast<MessageId>(NP_MSG_SYNC_SAVE_DATA);
|
||||
pac << MessageID::SyncSaveData;
|
||||
pac << static_cast<MessageId>(SYNC_SAVE_DATA_NOTIFY);
|
||||
pac << save_count;
|
||||
|
||||
|
@ -1657,7 +1656,7 @@ bool NetPlayServer::SyncSaveData()
|
|||
}
|
||||
|
||||
sf::Packet pac;
|
||||
pac << static_cast<MessageId>(NP_MSG_SYNC_SAVE_DATA);
|
||||
pac << MessageID::SyncSaveData;
|
||||
pac << static_cast<MessageId>(SYNC_SAVE_DATA_RAW);
|
||||
pac << is_slot_a << region << size_override;
|
||||
|
||||
|
@ -1682,7 +1681,7 @@ bool NetPlayServer::SyncSaveData()
|
|||
fmt::format("Card {}", is_slot_a ? 'A' : 'B');
|
||||
|
||||
sf::Packet pac;
|
||||
pac << static_cast<MessageId>(NP_MSG_SYNC_SAVE_DATA);
|
||||
pac << MessageID::SyncSaveData;
|
||||
pac << static_cast<MessageId>(SYNC_SAVE_DATA_GCI);
|
||||
pac << is_slot_a;
|
||||
|
||||
|
@ -1734,7 +1733,7 @@ bool NetPlayServer::SyncSaveData()
|
|||
std::vector<u64> titles;
|
||||
|
||||
sf::Packet pac;
|
||||
pac << static_cast<MessageId>(NP_MSG_SYNC_SAVE_DATA);
|
||||
pac << MessageID::SyncSaveData;
|
||||
pac << static_cast<MessageId>(SYNC_SAVE_DATA_WII);
|
||||
|
||||
// Shove the Mii data into the start the packet
|
||||
|
@ -1825,7 +1824,7 @@ bool NetPlayServer::SyncSaveData()
|
|||
if (m_gba_config[i].enabled && m_gba_config[i].has_rom)
|
||||
{
|
||||
sf::Packet pac;
|
||||
pac << static_cast<MessageId>(NP_MSG_SYNC_SAVE_DATA);
|
||||
pac << MessageID::SyncSaveData;
|
||||
pac << static_cast<MessageId>(SYNC_SAVE_DATA_GBA);
|
||||
pac << static_cast<u8>(i);
|
||||
|
||||
|
@ -1882,7 +1881,7 @@ bool NetPlayServer::SyncCodes()
|
|||
// Notify Clients of Incoming Code Sync
|
||||
{
|
||||
sf::Packet pac;
|
||||
pac << static_cast<MessageId>(NP_MSG_SYNC_CODES);
|
||||
pac << MessageID::SyncCodes;
|
||||
pac << static_cast<MessageId>(SYNC_CODES_NOTIFY);
|
||||
SendAsyncToClients(std::move(pac));
|
||||
}
|
||||
|
@ -1910,7 +1909,7 @@ bool NetPlayServer::SyncCodes()
|
|||
// Send initial packet. Notify of the sync operation and total number of lines being sent.
|
||||
{
|
||||
sf::Packet pac;
|
||||
pac << static_cast<MessageId>(NP_MSG_SYNC_CODES);
|
||||
pac << MessageID::SyncCodes;
|
||||
pac << static_cast<MessageId>(SYNC_CODES_NOTIFY_GECKO);
|
||||
pac << codelines;
|
||||
SendAsyncToClients(std::move(pac));
|
||||
|
@ -1919,7 +1918,7 @@ bool NetPlayServer::SyncCodes()
|
|||
// Send entire codeset in the second packet
|
||||
{
|
||||
sf::Packet pac;
|
||||
pac << static_cast<MessageId>(NP_MSG_SYNC_CODES);
|
||||
pac << MessageID::SyncCodes;
|
||||
pac << static_cast<MessageId>(SYNC_CODES_DATA_GECKO);
|
||||
// Iterate through the active code vector and send each codeline
|
||||
for (const Gecko::GeckoCode& active_code : s_active_codes)
|
||||
|
@ -1960,7 +1959,7 @@ bool NetPlayServer::SyncCodes()
|
|||
// Send initial packet. Notify of the sync operation and total number of lines being sent.
|
||||
{
|
||||
sf::Packet pac;
|
||||
pac << static_cast<MessageId>(NP_MSG_SYNC_CODES);
|
||||
pac << MessageID::SyncCodes;
|
||||
pac << static_cast<MessageId>(SYNC_CODES_NOTIFY_AR);
|
||||
pac << codelines;
|
||||
SendAsyncToClients(std::move(pac));
|
||||
|
@ -1969,7 +1968,7 @@ bool NetPlayServer::SyncCodes()
|
|||
// Send entire codeset in the second packet
|
||||
{
|
||||
sf::Packet pac;
|
||||
pac << static_cast<MessageId>(NP_MSG_SYNC_CODES);
|
||||
pac << MessageID::SyncCodes;
|
||||
pac << static_cast<MessageId>(SYNC_CODES_DATA_AR);
|
||||
// Iterate through the active code vector and send each codeline
|
||||
for (const ActionReplay::ARCode& active_code : s_active_codes)
|
||||
|
@ -2160,7 +2159,7 @@ void NetPlayServer::ChunkedDataThreadFunc()
|
|||
player_count = players.size();
|
||||
|
||||
sf::Packet pac;
|
||||
pac << static_cast<MessageId>(NP_MSG_CHUNKED_DATA_START);
|
||||
pac << MessageID::ChunkedDataStart;
|
||||
pac << id << e.title << sf::Uint64{e.packet.getDataSize()};
|
||||
|
||||
ChunkedDataSend(std::move(pac), e.target_pid, e.target_mode);
|
||||
|
@ -2182,7 +2181,7 @@ void NetPlayServer::ChunkedDataThreadFunc()
|
|||
if (m_abort_chunked_data)
|
||||
{
|
||||
sf::Packet pac;
|
||||
pac << static_cast<MessageId>(NP_MSG_CHUNKED_DATA_ABORT);
|
||||
pac << MessageID::ChunkedDataAbort;
|
||||
pac << id;
|
||||
ChunkedDataSend(std::move(pac), e.target_pid, e.target_mode);
|
||||
break;
|
||||
|
@ -2199,7 +2198,7 @@ void NetPlayServer::ChunkedDataThreadFunc()
|
|||
auto start = std::chrono::steady_clock::now();
|
||||
|
||||
sf::Packet pac;
|
||||
pac << static_cast<MessageId>(NP_MSG_CHUNKED_DATA_PAYLOAD);
|
||||
pac << MessageID::ChunkedDataPayload;
|
||||
pac << id;
|
||||
size_t len = std::min(CHUNKED_DATA_UNIT_SIZE, e.packet.getDataSize() - index);
|
||||
pac.append(static_cast<const u8*>(e.packet.getData()) + index, len);
|
||||
|
@ -2217,7 +2216,7 @@ void NetPlayServer::ChunkedDataThreadFunc()
|
|||
if (!m_abort_chunked_data)
|
||||
{
|
||||
sf::Packet pac;
|
||||
pac << static_cast<MessageId>(NP_MSG_CHUNKED_DATA_END);
|
||||
pac << MessageID::ChunkedDataEnd;
|
||||
pac << id;
|
||||
ChunkedDataSend(std::move(pac), e.target_pid, e.target_mode);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue