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:
Lioncash 2021-09-22 14:17:42 -04:00
parent 07af775afa
commit af4aaf4609
3 changed files with 183 additions and 185 deletions

View File

@ -313,143 +313,143 @@ static void ReceiveSyncIdentifier(sf::Packet& spac, SyncIdentifier& sync_identif
// called from ---NETPLAY--- thread // called from ---NETPLAY--- thread
void NetPlayClient::OnData(sf::Packet& packet) void NetPlayClient::OnData(sf::Packet& packet)
{ {
MessageId mid; MessageID mid;
packet >> mid; packet >> mid;
INFO_LOG_FMT(NETPLAY, "Got server message: {:x}", mid); INFO_LOG_FMT(NETPLAY, "Got server message: {:x}", mid);
switch (mid) switch (mid)
{ {
case NP_MSG_PLAYER_JOIN: case MessageID::PlayerJoin:
OnPlayerJoin(packet); OnPlayerJoin(packet);
break; break;
case NP_MSG_PLAYER_LEAVE: case MessageID::PlayerLeave:
OnPlayerLeave(packet); OnPlayerLeave(packet);
break; break;
case NP_MSG_CHAT_MESSAGE: case MessageID::ChatMessage:
OnChatMessage(packet); OnChatMessage(packet);
break; break;
case NP_MSG_CHUNKED_DATA_START: case MessageID::ChunkedDataStart:
OnChunkedDataStart(packet); OnChunkedDataStart(packet);
break; break;
case NP_MSG_CHUNKED_DATA_END: case MessageID::ChunkedDataEnd:
OnChunkedDataEnd(packet); OnChunkedDataEnd(packet);
break; break;
case NP_MSG_CHUNKED_DATA_PAYLOAD: case MessageID::ChunkedDataPayload:
OnChunkedDataPayload(packet); OnChunkedDataPayload(packet);
break; break;
case NP_MSG_CHUNKED_DATA_ABORT: case MessageID::ChunkedDataAbort:
OnChunkedDataAbort(packet); OnChunkedDataAbort(packet);
break; break;
case NP_MSG_PAD_MAPPING: case MessageID::PadMapping:
OnPadMapping(packet); OnPadMapping(packet);
break; break;
case NP_MSG_GBA_CONFIG: case MessageID::GBAConfig:
OnGBAConfig(packet); OnGBAConfig(packet);
break; break;
case NP_MSG_WIIMOTE_MAPPING: case MessageID::WiimoteMapping:
OnWiimoteMapping(packet); OnWiimoteMapping(packet);
break; break;
case NP_MSG_PAD_DATA: case MessageID::PadData:
OnPadData(packet); OnPadData(packet);
break; break;
case NP_MSG_PAD_HOST_DATA: case MessageID::PadHostData:
OnPadHostData(packet); OnPadHostData(packet);
break; break;
case NP_MSG_WIIMOTE_DATA: case MessageID::WiimoteData:
OnWiimoteData(packet); OnWiimoteData(packet);
break; break;
case NP_MSG_PAD_BUFFER: case MessageID::PadBuffer:
OnPadBuffer(packet); OnPadBuffer(packet);
break; break;
case NP_MSG_HOST_INPUT_AUTHORITY: case MessageID::HostInputAuthority:
OnHostInputAuthority(packet); OnHostInputAuthority(packet);
break; break;
case NP_MSG_GOLF_SWITCH: case MessageID::GolfSwitch:
OnGolfSwitch(packet); OnGolfSwitch(packet);
break; break;
case NP_MSG_GOLF_PREPARE: case MessageID::GolfPrepare:
OnGolfPrepare(packet); OnGolfPrepare(packet);
break; break;
case NP_MSG_CHANGE_GAME: case MessageID::ChangeGame:
OnChangeGame(packet); OnChangeGame(packet);
break; break;
case NP_MSG_GAME_STATUS: case MessageID::GameStatus:
OnGameStatus(packet); OnGameStatus(packet);
break; break;
case NP_MSG_START_GAME: case MessageID::StartGame:
OnStartGame(packet); OnStartGame(packet);
break; break;
case NP_MSG_STOP_GAME: case MessageID::StopGame:
case NP_MSG_DISABLE_GAME: case MessageID::DisableGame:
OnStopGame(packet); OnStopGame(packet);
break; break;
case NP_MSG_POWER_BUTTON: case MessageID::PowerButton:
OnPowerButton(); OnPowerButton();
break; break;
case NP_MSG_PING: case MessageID::Ping:
OnPing(packet); OnPing(packet);
break; break;
case NP_MSG_PLAYER_PING_DATA: case MessageID::PlayerPingData:
OnPlayerPingData(packet); OnPlayerPingData(packet);
break; break;
case NP_MSG_DESYNC_DETECTED: case MessageID::DesyncDetected:
OnDesyncDetected(packet); OnDesyncDetected(packet);
break; break;
case NP_MSG_SYNC_GC_SRAM: case MessageID::SyncGCSRAM:
OnSyncGCSRAM(packet); OnSyncGCSRAM(packet);
break; break;
case NP_MSG_SYNC_SAVE_DATA: case MessageID::SyncSaveData:
OnSyncSaveData(packet); OnSyncSaveData(packet);
break; break;
case NP_MSG_SYNC_CODES: case MessageID::SyncCodes:
OnSyncCodes(packet); OnSyncCodes(packet);
break; break;
case NP_MSG_COMPUTE_MD5: case MessageID::ComputeMD5:
OnComputeMD5(packet); OnComputeMD5(packet);
break; break;
case NP_MSG_MD5_PROGRESS: case MessageID::MD5Progress:
OnMD5Progress(packet); OnMD5Progress(packet);
break; break;
case NP_MSG_MD5_RESULT: case MessageID::MD5Result:
OnMD5Result(packet); OnMD5Result(packet);
break; break;
case NP_MSG_MD5_ERROR: case MessageID::MD5Error:
OnMD5Error(packet); OnMD5Error(packet);
break; break;
case NP_MSG_MD5_ABORT: case MessageID::MD5Abort:
OnMD5Abort(); OnMD5Abort();
break; break;
@ -547,7 +547,7 @@ void NetPlayClient::OnChunkedDataEnd(sf::Packet& packet)
m_dialog->HideChunkedProgressDialog(); m_dialog->HideChunkedProgressDialog();
sf::Packet complete_packet; sf::Packet complete_packet;
complete_packet << static_cast<MessageId>(NP_MSG_CHUNKED_DATA_COMPLETE); complete_packet << MessageID::ChunkedDataComplete;
complete_packet << cid; complete_packet << cid;
Send(complete_packet, CHUNKED_DATA_CHANNEL); 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()); m_dialog->SetChunkedProgress(m_local_player->pid, data_packet.getDataSize());
sf::Packet progress_packet; sf::Packet progress_packet;
progress_packet << static_cast<MessageId>(NP_MSG_CHUNKED_DATA_PROGRESS); progress_packet << MessageID::ChunkedDataProgress;
progress_packet << cid; progress_packet << cid;
progress_packet << sf::Uint64{data_packet.getDataSize()}; progress_packet << sf::Uint64{data_packet.getDataSize()};
Send(progress_packet, CHUNKED_DATA_CHANNEL); Send(progress_packet, CHUNKED_DATA_CHANNEL);
@ -731,13 +731,13 @@ void NetPlayClient::OnGolfSwitch(sf::Packet& packet)
if (m_local_player->pid == previous_golfer) if (m_local_player->pid == previous_golfer)
{ {
sf::Packet spac; sf::Packet spac;
spac << static_cast<MessageId>(NP_MSG_GOLF_RELEASE); spac << MessageID::GolfRelease;
Send(spac); Send(spac);
} }
else if (m_local_player->pid == pid) else if (m_local_player->pid == pid)
{ {
sf::Packet spac; sf::Packet spac;
spac << static_cast<MessageId>(NP_MSG_GOLF_ACQUIRE); spac << MessageID::GolfAcquire;
Send(spac); Send(spac);
// Pads are already calibrated so we can just ignore this // Pads are already calibrated so we can just ignore this
@ -771,7 +771,7 @@ void NetPlayClient::OnChangeGame(sf::Packet& packet)
SendGameStatus(); SendGameStatus();
sf::Packet client_capabilities_packet; 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 << ExpansionInterface::CEXIIPL::HasIPLDump();
client_capabilities_packet << Config::Get(Config::SESSION_USE_FMA); client_capabilities_packet << Config::Get(Config::SESSION_USE_FMA);
Send(client_capabilities_packet); Send(client_capabilities_packet);
@ -924,7 +924,7 @@ void NetPlayClient::OnPing(sf::Packet& packet)
packet >> ping_key; packet >> ping_key;
sf::Packet response_packet; sf::Packet response_packet;
response_packet << static_cast<MessageId>(NP_MSG_PONG); response_packet << MessageID::Pong;
response_packet << ping_key; response_packet << ping_key;
Send(response_packet); Send(response_packet);
@ -1643,7 +1643,7 @@ const NetSettings& NetPlayClient::GetNetSettings() const
void NetPlayClient::SendChatMessage(const std::string& msg) void NetPlayClient::SendChatMessage(const std::string& msg)
{ {
sf::Packet packet; sf::Packet packet;
packet << static_cast<MessageId>(NP_MSG_CHAT_MESSAGE); packet << MessageID::ChatMessage;
packet << msg; packet << msg;
SendAsync(std::move(packet)); 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) void NetPlayClient::SendWiimoteState(const int in_game_pad, const WiimoteInput& nw)
{ {
sf::Packet packet; sf::Packet packet;
packet << static_cast<MessageId>(NP_MSG_WIIMOTE_DATA); packet << MessageID::WiimoteData;
packet << static_cast<PadIndex>(in_game_pad); packet << static_cast<PadIndex>(in_game_pad);
packet << static_cast<u8>(nw.report_id); packet << static_cast<u8>(nw.report_id);
packet << static_cast<u8>(nw.data.size()); packet << static_cast<u8>(nw.data.size());
@ -1678,7 +1678,7 @@ void NetPlayClient::SendWiimoteState(const int in_game_pad, const WiimoteInput&
void NetPlayClient::SendStartGamePacket() void NetPlayClient::SendStartGamePacket()
{ {
sf::Packet packet; sf::Packet packet;
packet << static_cast<MessageId>(NP_MSG_START_GAME); packet << MessageID::StartGame;
packet << m_current_game; packet << m_current_game;
SendAsync(std::move(packet)); SendAsync(std::move(packet));
@ -1688,7 +1688,7 @@ void NetPlayClient::SendStartGamePacket()
void NetPlayClient::SendStopGamePacket() void NetPlayClient::SendStopGamePacket()
{ {
sf::Packet packet; sf::Packet packet;
packet << static_cast<MessageId>(NP_MSG_STOP_GAME); packet << MessageID::StopGame;
SendAsync(std::move(packet)); 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) if (++m_sync_save_data_success_count >= m_sync_save_data_count)
{ {
sf::Packet response_packet; 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); response_packet << static_cast<MessageId>(SYNC_SAVE_DATA_SUCCESS);
Send(response_packet); Send(response_packet);
@ -1769,7 +1769,7 @@ void NetPlayClient::SyncSaveDataResponse(const bool success)
else else
{ {
sf::Packet response_packet; 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); response_packet << static_cast<MessageId>(SYNC_SAVE_DATA_FAILURE);
Send(response_packet); Send(response_packet);
@ -1784,7 +1784,7 @@ void NetPlayClient::SyncCodeResponse(const bool success)
m_dialog->AppendChat(Common::GetStringT("Error processing codes.")); m_dialog->AppendChat(Common::GetStringT("Error processing codes."));
sf::Packet response_packet; 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); response_packet << static_cast<MessageId>(SYNC_CODES_FAILURE);
Send(response_packet); Send(response_packet);
@ -1797,7 +1797,7 @@ void NetPlayClient::SyncCodeResponse(const bool success)
m_dialog->AppendChat(Common::GetStringT("Codes received!")); m_dialog->AppendChat(Common::GetStringT("Codes received!"));
sf::Packet response_packet; 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); response_packet << static_cast<MessageId>(SYNC_CODES_SUCCESS);
Send(response_packet); 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 // Tell the server we've acknowledged the message
sf::Packet spac; sf::Packet spac;
spac << static_cast<MessageId>(NP_MSG_GOLF_PREPARE); spac << MessageID::GolfPrepare;
Send(spac); Send(spac);
m_wait_on_input_received = false; 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) if (IsFirstInGamePad(pad_nb) && batching)
{ {
sf::Packet packet; sf::Packet packet;
packet << static_cast<MessageId>(NP_MSG_PAD_DATA); packet << MessageID::PadData;
bool send_packet = false; bool send_packet = false;
const int num_local_pads = NumLocalPads(); const int num_local_pads = NumLocalPads();
@ -1990,11 +1990,11 @@ bool NetPlayClient::GetNetPads(const int pad_nb, const bool batching, GCPadStatu
if (!batching) if (!batching)
{ {
int local_pad = InGamePadToLocalPad(pad_nb); const int local_pad = InGamePadToLocalPad(pad_nb);
if (local_pad < 4) if (local_pad < 4)
{ {
sf::Packet packet; sf::Packet packet;
packet << static_cast<MessageId>(NP_MSG_PAD_DATA); packet << MessageID::PadData;
if (PollLocalPad(local_pad, packet)) if (PollLocalPad(local_pad, packet))
SendAsync(std::move(packet)); SendAsync(std::move(packet));
} }
@ -2208,7 +2208,7 @@ void NetPlayClient::SendPadHostPoll(const PadIndex pad_num)
return; return;
sf::Packet packet; sf::Packet packet;
packet << static_cast<MessageId>(NP_MSG_PAD_HOST_DATA); packet << MessageID::PadHostData;
if (pad_num < 0) if (pad_num < 0)
{ {
@ -2309,7 +2309,7 @@ void NetPlayClient::RequestStopGame()
void NetPlayClient::SendPowerButtonEvent() void NetPlayClient::SendPowerButtonEvent()
{ {
sf::Packet packet; sf::Packet packet;
packet << static_cast<MessageId>(NP_MSG_POWER_BUTTON); packet << MessageID::PowerButton;
SendAsync(std::move(packet)); SendAsync(std::move(packet));
} }
@ -2319,7 +2319,7 @@ void NetPlayClient::RequestGolfControl(const PlayerId pid)
return; return;
sf::Packet packet; sf::Packet packet;
packet << static_cast<MessageId>(NP_MSG_GOLF_REQUEST); packet << MessageID::GolfRequest;
packet << pid; packet << pid;
SendAsync(std::move(packet)); SendAsync(std::move(packet));
} }
@ -2410,7 +2410,7 @@ bool NetPlayClient::IsLocalPlayer(const PlayerId pid) const
void NetPlayClient::SendGameStatus() void NetPlayClient::SendGameStatus()
{ {
sf::Packet packet; sf::Packet packet;
packet << static_cast<MessageId>(NP_MSG_GAME_STATUS); packet << MessageID::GameStatus;
SyncIdentifierComparison result; SyncIdentifierComparison result;
m_dialog->FindGameFile(m_selected_game, &result); m_dialog->FindGameFile(m_selected_game, &result);
@ -2436,7 +2436,7 @@ void NetPlayClient::SendTimeBase()
const sf::Uint64 timebase = SystemTimers::GetFakeTimeBase(); const sf::Uint64 timebase = SystemTimers::GetFakeTimeBase();
sf::Packet packet; sf::Packet packet;
packet << static_cast<MessageId>(NP_MSG_TIMEBASE); packet << MessageID::TimeBase;
packet << timebase; packet << timebase;
packet << netplay_client->m_timebase_frame; packet << netplay_client->m_timebase_frame;
@ -2472,7 +2472,7 @@ void NetPlayClient::ComputeMD5(const SyncIdentifier& sync_identifier)
if (file.empty() || !File::Exists(file)) if (file.empty() || !File::Exists(file))
{ {
sf::Packet packet; sf::Packet packet;
packet << static_cast<MessageId>(NP_MSG_MD5_ERROR); packet << MessageID::MD5Error;
packet << "file not found"; packet << "file not found";
Send(packet); Send(packet);
return; return;
@ -2483,7 +2483,7 @@ void NetPlayClient::ComputeMD5(const SyncIdentifier& sync_identifier)
m_MD5_thread = std::thread([this, file]() { m_MD5_thread = std::thread([this, file]() {
std::string sum = MD5::MD5Sum(file, [&](int progress) { std::string sum = MD5::MD5Sum(file, [&](int progress) {
sf::Packet packet; sf::Packet packet;
packet << static_cast<MessageId>(NP_MSG_MD5_PROGRESS); packet << MessageID::MD5Progress;
packet << progress; packet << progress;
SendAsync(std::move(packet)); SendAsync(std::move(packet));
@ -2491,7 +2491,7 @@ void NetPlayClient::ComputeMD5(const SyncIdentifier& sync_identifier)
}); });
sf::Packet packet; sf::Packet packet;
packet << static_cast<MessageId>(NP_MSG_MD5_RESULT); packet << MessageID::MD5Result;
packet << sum; packet << sum;
SendAsync(std::move(packet)); SendAsync(std::move(packet));
}); });

View File

@ -120,64 +120,63 @@ struct NetTraversalConfig
u16 traversal_port = 0; u16 traversal_port = 0;
}; };
// messages enum class MessageID : u8
enum MessageID : u8
{ {
NP_MSG_PLAYER_JOIN = 0x10, PlayerJoin = 0x10,
NP_MSG_PLAYER_LEAVE = 0x11, PlayerLeave = 0x11,
NP_MSG_CHAT_MESSAGE = 0x30, ChatMessage = 0x30,
NP_MSG_CHUNKED_DATA_START = 0x40, ChunkedDataStart = 0x40,
NP_MSG_CHUNKED_DATA_END = 0x41, ChunkedDataEnd = 0x41,
NP_MSG_CHUNKED_DATA_PAYLOAD = 0x42, ChunkedDataPayload = 0x42,
NP_MSG_CHUNKED_DATA_PROGRESS = 0x43, ChunkedDataProgress = 0x43,
NP_MSG_CHUNKED_DATA_COMPLETE = 0x44, ChunkedDataComplete = 0x44,
NP_MSG_CHUNKED_DATA_ABORT = 0x45, ChunkedDataAbort = 0x45,
NP_MSG_PAD_DATA = 0x60, PadData = 0x60,
NP_MSG_PAD_MAPPING = 0x61, PadMapping = 0x61,
NP_MSG_PAD_BUFFER = 0x62, PadBuffer = 0x62,
NP_MSG_PAD_HOST_DATA = 0x63, PadHostData = 0x63,
NP_MSG_GBA_CONFIG = 0x64, GBAConfig = 0x64,
NP_MSG_WIIMOTE_DATA = 0x70, WiimoteData = 0x70,
NP_MSG_WIIMOTE_MAPPING = 0x71, WiimoteMapping = 0x71,
NP_MSG_GOLF_REQUEST = 0x90, GolfRequest = 0x90,
NP_MSG_GOLF_SWITCH = 0x91, GolfSwitch = 0x91,
NP_MSG_GOLF_ACQUIRE = 0x92, GolfAcquire = 0x92,
NP_MSG_GOLF_RELEASE = 0x93, GolfRelease = 0x93,
NP_MSG_GOLF_PREPARE = 0x94, GolfPrepare = 0x94,
NP_MSG_START_GAME = 0xA0, StartGame = 0xA0,
NP_MSG_CHANGE_GAME = 0xA1, ChangeGame = 0xA1,
NP_MSG_STOP_GAME = 0xA2, StopGame = 0xA2,
NP_MSG_DISABLE_GAME = 0xA3, DisableGame = 0xA3,
NP_MSG_GAME_STATUS = 0xA4, GameStatus = 0xA4,
NP_MSG_CLIENT_CAPABILITIES = 0xA5, ClientCapabilities = 0xA5,
NP_MSG_HOST_INPUT_AUTHORITY = 0xA6, HostInputAuthority = 0xA6,
NP_MSG_POWER_BUTTON = 0xA7, PowerButton = 0xA7,
NP_MSG_TIMEBASE = 0xB0, TimeBase = 0xB0,
NP_MSG_DESYNC_DETECTED = 0xB1, DesyncDetected = 0xB1,
NP_MSG_COMPUTE_MD5 = 0xC0, ComputeMD5 = 0xC0,
NP_MSG_MD5_PROGRESS = 0xC1, MD5Progress = 0xC1,
NP_MSG_MD5_RESULT = 0xC2, MD5Result = 0xC2,
NP_MSG_MD5_ABORT = 0xC3, MD5Abort = 0xC3,
NP_MSG_MD5_ERROR = 0xC4, MD5Error = 0xC4,
NP_MSG_READY = 0xD0, Ready = 0xD0,
NP_MSG_NOT_READY = 0xD1, NotReady = 0xD1,
NP_MSG_PING = 0xE0, Ping = 0xE0,
NP_MSG_PONG = 0xE1, Pong = 0xE1,
NP_MSG_PLAYER_PING_DATA = 0xE2, PlayerPingData = 0xE2,
NP_MSG_SYNC_GC_SRAM = 0xF0, SyncGCSRAM = 0xF0,
NP_MSG_SYNC_SAVE_DATA = 0xF1, SyncSaveData = 0xF1,
NP_MSG_SYNC_CODES = 0xF2, SyncCodes = 0xF2,
}; };
enum enum

View File

@ -242,7 +242,7 @@ void NetPlayServer::ThreadFunc()
m_ping_key = Common::Timer::GetTimeMs(); m_ping_key = Common::Timer::GetTimeMs();
sf::Packet spac; sf::Packet spac;
spac << (MessageId)NP_MSG_PING; spac << MessageID::Ping;
spac << m_ping_key; spac << m_ping_key;
m_ping_timer.Start(); m_ping_timer.Start();
@ -427,7 +427,7 @@ unsigned int NetPlayServer::OnConnect(ENetPeer* socket, sf::Packet& rpac)
// send join message to already connected clients // send join message to already connected clients
sf::Packet spac; sf::Packet spac;
spac << static_cast<MessageId>(NP_MSG_PLAYER_JOIN); spac << MessageID::PlayerJoin;
spac << player.pid << player.name << player.revision; spac << player.pid << player.name << player.revision;
SendToClients(spac); SendToClients(spac);
@ -441,7 +441,7 @@ unsigned int NetPlayServer::OnConnect(ENetPeer* socket, sf::Packet& rpac)
if (!m_selected_game_name.empty()) if (!m_selected_game_name.empty())
{ {
spac.clear(); spac.clear();
spac << static_cast<MessageId>(NP_MSG_CHANGE_GAME); spac << MessageID::ChangeGame;
SendSyncIdentifier(spac, m_selected_game_identifier); SendSyncIdentifier(spac, m_selected_game_identifier);
spac << m_selected_game_name; spac << m_selected_game_name;
Send(player.socket, spac); Send(player.socket, spac);
@ -451,14 +451,14 @@ unsigned int NetPlayServer::OnConnect(ENetPeer* socket, sf::Packet& rpac)
{ {
// send the pad buffer value // send the pad buffer value
spac.clear(); spac.clear();
spac << static_cast<MessageId>(NP_MSG_PAD_BUFFER); spac << MessageID::PadBuffer;
spac << static_cast<u32>(m_target_buffer_size); spac << m_target_buffer_size;
Send(player.socket, spac); Send(player.socket, spac);
} }
// send input authority state // send input authority state
spac.clear(); spac.clear();
spac << static_cast<MessageId>(NP_MSG_HOST_INPUT_AUTHORITY); spac << MessageID::HostInputAuthority;
spac << m_host_input_authority; spac << m_host_input_authority;
Send(player.socket, spac); Send(player.socket, spac);
@ -466,12 +466,12 @@ unsigned int NetPlayServer::OnConnect(ENetPeer* socket, sf::Packet& rpac)
for (const auto& p : m_players) for (const auto& p : m_players)
{ {
spac.clear(); spac.clear();
spac << static_cast<MessageId>(NP_MSG_PLAYER_JOIN); spac << MessageID::PlayerJoin;
spac << p.second.pid << p.second.name << p.second.revision; spac << p.second.pid << p.second.name << p.second.revision;
Send(player.socket, spac); Send(player.socket, spac);
spac.clear(); spac.clear();
spac << static_cast<MessageId>(NP_MSG_GAME_STATUS); spac << MessageID::GameStatus;
spac << p.second.pid << static_cast<u32>(p.second.game_status); spac << p.second.pid << static_cast<u32>(p.second.game_status);
Send(player.socket, spac); Send(player.socket, spac);
} }
@ -506,7 +506,7 @@ unsigned int NetPlayServer::OnDisconnect(const Client& player)
m_is_running = false; m_is_running = false;
sf::Packet spac; sf::Packet spac;
spac << (MessageId)NP_MSG_DISABLE_GAME; spac << MessageID::DisableGame;
// this thread doesn't need players lock // this thread doesn't need players lock
SendToClients(spac); SendToClients(spac);
break; break;
@ -522,7 +522,7 @@ unsigned int NetPlayServer::OnDisconnect(const Client& player)
} }
sf::Packet spac; sf::Packet spac;
spac << (MessageId)NP_MSG_PLAYER_LEAVE; spac << MessageID::PlayerLeave;
spac << pid; spac << pid;
enet_peer_disconnect(player.socket, 0); enet_peer_disconnect(player.socket, 0);
@ -612,7 +612,7 @@ void NetPlayServer::SetWiimoteMapping(const PadMappingArray& mappings)
void NetPlayServer::UpdatePadMapping() void NetPlayServer::UpdatePadMapping()
{ {
sf::Packet spac; sf::Packet spac;
spac << (MessageId)NP_MSG_PAD_MAPPING; spac << MessageID::PadMapping;
for (PlayerId mapping : m_pad_map) for (PlayerId mapping : m_pad_map)
{ {
spac << mapping; spac << mapping;
@ -624,7 +624,7 @@ void NetPlayServer::UpdatePadMapping()
void NetPlayServer::UpdateGBAConfig() void NetPlayServer::UpdateGBAConfig()
{ {
sf::Packet spac; sf::Packet spac;
spac << static_cast<MessageId>(NP_MSG_GBA_CONFIG); spac << MessageID::GBAConfig;
for (const auto& config : m_gba_config) for (const auto& config : m_gba_config)
{ {
spac << config.enabled << config.has_rom << config.title; spac << config.enabled << config.has_rom << config.title;
@ -638,7 +638,7 @@ void NetPlayServer::UpdateGBAConfig()
void NetPlayServer::UpdateWiimoteMapping() void NetPlayServer::UpdateWiimoteMapping()
{ {
sf::Packet spac; sf::Packet spac;
spac << (MessageId)NP_MSG_WIIMOTE_MAPPING; spac << MessageID::WiimoteMapping;
for (PlayerId mapping : m_wiimote_map) for (PlayerId mapping : m_wiimote_map)
{ {
spac << mapping; spac << mapping;
@ -658,8 +658,8 @@ void NetPlayServer::AdjustPadBufferSize(unsigned int size)
{ {
// tell clients to change buffer size // tell clients to change buffer size
sf::Packet spac; sf::Packet spac;
spac << static_cast<MessageId>(NP_MSG_PAD_BUFFER); spac << MessageID::PadBuffer;
spac << static_cast<u32>(m_target_buffer_size); spac << m_target_buffer_size;
SendAsyncToClients(std::move(spac)); SendAsyncToClients(std::move(spac));
} }
@ -673,7 +673,7 @@ void NetPlayServer::SetHostInputAuthority(const bool enable)
// tell clients about the new value // tell clients about the new value
sf::Packet spac; sf::Packet spac;
spac << static_cast<MessageId>(NP_MSG_HOST_INPUT_AUTHORITY); spac << MessageID::HostInputAuthority;
spac << m_host_input_authority; spac << m_host_input_authority;
SendAsyncToClients(std::move(spac)); SendAsyncToClients(std::move(spac));
@ -727,7 +727,7 @@ void NetPlayServer::SendChunkedToClients(sf::Packet&& packet, const PlayerId ski
// called from ---NETPLAY--- thread // called from ---NETPLAY--- thread
unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player) unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
{ {
MessageId mid; MessageID mid;
packet >> mid; packet >> mid;
INFO_LOG_FMT(NETPLAY, "Got client message: {:x}", 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) switch (mid)
{ {
case NP_MSG_CHAT_MESSAGE: case MessageID::ChatMessage:
{ {
std::string msg; std::string msg;
packet >> msg; packet >> msg;
// send msg to other clients // send msg to other clients
sf::Packet spac; sf::Packet spac;
spac << (MessageId)NP_MSG_CHAT_MESSAGE; spac << MessageID::ChatMessage;
spac << player.pid; spac << player.pid;
spac << msg; spac << msg;
@ -752,7 +752,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
} }
break; break;
case NP_MSG_CHUNKED_DATA_PROGRESS: case MessageID::ChunkedDataProgress:
{ {
u32 cid; u32 cid;
packet >> cid; packet >> cid;
@ -762,7 +762,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
} }
break; break;
case NP_MSG_CHUNKED_DATA_COMPLETE: case MessageID::ChunkedDataComplete:
{ {
u32 cid; u32 cid;
packet >> cid; packet >> cid;
@ -775,14 +775,14 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
} }
break; break;
case NP_MSG_PAD_DATA: case MessageID::PadData:
{ {
// if this is pad data from the last game still being received, ignore it // if this is pad data from the last game still being received, ignore it
if (player.current_game != m_current_game) if (player.current_game != m_current_game)
break; break;
sf::Packet spac; 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()) while (!packet.endOfPacket())
{ {
@ -822,14 +822,14 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
} }
break; break;
case NP_MSG_PAD_HOST_DATA: case MessageID::PadHostData:
{ {
// Kick player if they're not the golfer. // Kick player if they're not the golfer.
if (m_current_golfer != 0 && player.pid != m_current_golfer) if (m_current_golfer != 0 && player.pid != m_current_golfer)
return 1; return 1;
sf::Packet spac; sf::Packet spac;
spac << static_cast<MessageId>(NP_MSG_PAD_DATA); spac << MessageID::PadData;
while (!packet.endOfPacket()) while (!packet.endOfPacket())
{ {
@ -853,7 +853,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
} }
break; break;
case NP_MSG_WIIMOTE_DATA: case MessageID::WiimoteData:
{ {
// if this is Wiimote data from the last game still being received, ignore it // if this is Wiimote data from the last game still being received, ignore it
if (player.current_game != m_current_game) if (player.current_game != m_current_game)
@ -875,7 +875,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
// relay to clients // relay to clients
sf::Packet spac; sf::Packet spac;
spac << (MessageId)NP_MSG_WIIMOTE_DATA; spac << MessageID::WiimoteData;
spac << map; spac << map;
spac << size; spac << size;
for (const u8& byte : data) for (const u8& byte : data)
@ -885,7 +885,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
} }
break; break;
case NP_MSG_GOLF_REQUEST: case MessageID::GolfRequest:
{ {
PlayerId pid; PlayerId pid;
packet >> pid; packet >> pid;
@ -900,25 +900,25 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
m_pending_golfer = pid; m_pending_golfer = pid;
sf::Packet spac; sf::Packet spac;
spac << static_cast<MessageId>(NP_MSG_GOLF_PREPARE); spac << MessageID::GolfPrepare;
Send(m_players[pid].socket, spac); Send(m_players[pid].socket, spac);
} }
} }
break; break;
case NP_MSG_GOLF_RELEASE: case MessageID::GolfRelease:
{ {
if (m_pending_golfer == 0) if (m_pending_golfer == 0)
break; break;
sf::Packet spac; sf::Packet spac;
spac << static_cast<MessageId>(NP_MSG_GOLF_SWITCH); spac << MessageID::GolfSwitch;
spac << static_cast<PlayerId>(m_pending_golfer); spac << m_pending_golfer;
SendToClients(spac); SendToClients(spac);
} }
break; break;
case NP_MSG_GOLF_ACQUIRE: case MessageID::GolfAcquire:
{ {
if (m_pending_golfer == 0) if (m_pending_golfer == 0)
break; break;
@ -928,7 +928,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
} }
break; break;
case NP_MSG_GOLF_PREPARE: case MessageID::GolfPrepare:
{ {
if (m_pending_golfer == 0) if (m_pending_golfer == 0)
break; break;
@ -936,13 +936,13 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
m_current_golfer = 0; m_current_golfer = 0;
sf::Packet spac; sf::Packet spac;
spac << static_cast<MessageId>(NP_MSG_GOLF_SWITCH); spac << MessageID::GolfSwitch;
spac << static_cast<PlayerId>(0); spac << PlayerId{0};
SendToClients(spac); SendToClients(spac);
} }
break; break;
case NP_MSG_PONG: case MessageID::Pong:
{ {
const u32 ping = (u32)m_ping_timer.GetTimeElapsed(); const u32 ping = (u32)m_ping_timer.GetTimeElapsed();
u32 ping_key = 0; u32 ping_key = 0;
@ -954,7 +954,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
} }
sf::Packet spac; sf::Packet spac;
spac << (MessageId)NP_MSG_PLAYER_PING_DATA; spac << MessageID::PlayerPingData;
spac << player.pid; spac << player.pid;
spac << player.ping; spac << player.ping;
@ -962,13 +962,13 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
} }
break; break;
case NP_MSG_START_GAME: case MessageID::StartGame:
{ {
packet >> player.current_game; packet >> player.current_game;
} }
break; break;
case NP_MSG_STOP_GAME: case MessageID::StopGame:
{ {
if (!m_is_running) if (!m_is_running)
break; break;
@ -977,14 +977,14 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
// tell clients to stop game // tell clients to stop game
sf::Packet spac; sf::Packet spac;
spac << (MessageId)NP_MSG_STOP_GAME; spac << MessageID::StopGame;
std::lock_guard lkp(m_crit.players); std::lock_guard lkp(m_crit.players);
SendToClients(spac); SendToClients(spac);
} }
break; break;
case NP_MSG_GAME_STATUS: case MessageID::GameStatus:
{ {
u32 status; u32 status;
packet >> status; packet >> status;
@ -993,7 +993,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
// send msg to other clients // send msg to other clients
sf::Packet spac; sf::Packet spac;
spac << static_cast<MessageId>(NP_MSG_GAME_STATUS); spac << MessageID::GameStatus;
spac << player.pid; spac << player.pid;
spac << status; spac << status;
@ -1001,22 +1001,22 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
} }
break; break;
case NP_MSG_CLIENT_CAPABILITIES: case MessageID::ClientCapabilities:
{ {
packet >> m_players[player.pid].has_ipl_dump; packet >> m_players[player.pid].has_ipl_dump;
packet >> m_players[player.pid].has_hardware_fma; packet >> m_players[player.pid].has_hardware_fma;
} }
break; break;
case NP_MSG_POWER_BUTTON: case MessageID::PowerButton:
{ {
sf::Packet spac; sf::Packet spac;
spac << static_cast<MessageId>(NP_MSG_POWER_BUTTON); spac << MessageID::PowerButton;
SendToClients(spac, player.pid); SendToClients(spac, player.pid);
} }
break; break;
case NP_MSG_TIMEBASE: case MessageID::TimeBase:
{ {
u64 timebase = Common::PacketReadU64(packet); u64 timebase = Common::PacketReadU64(packet);
u32 frame; u32 frame;
@ -1049,7 +1049,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
} }
sf::Packet spac; sf::Packet spac;
spac << (MessageId)NP_MSG_DESYNC_DETECTED; spac << MessageID::DesyncDetected;
spac << pid_to_blame; spac << pid_to_blame;
spac << frame; spac << frame;
SendToClients(spac); SendToClients(spac);
@ -1061,13 +1061,13 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
} }
break; break;
case NP_MSG_MD5_PROGRESS: case MessageID::MD5Progress:
{ {
int progress; int progress;
packet >> progress; packet >> progress;
sf::Packet spac; sf::Packet spac;
spac << static_cast<MessageId>(NP_MSG_MD5_PROGRESS); spac << MessageID::MD5Progress;
spac << player.pid; spac << player.pid;
spac << progress; spac << progress;
@ -1075,13 +1075,13 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
} }
break; break;
case NP_MSG_MD5_RESULT: case MessageID::MD5Result:
{ {
std::string result; std::string result;
packet >> result; packet >> result;
sf::Packet spac; sf::Packet spac;
spac << static_cast<MessageId>(NP_MSG_MD5_RESULT); spac << MessageID::MD5Result;
spac << player.pid; spac << player.pid;
spac << result; spac << result;
@ -1089,13 +1089,13 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
} }
break; break;
case NP_MSG_MD5_ERROR: case MessageID::MD5Error:
{ {
std::string error; std::string error;
packet >> error; packet >> error;
sf::Packet spac; sf::Packet spac;
spac << static_cast<MessageId>(NP_MSG_MD5_ERROR); spac << MessageID::MD5Error;
spac << player.pid; spac << player.pid;
spac << error; spac << error;
@ -1103,7 +1103,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
} }
break; break;
case NP_MSG_SYNC_SAVE_DATA: case MessageID::SyncSaveData:
{ {
MessageId sub_id; MessageId sub_id;
packet >> sub_id; packet >> sub_id;
@ -1145,7 +1145,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
} }
break; break;
case NP_MSG_SYNC_CODES: case MessageID::SyncCodes:
{ {
// Receive Status of Code Sync // Receive Status of Code Sync
MessageId sub_id; MessageId sub_id;
@ -1217,8 +1217,8 @@ void NetPlayServer::OnTraversalStateChanged()
void NetPlayServer::SendChatMessage(const std::string& msg) void NetPlayServer::SendChatMessage(const std::string& msg)
{ {
sf::Packet spac; sf::Packet spac;
spac << static_cast<MessageId>(NP_MSG_CHAT_MESSAGE); spac << MessageID::ChatMessage;
spac << static_cast<PlayerId>(0); // server id always 0 spac << PlayerId{0}; // server ID always 0
spac << msg; spac << msg;
SendAsyncToClients(std::move(spac)); SendAsyncToClients(std::move(spac));
@ -1235,7 +1235,7 @@ bool NetPlayServer::ChangeGame(const SyncIdentifier& sync_identifier,
// send changed game to clients // send changed game to clients
sf::Packet spac; sf::Packet spac;
spac << static_cast<MessageId>(NP_MSG_CHANGE_GAME); spac << MessageID::ChangeGame;
SendSyncIdentifier(spac, m_selected_game_identifier); SendSyncIdentifier(spac, m_selected_game_identifier);
spac << m_selected_game_name; spac << m_selected_game_name;
@ -1248,7 +1248,7 @@ bool NetPlayServer::ChangeGame(const SyncIdentifier& sync_identifier,
bool NetPlayServer::ComputeMD5(const SyncIdentifier& sync_identifier) bool NetPlayServer::ComputeMD5(const SyncIdentifier& sync_identifier)
{ {
sf::Packet spac; sf::Packet spac;
spac << static_cast<MessageId>(NP_MSG_COMPUTE_MD5); spac << MessageID::ComputeMD5;
SendSyncIdentifier(spac, sync_identifier); SendSyncIdentifier(spac, sync_identifier);
SendAsyncToClients(std::move(spac)); SendAsyncToClients(std::move(spac));
@ -1260,10 +1260,9 @@ bool NetPlayServer::ComputeMD5(const SyncIdentifier& sync_identifier)
bool NetPlayServer::AbortMD5() bool NetPlayServer::AbortMD5()
{ {
sf::Packet spac; sf::Packet spac;
spac << static_cast<MessageId>(NP_MSG_MD5_ABORT); spac << MessageID::MD5Abort;
SendAsyncToClients(std::move(spac)); SendAsyncToClients(std::move(spac));
return true; return true;
} }
@ -1462,7 +1461,7 @@ bool NetPlayServer::StartGame()
g_SRAM_netplay_initialized = true; g_SRAM_netplay_initialized = true;
} }
sf::Packet srampac; 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) for (size_t i = 0; i < sizeof(g_SRAM) - offsetof(Sram, settings); ++i)
{ {
srampac << 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 // tell clients to start game
sf::Packet spac; sf::Packet spac;
spac << static_cast<MessageId>(NP_MSG_START_GAME); spac << MessageID::StartGame;
spac << m_current_game; spac << m_current_game;
spac << m_settings.m_CPUthread; spac << m_settings.m_CPUthread;
spac << static_cast<std::underlying_type_t<PowerPC::CPUCore>>(m_settings.m_CPUcore); spac << static_cast<std::underlying_type_t<PowerPC::CPUCore>>(m_settings.m_CPUcore);
@ -1620,7 +1619,7 @@ bool NetPlayServer::SyncSaveData()
{ {
sf::Packet pac; sf::Packet pac;
pac << static_cast<MessageId>(NP_MSG_SYNC_SAVE_DATA); pac << MessageID::SyncSaveData;
pac << static_cast<MessageId>(SYNC_SAVE_DATA_NOTIFY); pac << static_cast<MessageId>(SYNC_SAVE_DATA_NOTIFY);
pac << save_count; pac << save_count;
@ -1657,7 +1656,7 @@ bool NetPlayServer::SyncSaveData()
} }
sf::Packet pac; sf::Packet pac;
pac << static_cast<MessageId>(NP_MSG_SYNC_SAVE_DATA); pac << MessageID::SyncSaveData;
pac << static_cast<MessageId>(SYNC_SAVE_DATA_RAW); pac << static_cast<MessageId>(SYNC_SAVE_DATA_RAW);
pac << is_slot_a << region << size_override; pac << is_slot_a << region << size_override;
@ -1682,7 +1681,7 @@ bool NetPlayServer::SyncSaveData()
fmt::format("Card {}", is_slot_a ? 'A' : 'B'); fmt::format("Card {}", is_slot_a ? 'A' : 'B');
sf::Packet pac; sf::Packet pac;
pac << static_cast<MessageId>(NP_MSG_SYNC_SAVE_DATA); pac << MessageID::SyncSaveData;
pac << static_cast<MessageId>(SYNC_SAVE_DATA_GCI); pac << static_cast<MessageId>(SYNC_SAVE_DATA_GCI);
pac << is_slot_a; pac << is_slot_a;
@ -1734,7 +1733,7 @@ bool NetPlayServer::SyncSaveData()
std::vector<u64> titles; std::vector<u64> titles;
sf::Packet pac; sf::Packet pac;
pac << static_cast<MessageId>(NP_MSG_SYNC_SAVE_DATA); pac << MessageID::SyncSaveData;
pac << static_cast<MessageId>(SYNC_SAVE_DATA_WII); pac << static_cast<MessageId>(SYNC_SAVE_DATA_WII);
// Shove the Mii data into the start the packet // 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) if (m_gba_config[i].enabled && m_gba_config[i].has_rom)
{ {
sf::Packet pac; 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<MessageId>(SYNC_SAVE_DATA_GBA);
pac << static_cast<u8>(i); pac << static_cast<u8>(i);
@ -1882,7 +1881,7 @@ bool NetPlayServer::SyncCodes()
// Notify Clients of Incoming Code Sync // Notify Clients of Incoming Code Sync
{ {
sf::Packet pac; sf::Packet pac;
pac << static_cast<MessageId>(NP_MSG_SYNC_CODES); pac << MessageID::SyncCodes;
pac << static_cast<MessageId>(SYNC_CODES_NOTIFY); pac << static_cast<MessageId>(SYNC_CODES_NOTIFY);
SendAsyncToClients(std::move(pac)); 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. // Send initial packet. Notify of the sync operation and total number of lines being sent.
{ {
sf::Packet pac; sf::Packet pac;
pac << static_cast<MessageId>(NP_MSG_SYNC_CODES); pac << MessageID::SyncCodes;
pac << static_cast<MessageId>(SYNC_CODES_NOTIFY_GECKO); pac << static_cast<MessageId>(SYNC_CODES_NOTIFY_GECKO);
pac << codelines; pac << codelines;
SendAsyncToClients(std::move(pac)); SendAsyncToClients(std::move(pac));
@ -1919,7 +1918,7 @@ bool NetPlayServer::SyncCodes()
// Send entire codeset in the second packet // Send entire codeset in the second packet
{ {
sf::Packet pac; sf::Packet pac;
pac << static_cast<MessageId>(NP_MSG_SYNC_CODES); pac << MessageID::SyncCodes;
pac << static_cast<MessageId>(SYNC_CODES_DATA_GECKO); pac << static_cast<MessageId>(SYNC_CODES_DATA_GECKO);
// Iterate through the active code vector and send each codeline // Iterate through the active code vector and send each codeline
for (const Gecko::GeckoCode& active_code : s_active_codes) 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. // Send initial packet. Notify of the sync operation and total number of lines being sent.
{ {
sf::Packet pac; sf::Packet pac;
pac << static_cast<MessageId>(NP_MSG_SYNC_CODES); pac << MessageID::SyncCodes;
pac << static_cast<MessageId>(SYNC_CODES_NOTIFY_AR); pac << static_cast<MessageId>(SYNC_CODES_NOTIFY_AR);
pac << codelines; pac << codelines;
SendAsyncToClients(std::move(pac)); SendAsyncToClients(std::move(pac));
@ -1969,7 +1968,7 @@ bool NetPlayServer::SyncCodes()
// Send entire codeset in the second packet // Send entire codeset in the second packet
{ {
sf::Packet pac; sf::Packet pac;
pac << static_cast<MessageId>(NP_MSG_SYNC_CODES); pac << MessageID::SyncCodes;
pac << static_cast<MessageId>(SYNC_CODES_DATA_AR); pac << static_cast<MessageId>(SYNC_CODES_DATA_AR);
// Iterate through the active code vector and send each codeline // Iterate through the active code vector and send each codeline
for (const ActionReplay::ARCode& active_code : s_active_codes) for (const ActionReplay::ARCode& active_code : s_active_codes)
@ -2160,7 +2159,7 @@ void NetPlayServer::ChunkedDataThreadFunc()
player_count = players.size(); player_count = players.size();
sf::Packet pac; sf::Packet pac;
pac << static_cast<MessageId>(NP_MSG_CHUNKED_DATA_START); pac << MessageID::ChunkedDataStart;
pac << id << e.title << sf::Uint64{e.packet.getDataSize()}; pac << id << e.title << sf::Uint64{e.packet.getDataSize()};
ChunkedDataSend(std::move(pac), e.target_pid, e.target_mode); ChunkedDataSend(std::move(pac), e.target_pid, e.target_mode);
@ -2182,7 +2181,7 @@ void NetPlayServer::ChunkedDataThreadFunc()
if (m_abort_chunked_data) if (m_abort_chunked_data)
{ {
sf::Packet pac; sf::Packet pac;
pac << static_cast<MessageId>(NP_MSG_CHUNKED_DATA_ABORT); pac << MessageID::ChunkedDataAbort;
pac << id; pac << id;
ChunkedDataSend(std::move(pac), e.target_pid, e.target_mode); ChunkedDataSend(std::move(pac), e.target_pid, e.target_mode);
break; break;
@ -2199,7 +2198,7 @@ void NetPlayServer::ChunkedDataThreadFunc()
auto start = std::chrono::steady_clock::now(); auto start = std::chrono::steady_clock::now();
sf::Packet pac; sf::Packet pac;
pac << static_cast<MessageId>(NP_MSG_CHUNKED_DATA_PAYLOAD); pac << MessageID::ChunkedDataPayload;
pac << id; pac << id;
size_t len = std::min(CHUNKED_DATA_UNIT_SIZE, e.packet.getDataSize() - index); size_t len = std::min(CHUNKED_DATA_UNIT_SIZE, e.packet.getDataSize() - index);
pac.append(static_cast<const u8*>(e.packet.getData()) + index, len); pac.append(static_cast<const u8*>(e.packet.getData()) + index, len);
@ -2217,7 +2216,7 @@ void NetPlayServer::ChunkedDataThreadFunc()
if (!m_abort_chunked_data) if (!m_abort_chunked_data)
{ {
sf::Packet pac; sf::Packet pac;
pac << static_cast<MessageId>(NP_MSG_CHUNKED_DATA_END); pac << MessageID::ChunkedDataEnd;
pac << id; pac << id;
ChunkedDataSend(std::move(pac), e.target_pid, e.target_mode); ChunkedDataSend(std::move(pac), e.target_pid, e.target_mode);
} }