diff --git a/Code/Game/GameClient/GameClientState/GamingUI.cpp b/Code/Game/GameClient/GameClientState/GamingUI.cpp index 97748ee5..821ba414 100644 --- a/Code/Game/GameClient/GameClientState/GamingUI.cpp +++ b/Code/Game/GameClient/GameClientState/GamingUI.cpp @@ -121,50 +121,50 @@ void GamingUI::ReadKeyInput() this->key_Jump = false; // shoot - if( this->sharedData->mouseDevice->IsBtnDown(::Input::Enum::SAMI_MouseLeftBtn) ) - { - if( !this->key_Shoot ) - { - Protocol_PlayerShot playerShot; - playerShot.primaryPressed = true; - playerShot.secondaryPressed = false; - playerShot.utilityPressed = false; - this->sharedData->network->Send( playerShot ); - this->key_Shoot = true; - } - } - else - this->key_Shoot = false; - - if( this->sharedData->mouseDevice->IsBtnDown(::Input::Enum::SAMI_MouseRightBtn) ) - { - if( !this->key_Shoot ) - { - Protocol_PlayerShot playerShot; - playerShot.primaryPressed = false; - playerShot.secondaryPressed = true; - playerShot.utilityPressed = false; - this->sharedData->network->Send( playerShot ); - this->key_Shoot = true; - } - } - else - this->key_Shoot = false; - - if( this->sharedData->mouseDevice->IsBtnDown(::Input::Enum::SAMI_MouseMiddleBtn) ) - { - if( !this->key_Shoot ) - { - Protocol_PlayerShot playerShot; - playerShot.primaryPressed = false; - playerShot.secondaryPressed = false; - playerShot.utilityPressed = true; - this->sharedData->network->Send( playerShot ); - this->key_Shoot = true; - } - } - else - this->key_Shoot = false; + //if( this->sharedData->mouseDevice->IsBtnDown(::Input::Enum::SAMI_MouseLeftBtn) ) + //{ + // if( !this->key_Shoot ) + // { + // Protocol_PlayerShot playerShot; + // playerShot.primaryPressed = true; + // playerShot.secondaryPressed = false; + // playerShot.utilityPressed = false; + // this->sharedData->network->Send( playerShot ); + // this->key_Shoot = true; + // } + //} + //else + // this->key_Shoot = false; + // + //if( this->sharedData->mouseDevice->IsBtnDown(::Input::Enum::SAMI_MouseRightBtn) ) + //{ + // if( !this->key_Shoot ) + // { + // Protocol_PlayerShot playerShot; + // playerShot.primaryPressed = false; + // playerShot.secondaryPressed = true; + // playerShot.utilityPressed = false; + // this->sharedData->network->Send( playerShot ); + // this->key_Shoot = true; + // } + //} + //else + // this->key_Shoot = false; + // + //if( this->sharedData->mouseDevice->IsBtnDown(::Input::Enum::SAMI_MouseMiddleBtn) ) + //{ + // if( !this->key_Shoot ) + // { + // Protocol_PlayerShot playerShot; + // playerShot.primaryPressed = false; + // playerShot.secondaryPressed = false; + // playerShot.utilityPressed = true; + // this->sharedData->network->Send( playerShot ); + // this->key_Shoot = true; + // } + //} + //else + // this->key_Shoot = false; if( this->sharedData->keyboardDevice->IsKeyDown(::Input::Enum::SAKI_Escape) ) { @@ -177,31 +177,13 @@ void GamingUI::OnMousePress ( Input::Enum::SAMI key, Input::Mouse* sender ) switch ( key ) { case ::Input::Enum::SAMI_MouseLeftBtn: // shoot - { - Protocol_PlayerShot playerShot; - playerShot.primaryPressed = true; - playerShot.secondaryPressed = false; - playerShot.utilityPressed = false; - this->sharedData->network->Send( playerShot ); - } + this->sharedData->network->Send( Protocol_PlayerShot(Protocol_PlayerShot::ShootValue_PrimaryPress) ); break; case ::Input::Enum::SAMI_MouseRightBtn: - { - Protocol_PlayerShot playerShot; - playerShot.primaryPressed = false; - playerShot.secondaryPressed = true; - playerShot.utilityPressed = false; - this->sharedData->network->Send( playerShot ); - } + this->sharedData->network->Send( Protocol_PlayerShot(Protocol_PlayerShot::ShootValue_SecondaryPress) ); break; - case ::Input::Enum::SAMI_MouseMiddleBtn: - { - Protocol_PlayerShot playerShot; - playerShot.primaryPressed = false; - playerShot.secondaryPressed = false; - playerShot.utilityPressed = true; - this->sharedData->network->Send( playerShot ); - } + case ::Input::Enum::SAMI_MouseMiddleBtn: + this->sharedData->network->Send( Protocol_PlayerShot(Protocol_PlayerShot::ShootValue_UtilityPress) ); break; } } @@ -209,14 +191,14 @@ void GamingUI::OnMouseRelease ( Input::Enum::SAMI key, Input::Mouse* sender ) { switch ( key ) { + case ::Input::Enum::SAMI_MouseLeftBtn: // shoot + this->sharedData->network->Send( Protocol_PlayerShot(Protocol_PlayerShot::ShootValue_PrimaryRelease) ); + break; case ::Input::Enum::SAMI_MouseRightBtn: - { - Protocol_PlayerShot playerShot; - playerShot.primaryPressed = false; - playerShot.secondaryPressed = false; - playerShot.utilityPressed = false; - this->sharedData->network->Send( playerShot ); - } + this->sharedData->network->Send( Protocol_PlayerShot(Protocol_PlayerShot::ShootValue_SecondaryRelease) ); + break; + case ::Input::Enum::SAMI_MouseMiddleBtn: + this->sharedData->network->Send( Protocol_PlayerShot(Protocol_PlayerShot::ShootValue_UtilityRelease) ); break; } } diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp index dd20e8f3..f4b5e2ec 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -54,7 +54,13 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, break; case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS: - if( currentEnergy >= 1.0f ) + if(this->hasObject) + { + ((DynamicObject*)(this->heldObject->GetCustomTag()))->RemoveManipulation(); + this->hasObject = false; + this->heldObject = NULL; + } + else if( currentEnergy >= 1.0f ) { currentEnergy -= 1.0f; if(!this->hasObject) @@ -76,9 +82,9 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, { if (this->hasObject) //Dummy check { - ((DynamicObject*)(this->heldObject->GetCustomTag()))->RemoveManipulation(); - this->hasObject = false; - this->heldObject = NULL; + //((DynamicObject*)(this->heldObject->GetCustomTag()))->RemoveManipulation(); + //this->hasObject = false; + //this->heldObject = NULL; } } break; @@ -185,22 +191,27 @@ void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt) Oyster::Math::Float4 pullForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (this->force * 0.2); - Oyster::Collision3D::Cone *hitCone = new Oyster::Collision3D::Cone(lenght,pos,(Oyster::Math::Float4)owner->GetRigidBody()->GetState().quaternion,radius); + Oyster::Collision3D::Cone hitCone(lenght,pos,(Oyster::Math::Float4)owner->GetRigidBody()->GetState().quaternion,radius); forcePushData args; args.pushForce = -pullForce; args.p = this->owner; - Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction); - - if(hitCone) delete hitCone; + Oyster::Physics::API::Instance().ApplyEffect(&hitCone,&args,ForcePushAction); } void AttatchmentMassDriver::PickUpObject(const WEAPON_FIRE &usage, float dt) { - Oyster::Math::Float3 pos = owner->GetPosition() + owner->GetLookDir().GetNormalized()*2; - Oyster::Collision3D::Sphere *hitSphere = new Oyster::Collision3D::Sphere(pos,10); + //DEBUG: + MessageBeep(MB_ICONINFORMATION); + Oyster::Math::Float3 pos = owner->GetPosition() + owner->GetLookDir().GetNormalized() * 2; - Oyster::Physics::API::Instance().ApplyEffect(hitSphere,this,AttemptPickUp); + //Do ray test first! + //Oyster::Collision3D::Ray r(pos, owner->GetLookDir()); + //Oyster::Physics::API::Instance().ApplyEffect(&r, this, AttemptPickUp); - if(hitSphere) delete hitSphere; + if(this->hasObject) return; + + Oyster::Collision3D::Sphere hitSphere = Oyster::Collision3D::Sphere(pos , 1); + Oyster::Physics::API::Instance().ApplyEffect(&hitSphere,this,AttemptPickUp); + return; } diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index c355fd04..acad935a 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -326,6 +326,7 @@ using namespace GameLogic; void AttatchmentMassDriver::AttemptPickUp(Oyster::Physics::ICustomBody *obj, void* args) { if(obj->GetState().mass == 0) return; + if(!args) return; AttatchmentMassDriver *weapon = ((AttatchmentMassDriver*)args); @@ -339,7 +340,6 @@ using namespace GameLogic; //check so that it is an object that you can pickup DynamicObject *dynamicObj = dynamic_cast(realObj); - if(!dynamicObj) return; if(dynamicObj->getManipulatingPlayer() != NULL) diff --git a/Code/Game/GameProtocols/PlayerProtocols.h b/Code/Game/GameProtocols/PlayerProtocols.h index eb34c07c..e3cea80c 100644 --- a/Code/Game/GameProtocols/PlayerProtocols.h +++ b/Code/Game/GameProtocols/PlayerProtocols.h @@ -157,37 +157,59 @@ namespace GameLogic struct Protocol_PlayerShot :public Oyster::Network::CustomProtocolObject { - bool primaryPressed; - bool secondaryPressed; - bool utilityPressed; + enum ShootValue + { + ShootValue_PrimaryPress, + ShootValue_PrimaryRelease, + ShootValue_SecondaryPress, + ShootValue_SecondaryRelease, + ShootValue_UtilityPress, + ShootValue_UtilityRelease, + } value; + //bool primaryPressed; + //bool secondaryPressed; + //bool utilityPressed; Protocol_PlayerShot() { this->protocol[0].value = protocol_Gameplay_PlayerShot; this->protocol[0].type = Oyster::Network::NetAttributeType_Short; - this->protocol[1].type = Oyster::Network::NetAttributeType_Bool; - this->protocol[2].type = Oyster::Network::NetAttributeType_Bool; - this->protocol[3].type = Oyster::Network::NetAttributeType_Bool; + this->protocol[1].type = Oyster::Network::NetAttributeType_Char; + + //this->protocol[1].type = Oyster::Network::NetAttributeType_Bool; + //this->protocol[2].type = Oyster::Network::NetAttributeType_Bool; + //this->protocol[3].type = Oyster::Network::NetAttributeType_Bool; + } + Protocol_PlayerShot(ShootValue val) + { + this->protocol[0].value = protocol_Gameplay_PlayerShot; + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + + this->protocol[1].type = Oyster::Network::NetAttributeType_Char; + this->value = val; } Protocol_PlayerShot(Oyster::Network::CustomNetProtocol& p) { - primaryPressed = p[1].value.netBool; - secondaryPressed = p[2].value.netBool; - utilityPressed = p[3].value.netBool; + value = (ShootValue)p[1].value.netChar; + //primaryPressed = p[1].value.netBool; + //secondaryPressed = p[2].value.netBool; + //utilityPressed = p[3].value.netBool; } const Protocol_PlayerShot& operator=(Oyster::Network::CustomNetProtocol& val) { - primaryPressed = val[1].value.netBool; - secondaryPressed = val[2].value.netBool; - utilityPressed = val[3].value.netBool; + value = (ShootValue)val[1].value.netChar; + //primaryPressed = val[1].value.netBool; + //secondaryPressed = val[2].value.netBool; + //utilityPressed = val[3].value.netBool; return *this; } Oyster::Network::CustomNetProtocol GetProtocol() override { - this->protocol[1].value = primaryPressed; - this->protocol[2].value = secondaryPressed; - this->protocol[3].value = utilityPressed; + this->protocol[1].value = value; + //this->protocol[1].value = primaryPressed; + //this->protocol[2].value = secondaryPressed; + //this->protocol[3].value = utilityPressed; return protocol; } diff --git a/Code/Game/GameServer/Implementation/GameClient.cpp b/Code/Game/GameServer/Implementation/GameClient.cpp index b993cb79..74795ce6 100644 --- a/Code/Game/GameServer/Implementation/GameClient.cpp +++ b/Code/Game/GameServer/Implementation/GameClient.cpp @@ -25,8 +25,6 @@ GameClient::GameClient(Utility::DynamicMemory::SmartPointerplayer; - this->isReady = false; this->character = L"char_orca.dan"; this->alias = L"Unknown"; diff --git a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp index ceb22431..18e2b224 100644 --- a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp @@ -257,9 +257,21 @@ using namespace DanBias; } void GameSession::Gameplay_PlayerShot ( Protocol_PlayerShot& p, DanBias::GameClient* c ) { - if(p.secondaryPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_SECONDARY_PRESS); - if(p.primaryPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS); - if(p.utilityPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_UTILLITY_PRESS); + switch (p.value) + { + case Protocol_PlayerShot::ShootValue_PrimaryPress: c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS); + break; + case Protocol_PlayerShot::ShootValue_PrimaryRelease: c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_RELEASE); + break; + case Protocol_PlayerShot::ShootValue_SecondaryPress: c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_SECONDARY_PRESS); + break; + case Protocol_PlayerShot::ShootValue_SecondaryRelease: c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_SECONDARY_RELEASE); + break; + case Protocol_PlayerShot::ShootValue_UtilityPress: c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_UTILLITY_PRESS); + break; + case Protocol_PlayerShot::ShootValue_UtilityRelease: c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_UTILLITY_RELEASE); + break; + } } void GameSession::Gameplay_ObjectPickup ( Protocol_ObjectPickup& p, DanBias::GameClient* c ) { diff --git a/Code/Misc/Input/Source/Win32/Win32Mouse.cpp b/Code/Misc/Input/Source/Win32/Win32Mouse.cpp index 4faeed64..79cb49a4 100644 --- a/Code/Misc/Input/Source/Win32/Win32Mouse.cpp +++ b/Code/Misc/Input/Source/Win32/Win32Mouse.cpp @@ -200,12 +200,12 @@ void Win32Mouse::ProccessMouseData (RAWMOUSE mouse) if(btn == SAMI_Unknown) return; - this->buttons[btn].isDown = !isUp; this->buttons[btn].makeCode = makeCode; //The btn is released. if(isUp) { + this->buttons[btn].isDown = false; InternalOnBtnRelease(btn); GetNormalizedPosition( mouseEventData.normalizedPos ); @@ -222,6 +222,7 @@ void Win32Mouse::ProccessMouseData (RAWMOUSE mouse) //The btn is down since last frame if(this->buttons[btn].isDown) { + this->buttons[btn].isDown = true; InternalOnBtnDown(btn); GetNormalizedPosition( mouseEventData.normalizedPos ); @@ -234,6 +235,7 @@ void Win32Mouse::ProccessMouseData (RAWMOUSE mouse) } else { + this->buttons[btn].isDown = true; InternalOnBtnPress(btn); GetNormalizedPosition( mouseEventData.normalizedPos );