Merge remote-tracking branch 'origin/GameServer' into GameClient

This commit is contained in:
Dander7BD 2014-02-19 13:44:55 +01:00
commit e585589d6e
4 changed files with 27 additions and 59 deletions

View File

@ -74,69 +74,40 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_PlayerLook :public Oyster::Network::CustomProtocolObject
//protocol_Gameplay_PlayerLeftTurn
struct Protocol_PlayerLeftTurn : public ::Oyster::Network::CustomProtocolObject
{
// can be swapped to a quaternion later
float lookDir[3];
float right[3];
Protocol_PlayerLook()
public:
float deltaRadian;
Protocol_PlayerLeftTurn()
{
this->protocol[0].value = protocol_Gameplay_PlayerLookDir;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
// LookDir
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
// Right
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
this->protocol[6].type = Oyster::Network::NetAttributeType_Float;
memset(&this->lookDir[0], 0, sizeof(float) * 3);
memset(&this->right[0], 0, sizeof(float) * 3);
this->protocol[0].value = protocol_Gameplay_PlayerLeftTurn;
this->protocol[0].type = ::Oyster::Network::NetAttributeType_Short;
// deltaRadian
this->protocol[1].type = ::Oyster::Network::NetAttributeType_Float;
}
Protocol_PlayerLook(Oyster::Network::CustomNetProtocol& p)
{
this->lookDir[0] = p[1].value.netFloat;
this->lookDir[1] = p[2].value.netFloat;
this->lookDir[2] = p[3].value.netFloat;
this->right[0] = p[4].value.netFloat;
this->right[1] = p[5].value.netFloat;
this->right[2] = p[6].value.netFloat;
Protocol_PlayerLeftTurn( const ::Oyster::Network::CustomNetProtocol &p )
{
this->deltaRadian = p[1].value.netFloat;
}
Protocol_PlayerLook(float l[3], float r[3])
Protocol_PlayerLeftTurn( float deltaRadian )
{
this->protocol[0].value = protocol_Gameplay_PlayerLookDir;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
this->protocol[6].type = Oyster::Network::NetAttributeType_Float;
memcpy(&this->lookDir[0], &l[0], sizeof(float) * 3);
memcpy(&this->right[0], &r[0], sizeof(float) * 3);
this->protocol[0].value = protocol_Gameplay_PlayerLeftTurn;
this->protocol[0].type = ::Oyster::Network::NetAttributeType_Short;
this->deltaRadian = deltaRadian;
}
Oyster::Network::CustomNetProtocol GetProtocol() override
::Oyster::Network::CustomNetProtocol GetProtocol() override
{
this->protocol[1].value = this->lookDir[0];
this->protocol[2].value = this->lookDir[1];
this->protocol[3].value = this->lookDir[2];
this->protocol[4].value = this->right[0];
this->protocol[5].value = this->right[1];
this->protocol[6].value = this->right[2];
this->protocol[1].value = this->deltaRadian;
return protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
private:
::Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_PlayerChangeWeapon :public Oyster::Network::CustomProtocolObject

View File

@ -47,7 +47,7 @@
#define protocol_Gameplay_PlayerMovementLeft 301
#define protocol_Gameplay_PlayerMovementForward 302
#define protocol_Gameplay_PlayerMovementBackward 303
#define protocol_Gameplay_PlayerLookDir 304
#define protocol_Gameplay_PlayerLeftTurn 304
#define protocol_Gameplay_PlayerChangeWeapon 305
#define protocol_Gameplay_PlayerShot 306
#define protocol_Gameplay_PlayerJump 307

View File

@ -84,7 +84,7 @@ namespace DanBias
void Gameplay_PlayerMovementBack ( DanBias::GameClient* c );
void Gameplay_PlayerMovementForth ( DanBias::GameClient* c );
void Gameplay_PlayerJump ( DanBias::GameClient* c );
void Gameplay_PlayerLookDir ( GameLogic::Protocol_PlayerLook& p, DanBias::GameClient* c );
void Gameplay_PlayerLeftTurn ( GameLogic::Protocol_PlayerLeftTurn& p, DanBias::GameClient* c );
void Gameplay_PlayerChangeWeapon ( GameLogic::Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c );
void Gameplay_PlayerShot ( GameLogic::Protocol_PlayerShot& p, DanBias::GameClient* c );
void Gameplay_ObjectPickup ( GameLogic::Protocol_ObjectPickup& p, DanBias::GameClient* c );

View File

@ -156,7 +156,7 @@ using namespace DanBias;
break;
case protocol_Gameplay_PlayerJump: this->Gameplay_PlayerJump ( c );
break;
case protocol_Gameplay_PlayerLookDir: this->Gameplay_PlayerLookDir ( Protocol_PlayerLook (p), c );
case protocol_Gameplay_PlayerLeftTurn: this->Gameplay_PlayerLeftTurn ( Protocol_PlayerLeftTurn (p), c );
break;
case protocol_Gameplay_PlayerChangeWeapon: this->Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon (p), c );
break;
@ -203,12 +203,9 @@ using namespace DanBias;
{
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_JUMP);
}
void GameSession::Gameplay_PlayerLookDir ( Protocol_PlayerLook& p, DanBias::GameClient* c )
void GameSession::Gameplay_PlayerLeftTurn ( Protocol_PlayerLeftTurn& p, DanBias::GameClient* c )
{
Oyster::Math3D::Float3 lookDir = p.lookDir;
Oyster::Math3D::Float3 right = p.right;
c->GetPlayer()->Rotate(lookDir, right);
c->GetPlayer()->TurnLeft( p.deltaRadian );
}
void GameSession::Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c )
{