GameServer - Added more protocols. Divided the code in gamesession into several .cpp files
This commit is contained in:
parent
eb9360377d
commit
97cba4248d
|
@ -5,7 +5,7 @@
|
||||||
#include "GameClientState/GameClientState.h"
|
#include "GameClientState/GameClientState.h"
|
||||||
#include "GameClientState\GameState.h"
|
#include "GameClientState\GameState.h"
|
||||||
#include "GameClientState\LobbyState.h"
|
#include "GameClientState\LobbyState.h"
|
||||||
#include <GameProtocols.h>
|
#include <Protocols.h>
|
||||||
#include "NetworkClient.h"
|
#include "NetworkClient.h"
|
||||||
|
|
||||||
#include "../WindowManager/WindowShell.h"
|
#include "../WindowManager/WindowShell.h"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "DllInterfaces/GFXAPI.h"
|
#include "DllInterfaces/GFXAPI.h"
|
||||||
#include "C_obj/C_Player.h"
|
#include "C_obj/C_Player.h"
|
||||||
#include "C_obj/C_DynamicObj.h"
|
#include "C_obj/C_DynamicObj.h"
|
||||||
#include <GameProtocols.h>
|
#include <Protocols.h>
|
||||||
#include "NetworkClient.h"
|
#include "NetworkClient.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "GameClient.h"
|
#include "GameClient.h"
|
||||||
#include "..\LobbySessions\NetworkSession.h"
|
#include "..\LobbySessions\NetworkSession.h"
|
||||||
#include <Game.h>
|
#include <Game.h>
|
||||||
#include <GameProtocols.h>
|
#include <Protocols.h>
|
||||||
|
|
||||||
using namespace Utility::DynamicMemory;
|
using namespace Utility::DynamicMemory;
|
||||||
using namespace DanBias;
|
using namespace DanBias;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "GameSession.h"
|
#include "GameSession.h"
|
||||||
#include "GameClient.h"
|
#include "GameClient.h"
|
||||||
|
|
||||||
#include <GameProtocols.h>
|
#include <Protocols.h>
|
||||||
#include <PostBox\PostBox.h>
|
#include <PostBox\PostBox.h>
|
||||||
#include <GameLogicStates.h>
|
#include <GameLogicStates.h>
|
||||||
#include <OysterMath.h>
|
#include <OysterMath.h>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "GameSession.h"
|
#include "GameSession.h"
|
||||||
#include "GameClient.h"
|
#include "GameClient.h"
|
||||||
#include "..\GameServer.h"
|
#include "..\GameServer.h"
|
||||||
#include <GameProtocols.h>
|
#include <Protocols.h>
|
||||||
#include <PostBox\PostBox.h>
|
#include <PostBox\PostBox.h>
|
||||||
#include <GameLogicStates.h>
|
#include <GameLogicStates.h>
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "GameSession.h"
|
#include "GameSession.h"
|
||||||
#include "GameClient.h"
|
#include "GameClient.h"
|
||||||
|
|
||||||
#include <GameProtocols.h>
|
#include <Protocols.h>
|
||||||
#include <PostBox\PostBox.h>
|
#include <PostBox\PostBox.h>
|
||||||
#include <GameLogicStates.h>
|
#include <GameLogicStates.h>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "GameSession.h"
|
#include "GameSession.h"
|
||||||
#include "GameClient.h"
|
#include "GameClient.h"
|
||||||
|
|
||||||
#include <GameProtocols.h>
|
#include <Protocols.h>
|
||||||
#include <PostBox\PostBox.h>
|
#include <PostBox\PostBox.h>
|
||||||
#include <GameLogicStates.h>
|
#include <GameLogicStates.h>
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "LobbyClient.h"
|
#include "LobbyClient.h"
|
||||||
#include <GameProtocols.h>
|
#include <Protocols.h>
|
||||||
|
|
||||||
using namespace Utility::DynamicMemory;
|
using namespace Utility::DynamicMemory;
|
||||||
using namespace Oyster::Network;
|
using namespace Oyster::Network;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#include "NetworkSession.h"
|
#include "NetworkSession.h"
|
||||||
#include "GameLobby.h"
|
#include "GameLobby.h"
|
||||||
#include <GameProtocols.h>
|
#include <Protocols.h>
|
||||||
#include <PostBox\IPostBox.h>
|
#include <PostBox\IPostBox.h>
|
||||||
|
|
||||||
namespace DanBias
|
namespace DanBias
|
||||||
|
|
|
@ -9,9 +9,7 @@
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
|
class DynamicObject : public Object
|
||||||
|
|
||||||
class DANBIAS_GAMELOGIC_DLL DynamicObject : public Object
|
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -8,12 +8,11 @@
|
||||||
|
|
||||||
|
|
||||||
#include "GameLogicStates.h"
|
#include "GameLogicStates.h"
|
||||||
#include "GameLogicDef.h"
|
|
||||||
#include <PhysicsAPI.h>
|
#include <PhysicsAPI.h>
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
class DANBIAS_GAMELOGIC_DLL Object
|
class Object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Object();
|
Object();
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace GameLogic
|
||||||
States_ready,
|
States_ready,
|
||||||
States_idle,
|
States_idle,
|
||||||
States_bussy,
|
States_bussy,
|
||||||
|
State_waiting,
|
||||||
States_disconected,
|
States_disconected,
|
||||||
};
|
};
|
||||||
States status;
|
States status;
|
||||||
|
|
|
@ -155,7 +155,8 @@
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="ControlProtocols.h" />
|
<ClInclude Include="ControlProtocols.h" />
|
||||||
<ClInclude Include="GameProtocols.h" />
|
<ClInclude Include="GameplayProtocols.h" />
|
||||||
|
<ClInclude Include="Protocols.h" />
|
||||||
<ClInclude Include="LobbyProtocols.h" />
|
<ClInclude Include="LobbyProtocols.h" />
|
||||||
<ClInclude Include="ObjectProtocols.h" />
|
<ClInclude Include="ObjectProtocols.h" />
|
||||||
<ClInclude Include="PlayerProtocols.h" />
|
<ClInclude Include="PlayerProtocols.h" />
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
#ifndef GAMEPROTOCOLS_GAMEPLAYPROTOCOLS_H
|
||||||
|
#define GAMEPROTOCOLS_GAMEPLAYPROTOCOLS_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <CustomNetProtocol.h>
|
||||||
|
#include "ProtocolIdentificationID.h"
|
||||||
|
|
||||||
|
namespace GameLogic
|
||||||
|
{
|
||||||
|
struct Protocol_GameplayInitiateSession :public Oyster::Network::CustomProtocolObject
|
||||||
|
{
|
||||||
|
struct SessionInitData
|
||||||
|
{
|
||||||
|
int id;
|
||||||
|
int type;
|
||||||
|
//std::string text;
|
||||||
|
};
|
||||||
|
std::vector<SessionInitData> element;
|
||||||
|
|
||||||
|
Protocol_GameplayInitiateSession()
|
||||||
|
{
|
||||||
|
this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_Initiate;
|
||||||
|
this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
|
||||||
|
}
|
||||||
|
Protocol_GameplayInitiateSession(Oyster::Network::CustomNetProtocol& p)
|
||||||
|
{
|
||||||
|
int size = p[1].value.netInt;
|
||||||
|
for (int i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
SessionInitData d = { p[i+2].value.netInt, p[i+3].value.netInt /*, p[i+4].value.netCharPtr */ };
|
||||||
|
element.push_back(d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void Add(int id, int type, std::string text)
|
||||||
|
{
|
||||||
|
SessionInitData d = { id, type /*, text*/ };
|
||||||
|
element.push_back(d);
|
||||||
|
}
|
||||||
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
||||||
|
{
|
||||||
|
//Store the elements count
|
||||||
|
this->protocol[1].value = element.size();
|
||||||
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < element.size(); i+=3)
|
||||||
|
{
|
||||||
|
this->protocol[i+2].value = element[i].id;
|
||||||
|
this->protocol[i+3].value = element[i].type;
|
||||||
|
//element[i].text.copy(this->protocol[i+4].value.netCharPtr, element[i].text.size());
|
||||||
|
|
||||||
|
this->protocol[i+2].type = Oyster::Network::NetAttributeType_Int;
|
||||||
|
this->protocol[i+3].type = Oyster::Network::NetAttributeType_Int;
|
||||||
|
//this->protocol[i+4].type = Oyster::Network::NetAttributeType_CharArray;
|
||||||
|
}
|
||||||
|
return &protocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Oyster::Network::CustomNetProtocol protocol;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // !GAMEPROTOCOLS_GAMEPLAYPROTOCOLS_H
|
|
@ -22,7 +22,7 @@
|
||||||
/***********************************/
|
/***********************************/
|
||||||
/********* GENERAL PROTOCOLS ***************************************************************************************************/
|
/********* GENERAL PROTOCOLS ***************************************************************************************************/
|
||||||
/***********[ 100 - 200 ]***********/
|
/***********[ 100 - 200 ]***********/
|
||||||
#define protocol_GeneralMIN 100 /* This defines lower bounds of general protocols (okay to have same value on first element). */
|
#define protocol_GeneralMIN 100
|
||||||
#define protocol_General_Status 100
|
#define protocol_General_Status 100
|
||||||
#define protocol_General_Text 101
|
#define protocol_General_Text 101
|
||||||
#define protocol_GeneralMAX 199
|
#define protocol_GeneralMAX 199
|
||||||
|
@ -51,6 +51,7 @@
|
||||||
#define protocol_Gameplay_CreateObject 303
|
#define protocol_Gameplay_CreateObject 303
|
||||||
#define protocol_Gameplay_RemoveObject 304
|
#define protocol_Gameplay_RemoveObject 304
|
||||||
#define protocol_Gameplay_ObjectPosition 305
|
#define protocol_Gameplay_ObjectPosition 305
|
||||||
|
#define protocol_Gameplay_Initiate 306
|
||||||
#define protocol_GameplayMAX 399
|
#define protocol_GameplayMAX 399
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,11 +62,4 @@ inline bool ProtocolIsLobby(short ID) { return (ID >= protocol_LobbyMIN && ID <=
|
||||||
inline bool ProtocolIsGeneral(short ID) { return (ID >= protocol_GeneralMIN && ID <= protocol_GeneralMAX); }
|
inline bool ProtocolIsGeneral(short ID) { return (ID >= protocol_GeneralMIN && ID <= protocol_GeneralMAX); }
|
||||||
inline bool ProtocolIsGameplay(short ID) { return (ID >= protocol_GameplayMIN && ID <= protocol_GameplayMAX); }
|
inline bool ProtocolIsGameplay(short ID) { return (ID >= protocol_GameplayMIN && ID <= protocol_GameplayMAX); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************/
|
|
||||||
/*********** TEST PROTOCOLS *******************************************************************************************************/
|
|
||||||
/***********[ x - x ]************/
|
|
||||||
|
|
||||||
|
|
||||||
#endif // !GAMEPROTOCOL_PROTOCOL_DEFINITION_ID_H
|
#endif // !GAMEPROTOCOL_PROTOCOL_DEFINITION_ID_H
|
||||||
|
|
|
@ -5,5 +5,6 @@
|
||||||
#include "PlayerProtocols.h"
|
#include "PlayerProtocols.h"
|
||||||
#include "LobbyProtocols.h"
|
#include "LobbyProtocols.h"
|
||||||
#include "ControlProtocols.h"
|
#include "ControlProtocols.h"
|
||||||
|
#include "GameplayProtocols.h"
|
||||||
|
|
||||||
#endif // !GAMEPROTOCOLS_GAMEPROTOCOLS_H
|
#endif // !GAMEPROTOCOLS_GAMEPROTOCOLS_H
|
Loading…
Reference in New Issue