Files
MesenCE/Core/Netplay/PlayerListMessage.h
SourMesen e391fd8f9a Code: Add auto-formatting rules for C++ (clang-format) and enforce in CI via "clang-format" and "dotnet format" (#78)
* Code: Add auto-formatting rules for C++ projects (clang-format) and enforce code style via "clang-format" and "dotnet format"

* fix ui format warnings
2026-04-30 06:03:55 -07:00

46 lines
1.0 KiB
C++

#pragma once
#include "pch.h"
#include "Netplay/NetMessage.h"
class PlayerListMessage : public NetMessage
{
private:
vector<PlayerInfo> _playerList;
protected:
void Serialize(Serializer& s) override
{
if(s.IsSaving()) {
uint32_t playerCount = (uint32_t)_playerList.size();
SV(playerCount);
for(uint32_t i = 0; i < playerCount; i++) {
SVI(_playerList[i].ControllerPort.Port);
SVI(_playerList[i].ControllerPort.SubPort);
SVI(_playerList[i].IsHost);
}
} else {
uint32_t playerCount = 0;
SV(playerCount);
_playerList.resize(playerCount);
for(uint32_t i = 0; i < playerCount; i++) {
SVI(_playerList[i].ControllerPort.Port);
SVI(_playerList[i].ControllerPort.SubPort);
SVI(_playerList[i].IsHost);
}
}
}
public:
PlayerListMessage(void* buffer, uint32_t length) : NetMessage(buffer, length) {}
PlayerListMessage(vector<PlayerInfo> playerList) : NetMessage(MessageType::PlayerList)
{
_playerList = playerList;
}
vector<PlayerInfo> GetPlayerList()
{
return _playerList;
}
};