2013-12-19 12:32:23 +01:00
|
|
|
//////////////////////////////////////////////////////////
|
|
|
|
// Created 2013 //
|
|
|
|
// Dennis Andersen, Linda Andersson //
|
|
|
|
//////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef GAMELOGIC_LOBBY_PROTOCOLS_H
|
|
|
|
#define GAMELOGIC_LOBBY_PROTOCOLS_H
|
|
|
|
|
|
|
|
#include <CustomNetProtocol.h>
|
|
|
|
#include "ProtocolIdentificationID.h"
|
|
|
|
|
2014-01-22 15:22:52 +01:00
|
|
|
#include <DynamicArray.h>
|
|
|
|
|
2014-01-21 14:32:42 +01:00
|
|
|
|
2013-12-19 12:32:23 +01:00
|
|
|
namespace GameLogic
|
|
|
|
{
|
|
|
|
struct Protocol_LobbyCreateGame :public Oyster::Network::CustomProtocolObject
|
|
|
|
{
|
|
|
|
char* mapName;
|
|
|
|
char gameId;
|
|
|
|
|
|
|
|
Protocol_LobbyCreateGame()
|
|
|
|
{
|
2014-01-22 15:22:52 +01:00
|
|
|
this->protocol[protocol_INDEX_ID].value = protocol_Lobby_Create;
|
2014-01-07 10:26:09 +01:00
|
|
|
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
2013-12-19 12:32:23 +01:00
|
|
|
|
|
|
|
this->protocol[1].type = Oyster::Network::NetAttributeType_CharArray;
|
|
|
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Char;
|
|
|
|
}
|
|
|
|
Protocol_LobbyCreateGame(Oyster::Network::CustomNetProtocol& o)
|
|
|
|
{
|
|
|
|
mapName = o[1].value.netCharPtr;
|
|
|
|
gameId = o[2].value.netChar;
|
|
|
|
}
|
|
|
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
|
|
|
{
|
|
|
|
protocol[1].value = mapName;
|
|
|
|
protocol[2].value = gameId;
|
|
|
|
return &protocol;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Oyster::Network::CustomNetProtocol protocol;
|
|
|
|
};
|
|
|
|
|
2014-01-21 14:32:42 +01:00
|
|
|
struct Protocol_LobbyStartGame :public Oyster::Network::CustomProtocolObject
|
2013-12-19 12:32:23 +01:00
|
|
|
{
|
|
|
|
char gameId;
|
|
|
|
|
2014-01-21 14:32:42 +01:00
|
|
|
Protocol_LobbyStartGame()
|
2013-12-19 12:32:23 +01:00
|
|
|
{
|
2014-01-22 15:22:52 +01:00
|
|
|
this->protocol[protocol_INDEX_ID].value = protocol_Lobby_Start;
|
2014-01-07 10:26:09 +01:00
|
|
|
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
2013-12-19 12:32:23 +01:00
|
|
|
|
|
|
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Char;
|
|
|
|
}
|
|
|
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
|
|
|
{
|
|
|
|
protocol[1].value = gameId;
|
|
|
|
return &protocol;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Oyster::Network::CustomNetProtocol protocol;
|
|
|
|
};
|
|
|
|
|
2014-01-22 15:22:52 +01:00
|
|
|
struct Protocol_LobbyLogin :public Oyster::Network::CustomProtocolObject
|
2013-12-19 12:32:23 +01:00
|
|
|
{
|
2014-01-22 15:22:52 +01:00
|
|
|
// Login stuff
|
|
|
|
Protocol_LobbyLogin()
|
2013-12-19 12:32:23 +01:00
|
|
|
{
|
2014-01-22 15:22:52 +01:00
|
|
|
this->protocol[protocol_INDEX_ID].value = protocol_Lobby_Join;
|
2014-01-07 10:26:09 +01:00
|
|
|
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
2013-12-19 12:32:23 +01:00
|
|
|
|
2014-01-22 15:22:52 +01:00
|
|
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
|
2013-12-19 12:32:23 +01:00
|
|
|
}
|
|
|
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
|
|
|
{
|
|
|
|
return &protocol;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Oyster::Network::CustomNetProtocol protocol;
|
|
|
|
};
|
|
|
|
|
2014-01-22 15:22:52 +01:00
|
|
|
struct Protocol_LobbyJoin :public Oyster::Network::CustomProtocolObject
|
2013-12-19 12:32:23 +01:00
|
|
|
{
|
2014-01-22 15:22:52 +01:00
|
|
|
short value;
|
|
|
|
|
|
|
|
Protocol_LobbyJoin()
|
2013-12-19 12:32:23 +01:00
|
|
|
{
|
2014-01-22 15:22:52 +01:00
|
|
|
this->protocol[protocol_INDEX_ID].value = protocol_Lobby_Join;
|
2014-01-07 10:26:09 +01:00
|
|
|
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
2014-01-22 15:22:52 +01:00
|
|
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
|
2014-01-07 10:26:09 +01:00
|
|
|
}
|
2014-01-22 15:22:52 +01:00
|
|
|
Protocol_LobbyJoin(Oyster::Network::CustomNetProtocol& p)
|
2014-01-07 10:26:09 +01:00
|
|
|
{
|
2014-01-22 15:22:52 +01:00
|
|
|
this->protocol[protocol_INDEX_ID].value = protocol_Lobby_Join;
|
|
|
|
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
|
|
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
|
|
|
|
value = p[1].value.netShort;
|
2013-12-19 12:32:23 +01:00
|
|
|
}
|
|
|
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
|
|
|
{
|
2014-01-22 15:22:52 +01:00
|
|
|
protocol[1].value = value;
|
2013-12-19 12:32:23 +01:00
|
|
|
return &protocol;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Oyster::Network::CustomNetProtocol protocol;
|
|
|
|
};
|
|
|
|
|
2014-01-22 15:22:52 +01:00
|
|
|
struct Protocol_LobbyRefresh :public Oyster::Network::CustomProtocolObject
|
2013-12-19 12:32:23 +01:00
|
|
|
{
|
2014-01-22 15:22:52 +01:00
|
|
|
Protocol_LobbyRefresh()
|
2013-12-19 12:32:23 +01:00
|
|
|
{
|
2014-01-22 15:22:52 +01:00
|
|
|
this->protocol[protocol_INDEX_ID].value = protocol_Lobby_Login;
|
2014-01-07 10:26:09 +01:00
|
|
|
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
2013-12-19 12:32:23 +01:00
|
|
|
}
|
|
|
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
2014-01-22 15:22:52 +01:00
|
|
|
{ return &protocol; }
|
2013-12-19 12:32:23 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Oyster::Network::CustomNetProtocol protocol;
|
|
|
|
};
|
|
|
|
|
2014-01-22 15:22:52 +01:00
|
|
|
/**
|
|
|
|
* A protocol that contains all data to send to client when update game lobby
|
|
|
|
*/
|
|
|
|
struct Protocol_LobbyGameData :public Oyster::Network::CustomProtocolObject
|
2014-01-07 10:26:09 +01:00
|
|
|
{
|
2014-01-22 15:22:52 +01:00
|
|
|
// Player list
|
|
|
|
struct PlayerData
|
2014-01-07 10:26:09 +01:00
|
|
|
{
|
2014-01-22 15:22:52 +01:00
|
|
|
std::string name;
|
|
|
|
int id;
|
2014-01-07 10:26:09 +01:00
|
|
|
};
|
2014-01-22 15:22:52 +01:00
|
|
|
Utility::DynamicMemory::DynamicArray<PlayerData> list;
|
|
|
|
|
|
|
|
Protocol_LobbyGameData()
|
2014-01-07 10:26:09 +01:00
|
|
|
{
|
2014-01-22 15:22:52 +01:00
|
|
|
this->protocol[protocol_INDEX_ID].value = protocol_Lobby_GameData;
|
2014-01-07 10:26:09 +01:00
|
|
|
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
|
|
|
|
2014-01-22 15:22:52 +01:00
|
|
|
list.Reserve(10);
|
2014-01-07 10:26:09 +01:00
|
|
|
}
|
2014-01-22 15:22:52 +01:00
|
|
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
2014-01-07 10:26:09 +01:00
|
|
|
{
|
2014-01-22 15:22:52 +01:00
|
|
|
int a = 1;
|
|
|
|
for (unsigned int i = 0; i < list.Size(); i++)
|
2014-01-07 10:26:09 +01:00
|
|
|
{
|
2014-01-22 15:22:52 +01:00
|
|
|
this->protocol[a].type = Oyster::Network::NetAttributeType_Int;
|
|
|
|
this->protocol[a].type = Oyster::Network::NetAttributeType_CharArray;
|
|
|
|
|
|
|
|
this->protocol[a].value = list[i].id;
|
|
|
|
this->protocol.Set(a, list[i].name);
|
2014-01-07 10:26:09 +01:00
|
|
|
}
|
2014-01-22 15:22:52 +01:00
|
|
|
return &protocol;
|
2014-01-07 10:26:09 +01:00
|
|
|
}
|
2014-01-22 15:22:52 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Oyster::Network::CustomNetProtocol protocol;
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* A protocol that contains all data to send to client when update main lobby
|
|
|
|
*/
|
|
|
|
struct Protocol_LobbyMainData :public Oyster::Network::CustomProtocolObject
|
|
|
|
{
|
|
|
|
// Game instance list
|
|
|
|
|
|
|
|
Protocol_LobbyMainData()
|
2014-01-07 10:26:09 +01:00
|
|
|
{
|
2014-01-22 15:22:52 +01:00
|
|
|
this->protocol[protocol_INDEX_ID].value = protocol_Lobby_MainData;
|
|
|
|
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
|
|
|
|
|
|
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
|
2014-01-07 10:26:09 +01:00
|
|
|
}
|
|
|
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
|
|
|
{
|
|
|
|
return &protocol;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Oyster::Network::CustomNetProtocol protocol;
|
|
|
|
};
|
2013-12-19 12:32:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H
|