GL - added some protocols
This commit is contained in:
parent
e16c939285
commit
0c98e2847d
|
@ -111,7 +111,7 @@
|
|||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>WindowManager\WindowManager_$(PlatformShortName)D.lib;OysterGraphics_$(PlatformShortName)D.lib;Input\Input_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>Misc\Misc_$(PlatformShortName)D.lib;WindowManager\WindowManager_$(PlatformShortName)D.lib;OysterGraphics_$(PlatformShortName)D.lib;Input\Input_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName)D.dll;OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
@ -128,7 +128,7 @@
|
|||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>WindowManager\WindowManager_$(PlatformShortName)D.lib;OysterGraphics_$(PlatformShortName)D.lib;Input\Input_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>Misc\Misc_$(PlatformShortName)D.lib;WindowManager\WindowManager_$(PlatformShortName)D.lib;OysterGraphics_$(PlatformShortName)D.lib;Input\Input_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName)D.dll;OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
@ -149,7 +149,7 @@
|
|||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>WindowManager\WindowManager_$(PlatformShortName).lib;OysterGraphics_$(PlatformShortName).lib;Input\Input_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>Misc\Misc_$(PlatformShortName).lib;WindowManager\WindowManager_$(PlatformShortName).lib;OysterGraphics_$(PlatformShortName).lib;Input\Input_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName).dll;OysterGraphics_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
@ -170,7 +170,7 @@
|
|||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>WindowManager\WindowManager_$(PlatformShortName).lib;OysterGraphics_$(PlatformShortName).lib;Input\Input_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>Misc\Misc_$(PlatformShortName).lib;WindowManager\WindowManager_$(PlatformShortName).lib;OysterGraphics_$(PlatformShortName).lib;Input\Input_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName).dll;OysterGraphics_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
|
|
@ -10,13 +10,11 @@
|
|||
|
||||
#include "../WindowManager/WindowShell.h"
|
||||
#include "L_inputClass.h"
|
||||
#include "WinTimer.h"
|
||||
#include "vld.h"
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
__int64 DanBiasGame::cntsPerSec = 0;
|
||||
__int64 DanBiasGame::prevTimeStamp = 0;
|
||||
float DanBiasGame::secsPerCnt = 0;
|
||||
|
||||
#pragma region Game Data
|
||||
|
||||
|
@ -60,7 +58,24 @@ namespace DanBias
|
|||
}
|
||||
break;
|
||||
|
||||
case protocol_Gamplay_CreateObject:
|
||||
{
|
||||
|
||||
Client::GameClientState::NewObj* protocolData = new Client::GameClientState::NewObj;
|
||||
protocolData->object_ID = p[1].value.netInt;
|
||||
protocolData->path = p[2].value.netCharPtr;
|
||||
for(int i = 0; i< 16; i++)
|
||||
{
|
||||
protocolData->worldPos[i] = p[i+3].value.netFloat;
|
||||
}
|
||||
|
||||
if(dynamic_cast<Client::GameState*>(gameClientState))
|
||||
((Client::GameState*)gameClientState)->Protocol(protocolData);
|
||||
|
||||
delete protocolData;
|
||||
protocolData = NULL;
|
||||
}
|
||||
break;
|
||||
case protocol_Gamplay_ObjectPosition:
|
||||
{
|
||||
|
||||
|
@ -101,6 +116,7 @@ namespace DanBias
|
|||
//Client::GameClientState* gameClientState;
|
||||
WindowShell* window;
|
||||
InputClass* inputObj;
|
||||
Utility::WinTimer* timer;
|
||||
MyRecieverObject* recieverObj;
|
||||
|
||||
} data;
|
||||
|
@ -124,14 +140,6 @@ namespace DanBias
|
|||
if( FAILED( InitInput() ) )
|
||||
return DanBiasClientReturn_Error;
|
||||
|
||||
cntsPerSec = 0;
|
||||
QueryPerformanceFrequency((LARGE_INTEGER*)&cntsPerSec);
|
||||
secsPerCnt = 1.0f / (float)cntsPerSec;
|
||||
|
||||
prevTimeStamp = 0;
|
||||
QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp);
|
||||
|
||||
|
||||
m_data->recieverObj = new MyRecieverObject;
|
||||
|
||||
m_data->recieverObj->nwClient = new Oyster::Network::NetworkClient(m_data->recieverObj, Oyster::Network::NetworkProtocolCallbackType_Object);
|
||||
|
@ -144,37 +152,26 @@ namespace DanBias
|
|||
}
|
||||
// Start in lobby state
|
||||
m_data->recieverObj->gameClientState = new Client::LobbyState();
|
||||
m_data->recieverObj->gameClientState->Init(m_data->recieverObj->nwClient);
|
||||
|
||||
if(!m_data->recieverObj->gameClientState->Init(m_data->recieverObj->nwClient))
|
||||
return DanBiasClientReturn_Error;
|
||||
|
||||
m_data->timer = new Utility::WinTimer();
|
||||
m_data->timer->reset();
|
||||
return DanBiasClientReturn_Sucess;
|
||||
}
|
||||
|
||||
DanBiasClientReturn DanBiasGame::Run()
|
||||
{
|
||||
// Main message loop
|
||||
MSG msg = {0};
|
||||
while(WM_QUIT != msg.message)
|
||||
while(m_data->window->Frame())
|
||||
{
|
||||
if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE) )
|
||||
{
|
||||
TranslateMessage( &msg );
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
else
|
||||
{
|
||||
__int64 currTimeStamp = 0;
|
||||
QueryPerformanceCounter((LARGE_INTEGER*)&currTimeStamp);
|
||||
float dt = (currTimeStamp - prevTimeStamp) * secsPerCnt;
|
||||
float dt = m_data->timer->getElapsedSeconds();
|
||||
m_data->timer->reset();
|
||||
|
||||
//render
|
||||
if(Update(dt) != S_OK)
|
||||
return DanBiasClientReturn_Error;
|
||||
if(Render(dt) != S_OK)
|
||||
return DanBiasClientReturn_Error;
|
||||
|
||||
prevTimeStamp = currTimeStamp;
|
||||
}
|
||||
if(Update(dt) != S_OK)
|
||||
return DanBiasClientReturn_Error;
|
||||
if(Render(dt) != S_OK)
|
||||
return DanBiasClientReturn_Error;
|
||||
}
|
||||
return DanBiasClientReturn_Sucess;
|
||||
}
|
||||
|
@ -210,7 +207,7 @@ namespace DanBias
|
|||
|
||||
HRESULT DanBiasGame::Update(float deltaTime)
|
||||
{
|
||||
m_data->window->Frame();
|
||||
|
||||
m_data->inputObj->Update();
|
||||
|
||||
DanBias::Client::GameClientState::ClientState state = DanBias::Client::GameClientState::ClientState_Same;
|
||||
|
@ -272,40 +269,4 @@ namespace DanBias
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Called every time the application receives a message
|
||||
//--------------------------------------------------------------------------------------
|
||||
LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_PAINT:
|
||||
hdc = BeginPaint(hWnd, &ps);
|
||||
EndPaint(hWnd, &ps);
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
case WM_KEYDOWN:
|
||||
|
||||
switch(wParam)
|
||||
{
|
||||
case VK_ESCAPE:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} //End namespace DanBias
|
|
@ -22,6 +22,12 @@ public:
|
|||
int object_ID;
|
||||
float worldPos[16];
|
||||
};
|
||||
struct NewObj :public ProtocolStruct
|
||||
{
|
||||
int object_ID;
|
||||
char* path;
|
||||
float worldPos[16];
|
||||
};
|
||||
struct KeyInput :public ProtocolStruct
|
||||
{
|
||||
bool key[6];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "GameState.h"
|
||||
#include "GameState.h"
|
||||
#include "DllInterfaces/GFXAPI.h"
|
||||
#include "C_obj/C_Player.h"
|
||||
#include "C_obj/C_DynamicObj.h"
|
||||
|
@ -127,6 +127,15 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
|
|||
privData->nwClient->Send(movePlayer);
|
||||
}
|
||||
|
||||
//send delta mouse movement
|
||||
if (KeyInput->IsMousePressed())
|
||||
{
|
||||
GameLogic::Protocol_PlayerMouse deltaMouseMove;
|
||||
deltaMouseMove.dxMouse = KeyInput->GetYaw();
|
||||
deltaMouseMove.dyMouse = KeyInput->GetPitch();
|
||||
//privData->nwClient->Send(deltaMouseMove);
|
||||
}
|
||||
|
||||
// send event data
|
||||
//
|
||||
if(KeyInput->IsKeyPressed(DIK_L))
|
||||
|
@ -203,6 +212,25 @@ void GameState::Protocol( ObjPos* pos )
|
|||
privData->object[pos->object_ID]->setPos(world);
|
||||
}
|
||||
|
||||
void GameState::Protocol( NewObj* pos )
|
||||
{
|
||||
|
||||
Oyster::Math::Float4x4 world;
|
||||
for(int i = 0; i<16; i++)
|
||||
{
|
||||
world[i] = pos->worldPos[i];
|
||||
}
|
||||
ModelInitData modelData;
|
||||
|
||||
modelData.world = world;
|
||||
modelData.visible = true;
|
||||
const char* path = pos->path;
|
||||
modelData.modelPath = std::wstring(path, path + strlen(path));
|
||||
// load models
|
||||
privData->object[pos->object_ID] = new C_Player();
|
||||
privData->object[pos->object_ID]->Init(modelData);
|
||||
}
|
||||
|
||||
void GameState::Protocol( KeyInput* pos )
|
||||
{
|
||||
bool key = false;
|
||||
|
|
|
@ -35,6 +35,7 @@ public:
|
|||
void Protocol(PlayerPos* pos);
|
||||
void Protocol(ObjPos* pos);
|
||||
void Protocol(KeyInput* pos);
|
||||
void Protocol( NewObj* pos );
|
||||
void PlayerPosProtocol(PlayerPos* pos);
|
||||
void ObjectPosProtocol(ObjPos* pos);
|
||||
//void Protocol(LightPos pos);
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace DanBias
|
|||
int nCmdShow;
|
||||
|
||||
};
|
||||
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
class DanBiasGamePrivateData;
|
||||
class DANBIAS_GAME_DLL DanBiasGame
|
||||
{
|
||||
|
@ -55,11 +55,8 @@ namespace DanBias
|
|||
static HRESULT CleanUp();
|
||||
|
||||
private:
|
||||
static __int64 cntsPerSec;
|
||||
static __int64 prevTimeStamp;
|
||||
static float secsPerCnt;
|
||||
|
||||
static DanBiasGamePrivateData* m_data;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -8,6 +8,69 @@
|
|||
|
||||
namespace GameLogic
|
||||
{
|
||||
struct Protocol_CreateObject :public Oyster::Network::CustomProtocolObject
|
||||
{
|
||||
int object_ID;
|
||||
char path[255];
|
||||
float worldMatrix[16];
|
||||
|
||||
|
||||
Protocol_CreateObject()
|
||||
{
|
||||
this->protocol[0].value = protocol_Gamplay_CreateObject;
|
||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Int;
|
||||
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||
this->protocol[2].type = Oyster::Network::NetAttributeType_CharArray;
|
||||
|
||||
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;
|
||||
this->protocol[17].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[18].type = Oyster::Network::NetAttributeType_Float;
|
||||
|
||||
}
|
||||
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
||||
{
|
||||
|
||||
this->protocol[1].value = object_ID;
|
||||
this->protocol[2].value = path;
|
||||
this->protocol[3].value = worldMatrix[1];
|
||||
this->protocol[4].value = worldMatrix[2];
|
||||
this->protocol[5].value = worldMatrix[3];
|
||||
this->protocol[6].value = worldMatrix[4];
|
||||
this->protocol[7].value = worldMatrix[5];
|
||||
this->protocol[8].value = worldMatrix[6];
|
||||
this->protocol[9].value = worldMatrix[7];
|
||||
this->protocol[10].value = worldMatrix[8];
|
||||
this->protocol[11].value = worldMatrix[9];
|
||||
this->protocol[12].value = worldMatrix[10];
|
||||
this->protocol[13].value = worldMatrix[11];
|
||||
this->protocol[14].value = worldMatrix[12];
|
||||
this->protocol[15].value = worldMatrix[13];
|
||||
this->protocol[16].value = worldMatrix[14];
|
||||
this->protocol[17].value = worldMatrix[15];
|
||||
this->protocol[18].value = worldMatrix[16];
|
||||
|
||||
return &protocol;
|
||||
}
|
||||
|
||||
private:
|
||||
Oyster::Network::CustomNetProtocol protocol;
|
||||
};
|
||||
|
||||
|
||||
struct Protocol_ObjectPosition :public Oyster::Network::CustomProtocolObject
|
||||
{
|
||||
int object_ID;
|
||||
|
|
|
@ -51,6 +51,34 @@ namespace GameLogic
|
|||
Oyster::Network::CustomNetProtocol protocol;
|
||||
};
|
||||
|
||||
struct Protocol_PlayerMouse :public Oyster::Network::CustomProtocolObject
|
||||
{
|
||||
|
||||
float dxMouse;
|
||||
float dyMouse;
|
||||
|
||||
|
||||
Protocol_PlayerMouse()
|
||||
{
|
||||
this->protocol[0].value = protocol_Gamplay_PlayerMouseMovement;
|
||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
||||
|
||||
}
|
||||
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
||||
{
|
||||
this->protocol[1].value = dxMouse;
|
||||
this->protocol[2].value = dyMouse;
|
||||
|
||||
return &protocol;
|
||||
}
|
||||
|
||||
private:
|
||||
Oyster::Network::CustomNetProtocol protocol;
|
||||
};
|
||||
|
||||
struct Protocol_PlayerPosition :public Oyster::Network::CustomProtocolObject
|
||||
{
|
||||
|
||||
|
|
|
@ -8,8 +8,11 @@
|
|||
/* THERE CAN ABSOLUTLEY NOT BE TWO DEFINITIONS WITH THE SAME ID!! */
|
||||
|
||||
#define protocol_Gamplay_PlayerNavigation 0
|
||||
#define protocol_Gamplay_PlayerPosition 1
|
||||
#define protocol_Gamplay_ObjectPosition 2
|
||||
#define protocol_Gamplay_PlayerMouseMovement 1
|
||||
#define protocol_Gamplay_PlayerPosition 2
|
||||
#define protocol_Gamplay_CreateObject 3
|
||||
#define protocol_Gamplay_ObjectPosition 4
|
||||
|
||||
|
||||
#define protocol_Lobby_Msg 100
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////
|
||||
// Created 2013 //
|
||||
// Dennis Andersen, Linda Andersson //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
@ -32,7 +32,7 @@ public:
|
|||
{
|
||||
parent = 0;
|
||||
hInstance = NULL;
|
||||
windowName = L"MADAFACKA";
|
||||
windowName = L"おはよう";
|
||||
windowSize.x = 800;
|
||||
windowSize.y = 600;
|
||||
windowPosition.x = 0;
|
||||
|
|
Loading…
Reference in New Issue