GameLogic - pree-sprint merge
This commit is contained in:
parent
b85439bd5e
commit
6c3c234be1
|
@ -75,7 +75,7 @@ namespace DanBias
|
||||||
if(!m_data->recieverObj->gameClientState->Init(m_data->recieverObj->nwClient))
|
if(!m_data->recieverObj->gameClientState->Init(m_data->recieverObj->nwClient))
|
||||||
return DanBiasClientReturn_Error;
|
return DanBiasClientReturn_Error;
|
||||||
|
|
||||||
m_data->timer = new Utility::WinTimer();
|
m_data->timer = new Utility::WinTimer(); //why dynamic memory?
|
||||||
m_data->timer->reset();
|
m_data->timer->reset();
|
||||||
return DanBiasClientReturn_Sucess;
|
return DanBiasClientReturn_Sucess;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,6 @@ struct GameRecieverObject :public Oyster::Network::ProtocolRecieverObject
|
||||||
|
|
||||||
case protocol_Gameplay_CreateObject:
|
case protocol_Gameplay_CreateObject:
|
||||||
{
|
{
|
||||||
|
|
||||||
Client::GameClientState::NewObj* protocolData = new Client::GameClientState::NewObj;
|
Client::GameClientState::NewObj* protocolData = new Client::GameClientState::NewObj;
|
||||||
protocolData->object_ID = p[1].value.netInt;
|
protocolData->object_ID = p[1].value.netInt;
|
||||||
protocolData->path = p[2].value.netCharPtr;
|
protocolData->path = p[2].value.netCharPtr;
|
||||||
|
|
|
@ -173,11 +173,6 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Launcher.cpp" />
|
<ClCompile Include="Launcher.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\DanBiasGame\DanBiasGame.vcxproj">
|
|
||||||
<Project>{2a1bc987-af42-4500-802d-89cd32fc1309}</Project>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
|
|
@ -20,6 +20,7 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh
|
||||||
//gameDesc.port = 15152;
|
//gameDesc.port = 15152;
|
||||||
//gameDesc.IP = "193.11.184.196";
|
//gameDesc.IP = "193.11.184.196";
|
||||||
//gameDesc.IP = "193.11.184.31";
|
//gameDesc.IP = "193.11.184.31";
|
||||||
|
//gameDesc.IP = "194.47.150.56";
|
||||||
gameDesc.IP = "127.0.0.1";
|
gameDesc.IP = "127.0.0.1";
|
||||||
gameDesc.hinst = hinst;
|
gameDesc.hinst = hinst;
|
||||||
gameDesc.nCmdShow = cmdShow;
|
gameDesc.nCmdShow = cmdShow;
|
||||||
|
|
|
@ -112,7 +112,7 @@
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<DelayLoadDLLs>GameLogic_$(PlatformShortName)D.dll;%(DelayLoadDLLs);NetworkAPI_$(PlatformShortName)D.dll;GamePhysics_$(PlatformShortName)D.dll</DelayLoadDLLs>
|
<DelayLoadDLLs>GameLogic_$(PlatformShortName)D.dll;NetworkAPI_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
<AdditionalDependencies>NetworkAPI_$(PlatformShortName)D.lib;WindowManager_$(PlatformShortName)D.lib;GameLogic_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>NetworkAPI_$(PlatformShortName)D.lib;WindowManager_$(PlatformShortName)D.lib;GameLogic_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
@ -128,7 +128,7 @@
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<DelayLoadDLLs>GameLogic_$(PlatformShortName)D.dll;%(DelayLoadDLLs);NetworkAPI_$(PlatformShortName)D.dll;GamePhysics_$(PlatformShortName)D.dll</DelayLoadDLLs>
|
<DelayLoadDLLs>GameLogic_$(PlatformShortName)D.dll;NetworkAPI_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
<AdditionalDependencies>NetworkAPI_$(PlatformShortName)D.lib;WindowManager_$(PlatformShortName)D.lib;GameLogic_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>NetworkAPI_$(PlatformShortName)D.lib;WindowManager_$(PlatformShortName)D.lib;GameLogic_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
@ -148,7 +148,7 @@
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<DelayLoadDLLs>GameLogic_$(PlatformShortName).dll;%(DelayLoadDLLs);NetworkAPI_$(PlatformShortName).dll;GamePhysics_$(PlatformShortName).dll</DelayLoadDLLs>
|
<DelayLoadDLLs>GameLogic_$(PlatformShortName).dll;NetworkAPI_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
<AdditionalDependencies>NetworkAPI_$(PlatformShortName).lib;WindowManager_$(PlatformShortName).lib;GameLogic_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>NetworkAPI_$(PlatformShortName).lib;WindowManager_$(PlatformShortName).lib;GameLogic_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
@ -168,7 +168,7 @@
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<DelayLoadDLLs>GameLogic_$(PlatformShortName).dll;%(DelayLoadDLLs);NetworkAPI_$(PlatformShortName).dll;GamePhysics_$(PlatformShortName).dll</DelayLoadDLLs>
|
<DelayLoadDLLs>GameLogic_$(PlatformShortName).dll;NetworkAPI_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
<AdditionalDependencies>NetworkAPI_$(PlatformShortName).lib;WindowManager_$(PlatformShortName).lib;GameLogic_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>NetworkAPI_$(PlatformShortName).lib;WindowManager_$(PlatformShortName).lib;GameLogic_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
@ -206,9 +206,6 @@
|
||||||
<ClInclude Include="LobbySessions\NetworkSession.h" />
|
<ClInclude Include="LobbySessions\NetworkSession.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\GamePhysics\GamePhysics.vcxproj">
|
|
||||||
<Project>{104fa3e9-94d9-4e1d-a941-28a03bc8a095}</Project>
|
|
||||||
</ProjectReference>
|
|
||||||
<ProjectReference Include="..\..\Misc\Misc.vcxproj">
|
<ProjectReference Include="..\..\Misc\Misc.vcxproj">
|
||||||
<Project>{2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee}</Project>
|
<Project>{2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#include "GameClient.h"
|
#include "GameClient.h"
|
||||||
#include "..\LobbySessions\NetworkSession.h"
|
#include "..\LobbySessions\NetworkSession.h"
|
||||||
#include <Game.h>
|
|
||||||
#include <Protocols.h>
|
#include <Protocols.h>
|
||||||
|
|
||||||
using namespace Utility::DynamicMemory;
|
using namespace Utility::DynamicMemory;
|
||||||
|
@ -13,7 +12,7 @@ using namespace GameLogic;
|
||||||
|
|
||||||
static int gameClientIDCount = 1;
|
static int gameClientIDCount = 1;
|
||||||
|
|
||||||
GameClient::GameClient(SmartPointer<LobbyClient> client, Game::PlayerData* player, Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value)
|
GameClient::GameClient(SmartPointer<LobbyClient> client, IPlayerData* player, Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value)
|
||||||
{
|
{
|
||||||
this->callbackValue = value;
|
this->callbackValue = value;
|
||||||
this->client = client;
|
this->client = client;
|
||||||
|
@ -37,13 +36,13 @@ void GameClient::SetCallback(Oyster::Callback::OysterCallback<void, NetworkSessi
|
||||||
this->callbackValue = value;
|
this->callbackValue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLogic::Game::PlayerData* GameClient::GetPlayer()
|
GameLogic::IPlayerData* GameClient::GetPlayer()
|
||||||
{
|
{
|
||||||
return this->player;
|
return this->player;
|
||||||
}
|
}
|
||||||
GameLogic::Game::PlayerData* GameClient::ReleasePlayer()
|
GameLogic::IPlayerData* GameClient::ReleasePlayer()
|
||||||
{
|
{
|
||||||
GameLogic::Game::PlayerData *temp = this->player;
|
GameLogic::IPlayerData *temp = this->player;
|
||||||
this->player = 0;
|
this->player = 0;
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,22 +6,22 @@
|
||||||
|
|
||||||
#include "..\LobbySessions\LobbyClient.h"
|
#include "..\LobbySessions\LobbyClient.h"
|
||||||
#include <PostBox\PostBox.h>
|
#include <PostBox\PostBox.h>
|
||||||
#include <Game.h>
|
#include <GameAPI.h>
|
||||||
|
|
||||||
namespace DanBias
|
namespace DanBias
|
||||||
{
|
{
|
||||||
class GameClient: Oyster::Callback::CallbackObject<void, NetworkSession::NetEvent>
|
class GameClient: Oyster::Callback::CallbackObject<void, NetworkSession::NetEvent>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GameClient(Utility::DynamicMemory::SmartPointer<LobbyClient> client, GameLogic::Game::PlayerData* player, Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value);
|
GameClient(Utility::DynamicMemory::SmartPointer<LobbyClient> client, GameLogic::IPlayerData* player, Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value);
|
||||||
virtual~GameClient();
|
virtual~GameClient();
|
||||||
|
|
||||||
void SetCallback(Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value);
|
void SetCallback(Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> value);
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
GameLogic::Game::PlayerData* GetPlayer();
|
GameLogic::IPlayerData* GetPlayer();
|
||||||
|
|
||||||
GameLogic::Game::PlayerData* ReleasePlayer();
|
GameLogic::IPlayerData* ReleasePlayer();
|
||||||
|
|
||||||
LobbyClient* GetClient() const;
|
LobbyClient* GetClient() const;
|
||||||
Utility::DynamicMemory::SmartPointer<LobbyClient> ReleaseClient();
|
Utility::DynamicMemory::SmartPointer<LobbyClient> ReleaseClient();
|
||||||
|
@ -29,7 +29,7 @@ namespace DanBias
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//Utility::DynamicMemory::SmartPointer<GameLogic::Player> player;
|
//Utility::DynamicMemory::SmartPointer<GameLogic::Player> player;
|
||||||
GameLogic::Game::PlayerData* player;
|
GameLogic::IPlayerData* player;
|
||||||
Utility::DynamicMemory::SmartPointer<LobbyClient> client;
|
Utility::DynamicMemory::SmartPointer<LobbyClient> client;
|
||||||
Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> callbackValue;
|
Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> callbackValue;
|
||||||
int id;
|
int id;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include <WinTimer.h>
|
#include <WinTimer.h>
|
||||||
#include <PostBox\IPostBox.h>
|
#include <PostBox\IPostBox.h>
|
||||||
#include <Thread\OysterThread.h>
|
#include <Thread\OysterThread.h>
|
||||||
#include <Game.h>
|
#include <GameAPI.h>
|
||||||
#include <Queue.h>
|
#include <Queue.h>
|
||||||
|
|
||||||
namespace DanBias
|
namespace DanBias
|
||||||
|
@ -30,19 +30,6 @@ namespace DanBias
|
||||||
NetworkSession* owner;
|
NetworkSession* owner;
|
||||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<LobbyClient>> clients;
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<LobbyClient>> clients;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GameSessionEvent
|
|
||||||
{
|
|
||||||
union EventData
|
|
||||||
{
|
|
||||||
GameLogic::Game::PlayerData* player;
|
|
||||||
} data;
|
|
||||||
enum EventType
|
|
||||||
{
|
|
||||||
EventType_Player,
|
|
||||||
EventType_DynamicObject,
|
|
||||||
} value;
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GameSession();
|
GameSession();
|
||||||
|
@ -77,7 +64,7 @@ namespace DanBias
|
||||||
//Handles all general events
|
//Handles all general events
|
||||||
void ParseGeneralEvent(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c);
|
void ParseGeneralEvent(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c);
|
||||||
//Adds a client to the client list
|
//Adds a client to the client list
|
||||||
void AddClient(Utility::DynamicMemory::SmartPointer<GameClient> obj);
|
void InsertClient(Utility::DynamicMemory::SmartPointer<GameClient> obj);
|
||||||
//Removes a client from the client list
|
//Removes a client from the client list
|
||||||
void RemoveClient(DanBias::GameClient* obj);
|
void RemoveClient(DanBias::GameClient* obj);
|
||||||
//Sends a protocol ta all clients in session
|
//Sends a protocol ta all clients in session
|
||||||
|
@ -97,11 +84,14 @@ namespace DanBias
|
||||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<GameClient>> clients;
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<GameClient>> clients;
|
||||||
Oyster::IPostBox<DanBias::NetworkSession::NetEvent> *box;
|
Oyster::IPostBox<DanBias::NetworkSession::NetEvent> *box;
|
||||||
Oyster::Thread::OysterThread worker;
|
Oyster::Thread::OysterThread worker;
|
||||||
GameLogic::Game gameInstance;
|
GameLogic::GameAPI& gameInstance;
|
||||||
|
GameLogic::ILevelData *levelData;
|
||||||
NetworkSession* owner;
|
NetworkSession* owner;
|
||||||
bool isCreated;
|
bool isCreated;
|
||||||
bool isRunning;
|
bool isRunning;
|
||||||
Utility::Container::Queue<GameSessionEvent> modifiedClient;
|
Utility::WinTimer timer;
|
||||||
|
|
||||||
|
static void ObjectMove(GameLogic::IObjectData* movedObject);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class AdminInterface;
|
friend class AdminInterface;
|
||||||
|
|
|
@ -25,7 +25,9 @@ namespace DanBias
|
||||||
if( !this->box->IsEmpty() )
|
if( !this->box->IsEmpty() )
|
||||||
{
|
{
|
||||||
NetworkSession::NetEvent &e = this->box->Fetch();
|
NetworkSession::NetEvent &e = this->box->Fetch();
|
||||||
|
static int ii = 0;
|
||||||
|
printf("%i - Message recieved! [%i]\n", ii++, e.protocol[0].value);
|
||||||
|
|
||||||
if(e.protocol[0].type != Oyster::Network::NetAttributeType_Short) return;
|
if(e.protocol[0].type != Oyster::Network::NetAttributeType_Short) return;
|
||||||
|
|
||||||
if( ProtocolIsGameplay(e.protocol[protocol_INDEX_ID].value.netShort) )
|
if( ProtocolIsGameplay(e.protocol[protocol_INDEX_ID].value.netShort) )
|
||||||
|
@ -38,10 +40,6 @@ namespace DanBias
|
||||||
|
|
||||||
void GameSession::ParseGameplayEvent(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c)
|
void GameSession::ParseGameplayEvent(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c)
|
||||||
{
|
{
|
||||||
GameSessionEvent e;
|
|
||||||
e.data.player = c->GetPlayer();
|
|
||||||
e.value = GameSessionEvent::EventType_Player;
|
|
||||||
|
|
||||||
switch (p[protocol_INDEX_ID].value.netShort)
|
switch (p[protocol_INDEX_ID].value.netShort)
|
||||||
{
|
{
|
||||||
case protocol_Gameplay_PlayerNavigation:
|
case protocol_Gameplay_PlayerNavigation:
|
||||||
|
@ -60,9 +58,6 @@ namespace DanBias
|
||||||
if(p[6].value.netBool) //bool bStrafeLeft;
|
if(p[6].value.netBool) //bool bStrafeLeft;
|
||||||
//world.v[3].y = -2;
|
//world.v[3].y = -2;
|
||||||
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
|
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case protocol_Gameplay_PlayerMouseMovement:
|
case protocol_Gameplay_PlayerMouseMovement:
|
||||||
|
@ -77,11 +72,7 @@ namespace DanBias
|
||||||
case protocol_Gameplay_ObjectPosition:
|
case protocol_Gameplay_ObjectPosition:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->modifiedClient.Push(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameSession::ParseGeneralEvent(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c)
|
void GameSession::ParseGeneralEvent(Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c)
|
||||||
|
@ -92,7 +83,7 @@ namespace DanBias
|
||||||
switch (p[1].value.netInt)
|
switch (p[1].value.netInt)
|
||||||
{
|
{
|
||||||
case GameLogic::Protocol_General_Status::States_bussy:
|
case GameLogic::Protocol_General_Status::States_bussy:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GameLogic::Protocol_General_Status::States_disconected:
|
case GameLogic::Protocol_General_Status::States_disconected:
|
||||||
|
@ -116,5 +107,15 @@ namespace DanBias
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GameSession::ObjectMove(GameLogic::IObjectData* movedObject)
|
||||||
|
{
|
||||||
|
//if (movedObject->)
|
||||||
|
//{
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
//movedObject->GetOrientation();
|
||||||
|
}
|
||||||
|
|
||||||
}//End namespace DanBias
|
}//End namespace DanBias
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ using namespace GameLogic;
|
||||||
namespace DanBias
|
namespace DanBias
|
||||||
{
|
{
|
||||||
GameSession::GameSession()
|
GameSession::GameSession()
|
||||||
|
:gameInstance(GameAPI::Instance())
|
||||||
{
|
{
|
||||||
this->owner = 0;
|
this->owner = 0;
|
||||||
this->box = 0;
|
this->box = 0;
|
||||||
|
@ -36,30 +37,60 @@ namespace DanBias
|
||||||
|
|
||||||
bool GameSession::Create(GameDescription& desc)
|
bool GameSession::Create(GameDescription& desc)
|
||||||
{
|
{
|
||||||
|
/* Do some error checking */
|
||||||
if(desc.clients.Size() == 0) return false;
|
if(desc.clients.Size() == 0) return false;
|
||||||
if(!desc.owner) return false;
|
if(!desc.owner) return false;
|
||||||
if(!desc.mapName.size()) return false;
|
if(!desc.mapName.size()) return false;
|
||||||
if(this->isCreated) return false;
|
if(this->isCreated) return false;
|
||||||
|
|
||||||
|
/* standard initialization of some data */
|
||||||
this->clients.Resize(desc.clients.Size());
|
this->clients.Resize(desc.clients.Size());
|
||||||
|
|
||||||
this->box = new PostBox<NetworkSession::NetEvent>();
|
this->box = new PostBox<NetworkSession::NetEvent>();
|
||||||
this->owner = desc.owner;
|
this->owner = desc.owner;
|
||||||
|
|
||||||
Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> c;
|
/* Initiate the game instance */
|
||||||
c.value.callbackPostBox = this->box;
|
if(!this->gameInstance.Initiate())
|
||||||
c.callbackType = Oyster::Callback::CallbackType_PostBox;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < desc.clients.Size(); i++)
|
|
||||||
{
|
{
|
||||||
this->clients[i] = new GameClient(desc.clients[i], gameInstance.CreatePlayer(), c);
|
printf("Failed to initiate the game instance\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this->worker.Create(this, true, true) != OYSTER_THREAD_ERROR_SUCCESS) return false;
|
/* Create the game level */
|
||||||
|
if(!(this->levelData = this->gameInstance.CreateLevel()))
|
||||||
|
{
|
||||||
|
printf("Level not created!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create a callback object */
|
||||||
|
Oyster::Callback::OysterCallback<void, NetworkSession::NetEvent> c;
|
||||||
|
c.value.callbackPostBox = this->box;
|
||||||
|
c.callbackType = Oyster::Callback::CallbackType_PostBox;
|
||||||
|
|
||||||
|
/* Create the players in the game instance */
|
||||||
|
GameLogic::IPlayerData* p = 0;
|
||||||
|
for (unsigned int i = 0; i < desc.clients.Size(); i++)
|
||||||
|
{
|
||||||
|
if( (p = this->gameInstance.CreatePlayer()) )
|
||||||
|
{
|
||||||
|
this->clients[i] = new GameClient(desc.clients[i], p, c);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Failed to create player (%i)\n", i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create the worker thread */
|
||||||
|
if(this->worker.Create(this, true, true) != OYSTER_THREAD_ERROR_SUCCESS)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
this->worker.SetPriority(Oyster::Thread::OYSTER_THREAD_PRIORITY_3);
|
||||||
|
|
||||||
|
/* Set some gameinstance data options */
|
||||||
|
this->gameInstance.SetSubscription(GameLogic::GameEvent::ObjectEventFunctionType_OnMove, GameSession::ObjectMove);
|
||||||
|
|
||||||
this->isCreated = true;
|
this->isCreated = true;
|
||||||
|
return this->isCreated;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameSession::Run()
|
void GameSession::Run()
|
||||||
|
@ -69,8 +100,7 @@ namespace DanBias
|
||||||
|
|
||||||
if(this->clients.Size() > 0)
|
if(this->clients.Size() > 0)
|
||||||
{
|
{
|
||||||
|
this->worker.SetPriority(OYSTER_THREAD_PRIORITY_1);
|
||||||
this->worker.SetPriority(OYSTER_THREAD_PRIORITY_2);
|
|
||||||
this->isRunning = true;
|
this->isRunning = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +114,7 @@ namespace DanBias
|
||||||
c.callbackType = Oyster::Callback::CallbackType_PostBox;
|
c.callbackType = Oyster::Callback::CallbackType_PostBox;
|
||||||
|
|
||||||
SmartPointer<GameClient> obj = new GameClient(client, this->gameInstance.CreatePlayer(), c);
|
SmartPointer<GameClient> obj = new GameClient(client, this->gameInstance.CreatePlayer(), c);
|
||||||
AddClient(obj);
|
InsertClient(obj);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +135,7 @@ namespace DanBias
|
||||||
this->Clean();
|
this->Clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameSession::AddClient(SmartPointer<GameClient> obj)
|
void GameSession::InsertClient(SmartPointer<GameClient> obj)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < clients.Size(); i++)
|
for (unsigned int i = 0; i < clients.Size(); i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,6 +10,11 @@
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <OysterMath.h>
|
#include <OysterMath.h>
|
||||||
|
|
||||||
|
#define DELTA_TIME_24 0.04166666666666666666666666666667f
|
||||||
|
#define DELTA_TIME_30 0.03333333333333333333333333333333f
|
||||||
|
#define DELTA_TIME_60 0.01666666666666666666666666666667f
|
||||||
|
#define DELTA_TIME_120 0.00833333333333333333333333333333f
|
||||||
|
|
||||||
using namespace Utility::DynamicMemory;
|
using namespace Utility::DynamicMemory;
|
||||||
using namespace Oyster;
|
using namespace Oyster;
|
||||||
using namespace Oyster::Network;
|
using namespace Oyster::Network;
|
||||||
|
@ -20,53 +25,48 @@ namespace DanBias
|
||||||
{
|
{
|
||||||
bool GameSession::DoWork( )
|
bool GameSession::DoWork( )
|
||||||
{
|
{
|
||||||
if(GetAsyncKeyState(VK_UP))
|
if(this->isRunning)
|
||||||
{
|
{
|
||||||
Protocol_General_Status p(Protocol_General_Status::States_ready);
|
if(GetAsyncKeyState(VK_UP))
|
||||||
Send(p.GetProtocol());
|
{
|
||||||
Sleep(100);
|
Protocol_General_Status p(Protocol_General_Status::States_ready);
|
||||||
}
|
Send(p.GetProtocol());
|
||||||
if(GetAsyncKeyState(VK_DOWN))
|
Sleep(100);
|
||||||
{
|
}
|
||||||
Oyster::Math::Float4x4 world = Oyster::Math::Matrix::identity;
|
if(GetAsyncKeyState(VK_DOWN))
|
||||||
Protocol_CreateObject p(world, 2, "../Content/crate");
|
{
|
||||||
Send(p.GetProtocol());
|
Oyster::Math::Float4x4 world = Oyster::Math::Matrix::identity;
|
||||||
Sleep(100);
|
Protocol_CreateObject p(world, 2, "../Content/crate");
|
||||||
}
|
Send(p.GetProtocol());
|
||||||
|
Sleep(100);
|
||||||
|
}
|
||||||
|
|
||||||
this->ParseEvents();
|
double dt = this->timer.getElapsedSeconds();
|
||||||
|
gameInstance.SetFrameTimeLength((float)dt);
|
||||||
|
|
||||||
this->gameInstance.NewFrame();
|
if(dt >= DELTA_TIME_60)
|
||||||
|
{
|
||||||
|
this->ParseEvents();
|
||||||
|
|
||||||
this->UpdateGameObjects();
|
this->gameInstance.NewFrame();
|
||||||
|
|
||||||
|
this->UpdateGameObjects();
|
||||||
|
|
||||||
|
this->timer.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return this->isRunning;
|
return this->isRunning;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameSession::UpdateGameObjects()
|
void GameSession::UpdateGameObjects()
|
||||||
{
|
{
|
||||||
while(!this->modifiedClient.IsEmpty())
|
if(clients.Size() >= 1 && clients[0])
|
||||||
{
|
|
||||||
//There is something that needs update
|
|
||||||
GameSessionEvent e = this->modifiedClient.Pop();
|
|
||||||
|
|
||||||
switch (e.value)
|
|
||||||
{
|
|
||||||
case GameSessionEvent::EventType_Player:
|
|
||||||
//e.data.player->GetOrientation();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(clients.Size() == 1)
|
|
||||||
{
|
{
|
||||||
Oyster::Math::Float4x4 world = this->clients[0]->GetPlayer()->GetOrientation();
|
Oyster::Math::Float4x4 world = this->clients[0]->GetPlayer()->GetOrientation();
|
||||||
Protocol_ObjectPosition p(world, 1);
|
Protocol_ObjectPosition p(world, 1);
|
||||||
Send(p.GetProtocol());
|
Send(p.GetProtocol());
|
||||||
Sleep(100);
|
//Sleep(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,10 @@
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "Player.h"
|
|
||||||
#include "Level.h"
|
|
||||||
#include <DynamicArray.h>
|
|
||||||
#include <GID.h>
|
|
||||||
#include <PhysicsAPI.h>
|
|
||||||
#include <WinTimer.h>
|
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
using namespace Utility::DynamicMemory;
|
using namespace Utility::DynamicMemory;
|
||||||
using namespace Oyster::Physics;
|
using namespace Oyster::Physics;
|
||||||
|
|
||||||
#define DELTA_TIME 0.01666666666666666666666666666667f
|
template<typename T> int InsertObject(DynamicArray<T*>& list, T* obj)
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
int InsertObject(DynamicArray<T*>& list, T* obj)
|
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < list.Size(); i++)
|
for (unsigned int i = 0; i < list.Size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -26,8 +17,7 @@ int InsertObject(DynamicArray<T*>& list, T* obj)
|
||||||
list.Push(obj);
|
list.Push(obj);
|
||||||
return list.Size() - 1;
|
return list.Size() - 1;
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T> int RemoveObject(DynamicArray<T*>& list, T* obj)
|
||||||
int RemoveObject(DynamicArray<T*>& list, T* obj)
|
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < list.Size(); i++)
|
for (unsigned int i = 0; i < list.Size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -41,37 +31,33 @@ int RemoveObject(DynamicArray<T*>& list, T* obj)
|
||||||
return list.Size() - 1;
|
return list.Size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Game::PrivateData
|
|
||||||
|
Game gameInstance;
|
||||||
|
GameAPI& GameAPI::Instance()
|
||||||
{
|
{
|
||||||
PrivateData()
|
return gameInstance;
|
||||||
{ }
|
}
|
||||||
|
|
||||||
~PrivateData()
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < players.Size(); i++)
|
|
||||||
{
|
|
||||||
this->players[i]->player = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DynamicArray<PlayerData*> players;
|
|
||||||
LevelData* level;
|
|
||||||
Utility::WinTimer timer;
|
|
||||||
|
|
||||||
}myData;
|
|
||||||
|
|
||||||
|
|
||||||
Game::Game(void)
|
Game::Game(void)
|
||||||
{
|
: initiated(false)
|
||||||
myData = new PrivateData();
|
, onMoveFnc(0)
|
||||||
}
|
, onDeadFnc(0)
|
||||||
|
, frameTime(1.0f/120.0f)
|
||||||
|
{}
|
||||||
|
|
||||||
Game::~Game(void)
|
Game::~Game(void)
|
||||||
{
|
{
|
||||||
if(myData)
|
for (unsigned int i = 0; i < gameInstance.players.Size(); i++)
|
||||||
{
|
{
|
||||||
delete myData;
|
delete gameInstance.players[i];
|
||||||
}
|
}
|
||||||
|
gameInstance.players.Clear();
|
||||||
|
|
||||||
|
delete this->level;
|
||||||
|
this->level = 0;
|
||||||
|
|
||||||
|
initiated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::GetAllPlayerPositions() const
|
void Game::GetAllPlayerPositions() const
|
||||||
|
@ -81,21 +67,23 @@ void Game::GetAllPlayerPositions() const
|
||||||
|
|
||||||
Game::PlayerData* Game::CreatePlayer()
|
Game::PlayerData* Game::CreatePlayer()
|
||||||
{
|
{
|
||||||
Player *newPlayer = new Player();
|
// Find a free space in array or insert at end
|
||||||
PlayerData *newPdata = new PlayerData();
|
int id = InsertObject(this->players, (PlayerData*)0);
|
||||||
newPdata->player = newPlayer;
|
|
||||||
int id = InsertObject(this->myData->players, newPdata);
|
this->players[id] = new PlayerData();
|
||||||
return this->myData->players[id];
|
this->players[id]->player->GetRigidBody()->SetSubscription(Game::PhysicsOnMove);
|
||||||
|
|
||||||
|
return this->players[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::LevelData* Game::CreateLevel()
|
Game::LevelData* Game::CreateLevel()
|
||||||
{
|
{
|
||||||
Level *newLevel = new Level();
|
if(this->level) return this->level;
|
||||||
newLevel->InitiateLevel(1000);
|
|
||||||
LevelData *newLdata = new LevelData();
|
this->level = new LevelData();
|
||||||
newLdata->level = newLevel;
|
this->level->level->InitiateLevel(1000);
|
||||||
myData->level = newLdata;
|
|
||||||
return myData->level;
|
return this->level;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::CreateTeam()
|
void Game::CreateTeam()
|
||||||
|
@ -103,27 +91,72 @@ void Game::CreateTeam()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::NewFrame()
|
bool Game::NewFrame()
|
||||||
{
|
{
|
||||||
double dt = this->myData->timer.getElapsedSeconds();
|
for (unsigned int i = 0; i < this->players.Size(); i++)
|
||||||
|
|
||||||
//60 fps sec is currently staticly
|
|
||||||
|
|
||||||
|
|
||||||
if(dt >= DELTA_TIME)
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i < this->myData->players.Size(); i++)
|
if(this->players[i]->player) this->players[i]->player->BeginFrame();
|
||||||
{
|
|
||||||
if(this->myData->players[i]->player)
|
|
||||||
this->myData->players[i]->player->BeginFrame();
|
|
||||||
}
|
|
||||||
API::Instance().Update();
|
|
||||||
|
|
||||||
for (int i = 0; i < this->myData->players.Size(); i++)
|
|
||||||
{
|
|
||||||
if(this->myData->players[i]->player)
|
|
||||||
this->myData->players[i]->player->EndFrame();
|
|
||||||
}
|
|
||||||
this->myData->timer.reset();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
API::Instance().Update();
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < this->players.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->players[i]->player) this->players[i]->player->EndFrame();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Game::SetFPS(int FPS)
|
||||||
|
{
|
||||||
|
this->frameTime = 1.0f / FPS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Game::SetFrameTimeLength( float seconds )
|
||||||
|
{
|
||||||
|
this->frameTime = seconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Game::SetSubscription(GameEvent::ObjectEventFunctionType type, GameEvent::ObjectEventFunction functionPointer)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case GameLogic::GameEvent::ObjectEventFunctionType_OnMove:
|
||||||
|
this->onMoveFnc = functionPointer;
|
||||||
|
break;
|
||||||
|
case GameLogic::GameEvent::ObjectEventFunctionType_OnDead:
|
||||||
|
this->onDeadFnc = functionPointer;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Game::Initiate()
|
||||||
|
{
|
||||||
|
API::Instance().Init((int)pow(2u, 9u), 1u, Oyster::Math::Float3());
|
||||||
|
API::Instance().SetSubscription(Game::PhysicsOnDestroy);
|
||||||
|
this->initiated = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float Game::GetFrameTime() const
|
||||||
|
{
|
||||||
|
return this->frameTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************************************/
|
||||||
|
/*********** Private methods ******************/
|
||||||
|
/***************************************************************************************************/
|
||||||
|
|
||||||
|
void Game::PhysicsOnMove(const ICustomBody *object)
|
||||||
|
{
|
||||||
|
IObjectData* temp = 0;
|
||||||
|
//IObjectData* temp = ((IObjectData*)object->GetDataTag());
|
||||||
|
if(gameInstance.onMoveFnc) gameInstance.onMoveFnc(temp);
|
||||||
|
}
|
||||||
|
void Game::PhysicsOnDestroy(::Utility::DynamicMemory::UniquePointer<ICustomBody> proto)
|
||||||
|
{
|
||||||
|
if(gameInstance.onDeadFnc) gameInstance.onDeadFnc(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,112 +5,84 @@
|
||||||
#ifndef GAME_H
|
#ifndef GAME_H
|
||||||
#define GAME_H
|
#define GAME_H
|
||||||
|
|
||||||
#include "GameLogicDef.h"
|
//Includes windows so we need to undef minmax
|
||||||
#include "GameLogicStates.h"
|
#define NOMINMAX
|
||||||
#include <OysterMath.h>
|
#include <vld.h>
|
||||||
|
|
||||||
|
#include "GameAPI.h"
|
||||||
|
#include "Player.h"
|
||||||
|
#include "Level.h"
|
||||||
|
|
||||||
|
#include <DynamicArray.h>
|
||||||
|
#include <GID.h>
|
||||||
|
#include <PhysicsAPI.h>
|
||||||
|
#include <WinTimer.h>
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
class Player;
|
class Game :public GameAPI
|
||||||
class Level;
|
|
||||||
class DANBIAS_GAMELOGIC_DLL Game
|
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct DANBIAS_GAMELOGIC_DLL PlayerData
|
class PlayerData :public IPlayerData
|
||||||
{
|
{
|
||||||
private:
|
public:
|
||||||
friend class Game;
|
|
||||||
Player *player;
|
|
||||||
PlayerData();
|
PlayerData();
|
||||||
PlayerData(int playerID,int teamID);
|
PlayerData(int playerID,int teamID);
|
||||||
~PlayerData();
|
~PlayerData();
|
||||||
|
|
||||||
public:
|
|
||||||
/********************************************************
|
|
||||||
* Moves the chosen player based on input
|
|
||||||
* @param playerID: ID of the player you want to recieve the message
|
|
||||||
* @param movement: enum value on what kind of action is to be taken
|
|
||||||
********************************************************/
|
|
||||||
void Move(const PLAYER_MOVEMENT &movement);
|
|
||||||
|
|
||||||
/********************************************************
|
void Move(const PLAYER_MOVEMENT &movement) override;
|
||||||
* Uses the chosen players weapon based on input
|
void UseWeapon(int playerID, const WEAPON_FIRE &usage) override;
|
||||||
* @param playerID: ID of the player you want to recieve the message
|
int GetTeamID() const override;
|
||||||
* @param Usage: enum value on what kind of action is to be taken
|
PLAYER_STATE GetState() const override;
|
||||||
********************************************************/
|
Oyster::Math::Float3 GetPosition() override;
|
||||||
void UseWeapon(int playerID, const WEAPON_FIRE &usage);
|
Oyster::Math::Float4x4 GetOrientation() override;
|
||||||
|
int GetID() const override;
|
||||||
|
OBJECT_TYPE GetObjectType() const override;
|
||||||
|
|
||||||
/********************************************************
|
Player *player;
|
||||||
* Gets players position
|
|
||||||
* @param playerID: ID of the player whos position you want
|
|
||||||
********************************************************/
|
|
||||||
Oyster::Math::Float3 GetPosition();
|
|
||||||
|
|
||||||
/********************************************************
|
|
||||||
* Gets players current orientation
|
|
||||||
* @param playerID: ID of the player whos position you want
|
|
||||||
********************************************************/
|
|
||||||
Oyster::Math::Float4x4 GetOrientation();
|
|
||||||
|
|
||||||
/********************************************************
|
|
||||||
* Check player state
|
|
||||||
* @return The current player state
|
|
||||||
********************************************************/
|
|
||||||
PLAYER_STATE GetState() const;
|
|
||||||
|
|
||||||
/***/
|
|
||||||
int GetID() const;
|
|
||||||
|
|
||||||
/***/
|
|
||||||
int GetTeamID() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DANBIAS_GAMELOGIC_DLL LevelData
|
class LevelData :public ILevelData
|
||||||
{
|
{
|
||||||
private:
|
public:
|
||||||
friend class Game;
|
|
||||||
Level *level;
|
|
||||||
LevelData();
|
LevelData();
|
||||||
~LevelData();
|
~LevelData();
|
||||||
|
Oyster::Math::Float3 GetPosition() override;
|
||||||
public:
|
Oyster::Math::Float4x4 GetOrientation() override;
|
||||||
|
int GetID() const override;
|
||||||
|
OBJECT_TYPE GetObjectType() const override;
|
||||||
|
|
||||||
|
Level *level;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Game(void);
|
Game();
|
||||||
~Game(void);
|
~Game();
|
||||||
|
|
||||||
/********************************************************
|
void GetAllPlayerPositions() const override;
|
||||||
* Gets the position of all players currently in the game
|
PlayerData* CreatePlayer() override;
|
||||||
********************************************************/
|
LevelData* CreateLevel() override;
|
||||||
void GetAllPlayerPositions() const;
|
void CreateTeam() override;
|
||||||
|
bool NewFrame() override;
|
||||||
|
void SetFPS( int FPS ) override;
|
||||||
|
void SetFrameTimeLength( float seconds ) override;
|
||||||
|
void SetSubscription(GameEvent::ObjectEventFunctionType type, GameEvent::ObjectEventFunction functionPointer) override;
|
||||||
|
bool Initiate() override;
|
||||||
|
|
||||||
/********************************************************
|
float GetFrameTime() const;
|
||||||
* Creates a player and returns PlayerData
|
|
||||||
********************************************************/
|
|
||||||
PlayerData* CreatePlayer();
|
|
||||||
|
|
||||||
/********************************************************
|
|
||||||
* Creates a level and returns LevelData
|
|
||||||
********************************************************/
|
|
||||||
LevelData* CreateLevel();
|
|
||||||
|
|
||||||
/********************************************************
|
|
||||||
* Creates a team
|
|
||||||
********************************************************/
|
|
||||||
void CreateTeam();
|
|
||||||
|
|
||||||
/********************************************************
|
|
||||||
* Runs a update of the gamelogic and physics
|
|
||||||
********************************************************/
|
|
||||||
void NewFrame();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct PrivateData;
|
static void PhysicsOnMove(const Oyster::Physics::ICustomBody *object);
|
||||||
PrivateData *myData;
|
static void PhysicsOnDestroy(::Utility::DynamicMemory::UniquePointer<Oyster::Physics::ICustomBody> proto);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Utility::DynamicMemory::DynamicArray<PlayerData*> players;
|
||||||
|
LevelData* level;
|
||||||
|
float frameTime;
|
||||||
|
bool initiated;
|
||||||
|
GameEvent::ObjectEventFunction onDeadFnc;
|
||||||
|
GameEvent::ObjectEventFunction onMoveFnc;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,160 @@
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
// Created by [Erik Persson] [2013]
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef GAME_API_H
|
||||||
|
#define GAME_API_H
|
||||||
|
|
||||||
|
//Includes windows so we need to undef minmax
|
||||||
|
#define NOMINMAX
|
||||||
|
#include <vld.h>
|
||||||
|
|
||||||
|
#include "GameLogicDef.h"
|
||||||
|
#include "GameLogicStates.h"
|
||||||
|
#include <OysterMath.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace GameLogic
|
||||||
|
{
|
||||||
|
class IObjectData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collection of various event structures that may be used to get events grom the game.
|
||||||
|
*/
|
||||||
|
namespace GameEvent
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The type of event to listen on.
|
||||||
|
*/
|
||||||
|
enum ObjectEventFunctionType
|
||||||
|
{
|
||||||
|
ObjectEventFunctionType_OnMove,
|
||||||
|
ObjectEventFunctionType_OnDead,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef void(*ObjectEventFunction)(IObjectData* object); // Callback method that recieves and object
|
||||||
|
//etc...
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An object that collects the standard usage functions
|
||||||
|
*/
|
||||||
|
class IObjectData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/********************************************************
|
||||||
|
* Gets players position
|
||||||
|
* @param playerID: ID of the player whos position you want
|
||||||
|
********************************************************/
|
||||||
|
virtual Oyster::Math::Float3 GetPosition() = 0;
|
||||||
|
|
||||||
|
/********************************************************
|
||||||
|
* Gets players current orientation
|
||||||
|
* @param playerID: ID of the player whos position you want
|
||||||
|
********************************************************/
|
||||||
|
virtual Oyster::Math::Float4x4 GetOrientation() = 0;
|
||||||
|
|
||||||
|
/** Get the uniuqe id for the object
|
||||||
|
* @return The id for the object.
|
||||||
|
*/
|
||||||
|
virtual int GetID() const = 0;
|
||||||
|
|
||||||
|
/** Get the type of the object
|
||||||
|
* @return The OBJECT_TYPE of the object is returned
|
||||||
|
*/
|
||||||
|
virtual OBJECT_TYPE GetObjectType() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IPlayerData :public IObjectData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/********************************************************
|
||||||
|
* Moves the chosen player based on input
|
||||||
|
* @param playerID: ID of the player you want to recieve the message
|
||||||
|
* @param movement: enum value on what kind of action is to be taken
|
||||||
|
********************************************************/
|
||||||
|
virtual void Move(const PLAYER_MOVEMENT &movement) = 0;
|
||||||
|
|
||||||
|
/********************************************************
|
||||||
|
* Uses the chosen players weapon based on input
|
||||||
|
* @param playerID: ID of the player you want to recieve the message
|
||||||
|
* @param Usage: enum value on what kind of action is to be taken
|
||||||
|
********************************************************/
|
||||||
|
virtual void UseWeapon(int playerID, const WEAPON_FIRE &usage) = 0;
|
||||||
|
|
||||||
|
/***/
|
||||||
|
virtual int GetTeamID() const = 0;
|
||||||
|
|
||||||
|
/********************************************************
|
||||||
|
* Check player state
|
||||||
|
* @return The current player state
|
||||||
|
********************************************************/
|
||||||
|
virtual PLAYER_STATE GetState() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ILevelData :public IObjectData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class DANBIAS_GAMELOGIC_DLL GameAPI
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** A global function to get an instance of the API
|
||||||
|
* @return Returns the GameAPI instance
|
||||||
|
*/
|
||||||
|
static GameAPI& Instance( void );
|
||||||
|
|
||||||
|
public:
|
||||||
|
/** Initiates the Game instance.
|
||||||
|
* - This method must be called before the API can be used.
|
||||||
|
* @return If the return value is false, something went wrong.
|
||||||
|
*/
|
||||||
|
virtual bool Initiate( void ) = 0;
|
||||||
|
|
||||||
|
/********************************************************
|
||||||
|
* Gets the position of all players currently in the game
|
||||||
|
********************************************************/
|
||||||
|
virtual void GetAllPlayerPositions( void ) const = 0;
|
||||||
|
|
||||||
|
/** Creates a player
|
||||||
|
* @return Returns a IPlayerData container to use for player manipulation.
|
||||||
|
*/
|
||||||
|
virtual IPlayerData* CreatePlayer( void ) = 0;
|
||||||
|
|
||||||
|
/** Creates a level
|
||||||
|
* @return Returns a ILevelData container to use for level manipulation
|
||||||
|
*/
|
||||||
|
virtual ILevelData* CreateLevel( void ) = 0;
|
||||||
|
|
||||||
|
/** Creates a team
|
||||||
|
* @return ?
|
||||||
|
*/
|
||||||
|
virtual void CreateTeam( void ) = 0;
|
||||||
|
|
||||||
|
/** Runs a update of the gamelogic and physics
|
||||||
|
* @return Returns true if a frame was proccessed
|
||||||
|
*/
|
||||||
|
virtual bool NewFrame( void ) = 0;
|
||||||
|
|
||||||
|
/** Set the frame time in fps
|
||||||
|
* @param FPS The fps to set
|
||||||
|
*/
|
||||||
|
virtual void SetFPS( int FPS = 60 ) = 0;
|
||||||
|
|
||||||
|
/** Set the frames time in seconds
|
||||||
|
* @param seconds The frame length
|
||||||
|
*/
|
||||||
|
virtual void SetFrameTimeLength( float seconds ) = 0;
|
||||||
|
|
||||||
|
/** Set a specific object event subscription callback
|
||||||
|
* @param
|
||||||
|
*/
|
||||||
|
virtual void SetSubscription(GameEvent::ObjectEventFunctionType type, GameEvent::ObjectEventFunction functionPointer) = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -69,26 +69,30 @@
|
||||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
<LibraryPath>$(SolutionDir)..\Bin\DLL;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(SolutionDir)..\Bin\DLL;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
<TargetExt>.dll</TargetExt>
|
<TargetExt>.dll</TargetExt>
|
||||||
|
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
<LibraryPath>$(SolutionDir)..\Bin\DLL;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(SolutionDir)..\Bin\DLL;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
|
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
<LibraryPath>$(SolutionDir)..\Bin\DLL;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(SolutionDir)..\Bin\DLL;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath)</LibraryPath>
|
||||||
|
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\DLL\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
<LibraryPath>$(SolutionDir)..\Bin\DLL;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(SolutionDir)..\Bin\DLL;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath)</LibraryPath>
|
||||||
|
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
|
@ -174,6 +178,7 @@
|
||||||
<ClInclude Include="CollisionManager.h" />
|
<ClInclude Include="CollisionManager.h" />
|
||||||
<ClInclude Include="DynamicObject.h" />
|
<ClInclude Include="DynamicObject.h" />
|
||||||
<ClInclude Include="Game.h" />
|
<ClInclude Include="Game.h" />
|
||||||
|
<ClInclude Include="GameAPI.h" />
|
||||||
<ClInclude Include="GameLogicDef.h" />
|
<ClInclude Include="GameLogicDef.h" />
|
||||||
<ClInclude Include="GameLogicStates.h" />
|
<ClInclude Include="GameLogicStates.h" />
|
||||||
<ClInclude Include="GameMode.h" />
|
<ClInclude Include="GameMode.h" />
|
||||||
|
|
|
@ -24,7 +24,8 @@ namespace GameLogic
|
||||||
{
|
{
|
||||||
OBJECT_TYPE_PLAYER = 0,
|
OBJECT_TYPE_PLAYER = 0,
|
||||||
OBJECT_TYPE_BOX = 1,
|
OBJECT_TYPE_BOX = 1,
|
||||||
OBJECT_TYPE_UNKNOWN = 2,
|
OBJECT_TYPE_WORLD = 2,
|
||||||
|
OBJECT_TYPE_UNKNOWN = -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum WEAPON_FIRE
|
enum WEAPON_FIRE
|
||||||
|
|
|
@ -3,28 +3,13 @@
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
|
||||||
|
|
||||||
struct GameMode::PrivateData
|
|
||||||
{
|
|
||||||
PrivateData()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
~PrivateData()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}myData;
|
|
||||||
|
|
||||||
|
|
||||||
GameMode::GameMode()
|
GameMode::GameMode()
|
||||||
{
|
{
|
||||||
myData = new PrivateData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GameMode::~GameMode(void)
|
GameMode::~GameMode(void)
|
||||||
{
|
{
|
||||||
delete myData;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,9 @@ namespace GameLogic
|
||||||
public:
|
public:
|
||||||
GameMode(void);
|
GameMode(void);
|
||||||
~GameMode(void);
|
~GameMode(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct PrivateData;
|
|
||||||
PrivateData *myData;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,33 @@ using namespace GameLogic;
|
||||||
|
|
||||||
Game::LevelData::LevelData()
|
Game::LevelData::LevelData()
|
||||||
{
|
{
|
||||||
|
this->level = new Level();
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::LevelData::~LevelData()
|
Game::LevelData::~LevelData()
|
||||||
{
|
{
|
||||||
|
delete this->level;
|
||||||
|
this->level = 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
Oyster::Math::Float3 Game::LevelData::GetPosition()
|
||||||
|
{
|
||||||
|
//return this->level->GetCenter();
|
||||||
|
return Oyster::Math::Float3();
|
||||||
|
}
|
||||||
|
Oyster::Math::Float4x4 Game::LevelData::GetOrientation()
|
||||||
|
{
|
||||||
|
//return this->level->GetOrientation();
|
||||||
|
return Oyster::Math::Float4x4();
|
||||||
|
}
|
||||||
|
int Game::LevelData::GetID() const
|
||||||
|
{
|
||||||
|
//this->level->GetID();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
OBJECT_TYPE Game::LevelData::GetObjectType() const
|
||||||
|
{
|
||||||
|
//return this->level->GetType();
|
||||||
|
return OBJECT_TYPE_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
|
@ -5,15 +5,15 @@ using namespace GameLogic;
|
||||||
|
|
||||||
Game::PlayerData::PlayerData()
|
Game::PlayerData::PlayerData()
|
||||||
{
|
{
|
||||||
|
this->player = new Player();
|
||||||
}
|
}
|
||||||
Game::PlayerData::PlayerData(int playerID,int teamID)
|
Game::PlayerData::PlayerData(int playerID,int teamID)
|
||||||
{
|
{
|
||||||
|
this->player = new Player();
|
||||||
}
|
}
|
||||||
Game::PlayerData::~PlayerData()
|
Game::PlayerData::~PlayerData()
|
||||||
{
|
{
|
||||||
|
delete this->player;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::PlayerData::Move(const PLAYER_MOVEMENT &movement)
|
void Game::PlayerData::Move(const PLAYER_MOVEMENT &movement)
|
||||||
|
@ -43,4 +43,8 @@ int Game::PlayerData::GetID() const
|
||||||
int Game::PlayerData::GetTeamID() const
|
int Game::PlayerData::GetTeamID() const
|
||||||
{
|
{
|
||||||
return this->player->GetTeamID();
|
return this->player->GetTeamID();
|
||||||
|
}
|
||||||
|
OBJECT_TYPE Game::PlayerData::GetObjectType() const
|
||||||
|
{
|
||||||
|
return this->player->GetType();
|
||||||
}
|
}
|
|
@ -1,47 +1,16 @@
|
||||||
#include "Level.h"
|
#include "Level.h"
|
||||||
#include "StaticObject.h"
|
#include "CollisionManager.h"
|
||||||
#include "DynamicObject.h"
|
|
||||||
#include "GameMode.h"
|
|
||||||
#include "Player.h"
|
|
||||||
#include "PhysicsAPI.h"
|
|
||||||
#include "TeamManager.h"
|
|
||||||
#include "DynamicArray.h"
|
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
using namespace Utility::DynamicMemory;
|
using namespace Utility::DynamicMemory;
|
||||||
using namespace Oyster::Physics;
|
using namespace Oyster::Physics;
|
||||||
|
|
||||||
struct Level::PrivateData
|
|
||||||
{
|
|
||||||
PrivateData()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
~PrivateData()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
SmartPointer<TeamManager> teamManager;
|
|
||||||
|
|
||||||
DynamicArray<SmartPointer<StaticObject>> staticObjects;
|
|
||||||
|
|
||||||
DynamicArray<SmartPointer<DynamicObject>> dynamicObjects;
|
|
||||||
|
|
||||||
SmartPointer<GameMode> gameMode;
|
|
||||||
|
|
||||||
SmartPointer<ICustomBody> rigidBodyLevel;
|
|
||||||
|
|
||||||
}myData;
|
|
||||||
|
|
||||||
Level::Level(void)
|
Level::Level(void)
|
||||||
{
|
{
|
||||||
myData = new PrivateData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Level::~Level(void)
|
Level::~Level(void)
|
||||||
{
|
{
|
||||||
delete myData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Level::InitiateLevel(std::string levelPath)
|
void Level::InitiateLevel(std::string levelPath)
|
||||||
|
@ -50,39 +19,40 @@ void Level::InitiateLevel(std::string levelPath)
|
||||||
}
|
}
|
||||||
void Level::InitiateLevel(float radius)
|
void Level::InitiateLevel(float radius)
|
||||||
{
|
{
|
||||||
API::SphericalBodyDescription sbDesc;
|
//API::SphericalBodyDescription sbDesc;
|
||||||
sbDesc.centerPosition = Oyster::Math::Float4(0,0,0,1);
|
//sbDesc.centerPosition = Oyster::Math::Float4(0,0,0,1);
|
||||||
sbDesc.ignoreGravity = true;
|
//sbDesc.ignoreGravity = true;
|
||||||
sbDesc.radius = radius;
|
//sbDesc.radius = radius;
|
||||||
sbDesc.mass = 1e16; //10^16
|
//sbDesc.mass = 1e16f; //10^16
|
||||||
sbDesc.subscription = CollisionManager::LevelCollision;
|
//sbDesc.mass = 0; //10^16
|
||||||
|
//sbDesc.subscription_onCollision = CollisionManager::LevelCollision;
|
||||||
ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
|
//
|
||||||
API::Instance().AddObject(rigidBody);
|
//ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
|
||||||
|
//API::Instance().AddObject(rigidBody);
|
||||||
API::Gravity gravityWell;
|
|
||||||
|
//API::Gravity gravityWell;
|
||||||
gravityWell.gravityType = API::Gravity::GravityType_Well;
|
//
|
||||||
gravityWell.well.mass = (float)1e16;
|
//gravityWell.gravityType = API::Gravity::GravityType_Well;
|
||||||
gravityWell.well.position = Oyster::Math::Float4(0,0,0,1);
|
//gravityWell.well.mass = 1e16f;
|
||||||
|
//gravityWell.well.position = Oyster::Math::Float4(0,0,0,1);
|
||||||
API::Instance().AddGravity(gravityWell);
|
//
|
||||||
|
//API::Instance().AddGravity(gravityWell);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Level::AddPlayerToTeam(Player *player, int teamID)
|
void Level::AddPlayerToTeam(Player *player, int teamID)
|
||||||
{
|
{
|
||||||
myData->teamManager->AddPlayerToTeam(player,teamID);
|
this->teamManager.AddPlayerToTeam(player,teamID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Level::CreateTeam(int teamSize)
|
void Level::CreateTeam(int teamSize)
|
||||||
{
|
{
|
||||||
myData->teamManager->CreateTeam(teamSize);
|
this->teamManager.CreateTeam(teamSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Level::RespawnPlayer(Player *player)
|
void Level::RespawnPlayer(Player *player)
|
||||||
{
|
{
|
||||||
myData->teamManager->RespawnPlayerRandom(player);
|
this->teamManager.RespawnPlayerRandom(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,15 @@
|
||||||
#ifndef LEVEL_H
|
#ifndef LEVEL_H
|
||||||
#define LEVEL_H
|
#define LEVEL_H
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
|
#include "StaticObject.h"
|
||||||
|
#include "DynamicObject.h"
|
||||||
|
#include "GameMode.h"
|
||||||
|
#include "Player.h"
|
||||||
|
#include "PhysicsAPI.h"
|
||||||
|
#include "TeamManager.h"
|
||||||
|
#include "DynamicArray.h"
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
|
@ -44,10 +52,11 @@ namespace GameLogic
|
||||||
void RespawnPlayer(Player *player);
|
void RespawnPlayer(Player *player);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
TeamManager teamManager;
|
||||||
private:
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<StaticObject>> staticObjects;
|
||||||
struct PrivateData;
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<DynamicObject>> dynamicObjects;
|
||||||
PrivateData *myData;
|
GameMode gameMode;
|
||||||
|
Utility::DynamicMemory::SmartPointer<Oyster::Physics::ICustomBody> rigidBodyLevel;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "CollisionManager.h"
|
#include "CollisionManager.h"
|
||||||
#include "GID.h"
|
#include "GID.h"
|
||||||
#include "PhysicsAPI.h"
|
#include "PhysicsAPI.h"
|
||||||
|
#include "Game.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
@ -10,6 +11,8 @@ using namespace GameLogic;
|
||||||
using namespace Oyster::Math;
|
using namespace Oyster::Math;
|
||||||
using namespace Oyster::Physics;
|
using namespace Oyster::Physics;
|
||||||
|
|
||||||
|
const Game *Object::gameInstance = (Game*)(&Game::Instance());
|
||||||
|
|
||||||
Object::Object()
|
Object::Object()
|
||||||
{
|
{
|
||||||
API::SimpleBodyDescription sbDesc;
|
API::SimpleBodyDescription sbDesc;
|
||||||
|
@ -34,7 +37,7 @@ Object::Object(void* collisionFunc, OBJECT_TYPE type)
|
||||||
//sbDesc.centerPosition =
|
//sbDesc.centerPosition =
|
||||||
|
|
||||||
//poi
|
//poi
|
||||||
ICustomBody* temp = rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
|
this->rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
|
||||||
|
|
||||||
Oyster::Physics::API::Instance().AddObject(rigidBody);
|
Oyster::Physics::API::Instance().AddObject(rigidBody);
|
||||||
|
|
||||||
|
@ -66,3 +69,14 @@ Oyster::Physics::ICustomBody* Object::GetRigidBody()
|
||||||
{
|
{
|
||||||
return this->rigidBody;
|
return this->rigidBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Object::BeginFrame()
|
||||||
|
{
|
||||||
|
this->rigidBody->SetState(this->setState);
|
||||||
|
}
|
||||||
|
void Object::EndFrame()
|
||||||
|
{
|
||||||
|
this->rigidBody->GetState(this->getState);
|
||||||
|
this->setState = this->getState;
|
||||||
|
}
|
|
@ -6,12 +6,13 @@
|
||||||
#ifndef OBJECT_H
|
#ifndef OBJECT_H
|
||||||
#define OBJECT_H
|
#define OBJECT_H
|
||||||
|
|
||||||
|
|
||||||
#include "GameLogicStates.h"
|
#include "GameLogicStates.h"
|
||||||
#include <PhysicsAPI.h>
|
#include <PhysicsAPI.h>
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
|
class Game;
|
||||||
|
|
||||||
class Object
|
class Object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -21,17 +22,22 @@ namespace GameLogic
|
||||||
|
|
||||||
OBJECT_TYPE GetType() const;
|
OBJECT_TYPE GetType() const;
|
||||||
int GetID() const;
|
int GetID() const;
|
||||||
|
|
||||||
Oyster::Physics::ICustomBody* GetRigidBody();
|
Oyster::Physics::ICustomBody* GetRigidBody();
|
||||||
|
|
||||||
|
void BeginFrame();
|
||||||
|
void EndFrame();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OBJECT_TYPE type;
|
OBJECT_TYPE type;
|
||||||
int objectID;
|
int objectID;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Oyster::Physics::ICustomBody *rigidBody;
|
Oyster::Physics::ICustomBody *rigidBody;
|
||||||
Oyster::Physics::ICustomBody::State setState;
|
Oyster::Physics::ICustomBody::State setState;
|
||||||
Oyster::Physics::ICustomBody::State getState;
|
Oyster::Physics::ICustomBody::State getState;
|
||||||
|
|
||||||
|
static const Game* gameInstance;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "Weapon.h"
|
#include "Weapon.h"
|
||||||
|
#include "CollisionManager.h"
|
||||||
|
#include "Game.h"
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
using namespace Oyster::Physics;
|
using namespace Oyster::Physics;
|
||||||
|
@ -14,17 +16,11 @@ Player::Player()
|
||||||
teamID = -1;
|
teamID = -1;
|
||||||
playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
|
playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
|
||||||
lookDir = Oyster::Math::Float4(0,0,-1,0);
|
lookDir = Oyster::Math::Float4(0,0,-1,0);
|
||||||
Oyster::Physics::ICustomBody::State state;
|
|
||||||
this->rigidBody->GetState( this->setState );
|
|
||||||
setState.SetLinearMomentum( Oyster::Math::Float4(20, 0, 0, 0) );
|
|
||||||
this->rigidBody->SetState( setState );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::~Player(void)
|
Player::~Player(void)
|
||||||
{
|
{
|
||||||
delete weapon;
|
delete weapon;
|
||||||
|
|
||||||
weapon = NULL;
|
weapon = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,26 +53,26 @@ void Player::Move(const PLAYER_MOVEMENT &movement)
|
||||||
|
|
||||||
void Player::MoveForward()
|
void Player::MoveForward()
|
||||||
{
|
{
|
||||||
setState.ApplyLinearImpulse(this->lookDir * 100);
|
setState.ApplyLinearImpulse(this->lookDir * (100 * this->gameInstance->GetFrameTime()));
|
||||||
}
|
}
|
||||||
void Player::MoveBackwards()
|
void Player::MoveBackwards()
|
||||||
{
|
{
|
||||||
setState.ApplyLinearImpulse(-this->lookDir * 100);
|
setState.ApplyLinearImpulse(-this->lookDir * 100 * this->gameInstance->GetFrameTime());
|
||||||
}
|
}
|
||||||
void Player::MoveRight()
|
void Player::MoveRight()
|
||||||
{
|
{
|
||||||
//Do cross product with forward vector and negative gravity vector
|
//Do cross product with forward vector and negative gravity vector
|
||||||
Oyster::Math::Float4 r = Oyster::Math::Float4(1, 0, 0, 0 );
|
Oyster::Math::Float4 r = Oyster::Math::Float4(1, 0, 0, 0 );
|
||||||
//Oyster::Math::Float4 r = (-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir);
|
//Oyster::Math::Float4 r = (-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir);
|
||||||
setState.ApplyLinearImpulse(r * 100);
|
setState.ApplyLinearImpulse(r * 100 * this->gameInstance->GetFrameTime());
|
||||||
|
|
||||||
}
|
}
|
||||||
void Player::MoveLeft()
|
void Player::MoveLeft()
|
||||||
{
|
{
|
||||||
//Do cross product with forward vector and negative gravity vector
|
//Do cross product with forward vector and negative gravity vector
|
||||||
Oyster::Math::Float4 r = Oyster::Math::Float4(1, 0, 0, 0 );
|
Oyster::Math::Float4 r = Oyster::Math::Float4(1, 0, 0, 0 );
|
||||||
//Oyster::Math::Float4 r = -(-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir);
|
//Oyster::Math::Float4 r1 = -(-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir); //Still get zero
|
||||||
setState.ApplyLinearImpulse(-r * 100);
|
setState.ApplyLinearImpulse(-r * 100 * this->gameInstance->GetFrameTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::UseWeapon(const WEAPON_FIRE &usage)
|
void Player::UseWeapon(const WEAPON_FIRE &usage)
|
||||||
|
@ -136,12 +132,3 @@ void Player::DamageLife(int damage)
|
||||||
this->life -= damage;
|
this->life -= damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::BeginFrame()
|
|
||||||
{
|
|
||||||
this->rigidBody->SetState(this->setState);
|
|
||||||
}
|
|
||||||
void Player::EndFrame()
|
|
||||||
{
|
|
||||||
this->rigidBody->GetState(this->getState);
|
|
||||||
this->setState = this->getState;
|
|
||||||
}
|
|
|
@ -7,9 +7,6 @@
|
||||||
#include "GameLogicStates.h"
|
#include "GameLogicStates.h"
|
||||||
#include "OysterMath.h"
|
#include "OysterMath.h"
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include "OysterMath.h"
|
|
||||||
#include "CollisionManager.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
|
@ -58,10 +55,6 @@ namespace GameLogic
|
||||||
|
|
||||||
void DamageLife(int damage);
|
void DamageLife(int damage);
|
||||||
|
|
||||||
//Do frame calculations
|
|
||||||
void BeginFrame();
|
|
||||||
void EndFrame();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Jump();
|
void Jump();
|
||||||
|
|
||||||
|
|
|
@ -1,60 +1,54 @@
|
||||||
#include "Team.h"
|
#include "Team.h"
|
||||||
#include "Player.h"
|
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
|
||||||
struct Team::PrivateData
|
|
||||||
{
|
|
||||||
PrivateData()
|
|
||||||
{
|
|
||||||
players = 0;
|
|
||||||
nrOfPlayers = 0;
|
|
||||||
teamSize = 0;
|
|
||||||
}
|
|
||||||
~PrivateData()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Player **players;
|
|
||||||
int nrOfPlayers;
|
|
||||||
|
|
||||||
int teamSize;
|
|
||||||
|
|
||||||
}myData;
|
|
||||||
|
|
||||||
Team::Team(void)
|
Team::Team(void)
|
||||||
{
|
: players(5)
|
||||||
myData = new PrivateData();
|
, teamSize(5)
|
||||||
}
|
{}
|
||||||
|
|
||||||
Team::Team(int teamSize)
|
Team::Team(int teamSize)
|
||||||
{
|
: players((unsigned int)teamSize)
|
||||||
myData = new PrivateData();
|
, teamSize(teamSize)
|
||||||
myData->teamSize = teamSize;
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Team::~Team(void)
|
Team::~Team(void)
|
||||||
{
|
{
|
||||||
delete myData;
|
this->players.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
Player* Team::GetPlayer(int playerID)
|
Player* Team::GetPlayer(int playerID)
|
||||||
{
|
{
|
||||||
return myData->players[playerID];
|
if(playerID >= 0 && playerID < this->teamSize)
|
||||||
|
return this->players[playerID];
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Team::AddPlayer(Player *player)
|
bool Team::AddPlayer(Player *player)
|
||||||
{
|
{
|
||||||
if (myData->nrOfPlayers >= myData->teamSize)
|
if ((int)this->players.Size() >= this->teamSize)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
myData->players[myData->nrOfPlayers] = player;
|
int k = -1;
|
||||||
myData->nrOfPlayers++;
|
for (int i = 0; k == -1 && i < this->teamSize; i++)
|
||||||
|
{
|
||||||
|
if(!this->players[i])
|
||||||
|
k = i;
|
||||||
|
}
|
||||||
|
if(k == -1)
|
||||||
|
{
|
||||||
|
this->players.Push(player);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->players[k] = player;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
|
|
||||||
#ifndef TEAM_H
|
#ifndef TEAM_H
|
||||||
#define TEAM_H
|
#define TEAM_H
|
||||||
|
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
|
#include "DynamicArray.h"
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
|
@ -29,8 +31,8 @@ namespace GameLogic
|
||||||
bool AddPlayer(Player *player);
|
bool AddPlayer(Player *player);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct PrivateData;
|
Utility::DynamicMemory::DynamicArray<Player*> players;
|
||||||
PrivateData *myData;
|
int teamSize;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,69 +1,56 @@
|
||||||
#include "TeamManager.h"
|
#include "TeamManager.h"
|
||||||
#include "Team.h"
|
|
||||||
|
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
|
||||||
struct TeamManager::PrivateData
|
|
||||||
{
|
|
||||||
PrivateData()
|
|
||||||
{
|
|
||||||
teams = 0;
|
|
||||||
nrOfTeams = 0;
|
|
||||||
}
|
|
||||||
~PrivateData()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Team **teams;
|
|
||||||
int nrOfTeams;
|
|
||||||
int maxNrOfTeams;
|
|
||||||
|
|
||||||
}myData;
|
|
||||||
|
|
||||||
TeamManager::TeamManager(void)
|
TeamManager::TeamManager(void)
|
||||||
|
: teams(10)
|
||||||
|
, maxNrOfTeams(10)
|
||||||
{
|
{
|
||||||
myData = new PrivateData();
|
for (int i = 0; i < 10; i++)
|
||||||
myData->maxNrOfTeams = 10;
|
{
|
||||||
myData->teams = new Team*[myData->maxNrOfTeams];
|
teams[i] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TeamManager::TeamManager(int maxNrOfTeams)
|
TeamManager::TeamManager(int maxNrOfTeams)
|
||||||
|
: teams(maxNrOfTeams)
|
||||||
|
, maxNrOfTeams(maxNrOfTeams)
|
||||||
{
|
{
|
||||||
myData = new PrivateData();
|
for (int i = 0; i < this->maxNrOfTeams; i++)
|
||||||
myData->maxNrOfTeams = maxNrOfTeams;
|
|
||||||
|
|
||||||
myData->teams = new Team*[myData->maxNrOfTeams];
|
|
||||||
for (int i = 0; i < myData->maxNrOfTeams; i++)
|
|
||||||
{
|
{
|
||||||
myData->teams[i] = 0;
|
teams[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TeamManager::~TeamManager(void)
|
TeamManager::~TeamManager(void)
|
||||||
{
|
{
|
||||||
delete myData;
|
for (int i = 0; i < this->maxNrOfTeams; i++)
|
||||||
|
{
|
||||||
|
delete this->teams[i];
|
||||||
|
this->teams[i] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TeamManager::RespawnPlayerRandom(Player *player)
|
void TeamManager::RespawnPlayerRandom(Player *player)
|
||||||
{
|
{
|
||||||
|
// Whats going on here?
|
||||||
int teamID = player->GetTeamID();
|
int teamID = player->GetTeamID(); // ?
|
||||||
|
// ?
|
||||||
Player *respawnOnThis = myData->teams[teamID]->GetPlayer(0);
|
Player *respawnOnThis = this->teams[teamID]->GetPlayer(0); // ?
|
||||||
|
// ?
|
||||||
player->Respawn(respawnOnThis->GetPosition());
|
player->Respawn(respawnOnThis->GetPosition()); // ?
|
||||||
|
// player->Respawn(player->GetPosition()); ?
|
||||||
}
|
}
|
||||||
|
|
||||||
void TeamManager::CreateTeam(int teamSize)
|
void TeamManager::CreateTeam(int teamSize)
|
||||||
{
|
{
|
||||||
if (myData->nrOfTeams < myData->maxNrOfTeams)
|
//if (this->nrOfTeams < this->maxNrOfTeams)
|
||||||
{
|
//{
|
||||||
myData->teams[myData->nrOfTeams] = new Team(teamSize);
|
// this->teams[this->nrOfTeams] = new Team(teamSize);
|
||||||
myData->nrOfTeams++;
|
// this->nrOfTeams++;
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TeamManager::RemoveTeam(int teamID)
|
void TeamManager::RemoveTeam(int teamID)
|
||||||
|
@ -73,10 +60,10 @@ void TeamManager::RemoveTeam(int teamID)
|
||||||
|
|
||||||
bool TeamManager::AddPlayerToTeam(Player *player,int teamID)
|
bool TeamManager::AddPlayerToTeam(Player *player,int teamID)
|
||||||
{
|
{
|
||||||
if (IsValidTeam(teamID))
|
//if (IsValidTeam(teamID))
|
||||||
{
|
//{
|
||||||
return myData->teams[teamID]->AddPlayer(player);
|
// return this->teams[teamID]->AddPlayer(player);
|
||||||
}
|
//}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,10 +74,10 @@ bool TeamManager::AddPlayerToTeam(Player *player)
|
||||||
|
|
||||||
bool TeamManager::IsValidTeam(int teamID)
|
bool TeamManager::IsValidTeam(int teamID)
|
||||||
{
|
{
|
||||||
if (teamID < myData->nrOfTeams && teamID > 0 && myData->teams[teamID] != NULL)
|
//if (teamID < this->nrOfTeams && teamID > 0 && this->teams[teamID] != NULL)
|
||||||
{
|
//{
|
||||||
return true;
|
// return true;
|
||||||
}
|
//}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
|
@ -4,7 +4,10 @@
|
||||||
|
|
||||||
#ifndef TEAMMANAGER_H
|
#ifndef TEAMMANAGER_H
|
||||||
#define TEAMMANAGER_H
|
#define TEAMMANAGER_H
|
||||||
|
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
|
#include "Team.h"
|
||||||
|
#include <DynamicArray.h>
|
||||||
|
|
||||||
namespace GameLogic
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
|
@ -56,8 +59,8 @@ namespace GameLogic
|
||||||
bool IsValidTeam(int teamID);
|
bool IsValidTeam(int teamID);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct PrivateData;
|
Utility::DynamicMemory::DynamicArray<Team*> teams;
|
||||||
PrivateData *myData;
|
int maxNrOfTeams;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
|
@ -83,7 +83,7 @@ bool Weapon::IsReloading()
|
||||||
|
|
||||||
bool Weapon::IsValidSocket(int socketID)
|
bool Weapon::IsValidSocket(int socketID)
|
||||||
{
|
{
|
||||||
if(socketID < myData->attatchmentSockets.Size() && socketID >= 0)
|
if(socketID < (int)myData->attatchmentSockets.Size() && socketID >= 0)
|
||||||
{
|
{
|
||||||
if (myData->attatchmentSockets[socketID]->GetAttatchment() != 0)
|
if (myData->attatchmentSockets[socketID]->GetAttatchment() != 0)
|
||||||
{
|
{
|
||||||
|
@ -102,7 +102,7 @@ int Weapon::GetCurrentSocketID()
|
||||||
|
|
||||||
void Weapon::AddNewAttatchment(IAttatchment *attatchment, Player *owner)
|
void Weapon::AddNewAttatchment(IAttatchment *attatchment, Player *owner)
|
||||||
{
|
{
|
||||||
if(myData->currentNrOfAttatchments < myData->attatchmentSockets.Size())
|
if(myData->currentNrOfAttatchments < (int)myData->attatchmentSockets.Size())
|
||||||
{
|
{
|
||||||
myData->attatchmentSockets[myData->currentNrOfAttatchments]->SetAttatchment(attatchment);
|
myData->attatchmentSockets[myData->currentNrOfAttatchments]->SetAttatchment(attatchment);
|
||||||
myData->currentNrOfAttatchments++;
|
myData->currentNrOfAttatchments++;
|
||||||
|
|
|
@ -46,6 +46,7 @@ namespace GameLogic
|
||||||
struct Protocol_General_Text :public Oyster::Network::CustomProtocolObject
|
struct Protocol_General_Text :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
char* text;
|
char* text;
|
||||||
|
int destination;
|
||||||
|
|
||||||
Protocol_General_Text()
|
Protocol_General_Text()
|
||||||
{
|
{
|
||||||
|
|
|
@ -150,6 +150,10 @@
|
||||||
<ClCompile Include="Resource\Loaders\CustomLoader.cpp" />
|
<ClCompile Include="Resource\Loaders\CustomLoader.cpp" />
|
||||||
<ClCompile Include="Resource\OResourceHandler.cpp" />
|
<ClCompile Include="Resource\OResourceHandler.cpp" />
|
||||||
<ClCompile Include="Resource\OResource.cpp" />
|
<ClCompile Include="Resource\OResource.cpp" />
|
||||||
|
<ClCompile Include="Resource\ResourceManager.cpp">
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="Thread\OysterMutex.cpp" />
|
<ClCompile Include="Thread\OysterMutex.cpp" />
|
||||||
<ClCompile Include="Thread\OysterThread_Impl.cpp" />
|
<ClCompile Include="Thread\OysterThread_Impl.cpp" />
|
||||||
<ClCompile Include="Utilities.cpp" />
|
<ClCompile Include="Utilities.cpp" />
|
||||||
|
@ -165,6 +169,10 @@
|
||||||
<ClInclude Include="Queue.h" />
|
<ClInclude Include="Queue.h" />
|
||||||
<ClInclude Include="Resource\OysterResource.h" />
|
<ClInclude Include="Resource\OysterResource.h" />
|
||||||
<ClInclude Include="Resource\OResource.h" />
|
<ClInclude Include="Resource\OResource.h" />
|
||||||
|
<ClInclude Include="Resource\ResourceManager.h">
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="ThreadSafeQueue.h" />
|
<ClInclude Include="ThreadSafeQueue.h" />
|
||||||
<ClInclude Include="Thread\IThreadObject.h" />
|
<ClInclude Include="Thread\IThreadObject.h" />
|
||||||
<ClInclude Include="Thread\OysterMutex.h" />
|
<ClInclude Include="Thread\OysterMutex.h" />
|
||||||
|
|
|
@ -45,6 +45,9 @@
|
||||||
<ClCompile Include="Thread\OysterThread_Impl.cpp">
|
<ClCompile Include="Thread\OysterThread_Impl.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Resource\ResourceManager.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Utilities.h">
|
<ClInclude Include="Utilities.h">
|
||||||
|
@ -104,5 +107,8 @@
|
||||||
<ClInclude Include="Queue.h">
|
<ClInclude Include="Queue.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Resource\ResourceManager.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -101,7 +101,7 @@ using namespace Utility::DynamicMemory;
|
||||||
else
|
else
|
||||||
this->threadData->state = OYSTER_THREAD_STATE_IDLE;
|
this->threadData->state = OYSTER_THREAD_STATE_IDLE;
|
||||||
threadData->ownerObj = worker;
|
threadData->ownerObj = worker;
|
||||||
threadData->prio = OYSTER_THREAD_PRIORITY_3;
|
threadData->prio = OYSTER_THREAD_PRIORITY_2;
|
||||||
|
|
||||||
workerThread = std::thread(fnc, this->threadData);
|
workerThread = std::thread(fnc, this->threadData);
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,7 @@ struct ClientDataContainer
|
||||||
};
|
};
|
||||||
unsigned int ClientDataContainer::currID = 0;
|
unsigned int ClientDataContainer::currID = 0;
|
||||||
|
|
||||||
|
|
||||||
struct NetworkClient::PrivateData : public IThreadObject
|
struct NetworkClient::PrivateData : public IThreadObject
|
||||||
{
|
{
|
||||||
Utility::DynamicMemory::SmartPointer<ClientDataContainer> data;
|
Utility::DynamicMemory::SmartPointer<ClientDataContainer> data;
|
||||||
|
@ -92,6 +93,7 @@ struct NetworkClient::PrivateData : public IThreadObject
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Send(CustomNetProtocol* protocol)
|
void Send(CustomNetProtocol* protocol)
|
||||||
{
|
{
|
||||||
if(!data) return;
|
if(!data) return;
|
||||||
|
@ -175,12 +177,14 @@ struct NetworkClient::PrivateData : public IThreadObject
|
||||||
NetworkClient::NetworkClient()
|
NetworkClient::NetworkClient()
|
||||||
{
|
{
|
||||||
privateData = new PrivateData();
|
privateData = new PrivateData();
|
||||||
|
this->privateData->data->thread.SetPriority(Oyster::Thread::OYSTER_THREAD_PRIORITY_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkClient::NetworkClient(unsigned int socket)
|
NetworkClient::NetworkClient(unsigned int socket)
|
||||||
{
|
{
|
||||||
privateData = new PrivateData(socket);
|
privateData = new PrivateData(socket);
|
||||||
this->privateData->data->thread.Create(this->privateData, true);
|
this->privateData->data->thread.Create(this->privateData, true);
|
||||||
|
this->privateData->data->thread.SetPriority(Oyster::Thread::OYSTER_THREAD_PRIORITY_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkClient::NetworkClient(RecieverObject recvObj, NetworkProtocolCallbackType type)
|
NetworkClient::NetworkClient(RecieverObject recvObj, NetworkProtocolCallbackType type)
|
||||||
|
@ -196,6 +200,7 @@ NetworkClient::NetworkClient(RecieverObject recvObj, NetworkProtocolCallbackType
|
||||||
this->privateData->data->callbackType = type;
|
this->privateData->data->callbackType = type;
|
||||||
this->privateData->data->recvObj = recvObj;
|
this->privateData->data->recvObj = recvObj;
|
||||||
this->privateData->data->thread.Create(this->privateData, true);
|
this->privateData->data->thread.Create(this->privateData, true);
|
||||||
|
this->privateData->data->thread.SetPriority(Oyster::Thread::OYSTER_THREAD_PRIORITY_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkClient::NetworkClient(const NetworkClient& obj)
|
NetworkClient::NetworkClient(const NetworkClient& obj)
|
||||||
|
|
Loading…
Reference in New Issue