GL - Connection to network in clinet
This commit is contained in:
parent
4617523f8b
commit
7c1d19946d
Binary file not shown.
Binary file not shown.
|
@ -196,6 +196,7 @@ Global
|
|||
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.Build.0 = Debug|x64
|
||||
{2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||
<LibraryPath>$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>$(SolutionDir)Network/NetworkAPI;$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network/NetworkAPI;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
|
@ -106,13 +106,13 @@
|
|||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Game/GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName)D.dll;OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
|
|
|
@ -22,33 +22,50 @@ namespace DanBias
|
|||
#pragma region Game Data
|
||||
|
||||
|
||||
struct MyRecieverObject // :public PontusRecieverObject
|
||||
struct MyRecieverObject :public Oyster::Network::ProtocolRecieverObject
|
||||
{
|
||||
Oyster::Network::NetworkClient nwClient;
|
||||
|
||||
static void ProtocolRecieved(Network::CustomNetProtocol* p)
|
||||
{
|
||||
int pType = ((*p)[0]).value.netInt;
|
||||
switch (pType)
|
||||
{
|
||||
case protocol_PlayerNavigation:
|
||||
|
||||
break;
|
||||
case protocol_PlayerPosition:
|
||||
//int x = ((*p)[1]).value.netInt;
|
||||
//int y = ((*p)[2]).value.netInt;
|
||||
//int z = ((*p)[3]).value.netInt;
|
||||
break;
|
||||
Oyster::Network::NetworkClient* nwClient;
|
||||
Client::GameClientState* gameClientState;
|
||||
|
||||
void ProtocolRecievedCallback(Oyster::Network::CustomNetProtocol& p) override
|
||||
{
|
||||
|
||||
int pType = p[0].value.netInt;
|
||||
Client::GameClientState::ProtocolStruct* protocol;
|
||||
switch (pType)
|
||||
{
|
||||
case protocol_PlayerNavigation:
|
||||
|
||||
break;
|
||||
case protocol_PlayerPosition:
|
||||
protocol = new Client::GameClientState::PlayerPos;
|
||||
for(int i = 0; i< 3; i++)
|
||||
{
|
||||
((Client::GameClientState::PlayerPos*)protocol)->playerPos[i] = p[i].value.netFloat;
|
||||
}
|
||||
gameClientState->Protocol(protocol);
|
||||
delete protocol;
|
||||
protocol = NULL;
|
||||
break;
|
||||
|
||||
|
||||
case protocol_ObjectPosition:
|
||||
// DanBiasGame::protocolRecived();
|
||||
break;
|
||||
case protocol_ObjectPosition:
|
||||
protocol = new Client::GameClientState::ObjPos;
|
||||
for(int i = 0; i< 16; i++)
|
||||
{
|
||||
((Client::GameClientState::ObjPos*)protocol)->worldPos[i] = p[i].value.netFloat;
|
||||
}
|
||||
gameClientState->Protocol(protocol);
|
||||
delete protocol;
|
||||
protocol = NULL;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
class DanBiasGamePrivateData
|
||||
{
|
||||
|
@ -63,24 +80,17 @@ namespace DanBias
|
|||
|
||||
}
|
||||
|
||||
public:
|
||||
Client::GameClientState* gameClientState;
|
||||
InputClass* inputObj;
|
||||
GameLogic::Protocol_PlayerMovement player_move;
|
||||
//Oyster::Network::NetworkClient nwClient;
|
||||
MyRecieverObject r;
|
||||
|
||||
// gameClient;
|
||||
public:
|
||||
Client::GameClientState* gameClientState;
|
||||
InputClass* inputObj;
|
||||
MyRecieverObject* r;
|
||||
|
||||
} data;
|
||||
#pragma endregion
|
||||
|
||||
|
||||
DanBiasGamePrivateData* DanBiasGame::m_data = new DanBiasGamePrivateData();
|
||||
void DanBiasGame::protocolRecived()
|
||||
{
|
||||
//m_data->gameClientState.setPos()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Interface API functions
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
@ -106,6 +116,9 @@ namespace DanBias
|
|||
// Start in lobby state
|
||||
m_data->gameClientState = new Client::LobbyState();
|
||||
m_data->gameClientState->Init();
|
||||
m_data->r = new MyRecieverObject;
|
||||
m_data->r->nwClient = new Oyster::Network::NetworkClient();
|
||||
|
||||
return DanBiasClientReturn_Sucess;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,26 @@ namespace Client
|
|||
class GameClientState
|
||||
{
|
||||
public:
|
||||
struct ProtocolStruct
|
||||
{
|
||||
|
||||
};
|
||||
struct ObjPos :public ProtocolStruct
|
||||
{
|
||||
float worldPos[16];
|
||||
};
|
||||
struct PlayerPos :public ProtocolStruct
|
||||
{
|
||||
float playerPos[3];
|
||||
};
|
||||
struct PlayerMove :public ProtocolStruct
|
||||
{
|
||||
float playerPos[3];
|
||||
};
|
||||
struct PlayerName :public ProtocolStruct
|
||||
{
|
||||
char name[255];
|
||||
};
|
||||
enum ClientState
|
||||
{
|
||||
ClientState_Lobby,
|
||||
|
@ -26,6 +46,8 @@ public:
|
|||
virtual ClientState Update(float deltaTime, InputClass* KeyInput) = 0;
|
||||
virtual bool Render() = 0;
|
||||
virtual bool Release() = 0;
|
||||
virtual void Protocol(ProtocolStruct* protocolStruct) = 0;
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#include "DllInterfaces/GFXAPI.h"
|
||||
#include "Obj/C_Player.h"
|
||||
#include "Obj/C_DynamicObj.h"
|
||||
#include "NetworkClient.h"
|
||||
#include "PlayerProtocols.h"
|
||||
|
||||
using namespace DanBias::Client;
|
||||
|
||||
|
@ -12,8 +14,9 @@ struct GameState::myData
|
|||
Oyster::Math3D::Float4x4 proj;
|
||||
C_Object* object[3];
|
||||
int modelCount;
|
||||
//Oyster::Network::NetworkClient* nwClient;
|
||||
Oyster::Network::NetworkClient* nwClient;
|
||||
gameStateState state;
|
||||
|
||||
}privData;
|
||||
|
||||
GameState::GameState(void)
|
||||
|
@ -33,7 +36,7 @@ bool GameState::Init()
|
|||
privData->state = LoadGame();
|
||||
return true;
|
||||
}
|
||||
GameState::gameStateState GameState::LoadGame()
|
||||
GameState::gameStateState GameState::LoadGame()
|
||||
{
|
||||
LoadModels(L"map");
|
||||
InitCamera(Oyster::Math::Float3(0,0,5.4f));
|
||||
|
@ -88,9 +91,14 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
|
|||
// read server data
|
||||
// update objects
|
||||
// Client.send(obj);
|
||||
{
|
||||
GameLogic::Protocol_PlayerMovement movePlayer;
|
||||
|
||||
//privData->nwClient->Send(movePlayer);
|
||||
|
||||
if(KeyInput->IsKeyPressed(DIK_L))
|
||||
privData->state = GameState::gameStateState_end;
|
||||
}
|
||||
break;
|
||||
case gameStateState_end:
|
||||
return ClientState_Lobby;
|
||||
|
@ -126,4 +134,21 @@ bool GameState::Release()
|
|||
delete privData;
|
||||
privData = NULL;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void GameState::Protocol(ProtocolStruct* pos)
|
||||
{
|
||||
if((ObjPos*)pos)
|
||||
ObjectPosProtocol((ObjPos*)pos);
|
||||
else if((PlayerPos*)pos)
|
||||
PlayerPosProtocol((PlayerPos*)pos);
|
||||
}
|
||||
void GameState::PlayerPosProtocol(PlayerPos* pos)
|
||||
{
|
||||
|
||||
}
|
||||
void GameState::ObjectPosProtocol(ObjPos* pos)
|
||||
{
|
||||
|
||||
}
|
||||
//void GameState::Protocol(LightPos pos);
|
|
@ -23,13 +23,18 @@ public:
|
|||
GameState(void);
|
||||
~GameState(void);
|
||||
bool Init();
|
||||
GameClientState::ClientState Update(float deltaTime, InputClass* KeyInput);
|
||||
bool LoadModels(std::wstring mapFile);
|
||||
bool InitCamera(Oyster::Math::Float3 startPos);
|
||||
GameClientState::ClientState Update(float deltaTime, InputClass* KeyInput) override;
|
||||
bool LoadModels(std::wstring mapFile) ;
|
||||
bool InitCamera(Oyster::Math::Float3 startPos) ;
|
||||
gameStateState LoadGame();
|
||||
|
||||
bool Render();
|
||||
bool Release();
|
||||
bool Render()override;
|
||||
bool Release()override;
|
||||
|
||||
void Protocol(ProtocolStruct* pos)override;
|
||||
void PlayerPosProtocol(PlayerPos* pos);
|
||||
void ObjectPosProtocol(ObjPos* pos);
|
||||
//void Protocol(LightPos pos);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -118,4 +118,14 @@ bool LobbyState::Release()
|
|||
delete privData;
|
||||
privData = NULL;
|
||||
return true;
|
||||
}
|
||||
void LobbyState::Protocol(ProtocolStruct* protocol)
|
||||
{
|
||||
if((PlayerName*)protocol)
|
||||
PlayerJoinProtocol((PlayerName*)protocol);
|
||||
|
||||
}
|
||||
void LobbyState::PlayerJoinProtocol(PlayerName* name)
|
||||
{
|
||||
|
||||
}
|
|
@ -32,5 +32,8 @@ public:
|
|||
|
||||
bool Render();
|
||||
bool Release();
|
||||
void Protocol(ProtocolStruct* protocol)override;
|
||||
void PlayerJoinProtocol(PlayerName* name);
|
||||
|
||||
};};};
|
||||
#endif // ! DANBIAS_CLIENT_GAMECLIENTSTATE_H
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef DANBIASGAME_DANBIASGAME_H
|
||||
#define DANBIASGAME_DANBIASGAME_H
|
||||
|
||||
#define DANBIAS_CLIENT_L
|
||||
|
||||
#if defined (DANBIAS_GAME_DLL_EXPORT)
|
||||
#define DANBIAS_GAME_DLL __declspec(dllexport)
|
||||
#else
|
||||
|
@ -10,7 +12,7 @@
|
|||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
|
||||
#define DANBIAS_CLIENT
|
||||
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
|
@ -53,7 +55,6 @@ namespace DanBias
|
|||
static HRESULT Render(float deltaTime);
|
||||
static HRESULT CleanUp();
|
||||
|
||||
static void protocolRecived();
|
||||
private:
|
||||
static __int64 cntsPerSec;
|
||||
static __int64 prevTimeStamp;
|
||||
|
|
|
@ -110,7 +110,7 @@
|
|||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<DelayLoadDLLs>DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<DelayLoadDLLs>DanBiasGame_$(PlatformShortName)D.dll;DanBiasServer_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
<AdditionalDependencies>DanBiasGame_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
|
||||
#include "DanBiasServerAPI.h"
|
||||
//#include "DanBiasGame.h"
|
||||
//#include "DanBiasServerAPI.h"
|
||||
#include "DanBiasGame.h"
|
||||
|
||||
|
||||
int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdShow)
|
||||
|
@ -20,7 +20,7 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh
|
|||
DanBias::DanBiasServerAPI::Run();
|
||||
DanBias::DanBiasServerAPI::Release();
|
||||
}
|
||||
#elif defined(DANBIAS_CLIENT)
|
||||
#elif defined(DANBIAS_CLIENT_L)
|
||||
if(SetDllDirectory(L"..\\DLL") == FALSE)
|
||||
{
|
||||
return cmdShow;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
namespace GameLogic
|
||||
{
|
||||
struct Protocol_ObjectPosition :public Network::CustomProtocolObject
|
||||
struct Protocol_ObjectPosition :public Oyster::Network::CustomProtocolObject
|
||||
{
|
||||
float worldMatrix[16];
|
||||
// look at dir
|
||||
|
@ -16,27 +16,27 @@ namespace GameLogic
|
|||
Protocol_ObjectPosition()
|
||||
{
|
||||
this->protocol[0].value = protocol_PlayerPosition;
|
||||
this->protocol[0].type = Network::NetAttributeType_Int;
|
||||
|
||||
this->protocol[1].type = Network::NetAttributeType_Float;
|
||||
this->protocol[2].type = Network::NetAttributeType_Float;
|
||||
this->protocol[3].type = Network::NetAttributeType_Float;
|
||||
this->protocol[4].type = Network::NetAttributeType_Float;
|
||||
this->protocol[5].type = Network::NetAttributeType_Float;
|
||||
this->protocol[6].type = Network::NetAttributeType_Float;
|
||||
this->protocol[7].type = Network::NetAttributeType_Float;
|
||||
this->protocol[8].type = Network::NetAttributeType_Float;
|
||||
this->protocol[9].type = Network::NetAttributeType_Float;
|
||||
this->protocol[10].type = Network::NetAttributeType_Float;
|
||||
this->protocol[11].type = Network::NetAttributeType_Float;
|
||||
this->protocol[12].type = Network::NetAttributeType_Float;
|
||||
this->protocol[13].type = Network::NetAttributeType_Float;
|
||||
this->protocol[14].type = Network::NetAttributeType_Float;
|
||||
this->protocol[15].type = Network::NetAttributeType_Float;
|
||||
this->protocol[16].type = Network::NetAttributeType_Float;
|
||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Int;
|
||||
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[6].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[7].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[8].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[9].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[10].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[11].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[12].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[13].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[14].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[15].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[16].type = Oyster::Network::NetAttributeType_Float;
|
||||
|
||||
}
|
||||
Network::CustomNetProtocol* GetProtocol() override
|
||||
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
||||
{
|
||||
|
||||
this->protocol[1].value = worldMatrix[0];
|
||||
|
@ -59,7 +59,7 @@ namespace GameLogic
|
|||
}
|
||||
|
||||
private:
|
||||
Network::CustomNetProtocol protocol;
|
||||
Oyster::Network::CustomNetProtocol protocol;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue