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

View File

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

View File

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

View File

@ -5,7 +5,6 @@ namespace DanBias
{ {
namespace Client namespace Client
{ {
struct ModelInitData struct ModelInitData
{ {
int id; int id;
@ -16,34 +15,50 @@ namespace DanBias
bool visible; bool visible;
}; };
class C_Object class C_Object
{ {
private: private:
Oyster::Math::Float4x4 world; Oyster::Math::Float4x4 world;
Oyster::Math::Float3 position; Oyster::Math::Float3 position;
Oyster::Math::Quaternion rotation; Oyster::Math::Quaternion rotation;
Oyster::Math::Float3 scale; Oyster::Math::Float3 scale;
Oyster::Graphics::Model::Model *model; Oyster::Graphics::Model::Model *model;
int id; int id;
void updateWorld(); void updateWorld();
public: public:
virtual void Init(ModelInitData modelInit); virtual void Init(ModelInitData modelInit);
void setWorld(Oyster::Math::Float4x4 world); void setWorld(Oyster::Math::Float4x4 world);
Oyster::Math::Float4x4 getWorld() const; Oyster::Math::Float4x4 getWorld() const;
void setPos(Oyster::Math::Float3 newPos); void setPos(Oyster::Math::Float3 newPos);
Oyster::Math::Float3 getPos() const; Oyster::Math::Float3 getPos() const;
void addPos(Oyster::Math::Float3 deltaPos); void addPos(Oyster::Math::Float3 deltaPos);
void setRot(Oyster::Math::Quaternion newRot); void setRot(Oyster::Math::Quaternion newRot);
Oyster::Math::Quaternion getRotation() const; Oyster::Math::Quaternion getRotation() const;
void addRot(Oyster::Math::Quaternion deltaRot); void addRot(Oyster::Math::Quaternion deltaRot);
void setScale(Oyster::Math::Float3 newScale); void setScale(Oyster::Math::Float3 newScale);
void addScale(Oyster::Math::Float3 deltaScale); void addScale(Oyster::Math::Float3 deltaScale);
Oyster::Math::Float3 getScale() const; 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 #endif

View File

@ -1,12 +1,15 @@
#include "GameClientState.h" #include "GameClientState.h"
using namespace DanBias::Client; using namespace DanBias::Client;
using namespace ::Oyster::Network;
GameClientState::GameClientState(void) GameClientState::GameClientState(void)
{ {
} }
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 namespace DanBias { namespace Client
{ {
class GameClientState : public ::Oyster::Network::NetworkClient class GameClientState
{ {
public: public:
enum ClientState enum ClientState
@ -27,6 +27,8 @@ namespace DanBias { namespace Client
virtual ClientState Update(float deltaTime, InputClass* KeyInput) = 0; virtual ClientState Update(float deltaTime, InputClass* KeyInput) = 0;
virtual bool Render() = 0; virtual bool Render() = 0;
virtual bool Release() = 0; virtual bool Release() = 0;
virtual void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
}; };
} } } }
#endif #endif

View File

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

View File

@ -52,7 +52,7 @@ namespace Client
bool Render()override; bool Render()override;
bool Release()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 "LobbyState.h"
#include "GameState.h" #include "GameState.h"
#include "../GameClientRecieverFunc.h" #include "../Network/NetworkAPI/NetworkClient.h"
#include <GameServerAPI.h> #include <GameServerAPI.h>
using namespace DanBias::Client; using namespace ::DanBias::Client;
using namespace ::Oyster::Network;
struct LanMenuState::myData struct LanMenuState::myData
{ {
@ -21,7 +22,7 @@ struct LanMenuState::myData
C_Object* object[2]; C_Object* object[2];
int modelCount; int modelCount;
GameRecieverObject* recieverObj; NetworkClient* recieverObj;
bool serverOwner; bool serverOwner;
// UI object // UI object

View File

@ -135,7 +135,7 @@ bool LobbyState::Release()
using namespace ::Oyster::Network; 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; CustomNetProtocol data = e.args.data.protocol;
short ID = data[0].value.netShort; // fetching the id data. short ID = data[0].value.netShort; // fetching the id data.

View File

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

View File

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