NetPlayProto: Turn Sync-related enums into enum classes
This commit is contained in:
parent
af4aaf4609
commit
dedd0b7ba1
|
@ -981,7 +981,7 @@ void NetPlayClient::OnSyncGCSRAM(sf::Packet& packet)
|
|||
|
||||
void NetPlayClient::OnSyncSaveData(sf::Packet& packet)
|
||||
{
|
||||
MessageId sub_id;
|
||||
SyncSaveDataID sub_id;
|
||||
packet >> sub_id;
|
||||
|
||||
if (m_local_player->IsHost())
|
||||
|
@ -989,23 +989,23 @@ void NetPlayClient::OnSyncSaveData(sf::Packet& packet)
|
|||
|
||||
switch (sub_id)
|
||||
{
|
||||
case SYNC_SAVE_DATA_NOTIFY:
|
||||
case SyncSaveDataID::Notify:
|
||||
OnSyncSaveDataNotify(packet);
|
||||
break;
|
||||
|
||||
case SYNC_SAVE_DATA_RAW:
|
||||
case SyncSaveDataID::RawData:
|
||||
OnSyncSaveDataRaw(packet);
|
||||
break;
|
||||
|
||||
case SYNC_SAVE_DATA_GCI:
|
||||
case SyncSaveDataID::GCIData:
|
||||
OnSyncSaveDataGCI(packet);
|
||||
break;
|
||||
|
||||
case SYNC_SAVE_DATA_WII:
|
||||
case SyncSaveDataID::WiiData:
|
||||
OnSyncSaveDataWii(packet);
|
||||
break;
|
||||
|
||||
case SYNC_SAVE_DATA_GBA:
|
||||
case SyncSaveDataID::GBAData:
|
||||
OnSyncSaveDataGBA(packet);
|
||||
break;
|
||||
|
||||
|
@ -1239,29 +1239,29 @@ void NetPlayClient::OnSyncSaveDataGBA(sf::Packet& packet)
|
|||
void NetPlayClient::OnSyncCodes(sf::Packet& packet)
|
||||
{
|
||||
// Recieve Data Packet
|
||||
MessageId sub_id;
|
||||
SyncCodeID sub_id;
|
||||
packet >> sub_id;
|
||||
|
||||
// Check Which Operation to Perform with This Packet
|
||||
switch (sub_id)
|
||||
{
|
||||
case SYNC_CODES_NOTIFY:
|
||||
case SyncCodeID::Notify:
|
||||
OnSyncCodesNotify();
|
||||
break;
|
||||
|
||||
case SYNC_CODES_NOTIFY_GECKO:
|
||||
case SyncCodeID::NotifyGecko:
|
||||
OnSyncCodesNotifyGecko(packet);
|
||||
break;
|
||||
|
||||
case SYNC_CODES_DATA_GECKO:
|
||||
case SyncCodeID::GeckoData:
|
||||
OnSyncCodesDataGecko(packet);
|
||||
break;
|
||||
|
||||
case SYNC_CODES_NOTIFY_AR:
|
||||
case SyncCodeID::NotifyAR:
|
||||
OnSyncCodesNotifyAR(packet);
|
||||
break;
|
||||
|
||||
case SYNC_CODES_DATA_AR:
|
||||
case SyncCodeID::ARData:
|
||||
OnSyncCodesDataAR(packet);
|
||||
break;
|
||||
|
||||
|
@ -1761,7 +1761,7 @@ void NetPlayClient::SyncSaveDataResponse(const bool success)
|
|||
{
|
||||
sf::Packet response_packet;
|
||||
response_packet << MessageID::SyncSaveData;
|
||||
response_packet << static_cast<MessageId>(SYNC_SAVE_DATA_SUCCESS);
|
||||
response_packet << SyncSaveDataID::Success;
|
||||
|
||||
Send(response_packet);
|
||||
}
|
||||
|
@ -1770,7 +1770,7 @@ void NetPlayClient::SyncSaveDataResponse(const bool success)
|
|||
{
|
||||
sf::Packet response_packet;
|
||||
response_packet << MessageID::SyncSaveData;
|
||||
response_packet << static_cast<MessageId>(SYNC_SAVE_DATA_FAILURE);
|
||||
response_packet << SyncSaveDataID::Failure;
|
||||
|
||||
Send(response_packet);
|
||||
}
|
||||
|
@ -1785,7 +1785,7 @@ void NetPlayClient::SyncCodeResponse(const bool success)
|
|||
|
||||
sf::Packet response_packet;
|
||||
response_packet << MessageID::SyncCodes;
|
||||
response_packet << static_cast<MessageId>(SYNC_CODES_FAILURE);
|
||||
response_packet << SyncCodeID::Failure;
|
||||
|
||||
Send(response_packet);
|
||||
return;
|
||||
|
@ -1798,7 +1798,7 @@ void NetPlayClient::SyncCodeResponse(const bool success)
|
|||
|
||||
sf::Packet response_packet;
|
||||
response_packet << MessageID::SyncCodes;
|
||||
response_packet << static_cast<MessageId>(SYNC_CODES_SUCCESS);
|
||||
response_packet << SyncCodeID::Success;
|
||||
|
||||
Send(response_packet);
|
||||
}
|
||||
|
|
|
@ -187,26 +187,26 @@ enum
|
|||
CON_ERR_NAME_TOO_LONG = 4
|
||||
};
|
||||
|
||||
enum
|
||||
enum class SyncSaveDataID : u8
|
||||
{
|
||||
SYNC_SAVE_DATA_NOTIFY = 0,
|
||||
SYNC_SAVE_DATA_SUCCESS = 1,
|
||||
SYNC_SAVE_DATA_FAILURE = 2,
|
||||
SYNC_SAVE_DATA_RAW = 3,
|
||||
SYNC_SAVE_DATA_GCI = 4,
|
||||
SYNC_SAVE_DATA_WII = 5,
|
||||
SYNC_SAVE_DATA_GBA = 6
|
||||
Notify = 0,
|
||||
Success = 1,
|
||||
Failure = 2,
|
||||
RawData = 3,
|
||||
GCIData = 4,
|
||||
WiiData = 5,
|
||||
GBAData = 6
|
||||
};
|
||||
|
||||
enum
|
||||
enum class SyncCodeID : u8
|
||||
{
|
||||
SYNC_CODES_NOTIFY = 0,
|
||||
SYNC_CODES_NOTIFY_GECKO = 1,
|
||||
SYNC_CODES_NOTIFY_AR = 2,
|
||||
SYNC_CODES_DATA_GECKO = 3,
|
||||
SYNC_CODES_DATA_AR = 4,
|
||||
SYNC_CODES_SUCCESS = 5,
|
||||
SYNC_CODES_FAILURE = 6,
|
||||
Notify = 0,
|
||||
NotifyGecko = 1,
|
||||
NotifyAR = 2,
|
||||
GeckoData = 3,
|
||||
ARData = 4,
|
||||
Success = 5,
|
||||
Failure = 6,
|
||||
};
|
||||
|
||||
constexpr u32 MAX_NAME_LENGTH = 30;
|
||||
|
|
|
@ -1105,12 +1105,12 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
|
||||
case MessageID::SyncSaveData:
|
||||
{
|
||||
MessageId sub_id;
|
||||
SyncSaveDataID sub_id;
|
||||
packet >> sub_id;
|
||||
|
||||
switch (sub_id)
|
||||
{
|
||||
case SYNC_SAVE_DATA_SUCCESS:
|
||||
case SyncSaveDataID::Success:
|
||||
{
|
||||
if (m_start_pending)
|
||||
{
|
||||
|
@ -1127,7 +1127,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
}
|
||||
break;
|
||||
|
||||
case SYNC_SAVE_DATA_FAILURE:
|
||||
case SyncSaveDataID::Failure:
|
||||
{
|
||||
m_dialog->AppendChat(Common::FmtFormatT("{0} failed to synchronize.", player.name));
|
||||
m_dialog->OnGameStartAborted();
|
||||
|
@ -1148,13 +1148,13 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
case MessageID::SyncCodes:
|
||||
{
|
||||
// Receive Status of Code Sync
|
||||
MessageId sub_id;
|
||||
SyncCodeID sub_id;
|
||||
packet >> sub_id;
|
||||
|
||||
// Check If Code Sync was successful or not
|
||||
switch (sub_id)
|
||||
{
|
||||
case SYNC_CODES_SUCCESS:
|
||||
case SyncCodeID::Success:
|
||||
{
|
||||
if (m_start_pending)
|
||||
{
|
||||
|
@ -1170,7 +1170,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
}
|
||||
break;
|
||||
|
||||
case SYNC_CODES_FAILURE:
|
||||
case SyncCodeID::Failure:
|
||||
{
|
||||
m_dialog->AppendChat(Common::FmtFormatT("{0} failed to synchronize codes.", player.name));
|
||||
m_dialog->OnGameStartAborted();
|
||||
|
@ -1620,7 +1620,7 @@ bool NetPlayServer::SyncSaveData()
|
|||
{
|
||||
sf::Packet pac;
|
||||
pac << MessageID::SyncSaveData;
|
||||
pac << static_cast<MessageId>(SYNC_SAVE_DATA_NOTIFY);
|
||||
pac << SyncSaveDataID::Notify;
|
||||
pac << save_count;
|
||||
|
||||
// send this on the chunked data channel to ensure it's sequenced properly
|
||||
|
@ -1657,7 +1657,7 @@ bool NetPlayServer::SyncSaveData()
|
|||
|
||||
sf::Packet pac;
|
||||
pac << MessageID::SyncSaveData;
|
||||
pac << static_cast<MessageId>(SYNC_SAVE_DATA_RAW);
|
||||
pac << SyncSaveDataID::RawData;
|
||||
pac << is_slot_a << region << size_override;
|
||||
|
||||
if (File::Exists(path))
|
||||
|
@ -1682,7 +1682,7 @@ bool NetPlayServer::SyncSaveData()
|
|||
|
||||
sf::Packet pac;
|
||||
pac << MessageID::SyncSaveData;
|
||||
pac << static_cast<MessageId>(SYNC_SAVE_DATA_GCI);
|
||||
pac << SyncSaveDataID::GCIData;
|
||||
pac << is_slot_a;
|
||||
|
||||
if (File::IsDirectory(path))
|
||||
|
@ -1734,7 +1734,7 @@ bool NetPlayServer::SyncSaveData()
|
|||
|
||||
sf::Packet pac;
|
||||
pac << MessageID::SyncSaveData;
|
||||
pac << static_cast<MessageId>(SYNC_SAVE_DATA_WII);
|
||||
pac << SyncSaveDataID::WiiData;
|
||||
|
||||
// Shove the Mii data into the start the packet
|
||||
{
|
||||
|
@ -1825,7 +1825,7 @@ bool NetPlayServer::SyncSaveData()
|
|||
{
|
||||
sf::Packet pac;
|
||||
pac << MessageID::SyncSaveData;
|
||||
pac << static_cast<MessageId>(SYNC_SAVE_DATA_GBA);
|
||||
pac << SyncSaveDataID::GBAData;
|
||||
pac << static_cast<u8>(i);
|
||||
|
||||
std::string path;
|
||||
|
@ -1882,7 +1882,7 @@ bool NetPlayServer::SyncCodes()
|
|||
{
|
||||
sf::Packet pac;
|
||||
pac << MessageID::SyncCodes;
|
||||
pac << static_cast<MessageId>(SYNC_CODES_NOTIFY);
|
||||
pac << SyncCodeID::Notify;
|
||||
SendAsyncToClients(std::move(pac));
|
||||
}
|
||||
// Sync Gecko Codes
|
||||
|
@ -1910,7 +1910,7 @@ bool NetPlayServer::SyncCodes()
|
|||
{
|
||||
sf::Packet pac;
|
||||
pac << MessageID::SyncCodes;
|
||||
pac << static_cast<MessageId>(SYNC_CODES_NOTIFY_GECKO);
|
||||
pac << SyncCodeID::NotifyGecko;
|
||||
pac << codelines;
|
||||
SendAsyncToClients(std::move(pac));
|
||||
}
|
||||
|
@ -1919,7 +1919,7 @@ bool NetPlayServer::SyncCodes()
|
|||
{
|
||||
sf::Packet pac;
|
||||
pac << MessageID::SyncCodes;
|
||||
pac << static_cast<MessageId>(SYNC_CODES_DATA_GECKO);
|
||||
pac << SyncCodeID::GeckoData;
|
||||
// Iterate through the active code vector and send each codeline
|
||||
for (const Gecko::GeckoCode& active_code : s_active_codes)
|
||||
{
|
||||
|
@ -1960,7 +1960,7 @@ bool NetPlayServer::SyncCodes()
|
|||
{
|
||||
sf::Packet pac;
|
||||
pac << MessageID::SyncCodes;
|
||||
pac << static_cast<MessageId>(SYNC_CODES_NOTIFY_AR);
|
||||
pac << SyncCodeID::NotifyAR;
|
||||
pac << codelines;
|
||||
SendAsyncToClients(std::move(pac));
|
||||
}
|
||||
|
@ -1969,7 +1969,7 @@ bool NetPlayServer::SyncCodes()
|
|||
{
|
||||
sf::Packet pac;
|
||||
pac << MessageID::SyncCodes;
|
||||
pac << static_cast<MessageId>(SYNC_CODES_DATA_AR);
|
||||
pac << SyncCodeID::ARData;
|
||||
// Iterate through the active code vector and send each codeline
|
||||
for (const ActionReplay::ARCode& active_code : s_active_codes)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue