diff --git a/Code/Game/GameClient/GameClient.vcxproj.user b/Code/Game/GameClient/GameClient.vcxproj.user index 4b847ee6..2e28d6f7 100644 --- a/Code/Game/GameClient/GameClient.vcxproj.user +++ b/Code/Game/GameClient/GameClient.vcxproj.user @@ -1,7 +1,7 @@  - false + true $(OutDir) diff --git a/Code/Game/GameClient/GameClientState/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp index bf436d65..b4aee882 100644 --- a/Code/Game/GameClient/GameClientState/GameState.cpp +++ b/Code/Game/GameClient/GameClientState/GameState.cpp @@ -190,6 +190,7 @@ bool GameState::Render() if( dynamicObject->second ) { dynamicObject->second->Render(); + } } @@ -515,19 +516,21 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState this->privData->player.updateRBWorld(); // !RB DEBUG } - - C_DynamicObj *object = (*this->privData->dynamicObjects)[decoded.object_ID]; - - if( object ) + else { - object->setPos( position ); - object->setRot( rotation ); - object->updateWorld(); - // RB DEBUG - object->setRBPos ( position ); - object->setRBRot ( rotation ); - object->updateRBWorld(); - // !RB DEBUG + C_DynamicObj *object = (*this->privData->dynamicObjects)[decoded.object_ID]; + + if( object ) + { + object->setPos( position ); + object->setRot( rotation ); + object->updateWorld(); + // RB DEBUG + object->setRBPos ( position ); + object->setRBRot ( rotation ); + object->updateRBWorld(); + // !RB DEBUG + } } } return GameClientState::event_processed; @@ -586,6 +589,18 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState case protocol_Gameplay_ObjectWeaponEnergy: break; /** @todo TODO: implement */ case protocol_Gameplay_ObjectRespawn: break; /** @todo TODO: implement */ case protocol_Gameplay_ObjectDie: break; /** @todo TODO: implement */ + case protocol_Gameplay_ObjectDisconnectPlayer: + { + //Removes + Protocol_ObjectDisconnectPlayer decoded(data); + auto object = this->privData->dynamicObjects->find( decoded.objectID ); + if( object != this->privData->dynamicObjects->end() ) + { + object->second = nullptr; + this->privData->dynamicObjects->erase( object ); + } + } + return GameClientState::event_processed; default: break; } } diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp index 3102b9f2..89de1f3e 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -106,6 +106,8 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float args.pushForce = pushForce; Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction); + + if(hitCone) delete hitCone; } /******************************************************** @@ -141,6 +143,8 @@ void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt) args.pushForce = -pushForce; Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction); + + if(hitCone) delete hitCone; } void AttatchmentMassDriver::PickUpObject(const WEAPON_FIRE &usage, float dt) @@ -150,5 +154,5 @@ void AttatchmentMassDriver::PickUpObject(const WEAPON_FIRE &usage, float dt) Oyster::Physics::API::Instance().ApplyEffect(hitSphere,this,AttemptPickUp); - delete hitSphere; + if(hitSphere) delete hitSphere; } diff --git a/Code/Game/GameProtocols/ObjectProtocols.h b/Code/Game/GameProtocols/ObjectProtocols.h index fc02a4bd..cae7c7f5 100644 --- a/Code/Game/GameProtocols/ObjectProtocols.h +++ b/Code/Game/GameProtocols/ObjectProtocols.h @@ -892,6 +892,38 @@ namespace GameLogic Oyster::Network::CustomNetProtocol protocol; }; + //#define protocol_Gameplay_ObjectDisconnectPlayer 367 + struct Protocol_ObjectDisconnectPlayer :public Oyster::Network::CustomProtocolObject + { + int objectID; + + Protocol_ObjectDisconnectPlayer() + { + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[0].value.netShort = protocol_Gameplay_ObjectDisconnectPlayer; + this->protocol[1].type = Oyster::Network::NetAttributeType_Int; + this->objectID = 0; + } + Protocol_ObjectDisconnectPlayer(int objectID) + { + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[0].value.netShort = protocol_Gameplay_ObjectDisconnectPlayer; + this->protocol[1].type = Oyster::Network::NetAttributeType_Int; + this->objectID = objectID; + } + Protocol_ObjectDisconnectPlayer(Oyster::Network::CustomNetProtocol& p) + { + this->objectID = p[1].value.netInt; + } + Oyster::Network::CustomNetProtocol GetProtocol() override + { + this->protocol[1].value = this->objectID; + return protocol; + } + + private: + Oyster::Network::CustomNetProtocol protocol; + }; } #endif // !GAMELOGIC_PLAYER_PROTOCOLS_H \ No newline at end of file diff --git a/Code/Game/GameProtocols/ProtocolIdentificationID.h b/Code/Game/GameProtocols/ProtocolIdentificationID.h index 4394a1a1..cb630012 100644 --- a/Code/Game/GameProtocols/ProtocolIdentificationID.h +++ b/Code/Game/GameProtocols/ProtocolIdentificationID.h @@ -69,6 +69,8 @@ #define protocol_Gameplay_ObjectWeaponEnergy 364 #define protocol_Gameplay_ObjectRespawn 365 #define protocol_Gameplay_ObjectDie 366 +//Disconnect +#define protocol_Gameplay_ObjectDisconnectPlayer 367 #define protocol_GameplayMAX 399 diff --git a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp index e2a2961d..0c52dfff 100644 --- a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp @@ -61,8 +61,19 @@ using namespace DanBias; switch (e.args.type) { case NetworkClient::ClientEventArgs::EventType_Disconnect: + { + //Send disconnect message to all the other players so the player can be removed from the client. + Protocol_ObjectDisconnectPlayer dp(cl->GetClient()->GetID()); + for(int i = 0; i < this->gClients.Size(); i++) + { + 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(); + } break; case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToRecieve: break;