Compiler fixes in State classes

This commit is contained in:
Dander7BD 2014-02-12 10:43:06 +01:00
parent fdb7a7e1b6
commit af85a6efdc
13 changed files with 108 additions and 87 deletions

View File

@ -213,7 +213,7 @@
<ClCompile Include="GameClientState\LevelLoader\ParseFunctions.cpp" />
<ClCompile Include="GameClientState\LobbyState.cpp" />
<ClCompile Include="GameClientState\C_Object.cpp" />
<ClCompile Include="GameClientState\LoginState.cpp" />
<ClCompile Include="GameClientState\MainState.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="GameClientRecieverFunc.h" />
@ -232,7 +232,7 @@
<ClInclude Include="GameClientState\LevelLoader\Loader.h" />
<ClInclude Include="GameClientState\LevelLoader\ObjectDefines.h" />
<ClInclude Include="GameClientState\LevelLoader\ParseFunctions.h" />
<ClInclude Include="GameClientState\LoginState.h" />
<ClInclude Include="GameClientState\MainState.h" />
<ClInclude Include="Include\DanBiasGame.h" />
<ClInclude Include="GameClientState\LobbyState.h" />
<ClInclude Include="GameClientState\C_Object.h" />

View File

@ -5,7 +5,7 @@
#include "GameClientState/GameClientState.h"
#include "GameClientState\GameState.h"
#include "GameClientState\LobbyState.h"
#include "GameClientState\LoginState.h"
#include "GameClientState\MainState.h"
#include "GameClientState\LanMenuState.h"
#include <Protocols.h>
#include "NetworkClient.h"
@ -18,7 +18,9 @@
#include "GameClientRecieverFunc.h"
#include "../Misc/EventHandler/EventHandler.h"
using namespace Oyster::Event;
using namespace ::Oyster::Event;
using namespace ::Utility::DynamicMemory;
namespace DanBias
{
@ -29,20 +31,15 @@ namespace DanBias
{
public:
DanBiasGamePrivateData()
{
DanBiasGamePrivateData() {}
}
~DanBiasGamePrivateData()
{
}
~DanBiasGamePrivateData() {}
public:
WindowShell* window;
InputClass* inputObj;
Utility::WinTimer timer;
GameRecieverObject* recieverObj;
UniquePointer<Client::GameClientState> state;
bool serverOwner;
} data;
@ -69,12 +66,12 @@ namespace DanBias
if( FAILED( InitInput() ) )
return DanBiasClientReturn_Error;
m_data->recieverObj = new GameRecieverObject;
m_data->serverOwner = false;
//m_data->serverOwner = false;
// Start in lobby state
m_data->recieverObj->gameClientState = new Client::LoginState();
if(!m_data->recieverObj->gameClientState->Init(m_data->recieverObj))
m_data->state = new Client::MainState();
if( !m_data->state->Init() )
return DanBiasClientReturn_Error;
m_data->timer.reset();

View File

@ -9,7 +9,6 @@
#include "GameClientState\GameClientState.h"
#include "GameClientState\GameState.h"
#include <Utilities.h>
namespace DanBias

View File

@ -5,7 +5,6 @@ namespace DanBias
{
namespace Client
{
struct ModelInitData
{
int id;
@ -16,34 +15,50 @@ namespace DanBias
bool visible;
};
class C_Object
{
private:
Oyster::Math::Float4x4 world;
Oyster::Math::Float3 position;
Oyster::Math::Quaternion rotation;
Oyster::Math::Float3 scale;
Oyster::Graphics::Model::Model *model;
int id;
void updateWorld();
public:
class C_Object
{
private:
Oyster::Math::Float4x4 world;
Oyster::Math::Float3 position;
Oyster::Math::Quaternion rotation;
Oyster::Math::Float3 scale;
Oyster::Graphics::Model::Model *model;
int id;
void updateWorld();
public:
virtual void Init(ModelInitData modelInit);
virtual void Init(ModelInitData modelInit);
void setWorld(Oyster::Math::Float4x4 world);
Oyster::Math::Float4x4 getWorld() const;
void setPos(Oyster::Math::Float3 newPos);
Oyster::Math::Float3 getPos() const;
void addPos(Oyster::Math::Float3 deltaPos);
void setRot(Oyster::Math::Quaternion newRot);
Oyster::Math::Quaternion getRotation() const;
void addRot(Oyster::Math::Quaternion deltaRot);
void setScale(Oyster::Math::Float3 newScale);
void addScale(Oyster::Math::Float3 deltaScale);
Oyster::Math::Float3 getScale() const;
void setWorld(Oyster::Math::Float4x4 world);
Oyster::Math::Float4x4 getWorld() const;
void setPos(Oyster::Math::Float3 newPos);
Oyster::Math::Float3 getPos() const;
void addPos(Oyster::Math::Float3 deltaPos);
void setRot(Oyster::Math::Quaternion newRot);
Oyster::Math::Quaternion getRotation() const;
void addRot(Oyster::Math::Quaternion deltaRot);
void setScale(Oyster::Math::Float3 newScale);
void addScale(Oyster::Math::Float3 deltaScale);
Oyster::Math::Float3 getScale() const;
virtual void Render();
virtual void Release();
virtual int GetId() const;
};
}
}
namespace Utility { namespace DynamicMemory
{ // template specializationto allowuse of dynamicmemory tools
template<>
inline void SafeDeleteInstance( ::DanBias::Client::C_Object *dynamicInstance )
{
if( dynamicInstance )
{
dynamicInstance->Release();
delete dynamicInstance;
}
}
} }
virtual void Render();
virtual void Release();
virtual int GetId() const;
};};};
#endif

View File

@ -1,12 +1,15 @@
#include "GameClientState.h"
using namespace DanBias::Client;
using namespace ::Oyster::Network;
GameClientState::GameClientState(void)
{
}
GameClientState::~GameClientState(void)
{
}
void DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
{ /* do nothing */ }

View File

@ -7,7 +7,7 @@
namespace DanBias { namespace Client
{
class GameClientState : public ::Oyster::Network::NetworkClient
class GameClientState
{
public:
enum ClientState
@ -27,6 +27,8 @@ namespace DanBias { namespace Client
virtual ClientState Update(float deltaTime, InputClass* KeyInput) = 0;
virtual bool Render() = 0;
virtual bool Release() = 0;
virtual void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
};
} }
#endif

View File

@ -491,7 +491,7 @@ int FindObject( const DynamicArray<SmartPointer<C_Object>> &collection, int id )
return -1;
}
void GameState::DataRecieved( NetEvent<NetworkClient*, ClientEventArgs> e )
void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
{
CustomNetProtocol data = e.args.data.protocol;
short ID = data[0].value.netShort; // fetching the id data.

View File

@ -52,7 +52,7 @@ namespace Client
bool Render()override;
bool Release()override;
void DataRecieved( ::Oyster::Network::NetEvent<NetworkClient*, ClientEventArgs> e );
void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
};
}
}

View File

@ -7,11 +7,12 @@
#include "LobbyState.h"
#include "GameState.h"
#include "../GameClientRecieverFunc.h"
#include "../Network/NetworkAPI/NetworkClient.h"
#include <GameServerAPI.h>
using namespace DanBias::Client;
using namespace ::DanBias::Client;
using namespace ::Oyster::Network;
struct LanMenuState::myData
{
@ -21,7 +22,7 @@ struct LanMenuState::myData
C_Object* object[2];
int modelCount;
GameRecieverObject* recieverObj;
NetworkClient* recieverObj;
bool serverOwner;
// UI object

View File

@ -135,7 +135,7 @@ bool LobbyState::Release()
using namespace ::Oyster::Network;
void LobbyState::DataRecieved( NetEvent<NetworkClient*, ClientEventArgs> e )
void LobbyState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
{
CustomNetProtocol data = e.args.data.protocol;
short ID = data[0].value.netShort; // fetching the id data.

View File

@ -34,7 +34,7 @@ namespace DanBias
bool Render();
bool Release();
void DataRecieved( ::Oyster::Network::NetEvent<NetworkClient*, ClientEventArgs> e );
void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
};
}
}

View File

@ -5,39 +5,44 @@
#include "C_obj/C_StaticObj.h"
#include "C_obj/C_DynamicObj.h"
#include <GameServerAPI.h>
#include "NetworkClient.h"
using namespace DanBias::Client;
using namespace ::DanBias::Client;
using namespace ::Oyster::Math3D;
using namespace ::Oyster::Network;
using namespace ::Utility::DynamicMemory;
struct MainState::myData
struct MainState::MyData
{
myData(){}
Oyster::Math3D::Float4x4 view;
Oyster::Math3D::Float4x4 proj;
C_Object* object[2];
MyData() {}
Float4x4 view;
Float4x4 proj;
UniquePointer<C_Object> object[2];
int modelCount;
// UI object
// game client*
} privData;
NetworkClient *nwClient;
};
MainState::MainState(void) {}
MainState::~MainState(void) {}
bool MainState::Init(Oyster::Network::NetworkClient* nwClient)
bool MainState::Init( NetworkClient* nwClient )
{
privData = new myData();
this->nwClient = nwClient;
this->privData = new MyData();
// load models
LoadModels(L"UImodels.txt");
InitCamera(Oyster::Math::Float3(0,0,5.4f));
InitCamera( Float3(0.0f, 0.0f, 5.4f) );
return true;
}
bool MainState::LoadModels(std::wstring file)
{
Oyster::Graphics::Definitions::Pointlight plight;
plight.Pos = Oyster::Math::Float3(0,0,5);
plight.Color = Oyster::Math::Float3(1,1,1);
plight.Pos = Float3(0,0,5);
plight.Color = Float3(1,1,1);
plight.Radius = 100;
plight.Bright = 1;
Oyster::Graphics::API::AddLight(plight);
@ -48,30 +53,30 @@ bool MainState::LoadModels(std::wstring file)
ModelInitData modelData;
modelData.rotation = Oyster::Math::Quaternion::identity;
modelData.scale = Oyster::Math::Float3(1,1,1);
modelData.rotation = Quaternion::identity;
modelData.scale = Float3(1,1,1);
modelData.visible = true;
modelData.modelPath = L"box.dan";
modelData.position = Oyster::Math::Float3(2,2,2);
modelData.position = Float3(2,2,2);
privData->object[0] = new C_StaticObj();
privData->object[0]->Init(modelData);
modelData.position = Oyster::Math::Float3(-2,0,-2);
modelData.position = Float3(-2,0,-2);
privData->object[1] = new C_StaticObj();
privData->object[1]->Init(modelData);
return true;
}
bool MainState::InitCamera(Oyster::Math::Float3 startPos)
bool MainState::InitCamera(Float3 startPos)
{
privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000);
//privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000);
privData->proj = ProjectionMatrix_Perspective(pi/2,1024.0f/768.0f,.1f,1000);
//privData->proj = ProjectionMatrix_Orthographic(1024, 768, 1, 1000);
Oyster::Graphics::API::SetProjection(privData->proj);
privData->view = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos);
privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
privData->view = OrientationMatrix_LookAtDirection(Float3(0,0,-1),Float3(0,1,0),startPos);
privData->view = InverseOrientationMatrix(privData->view);
return true;
}
@ -93,9 +98,9 @@ GameClientState::ClientState MainState::Update(float deltaTime, InputClass* KeyI
DanBias::GameServerAPI::ServerInitiate(desc);
DanBias::GameServerAPI::ServerStart();
// my ip
nwClient->Connect(15152, "127.0.0.1");
this->privData->nwClient->Connect(15152, "127.0.0.1");
if (!nwClient->IsConnected())
if (!this->privData->nwClient->IsConnected())
{
// failed to connect
return ClientState_Same;
@ -106,10 +111,10 @@ GameClientState::ClientState MainState::Update(float deltaTime, InputClass* KeyI
if( KeyInput->IsKeyPressed(DIK_J))
{
// game ip
nwClient->Connect(15152, "127.0.0.1");
this->privData->nwClient->Connect(15152, "127.0.0.1");
//nwClient->Connect(15152, "83.254.217.248");
if (!nwClient->IsConnected())
if (!this->privData->nwClient->IsConnected())
{
// failed to connect
return ClientState_Same;

View File

@ -12,13 +12,12 @@ namespace DanBias
class MainState : public GameClientState
{
private:
Oyster::Network::NetworkClient* nwClient;
struct myData;
myData* privData;
struct MyData;
::Utility::DynamicMemory::UniquePointer<MyData> privData;
public:
MainState(void);
~MainState(void);
bool Init(Oyster::Network::NetworkClient* nwClient);
bool Init( Oyster::Network::NetworkClient* nwClient );
bool LoadModels(std::wstring file);
bool InitCamera(Oyster::Math::Float3 startPos);
ClientState Update(float deltaTime, InputClass* KeyInput);
@ -26,7 +25,7 @@ namespace DanBias
bool Render();
bool Release();
void DataRecieved( ::Oyster::Network::NetEvent<NetworkClient*, ClientEventArgs> e );
void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
};
}
}