Merge remote-tracking branch 'origin/GameClient' into GameLogic
This commit is contained in:
commit
4360519be7
|
@ -103,7 +103,6 @@ namespace DanBias
|
||||||
float dt = (float)data.timer.getElapsedSeconds();
|
float dt = (float)data.timer.getElapsedSeconds();
|
||||||
data.timer.reset();
|
data.timer.reset();
|
||||||
|
|
||||||
Graphics::API::Update( dt );
|
|
||||||
|
|
||||||
data.capFrame += dt;
|
data.capFrame += dt;
|
||||||
if(data.capFrame > 0.03f)
|
if(data.capFrame > 0.03f)
|
||||||
|
@ -115,6 +114,8 @@ namespace DanBias
|
||||||
case Result_error: return DanBiasClientReturn_Error;
|
case Result_error: return DanBiasClientReturn_Error;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Graphics::API::Update( data.capFrame );
|
||||||
if(Render() != S_OK)
|
if(Render() != S_OK)
|
||||||
return DanBiasClientReturn_Error;
|
return DanBiasClientReturn_Error;
|
||||||
data.capFrame -= 0.03f;
|
data.capFrame -= 0.03f;
|
||||||
|
|
|
@ -33,7 +33,8 @@ struct GameState::MyData
|
||||||
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_DynamicObj>> *dynamicObjects;
|
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_DynamicObj>> *dynamicObjects;
|
||||||
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_Light>> *lights;
|
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_Light>> *lights;
|
||||||
|
|
||||||
C_Player player;
|
//C_Player player;
|
||||||
|
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_Player>> players;
|
||||||
Camera_FPSV2 camera;
|
Camera_FPSV2 camera;
|
||||||
|
|
||||||
int myId;
|
int myId;
|
||||||
|
@ -75,7 +76,7 @@ bool GameState::Init( SharedStateContent &shared )
|
||||||
this->privData->camera.SetPerspectiveProjection( Utility::Value::Radian(90.0f), aspectRatio, 0.1f, 1000.0f );
|
this->privData->camera.SetPerspectiveProjection( Utility::Value::Radian(90.0f), aspectRatio, 0.1f, 1000.0f );
|
||||||
Graphics::API::SetProjection( this->privData->camera.GetProjectionMatrix() );
|
Graphics::API::SetProjection( this->privData->camera.GetProjectionMatrix() );
|
||||||
gfxOp.AmbientValue = 0.5f;
|
gfxOp.AmbientValue = 0.5f;
|
||||||
gfxOp.GlobalGlowTint = Math::Float3(2,1,1);
|
gfxOp.GlobalGlowTint = Math::Float3(1,1,1);
|
||||||
gfxOp.GlobalTint = Math::Float3(1,1,1);
|
gfxOp.GlobalTint = Math::Float3(1,1,1);
|
||||||
Graphics::API::SetOptions(gfxOp);
|
Graphics::API::SetOptions(gfxOp);
|
||||||
|
|
||||||
|
@ -123,37 +124,30 @@ void GameState::InitiatePlayer( int id, const std::string &modelName, const floa
|
||||||
RBData.scale = scale;
|
RBData.scale = scale;
|
||||||
RBData.type = RB_Type_Cube;
|
RBData.type = RB_Type_Cube;
|
||||||
// !RB DEBUG
|
// !RB DEBUG
|
||||||
if( isMyPlayer )
|
C_Player *p = new C_Player();
|
||||||
|
if( p->Init(modelData) )
|
||||||
{
|
{
|
||||||
if( this->privData->player.Init(modelData) )
|
// RB DEBUG
|
||||||
{
|
p->InitRB( RBData );
|
||||||
// RB DEBUG
|
// !RB DEBUG
|
||||||
this->privData->player.InitRB( RBData );
|
// start with runing animation
|
||||||
// !RB DEBUG
|
p->playAnimation( L"run_forwards", true );
|
||||||
|
|
||||||
|
(this->privData->players)[id] = p;
|
||||||
|
|
||||||
|
if( isMyPlayer )
|
||||||
|
{
|
||||||
this->privData->myId = id;
|
this->privData->myId = id;
|
||||||
this->privData->camera.SetPosition( this->privData->player.getPos() );
|
this->privData->camera.SetPosition( p->getPos() );
|
||||||
Float3 offset = Float3( 0.0f );
|
Float3 offset = Float3( 0.0f );
|
||||||
// DEBUG position of camera so we can see the player model
|
// DEBUG position of camera so we can see the player model
|
||||||
//offset.y = this->privData->player.getScale().y * 5.0f;
|
//offset.y = p->getScale().y * 5.0f;
|
||||||
//offset.z = this->privData->player.getScale().z * -5.0f;
|
//offset.z = p->getScale().z * -5.0f;
|
||||||
// !DEBUG
|
// !DEBUG
|
||||||
this->privData->camera.SetHeadOffset( offset );
|
this->privData->camera.SetHeadOffset( offset );
|
||||||
this->privData->camera.UpdateOrientation();
|
this->privData->camera.UpdateOrientation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
C_DynamicObj *p = new C_DynamicObj();
|
|
||||||
if( p->Init(modelData) )
|
|
||||||
{
|
|
||||||
// RB DEBUG
|
|
||||||
this->privData->player.InitRB( RBData );
|
|
||||||
// !RB DEBUG
|
|
||||||
|
|
||||||
(*this->privData->dynamicObjects)[id] = p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameClientState::ClientState GameState::Update( float deltaTime )
|
GameClientState::ClientState GameState::Update( float deltaTime )
|
||||||
|
@ -187,7 +181,17 @@ bool GameState::Render()
|
||||||
Oyster::Graphics::API::NewFrame();
|
Oyster::Graphics::API::NewFrame();
|
||||||
|
|
||||||
// for debugging to be replaced with render weapon
|
// for debugging to be replaced with render weapon
|
||||||
this->privData->player.Render();
|
auto playerObject = this->privData->players.begin();
|
||||||
|
for( ; playerObject != this->privData->players.end(); ++playerObject )
|
||||||
|
{
|
||||||
|
if(playerObject->second)
|
||||||
|
{
|
||||||
|
if( this->privData->myId != playerObject->second->GetId() )
|
||||||
|
{
|
||||||
|
playerObject->second->Render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto staticObject = this->privData->staticObjects->begin();
|
auto staticObject = this->privData->staticObjects->begin();
|
||||||
for( ; staticObject != this->privData->staticObjects->end(); ++staticObject )
|
for( ; staticObject != this->privData->staticObjects->end(); ++staticObject )
|
||||||
|
@ -211,11 +215,18 @@ bool GameState::Render()
|
||||||
{
|
{
|
||||||
Oyster::Graphics::API::StartRenderWireFrame();
|
Oyster::Graphics::API::StartRenderWireFrame();
|
||||||
|
|
||||||
Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(Float3( 0,132, 20));
|
playerObject = this->privData->players.begin();
|
||||||
Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(Float3( 0.5f, 0.5f, 0.5f));
|
for( ; playerObject != this->privData->players.end(); ++playerObject )
|
||||||
Oyster::Math3D::Float4x4 world = translation * scale;
|
{
|
||||||
Oyster::Graphics::API::RenderDebugCube( world );
|
if( playerObject->second->getBRtype() == RB_Type_Cube)
|
||||||
Oyster::Graphics::API::RenderDebugCube(this->privData->player.getRBWorld());
|
{
|
||||||
|
Oyster::Graphics::API::RenderDebugCube( playerObject->second->getRBWorld());
|
||||||
|
}
|
||||||
|
if( playerObject->second->getBRtype() == RB_Type_Sphere)
|
||||||
|
{
|
||||||
|
Oyster::Graphics::API::RenderDebugSphere( playerObject->second->getRBWorld());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
staticObject = this->privData->staticObjects->begin();
|
staticObject = this->privData->staticObjects->begin();
|
||||||
for( ; staticObject != this->privData->staticObjects->end(); ++staticObject )
|
for( ; staticObject != this->privData->staticObjects->end(); ++staticObject )
|
||||||
|
@ -276,6 +287,12 @@ bool GameState::Release()
|
||||||
Graphics::API::Option o = Graphics::API::GetOption();
|
Graphics::API::Option o = Graphics::API::GetOption();
|
||||||
if( privData )
|
if( privData )
|
||||||
{
|
{
|
||||||
|
auto playerObject = this->privData->players.begin();
|
||||||
|
for( ; playerObject != this->privData->players.end(); ++playerObject )
|
||||||
|
{
|
||||||
|
playerObject->second = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
auto staticObject = this->privData->staticObjects->begin();
|
auto staticObject = this->privData->staticObjects->begin();
|
||||||
for( ; staticObject != this->privData->staticObjects->end(); ++staticObject )
|
for( ; staticObject != this->privData->staticObjects->end(); ++staticObject )
|
||||||
{
|
{
|
||||||
|
@ -381,6 +398,7 @@ void GameState::ReadKeyInput()
|
||||||
this->key_showStats = false;
|
this->key_showStats = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState::NetEvent &message )
|
const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState::NetEvent &message )
|
||||||
{
|
{
|
||||||
if( message.args.type == NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend )
|
if( message.args.type == NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend )
|
||||||
|
@ -459,42 +477,29 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
||||||
Protocol_ObjectPositionRotation decoded(data);
|
Protocol_ObjectPositionRotation decoded(data);
|
||||||
Float3 position = decoded.position;
|
Float3 position = decoded.position;
|
||||||
Quaternion rotation = Quaternion( Float3(decoded.rotationQ), decoded.rotationQ[3] );
|
Quaternion rotation = Quaternion( Float3(decoded.rotationQ), decoded.rotationQ[3] );
|
||||||
|
C_Object *object;
|
||||||
// if is this player. Remember to change camera
|
object = (this->privData->players)[decoded.object_ID];
|
||||||
if( this->privData->myId == decoded.object_ID )
|
if( !object)
|
||||||
{
|
{
|
||||||
if( !Within(position.Dot(position), 2500.0f, 90000.0f) )
|
// if it is not a player
|
||||||
{ // HACK: bug trap
|
object = (*this->privData->dynamicObjects)[decoded.object_ID];
|
||||||
const char *breakPoint = "Something is wrong.";
|
|
||||||
position = Float3( 0.0f, 160.0f, 0.0f );
|
|
||||||
}
|
|
||||||
|
|
||||||
this->privData->camera.SetPosition( position );
|
|
||||||
this->privData->camera.SetRotation( rotation );
|
|
||||||
this->privData->player.setPos( position );
|
|
||||||
this->privData->player.setRot( rotation );
|
|
||||||
this->privData->player.updateWorld();
|
|
||||||
// RB DEBUG
|
|
||||||
this->privData->player.setRBPos ( position );
|
|
||||||
this->privData->player.setRBRot ( rotation );
|
|
||||||
this->privData->player.updateRBWorld();
|
|
||||||
// !RB DEBUG
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
C_DynamicObj *object = (*this->privData->dynamicObjects)[decoded.object_ID];
|
|
||||||
|
|
||||||
if( object )
|
if( object )
|
||||||
|
{
|
||||||
|
if( this->privData->myId == decoded.object_ID )
|
||||||
{
|
{
|
||||||
object->setPos( position );
|
this->privData->camera.SetPosition( position );
|
||||||
object->setRot( rotation );
|
this->privData->camera.SetRotation( rotation );
|
||||||
object->updateWorld();
|
|
||||||
// RB DEBUG
|
|
||||||
object->setRBPos ( position );
|
|
||||||
object->setRBRot ( rotation );
|
|
||||||
object->updateRBWorld();
|
|
||||||
// !RB DEBUG
|
|
||||||
}
|
}
|
||||||
|
object->setPos( position );
|
||||||
|
object->setRot( rotation );
|
||||||
|
object->updateWorld();
|
||||||
|
// RB DEBUG
|
||||||
|
object->setRBPos ( position );
|
||||||
|
object->setRBRot ( rotation );
|
||||||
|
object->updateRBWorld();
|
||||||
|
// !RB DEBUG
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return GameClientState::event_processed;
|
return GameClientState::event_processed;
|
||||||
|
@ -534,7 +539,7 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
||||||
RBData.rotation = ArrayToQuaternion( decoded.position );
|
RBData.rotation = ArrayToQuaternion( decoded.position );
|
||||||
RBData.scale = Float3( decoded.scale );
|
RBData.scale = Float3( decoded.scale );
|
||||||
|
|
||||||
this->privData->player.InitRB( RBData );
|
object->InitRB( RBData );
|
||||||
// !RB DEBUG
|
// !RB DEBUG
|
||||||
|
|
||||||
(*this->privData->dynamicObjects)[decoded.object_ID] = object;
|
(*this->privData->dynamicObjects)[decoded.object_ID] = object;
|
||||||
|
@ -553,17 +558,29 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
|
||||||
case protocol_Gameplay_ObjectWeaponEnergy: break; /** @todo TODO: implement */
|
case protocol_Gameplay_ObjectWeaponEnergy: break; /** @todo TODO: implement */
|
||||||
case protocol_Gameplay_ObjectRespawn:
|
case protocol_Gameplay_ObjectRespawn:
|
||||||
{
|
{
|
||||||
// set player pos
|
|
||||||
Protocol_ObjectRespawn decoded(data);
|
Protocol_ObjectRespawn decoded(data);
|
||||||
// move player. Remember to change camera
|
|
||||||
this->privData->camera.SetPosition( decoded.position );
|
|
||||||
this->privData->player.setPos( decoded.position );
|
|
||||||
this->privData->player.updateWorld();
|
|
||||||
// RB DEBUG
|
|
||||||
this->privData->player.setRBPos ( decoded.position );
|
|
||||||
this->privData->player.updateRBWorld();
|
|
||||||
// !RB DEBUG
|
|
||||||
|
|
||||||
|
C_Object *object;
|
||||||
|
object = (this->privData->players)[decoded.objectID];
|
||||||
|
if( !object)
|
||||||
|
{
|
||||||
|
// if it is not a player
|
||||||
|
object = (*this->privData->dynamicObjects)[decoded.objectID];
|
||||||
|
}
|
||||||
|
|
||||||
|
if( object )
|
||||||
|
{
|
||||||
|
if( this->privData->myId == decoded.objectID )
|
||||||
|
{
|
||||||
|
this->privData->camera.SetPosition( decoded.position );
|
||||||
|
}
|
||||||
|
object->setPos( decoded.position );
|
||||||
|
object->updateWorld();
|
||||||
|
// RB DEBUG
|
||||||
|
object->setRBPos ( decoded.position );
|
||||||
|
object->updateRBWorld();
|
||||||
|
// !RB DEBUG
|
||||||
|
}
|
||||||
this->currGameUI = this->gameUI;
|
this->currGameUI = this->gameUI;
|
||||||
}
|
}
|
||||||
return GameClientState::event_processed;
|
return GameClientState::event_processed;
|
||||||
|
|
|
@ -813,39 +813,48 @@ namespace GameLogic
|
||||||
//#define protocol_Gameplay_ObjectRespawn 365
|
//#define protocol_Gameplay_ObjectRespawn 365
|
||||||
struct Protocol_ObjectRespawn :public Oyster::Network::CustomProtocolObject
|
struct Protocol_ObjectRespawn :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
|
int objectID;
|
||||||
float position[3];
|
float position[3];
|
||||||
|
|
||||||
Protocol_ObjectRespawn()
|
Protocol_ObjectRespawn()
|
||||||
{
|
{
|
||||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||||
this->protocol[0].value.netShort = protocol_Gameplay_ObjectRespawn;
|
this->protocol[0].value.netShort = protocol_Gameplay_ObjectRespawn;
|
||||||
|
// ID
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||||
|
// POSITION
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
this->objectID = 0;
|
||||||
memset(&this->position[0], 0, sizeof(float) * 3);
|
memset(&this->position[0], 0, sizeof(float) * 3);
|
||||||
}
|
}
|
||||||
Protocol_ObjectRespawn(float position[3])
|
Protocol_ObjectRespawn(int id, float position[3])
|
||||||
{
|
{
|
||||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||||
this->protocol[0].value.netShort = protocol_Gameplay_ObjectRespawn;
|
this->protocol[0].value.netShort = protocol_Gameplay_ObjectRespawn;
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
|
// ID
|
||||||
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||||
|
// POSITION
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
this->objectID = id;
|
||||||
memcpy(&this->position[0], &position[0], sizeof(float) * 3);
|
memcpy(&this->position[0], &position[0], sizeof(float) * 3);
|
||||||
}
|
}
|
||||||
Protocol_ObjectRespawn(Oyster::Network::CustomNetProtocol& p)
|
Protocol_ObjectRespawn(Oyster::Network::CustomNetProtocol& p)
|
||||||
{
|
{
|
||||||
this->position[0] = p[1].value.netFloat;
|
this->objectID = p[1].value.netInt;
|
||||||
this->position[1] = p[2].value.netFloat;
|
this->position[0] = p[2].value.netFloat;
|
||||||
this->position[2] = p[3].value.netFloat;
|
this->position[1] = p[3].value.netFloat;
|
||||||
|
this->position[2] = p[4].value.netFloat;
|
||||||
}
|
}
|
||||||
Oyster::Network::CustomNetProtocol GetProtocol() override
|
Oyster::Network::CustomNetProtocol GetProtocol() override
|
||||||
{
|
{
|
||||||
this->protocol[1].value = this->position[0];
|
this->protocol[1].value = this->objectID;
|
||||||
this->protocol[2].value = this->position[1];
|
this->protocol[2].value = this->position[0];
|
||||||
this->protocol[3].value = this->position[2];
|
this->protocol[3].value = this->position[1];
|
||||||
|
this->protocol[4].value = this->position[2];
|
||||||
return protocol;
|
return protocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ GameClient::GameClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::Net
|
||||||
this->client = nwClient;
|
this->client = nwClient;
|
||||||
this->player = 0;
|
this->player = 0;
|
||||||
isReady = false;
|
isReady = false;
|
||||||
this->character = L"crate_colonists.dan";
|
this->character = L"char_orca.dan";
|
||||||
this->alias = L"Unknown";
|
this->alias = L"Unknown";
|
||||||
this->secondsSinceLastResponse = 0.0f;
|
this->secondsSinceLastResponse = 0.0f;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ GameClient::~GameClient()
|
||||||
this->player->Inactivate();
|
this->player->Inactivate();
|
||||||
|
|
||||||
this->isReady = false;
|
this->isReady = false;
|
||||||
this->character = L"crate_colonists.dan";
|
this->character = L"char_orca.dan";
|
||||||
this->alias = L"Unknown";
|
this->alias = L"Unknown";
|
||||||
this->secondsSinceLastResponse = 0.0f;
|
this->secondsSinceLastResponse = 0.0f;
|
||||||
this->client = 0;
|
this->client = 0;
|
||||||
|
|
|
@ -62,31 +62,24 @@ using namespace DanBias;
|
||||||
{
|
{
|
||||||
case NetworkClient::ClientEventArgs::EventType_Disconnect:
|
case NetworkClient::ClientEventArgs::EventType_Disconnect:
|
||||||
{
|
{
|
||||||
printf("\t(%i : %s) - EventType_Disconnect\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str());
|
//Send disconnect message to all the other players so the player can be removed from the client.
|
||||||
Protocol_ObjectDisconnectPlayer prot(this->gClients[temp]->GetPlayer()->GetID());
|
Protocol_ObjectDisconnectPlayer dp(cl->GetClient()->GetID());
|
||||||
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
for(int i = 0; i < this->gClients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(i != temp && this->gClients[i]) this->gClients[i]->GetClient()->Send(prot);
|
if(this->gClients[i] && this->gClients[i] != cl)
|
||||||
|
{
|
||||||
|
this->gClients[i]->GetClient()->Send(dp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
printf("\t(%i : %s) - EventType_Disconnect\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str());
|
||||||
this->gClients[temp]->Invalidate();
|
this->gClients[temp]->Invalidate();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToRecieve:
|
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToRecieve:
|
||||||
break;
|
break;
|
||||||
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend:
|
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend:
|
||||||
{
|
|
||||||
if(this->gClients[temp]->IncrementFailedProtocol() >= 5/*client->threshold*/)
|
if(this->gClients[temp]->IncrementFailedProtocol() >= 5/*client->threshold*/)
|
||||||
{
|
|
||||||
printf("\t(%i : %s) - EventType_Disconnect\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str());
|
|
||||||
Protocol_ObjectDisconnectPlayer prot(this->gClients[temp]->GetPlayer()->GetID());
|
|
||||||
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
|
||||||
{
|
|
||||||
if(i != temp && this->gClients[i]) this->gClients[i]->GetClient()->Send(prot);
|
|
||||||
}
|
|
||||||
this->gClients[temp]->Invalidate();
|
this->gClients[temp]->Invalidate();
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case NetworkClient::ClientEventArgs::EventType_ProtocolRecieved:
|
case NetworkClient::ClientEventArgs::EventType_ProtocolRecieved:
|
||||||
this->ParseProtocol(e.args.data.protocol, cl);
|
this->ParseProtocol(e.args.data.protocol, cl);
|
||||||
|
@ -150,9 +143,6 @@ using namespace DanBias;
|
||||||
|
|
||||||
Oyster::Math::Float3 temp = movedObject->GetPosition();
|
Oyster::Math::Float3 temp = movedObject->GetPosition();
|
||||||
|
|
||||||
if(temp.x < -300)
|
|
||||||
id = 0;
|
|
||||||
|
|
||||||
GameSession::gameSession->Send(p.GetProtocol());
|
GameSession::gameSession->Send(p.GetProtocol());
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
@ -231,7 +221,7 @@ using namespace DanBias;
|
||||||
void GameSession::Gameplay_PlayerLeftTurn ( Protocol_PlayerLeftTurn& p, DanBias::GameClient* c )
|
void GameSession::Gameplay_PlayerLeftTurn ( Protocol_PlayerLeftTurn& p, DanBias::GameClient* c )
|
||||||
{
|
{
|
||||||
c->GetPlayer()->TurnLeft( p.deltaRadian );
|
c->GetPlayer()->TurnLeft( p.deltaRadian );
|
||||||
c->GetPlayer()->SetLookDir(p.lookdir);
|
c->GetPlayer()->SetLookDir( p.lookdir ) ;
|
||||||
}
|
}
|
||||||
void GameSession::Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c )
|
void GameSession::Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c )
|
||||||
{
|
{
|
||||||
|
@ -275,17 +265,10 @@ using namespace DanBias;
|
||||||
switch (p.status)
|
switch (p.status)
|
||||||
{
|
{
|
||||||
case GameLogic::Protocol_General_Status::States_disconected:
|
case GameLogic::Protocol_General_Status::States_disconected:
|
||||||
{
|
|
||||||
printf("Client with ID [%i] dissconnected\n", c->GetClient()->GetID());
|
printf("Client with ID [%i] dissconnected\n", c->GetClient()->GetID());
|
||||||
|
//TODO: Tell other clients
|
||||||
Protocol_ObjectDisconnectPlayer prot(c->GetPlayer()->GetID());
|
//Protocol_
|
||||||
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
|
||||||
{
|
|
||||||
if( this->gClients[i] && c->GetClient()->GetID() != this->gClients[i]->GetClient()->GetID() ) this->gClients[i]->GetClient()->Send(prot);
|
|
||||||
}
|
|
||||||
c->Invalidate();
|
|
||||||
this->Detach(c->GetClient()->GetID());
|
this->Detach(c->GetClient()->GetID());
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GameLogic::Protocol_General_Status::States_idle:
|
case GameLogic::Protocol_General_Status::States_idle:
|
||||||
|
|
|
@ -437,6 +437,38 @@ int ResourceManager::GetResourceId(const wchar_t c[])
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
int ResourceManager::GetResourceCount(const wchar_t filename[])
|
||||||
|
{
|
||||||
|
ResourceData *t = FindResource(this->resources, filename);
|
||||||
|
|
||||||
|
if(t) return t->referenceCount;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int ResourceManager::GetResourceCount(const HRESOURCE& resource)
|
||||||
|
{
|
||||||
|
ResourceData *t = FindResource(this->resources, resource);
|
||||||
|
|
||||||
|
if(t) return t->referenceCount;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int ResourceManager::GetResourceSize(const wchar_t filename[])
|
||||||
|
{
|
||||||
|
ResourceData *t = FindResource(this->resources, filename);
|
||||||
|
|
||||||
|
if(t) return t->resourceSize;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int ResourceManager::GetResourceSize(const HRESOURCE& resource)
|
||||||
|
{
|
||||||
|
ResourceData *t = FindResource(this->resources, resource);
|
||||||
|
|
||||||
|
if(t) return t->resourceSize;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -148,6 +148,14 @@ namespace Oyster
|
||||||
* @return Returns the accociated ID
|
* @return Returns the accociated ID
|
||||||
*/
|
*/
|
||||||
int GetResourceId(const wchar_t filename[]);
|
int GetResourceId(const wchar_t filename[]);
|
||||||
|
|
||||||
|
int GetResourceCount(const wchar_t filename[]);
|
||||||
|
|
||||||
|
int GetResourceCount(const HRESOURCE& resource);
|
||||||
|
|
||||||
|
int GetResourceSize(const wchar_t filename[]);
|
||||||
|
|
||||||
|
int GetResourceSize(const HRESOURCE& resource);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ResourceManager(const ResourceManager& obj);
|
ResourceManager(const ResourceManager& obj);
|
||||||
|
|
|
@ -44,6 +44,7 @@ namespace Utility
|
||||||
ReferenceCount() :count(0) { }
|
ReferenceCount() :count(0) { }
|
||||||
ReferenceCount(const ReferenceCount& o) { count = o.count; }
|
ReferenceCount(const ReferenceCount& o) { count = o.count; }
|
||||||
inline const ReferenceCount& operator=(const ReferenceCount& o) { count = o.count; return *this;}
|
inline const ReferenceCount& operator=(const ReferenceCount& o) { count = o.count; return *this;}
|
||||||
|
operator int() { return this->count; }
|
||||||
inline void Incref() { this->count++; }
|
inline void Incref() { this->count++; }
|
||||||
inline void Incref(int c) { this->count += c; }
|
inline void Incref(int c) { this->count += c; }
|
||||||
inline int Decref() { return --this->count;}
|
inline int Decref() { return --this->count;}
|
||||||
|
|
|
@ -90,6 +90,13 @@ namespace Oyster
|
||||||
Math::Float3 GlowTint;
|
Math::Float3 GlowTint;
|
||||||
Math::Float PAD2;
|
Math::Float PAD2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct RenderInstanceData
|
||||||
|
{
|
||||||
|
Math::Matrix WV;
|
||||||
|
Math::Matrix WVP;
|
||||||
|
TintData td;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -19,6 +19,7 @@ namespace Oyster
|
||||||
Math::Float4x4 Projection;
|
Math::Float4x4 Projection;
|
||||||
std::vector<Definitions::Pointlight> Lights;
|
std::vector<Definitions::Pointlight> Lights;
|
||||||
float deltaTime;
|
float deltaTime;
|
||||||
|
int MostModel;
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
Model::Model* cube;
|
Model::Model* cube;
|
||||||
Model::Model* sphere;
|
Model::Model* sphere;
|
||||||
|
@ -133,6 +134,16 @@ namespace Oyster
|
||||||
return API::Sucsess;
|
return API::Sucsess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void API::BeginLoadingModels()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void API::EndLoadingModels()
|
||||||
|
{
|
||||||
|
//TODO finalize instance buffers and create rendering map;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//returns null for invalid filenames
|
//returns null for invalid filenames
|
||||||
Model::Model* API::CreateModel(std::wstring filename)
|
Model::Model* API::CreateModel(std::wstring filename)
|
||||||
{
|
{
|
||||||
|
@ -153,6 +164,15 @@ namespace Oyster
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Core::loader.GetResourceCount(m->info) == 1)
|
||||||
|
{
|
||||||
|
Render::Resources::RenderData[m->info] = new Render::Resources::ModelDataWrapper();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Render::Resources::RenderData[m->info]->Models++;
|
||||||
|
}
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,10 @@ namespace Oyster
|
||||||
|
|
||||||
static State Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Option options);
|
static State Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Option options);
|
||||||
|
|
||||||
|
static void BeginLoadingModels();
|
||||||
|
|
||||||
|
static void EndLoadingModels();
|
||||||
|
|
||||||
static State ReloadShaders();
|
static State ReloadShaders();
|
||||||
|
|
||||||
//should be called after rendered normal models, before GUI or Text rendering
|
//should be called after rendered normal models, before GUI or Text rendering
|
||||||
|
|
|
@ -63,6 +63,8 @@ namespace Oyster
|
||||||
|
|
||||||
ID3D11ShaderResourceView* Resources::Gui::Text::Font = NULL;
|
ID3D11ShaderResourceView* Resources::Gui::Text::Font = NULL;
|
||||||
ID3D11DepthStencilView* Resources::Gui::depth = NULL;
|
ID3D11DepthStencilView* Resources::Gui::depth = NULL;
|
||||||
|
|
||||||
|
std::map<Model::ModelInfo*, Resources::ModelDataWrapper*> Resources::RenderData = std::map<Model::ModelInfo*, Resources::ModelDataWrapper*>();
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../Core/Core.h"
|
#include "../Core/Core.h"
|
||||||
|
#include "../Model/ModelInfo.h"
|
||||||
|
#include "../Definitions/GraphicalDefinition.h"
|
||||||
|
|
||||||
namespace Oyster
|
namespace Oyster
|
||||||
{
|
{
|
||||||
|
@ -11,6 +13,14 @@ namespace Oyster
|
||||||
class Resources
|
class Resources
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
struct ModelDataWrapper
|
||||||
|
{
|
||||||
|
Definitions::RenderInstanceData* rid;
|
||||||
|
int Models;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static std::map<Model::ModelInfo*, ModelDataWrapper*> RenderData;
|
||||||
|
|
||||||
static const int GBufferSize = 3;
|
static const int GBufferSize = 3;
|
||||||
static const int LBufferSize = 3;
|
static const int LBufferSize = 3;
|
||||||
|
|
Loading…
Reference in New Issue