Merge branch 'GameServer' of https://github.com/dean11/Danbias into GameLogic

This commit is contained in:
dean11 2014-02-20 16:12:33 +01:00
commit 8583e40d2f
6 changed files with 78 additions and 14 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<ShowAllFiles>false</ShowAllFiles> <ShowAllFiles>true</ShowAllFiles>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>

View File

@ -190,6 +190,7 @@ bool GameState::Render()
if( dynamicObject->second ) if( dynamicObject->second )
{ {
dynamicObject->second->Render(); dynamicObject->second->Render();
} }
} }
@ -515,7 +516,8 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
this->privData->player.updateRBWorld(); this->privData->player.updateRBWorld();
// !RB DEBUG // !RB DEBUG
} }
else
{
C_DynamicObj *object = (*this->privData->dynamicObjects)[decoded.object_ID]; C_DynamicObj *object = (*this->privData->dynamicObjects)[decoded.object_ID];
if( object ) if( object )
@ -530,6 +532,7 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
// !RB DEBUG // !RB DEBUG
} }
} }
}
return GameClientState::event_processed; return GameClientState::event_processed;
case protocol_Gameplay_ObjectEnabled: break; /** @todo TODO: implement */ case protocol_Gameplay_ObjectEnabled: break; /** @todo TODO: implement */
case protocol_Gameplay_ObjectDisabled: case protocol_Gameplay_ObjectDisabled:
@ -586,6 +589,18 @@ 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: break; /** @todo TODO: implement */ case protocol_Gameplay_ObjectRespawn: break; /** @todo TODO: implement */
case protocol_Gameplay_ObjectDie: 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; default: break;
} }
} }

View File

@ -106,6 +106,8 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float
args.pushForce = pushForce; args.pushForce = pushForce;
Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction); 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; args.pushForce = -pushForce;
Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction); Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction);
if(hitCone) delete hitCone;
} }
void AttatchmentMassDriver::PickUpObject(const WEAPON_FIRE &usage, float dt) 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); Oyster::Physics::API::Instance().ApplyEffect(hitSphere,this,AttemptPickUp);
delete hitSphere; if(hitSphere) delete hitSphere;
} }

View File

@ -892,6 +892,38 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol; 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 #endif // !GAMELOGIC_PLAYER_PROTOCOLS_H

View File

@ -69,6 +69,8 @@
#define protocol_Gameplay_ObjectWeaponEnergy 364 #define protocol_Gameplay_ObjectWeaponEnergy 364
#define protocol_Gameplay_ObjectRespawn 365 #define protocol_Gameplay_ObjectRespawn 365
#define protocol_Gameplay_ObjectDie 366 #define protocol_Gameplay_ObjectDie 366
//Disconnect
#define protocol_Gameplay_ObjectDisconnectPlayer 367
#define protocol_GameplayMAX 399 #define protocol_GameplayMAX 399

View File

@ -61,8 +61,19 @@ using namespace DanBias;
switch (e.args.type) switch (e.args.type)
{ {
case NetworkClient::ClientEventArgs::EventType_Disconnect: 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()); 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;