From 834de9ba8423f9b3142d33007ffa5b3c67132fc8 Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Thu, 28 Nov 2013 17:59:12 +0100 Subject: [PATCH 01/32] Bunch of implementations --- Code/GamePhysics/GamePhysics.vcxproj.filters | 2 +- Code/GamePhysics/Implementation/Octree.cpp | 60 ++++++++- Code/GamePhysics/Implementation/Octree.h | 10 +- .../Implementation/PhysicsAPI_Impl.cpp | 123 +++++++++++++----- .../Implementation/PhysicsAPI_Impl.h | 4 +- Code/GamePhysics/PhysicsAPI.h | 2 +- 6 files changed, 158 insertions(+), 43 deletions(-) diff --git a/Code/GamePhysics/GamePhysics.vcxproj.filters b/Code/GamePhysics/GamePhysics.vcxproj.filters index 72b83568..694a8ec7 100644 --- a/Code/GamePhysics/GamePhysics.vcxproj.filters +++ b/Code/GamePhysics/GamePhysics.vcxproj.filters @@ -51,7 +51,7 @@ Source Files - Header Files\Implementation + Source Files \ No newline at end of file diff --git a/Code/GamePhysics/Implementation/Octree.cpp b/Code/GamePhysics/Implementation/Octree.cpp index 6a6416b8..baa431da 100644 --- a/Code/GamePhysics/Implementation/Octree.cpp +++ b/Code/GamePhysics/Implementation/Octree.cpp @@ -2,6 +2,9 @@ using namespace Oyster; using namespace Physics; +using namespace ::Utility::DynamicMemory; + +const unsigned int Octree::invalid_ref = ::Utility::Value::numeric_limits::max(); Octree::Octree(unsigned int bufferSize, unsigned char numLayers, Math::Float3 worldSize) { @@ -26,7 +29,7 @@ Octree& Octree::operator=(const Octree& orig) return *this; } -void Octree::AddObject(Utility::DynamicMemory::UniquePointer< ICustomBody > customBodyRef) +void Octree::AddObject(UniquePointer< ICustomBody > customBodyRef) { Data data; //Data* tempPtr = this->worldNode.dataPtr; @@ -54,15 +57,15 @@ void Octree::AddObject(Utility::DynamicMemory::UniquePointer< ICustomBody > cust }*/ } -void Octree::MoveToUpdateQueue(Utility::DynamicMemory::UniquePointer< ICustomBody > customBodyRef) +void Octree::MoveToUpdateQueue(UniquePointer< ICustomBody > customBodyRef) { /*this->leafData[this->mapReferences[customBodyRef]].queueRef = this->updateQueue.size(); this->updateQueue.push_back(&this->leafData[this->mapReferences[customBodyRef]]);*/ } -void Octree::DestroyObject(Utility::DynamicMemory::UniquePointer< ICustomBody > customBodyRef) +void Octree::DestroyObject(UniquePointer< ICustomBody > customBodyRef) { - std::map::iterator it = this->mapReferences.find(customBodyRef); + std::map::iterator it = this->mapReferences.find(customBodyRef); this->mapReferences.erase(it); @@ -116,4 +119,53 @@ void Octree::Visit(ICustomBody* customBodyRef, VistorAction hitAction ) ICustomBody* Octree::GetCustomBody(const unsigned int tempRef) { return this->leafData[tempRef].customBodyRef; +} + +UniquePointer Octree::Extract( const ICustomBody* objRef ) +{ // Dan Andersson + auto iter = this->mapReferences.find( objRef ); + if( iter != this->mapReferences.end() ) + { + return this->Extract( iter->second ); + } + else + { + return NULL; + } +} + +UniquePointer Octree::Extract( unsigned int tempRef ) +{ + if( tempRef != Octree::invalid_ref ) + { + //! @todo TODO: implement stub + return NULL; + } + else + { + return NULL; + } +} + +unsigned int Octree::GetTemporaryReferenceOf( const ICustomBody* objRef ) const +{ // Dan Andersson + auto iter = this->mapReferences.find( objRef ); + if( iter != this->mapReferences.end() ) + { + return iter->second; + } + else + { + return Octree::invalid_ref; + } +} + +void Octree::SetAsAltered( unsigned int tempRef ) +{ + //! @todo TODO: implement stub +} + +void Octree::EvaluatePosition( unsigned int tempRef ) +{ + //! @todo TODO: implement stub } \ No newline at end of file diff --git a/Code/GamePhysics/Implementation/Octree.h b/Code/GamePhysics/Implementation/Octree.h index 8d111329..5ef3b0a8 100644 --- a/Code/GamePhysics/Implementation/Octree.h +++ b/Code/GamePhysics/Implementation/Octree.h @@ -15,6 +15,8 @@ namespace Oyster class Octree { public: + static const unsigned int invalid_ref; + typedef void(*VistorAction)(Octree&, unsigned int, unsigned int); struct Data @@ -52,11 +54,17 @@ namespace Oyster ICustomBody* GetCustomBody(const unsigned int tempRef); + ::Utility::DynamicMemory::UniquePointer Extract( const ICustomBody* objRef ); + ::Utility::DynamicMemory::UniquePointer Extract( unsigned int tempRef ); // Dan vill ha + unsigned int GetTemporaryReferenceOf( const ICustomBody* objRef ) const; // Dan vill ha + void SetAsAltered( unsigned int tempRef ); // Dan vill ha + void EvaluatePosition( unsigned int tempRef ); // Dan vill ha + private: std::vector < Data > leafData; std::vector < Data* > updateQueue; - std::map< ICustomBody*, unsigned int > mapReferences; + std::map< const ICustomBody*, unsigned int > mapReferences; OctreeNode worldNode; }; diff --git a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp index 6c9b212a..0374704f 100644 --- a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp +++ b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp @@ -42,21 +42,24 @@ API & API::Instance() } API_Impl::API_Impl() - : gravityConstant( Constant::gravity_constant ), - updateFrameLength( 1.0f / 120.0f ), - destructionAction( Default::EventAction_Destruction ) -{} +{ + this->gravityConstant = Constant::gravity_constant; + this->updateFrameLength = 1.0f / 120.0f; + this->destructionAction = Default::EventAction_Destruction; + this->worldScene = Octree(); +} API_Impl::~API_Impl() {} void API_Impl::Init( unsigned int numObjects, unsigned int numGravityWells , const Float3 &worldSize ) { - //! @todo TODO: implement stub + unsigned char numLayers = 4; //!< @todo TODO: calc numLayers from worldSize + this->worldScene = Octree( numObjects, numLayers, worldSize ); } -void API_Impl::SetDeltaTime( float deltaTime ) +void API_Impl::SetFrameTimeLength( float deltaTime ) { - updateFrameLength = deltaTime; + this->updateFrameLength = deltaTime; } void API_Impl::SetGravityConstant( float g ) @@ -98,68 +101,117 @@ void API_Impl::ReleaseFromLimbo( const ICustomBody* objRef ) void API_Impl::AddObject( ::Utility::DynamicMemory::UniquePointer handle ) { - /** @todo TODO: Fix this function.*/ + this->worldScene.AddObject( handle ); } -::Utility::DynamicMemory::UniquePointer API_Impl::ExtractObject( const ICustomBody* objRef ) +UniquePointer API_Impl::ExtractObject( const ICustomBody* objRef ) { - //! @todo TODO: implement stub - return NULL; + return this->worldScene.Extract( objRef ); } void API_Impl::DestroyObject( const ICustomBody* objRef ) { - /** @todo TODO: Fix this function.*/ + UniquePointer object = this->worldScene.Extract( objRef ); + if( object != NULL ) + { + this->destructionAction( object ); + } } void API_Impl::ApplyForceAt( const ICustomBody* objRef, const Float3 &worldPos, const Float3 &worldF ) { - //! @todo TODO: implement stub + unsigned int tempRef = this->worldScene.GetTemporaryReferenceOf( objRef ); + if( tempRef != this->worldScene.invalid_ref ) + { + //this->worldScene.GetCustomBody( tempRef )->Apply //!< @todo TODO: need function + this->worldScene.SetAsAltered( tempRef ); + } } void API_Impl::ApplyCollisionResponse( const ICustomBody* objRefA, const ICustomBody* objRefB, Float &deltaWhen, Float3 &worldPointOfContact ) { - //! @todo TODO: implement stub + unsigned int tempRef = this->worldScene.GetTemporaryReferenceOf( objRefA ); + if( tempRef != this->worldScene.invalid_ref ) + { + //! @todo TODO: implement stub + this->worldScene.SetAsAltered( tempRef ); + } } void API_Impl::SetMomentOfInertiaTensor_KeepVelocity( const ICustomBody* objRef, const Float4x4 &localI ) -{ - //! @todo TODO: implement stub +{ // deprecated + unsigned int tempRef = this->worldScene.GetTemporaryReferenceOf( objRef ); + if( tempRef != this->worldScene.invalid_ref ) + { + this->worldScene.GetCustomBody( tempRef )->SetMomentOfInertiaTensor_KeepVelocity( localI ); + } } void API_Impl::SetMomentOfInertiaTensor_KeepMomentum( const ICustomBody* objRef, const Float4x4 &localI ) -{ - //! @todo TODO: implement stub +{ // deprecated + unsigned int tempRef = this->worldScene.GetTemporaryReferenceOf( objRef ); + if( tempRef != this->worldScene.invalid_ref ) + { + this->worldScene.GetCustomBody( tempRef )->SetMomentOfInertiaTensor_KeepMomentum( localI ); + } } void API_Impl::SetMass_KeepVelocity( const ICustomBody* objRef, Float m ) -{ - //! @todo TODO: implement stub +{ // deprecated + unsigned int tempRef = this->worldScene.GetTemporaryReferenceOf( objRef ); + if( tempRef != this->worldScene.invalid_ref ) + { + this->worldScene.GetCustomBody( tempRef )->SetMass_KeepVelocity( m ); + } } void API_Impl::SetMass_KeepMomentum( const ICustomBody* objRef, Float m ) -{ - //! @todo TODO: implement stub +{ // deprecated + unsigned int tempRef = this->worldScene.GetTemporaryReferenceOf( objRef ); + if( tempRef != this->worldScene.invalid_ref ) + { + this->worldScene.GetCustomBody( tempRef )->SetMass_KeepMomentum( m ); + } } void API_Impl::SetCenter( const ICustomBody* objRef, const Float3 &worldPos ) { - //! @todo TODO: implement stub + unsigned int tempRef = this->worldScene.GetTemporaryReferenceOf( objRef ); + if( tempRef != this->worldScene.invalid_ref ) + { + //this->worldScene.GetCustomBody( tempRef )->Set //!< @todo TODO: need function + this->worldScene.EvaluatePosition( tempRef ); + } } void API_Impl::SetRotation( const ICustomBody* objRef, const Float4x4 &rotation ) { - //! @todo TODO: implement stub + unsigned int tempRef = this->worldScene.GetTemporaryReferenceOf( objRef ); + if( tempRef != this->worldScene.invalid_ref ) + { + this->worldScene.GetCustomBody( tempRef )->SetRotation( rotation ); + this->worldScene.EvaluatePosition( tempRef ); + } } void API_Impl::SetOrientation( const ICustomBody* objRef, const Float4x4 &orientation ) { - //! @todo TODO: implement stub + unsigned int tempRef = this->worldScene.GetTemporaryReferenceOf( objRef ); + if( tempRef != this->worldScene.invalid_ref ) + { + this->worldScene.GetCustomBody( tempRef )->SetOrientation( orientation ); + this->worldScene.EvaluatePosition( tempRef ); + } } void API_Impl::SetSize( const ICustomBody* objRef, const Float3 &size ) { - //! @todo TODO: implement stub + unsigned int tempRef = this->worldScene.GetTemporaryReferenceOf( objRef ); + if( tempRef != this->worldScene.invalid_ref ) + { + this->worldScene.GetCustomBody( tempRef )->SetSize( size ); + this->worldScene.EvaluatePosition( tempRef ); + } } UniquePointer API_Impl::CreateRigidBody( const API::SimpleBodyDescription &desc ) const @@ -172,15 +224,16 @@ UniquePointer API_Impl::CreateRigidBody( const API::SphericalBodyDe return new SphericalRigidBody( desc ); } -namespace Oyster { namespace Physics { namespace Default +namespace Oyster { namespace Physics { + namespace Default + { + void EventAction_Destruction( ::Utility::DynamicMemory::UniquePointer<::Oyster::Physics::ICustomBody> proto ) + { /* Do nothing except allowing the proto uniquePointer destroy itself. */ } - void EventAction_Destruction( ::Utility::DynamicMemory::UniquePointer<::Oyster::Physics::ICustomBody> proto ) - { /* Do nothing except allowing the proto uniquePointer destroy itself. */ } - - ::Oyster::Physics::ICustomBody::SubscriptMessage EventAction_Collision( const ::Oyster::Physics::ICustomBody *proto, const ::Oyster::Physics::ICustomBody *deuter ) - { /* Do nothing except returning business as usual. */ - return ::Oyster::Physics::ICustomBody::SubscriptMessage_none; + ::Oyster::Physics::ICustomBody::SubscriptMessage EventAction_Collision( const ::Oyster::Physics::ICustomBody *proto, const ::Oyster::Physics::ICustomBody *deuter ) + { /* Do nothing except returning business as usual. */ + return ::Oyster::Physics::ICustomBody::SubscriptMessage_none; + } } - -} } } \ No newline at end of file +} } \ No newline at end of file diff --git a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.h b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.h index 7d6858f0..5de9c05a 100644 --- a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.h +++ b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.h @@ -2,6 +2,7 @@ #define PHYSICS_API_IMPL_H #include "../PhysicsAPI.h" +#include "Octree.h" namespace Oyster { @@ -15,7 +16,7 @@ namespace Oyster void Init( unsigned int numObjects, unsigned int numGravityWells , const ::Oyster::Math::Float3 &worldSize ); - void SetDeltaTime( float deltaTime ); + void SetFrameTimeLength( float deltaTime ); void SetGravityConstant( float g ); void SetSubscription( EventAction_Destruction functionPointer ); @@ -47,6 +48,7 @@ namespace Oyster private: ::Oyster::Math::Float gravityConstant, updateFrameLength; EventAction_Destruction destructionAction; + Octree worldScene; }; namespace Default diff --git a/Code/GamePhysics/PhysicsAPI.h b/Code/GamePhysics/PhysicsAPI.h index 6cba993c..5d44b695 100644 --- a/Code/GamePhysics/PhysicsAPI.h +++ b/Code/GamePhysics/PhysicsAPI.h @@ -64,7 +64,7 @@ namespace Oyster /******************************************************** * Sets the time length of each physics update frame. ********************************************************/ - virtual void SetDeltaTime( float seconds ) = 0; + virtual void SetFrameTimeLength( float seconds ) = 0; /******************************************************** * Sets the Gravityconstant in the physics that will be From 14b1f20b87a21e4a3386b79f69e603f124310766 Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Thu, 28 Nov 2013 18:05:19 +0100 Subject: [PATCH 02/32] minor compilation error fix Forgot that UniquePointer had a special operator for checking if it is not NULL >.< --- Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp index 0374704f..ed8f8eed 100644 --- a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp +++ b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp @@ -112,7 +112,7 @@ UniquePointer API_Impl::ExtractObject( const ICustomBody* objRef ) void API_Impl::DestroyObject( const ICustomBody* objRef ) { UniquePointer object = this->worldScene.Extract( objRef ); - if( object != NULL ) + if( object ) { this->destructionAction( object ); } From 255a0b0070ed94ec38a8097b97f76085791febed Mon Sep 17 00:00:00 2001 From: Robin Engman Date: Fri, 29 Nov 2013 09:03:37 +0100 Subject: [PATCH 03/32] Added overloads for visitor and sample functions They now have an overload for accepting ICollideable --- Code/GamePhysics/Implementation/Octree.cpp | 34 ++++++++++++++++++---- Code/GamePhysics/Implementation/Octree.h | 4 ++- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/Code/GamePhysics/Implementation/Octree.cpp b/Code/GamePhysics/Implementation/Octree.cpp index baa431da..70d2842a 100644 --- a/Code/GamePhysics/Implementation/Octree.cpp +++ b/Code/GamePhysics/Implementation/Octree.cpp @@ -72,15 +72,13 @@ void Octree::DestroyObject(UniquePointer< ICustomBody > customBodyRef) this->leafData.erase(this->leafData.begin() + this->leafData[this->mapReferences[customBodyRef]].queueRef); } -std::vector Octree::Sample(ICustomBody* customBodyRef) +std::vector& Octree::Sample(ICustomBody* customBodyRef, std::vector& updateList) { - std::vector list; - auto object = this->mapReferences.find(customBodyRef); if(object == this->mapReferences.end()) { - return list; + return updateList; } unsigned int tempRef = object->second; @@ -89,11 +87,24 @@ std::vector Octree::Sample(ICustomBody* customBodyRef) { if(tempRef != i) if(this->leafData[tempRef].container.Intersects(this->leafData[i].container)) { - list.push_back(this->leafData[i].customBodyRef); + updateList.push_back(this->leafData[i].customBodyRef); } } - return list; + return updateList; +} + +std::vector& Octree::Sample(::Collision3D::ICollideable* collideable, std::vector& updateList) +{ + for(unsigned int i = 0; ileafData.size(); i++) + { + if(this->leafData[i].container.Intersects(*collideable)) + { + updateList.push_back(this->leafData[i].customBodyRef); + } + } + + return updateList; } void Octree::Visit(ICustomBody* customBodyRef, VistorAction hitAction ) @@ -116,6 +127,17 @@ void Octree::Visit(ICustomBody* customBodyRef, VistorAction hitAction ) } } +void Octree::Visit(::Collision3D::ICollideable* collideable, VistorAction hitAction) +{ + for(unsigned int i = 0; ileafData.size(); i++) + { + if(this->leafData[i].container.Intersects(*collideable)) + { + //hitAction(*this, tempRef, i); // @todo TODO: Add typedef to handle function calls with ICollideable + } + } +} + ICustomBody* Octree::GetCustomBody(const unsigned int tempRef) { return this->leafData[tempRef].customBodyRef; diff --git a/Code/GamePhysics/Implementation/Octree.h b/Code/GamePhysics/Implementation/Octree.h index 5ef3b0a8..6340fa58 100644 --- a/Code/GamePhysics/Implementation/Octree.h +++ b/Code/GamePhysics/Implementation/Octree.h @@ -49,8 +49,10 @@ namespace Oyster void DestroyObject(::Utility::DynamicMemory::UniquePointer< ICustomBody > customBodyRef); - std::vector Sample(ICustomBody* customBodyRef); + std::vector& Sample(ICustomBody* customBodyRef, std::vector& updateList); + std::vector& Sample(Oyster::Collision3D::ICollideable* collideable, std::vector& updateList); void Visit(ICustomBody* customBodyRef, VistorAction hitAction ); + void Visit(Oyster::Collision3D::ICollideable* collideable, VistorAction hitAction ); ICustomBody* GetCustomBody(const unsigned int tempRef); From bddc3acad2dcc6a55b6bc7f1413d207d7bea6d7e Mon Sep 17 00:00:00 2001 From: Robin Engman Date: Fri, 29 Nov 2013 09:07:52 +0100 Subject: [PATCH 04/32] Changed from pointer to reference Did it in sample and visit functions --- Code/GamePhysics/Implementation/Octree.cpp | 8 ++++---- Code/GamePhysics/Implementation/Octree.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Code/GamePhysics/Implementation/Octree.cpp b/Code/GamePhysics/Implementation/Octree.cpp index 70d2842a..1da6045b 100644 --- a/Code/GamePhysics/Implementation/Octree.cpp +++ b/Code/GamePhysics/Implementation/Octree.cpp @@ -94,11 +94,11 @@ std::vector& Octree::Sample(ICustomBody* customBodyRef, std::vecto return updateList; } -std::vector& Octree::Sample(::Collision3D::ICollideable* collideable, std::vector& updateList) +std::vector& Octree::Sample(const Oyster::Collision3D::ICollideable& collideable, std::vector& updateList) { for(unsigned int i = 0; ileafData.size(); i++) { - if(this->leafData[i].container.Intersects(*collideable)) + if(this->leafData[i].container.Intersects(collideable)) { updateList.push_back(this->leafData[i].customBodyRef); } @@ -127,11 +127,11 @@ void Octree::Visit(ICustomBody* customBodyRef, VistorAction hitAction ) } } -void Octree::Visit(::Collision3D::ICollideable* collideable, VistorAction hitAction) +void Octree::Visit(const Oyster::Collision3D::ICollideable& collideable, VistorAction hitAction) { for(unsigned int i = 0; ileafData.size(); i++) { - if(this->leafData[i].container.Intersects(*collideable)) + if(this->leafData[i].container.Intersects(collideable)) { //hitAction(*this, tempRef, i); // @todo TODO: Add typedef to handle function calls with ICollideable } diff --git a/Code/GamePhysics/Implementation/Octree.h b/Code/GamePhysics/Implementation/Octree.h index 6340fa58..96631605 100644 --- a/Code/GamePhysics/Implementation/Octree.h +++ b/Code/GamePhysics/Implementation/Octree.h @@ -50,9 +50,9 @@ namespace Oyster void DestroyObject(::Utility::DynamicMemory::UniquePointer< ICustomBody > customBodyRef); std::vector& Sample(ICustomBody* customBodyRef, std::vector& updateList); - std::vector& Sample(Oyster::Collision3D::ICollideable* collideable, std::vector& updateList); + std::vector& Sample(const Oyster::Collision3D::ICollideable& collideable, std::vector& updateList); void Visit(ICustomBody* customBodyRef, VistorAction hitAction ); - void Visit(Oyster::Collision3D::ICollideable* collideable, VistorAction hitAction ); + void Visit(const Oyster::Collision3D::ICollideable& collideable, VistorAction hitAction ); ICustomBody* GetCustomBody(const unsigned int tempRef); From f0b766e37c38a8ae1bc8bbb853654f9eddd6eded Mon Sep 17 00:00:00 2001 From: dean11 Date: Mon, 2 Dec 2013 14:43:57 +0100 Subject: [PATCH 05/32] Something done in misc --- Code/Misc/Utilities-Impl.h | 8 ++++++++ Code/Misc/Utilities.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/Code/Misc/Utilities-Impl.h b/Code/Misc/Utilities-Impl.h index cc82c959..33b35662 100644 --- a/Code/Misc/Utilities-Impl.h +++ b/Code/Misc/Utilities-Impl.h @@ -274,6 +274,14 @@ namespace Utility { return &p == this->_ptr; } + template inline bool SmartPointer::operator!= (const SmartPointer& d) + { + return d._ptr != this->_ptr; + } + template inline bool SmartPointer::operator!= (const T& p) + { + return &p != this->_ptr; + } template inline T& SmartPointer::operator* () { return *this->_ptr; diff --git a/Code/Misc/Utilities.h b/Code/Misc/Utilities.h index ec8b0229..e541e1df 100644 --- a/Code/Misc/Utilities.h +++ b/Code/Misc/Utilities.h @@ -212,6 +212,8 @@ namespace Utility SmartPointer& operator= (T* p); bool operator== (const SmartPointer& d); bool operator== (const T& p); + bool operator!= (const SmartPointer& d); + bool operator!= (const T& p); T& operator* (); T* operator-> (); operator T* (); From e4476f7757a79de5fee9ade50bf674584cbc5e4b Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Tue, 3 Dec 2013 15:11:13 +0100 Subject: [PATCH 06/32] Added function for ICustomBody void ICustomBody::SetMomentum( const ::Oyster::Math::Float3 &worldG ) - Added and implemented --- Code/GamePhysics/Implementation/SimpleRigidBody.cpp | 5 +++++ Code/GamePhysics/Implementation/SimpleRigidBody.h | 1 + Code/GamePhysics/Implementation/SphericalRigidBody.cpp | 5 +++++ Code/GamePhysics/Implementation/SphericalRigidBody.h | 1 + Code/GamePhysics/PhysicsAPI.h | 6 ++++++ 5 files changed, 18 insertions(+) diff --git a/Code/GamePhysics/Implementation/SimpleRigidBody.cpp b/Code/GamePhysics/Implementation/SimpleRigidBody.cpp index 70bc6938..ea75ffe3 100644 --- a/Code/GamePhysics/Implementation/SimpleRigidBody.cpp +++ b/Code/GamePhysics/Implementation/SimpleRigidBody.cpp @@ -177,4 +177,9 @@ void SimpleRigidBody::SetOrientation( const Float4x4 &orientation ) void SimpleRigidBody::SetSize( const Float3 &size ) { this->rigid.SetSize( size ); +} + +void SimpleRigidBody::SetMomentum( const Float3 &worldG ) +{ + this->rigid.SetLinearMomentum( worldG ); } \ No newline at end of file diff --git a/Code/GamePhysics/Implementation/SimpleRigidBody.h b/Code/GamePhysics/Implementation/SimpleRigidBody.h index a674a20d..5e05c9d7 100644 --- a/Code/GamePhysics/Implementation/SimpleRigidBody.h +++ b/Code/GamePhysics/Implementation/SimpleRigidBody.h @@ -41,6 +41,7 @@ namespace Oyster { namespace Physics void SetRotation( const ::Oyster::Math::Float4x4 &rotation ); void SetOrientation( const ::Oyster::Math::Float4x4 &orientation ); void SetSize( const ::Oyster::Math::Float3 &size ); + void SetMomentum( const ::Oyster::Math::Float3 &worldG ); private: ::Oyster::Physics3D::RigidBody rigid; diff --git a/Code/GamePhysics/Implementation/SphericalRigidBody.cpp b/Code/GamePhysics/Implementation/SphericalRigidBody.cpp index c741a68a..03ed7d2a 100644 --- a/Code/GamePhysics/Implementation/SphericalRigidBody.cpp +++ b/Code/GamePhysics/Implementation/SphericalRigidBody.cpp @@ -183,4 +183,9 @@ void SphericalRigidBody::SetSize( const Float3 &size ) { this->rigid.SetSize( size ); this->body.radius = 0.5f * Min( Min( size.x, size.y ), size.z ); // inline Min( FloatN )? +} + +void SphericalRigidBody::SetMomentum( const Float3 &worldG ) +{ + this->rigid.SetLinearMomentum( worldG ); } \ No newline at end of file diff --git a/Code/GamePhysics/Implementation/SphericalRigidBody.h b/Code/GamePhysics/Implementation/SphericalRigidBody.h index 37263e91..a25cba2c 100644 --- a/Code/GamePhysics/Implementation/SphericalRigidBody.h +++ b/Code/GamePhysics/Implementation/SphericalRigidBody.h @@ -42,6 +42,7 @@ namespace Oyster { namespace Physics void SetRotation( const ::Oyster::Math::Float4x4 &rotation ); void SetOrientation( const ::Oyster::Math::Float4x4 &orientation ); void SetSize( const ::Oyster::Math::Float3 &size ); + void SetMomentum( const ::Oyster::Math::Float3 &worldG ); private: ::Oyster::Physics3D::RigidBody rigid; diff --git a/Code/GamePhysics/PhysicsAPI.h b/Code/GamePhysics/PhysicsAPI.h index 29014214..56e46817 100644 --- a/Code/GamePhysics/PhysicsAPI.h +++ b/Code/GamePhysics/PhysicsAPI.h @@ -390,6 +390,12 @@ namespace Oyster * Use API::SetSize(...) ********************************************************/ virtual void SetSize( const ::Oyster::Math::Float3 &size ) = 0; + + /******************************************************** + * To not be called if is in Engine + * Use API::?? @todo TODO: + ********************************************************/ + virtual void SetMomentum( const ::Oyster::Math::Float3 &worldG ) = 0; }; struct API::SimpleBodyDescription From b03e9af027620da96eaee49bc8d2c0f3726efd21 Mon Sep 17 00:00:00 2001 From: Robin Engman Date: Wed, 4 Dec 2013 09:51:48 +0100 Subject: [PATCH 07/32] Fixed octree and API Rewrote AddObject function in octree and OnPossibleCollision in PhysocsAPI_Impl --- Code/GamePhysics/Implementation/Octree.cpp | 2 +- Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Code/GamePhysics/Implementation/Octree.cpp b/Code/GamePhysics/Implementation/Octree.cpp index 1da6045b..4da48863 100644 --- a/Code/GamePhysics/Implementation/Octree.cpp +++ b/Code/GamePhysics/Implementation/Octree.cpp @@ -39,7 +39,7 @@ void Octree::AddObject(UniquePointer< ICustomBody > customBodyRef) data.next = NULL; data.prev = NULL; data.customBodyRef = customBodyRef; - this->mapReferences.insert(std::pair (customBodyRef, this->leafData.size())); + this->mapReferences.insert(std::pair (data.customBodyRef, this->leafData.size())); this->leafData.push_back(data); /*if(tempPtr != NULL) diff --git a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp index 3d3080da..447a6c68 100644 --- a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp +++ b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp @@ -20,7 +20,7 @@ namespace float deltaWhen; Float3 worldWhere; - if( deuter->Intersects(*deuter, 1.0f, deltaWhen, worldWhere) ) + if( proto->Intersects(*deuter, 1.0f, deltaWhen, worldWhere) ) { proto->CallSubscription( proto, deuter ); } From 1d94ed0ddcccde9ffa22b3342dd42ab0029519c2 Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Wed, 4 Dec 2013 11:30:56 +0100 Subject: [PATCH 08/32] Fixed MomentOfInertia methods --- .../Implementation/PhysicsAPI_Impl.cpp | 20 +++++++++---------- Code/GamePhysics/PhysicsAPI.h | 12 +++++------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp index 447a6c68..46b3369c 100644 --- a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp +++ b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp @@ -27,29 +27,29 @@ namespace } } -Float4x4 & MomentOfInertia::CreateSphereMatrix( const Float mass, const Float radius) +Float4x4 & MomentOfInertia::CreateSphereMatrix( const Float mass, const Float radius, ::Oyster::Math::Float4x4 &targetMem ) { - return Formula::MomentOfInertia::Sphere(mass, radius); + return targetMem = Formula::MomentOfInertia::Sphere(mass, radius); } -Float4x4 & MomentOfInertia::CreateHollowSphereMatrix( const Float mass, const Float radius) +Float4x4 & MomentOfInertia::CreateHollowSphereMatrix( const Float mass, const Float radius, ::Oyster::Math::Float4x4 &targetMem ) { - return Formula::MomentOfInertia::HollowSphere(mass, radius); + return targetMem = Formula::MomentOfInertia::HollowSphere(mass, radius); } -Float4x4 & MomentOfInertia::CreateCuboidMatrix( const Float mass, const Float height, const Float width, const Float depth ) +Float4x4 & MomentOfInertia::CreateCuboidMatrix( const Float mass, const Float height, const Float width, const Float depth, ::Oyster::Math::Float4x4 &targetMem ) { - return Formula::MomentOfInertia::Cuboid(mass, height, width, depth); + return targetMem = Formula::MomentOfInertia::Cuboid(mass, height, width, depth); } -Float4x4 & MomentOfInertia::CreateCylinderMatrix( const Float mass, const Float height, const Float radius ) +Float4x4 & MomentOfInertia::CreateCylinderMatrix( const Float mass, const Float height, const Float radius, ::Oyster::Math::Float4x4 &targetMem ) { - return Formula::MomentOfInertia::Cylinder(mass, height, radius); + return targetMem = Formula::MomentOfInertia::Cylinder(mass, height, radius); } -Float4x4 & MomentOfInertia::CreateRodMatrix( const Float mass, const Float length ) +Float4x4 & MomentOfInertia::CreateRodMatrix( const Float mass, const Float length, ::Oyster::Math::Float4x4 &targetMem ) { - return Formula::MomentOfInertia::RodCenter(mass, length); + return targetMem = Formula::MomentOfInertia::RodCenter(mass, length); } API & API::Instance() diff --git a/Code/GamePhysics/PhysicsAPI.h b/Code/GamePhysics/PhysicsAPI.h index 56e46817..cd720abd 100644 --- a/Code/GamePhysics/PhysicsAPI.h +++ b/Code/GamePhysics/PhysicsAPI.h @@ -1,4 +1,4 @@ -#ifndef PHYSICS_API_H + #ifndef PHYSICS_API_H #define PHYSICS_API_H #include "OysterCollision3D.h" @@ -31,15 +31,15 @@ namespace Oyster class PHYSICS_DLL_USAGE MomentOfInertia { public: - static ::Oyster::Math::Float4x4 & CreateSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius); + static ::Oyster::Math::Float4x4 & CreateSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius, ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ); - static ::Oyster::Math::Float4x4 & CreateHollowSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius); + static ::Oyster::Math::Float4x4 & CreateHollowSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius, ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ); - static ::Oyster::Math::Float4x4 & CreateCuboidMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float width, const ::Oyster::Math::Float depth ); + static ::Oyster::Math::Float4x4 & CreateCuboidMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float width, const ::Oyster::Math::Float depth, ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ); - static ::Oyster::Math::Float4x4 & CreateCylinderMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float radius ); + static ::Oyster::Math::Float4x4 & CreateCylinderMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float radius, ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ); - static ::Oyster::Math::Float4x4 & CreateRodMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float length ); + static ::Oyster::Math::Float4x4 & CreateRodMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float length, ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ); }; class PHYSICS_DLL_USAGE API From 080bbf68fdfece5ed2ad184c9018682e065ef1bc Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Wed, 4 Dec 2013 11:42:11 +0100 Subject: [PATCH 09/32] Collideables fixed Missing returns --- Code/OysterPhysics3D/Point.cpp | 2 +- Code/OysterPhysics3D/Ray.cpp | 2 +- Code/OysterPhysics3D/Sphere.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Code/OysterPhysics3D/Point.cpp b/Code/OysterPhysics3D/Point.cpp index cf1186c9..d81c91a3 100644 --- a/Code/OysterPhysics3D/Point.cpp +++ b/Code/OysterPhysics3D/Point.cpp @@ -38,7 +38,7 @@ bool Point::Intersects( const ICollideable &target ) const case Type_universe: return true; case Type_point: return Utility::Intersect( *this, *(Point*)&target ); case Type_ray: return Utility::Intersect( *(Ray*)&target, *this, ((Ray*)&target)->collisionDistance ); - case Type_sphere: Utility::Intersect( *(Sphere*)&target, *this ); + case Type_sphere: return Utility::Intersect( *(Sphere*)&target, *this ); case Type_plane: return Utility::Intersect( *(Plane*)&target, *this ); //case Type_triangle: return false; // TODO: case Type_box_axis_aligned: return Utility::Intersect( *(BoxAxisAligned*)&target, *this ); diff --git a/Code/OysterPhysics3D/Ray.cpp b/Code/OysterPhysics3D/Ray.cpp index 09fb13ec..79e4dbd5 100644 --- a/Code/OysterPhysics3D/Ray.cpp +++ b/Code/OysterPhysics3D/Ray.cpp @@ -60,7 +60,7 @@ bool Ray::Contains( const ICollideable &target ) const switch( target.type ) { case Type_point: return Utility::Intersect( *this, *(Point*)&target, this->collisionDistance ); - case Type_ray: Utility::Contains( *this, *(Ray*)&target ); + case Type_ray: return Utility::Contains( *this, *(Ray*)&target ); default: return false; } } \ No newline at end of file diff --git a/Code/OysterPhysics3D/Sphere.cpp b/Code/OysterPhysics3D/Sphere.cpp index 0cc8bc3b..4f6f76f7 100644 --- a/Code/OysterPhysics3D/Sphere.cpp +++ b/Code/OysterPhysics3D/Sphere.cpp @@ -35,7 +35,7 @@ bool Sphere::Intersects( const ICollideable &target ) const case Type_universe: return true; case Type_point: return Utility::Intersect( *this, *(Point*)&target ); case Type_ray: return Utility::Intersect( *this, *(Ray*)&target, ((Ray*)&target)->collisionDistance ); - case Type_sphere: Utility::Intersect( *this, *(Sphere*)&target ); + case Type_sphere: return Utility::Intersect( *this, *(Sphere*)&target ); case Type_plane: return Utility::Intersect( *(Plane*)&target, *this ); // case Type_triangle: return false; // TODO: case Type_box_axis_aligned: return Utility::Intersect( *(BoxAxisAligned*)&target, *this ); From 202ee23b252627be7edf9f3cc37023c33042a18d Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Wed, 4 Dec 2013 11:49:33 +0100 Subject: [PATCH 10/32] Octtree::leafData Container should be kept updated now --- Code/GamePhysics/Implementation/Octree.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Code/GamePhysics/Implementation/Octree.cpp b/Code/GamePhysics/Implementation/Octree.cpp index 4da48863..b841b49d 100644 --- a/Code/GamePhysics/Implementation/Octree.cpp +++ b/Code/GamePhysics/Implementation/Octree.cpp @@ -184,6 +184,7 @@ unsigned int Octree::GetTemporaryReferenceOf( const ICustomBody* objRef ) const void Octree::SetAsAltered( unsigned int tempRef ) { + this->leafData[tempRef].container = this->leafData[tempRef].customBodyRef->GetBoundingSphere(); //! @todo TODO: implement stub } From e0adc0ae93d7c8d33c23f6c1ee7dc7dfeb8a2f3e Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Wed, 4 Dec 2013 13:52:07 +0100 Subject: [PATCH 11/32] Sphere Vs Box collision detect fix --- Code/OysterPhysics3D/OysterCollision3D.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Code/OysterPhysics3D/OysterCollision3D.cpp b/Code/OysterPhysics3D/OysterCollision3D.cpp index 131cad62..95c56f81 100644 --- a/Code/OysterPhysics3D/OysterCollision3D.cpp +++ b/Code/OysterPhysics3D/OysterCollision3D.cpp @@ -393,8 +393,8 @@ namespace Oyster { namespace Collision3D { namespace Utility bool Intersect( const BoxAxisAligned &box, const Sphere &sphere ) { // by Dan Andersson - Float3 e = Max( box.minVertex - sphere.center, Float3::null ); - e += Max( sphere.center - box.maxVertex, Float3::null ); + Float4 e = Max( Float4(box.minVertex - sphere.center, 0.0f), Float4::null ); + e += Max( Float4(sphere.center - box.maxVertex, 0.0f), Float4::null ); if( e.Dot(e) > (sphere.radius * sphere.radius) ) return false; return true; @@ -459,12 +459,13 @@ namespace Oyster { namespace Collision3D { namespace Utility bool Intersect( const Box &box, const Sphere &sphere ) { // by Dan Andersson - Float3 e = sphere.center - box.center, - centerL = Float3( e.Dot(box.xAxis), e.Dot(box.yAxis), e.Dot(box.zAxis) ); - - e = Max( (box.boundingOffset + centerL)*=-1.0f, Float3::null ); - e += Max( centerL - box.boundingOffset, Float3::null ); - + Float4 vCenter = Float4( sphere.center - box.center, 1.0f ); // sphere's center in the box's view space + vCenter = InverseRotationMatrix( box.rotation ) * vCenter; + vCenter.w = 0.0f; + + Float4 e = Max( Float4(-box.boundingOffset, 0.0f) - vCenter, Float4::null ); + e += Max( vCenter - Float4(-box.boundingOffset, 0.0f), Float4::null ); + if( e.Dot(e) > (sphere.radius * sphere.radius) ) return false; return true; } From 7ad60969fc24912293276b04070c80f0cb55215b Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Wed, 4 Dec 2013 14:12:06 +0100 Subject: [PATCH 12/32] Sphere Vs Box collision detect fix second ed. ... Works now! :3 --- Code/OysterPhysics3D/OysterCollision3D.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Code/OysterPhysics3D/OysterCollision3D.cpp b/Code/OysterPhysics3D/OysterCollision3D.cpp index 95c56f81..5df9761c 100644 --- a/Code/OysterPhysics3D/OysterCollision3D.cpp +++ b/Code/OysterPhysics3D/OysterCollision3D.cpp @@ -459,12 +459,11 @@ namespace Oyster { namespace Collision3D { namespace Utility bool Intersect( const Box &box, const Sphere &sphere ) { // by Dan Andersson - Float4 vCenter = Float4( sphere.center - box.center, 1.0f ); // sphere's center in the box's view space - vCenter = InverseRotationMatrix( box.rotation ) * vCenter; - vCenter.w = 0.0f; + // center: sphere's center in the box's view space + Float4 center = TransformVector( InverseRotationMatrix(box.rotation), Float4(sphere.center - box.center, 0.0f) ); - Float4 e = Max( Float4(-box.boundingOffset, 0.0f) - vCenter, Float4::null ); - e += Max( vCenter - Float4(-box.boundingOffset, 0.0f), Float4::null ); + Float4 e = Max( Float4(-box.boundingOffset, 0.0f) - center, Float4::null ); + e += Max( center - Float4(box.boundingOffset, 0.0f), Float4::null ); if( e.Dot(e) > (sphere.radius * sphere.radius) ) return false; return true; From d0936f9133319fdb6edd109e8fefa16d15bd3c8b Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Wed, 4 Dec 2013 14:22:25 +0100 Subject: [PATCH 13/32] InverseRotationMatrix fixed Compiler overstepping its bound, doing whatever it wants. --- Code/OysterMath/OysterMath.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Code/OysterMath/OysterMath.cpp b/Code/OysterMath/OysterMath.cpp index a82658ee..421ebc0b 100644 --- a/Code/OysterMath/OysterMath.cpp +++ b/Code/OysterMath/OysterMath.cpp @@ -103,7 +103,8 @@ namespace Oyster { namespace Math3D Float4x4 & InverseRotationMatrix( const Float4x4 &rotation, Float4x4 &targetMem ) { - return targetMem = ::LinearAlgebra3D::InverseRotationMatrix( rotation ); +// return targetMem = ::LinearAlgebra3D::InverseRotationMatrix( rotation ); + return targetMem = rotation.GetTranspose(); } Float4x4 & OrientationMatrix( const Float3x3 &rotation, const Float3 &translation, Float4x4 &targetMem ) From 5835a72acc3d1ca18f037b4fdeaf982025e867ff Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Fri, 6 Dec 2013 09:46:30 +0100 Subject: [PATCH 14/32] Setstruct introduction done Can be found as: Physics::Struct::CustomBodyState Physics::ICustomBody::State Is all inline thus no expensive API calls, as intended. Will be expanded to move API call methods from Physics::ICustomBody to it. --- Code/GamePhysics/GamePhysics.vcxproj | 14 +++ Code/GamePhysics/GamePhysics.vcxproj.filters | 6 + .../Implementation/SimpleRigidBody.cpp | 17 +++ .../Implementation/SimpleRigidBody.h | 4 + .../Implementation/SphericalRigidBody.cpp | 17 +++ .../Implementation/SphericalRigidBody.h | 4 + Code/GamePhysics/PhysicsAPI.h | 78 +++++------- Code/GamePhysics/PhysicsStructs-Impl.h | 117 ++++++++++++++++++ Code/GamePhysics/PhysicsStructs.h | 70 +++++++++++ Code/OysterMath/LinearMath.h | 57 ++++++++- Code/OysterMath/OysterMath.cpp | 35 +++++- Code/OysterMath/OysterMath.h | 9 ++ 12 files changed, 373 insertions(+), 55 deletions(-) create mode 100644 Code/GamePhysics/PhysicsStructs-Impl.h create mode 100644 Code/GamePhysics/PhysicsStructs.h diff --git a/Code/GamePhysics/GamePhysics.vcxproj b/Code/GamePhysics/GamePhysics.vcxproj index 540002a1..06e64fd1 100644 --- a/Code/GamePhysics/GamePhysics.vcxproj +++ b/Code/GamePhysics/GamePhysics.vcxproj @@ -91,9 +91,12 @@ Disabled $(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;%(AdditionalIncludeDirectories) _WINDLL;PHYSICS_DLL_EXPORT;%(PreprocessorDefinitions) + false true + + @@ -102,9 +105,12 @@ Disabled $(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;%(AdditionalIncludeDirectories) _WINDLL;PHYSICS_DLL_EXPORT;%(PreprocessorDefinitions) + false true + + @@ -115,11 +121,14 @@ true $(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;%(AdditionalIncludeDirectories) _WINDLL;PHYSICS_DLL_EXPORT;%(PreprocessorDefinitions) + false true true true + + @@ -130,11 +139,14 @@ true $(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;%(AdditionalIncludeDirectories) _WINDLL;PHYSICS_DLL_EXPORT;%(PreprocessorDefinitions) + false true true true + + @@ -154,6 +166,8 @@ + + diff --git a/Code/GamePhysics/GamePhysics.vcxproj.filters b/Code/GamePhysics/GamePhysics.vcxproj.filters index 694a8ec7..15221691 100644 --- a/Code/GamePhysics/GamePhysics.vcxproj.filters +++ b/Code/GamePhysics/GamePhysics.vcxproj.filters @@ -36,6 +36,12 @@ Header Files\Implementation + + Header Files\Include + + + Header Files\Include + diff --git a/Code/GamePhysics/Implementation/SimpleRigidBody.cpp b/Code/GamePhysics/Implementation/SimpleRigidBody.cpp index ea75ffe3..934c843f 100644 --- a/Code/GamePhysics/Implementation/SimpleRigidBody.cpp +++ b/Code/GamePhysics/Implementation/SimpleRigidBody.cpp @@ -42,6 +42,23 @@ UniquePointer SimpleRigidBody::Clone() const return new SimpleRigidBody( *this ); } +SimpleRigidBody::State SimpleRigidBody::GetState() const +{ + return State( this->rigid.box.boundingOffset, this->rigid.box.center, AngularAxis(this->rigid.box.rotation).xyz ); +} + +SimpleRigidBody::State & SimpleRigidBody::GetState( SimpleRigidBody::State &targetMem ) const +{ + return targetMem = State( this->rigid.box.boundingOffset, this->rigid.box.center, AngularAxis(this->rigid.box.rotation).xyz ); +} + +void SimpleRigidBody::SetState( const SimpleRigidBody::State &state ) +{ /** @todo TODO: temporary solution! Need to know it's occtree */ + this->rigid.box.boundingOffset = state.GetReach(); + this->rigid.box.center = state.GetCenterPosition(); + this->rigid.box.rotation = state.GetRotation(); +} + void SimpleRigidBody::CallSubscription( const ICustomBody *proto, const ICustomBody *deuter ) { this->collisionAction( proto, deuter ); diff --git a/Code/GamePhysics/Implementation/SimpleRigidBody.h b/Code/GamePhysics/Implementation/SimpleRigidBody.h index 5e05c9d7..774420c5 100644 --- a/Code/GamePhysics/Implementation/SimpleRigidBody.h +++ b/Code/GamePhysics/Implementation/SimpleRigidBody.h @@ -15,6 +15,10 @@ namespace Oyster { namespace Physics ::Utility::DynamicMemory::UniquePointer Clone() const; + State GetState() const; + State & GetState( State &targetMem ) const; + void SetState( const State &state ); + void CallSubscription( const ICustomBody *proto, const ICustomBody *deuter ); bool IsAffectedByGravity() const; bool Intersects( const ICustomBody &object, ::Oyster::Math::Float timeStepLength, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) const; diff --git a/Code/GamePhysics/Implementation/SphericalRigidBody.cpp b/Code/GamePhysics/Implementation/SphericalRigidBody.cpp index 03ed7d2a..34160192 100644 --- a/Code/GamePhysics/Implementation/SphericalRigidBody.cpp +++ b/Code/GamePhysics/Implementation/SphericalRigidBody.cpp @@ -44,6 +44,23 @@ UniquePointer SphericalRigidBody::Clone() const return new SphericalRigidBody( *this ); } +SphericalRigidBody::State SphericalRigidBody::GetState() const +{ + return State( this->rigid.box.boundingOffset, this->rigid.box.center, AngularAxis(this->rigid.box.rotation).xyz ); +} + +SphericalRigidBody::State & SphericalRigidBody::GetState( SphericalRigidBody::State &targetMem ) const +{ + return targetMem = State( this->rigid.box.boundingOffset, this->rigid.box.center, AngularAxis(this->rigid.box.rotation).xyz ); +} + +void SphericalRigidBody::SetState( const SphericalRigidBody::State &state ) +{ /** @todo TODO: temporary solution! Need to know it's occtree */ + this->rigid.box.boundingOffset = state.GetReach(); + this->rigid.box.center = state.GetCenterPosition(); + this->rigid.box.rotation = state.GetRotation(); +} + void SphericalRigidBody::CallSubscription( const ICustomBody *proto, const ICustomBody *deuter ) { this->collisionAction( proto, deuter ); diff --git a/Code/GamePhysics/Implementation/SphericalRigidBody.h b/Code/GamePhysics/Implementation/SphericalRigidBody.h index a25cba2c..1aca514d 100644 --- a/Code/GamePhysics/Implementation/SphericalRigidBody.h +++ b/Code/GamePhysics/Implementation/SphericalRigidBody.h @@ -16,6 +16,10 @@ namespace Oyster { namespace Physics ::Utility::DynamicMemory::UniquePointer Clone() const; + State GetState() const; + State & GetState( State &targetMem = State() ) const; + void SetState( const State &state ); + void CallSubscription( const ICustomBody *proto, const ICustomBody *deuter ); bool IsAffectedByGravity() const; bool Intersects( const ICustomBody &object, ::Oyster::Math::Float timeStepLength, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) const; diff --git a/Code/GamePhysics/PhysicsAPI.h b/Code/GamePhysics/PhysicsAPI.h index cd720abd..387bf0e6 100644 --- a/Code/GamePhysics/PhysicsAPI.h +++ b/Code/GamePhysics/PhysicsAPI.h @@ -1,4 +1,4 @@ - #ifndef PHYSICS_API_H +#ifndef PHYSICS_API_H #define PHYSICS_API_H #include "OysterCollision3D.h" @@ -17,6 +17,13 @@ namespace Oyster class API; class ICustomBody; + namespace Struct + { + struct SimpleBodyDescription; + struct SphericalBodyDescription; + struct CustomBodyState; + } + enum UpdateState { UpdateState_resting, @@ -32,7 +39,7 @@ namespace Oyster { public: static ::Oyster::Math::Float4x4 & CreateSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius, ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ); - + static ::Oyster::Math::Float4x4 & CreateHollowSphereMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius, ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ); static ::Oyster::Math::Float4x4 & CreateCuboidMatrix( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float width, const ::Oyster::Math::Float depth, ::Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ); @@ -45,8 +52,8 @@ namespace Oyster class PHYSICS_DLL_USAGE API { public: - struct SimpleBodyDescription; - struct SphericalBodyDescription; + typedef Struct::SimpleBodyDescription SimpleBodyDescription; + typedef Struct::SphericalBodyDescription SphericalBodyDescription; typedef void (*EventAction_Destruction)( ::Utility::DynamicMemory::UniquePointer proto ); @@ -237,6 +244,9 @@ namespace Oyster }; typedef SubscriptMessage (*EventAction_Collision)( const ICustomBody *proto, const ICustomBody *deuter ); + typedef Struct::SimpleBodyDescription SimpleBodyDescription; + typedef Struct::SphericalBodyDescription SphericalBodyDescription; + typedef Struct::CustomBodyState State; virtual ~ICustomBody() {}; @@ -251,6 +261,21 @@ namespace Oyster ********************************************************/ virtual void CallSubscription( const ICustomBody *proto, const ICustomBody *deuter ) = 0; + /******************************************************** + * @todo TODO: need doc + ********************************************************/ + virtual State GetState() const = 0; + + /******************************************************** + * @todo TODO: need doc + ********************************************************/ + virtual State & GetState( State &targetMem ) const = 0; + + /******************************************************** + * @todo TODO: need doc + ********************************************************/ + virtual void SetState( const State &state ) = 0; + /******************************************************** * @return true if Engine should apply gravity on this object. ********************************************************/ @@ -397,48 +422,9 @@ namespace Oyster ********************************************************/ virtual void SetMomentum( const ::Oyster::Math::Float3 &worldG ) = 0; }; - - struct API::SimpleBodyDescription - { - ::Oyster::Math::Float4x4 rotation; - ::Oyster::Math::Float3 centerPosition; - ::Oyster::Math::Float3 size; - ::Oyster::Math::Float mass; - ::Oyster::Math::Float4x4 inertiaTensor; - ICustomBody::EventAction_Collision subscription; - bool ignoreGravity; - - SimpleBodyDescription() - { - this->rotation = ::Oyster::Math::Float4x4::identity; - this->centerPosition = ::Oyster::Math::Float3::null; - this->size = ::Oyster::Math::Float3( 1.0f ); - this->mass = 12.0f; - this->inertiaTensor = ::Oyster::Math::Float4x4::identity; - this->subscription = NULL; - this->ignoreGravity = false; - } - }; - - struct API::SphericalBodyDescription - { - ::Oyster::Math::Float4x4 rotation; - ::Oyster::Math::Float3 centerPosition; - ::Oyster::Math::Float radius; - ::Oyster::Math::Float mass; - ICustomBody::EventAction_Collision subscription; - bool ignoreGravity; - - SphericalBodyDescription() - { - this->rotation = ::Oyster::Math::Float4x4::identity; - this->centerPosition = ::Oyster::Math::Float3::null; - this->radius = 0.5f; - this->mass = 10.0f; - this->subscription = NULL; - this->ignoreGravity = false; - } - }; } } + +#include "PhysicsStructs.h" + #endif \ No newline at end of file diff --git a/Code/GamePhysics/PhysicsStructs-Impl.h b/Code/GamePhysics/PhysicsStructs-Impl.h new file mode 100644 index 00000000..3de46ee2 --- /dev/null +++ b/Code/GamePhysics/PhysicsStructs-Impl.h @@ -0,0 +1,117 @@ +#ifndef PHYSICS_STRUCTS_IMPL_H +#define PHYSICS_STRUCTS_IMPL_H + +#include "PhysicsStructs.h" + +namespace Oyster { namespace Physics +{ + namespace Struct + { + inline SimpleBodyDescription::SimpleBodyDescription() + { + this->rotation = ::Oyster::Math::Float4x4::identity; + this->centerPosition = ::Oyster::Math::Float3::null; + this->size = ::Oyster::Math::Float3( 1.0f ); + this->mass = 12.0f; + this->inertiaTensor = ::Oyster::Math::Float4x4::identity; + this->subscription = NULL; + this->ignoreGravity = false; + } + + inline SphericalBodyDescription::SphericalBodyDescription() + { + this->rotation = ::Oyster::Math::Float4x4::identity; + this->centerPosition = ::Oyster::Math::Float3::null; + this->radius = 0.5f; + this->mass = 10.0f; + this->subscription = NULL; + this->ignoreGravity = false; + } + + + inline CustomBodyState::CustomBodyState( const ::Oyster::Math::Float3 &reach, const ::Oyster::Math::Float3 ¢erPos, const ::Oyster::Math::Float3 &rotation ) + { + this->reach = ::Oyster::Math::Float4( reach, 0.0f ); + this->centerPos = ::Oyster::Math::Float4( centerPos, 1.0f ); + this->angularAxis = ::Oyster::Math::Float4( rotation, 0.0f ); + this->isSpatiallyAltered = this->isDisturbed = false; + } + + inline CustomBodyState & CustomBodyState::operator = ( const CustomBodyState &state ) + { + this->reach = state.reach; + this->centerPos = state.centerPos; + this->angularAxis = state.angularAxis; + + this->isSpatiallyAltered = state.isSpatiallyAltered; + this->isDisturbed = state.isDisturbed; + return *this; + } + + inline const ::Oyster::Math::Float4 & CustomBodyState::GetReach() const + { + return this->reach; + } + + inline ::Oyster::Math::Float4 CustomBodyState::GetSize() const + { + return 2.0f * this->GetReach(); + } + + inline const ::Oyster::Math::Float4 & CustomBodyState::GetCenterPosition() const + { + return this->centerPos; + } + + inline const ::Oyster::Math::Float4 & CustomBodyState::GetAngularAxis() const + { + return this->angularAxis; + } + + inline ::Oyster::Math::Float4x4 CustomBodyState::GetRotation() const + { + return ::Oyster::Math3D::RotationMatrix( this->GetAngularAxis().xyz ); + } + + inline void CustomBodyState::SetSize( const ::Oyster::Math::Float3 &size ) + { + this->SetReach( 0.5f * size ); + } + + inline void CustomBodyState::SetReach( const ::Oyster::Math::Float3 &halfSize ) + { + this->reach.xyz = halfSize; + this->reach = ::Utility::Value::Max( this->reach, ::Oyster::Math::Float4::null ); + this->isSpatiallyAltered = this->isDisturbed = true; + } + + inline void CustomBodyState::SetCenterPosition( const ::Oyster::Math::Float3 ¢erPos ) + { + this->centerPos.xyz = centerPos; + this->isSpatiallyAltered = this->isDisturbed = true; + } + + inline void CustomBodyState::SetRotation( const ::Oyster::Math::Float3 &angularAxis ) + { + this->angularAxis.xyz = angularAxis; + this->isSpatiallyAltered = this->isDisturbed = true; + } + + inline void CustomBodyState::SetRotation( const ::Oyster::Math::Float4x4 &rotation ) + { + this->SetRotation( ::Oyster::Math3D::AngularAxis(rotation).xyz ); + } + + inline bool CustomBodyState::IsSpatiallyAltered() const + { + return this->isSpatiallyAltered; + } + + inline bool CustomBodyState::IsDisturbed() const + { + return this->isDisturbed; + } + } +} } + +#endif \ No newline at end of file diff --git a/Code/GamePhysics/PhysicsStructs.h b/Code/GamePhysics/PhysicsStructs.h new file mode 100644 index 00000000..c1f74640 --- /dev/null +++ b/Code/GamePhysics/PhysicsStructs.h @@ -0,0 +1,70 @@ +#ifndef PHYSICS_STRUCTS_H +#define PHYSICS_STRUCTS_H + +#include "OysterMath.h" +#include "PhysicsAPI.h" + +namespace Oyster { namespace Physics +{ + namespace Struct + { + struct SimpleBodyDescription + { + ::Oyster::Math::Float4x4 rotation; + ::Oyster::Math::Float3 centerPosition; + ::Oyster::Math::Float3 size; + ::Oyster::Math::Float mass; + ::Oyster::Math::Float4x4 inertiaTensor; + ::Oyster::Physics::ICustomBody::EventAction_Collision subscription; + bool ignoreGravity; + + SimpleBodyDescription(); + }; + + struct SphericalBodyDescription + { + ::Oyster::Math::Float4x4 rotation; + ::Oyster::Math::Float3 centerPosition; + ::Oyster::Math::Float radius; + ::Oyster::Math::Float mass; + ::Oyster::Physics::ICustomBody::EventAction_Collision subscription; + bool ignoreGravity; + + SphericalBodyDescription(); + }; + + struct CustomBodyState + { + public: + CustomBodyState( const ::Oyster::Math::Float3 &reach = ::Oyster::Math::Float3::null, + const ::Oyster::Math::Float3 ¢erPos = ::Oyster::Math::Float3::null, + const ::Oyster::Math::Float3 &rotation = ::Oyster::Math::Float3::null ); + + CustomBodyState & operator = ( const CustomBodyState &state ); + + const ::Oyster::Math::Float4 & GetReach() const; + ::Oyster::Math::Float4 GetSize() const; + const ::Oyster::Math::Float4 & GetCenterPosition() const; + const ::Oyster::Math::Float4 & GetAngularAxis() const; + ::Oyster::Math::Float4x4 GetRotation() const; + + void SetSize( const ::Oyster::Math::Float3 &size ); + void SetReach( const ::Oyster::Math::Float3 &halfSize ); + void SetCenterPosition( const ::Oyster::Math::Float3 ¢erPos ); + void SetRotation( const ::Oyster::Math::Float3 &angularAxis ); + void SetRotation( const ::Oyster::Math::Float4x4 &rotation ); + + bool IsSpatiallyAltered() const; + bool IsDisturbed() const; + + private: + ::Oyster::Math::Float4 reach, centerPos, angularAxis; + + bool isSpatiallyAltered, isDisturbed; + }; + } +} } + +#include "PhysicsStructs-Impl.h" + +#endif \ No newline at end of file diff --git a/Code/OysterMath/LinearMath.h b/Code/OysterMath/LinearMath.h index 0495939d..8bca1c19 100644 --- a/Code/OysterMath/LinearMath.h +++ b/Code/OysterMath/LinearMath.h @@ -11,6 +11,27 @@ #include "Quaternion.h" #include +namespace std +{ + template + inline ::LinearAlgebra::Vector2 asin( const ::LinearAlgebra::Vector2 &vec ) + { + return ::LinearAlgebra::Vector2( asin(vec.x), asin(vec.y) ); + } + + template + inline ::LinearAlgebra::Vector3 asin( const ::LinearAlgebra::Vector3 &vec ) + { + return ::LinearAlgebra::Vector3( asin(vec.x), asin(vec.y), asin(vec.z) ); + } + + template + inline ::LinearAlgebra::Vector4 asin( const ::LinearAlgebra::Vector4 &vec ) + { + return ::LinearAlgebra::Vector4( asin(vec.x), asin(vec.y), asin(vec.z), asin(vec.w) ); + } +} + // x2 template @@ -233,6 +254,18 @@ namespace LinearAlgebra2D namespace LinearAlgebra3D { + template + inline ::LinearAlgebra::Vector4 AngularAxis( const ::LinearAlgebra::Matrix3x3 &rotationMatrix ) + { + return ::std::asin( ::LinearAlgebra::Vector4(rotationMatrix.v[1].z, rotationMatrix.v[2].x, rotationMatrix.v[0].y, 1) ); + } + + template + inline ::LinearAlgebra::Vector4 AngularAxis( const ::LinearAlgebra::Matrix4x4 &rotationMatrix ) + { + return ::std::asin( ::LinearAlgebra::Vector4(rotationMatrix.v[1].z, rotationMatrix.v[2].x, rotationMatrix.v[0].y, 1) ); + } + template inline ::LinearAlgebra::Matrix4x4 & TranslationMatrix( const ::LinearAlgebra::Vector3 &position, ::LinearAlgebra::Matrix4x4 &targetMem = ::LinearAlgebra::Matrix4x4() ) { @@ -286,7 +319,9 @@ namespace LinearAlgebra3D template inline ::LinearAlgebra::Matrix3x3 & RotationMatrix_AxisZ( const ScalarType &radian, ::LinearAlgebra::Matrix3x3 &targetMem = ::LinearAlgebra::Matrix3x3() ) - { return ::LinearAlgebra2D::RotationMatrix( radian, targetMem ); } + { + return ::LinearAlgebra2D::RotationMatrix( radian, targetMem ); + } template inline ::LinearAlgebra::Matrix4x4 & RotationMatrix_AxisZ( const ScalarType &radian, ::LinearAlgebra::Matrix4x4 &targetMem = ::LinearAlgebra::Matrix4x4() ) @@ -300,7 +335,21 @@ namespace LinearAlgebra3D } template - ::LinearAlgebra::Matrix4x4 & RotationMatrix( const ::LinearAlgebra::Vector3 &normalizedAxis, const ScalarType &radian, ::LinearAlgebra::Matrix4x4 &targetMem ) + inline ::LinearAlgebra::Matrix4x4 RotationMatrix( const ::LinearAlgebra::Vector3 &angularAxis ) + { + ScalarType radian = angularAxis.GetMagnitude(); + if( radian != 0 ) + { + return RotationMatrix( angularAxis / radian, radian ); + } + else + { + return ::LinearAlgebra::Matrix4x4::identity; + } + } + + template + ::LinearAlgebra::Matrix4x4 & RotationMatrix( const ::LinearAlgebra::Vector3 &normalizedAxis, const ScalarType &radian, ::LinearAlgebra::Matrix4x4 &targetMem = ::LinearAlgebra::Matrix4x4() ) { /// TODO: not verified ScalarType r = radian * 0.5f, s = std::sin( r ), @@ -462,7 +511,7 @@ namespace LinearAlgebra3D ::LinearAlgebra::Matrix4x4 & ProjectionMatrix_Perspective( const ScalarType &vertFoV, const ScalarType &aspect, const ScalarType &nearClip, const ScalarType &farClip, ::LinearAlgebra::Matrix4x4 &targetMem = ::LinearAlgebra::Matrix4x4() ) { ScalarType fov = 1 / ::std::tan( vertFoV * 0.5f ), - dDepth = farClip / (farClip - nearClip); + dDepth = farClip / (farClip - nearClip); return targetMem = ::LinearAlgebra::Matrix4x4( fov / aspect, 0, 0, 0, 0, fov, 0, 0, 0, 0, dDepth, -(dDepth * nearClip), @@ -473,7 +522,7 @@ namespace LinearAlgebra3D ::LinearAlgebra::Matrix4x4 & ProjectionMatrix_Perspective( const ScalarType &left, const ScalarType &right, const ScalarType &top, const ScalarType &bottom, const ScalarType &nearClip, const ScalarType &farClip, ::LinearAlgebra::Matrix4x4 &targetMem = ::LinearAlgebra::Matrix4x4() ) { /** @todo TODO: not tested */ ScalarType fov = 1 / ::std::tan( vertFoV * 0.5f ), - dDepth = farClip / (farClip - nearClip); + dDepth = farClip / (farClip - nearClip); return targetMem = ::LinearAlgebra::Matrix4x4( 2*nearClip/(right - left), 0, -(right + left)/(right - left), 0, 0, 2*nearClip/(top - bottom), -(top + bottom)/(top - bottom), 0, 0, 0, dDepth, -(dDepth * nearClip), diff --git a/Code/OysterMath/OysterMath.cpp b/Code/OysterMath/OysterMath.cpp index 421ebc0b..cf9fa8ae 100644 --- a/Code/OysterMath/OysterMath.cpp +++ b/Code/OysterMath/OysterMath.cpp @@ -81,20 +81,45 @@ namespace Oyster { namespace Math2D namespace Oyster { namespace Math3D { + Float4 AngularAxis( const Float3x3 &rotationMatrix ) + { + return ::LinearAlgebra3D::AngularAxis( rotationMatrix ); + } + + Float4 AngularAxis( const Float4x4 &rotationMatrix ) + { + return ::LinearAlgebra3D::AngularAxis( rotationMatrix ); + } + Float4x4 & TranslationMatrix( const Float3 &position, Float4x4 &targetMem ) - { return ::LinearAlgebra3D::TranslationMatrix( position, targetMem ); } + { + return ::LinearAlgebra3D::TranslationMatrix( position, targetMem ); + } Float4x4 & RotationMatrix_AxisX( const Float &radian, Float4x4 &targetMem ) - { return ::LinearAlgebra3D::RotationMatrix_AxisX( radian, targetMem ); } + { + return ::LinearAlgebra3D::RotationMatrix_AxisX( radian, targetMem ); + } Float4x4 & RotationMatrix_AxisY( const Float &radian, Float4x4 &targetMem ) - { return ::LinearAlgebra3D::RotationMatrix_AxisY( radian, targetMem ); } + { + return ::LinearAlgebra3D::RotationMatrix_AxisY( radian, targetMem ); + } Float4x4 & RotationMatrix_AxisZ( const Float &radian, Float4x4 &targetMem ) - { return ::LinearAlgebra3D::RotationMatrix_AxisZ( radian, targetMem ); } + { + return ::LinearAlgebra3D::RotationMatrix_AxisZ( radian, targetMem ); + } + + Float4x4 & RotationMatrix( const Float3 &angularAxis, Float4x4 &targetMem ) + { + return targetMem = ::LinearAlgebra3D::RotationMatrix( angularAxis ); + } Float4x4 & RotationMatrix( const Float &radian, const Float3 &normalizedAxis, Float4x4 &targetMem ) - { return ::LinearAlgebra3D::RotationMatrix( normalizedAxis, radian, targetMem ); } + { + return ::LinearAlgebra3D::RotationMatrix( normalizedAxis, radian, targetMem ); + } Float3x3 & InverseRotationMatrix( const Float3x3 &rotation, Float3x3 &targetMem ) { diff --git a/Code/OysterMath/OysterMath.h b/Code/OysterMath/OysterMath.h index ab3b307f..72fe7478 100644 --- a/Code/OysterMath/OysterMath.h +++ b/Code/OysterMath/OysterMath.h @@ -147,6 +147,12 @@ namespace Oyster { namespace Math3D /// Oyster's native math library specialized { using namespace ::Oyster::Math; // deliberate inheritance from ::Oyster::Math namespace + //! Extracts the angularAxis from rotationMatrix + Float4 AngularAxis( const Float3x3 &rotationMatrix ); + + //! Extracts the angularAxis from rotationMatrix + Float4 AngularAxis( const Float4x4 &rotationMatrix ); + /// Sets and returns targetMem to a translationMatrix with position as translation. Float4x4 & TranslationMatrix( const Float3 &position, Float4x4 &targetMem = Float4x4() ); @@ -159,6 +165,9 @@ namespace Oyster { namespace Math3D /// Oyster's native math library specialized /// Sets and returns targetMem as an counterclockwise rotation matrix around the global Z-axis Float4x4 & RotationMatrix_AxisZ( const Float &radian, Float4x4 &targetMem = Float4x4() ); + /// Sets and returns targetMem as an counterclockwise rotation matrix around the angularAxis. + Float4x4 & RotationMatrix( const Float3 &angularAxis, Float4x4 &targetMem = Float4x4() ); + /// Sets and returns targetMem as an counterclockwise rotation matrix around the normalizedAxis. /// Please make sure normalizedAxis is normalized. Float4x4 & RotationMatrix( const Float &radian, const Float3 &normalizedAxis, Float4x4 &targetMem = Float4x4() ); From 597891acfe536cc3c71c610763a2eda75b0720ae Mon Sep 17 00:00:00 2001 From: dean11 Date: Fri, 6 Dec 2013 11:46:47 +0100 Subject: [PATCH 15/32] Misc - Added more fetures to Smart pointers --- .../Resource/Loaders/CustomLoader.cpp.orig | 73 -------- Code/Misc/Resource/OysterResource.h.orig | 162 ------------------ Code/Misc/Utilities-Impl.h | 60 ++++++- Code/Misc/Utilities.h | 21 ++- 4 files changed, 67 insertions(+), 249 deletions(-) delete mode 100644 Code/Misc/Resource/Loaders/CustomLoader.cpp.orig delete mode 100644 Code/Misc/Resource/OysterResource.h.orig diff --git a/Code/Misc/Resource/Loaders/CustomLoader.cpp.orig b/Code/Misc/Resource/Loaders/CustomLoader.cpp.orig deleted file mode 100644 index a37c0a76..00000000 --- a/Code/Misc/Resource/Loaders/CustomLoader.cpp.orig +++ /dev/null @@ -1,73 +0,0 @@ -///////////////////////////////////////////////////////////////////// -// Created by [Dennis Andersen] [2013] -///////////////////////////////////////////////////////////////////// - -#include "..\OResource.h" -#include "..\..\Utilities.h" - -#include - -using namespace Oyster::Resource; - - -OResource* OResource::CustomLoader(const wchar_t filename[], CustomLoadFunction fnc) -{ -<<<<<<< HEAD - CustomData &data = fnc(filename); - - if(!data.loadedData) return 0; - if(!data.resourceUnloadFnc) return 0; - OHRESOURCE n = (OHRESOURCE)data.loadedData; - OResource *resource = new OResource(n, ResourceType_UNKNOWN, 0, 0, filename); - - resource->customData = new CustomResourceData(); - resource->customData->unloadingFunction = data.resourceUnloadFnc; - //resource->resourceData = (OHRESOURCE)data.loadedData; -======= - CustomData data; - memset(&data, 0, sizeof(CustomData)); - - fnc(filename, data); - - if(!data.loadedData) - { - return 0; - } - if(!data.resourceUnloadFnc) - { - return 0; - } - /** For some wierd reason that i don't understand when trying to send data.loadedData directly as a - * parameter to OResource constructor, the value is changed when it arrives in the constructor. - * Doing it like this, storing in a temporary variable, the value stays correct. (What the fuck! I must be overloking something...)*/ - //OHRESOURCE temp = data.loadedData; - OResource *resource = new OResource(data.loadedData, ResourceType_UNKNOWN, 0, 0, filename); - - resource->customData = new CustomResourceData(); - resource->customData->unloadingFunction = data.resourceUnloadFnc; ->>>>>>> d08644e8e1ecc56f4d9dfa6a9aa33df94d9e655a - resource->customData->loadingFunction = fnc; - - return resource; -} -void OResource::CustomUnloader() -{ - this->customData->unloadingFunction(this->resourceData); -} -OResource* OResource::CustomReloader() -{ - CustomUnloader(); - - CustomData data; - memset(&data, 0, sizeof(CustomData)); - - this->customData->loadingFunction(this->resourceFilename.c_str(), data); - this->resourceData = (OHRESOURCE)data.loadedData; - - if(data.resourceUnloadFnc) - { - this->customData->unloadingFunction = data.resourceUnloadFnc; - } - return this; -} - diff --git a/Code/Misc/Resource/OysterResource.h.orig b/Code/Misc/Resource/OysterResource.h.orig deleted file mode 100644 index 2ec147e8..00000000 --- a/Code/Misc/Resource/OysterResource.h.orig +++ /dev/null @@ -1,162 +0,0 @@ -///////////////////////////////////////////////////////////////////// -// Created by [Dennis Andersen] [2013] -///////////////////////////////////////////////////////////////////// - -#ifndef MISC_OYSTER_RESOURCE_H -#define MISC_OYSTER_RESOURCE_H - - -namespace Oyster -{ - namespace Resource - { - struct CustomData; - /** A Resource handle representing various resources */ - typedef void* OHRESOURCE; - /** Typedef on a fuction required for custom unloading */ - typedef void(*CustomUnloadFunction)(void* loadedData); - /** Typedef on a fuction required for custom loading */ -<<<<<<< HEAD - typedef CustomData&(*CustomLoadFunction)(const wchar_t filename[]); -======= - typedef void(*CustomLoadFunction)(const wchar_t filename[], CustomData& outData); ->>>>>>> d08644e8e1ecc56f4d9dfa6a9aa33df94d9e655a - - /** An enum class representing all avalible resources that is supported. */ - enum ResourceType - { - //Byte - ResourceType_Byte_Raw, /**< Handle can be interpeted as char[] or char* */ - ResourceType_Byte_ANSI, /**< Handle can be interpeted as char[] or char* */ - ResourceType_Byte_UTF8, /**< Handle can be interpeted as char[] or char* */ - ResourceType_Byte_UNICODE, /**< Handle can be interpeted as char[] or char* */ - ResourceType_Byte_UTF16LE, /**< Handle can be interpeted as char[] or char* */ - - ResourceType_COUNT, /**< Not used. */ - - ResourceType_UNKNOWN = -1, /**< Handle can be interpeted as void* */ - ResourceType_INVALID = -2, /**< Invalid or non existing resource */ - }; - - /** A struct to fill when doing a custom resource Load. */ - struct CustomData - { - void* loadedData; // SmartPointer::SmartPointer() :_rc(0), _ptr(0) { } + template SmartPointer::SmartPointer(UniquePointer& p) + :_ptr(p.Release()) + { + this->_rc = new ReferenceCount(); + this->_rc->Incref(); + } template SmartPointer::SmartPointer(T* p) :_ptr(p) { @@ -244,6 +250,30 @@ namespace Utility } return *this; } + template SmartPointer& SmartPointer::operator= (UniquePointer& p) + { + //Last to go? + if(this->_rc) + { + if(this->_rc->Decref() == 0) + { + //Call child specific + Destroy(); + this->_rc = new ReferenceCount(); + } + } + else + { + if(p) this->_rc = new ReferenceCount(); + } + + if(this->_rc) + this->_rc->Incref(); + + this->_ptr = p.Release(); + + return *this; + } template SmartPointer& SmartPointer::operator= (T* p) { if (this->_ptr != p) @@ -266,19 +296,19 @@ namespace Utility } return *this; } - template inline bool SmartPointer::operator== (const SmartPointer& d) + template inline bool SmartPointer::operator== (const SmartPointer& d) const { return d._ptr == this->_ptr; } - template inline bool SmartPointer::operator== (const T& p) + template inline bool SmartPointer::operator== (const T& p) const { return &p == this->_ptr; } - template inline bool SmartPointer::operator!= (const SmartPointer& d) + template inline bool SmartPointer::operator!= (const SmartPointer& d) const { return d._ptr != this->_ptr; } - template inline bool SmartPointer::operator!= (const T& p) + template inline bool SmartPointer::operator!= (const T& p) const { return &p != this->_ptr; } @@ -286,15 +316,31 @@ namespace Utility { return *this->_ptr; } + template inline const T& SmartPointer::operator* () const + { + return *this->_ptr; + } template inline T* SmartPointer::operator-> () { return this->_ptr; } - template inline SmartPointer::operator T* () + template inline const T* SmartPointer::operator-> () const { return this->_ptr; } - template inline SmartPointer::operator bool() + template inline SmartPointer::operator T* () const + { + return this->_ptr; + } + template inline SmartPointer::operator const T* () const + { + return this->_ptr; + } + template inline SmartPointer::operator T& () const + { + return *this->_ptr; + } + template inline SmartPointer::operator bool() const { return (this->_ptr != 0); } @@ -302,7 +348,7 @@ namespace Utility { return this->_ptr; } - template inline bool SmartPointer::IsValid() + template inline bool SmartPointer::IsValid() const { return (this->_ptr != NULL) ? true : false; } diff --git a/Code/Misc/Utilities.h b/Code/Misc/Utilities.h index e541e1df..aaec016a 100644 --- a/Code/Misc/Utilities.h +++ b/Code/Misc/Utilities.h @@ -205,29 +205,36 @@ namespace Utility public: SmartPointer(); + SmartPointer(UniquePointer& up); SmartPointer(T* p); SmartPointer(const SmartPointer& d); virtual~SmartPointer(); SmartPointer& operator= (const SmartPointer& p); + SmartPointer& operator= (UniquePointer& p); SmartPointer& operator= (T* p); - bool operator== (const SmartPointer& d); - bool operator== (const T& p); - bool operator!= (const SmartPointer& d); - bool operator!= (const T& p); + bool operator== (const SmartPointer& d) const; + bool operator== (const T& p) const; + bool operator!= (const SmartPointer& d) const; + bool operator!= (const T& p) const; T& operator* (); + const T& operator* () const; T* operator-> (); - operator T* (); - operator bool(); + const T* operator-> () const; + operator T* () const; + operator const T* () const; + operator T& () const; + operator bool() const; /** * Returns the connected pointer */ T* Get(); + T* Get() const; /** Checks if the pointer is valid (not NULL) * Returns true for valid, else false. */ - bool IsValid(); + bool IsValid() const; }; } From 226bbcc8af8227a17b4d2021952caa960dec33fa Mon Sep 17 00:00:00 2001 From: dean11 Date: Mon, 9 Dec 2013 22:55:22 +0100 Subject: [PATCH 16/32] MISC - Added a release feature in smartpointers --- Code/DanBias.sln | 225 +++++++++++++++++++++++-------------- Code/Misc/Utilities-Impl.h | 19 +++- Code/Misc/Utilities.h | 5 + 3 files changed, 159 insertions(+), 90 deletions(-) diff --git a/Code/DanBias.sln b/Code/DanBias.sln index 2e047aee..43d5838d 100644 --- a/Code/DanBias.sln +++ b/Code/DanBias.sln @@ -23,13 +23,26 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OysterNetworkServer", "Netw EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NetworkDependencies", "Network\NetworkDependencies\NetworkDependencies.vcxproj", "{C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameLogic", "GameLogic\GameLogic.vcxproj", "{B1195BB9-B3A5-47F0-906C-8DEA384D1520}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GamePhysics", "GamePhysics\GamePhysics.vcxproj", "{104FA3E9-94D9-4E1D-A941-28A03BC8A095}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tester", "Tester\Tester.vcxproj", "{1B3BEA4C-CF75-438A-9693-60FB8444BBF3}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasGame", "DanBiasGame\DanBiasGame.vcxproj", "{2A1BC987-AF42-4500-802D-89CD32FC1309}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasGame", "Game\DanBiasGame\DanBiasGame.vcxproj", "{2A1BC987-AF42-4500-802D-89CD32FC1309}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Game", "Game", "{20720CA7-795C-45AD-A302-9383A6DD503A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameLogic", "Game\GameLogic\GameLogic.vcxproj", "{B1195BB9-B3A5-47F0-906C-8DEA384D1520}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasServer", "Game\DanBiasServer\DanBiasServer.vcxproj", "{52380DAA-0F4A-4D97-8E57-98DF39319CAF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasLauncher", "Game\DanBiasLauncher\DanBiasLauncher.vcxproj", "{8690FDDF-C5B7-4C42-A337-BD5243F29B85}" + ProjectSection(ProjectDependencies) = postProject + {52380DAA-0F4A-4D97-8E57-98DF39319CAF} = {52380DAA-0F4A-4D97-8E57-98DF39319CAF} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NetworkAPI", "Network\NetworkAPI\NetworkAPI.vcxproj", "{460D625F-2AC9-4559-B809-0BA89CEAEDF4}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameProtocols", "Game\GameProtocols\GameProtocols.vcxproj", "{DA2AA800-ED64-4649-8B3B-E7F1E3968B78}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -41,126 +54,146 @@ Global Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Mixed Platforms.ActiveCfg = Release|x64 + {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Mixed Platforms.Build.0 = Release|x64 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Win32.ActiveCfg = Debug|Win32 - {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Win32.Build.0 = Debug|Win32 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|x64.ActiveCfg = Debug|x64 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|x64.Build.0 = Debug|x64 - {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Release|Mixed Platforms.Build.0 = Release|Win32 + {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Release|Mixed Platforms.ActiveCfg = Release|x64 + {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Release|Mixed Platforms.Build.0 = Release|x64 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Release|Win32.ActiveCfg = Release|Win32 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Release|Win32.Build.0 = Release|Win32 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Release|x64.ActiveCfg = Release|x64 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Release|x64.Build.0 = Release|x64 - {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|Mixed Platforms.ActiveCfg = Release|x64 + {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|Mixed Platforms.Build.0 = Release|x64 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|Win32.ActiveCfg = Debug|Win32 - {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|Win32.Build.0 = Debug|Win32 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|x64.ActiveCfg = Debug|x64 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|x64.Build.0 = Debug|x64 - {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Release|Mixed Platforms.Build.0 = Release|Win32 + {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Release|Mixed Platforms.ActiveCfg = Release|x64 + {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Release|Mixed Platforms.Build.0 = Release|x64 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Release|Win32.ActiveCfg = Release|Win32 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Release|Win32.Build.0 = Release|Win32 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Release|x64.ActiveCfg = Release|x64 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Release|x64.Build.0 = Release|x64 - {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Debug|Mixed Platforms.ActiveCfg = Release|x64 + {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Debug|Mixed Platforms.Build.0 = Release|x64 {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Debug|Win32.ActiveCfg = Debug|Win32 - {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Debug|Win32.Build.0 = Debug|Win32 {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Debug|x64.ActiveCfg = Debug|x64 {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Debug|x64.Build.0 = Debug|x64 - {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Release|Mixed Platforms.Build.0 = Release|Win32 + {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Release|Mixed Platforms.ActiveCfg = Release|x64 + {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Release|Mixed Platforms.Build.0 = Release|x64 {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Release|Win32.ActiveCfg = Release|Win32 {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Release|Win32.Build.0 = Release|Win32 {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Release|x64.ActiveCfg = Release|x64 {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Release|x64.Build.0 = Release|x64 - {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Debug|Mixed Platforms.ActiveCfg = Release|x64 + {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Debug|Mixed Platforms.Build.0 = Release|x64 {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Debug|Win32.ActiveCfg = Debug|Win32 - {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Debug|Win32.Build.0 = Debug|Win32 {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Debug|x64.ActiveCfg = Debug|x64 {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Debug|x64.Build.0 = Debug|x64 - {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Release|Mixed Platforms.Build.0 = Release|Win32 + {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Release|Mixed Platforms.ActiveCfg = Release|x64 + {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Release|Mixed Platforms.Build.0 = Release|x64 {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Release|Win32.ActiveCfg = Release|Win32 {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Release|Win32.Build.0 = Release|Win32 {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Release|x64.ActiveCfg = Release|x64 {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Release|x64.Build.0 = Release|x64 - {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|Mixed Platforms.ActiveCfg = Release|x64 + {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|Mixed Platforms.Build.0 = Release|x64 {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|Win32.ActiveCfg = Debug|Win32 - {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|Win32.Build.0 = Debug|Win32 {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|x64.ActiveCfg = Debug|x64 {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|x64.Build.0 = Debug|x64 - {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Release|Mixed Platforms.Build.0 = Release|Win32 + {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Release|Mixed Platforms.ActiveCfg = Release|x64 + {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Release|Mixed Platforms.Build.0 = Release|x64 {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Release|Win32.ActiveCfg = Release|Win32 {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Release|Win32.Build.0 = Release|Win32 {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Release|x64.ActiveCfg = Release|x64 {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Release|x64.Build.0 = Release|x64 - {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|Mixed Platforms.ActiveCfg = Release|x64 + {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|Mixed Platforms.Build.0 = Release|x64 {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|Win32.ActiveCfg = Debug|Win32 - {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|Win32.Build.0 = Debug|Win32 {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|x64.ActiveCfg = Debug|x64 {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|x64.Build.0 = Debug|x64 - {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Release|Mixed Platforms.Build.0 = Release|Win32 + {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Release|Mixed Platforms.ActiveCfg = Release|x64 + {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Release|Mixed Platforms.Build.0 = Release|x64 {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Release|Win32.ActiveCfg = Release|Win32 {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Release|Win32.Build.0 = Release|Win32 {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Release|x64.ActiveCfg = Release|x64 {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Release|x64.Build.0 = Release|x64 - {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Mixed Platforms.ActiveCfg = Release|x64 + {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Mixed Platforms.Build.0 = Release|x64 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Win32.ActiveCfg = Debug|Win32 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Win32.Build.0 = Debug|Win32 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|x64.ActiveCfg = Debug|x64 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|x64.Build.0 = Debug|x64 - {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Release|Mixed Platforms.Build.0 = Release|Win32 + {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Release|Mixed Platforms.ActiveCfg = Release|x64 + {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Release|Mixed Platforms.Build.0 = Release|x64 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Release|Win32.ActiveCfg = Release|Win32 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Release|Win32.Build.0 = Release|Win32 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Release|x64.ActiveCfg = Release|x64 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Release|x64.Build.0 = Release|x64 - {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|Mixed Platforms.ActiveCfg = Release|x64 + {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|Mixed Platforms.Build.0 = Release|x64 {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|Win32.ActiveCfg = Debug|Win32 - {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|Win32.Build.0 = Debug|Win32 {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|x64.ActiveCfg = Debug|x64 {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|x64.Build.0 = Debug|x64 - {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Release|Mixed Platforms.Build.0 = Release|Win32 + {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Release|Mixed Platforms.ActiveCfg = Release|x64 + {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Release|Mixed Platforms.Build.0 = Release|x64 {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Release|Win32.ActiveCfg = Release|Win32 {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Release|Win32.Build.0 = Release|Win32 {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Release|x64.ActiveCfg = Release|x64 {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Release|x64.Build.0 = Release|x64 - {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|Mixed Platforms.ActiveCfg = Release|x64 + {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|Mixed Platforms.Build.0 = Release|x64 {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|Win32.ActiveCfg = Debug|Win32 - {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|Win32.Build.0 = Debug|Win32 {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|x64.ActiveCfg = Debug|x64 {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|x64.Build.0 = Debug|x64 - {6A066806-F43F-4B31-A4E3-57179674F460}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {6A066806-F43F-4B31-A4E3-57179674F460}.Release|Mixed Platforms.Build.0 = Release|Win32 + {6A066806-F43F-4B31-A4E3-57179674F460}.Release|Mixed Platforms.ActiveCfg = Release|x64 + {6A066806-F43F-4B31-A4E3-57179674F460}.Release|Mixed Platforms.Build.0 = Release|x64 {6A066806-F43F-4B31-A4E3-57179674F460}.Release|Win32.ActiveCfg = Release|Win32 {6A066806-F43F-4B31-A4E3-57179674F460}.Release|Win32.Build.0 = Release|Win32 {6A066806-F43F-4B31-A4E3-57179674F460}.Release|x64.ActiveCfg = Release|x64 {6A066806-F43F-4B31-A4E3-57179674F460}.Release|x64.Build.0 = Release|x64 - {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Mixed Platforms.ActiveCfg = Release|x64 + {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Mixed Platforms.Build.0 = Release|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Win32.ActiveCfg = Debug|Win32 - {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Win32.Build.0 = Debug|Win32 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|x64.ActiveCfg = Debug|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|x64.Build.0 = Debug|x64 - {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Release|Mixed Platforms.Build.0 = Release|Win32 + {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Release|Mixed Platforms.ActiveCfg = Release|x64 + {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Release|Mixed Platforms.Build.0 = Release|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Release|Win32.ActiveCfg = Release|Win32 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Release|Win32.Build.0 = Release|Win32 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Release|x64.ActiveCfg = Release|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Release|x64.Build.0 = Release|x64 + {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Mixed Platforms.ActiveCfg = Release|Win32 + {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Mixed Platforms.Build.0 = Release|Win32 + {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Win32.ActiveCfg = Debug|Win32 + {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Win32.Build.0 = Debug|Win32 + {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|x64.ActiveCfg = Debug|x64 + {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|x64.Build.0 = Debug|x64 + {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Mixed Platforms.Build.0 = Release|Win32 + {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Win32.ActiveCfg = Release|Win32 + {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Win32.Build.0 = Release|Win32 + {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|x64.ActiveCfg = Release|x64 + {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|x64.Build.0 = Release|x64 + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|Mixed Platforms.ActiveCfg = Release|Win32 + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|Win32.ActiveCfg = Debug|Win32 + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|x64.ActiveCfg = Debug|Win32 + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|Win32.ActiveCfg = Release|Win32 + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|x64.ActiveCfg = Release|Win32 + {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.ActiveCfg = Debug|Win32 + {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.ActiveCfg = Debug|x64 + {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.Build.0 = Debug|x64 + {2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|Mixed Platforms.Build.0 = Release|Win32 + {2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|Win32.ActiveCfg = Release|Win32 + {2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|Win32.Build.0 = Release|Win32 + {2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|x64.ActiveCfg = Release|x64 + {2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|x64.Build.0 = Release|x64 {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Win32.ActiveCfg = Debug|Win32 @@ -171,40 +204,54 @@ Global {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|Mixed Platforms.Build.0 = Release|Win32 {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|Win32.ActiveCfg = Release|Win32 {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|Win32.Build.0 = Release|Win32 - {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|x64.ActiveCfg = Release|Win32 - {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Win32.ActiveCfg = Debug|Win32 - {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Win32.Build.0 = Debug|Win32 - {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|x64.ActiveCfg = Debug|x64 - {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|x64.Build.0 = Debug|x64 - {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Mixed Platforms.Build.0 = Release|Win32 - {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Win32.ActiveCfg = Release|Win32 - {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Win32.Build.0 = Release|Win32 - {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|x64.ActiveCfg = Release|Win32 - {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|Win32.ActiveCfg = Debug|Win32 - {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|Win32.Build.0 = Debug|Win32 - {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|x64.ActiveCfg = Debug|x64 - {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|Mixed Platforms.Build.0 = Release|Win32 - {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|Win32.ActiveCfg = Release|Win32 - {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|Win32.Build.0 = Release|Win32 - {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|x64.ActiveCfg = Release|Win32 - {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.ActiveCfg = Debug|Win32 - {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.Build.0 = Debug|Win32 - {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.ActiveCfg = Debug|x64 - {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.Build.0 = Debug|x64 - {2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|Mixed Platforms.Build.0 = Release|Win32 - {2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|Win32.ActiveCfg = Release|Win32 - {2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|Win32.Build.0 = Release|Win32 - {2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|x64.ActiveCfg = Release|x64 - {2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|x64.Build.0 = Release|x64 + {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|x64.ActiveCfg = Release|x64 + {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|x64.Build.0 = Release|x64 + {52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Win32.ActiveCfg = Debug|Win32 + {52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Win32.Build.0 = Debug|Win32 + {52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|x64.ActiveCfg = Debug|x64 + {52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|x64.Build.0 = Debug|x64 + {52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Release|Mixed Platforms.Build.0 = Release|Win32 + {52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Release|Win32.ActiveCfg = Release|Win32 + {52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Release|Win32.Build.0 = Release|Win32 + {52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Release|x64.ActiveCfg = Release|x64 + {52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Release|x64.Build.0 = Release|x64 + {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Win32.ActiveCfg = Debug|Win32 + {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Win32.Build.0 = Debug|Win32 + {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|x64.ActiveCfg = Debug|x64 + {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|x64.Build.0 = Debug|x64 + {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Release|Mixed Platforms.Build.0 = Release|Win32 + {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Release|Win32.ActiveCfg = Release|Win32 + {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Release|Win32.Build.0 = Release|Win32 + {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Release|x64.ActiveCfg = Release|x64 + {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Release|x64.Build.0 = Release|x64 + {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Win32.ActiveCfg = Debug|Win32 + {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Win32.Build.0 = Debug|Win32 + {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|x64.ActiveCfg = Debug|x64 + {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|x64.Build.0 = Debug|x64 + {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Release|Mixed Platforms.Build.0 = Release|Win32 + {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Release|Win32.ActiveCfg = Release|Win32 + {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Release|Win32.Build.0 = Release|Win32 + {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Release|x64.ActiveCfg = Release|x64 + {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Release|x64.Build.0 = Release|x64 + {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|Win32.ActiveCfg = Debug|Win32 + {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|x64.ActiveCfg = Debug|x64 + {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|x64.Build.0 = Debug|x64 + {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Release|Mixed Platforms.Build.0 = Release|Win32 + {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Release|Win32.ActiveCfg = Release|Win32 + {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Release|Win32.Build.0 = Release|Win32 + {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -213,5 +260,11 @@ Global {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8} = {C27B926E-B3EF-4990-8822-47580E43A0BE} {6A066806-F43F-4B31-A4E3-57179674F460} = {C27B926E-B3EF-4990-8822-47580E43A0BE} {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50} = {C27B926E-B3EF-4990-8822-47580E43A0BE} + {460D625F-2AC9-4559-B809-0BA89CEAEDF4} = {C27B926E-B3EF-4990-8822-47580E43A0BE} + {2A1BC987-AF42-4500-802D-89CD32FC1309} = {20720CA7-795C-45AD-A302-9383A6DD503A} + {B1195BB9-B3A5-47F0-906C-8DEA384D1520} = {20720CA7-795C-45AD-A302-9383A6DD503A} + {52380DAA-0F4A-4D97-8E57-98DF39319CAF} = {20720CA7-795C-45AD-A302-9383A6DD503A} + {8690FDDF-C5B7-4C42-A337-BD5243F29B85} = {20720CA7-795C-45AD-A302-9383A6DD503A} + {DA2AA800-ED64-4649-8B3B-E7F1E3968B78} = {20720CA7-795C-45AD-A302-9383A6DD503A} EndGlobalSection EndGlobal diff --git a/Code/Misc/Utilities-Impl.h b/Code/Misc/Utilities-Impl.h index 67d0ad7a..6567d9eb 100644 --- a/Code/Misc/Utilities-Impl.h +++ b/Code/Misc/Utilities-Impl.h @@ -228,10 +228,7 @@ namespace Utility } template SmartPointer::~SmartPointer() { - if (this->_rc && this->_rc->Decref() == 0) - { - Destroy(); - } + this->Release(); } template SmartPointer& SmartPointer::operator= (const SmartPointer& p) { @@ -348,6 +345,20 @@ namespace Utility { return this->_ptr; } + template inline T* SmartPointer::Get() const + { + return this->_ptr; + } + template int SmartPointer::Release() + { + int returnVal = 0; + + if(this->_rc && ((returnVal = this->_rc->Decref()) == 0)) + { + Destroy(); + } + return returnVal; + } template inline bool SmartPointer::IsValid() const { return (this->_ptr != NULL) ? true : false; diff --git a/Code/Misc/Utilities.h b/Code/Misc/Utilities.h index aaec016a..9d630190 100644 --- a/Code/Misc/Utilities.h +++ b/Code/Misc/Utilities.h @@ -231,6 +231,11 @@ namespace Utility T* Get(); T* Get() const; + /** + * Releases one reference of the pointer and set value to null, making the current SmartPointer invalid. + */ + int Release(); + /** Checks if the pointer is valid (not NULL) * Returns true for valid, else false. */ From 22665bc44ba801f0e9c27b76456504b5aa40afe7 Mon Sep 17 00:00:00 2001 From: Linda Andersson Date: Wed, 11 Dec 2013 12:14:00 +0100 Subject: [PATCH 17/32] GL - started using network and protocols for sending/recieveing --- Code/DanBias.sln | 2 + Code/Game/DanBiasGame/DanBiasGame.vcxproj | 19 +++--- Code/Game/DanBiasGame/DanBiasGame_Impl.cpp | 44 +++++++++++- .../DanBiasGame/GameClientState/GameState.cpp | 3 + Code/Game/DanBiasGame/Include/DanBiasGame.h | 2 + Code/Game/DanBiasLauncher/Launcher.cpp | 4 +- Code/Game/GameProtocols/GameProtocols.vcxproj | 1 + Code/Game/GameProtocols/ObjectProtocols.h | 67 +++++++++++++++++++ Code/Game/GameProtocols/PlayerProtocols.h | 59 +++++++++++----- .../GameProtocols/ProtocolIdentificationID.h | 4 +- 10 files changed, 177 insertions(+), 28 deletions(-) create mode 100644 Code/Game/GameProtocols/ObjectProtocols.h diff --git a/Code/DanBias.sln b/Code/DanBias.sln index 9ef6f418..90a7843f 100644 --- a/Code/DanBias.sln +++ b/Code/DanBias.sln @@ -163,6 +163,7 @@ Global {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Mixed Platforms.ActiveCfg = Release|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Mixed Platforms.Build.0 = Release|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Win32.ActiveCfg = Debug|Win32 + {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Win32.Build.0 = Debug|Win32 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|x64.ActiveCfg = Debug|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|x64.Build.0 = Debug|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Release|Mixed Platforms.ActiveCfg = Release|x64 @@ -240,6 +241,7 @@ Global {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Win32.ActiveCfg = Debug|Win32 + {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Win32.Build.0 = Debug|Win32 {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|x64.ActiveCfg = Debug|x64 {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|x64.Build.0 = Debug|x64 {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Release|Mixed Platforms.ActiveCfg = Release|Win32 diff --git a/Code/Game/DanBiasGame/DanBiasGame.vcxproj b/Code/Game/DanBiasGame/DanBiasGame.vcxproj index 1784ca35..76a7554e 100644 --- a/Code/Game/DanBiasGame/DanBiasGame.vcxproj +++ b/Code/Game/DanBiasGame/DanBiasGame.vcxproj @@ -72,7 +72,7 @@ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName)D $(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath) - $(SolutionDir)..\External\Include\;$(IncludePath) + $(SolutionDir)Network/NetworkAPI;$(IncludePath) true @@ -106,7 +106,7 @@ Disabled DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true - $(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) + $(SolutionDir)Game/GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;%(AdditionalIncludeDirectories) Windows @@ -123,12 +123,12 @@ Disabled DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true - $(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) + $(SolutionDir)GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) Windows true - OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;%(AdditionalDependencies) + GameProtocols_$(PlatformShortName)D.lib;OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;%(AdditionalDependencies) OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs) @@ -142,14 +142,14 @@ true DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - $(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) + $(SolutionDir)GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) Windows true true true - OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;%(AdditionalDependencies) + GameProtocols_$(PlatformShortName).lib;OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;%(AdditionalDependencies) OysterGraphics_x86.dll;%(DelayLoadDLLs) @@ -163,14 +163,14 @@ true DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true - $(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) + $(SolutionDir)GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) Windows true true true - OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;%(AdditionalDependencies) + GameProtocols_$(PlatformShortName).lib;OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;%(AdditionalDependencies) OysterGraphics_x86.dll;%(DelayLoadDLLs) @@ -181,6 +181,9 @@ {2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee} + + {460d625f-2ac9-4559-b809-0ba89ceaedf4} + {0ec83e64-230e-48ef-b08c-6ac9651b4f82} diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index 64fc0bc4..e38b8cc9 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -5,7 +5,8 @@ #include "GameClientState/GameClientState.h" #include "GameClientState\GameState.h" #include "GameClientState\LobbyState.h" - +#include "PlayerProtocols.h" +#include "NetworkClient.h" #include "L_inputClass.h" #include "vld.h" @@ -19,6 +20,36 @@ namespace DanBias HWND DanBiasGame::g_hWnd = NULL; #pragma region Game Data + + + struct MyRecieverObject // :public PontusRecieverObject + { + Oyster::Network::NetworkClient nwClient; + + static void ProtocolRecieved(Network::CustomNetProtocol* p) + { + int pType = ((*p)[0]).value.netInt; + switch (pType) + { + case protocol_PlayerNavigation: + + break; + case protocol_PlayerPosition: + //int x = ((*p)[1]).value.netInt; + //int y = ((*p)[2]).value.netInt; + //int z = ((*p)[3]).value.netInt; + break; + + + case protocol_ObjectPosition: + // DanBiasGame::protocolRecived(); + break; + + default: + break; + } + } + }; class DanBiasGamePrivateData { @@ -35,12 +66,21 @@ namespace DanBias public: Client::GameClientState* gameClientState; InputClass* inputObj; + GameLogic::Protocol_PlayerMovement player_move; + //Oyster::Network::NetworkClient nwClient; + MyRecieverObject r; + // gameClient; } data; #pragma endregion - DanBiasGamePrivateData* DanBiasGame::m_data = new DanBiasGamePrivateData(); + + DanBiasGamePrivateData* DanBiasGame::m_data = new DanBiasGamePrivateData(); + void DanBiasGame::protocolRecived() + { + //m_data->gameClientState.setPos() + } //-------------------------------------------------------------------------------------- // Interface API functions //-------------------------------------------------------------------------------------- diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index fb81e23a..a95b6798 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -12,6 +12,7 @@ struct GameState::myData Oyster::Math3D::Float4x4 proj; C_Object* object[3]; int modelCount; + //Oyster::Network::NetworkClient* nwClient; gameStateState state; }privData; @@ -86,6 +87,8 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI case gameStateState_playing: // read server data // update objects + // Client.send(obj); + if(KeyInput->IsKeyPressed(DIK_L)) privData->state = GameState::gameStateState_end; break; diff --git a/Code/Game/DanBiasGame/Include/DanBiasGame.h b/Code/Game/DanBiasGame/Include/DanBiasGame.h index 924caac7..deaafdb9 100644 --- a/Code/Game/DanBiasGame/Include/DanBiasGame.h +++ b/Code/Game/DanBiasGame/Include/DanBiasGame.h @@ -54,6 +54,8 @@ namespace DanBias static HRESULT Update(float deltaTime); static HRESULT Render(float deltaTime); static HRESULT CleanUp(); + + static void protocolRecived(); private: static __int64 cntsPerSec; static __int64 prevTimeStamp; diff --git a/Code/Game/DanBiasLauncher/Launcher.cpp b/Code/Game/DanBiasLauncher/Launcher.cpp index 28b89485..0440d973 100644 --- a/Code/Game/DanBiasLauncher/Launcher.cpp +++ b/Code/Game/DanBiasLauncher/Launcher.cpp @@ -4,8 +4,8 @@ #define NOMINMAX #include -#define DANBIAS_SERVER -//#define DANBIAS_CLIENT +//#define DANBIAS_SERVER +#define DANBIAS_CLIENT #if defined(DANBIAS_SERVER) diff --git a/Code/Game/GameProtocols/GameProtocols.vcxproj b/Code/Game/GameProtocols/GameProtocols.vcxproj index 629ecf72..a7ebcca0 100644 --- a/Code/Game/GameProtocols/GameProtocols.vcxproj +++ b/Code/Game/GameProtocols/GameProtocols.vcxproj @@ -154,6 +154,7 @@ + diff --git a/Code/Game/GameProtocols/ObjectProtocols.h b/Code/Game/GameProtocols/ObjectProtocols.h new file mode 100644 index 00000000..32a86259 --- /dev/null +++ b/Code/Game/GameProtocols/ObjectProtocols.h @@ -0,0 +1,67 @@ +#ifndef GAMELOGIC_PLAYER_PROTOCOLS_H +#define GAMELOGIC_PLAYER_PROTOCOLS_H + +#include +#include "ProtocolIdentificationID.h" + + + +namespace GameLogic +{ + struct Protocol_ObjectPosition :public Network::CustomProtocolObject + { + float worldMatrix[16]; + // look at dir + + Protocol_ObjectPosition() + { + this->protocol[0].value = protocol_PlayerPosition; + this->protocol[0].type = Network::NetAttributeType_Int; + + this->protocol[1].type = Network::NetAttributeType_Float; + this->protocol[2].type = Network::NetAttributeType_Float; + this->protocol[3].type = Network::NetAttributeType_Float; + this->protocol[4].type = Network::NetAttributeType_Float; + this->protocol[5].type = Network::NetAttributeType_Float; + this->protocol[6].type = Network::NetAttributeType_Float; + this->protocol[7].type = Network::NetAttributeType_Float; + this->protocol[8].type = Network::NetAttributeType_Float; + this->protocol[9].type = Network::NetAttributeType_Float; + this->protocol[10].type = Network::NetAttributeType_Float; + this->protocol[11].type = Network::NetAttributeType_Float; + this->protocol[12].type = Network::NetAttributeType_Float; + this->protocol[13].type = Network::NetAttributeType_Float; + this->protocol[14].type = Network::NetAttributeType_Float; + this->protocol[15].type = Network::NetAttributeType_Float; + this->protocol[16].type = Network::NetAttributeType_Float; + + } + Network::CustomNetProtocol* GetProtocol() override + { + + this->protocol[1].value = worldMatrix[0]; + this->protocol[2].value = worldMatrix[1]; + this->protocol[3].value = worldMatrix[2]; + this->protocol[4].value = worldMatrix[4]; + this->protocol[5].value = worldMatrix[5]; + this->protocol[6].value = worldMatrix[6]; + this->protocol[7].value = worldMatrix[7]; + this->protocol[8].value = worldMatrix[8]; + this->protocol[9].value = worldMatrix[9]; + this->protocol[10].value = worldMatrix[10]; + this->protocol[11].value = worldMatrix[11]; + this->protocol[12].value = worldMatrix[12]; + this->protocol[13].value = worldMatrix[13]; + this->protocol[14].value = worldMatrix[14]; + this->protocol[15].value = worldMatrix[15]; + this->protocol[16].value = worldMatrix[16]; + return &protocol; + } + + private: + Network::CustomNetProtocol protocol; + }; + +} + +#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H \ No newline at end of file diff --git a/Code/Game/GameProtocols/PlayerProtocols.h b/Code/Game/GameProtocols/PlayerProtocols.h index b091ba34..3375a87c 100644 --- a/Code/Game/GameProtocols/PlayerProtocols.h +++ b/Code/Game/GameProtocols/PlayerProtocols.h @@ -1,7 +1,7 @@ #ifndef GAMELOGIC_PLAYER_PROTOCOLS_H #define GAMELOGIC_PLAYER_PROTOCOLS_H -#include "CustomNetProtocol.h" +#include #include "ProtocolIdentificationID.h" @@ -20,24 +20,24 @@ namespace GameLogic Protocol_PlayerMovement() { - protocol[0]->value = ProtocolID = protocol_PlayerNavigation; + this->protocol[0].value = ProtocolID = protocol_PlayerNavigation; - protocol[0]->type = Network::NetAttributeType_Int; - protocol[1]->type = Network::NetAttributeType_Bool; - protocol[2]->type = Network::NetAttributeType_Bool; - protocol[3]->type = Network::NetAttributeType_Bool; - protocol[4]->type = Network::NetAttributeType_Bool; - protocol[5]->type = Network::NetAttributeType_Bool; - protocol[6]->type = Network::NetAttributeType_Bool; + this->protocol[0].type = Network::NetAttributeType_Int; + this->protocol[1].type = Network::NetAttributeType_Bool; + this->protocol[2].type = Network::NetAttributeType_Bool; + this->protocol[3].type = Network::NetAttributeType_Bool; + this->protocol[4].type = Network::NetAttributeType_Bool; + this->protocol[5].type = Network::NetAttributeType_Bool; + this->protocol[6].type = Network::NetAttributeType_Bool; } Network::CustomNetProtocol* GetProtocol() override { - protocol[1]->value = bForward; - protocol[2]->value = bBackward; - protocol[3]->value = bTurnLeft; - protocol[4]->value = bTurnRight; - protocol[5]->value = bStrafeRight; - protocol[6]->value = bStrafeRight; + this->protocol[1].value = bForward; + this->protocol[2].value = bBackward; + this->protocol[3].value = bTurnLeft; + this->protocol[4].value = bTurnRight; + this->protocol[5].value = bStrafeRight; + this->protocol[6].value = bStrafeRight; return &protocol; } @@ -45,6 +45,35 @@ namespace GameLogic private: Network::CustomNetProtocol protocol; }; + + struct Protocol_PlayerPosition :public Network::CustomProtocolObject + { + float position[3]; + // look at dir + + Protocol_PlayerPosition() + { + this->protocol[0].value = protocol_PlayerPosition; + this->protocol[0].type = Network::NetAttributeType_Int; + + this->protocol[1].type = Network::NetAttributeType_Float; + this->protocol[2].type = Network::NetAttributeType_Float; + this->protocol[3].type = Network::NetAttributeType_Float; + + } + Network::CustomNetProtocol* GetProtocol() override + { + + this->protocol[1].value = position[0]; + this->protocol[2].value = position[1]; + this->protocol[3].value = position[2]; + return &protocol; + } + + private: + Network::CustomNetProtocol protocol; + }; + } #endif // !GAMELOGIC_PLAYER_PROTOCOLS_H diff --git a/Code/Game/GameProtocols/ProtocolIdentificationID.h b/Code/Game/GameProtocols/ProtocolIdentificationID.h index 1af8c920..46a1b72f 100644 --- a/Code/Game/GameProtocols/ProtocolIdentificationID.h +++ b/Code/Game/GameProtocols/ProtocolIdentificationID.h @@ -3,6 +3,8 @@ /* THERE CAN ABSOLUTLEY NOT BE TWO DEFINITIONS WITH THE SAME ID!! */ -#define protocol_PlayerNavigation 0; +#define protocol_PlayerNavigation 0 +#define protocol_PlayerPosition 1 +#define protocol_ObjectPosition 2 #endif // !GAMEPROTOCOL_PROTOCOL_DEFINITION_ID_H From fd3776a53bca3a10284dcbe35b430236a9d2ea81 Mon Sep 17 00:00:00 2001 From: dean11 Date: Thu, 12 Dec 2013 09:33:59 +0100 Subject: [PATCH 18/32] GameLogic - Pre-network merge --- Bin/Settings/PLACEHOLDER | 0 Bin/Settings/ServerInit.ini | 2 + Bin/Settings/serversearchpath.ini | 4 + Code/DanBias.sln | 6 +- Code/Game/DanBiasGame/Include/DanBiasGame.h | 6 +- .../DanBiasLauncher/DanBiasLauncher.vcxproj | 50 +-- Code/Game/DanBiasLauncher/Launcher.cpp | 20 +- Code/Game/DanBiasServer/DBServer.cpp | 56 --- Code/Game/DanBiasServer/DBServer.h | 27 -- Code/Game/DanBiasServer/DLLMain.cpp | 2 +- Code/Game/DanBiasServer/DanBiasServer.vcxproj | 57 ++- Code/Game/DanBiasServer/GameServer.cpp | 103 +++++ Code/Game/DanBiasServer/GameServer.h | 46 +++ .../DanBiasServerAPI.cpp} | 14 +- .../{IDanBiasServer.h => DanBiasServerAPI.h} | 28 +- .../DanBiasServer/Include/ServerWrapper.h | 23 -- Code/Game/DanBiasServer/MainLobby.h | 17 - Code/Game/DanBiasServer/ServerInitReader.h | 41 ++ .../ServerObjects/ClientObject.cpp | 12 + .../ServerObjects/ClientObject.h | 19 + .../ServerObjects/GameSession.cpp | 9 + .../DanBiasServer/ServerObjects/GameSession.h | 19 + .../ServerObjects/Lobby/GameLobby.cpp | 18 + .../ServerObjects/Lobby/GameLobby.h | 21 + .../ServerObjects/Lobby/MainLobby.cpp | 18 + .../ServerObjects/Lobby/MainLobby.h | 22 + .../ServerObjects/NetworkSession.cpp | 36 ++ .../ServerObjects/NetworkSession.h | 37 ++ Code/Game/GameProtocols/PlayerProtocols.h | 35 +- .../GameProtocols/ProtocolIdentificationID.h | 2 +- Code/WindowManager/WindowShell.cpp | 383 ++++++++---------- Code/WindowManager/WindowShell.h | 123 +++--- 32 files changed, 736 insertions(+), 520 deletions(-) delete mode 100644 Bin/Settings/PLACEHOLDER create mode 100644 Bin/Settings/ServerInit.ini create mode 100644 Bin/Settings/serversearchpath.ini delete mode 100644 Code/Game/DanBiasServer/DBServer.cpp delete mode 100644 Code/Game/DanBiasServer/DBServer.h create mode 100644 Code/Game/DanBiasServer/GameServer.cpp create mode 100644 Code/Game/DanBiasServer/GameServer.h rename Code/Game/DanBiasServer/{IDanBiasServer.cpp => Include/DanBiasServerAPI.cpp} (51%) rename Code/Game/DanBiasServer/Include/{IDanBiasServer.h => DanBiasServerAPI.h} (64%) delete mode 100644 Code/Game/DanBiasServer/Include/ServerWrapper.h delete mode 100644 Code/Game/DanBiasServer/MainLobby.h create mode 100644 Code/Game/DanBiasServer/ServerInitReader.h create mode 100644 Code/Game/DanBiasServer/ServerObjects/ClientObject.cpp create mode 100644 Code/Game/DanBiasServer/ServerObjects/ClientObject.h create mode 100644 Code/Game/DanBiasServer/ServerObjects/GameSession.cpp create mode 100644 Code/Game/DanBiasServer/ServerObjects/GameSession.h create mode 100644 Code/Game/DanBiasServer/ServerObjects/Lobby/GameLobby.cpp create mode 100644 Code/Game/DanBiasServer/ServerObjects/Lobby/GameLobby.h create mode 100644 Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.cpp create mode 100644 Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.h create mode 100644 Code/Game/DanBiasServer/ServerObjects/NetworkSession.cpp create mode 100644 Code/Game/DanBiasServer/ServerObjects/NetworkSession.h diff --git a/Bin/Settings/PLACEHOLDER b/Bin/Settings/PLACEHOLDER deleted file mode 100644 index e69de29b..00000000 diff --git a/Bin/Settings/ServerInit.ini b/Bin/Settings/ServerInit.ini new file mode 100644 index 00000000..a3b8f420 --- /dev/null +++ b/Bin/Settings/ServerInit.ini @@ -0,0 +1,2 @@ +port 15151 +clients 200 \ No newline at end of file diff --git a/Bin/Settings/serversearchpath.ini b/Bin/Settings/serversearchpath.ini new file mode 100644 index 00000000..6dc44cff --- /dev/null +++ b/Bin/Settings/serversearchpath.ini @@ -0,0 +1,4 @@ +ServerInit ..\Settings\ServerInit.ini +More a +more b +more c \ No newline at end of file diff --git a/Code/DanBias.sln b/Code/DanBias.sln index 32915f21..e2ee84d0 100644 --- a/Code/DanBias.sln +++ b/Code/DanBias.sln @@ -101,6 +101,7 @@ Global {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|Mixed Platforms.ActiveCfg = Release|x64 {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|Mixed Platforms.Build.0 = Release|x64 {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|Win32.ActiveCfg = Debug|Win32 + {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|Win32.Build.0 = Debug|Win32 {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|x64.ActiveCfg = Debug|x64 {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Debug|x64.Build.0 = Debug|x64 {35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}.Release|Mixed Platforms.ActiveCfg = Release|x64 @@ -112,7 +113,6 @@ Global {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|Mixed Platforms.ActiveCfg = Release|x64 {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|Mixed Platforms.Build.0 = Release|x64 {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|Win32.ActiveCfg = Debug|Win32 - {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|Win32.Build.0 = Debug|Win32 {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|x64.ActiveCfg = Debug|x64 {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|x64.Build.0 = Debug|x64 {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Release|Mixed Platforms.ActiveCfg = Release|x64 @@ -124,6 +124,7 @@ Global {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Mixed Platforms.ActiveCfg = Release|x64 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Mixed Platforms.Build.0 = Release|x64 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Win32.ActiveCfg = Debug|Win32 + {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Win32.Build.0 = Debug|Win32 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|x64.ActiveCfg = Debug|x64 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|x64.Build.0 = Debug|x64 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Release|Mixed Platforms.ActiveCfg = Release|x64 @@ -207,6 +208,7 @@ Global {52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Win32.ActiveCfg = Debug|Win32 + {52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|Win32.Build.0 = Debug|Win32 {52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|x64.ActiveCfg = Debug|x64 {52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Debug|x64.Build.0 = Debug|x64 {52380DAA-0F4A-4D97-8E57-98DF39319CAF}.Release|Mixed Platforms.ActiveCfg = Release|Win32 @@ -229,6 +231,7 @@ Global {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Win32.ActiveCfg = Debug|Win32 + {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Win32.Build.0 = Debug|Win32 {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|x64.ActiveCfg = Debug|x64 {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|x64.Build.0 = Debug|x64 {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Release|Mixed Platforms.ActiveCfg = Release|Win32 @@ -240,6 +243,7 @@ Global {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|Win32.ActiveCfg = Debug|Win32 + {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|Win32.Build.0 = Debug|Win32 {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|x64.ActiveCfg = Debug|x64 {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|x64.Build.0 = Debug|x64 {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Release|Mixed Platforms.ActiveCfg = Release|Win32 diff --git a/Code/Game/DanBiasGame/Include/DanBiasGame.h b/Code/Game/DanBiasGame/Include/DanBiasGame.h index 0f9b83eb..519eda13 100644 --- a/Code/Game/DanBiasGame/Include/DanBiasGame.h +++ b/Code/Game/DanBiasGame/Include/DanBiasGame.h @@ -10,9 +10,7 @@ #define NOMINMAX #include - -#include "L_inputClass.h" - +#define DANBIAS_CLIENT namespace DanBias { @@ -25,8 +23,6 @@ namespace DanBias DanBiasClientReturn_Sucess, }; - - struct DanBiasGameDesc { //Stuff goes here... diff --git a/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj b/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj index 6e5f099c..7eacfd89 100644 --- a/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj +++ b/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj @@ -71,32 +71,32 @@ $(SolutionDir)..\Bin\Executable\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName)D - $(SolutionDir)..\External\Include\;$(IncludePath);$(IncludePath) - $(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL; + $(SolutionDir)..\External\Include\;$(IncludePath) + $(OutDir)..\DLL\;$(LibraryPath) true $(SolutionDir)..\Bin\Executable\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName)D - $(SolutionDir)..\External\Include\;$(IncludePath);$(IncludePath) - $(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL; + $(SolutionDir)..\External\Include\;$(IncludePath) + $(OutDir)..\DLL\;$(LibraryPath) false $(SolutionDir)..\Bin\Executable\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName) - $(SolutionDir)..\External\Include\;$(IncludePath);$(IncludePath) - $(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL; + $(SolutionDir)..\External\Include\;$(IncludePath) + $(OutDir)..\DLL\;$(LibraryPath) false $(SolutionDir)..\Bin\Executable\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName) - $(SolutionDir)..\External\Include\;$(IncludePath);$(IncludePath) - $(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL; + $(SolutionDir)..\External\Include\;$(IncludePath) + $(OutDir)..\DLL\;$(LibraryPath) @@ -105,13 +105,13 @@ Level3 Disabled WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - $(SolutionDir)Input;$(SolutionDir)Include;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterGraphics\;$(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include + $(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include Windows true DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs) - Input_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies) + DanBiasGame_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;%(AdditionalDependencies) @@ -121,13 +121,13 @@ Level3 Disabled WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - $(SolutionDir)Input;$(SolutionDir)Include;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterGraphics\;$(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include + $(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include Windows true DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs) - Input_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies) + DanBiasGame_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;%(AdditionalDependencies) @@ -139,7 +139,7 @@ true true WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - $(SolutionDir)Input;$(SolutionDir)Include;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterGraphics\;$(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include + $(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include Windows @@ -147,7 +147,7 @@ true true DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs) - Input_$(PlatformShortName).lib;DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies) + DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies) @@ -159,7 +159,7 @@ true true WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - $(SolutionDir)Input;$(SolutionDir)Include;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterGraphics\;$(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include + $(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include Windows @@ -167,34 +167,16 @@ true true DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs) - Input_$(PlatformShortName).lib;DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies) + DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies) - - {104fa3e9-94d9-4e1d-a941-28a03bc8a095} - - - {7e3990d2-3d94-465c-b58d-64a74b3ecf9b} - - - {2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee} - - - {0ec83e64-230e-48ef-b08c-6ac9651b4f82} - - - {f10cbc03-9809-4cba-95d8-327c287b18ee} - {2a1bc987-af42-4500-802d-89cd32fc1309} - - {52380daa-0f4a-4d97-8e57-98df39319caf} - diff --git a/Code/Game/DanBiasLauncher/Launcher.cpp b/Code/Game/DanBiasLauncher/Launcher.cpp index 0440d973..1d42d16e 100644 --- a/Code/Game/DanBiasLauncher/Launcher.cpp +++ b/Code/Game/DanBiasLauncher/Launcher.cpp @@ -4,16 +4,10 @@ #define NOMINMAX #include -//#define DANBIAS_SERVER -#define DANBIAS_CLIENT +#include "DanBiasServerAPI.h" +//#include "DanBiasGame.h" -#if defined(DANBIAS_SERVER) -#include "IDanBiasServer.h" -#elif defined(DANBIAS_CLIENT) -#include "DanBiasGame.h" -#endif - int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdShow) { #if defined(DANBIAS_SERVER) @@ -21,14 +15,10 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh { return cmdShow; } - // Server starter code goes here - DanBias::DanBiasServerDesc desc; - desc.port = 0; - - if( DanBias::DanBiasServer::Initiate(desc) == DanBias::DanBiasServerReturn_Sucess) + if( DanBias::DanBiasServerAPI::Initiate() == DanBias::DanBiasServerReturn_Sucess) { - DanBias::DanBiasServer::Run(); - DanBias::DanBiasServer::Release(); + DanBias::DanBiasServerAPI::Run(); + DanBias::DanBiasServerAPI::Release(); } #elif defined(DANBIAS_CLIENT) if(SetDllDirectory(L"..\\DLL") == FALSE) diff --git a/Code/Game/DanBiasServer/DBServer.cpp b/Code/Game/DanBiasServer/DBServer.cpp deleted file mode 100644 index db81f4da..00000000 --- a/Code/Game/DanBiasServer/DBServer.cpp +++ /dev/null @@ -1,56 +0,0 @@ -///////////////////////////////////////////////////////////////////// -// Created by [Dennis Andersen] [2013] -///////////////////////////////////////////////////////////////////// -#include -#include "DBServer.h" -//#include "GameLogic\?" -#include "Utilities.h" - -using namespace DanBias; - -DBServer::DBServer() - : initiated(0) - , running(0) - , released(0) -{ -} -DBServer::~DBServer() -{ - -} -DanBiasServerReturn DBServer::Create(const DanBias::DanBiasServerDesc& desc) -{ - this->initiated = true; - return DanBiasServerReturn_Sucess; -} -DanBiasServerReturn DBServer::Run() -{ - - if(this->running) - { - return DanBiasServerReturn_Error; - } - if(this->released) - { - return DanBiasServerReturn_Error; - } - if(!this->initiated) - { - return DanBiasServerReturn_Error; - } - this->running = true; - while (this->running) - { - MessageBox(0, L"What to do here...", L"TYPELESS", 0); - - this->running = false; - } - return DanBiasServerReturn_Sucess; -} -DanBiasServerReturn DBServer::Release() -{ - this->released = true; - return DanBiasServerReturn_Sucess; -} - - diff --git a/Code/Game/DanBiasServer/DBServer.h b/Code/Game/DanBiasServer/DBServer.h deleted file mode 100644 index 261e62d5..00000000 --- a/Code/Game/DanBiasServer/DBServer.h +++ /dev/null @@ -1,27 +0,0 @@ -///////////////////////////////////////////////////////////////////// -// Created by [Dennis Andersen] [2013] -///////////////////////////////////////////////////////////////////// -#ifndef DANBIASSERVER_DBSERVER_H -#define DANBIASSERVER_DBSERVER_H - -#include "Include\IDanBiasServer.h" - -namespace DanBias -{ - class DBServer - { - public: - DBServer(); - ~DBServer(); - - DanBiasServerReturn Create(const DanBias::DanBiasServerDesc& desc); - DanBiasServerReturn Run(); - DanBiasServerReturn Release(); - - private: - bool initiated; - bool running; - bool released; - }; -}// End namspace DanBias -#endif // !DANBIASSERVER_DBSERVER_H diff --git a/Code/Game/DanBiasServer/DLLMain.cpp b/Code/Game/DanBiasServer/DLLMain.cpp index 93409304..b088d800 100644 --- a/Code/Game/DanBiasServer/DLLMain.cpp +++ b/Code/Game/DanBiasServer/DLLMain.cpp @@ -3,6 +3,6 @@ BOOL WINAPI DllMain( _In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpvReserved ) { - MessageBox(0, L"DanBiasServer Loaded", 0, 0); + return TRUE; } \ No newline at end of file diff --git a/Code/Game/DanBiasServer/DanBiasServer.vcxproj b/Code/Game/DanBiasServer/DanBiasServer.vcxproj index ba85aaa5..b919dade 100644 --- a/Code/Game/DanBiasServer/DanBiasServer.vcxproj +++ b/Code/Game/DanBiasServer/DanBiasServer.vcxproj @@ -73,28 +73,32 @@ $(SolutionDir)..\Bin\DLL\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName)D - $(SolutionDir)..\External\Include\;$(IncludePath) + $(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network\NetworkAPI\;$(SolutionDir)Misc\;$(SolutionDir)WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath) + $(OutDir);$(SolutionDir)..\External\Lib\WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath) true $(SolutionDir)..\Bin\DLL\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName)D - $(SolutionDir)..\External\Include\;$(IncludePath) + $(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network\NetworkAPI\;$(SolutionDir)Misc\;$(SolutionDir)WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath) + $(OutDir);$(SolutionDir)..\External\Lib\WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath) false $(SolutionDir)..\Bin\DLL\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName) - $(SolutionDir)..\External\Include\;$(IncludePath) + $(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network\NetworkAPI\;$(SolutionDir)Misc\;$(SolutionDir)WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath) + $(OutDir);$(SolutionDir)..\External\Lib\WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath) false $(SolutionDir)..\Bin\DLL\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName) - $(SolutionDir)..\External\Include\;$(IncludePath) + $(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network\NetworkAPI\;$(SolutionDir)Misc\;$(SolutionDir)WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath) + $(OutDir);$(SolutionDir)..\External\Lib\WindowManager\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath) @@ -102,13 +106,15 @@ Level3 Disabled - DANBIAS_SERVER;DANBIAS_SERVER_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - $(SolutionDir)Misc\;$(SolutionDir)Game\ + DANBIAS_SERVER_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + + Windows true GameLogic_$(PlatformShortName)D.dll;%(DelayLoadDLLs) + NetworkAPI_$(PlatformShortName)D.lib;WindowManager_$(PlatformShortName)D.lib;%(AdditionalDependencies) @@ -117,13 +123,15 @@ Level3 Disabled - DANBIAS_SERVER;DANBIAS_SERVER_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - $(SolutionDir)Misc\;$(SolutionDir)Game\ + DANBIAS_SERVER_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + + Windows true GameLogic_$(PlatformShortName)D.dll;%(DelayLoadDLLs) + NetworkAPI_$(PlatformShortName)D.lib;WindowManager_$(PlatformShortName)D.lib;%(AdditionalDependencies) @@ -134,8 +142,9 @@ MaxSpeed true true - DANBIAS_SERVER;DANBIAS_SERVER_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - $(SolutionDir)Misc\;$(SolutionDir)Game\ + DANBIAS_SERVER_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + + Windows @@ -143,6 +152,7 @@ true true GameLogic_$(PlatformShortName).dll;%(DelayLoadDLLs) + NetworkAPI_$(PlatformShortName).lib;WindowManager_$(PlatformShortName).lib;%(AdditionalDependencies) @@ -153,8 +163,9 @@ MaxSpeed true true - DANBIAS_SERVER;DANBIAS_SERVER_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - $(SolutionDir)Misc\;$(SolutionDir)Game\ + DANBIAS_SERVER_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + + Windows @@ -162,18 +173,28 @@ true true GameLogic_$(PlatformShortName).dll;%(DelayLoadDLLs) + NetworkAPI_$(PlatformShortName).lib;WindowManager_$(PlatformShortName).lib;%(AdditionalDependencies) - + - + + + + + + - - - - + + + + + + + + diff --git a/Code/Game/DanBiasServer/GameServer.cpp b/Code/Game/DanBiasServer/GameServer.cpp new file mode 100644 index 00000000..104841cd --- /dev/null +++ b/Code/Game/DanBiasServer/GameServer.cpp @@ -0,0 +1,103 @@ +///////////////////////////////////////////////////////////////////// +// Created by [Dennis Andersen] [2013] +///////////////////////////////////////////////////////////////////// +#include +#include + +#include "GameServer.h" +#include "Utilities.h" +#include "ServerInitReader.h" + +namespace DanBias +{ + using namespace Oyster::Network; + + //void GameServer::ClientConnectCallbackFunction(Oyster::Network::NetworkClient& connectedClient) + //{ + // if( + //} + void GameServer::ClientConnectCallback(NetworkClient &client) + { + + } + GameServer::GameServer() + : initiated(0) + , running(0) + , released(0) + , maxClients(0) + , mainLobby(0) + , server(0) + { + } + GameServer::~GameServer() + { + + } + DanBiasServerReturn GameServer::Create() + { + this->server = new NetworkServer(); + this->mainLobby = new MainLobby(); + + InitData data; + if(!LoadIniFile(data)) return DanBiasServerReturn_Error; + + NetworkServer::INIT_DESC serverDesc; + serverDesc.port = data.port; + this->maxClients = data.clients; + serverDesc.callback = this; + + if(!this->server->Init(serverDesc)) return DanBiasServerReturn_Error; + if(!WindowShell::CreateConsoleWindow()) return DanBiasServerReturn_Error; + if(!WindowShell::CreateWin(WindowShell::WINDOW_INIT_DESC())) return DanBiasServerReturn_Error; + + this->initiated = true; + return DanBiasServerReturn_Sucess; + } + DanBiasServerReturn GameServer::Run() + { + if(this->running) return DanBiasServerReturn_Error; + if(this->released) return DanBiasServerReturn_Error; + if(!this->initiated) return DanBiasServerReturn_Error; + + this->running = true; + while (this->running) + { + if(!WindowShell::Frame()) + break; + } + + return DanBiasServerReturn_Sucess; + } + DanBiasServerReturn GameServer::Release() + { + this->released = true; + return DanBiasServerReturn_Sucess; + } + + bool GameServer::LoadIniFile(InitData& ini) + { + std::ifstream in; + std::string f = GetInitPath(InitPath_ServerIni); + in.open(f, std::ios::in); + if(!in.is_open()) return false; + + std::string buffer; + while (!in.eof()) + { + in >> buffer; + + if(buffer == "port") + { + in >> ini.port; + } + else if(buffer == "clients") + { + in >> ini.clients; + } + + } + + in.close(); + return true; + } +}//End namespace DanBias diff --git a/Code/Game/DanBiasServer/GameServer.h b/Code/Game/DanBiasServer/GameServer.h new file mode 100644 index 00000000..b46891db --- /dev/null +++ b/Code/Game/DanBiasServer/GameServer.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////// +// Created by [Dennis Andersen] [2013] +///////////////////////////////////////////////////////////////////// +#ifndef DANBIASSERVER_GAME_SERVER_H +#define DANBIASSERVER_GAME_SERVER_H + +#include + +#include "Include\DanBiasServerAPI.h" +#include "ServerObjects\Lobby\MainLobby.h" +#include +#include + +namespace DanBias +{ + class GameServer :public Oyster::Network::ClientConnectedObject + { + public: + GameServer(); + ~GameServer(); + + DanBiasServerReturn Create(); + DanBiasServerReturn Run(); + DanBiasServerReturn Release(); + + private: + //static void ClientConnectCallbackFunction(Oyster::Network::NetworkClient& connectedClient); + void ClientConnectCallback(Oyster::Network::NetworkClient &client) override; + + bool initiated; + bool running; + bool released; + int maxClients; + MainLobby *mainLobby; + Oyster::Network::NetworkServer *server; + + private: + struct InitData + { + int port; + int clients; + }; + bool LoadIniFile(InitData&); + }; +}// End namspace DanBias +#endif // !DANBIASSERVER_DBSERVER_H diff --git a/Code/Game/DanBiasServer/IDanBiasServer.cpp b/Code/Game/DanBiasServer/Include/DanBiasServerAPI.cpp similarity index 51% rename from Code/Game/DanBiasServer/IDanBiasServer.cpp rename to Code/Game/DanBiasServer/Include/DanBiasServerAPI.cpp index bf0b52de..e897a6dd 100644 --- a/Code/Game/DanBiasServer/IDanBiasServer.cpp +++ b/Code/Game/DanBiasServer/Include/DanBiasServerAPI.cpp @@ -1,26 +1,26 @@ ///////////////////////////////////////////////////////////////////// // Created by [Dennis Andersen] [2013] ///////////////////////////////////////////////////////////////////// -#include "Include\IDanBiasServer.h" -#include "DBServer.h" +#include "DanBiasServerAPI.h" +#include "..\GameServer.h" namespace DanBias { #pragma region Server Data - static DBServer server; + static GameServer server; #pragma endregion - DanBiasServerReturn DanBiasServer::Initiate(DanBiasServerDesc& desc) + DanBiasServerReturn DanBiasServerAPI::Initiate() { - return server.Create(desc); + return server.Create(); } - DanBiasServerReturn DanBiasServer::Run() + DanBiasServerReturn DanBiasServerAPI::Run() { return server.Run(); } - DanBiasServerReturn DanBiasServer::Release() + DanBiasServerReturn DanBiasServerAPI::Release() { return server.Release(); } diff --git a/Code/Game/DanBiasServer/Include/IDanBiasServer.h b/Code/Game/DanBiasServer/Include/DanBiasServerAPI.h similarity index 64% rename from Code/Game/DanBiasServer/Include/IDanBiasServer.h rename to Code/Game/DanBiasServer/Include/DanBiasServerAPI.h index 681ea348..acf0d5d6 100644 --- a/Code/Game/DanBiasServer/Include/IDanBiasServer.h +++ b/Code/Game/DanBiasServer/Include/DanBiasServerAPI.h @@ -4,8 +4,9 @@ #ifndef DANBIAS_SERVER_DANBIAS_SERVER_H #define DANBIAS_SERVER_DANBIAS_SERVER_H +#define DANBIAS_SERVER -#if defined (DANBIAS_SERVER_DLL_EXPORT) +#ifdef DANBIAS_SERVER_DLL_EXPORT #define DANBIAS_SERVER_DLL __declspec(dllexport) #else #define DANBIAS_SERVER_DLL __declspec(dllimport) @@ -13,28 +14,21 @@ namespace DanBias { + enum DanBiasServerReturn + { + DanBiasServerReturn_Error, + DanBiasServerReturn_Sucess, + }; + extern "C" { - enum DanBiasServerReturn - { - DanBiasServerReturn_Error, - DanBiasServerReturn_Sucess, - }; - - struct DanBiasServerDesc - { - //Stuff goes here... - int port; - }; - - class DANBIAS_SERVER_DLL DanBiasServer + class DANBIAS_SERVER_DLL DanBiasServerAPI { public: - static DanBiasServerReturn Initiate(DanBiasServerDesc& desc); + static DanBiasServerReturn Initiate(); static DanBiasServerReturn Run(); static DanBiasServerReturn Release(); - }; - + };//End class DanBiasServer }//End Extern "C" } //End namspace DanBias diff --git a/Code/Game/DanBiasServer/Include/ServerWrapper.h b/Code/Game/DanBiasServer/Include/ServerWrapper.h deleted file mode 100644 index 29829c17..00000000 --- a/Code/Game/DanBiasServer/Include/ServerWrapper.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef NETWORK_SERVER_WRAPPER_H -#define NETWORK_SERVER_WRAPPER_H - - -class SingletonServer -{ -public: - - struct INIT_DESC - { - bool l; - }; - void CreateServer(/*DATA*/); - void StartServer(/*DATA*/); - void StopServer(/*DATA*/); - void TerminateServer(/*DATA*/); - - void AttachLobby(/*LOBBY*/); - void DetachLobby(/*LOBBY*/); - void KickClient(/*CLIENT*/); -}; - -#endif // !NETWORK_SERVER_WRAPPER_H diff --git a/Code/Game/DanBiasServer/MainLobby.h b/Code/Game/DanBiasServer/MainLobby.h deleted file mode 100644 index 5807ab9c..00000000 --- a/Code/Game/DanBiasServer/MainLobby.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef DANBIASGAME_GAMELOBBY_H -#define DANBIASGAME_GAMELOBBY_H - -#include "Include\ServerWrapper.h" - -class MainLobby :public SingletonServer -{ -public: - MainLobby(); - ~MainLobby(); - -private: - - -}; - -#endif // !DANBIASGAME_GAMELOBBY_H diff --git a/Code/Game/DanBiasServer/ServerInitReader.h b/Code/Game/DanBiasServer/ServerInitReader.h new file mode 100644 index 00000000..cf7cc4c7 --- /dev/null +++ b/Code/Game/DanBiasServer/ServerInitReader.h @@ -0,0 +1,41 @@ +#ifndef DANBIASSERVER_SERVER_INIT_READER_H +#define DANBIASSERVER_SERVER_INIT_READER_H + +#include +#include + +namespace DanBias +{ + enum InitPath + { + InitPath_ServerIni, + }; + std::string GetInitPath(InitPath file) + { + std::string type = ""; + std::string path = ""; + std::string flag = ""; + + switch (file) + { + case DanBias::InitPath_ServerIni: + flag = "ServerInit"; + break; + } + + std::fstream in; + in.open("..\\Settings\\serversearchpath.ini", std::ios::in); + if(!in.is_open()) return ""; + + while (!in.eof() && type != flag) + { + in >> type; + in >> path; + } + + in.close(); + return path; + } +} + +#endif // !DANBIASSERVER_SERVER_INIT_READER_H diff --git a/Code/Game/DanBiasServer/ServerObjects/ClientObject.cpp b/Code/Game/DanBiasServer/ServerObjects/ClientObject.cpp new file mode 100644 index 00000000..acad56d3 --- /dev/null +++ b/Code/Game/DanBiasServer/ServerObjects/ClientObject.cpp @@ -0,0 +1,12 @@ +#include "ClientObject.h" + +using namespace DanBias; + +ClientObject::ClientObject() +{ +} +ClientObject::~ClientObject() +{ +} + + diff --git a/Code/Game/DanBiasServer/ServerObjects/ClientObject.h b/Code/Game/DanBiasServer/ServerObjects/ClientObject.h new file mode 100644 index 00000000..55acdf6f --- /dev/null +++ b/Code/Game/DanBiasServer/ServerObjects/ClientObject.h @@ -0,0 +1,19 @@ +#ifndef DANBIASSERVER_CLIENT_OBJECT_H +#define DANBIASSERVER_CLIENT_OBJECT_H + +#include "NetworkClient.h" + +namespace DanBias +{ + class ClientObject + { + public: + ClientObject(); + ~ClientObject(); + + private: + + }; + +}//End namespace DanBias +#endif // !DANBIASSERVER_CLIENT_OBJECT_H diff --git a/Code/Game/DanBiasServer/ServerObjects/GameSession.cpp b/Code/Game/DanBiasServer/ServerObjects/GameSession.cpp new file mode 100644 index 00000000..fced4e45 --- /dev/null +++ b/Code/Game/DanBiasServer/ServerObjects/GameSession.cpp @@ -0,0 +1,9 @@ + + + + +namespace DanBias +{ + + +}//End namespace DanBias \ No newline at end of file diff --git a/Code/Game/DanBiasServer/ServerObjects/GameSession.h b/Code/Game/DanBiasServer/ServerObjects/GameSession.h new file mode 100644 index 00000000..26ad5ec2 --- /dev/null +++ b/Code/Game/DanBiasServer/ServerObjects/GameSession.h @@ -0,0 +1,19 @@ +#ifndef DANBIASSERVER_GAME_SESSION_H +#define DANBIASSERVER_GAME_SESSION_H + +#include "NetworkSession.h" + +namespace DanBias +{ + class GameSession :public NetworkSession + { + public: + GameSession(); + ~GameSession(); + + private: + + + };//End GameSession +}//End namespace DanBias +#endif // !DANBIASSERVER_GAME_SESSION_H \ No newline at end of file diff --git a/Code/Game/DanBiasServer/ServerObjects/Lobby/GameLobby.cpp b/Code/Game/DanBiasServer/ServerObjects/Lobby/GameLobby.cpp new file mode 100644 index 00000000..06efcb96 --- /dev/null +++ b/Code/Game/DanBiasServer/ServerObjects/Lobby/GameLobby.cpp @@ -0,0 +1,18 @@ +#include "GameLobby.h" + + +namespace DanBias +{ + GameLobby::GameLobby() + { + + } + GameLobby::~GameLobby() + { + + } + void GameLobby::Release() + { + + } +}//End namespace DanBias \ No newline at end of file diff --git a/Code/Game/DanBiasServer/ServerObjects/Lobby/GameLobby.h b/Code/Game/DanBiasServer/ServerObjects/Lobby/GameLobby.h new file mode 100644 index 00000000..b28d9b31 --- /dev/null +++ b/Code/Game/DanBiasServer/ServerObjects/Lobby/GameLobby.h @@ -0,0 +1,21 @@ +#ifndef DANBIASSERVER_GAME_LOBBY_H +#define DANBIASSERVER_GAME_LOBBY_H + +#include "..\NetworkSession.h" + +namespace DanBias +{ + class GameLobby :public NetworkSession + { + public: + GameLobby(); + ~GameLobby(); + void Release(); + + private: + + + }; +}//End namespace DanBias + +#endif // !DANBIASSERVER_GAME_LOBBY_H \ No newline at end of file diff --git a/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.cpp b/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.cpp new file mode 100644 index 00000000..d518a0c7 --- /dev/null +++ b/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.cpp @@ -0,0 +1,18 @@ +#include "MainLobby.h" + + +namespace DanBias +{ + MainLobby::MainLobby() + { + + } + MainLobby::~MainLobby() + { + + } + void MainLobby::Release() + { + + } +}//End namespace DanBias \ No newline at end of file diff --git a/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.h b/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.h new file mode 100644 index 00000000..456eee9d --- /dev/null +++ b/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.h @@ -0,0 +1,22 @@ +#ifndef DANBIASGAME_GAMELOBBY_H +#define DANBIASGAME_GAMELOBBY_H + +#include "..\NetworkSession.h" +#include +#include + +namespace DanBias +{ + class MainLobby :public NetworkSession + { + public: + MainLobby(); + ~MainLobby(); + void Release(); + + private: + + + }; +}//End namespace DanBias +#endif // !DANBIASGAME_GAMELOBBY_H diff --git a/Code/Game/DanBiasServer/ServerObjects/NetworkSession.cpp b/Code/Game/DanBiasServer/ServerObjects/NetworkSession.cpp new file mode 100644 index 00000000..569b8a0a --- /dev/null +++ b/Code/Game/DanBiasServer/ServerObjects/NetworkSession.cpp @@ -0,0 +1,36 @@ +#include "NetworkSession.h" + + +namespace DanBias +{ + NetworkSession::NetworkSession() + { + } + NetworkSession::~NetworkSession() + { + } + + void NetworkSession::AttachClient(Utility::DynamicMemory::SmartPointer client) + { + } + void NetworkSession::DetachClient(Utility::DynamicMemory::SmartPointer client) + { + } + void NetworkSession::DetachClient(short ID) + { + + } + + void NetworkSession::Kick(Utility::DynamicMemory::SmartPointer client) + { + } + void NetworkSession::Kick() + { + + } + + Oyster::Network::NetworkClient* NetworkSession::operator[](int Identification) + { + return 0; + } +}//End namespace DanBias \ No newline at end of file diff --git a/Code/Game/DanBiasServer/ServerObjects/NetworkSession.h b/Code/Game/DanBiasServer/ServerObjects/NetworkSession.h new file mode 100644 index 00000000..6653c297 --- /dev/null +++ b/Code/Game/DanBiasServer/ServerObjects/NetworkSession.h @@ -0,0 +1,37 @@ +#ifndef DANBIASSERVER_NETWORK_SESSION_H +#define DANBIASSERVER_NETWORK_SESSION_H + +#include "Utilities.h" +#include "ClientObject.h" +#include +#include + +namespace DanBias +{ + class NetworkSession + { + public: + NetworkSession(); + ~NetworkSession(); + + void AttachClient(Utility::DynamicMemory::SmartPointer client); + + void DetachClient(Utility::DynamicMemory::SmartPointer client); + void DetachClient(short ID); + + void Kick(Utility::DynamicMemory::SmartPointer client); + void Kick(); + + void Send(Network::CustomNetProtocol& protocol); + void Send(Network::CustomNetProtocol& protocol, int ID); + + //TODO: Do more lobby features + + protected: + Oyster::Network::NetworkClient* operator[](int Identification); + + private: + std::vector> clients; + }; +}//End namespace DanBias +#endif // !DANBIASSERVER_NETWORK_SESSION_H diff --git a/Code/Game/GameProtocols/PlayerProtocols.h b/Code/Game/GameProtocols/PlayerProtocols.h index b091ba34..c579d701 100644 --- a/Code/Game/GameProtocols/PlayerProtocols.h +++ b/Code/Game/GameProtocols/PlayerProtocols.h @@ -1,7 +1,12 @@ +////////////////////////////////////////////////////////// +// Created 2013 // +// Dennis Andersen, Linda Andersson // +////////////////////////////////////////////////////////// + #ifndef GAMELOGIC_PLAYER_PROTOCOLS_H #define GAMELOGIC_PLAYER_PROTOCOLS_H -#include "CustomNetProtocol.h" +#include #include "ProtocolIdentificationID.h" @@ -20,24 +25,24 @@ namespace GameLogic Protocol_PlayerMovement() { - protocol[0]->value = ProtocolID = protocol_PlayerNavigation; + this->protocol[0].value = ProtocolID = protocol_PlayerNavigation; - protocol[0]->type = Network::NetAttributeType_Int; - protocol[1]->type = Network::NetAttributeType_Bool; - protocol[2]->type = Network::NetAttributeType_Bool; - protocol[3]->type = Network::NetAttributeType_Bool; - protocol[4]->type = Network::NetAttributeType_Bool; - protocol[5]->type = Network::NetAttributeType_Bool; - protocol[6]->type = Network::NetAttributeType_Bool; + this->protocol[0].type = Network::NetAttributeType_Int; + this->protocol[1].type = Network::NetAttributeType_Bool; + this->protocol[2].type = Network::NetAttributeType_Bool; + this->protocol[3].type = Network::NetAttributeType_Bool; + this->protocol[4].type = Network::NetAttributeType_Bool; + this->protocol[5].type = Network::NetAttributeType_Bool; + this->protocol[6].type = Network::NetAttributeType_Bool; } Network::CustomNetProtocol* GetProtocol() override { - protocol[1]->value = bForward; - protocol[2]->value = bBackward; - protocol[3]->value = bTurnLeft; - protocol[4]->value = bTurnRight; - protocol[5]->value = bStrafeRight; - protocol[6]->value = bStrafeRight; + this->protocol[1].value = bForward; + this->protocol[2].value = bBackward; + this->protocol[3].value = bTurnLeft; + this->protocol[4].value = bTurnRight; + this->protocol[5].value = bStrafeRight; + this->protocol[6].value = bStrafeRight; return &protocol; } diff --git a/Code/Game/GameProtocols/ProtocolIdentificationID.h b/Code/Game/GameProtocols/ProtocolIdentificationID.h index 1af8c920..5890e9ff 100644 --- a/Code/Game/GameProtocols/ProtocolIdentificationID.h +++ b/Code/Game/GameProtocols/ProtocolIdentificationID.h @@ -3,6 +3,6 @@ /* THERE CAN ABSOLUTLEY NOT BE TWO DEFINITIONS WITH THE SAME ID!! */ -#define protocol_PlayerNavigation 0; +#define protocol_PlayerNavigation 0 #endif // !GAMEPROTOCOL_PROTOCOL_DEFINITION_ID_H diff --git a/Code/WindowManager/WindowShell.cpp b/Code/WindowManager/WindowShell.cpp index 7f8e1481..b82a58f6 100644 --- a/Code/WindowManager/WindowShell.cpp +++ b/Code/WindowManager/WindowShell.cpp @@ -1,87 +1,87 @@ #include "WindowShell.h" #include +// debug window include +#include +#include +#include -struct ChildWin; -struct _PrSt; #pragma region Declarations - namespace - { - //Private data - static WindowShell* instance = NULL; - int childIdCounter = 0; - _PrSt *pData = NULL; - } - - struct ChildWin - { - int id; - HWND hWnd; - - ChildWin() - { - hWnd = NULL; - childIdCounter++; - id = childIdCounter; - } - int ID() const { return id; } - }; - struct _PrSt + struct _PrivateDataContainer { HINSTANCE hIns; HWND hWnd; - std::vector childWindows; + HWND parent; + bool consoleWindow; + WNDPROC callback; + const wchar_t* windowClassName; + _PrivateDataContainer() + : hIns(0) + , hWnd(0) + , parent(0) + , consoleWindow(0) + { } + ~_PrivateDataContainer() { if(this->consoleWindow) FreeConsole(); } - _PrSt() - { - hIns = NULL; - hWnd = NULL; - } - }; + } __windowShellData; #pragma endregion - - -WindowShell::WindowShell() +LRESULT CALLBACK DefaultWindowCallback(HWND h, UINT m, WPARAM w, LPARAM l) { - pData = new _PrSt(); -} -WindowShell::~WindowShell() -{ - delete pData; + PAINTSTRUCT ps; + HDC hdc; + + switch (m) + { + case WM_PAINT: + hdc = BeginPaint(h, &ps); + EndPaint(h, &ps); + break; + + case WM_DESTROY: + PostQuitMessage(0); + break; + + case WM_KEYDOWN: + switch(w) + { + case VK_ESCAPE: + PostQuitMessage(0); + break; + } + break; + } + + return DefWindowProc(h, m, w, l); } - - -bool WindowShell::createWin(WINDOW_INIT_DESC &desc) +HINSTANCE WindowShell::GetHINSTANCE() { - if(pData->hWnd) - { - MessageBox(0, L"There is already a window registered\nPlease use child windows to create more windows!" ,L"Error", 0); - return false; - } - if(!desc.windowProcCallback) - { - MessageBox(0, L"No callback function for window messages was found!" ,L"Error", 0); - return false; - } - if(desc.windowSize.x < 0 || desc.windowSize.y < 0) - { - MessageBox(0, L"Size specified for window is invalid!" ,L"Error", 0); - return false; - } - - if(!desc.hInstance) - { - desc.hInstance = GetModuleHandle(0); - } - - - pData->hIns = desc.hInstance; + return __windowShellData.hIns; +} +HWND WindowShell::GetHWND() +{ + return __windowShellData.hWnd; +} +HWND WindowShell::GetParent() +{ + return __windowShellData.parent; +} +bool WindowShell::CreateWin(WINDOW_INIT_DESC &desc) +{ + if(__windowShellData.hWnd) return false; + if(!desc.windowProcCallback) desc.windowProcCallback = DefaultWindowCallback; + if(!desc.hInstance) desc.hInstance = GetModuleHandle(0); + if(desc.windowSize.x <= 0) desc.windowSize.x = 50; + if(desc.windowSize.y <= 0) desc.windowSize.y = 50; + + __windowShellData.parent = desc.parent; + __windowShellData.hIns = desc.hInstance; + __windowShellData.windowClassName = L"MainWindowShellClassName"; #pragma region Register @@ -92,12 +92,12 @@ bool WindowShell::createWin(WINDOW_INIT_DESC &desc) wc.lpfnWndProc = desc.windowProcCallback; wc.cbClsExtra = 0; wc.cbWndExtra = 0; - wc.hInstance = pData->hIns; - wc.hIcon = LoadIcon(0, IDI_APPLICATION); - wc.hCursor = LoadCursor(0, IDC_ARROW); - wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); - wc.lpszMenuName = 0; - wc.lpszClassName = L"MainWindowClass"; + wc.hInstance = __windowShellData.hIns; + wc.hIcon = desc.icon; + wc.hCursor = desc.cursor; + wc.hbrBackground = desc.background; + wc.lpszMenuName = NULL; + wc.lpszClassName = __windowShellData.windowClassName; if( !RegisterClassEx(&wc) ) { @@ -110,168 +110,131 @@ bool WindowShell::createWin(WINDOW_INIT_DESC &desc) #pragma region Create window - pData->hWnd = CreateWindow( - L"MainWindowClass" , - desc.windowName.c_str(), - desc.windowStyle, - desc.windowPosition.x, - desc.windowPosition.y, - desc.windowSize.x, - desc.windowSize.y, - 0, - 0, - pData->hIns, - 0 - ); + RECT rectW; + int width; + int height; + DWORD style = desc.windowStyle; + bool windowed = false; + + width = desc.windowSize.x + GetSystemMetrics(SM_CXFIXEDFRAME)*2; + height = desc.windowSize.y + GetSystemMetrics(SM_CYFIXEDFRAME)*2 + GetSystemMetrics(SM_CYCAPTION); + + rectW.left=(GetSystemMetrics(SM_CXSCREEN)-width)/2; + rectW.top=(GetSystemMetrics(SM_CYSCREEN)-height)/2; + rectW.right=rectW.left+width; + rectW.bottom=rectW.top+height; - if( !pData->hWnd ) + + if(__windowShellData.parent) { - MessageBox(0, L"Failed to create window", L"Error!", 0); + rectW.left = 0; + rectW.top = 0; + rectW.right = desc.windowSize.x; + rectW.bottom = desc.windowSize.y; + style = WS_CHILD | WS_VISIBLE; + windowed = true; + } + + if(windowed) + { + __windowShellData.hWnd = CreateWindowEx( + 0, + __windowShellData.windowClassName , + desc.windowName, + style, + rectW.left, + rectW.top, + rectW.right - rectW.left, + rectW.bottom - rectW.top, + __windowShellData.parent, + NULL, + __windowShellData.hIns, + NULL + ); + } + else + { + __windowShellData.hWnd = CreateWindowEx( + 0, + __windowShellData.windowClassName , + desc.windowName, + style, + desc.windowPosition.x, + desc.windowPosition.y, + desc.windowSize.x, + desc.windowSize.y, + 0, + 0, + __windowShellData.hIns, + 0 + ); + } + + if( !__windowShellData.hWnd ) + { + printf("Failed to create window handle : Code ( %ul )", GetLastError()); + //MessageBox(0, L"Failed to create window", L"Error!", 0); return false; } #pragma endregion - + //Show and update window - ShowWindow(pData->hWnd, SW_SHOW); - UpdateWindow(pData->hWnd); + ShowWindow(__windowShellData.hWnd, SW_SHOW); + UpdateWindow(__windowShellData.hWnd); return true; } -int WindowShell::createChildWin(CHILD_WINDOW_INIT_DESC &desc) +bool WindowShell::CreateConsoleWindow(bool redirectStdOut, const wchar_t* title) { - ChildWin win; + // allocate a console for this app + if(AllocConsole() == FALSE) return false; - - char idStr[3]; - _itoa_s(win.id, idStr, 10); - std::string next = idStr; - std::wstring str = std::wstring(next.begin(), next.end()); - std::wstring childClassName = L"ChildWindow_"; - childClassName += str; - - WNDCLASSEX wcex; - wcex.cbSize = sizeof(WNDCLASSEX); - wcex.style = CS_VREDRAW; - wcex.lpfnWndProc = desc.windowProcCallback; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = pData->hIns; - wcex.hIcon = NULL; - wcex.hCursor = LoadCursor(0, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); - wcex.lpszMenuName = NULL; - wcex.lpszClassName = childClassName.c_str(); - wcex.hIconSm = NULL; - - if(!RegisterClassEx(&wcex)) + if(redirectStdOut) { - MessageBox(0, L"", 0, 0); - } - - if(!desc.style) - desc.style = WS_EX_CLIENTEDGE; - - win.hWnd = CreateWindowEx - ( - desc.style, - childClassName.c_str(), - desc.name.c_str(), - WS_CAPTION | WS_SYSMENU , - desc.topLeftPos.x, desc.topLeftPos.y, - desc.windowSize.x, desc.windowSize.y, - pData->hWnd, - NULL, - pData->hIns, - NULL - ); - - - if (win.hWnd) - { - pData->childWindows.push_back(win); - ShowWindow(win.hWnd, 5); - UpdateWindow(win.hWnd); - } - else - { - DWORD err = GetLastError(); - MessageBox(0, L"Failed to create child window", L"Error!", MB_OK); - return false; - } - - return win.id; -} -bool WindowShell::removeChild(int id) -{ - for (int i = 0; i < (int)pData->childWindows.size(); i++) - { - if(id == pData->childWindows[i].id) + // redirect unbuffered STDOUT to the console + HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE); + int fileDescriptor = _open_osfhandle((intptr_t)consoleHandle, _O_TEXT); + FILE *fp = _fdopen( fileDescriptor, "w" ); + *stdout = *fp; + setvbuf( stdout, NULL, _IONBF, 0 ); + + + // give the console window a bigger buffer size + CONSOLE_SCREEN_BUFFER_INFO csbi; + if ( GetConsoleScreenBufferInfo(consoleHandle, &csbi) ) { - pData->childWindows.erase(pData->childWindows.begin() + i); - return true; + COORD bufferSize; + bufferSize.X = csbi.dwSize.X; + bufferSize.Y = 50; + SetConsoleScreenBufferSize(consoleHandle, bufferSize); } } - return false; + // give the console window a nicer title + SetConsoleTitle(title); + + return true; } -bool WindowShell::removeChild(HWND hwnd) +bool WindowShell::Frame() { - for (int i = 0; i < (int)pData->childWindows.size(); i++) + MSG msg = {0}; + while (true) { - if(hwnd == pData->childWindows[i].hWnd) + if(!__windowShellData.parent) { - pData->childWindows.erase(pData->childWindows.begin() + i); - return true; + if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) + { + if (msg.message == WM_QUIT) return false; + + DispatchMessage(&msg); + continue; + } } + + break; } - return false; + return true; } - - - -const HINSTANCE WindowShell::getHINSTANCE() const -{ - return pData->hIns; -} -const HWND WindowShell::getHWND() const -{ - return pData->hWnd; -} -const HWND WindowShell::getChildHWND(int id) const -{ - for(int i = 0; i<(int)pData->childWindows.size(); i++) - { - if(id == pData->childWindows[i].id) - return pData->childWindows[i].hWnd; - } - - return NULL; -} -const int WindowShell::getChildID(HWND hwnd) const -{ - for(int i = 0; i<(int)pData->childWindows.size(); i++) - { - if(hwnd == pData->childWindows[i].hWnd) - return pData->childWindows[i].id; - } - - return -1; -} - - - -WindowShell* WindowShell::self() -{ - if(!instance) - instance = new WindowShell(); - - return instance; -} -void WindowShell::destroy() -{ - delete instance; - instance = NULL; -} \ No newline at end of file diff --git a/Code/WindowManager/WindowShell.h b/Code/WindowManager/WindowShell.h index d29a3666..5adb95d4 100644 --- a/Code/WindowManager/WindowShell.h +++ b/Code/WindowManager/WindowShell.h @@ -1,85 +1,62 @@ -#ifndef GLARE_WINDOW_H -#define GLARE_WINDOW_H +////////////////////////////////////////////////////////// +// Created 2013 // +// Dennis Andersen, Linda Andersson // +////////////////////////////////////////////////////////// +#ifndef WINDOWMANAGER_WINDOWSHELL_H +#define WINDOWMANAGER_WINDOWSHELL_H #include -#include class WindowShell { - public: - struct WINDOW_INIT_DESC +public: + struct WINDOW_INIT_DESC + { + HWND parent; //!< Optional + HINSTANCE hInstance; //!< Optional + WNDPROC windowProcCallback; //!< Optional + + const wchar_t* windowName; //!< Optional + POINT windowSize; //!< Optional + POINT windowPosition; //!< Optional + + UINT windowClassStyle; //!< Optional + UINT windowStyle; //!< Optional + + HICON icon; //!< Optional + HCURSOR cursor; //!< Optional + HBRUSH background; //!< Optional + + WINDOW_INIT_DESC() { - HINSTANCE hInstance; - std::wstring windowName; - POINT windowSize; - POINT windowPosition; - WNDPROC windowProcCallback; - UINT windowClassStyle; - UINT windowStyle; - - WINDOW_INIT_DESC() - { - hInstance = NULL; - windowName = L"MADAFACKA"; - windowSize.x = 800; - windowSize.y = 600; - windowPosition.x = 0; - windowPosition.y = 0; - windowProcCallback = NULL; - windowClassStyle = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; - windowStyle = WS_OVERLAPPEDWINDOW; - } - }; - struct CHILD_WINDOW_INIT_DESC - { - std::wstring name; - DWORD style; - POINT topLeftPos; - POINT windowSize; - WNDPROC windowProcCallback; + parent = 0; + hInstance = NULL; + windowName = L"MADAFACKA"; + windowSize.x = 800; + windowSize.y = 600; + windowPosition.x = 0; + windowPosition.y = 0; + windowProcCallback = NULL; + windowClassStyle = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; + windowStyle = WS_POPUPWINDOW|WS_SYSMENU|WS_CAPTION; + //windowStyle = WS_OVERLAPPEDWINDOW; + icon = LoadIcon(0, IDI_APPLICATION); + cursor = LoadCursor(NULL, IDC_ARROW); + background = (HBRUSH)GetStockObject(BLACK_BRUSH); + //background = (HBRUSH)GetStockObject(BACKGROUND_BLUE);(HBRUSH)(COLOR_WINDOW+1); + } + }; - CHILD_WINDOW_INIT_DESC() - { - name = L"Child Window"; - style = WS_CHILD; - memset(&topLeftPos, 0, sizeof(POINT)); - windowSize.x = 300; - windowSize.y = 200; - windowProcCallback = NULL; - } - }; +public: + static HINSTANCE GetHINSTANCE (); + static HWND GetHWND (); + static HWND GetParent (); + static bool CreateWin (WINDOW_INIT_DESC&); + static bool CreateConsoleWindow (bool redirectStdOut = true, const wchar_t* title = L"Debug Output"); - - private: - WindowShell (); - WindowShell (const WindowShell&); - void operator= (const WindowShell&); - virtual~WindowShell (); - - public: - const HINSTANCE getHINSTANCE () const; - /* Returns NULL if no hwnd exists */ - const HWND getHWND () const; - /* Returns NULL if not found */ - const HWND getChildHWND (int id) const; - /* Returns -1 if not found */ - const int getChildID (HWND hwnd) const; - - /* Creates an empty window */ - bool createWin (WINDOW_INIT_DESC&); - /*Creates a child window and returns the id of child window or -1 if failed*/ - int createChildWin (CHILD_WINDOW_INIT_DESC&); - /* Removes a child window */ - bool removeChild (int id); - /* Removes a child window */ - bool removeChild (HWND hwnd); - - - /* Returns a pointer to this class, dont forget to destroy on exit */ - static WindowShell* self(); - /* Deletes the instance */ - static void destroy(); + /** Procces window messages if avalible. If the return value was false, the window was destroyed. */ + static bool Frame (); }; #endif \ No newline at end of file From e11d7d94f72a011b30eb739600037ceb3549f75b Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Thu, 12 Dec 2013 09:36:14 +0100 Subject: [PATCH 19/32] updated the weapon system, collisionManager and redid the "object" heirarki --- Bin/Content/Shaders/DebugVertex.cso | Bin 12292 -> 12292 bytes Code/Game/GameLogic/AttatchmentSocket.cpp | 22 ++++++- Code/Game/GameLogic/AttatchmentSocket.h | 2 + Code/Game/GameLogic/CollisionManager.cpp | 24 ++++--- Code/Game/GameLogic/CollisionManager.h | 9 ++- Code/Game/GameLogic/DynamicObject.cpp | 26 +++----- Code/Game/GameLogic/DynamicObject.h | 11 ++-- Code/Game/GameLogic/GameLogicStates.h | 9 ++- Code/Game/GameLogic/Level.cpp | 8 +-- Code/Game/GameLogic/Level.h | 2 + Code/Game/GameLogic/Object.cpp | 40 ++++++------ Code/Game/GameLogic/Object.h | 27 ++------ Code/Game/GameLogic/Player.cpp | 14 ++-- Code/Game/GameLogic/Player.h | 5 +- Code/Game/GameLogic/RefManager.h | 1 - Code/Game/GameLogic/StaticObject.cpp | 24 +++---- Code/Game/GameLogic/StaticObject.h | 6 +- Code/Game/GameLogic/Weapon.cpp | 75 ++++++++++++++++++++-- Code/Game/GameLogic/Weapon.h | 13 +++- 19 files changed, 197 insertions(+), 121 deletions(-) diff --git a/Bin/Content/Shaders/DebugVertex.cso b/Bin/Content/Shaders/DebugVertex.cso index e35466e14dca7c76b79bb799b061e06a02989cce..4e8292c6b9d3cd124bebd03c7ec3fd0a25ae8a33 100644 GIT binary patch delta 535 zcmZokXh{%piEwgmxMmkFX%Q`bU2x&g3!(w(8%4fwOFX=}EQpbTfgySASH20`1^m~P z1_{cp`Ovvpf#(goQ3puM*(xTqIJKxa#^rGHp(VKmi7uJxF)sPZrManjCB-rBnI#^j zNii;oc}bax#glzC?RAr_VoJd}QVuT$>qr6WNP+7}&n(FR>PUg=kP@}iMzVtl8|)@W zh@FlMgcLPj(R#kp=0| z0Ai4e1hH*wZa_BNyv>eG{fwJgB;GJG-q`$6(wvX6VzQ=&KXbwBrpeVB<%)-iaH9R> zF3qaR0ZbOMQ}hfOafR}X$%P)WD}cBj=s61@4FWqhE9yLE1^|$krx*YL delta 697 zcmZokXh{%piEwh3v=b>QobD)osN7LnV|p9cMv*Vv68m4w4Ps+-<>w zXwza<8{^FiJa5>u`ax38RxzQ)sYS&xE~$BWnINh-yClCLrZ_u4Co#q)%+SQ#TtQbM zxFo-*M4`AKHK(+sEHybhCo?a-xS%LMD>b`BAyXl}sI;IUCIG}wE>Q^2FUkhWE4XA9 z0lE1_m6Pp6Jfk7zr=XahQU*1@m>BcH_5sZ=hnk-PH@{BHZgQZgwC61LQRz z08vXP$4dDKNF!=KrpCx3FaMmf||v&X*Mc@)Uqr X2Pjklq_+cU3m^>w`!_4Attatchment; + return myData->attatchment; +} + +void AttatchmentSocket::SetAttatchment(IAttatchment *attatchment) +{ + if (myData->attatchment) + { + delete myData->attatchment; + } + + myData->attatchment = attatchment; +} + +void AttatchmentSocket::RemoveAttatchment() +{ + if (myData->attatchment) + { + delete myData->attatchment; + } } diff --git a/Code/Game/GameLogic/AttatchmentSocket.h b/Code/Game/GameLogic/AttatchmentSocket.h index 1067e339..f9be588b 100644 --- a/Code/Game/GameLogic/AttatchmentSocket.h +++ b/Code/Game/GameLogic/AttatchmentSocket.h @@ -11,6 +11,8 @@ namespace GameLogic ~AttatchmentSocket(void); IAttatchment* GetAttatchment(); + void SetAttatchment(IAttatchment *attatchment); + void RemoveAttatchment(); private: struct PrivateData; diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index 52eaa4f3..b19c7de3 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -1,4 +1,9 @@ #include "CollisionManager.h" +#include "RefManager.h" +#include "PhysicsAPI.h" +#include "Object.h" +#include "DynamicObject.h" +#include "Player.h" using namespace Oyster; @@ -15,22 +20,21 @@ namespace GameLogic switch (realObj->GetType()) { - case Object::OBJECT_TYPE_BOX: - PlayerVBox(*player,(*(DynamicObject*) realObj)); + case OBJECT_TYPE_BOX: + //PlayerVBox(*player,(*(DynamicObject*) realObj)); break; - case Object::OBJECT_TYPE_PLAYER: + case OBJECT_TYPE_PLAYER: break; } - //spela ljud? ta skada? etc etc return Physics::ICustomBody::SubscriptMessage_none; } - void PlayerVBox(Player &player, DynamicObject &box) + /* void PlayerVBox(Player &player, DynamicObject &box) { - //spela ljud? ta skada? etc etc - } + spela ljud? ta skada? etc etc + }*/ Physics::ICustomBody::SubscriptMessage BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj) { @@ -39,11 +43,11 @@ namespace GameLogic switch (realObj->GetType()) { - case Object::OBJECT_TYPE_BOX: + case OBJECT_TYPE_BOX: break; - case Object::OBJECT_TYPE_PLAYER: - PlayerVBox(*(Player*)realObj,*box); + case OBJECT_TYPE_PLAYER: + //PlayerVBox(*(Player*)realObj,*box); break; } diff --git a/Code/Game/GameLogic/CollisionManager.h b/Code/Game/GameLogic/CollisionManager.h index f88404cc..86a05906 100644 --- a/Code/Game/GameLogic/CollisionManager.h +++ b/Code/Game/GameLogic/CollisionManager.h @@ -3,9 +3,8 @@ #include "Object.h" #include "PhysicsAPI.h" -#include "RefManager.h" -#include "DynamicObject.h" -#include "Player.h" +//#include "DynamicObject.h" +//#include "Player.h" namespace GameLogic { @@ -18,8 +17,8 @@ namespace GameLogic Oyster::Physics::ICustomBody::SubscriptMessage BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj); //these are the specific collision case functions - void PlayerVBox(Player &player, DynamicObject &box); - void BoxVBox(DynamicObject &box1, DynamicObject &box2); + //void PlayerVBox(Player &player, DynamicObject &box); + //void BoxVBox(DynamicObject &box1, DynamicObject &box2); }; diff --git a/Code/Game/GameLogic/DynamicObject.cpp b/Code/Game/GameLogic/DynamicObject.cpp index 8786255c..a8ea1ab4 100644 --- a/Code/Game/GameLogic/DynamicObject.cpp +++ b/Code/Game/GameLogic/DynamicObject.cpp @@ -1,29 +1,23 @@ #include "DynamicObject.h" +#include "CollisionManager.h" using namespace GameLogic; -struct DynamicObject::PrivateData -{ - PrivateData() - { - - } - - ~PrivateData() - { - - } - -}myData; - DynamicObject::DynamicObject() + :Object() { - myData = new PrivateData(); + +} + +DynamicObject::DynamicObject(void* collisionFunc, OBJECT_TYPE type) + :Object(collisionFunc, type) +{ + } DynamicObject::~DynamicObject(void) { - delete myData; + } \ No newline at end of file diff --git a/Code/Game/GameLogic/DynamicObject.h b/Code/Game/GameLogic/DynamicObject.h index ecf1e905..70bb8c11 100644 --- a/Code/Game/GameLogic/DynamicObject.h +++ b/Code/Game/GameLogic/DynamicObject.h @@ -1,27 +1,24 @@ ////////////////////////////////////////////////// //Created by Erik and Linda of the GameLogic team ////////////////////////////////////////////////// - - #ifndef DYNAMICOBJECT_H #define DYNAMICOBJECT_H +#include "Object.h" namespace GameLogic { - class DynamicObject + class DynamicObject : public Object { public: DynamicObject(); + DynamicObject(void* collisionFunc, OBJECT_TYPE type); ~DynamicObject(void); - void Update(); - private: - struct PrivateData; - PrivateData *myData; + }; } diff --git a/Code/Game/GameLogic/GameLogicStates.h b/Code/Game/GameLogic/GameLogicStates.h index 3c2b9997..3e72647e 100644 --- a/Code/Game/GameLogic/GameLogicStates.h +++ b/Code/Game/GameLogic/GameLogicStates.h @@ -36,6 +36,13 @@ namespace GameLogic WEAPON_STATE_IDLE = 1, WEAPON_STATE_RELOADING = 2, }; -} + + enum OBJECT_TYPE + { + OBJECT_TYPE_PLAYER = 0, + OBJECT_TYPE_BOX = 1, + OBJECT_TYPE_UNKNOWN = 2, + }; +}; #endif \ No newline at end of file diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index c83056c6..38865f63 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -9,14 +9,10 @@ struct Level::PrivateData { PrivateData() { - gameMode = new GameMode(); + } ~PrivateData() { - if (gameMode) - { - delete gameMode; - } } @@ -40,3 +36,5 @@ Level::~Level(void) { delete myData; } + + diff --git a/Code/Game/GameLogic/Level.h b/Code/Game/GameLogic/Level.h index 217a60e4..9c7adb1a 100644 --- a/Code/Game/GameLogic/Level.h +++ b/Code/Game/GameLogic/Level.h @@ -14,6 +14,8 @@ namespace GameLogic Level(void); ~Level(void); + void CreateBox(); + private: struct PrivateData; PrivateData *myData; diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp index 67385874..7eb4b57f 100644 --- a/Code/Game/GameLogic/Object.cpp +++ b/Code/Game/GameLogic/Object.cpp @@ -1,23 +1,15 @@ #include "Object.h" #include "OysterMath.h" -#include "DllInterfaces\GFXAPI.h" -#include "CollisionManager.h" +#include "RefManager.h" using namespace GameLogic; using namespace Oyster::Math; -using namespace Oyster::Graphics::Model; - -using namespace Utility::DynamicMemory; using namespace Oyster::Physics; -Object::Object(std::wstring objFile) -{ - - //model = new Model(); - model = Oyster::Graphics::API::CreateModel(objFile); - +Object::Object() +{ API::SimpleBodyDescription sbDesc; //sbDesc.centerPosition = @@ -26,23 +18,33 @@ Object::Object(std::wstring objFile) GameLogic::RefManager::getInstance()->AddMapping(*rigidBody, *this); + this->type = OBJECT_TYPE_UNKNOWN; + +} + +Object::Object(void* collisionFunc, OBJECT_TYPE type) +{ + API::SimpleBodyDescription sbDesc; + //sbDesc.centerPosition = + + //poi + ICustomBody* temp = rigidBody = API::Instance().CreateRigidBody(sbDesc).Release(); + + rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Collision)(collisionFunc)); + + GameLogic::RefManager::getInstance()->AddMapping(*rigidBody, *this); + + this->type = type; } Object::~Object(void) { - Oyster::Graphics::API::DeleteModel(model); } -void Object::Render() -{ - this->rigidBody->GetOrientation(model->WorldMatrix); - Oyster::Graphics::API::RenderScene(model, 1); -} - -Object::OBJECT_TYPE Object::GetType() +OBJECT_TYPE Object::GetType() { return this->type; } diff --git a/Code/Game/GameLogic/Object.h b/Code/Game/GameLogic/Object.h index 1c1c2830..e2c1bee4 100644 --- a/Code/Game/GameLogic/Object.h +++ b/Code/Game/GameLogic/Object.h @@ -7,41 +7,24 @@ #define OBJECT_H #include "PhysicsAPI.h" -#include "DllInterfaces/GFXAPI.h" - -#include "Model/Model.h" -#include "Utilities.h" - - +#include "GameLogicStates.h" +#include "CollisionManager.h" namespace GameLogic { class Object { public: - - enum OBJECT_TYPE - { - OBJECT_TYPE_PLAYER, - OBJECT_TYPE_BOX, - }; - Object(std::wstring objFile ); - virtual ~Object(void); - - void Render(); + Object(); + Object(void* collisionFunc, OBJECT_TYPE type); + ~Object(void); OBJECT_TYPE GetType(); private: OBJECT_TYPE type; - protected: - //either a model pointer or an ID to an arraypos filled with models that are to be rendered - //rigidBody - Oyster::Physics::ICustomBody *rigidBody; - Oyster::Graphics::Model::Model *model; - }; } diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 9bc9d752..ad81bf61 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -15,8 +15,6 @@ struct Player::PrivateData life = 100; playerState = PLAYER_STATE_IDLE; - rigidBody->SetSubscription(CollisionManager::PlayerCollision); - } ~PrivateData() @@ -30,16 +28,16 @@ struct Player::PrivateData int life; Weapon *weapon; PLAYER_STATE playerState; - - ICustomBody *rigidBody; + Oyster::Math::Float3 lookDir; }myData; Player::Player() + :Object(CollisionManager::PlayerCollision, OBJECT_TYPE_PLAYER) { myData = new PrivateData(); - } + Player::~Player(void) { delete myData; @@ -83,9 +81,9 @@ void Player::Move(const PLAYER_MOVEMENT &movement) /******************************************************** * Uses the players weapon based on user input ********************************************************/ -void Player::Shoot(const WEAPON_FIRE &fireInput) +void Player::UseWeapon(const WEAPON_FIRE &fireInput) { - myData->weapon->UseWeapon(fireInput); + myData->weapon->Use(fireInput); } /******************************************************** @@ -112,7 +110,7 @@ bool Player::IsIdle() Oyster::Math::Float3 Player::GetPos() { - return myData->rigidBody->GetCenter(); + return rigidBody->GetCenter(); } /******************************************************** diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h index 20fc8de6..44b28ceb 100644 --- a/Code/Game/GameLogic/Player.h +++ b/Code/Game/GameLogic/Player.h @@ -5,10 +5,11 @@ #define PLAYER_H #include "GameLogicStates.h" #include "OysterMath.h" +#include "Object.h" namespace GameLogic { - class Player + class Player : public Object { public: @@ -17,7 +18,7 @@ namespace GameLogic void Update(); void Move(const PLAYER_MOVEMENT &movement); - void Shoot(const WEAPON_FIRE &fireInput); + void UseWeapon(const WEAPON_FIRE &fireInput); void Jump(); bool IsWalking(); diff --git a/Code/Game/GameLogic/RefManager.h b/Code/Game/GameLogic/RefManager.h index a184e220..fa4080c9 100644 --- a/Code/Game/GameLogic/RefManager.h +++ b/Code/Game/GameLogic/RefManager.h @@ -8,7 +8,6 @@ #include #include "Object.h" -#include "PhysicsAPI.h" namespace GameLogic { diff --git a/Code/Game/GameLogic/StaticObject.cpp b/Code/Game/GameLogic/StaticObject.cpp index c58fb83c..155834fe 100644 --- a/Code/Game/GameLogic/StaticObject.cpp +++ b/Code/Game/GameLogic/StaticObject.cpp @@ -2,28 +2,22 @@ using namespace GameLogic; -struct StaticObject::PrivateData -{ - PrivateData() - { - - } - - ~PrivateData() - { - - } - -}myData; StaticObject::StaticObject() + :Object() { - myData = new PrivateData(); + +} + +StaticObject::StaticObject(void* collisionFunc, OBJECT_TYPE type) + :Object(collisionFunc,type) +{ + } StaticObject::~StaticObject(void) { - delete myData; + } diff --git a/Code/Game/GameLogic/StaticObject.h b/Code/Game/GameLogic/StaticObject.h index 2f292795..31121447 100644 --- a/Code/Game/GameLogic/StaticObject.h +++ b/Code/Game/GameLogic/StaticObject.h @@ -11,16 +11,16 @@ namespace GameLogic { - class StaticObject + class StaticObject : public Object { public: StaticObject(); + StaticObject(void* collisionFunc, OBJECT_TYPE type); ~StaticObject(void); private: - struct PrivateData; - PrivateData *myData; + }; } diff --git a/Code/Game/GameLogic/Weapon.cpp b/Code/Game/GameLogic/Weapon.cpp index 2a575039..4bf4311c 100644 --- a/Code/Game/GameLogic/Weapon.cpp +++ b/Code/Game/GameLogic/Weapon.cpp @@ -9,20 +9,23 @@ struct Weapon::PrivateData PrivateData() { weaponState = WEAPON_STATE_IDLE; - SelectedAttatchment = new AttatchmentMassDriver(); + SelectedAttatchment = 0; + currentNrOfAttatchments = 0; + selectedSocketID = 0; } ~PrivateData() { - delete SelectedAttatchment; } WEAPON_STATE weaponState; AttatchmentSocket **attatchmentSockets; - int nrOfAttatchmentSockets; + int MaxNrOfSockets; + int currentNrOfAttatchments; IAttatchment *SelectedAttatchment; + int selectedSocketID; }myData; @@ -31,6 +34,17 @@ Weapon::Weapon() myData = new PrivateData(); } +Weapon::Weapon(int MaxNrOfSockets) +{ + myData = new PrivateData(); + myData->MaxNrOfSockets = MaxNrOfSockets; + myData->attatchmentSockets = new AttatchmentSocket*[MaxNrOfSockets]; + for (int i = 0; i < MaxNrOfSockets; i++) + { + myData->attatchmentSockets[i] = new AttatchmentSocket(); + } +} + Weapon::~Weapon(void) { @@ -40,7 +54,7 @@ Weapon::~Weapon(void) /******************************************************** * Uses the weapon based on the input given and the current chosen attatchment ********************************************************/ -void Weapon::UseWeapon(const WEAPON_FIRE &fireInput) +void Weapon::Use(const WEAPON_FIRE &fireInput) { myData->SelectedAttatchment->UseAttatchment(fireInput); } @@ -67,3 +81,56 @@ bool Weapon::IsReloading() return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_RELOADING); } +bool Weapon::IsValidSocket(int socketID) +{ + if(socketID < myData->MaxNrOfSockets && socketID >= 0) + { + if (myData->attatchmentSockets[socketID]->GetAttatchment() != 0) + { + return true; + } + } + + return false; +} + +int Weapon::GetCurrentSocketID() +{ + return myData->selectedSocketID; +} + + +void Weapon::AddNewAttatchment(IAttatchment *attatchment) +{ + if(myData->currentNrOfAttatchments < myData->MaxNrOfSockets) + { + myData->attatchmentSockets[myData->currentNrOfAttatchments]->SetAttatchment(attatchment); + myData->currentNrOfAttatchments++; + } +} + +void Weapon::SwitchAttatchment(IAttatchment *attatchment, int socketID) +{ + if (IsValidSocket(socketID)) + { + myData->attatchmentSockets[socketID]->SetAttatchment(attatchment); + } +} + +void Weapon::RemoveAttatchment(int socketID) +{ + if (IsValidSocket(socketID)) + { + myData->attatchmentSockets[socketID]->RemoveAttatchment(); + } +} + +void Weapon::SelectAttatchment(int socketID) +{ + if (IsValidSocket(socketID)) + { + myData->SelectedAttatchment = myData->attatchmentSockets[socketID]->GetAttatchment(); + myData->selectedSocketID = socketID; + } + +} \ No newline at end of file diff --git a/Code/Game/GameLogic/Weapon.h b/Code/Game/GameLogic/Weapon.h index 74a408e9..b5239b6e 100644 --- a/Code/Game/GameLogic/Weapon.h +++ b/Code/Game/GameLogic/Weapon.h @@ -4,6 +4,7 @@ #ifndef WEAPON_H #define WEAPON_H #include "GameLogicStates.h" +#include "IAttatchment.h" namespace GameLogic { @@ -15,14 +16,24 @@ namespace GameLogic Weapon(void); + Weapon(int nrOfAttatchmentSockets); ~Weapon(void); - void UseWeapon(const WEAPON_FIRE &fireInput); + void Use(const WEAPON_FIRE &fireInput); + void AddNewAttatchment(IAttatchment *attatchment); + void SwitchAttatchment(IAttatchment *attatchment, int socketID); + void RemoveAttatchment(int socketID); + + void SelectAttatchment(int socketID); bool IsFireing(); bool IsIdle(); bool IsReloading(); + bool IsValidSocket(int socketID); + + int GetCurrentSocketID(); + private: From c740bd593566070d744d1eb562ede6e1c88bd5b9 Mon Sep 17 00:00:00 2001 From: Robin Engman Date: Thu, 12 Dec 2013 10:02:35 +0100 Subject: [PATCH 20/32] Added some data to PhysicsAPI GetRigidLinearVelocity() and void* as reference to game object. --- Bin/Content/Shaders/TextureDebug.cso | Bin 14560 -> 14560 bytes .../Implementation/SimpleRigidBody.cpp | 6 ++++++ .../Implementation/SimpleRigidBody.h | 1 + .../Implementation/SphericalRigidBody.cpp | 5 +++++ .../Implementation/SphericalRigidBody.h | 1 + Code/GamePhysics/PhysicsAPI.h | 10 ++++++++++ 6 files changed, 23 insertions(+) diff --git a/Bin/Content/Shaders/TextureDebug.cso b/Bin/Content/Shaders/TextureDebug.cso index 0dc6bcffa9d17cf2aa80d41dbe8b05fa689ed0ac..23c9aa238f2caca3ef27eaef75cc83f52464c37c 100644 GIT binary patch delta 623 zcmaD*_@Ge4CBn&h70aI$-5H{x-{K2bK8^fgxKZQ+kA#2a${;*$!r)yt7q|OPHaFxp|CxW{E;jYC(Q+W=Vcg<>Xo7rjvEV#YM`%lIcLnB7~%; zxVH!nT`stEm`;|I=ogTFWWcxvXs_n8s5{6Ojs6XSu+du84E8Ba`R z)%9m~=t!L$uA3_p4^%|Jzd{mt6gW&y)=QlHfQLmASLD2({8!HeR{*$AuG8noB?$^0 zZcA363%P(86j^pa3<82c%nrmoK+FlmAOKRQ1jHOb3{uZFS&(EqQO9|2|#=v Qh%JCJAaG*yUxUZ&0A8h{KmY&$ delta 494 zcmaD*_@Ge4CBn&>|Fq1T6$_ab$!`j??QVUnv{B>&kHmxQIYEpJ3=Hz;J|3t}>GPdk z_Pus_LGp~ve|VlSZkFIrVAKo-N(TY)5+HsD#1BF0(SQX|jB)Zp0sF}dm@GCw5a3|r z4`2qWakh$aNz8M~Oe~)KK-Zm{A=xS>B{44v#9yy(I(e437#m#Lbn;Jeejpbr>o7S+ zqGfW5u~EaaNE_@McBkWX8=8r0y^=F4??S)}5bm&16bNK>+icp;I zjp|hH$@O}PK<~;-e!#;bi7Om0PyVZCg7B2-rigid.GetView(); } +Float3 SimpleRigidBody::GetRigidLinearVelocity() const +{ + return this->rigid.GetLinearVelocity(); +} + + UpdateState SimpleRigidBody::Update( Float timeStepLength ) { this->rigid.Update_LeapFrog( timeStepLength ); diff --git a/Code/GamePhysics/Implementation/SimpleRigidBody.h b/Code/GamePhysics/Implementation/SimpleRigidBody.h index 774420c5..9eefeb48 100644 --- a/Code/GamePhysics/Implementation/SimpleRigidBody.h +++ b/Code/GamePhysics/Implementation/SimpleRigidBody.h @@ -18,6 +18,7 @@ namespace Oyster { namespace Physics State GetState() const; State & GetState( State &targetMem ) const; void SetState( const State &state ); + ::Oyster::Math::Float3 GetRigidLinearVelocity() const; void CallSubscription( const ICustomBody *proto, const ICustomBody *deuter ); bool IsAffectedByGravity() const; diff --git a/Code/GamePhysics/Implementation/SphericalRigidBody.cpp b/Code/GamePhysics/Implementation/SphericalRigidBody.cpp index 34160192..364d7454 100644 --- a/Code/GamePhysics/Implementation/SphericalRigidBody.cpp +++ b/Code/GamePhysics/Implementation/SphericalRigidBody.cpp @@ -126,6 +126,11 @@ Float4x4 & SphericalRigidBody::GetView( Float4x4 &targetMem ) const return targetMem = this->rigid.GetView(); } +Float3 SphericalRigidBody::GetRigidLinearVelocity() const +{ + return this->rigid.GetLinearVelocity(); +} + UpdateState SphericalRigidBody::Update( Float timeStepLength ) { this->rigid.Update_LeapFrog( timeStepLength ); diff --git a/Code/GamePhysics/Implementation/SphericalRigidBody.h b/Code/GamePhysics/Implementation/SphericalRigidBody.h index 1aca514d..4d003f99 100644 --- a/Code/GamePhysics/Implementation/SphericalRigidBody.h +++ b/Code/GamePhysics/Implementation/SphericalRigidBody.h @@ -19,6 +19,7 @@ namespace Oyster { namespace Physics State GetState() const; State & GetState( State &targetMem = State() ) const; void SetState( const State &state ); + ::Oyster::Math::Float3 GetRigidLinearVelocity() const; void CallSubscription( const ICustomBody *proto, const ICustomBody *deuter ); bool IsAffectedByGravity() const; diff --git a/Code/GamePhysics/PhysicsAPI.h b/Code/GamePhysics/PhysicsAPI.h index 387bf0e6..84a3d639 100644 --- a/Code/GamePhysics/PhysicsAPI.h +++ b/Code/GamePhysics/PhysicsAPI.h @@ -243,6 +243,11 @@ namespace Oyster SubscriptMessage_ignore_collision_response }; + /******************************************************** + * @param gameObjectRef: a pointer to the object in the game owning the rigid body. + ********************************************************/ + void* gameObjectRef; + typedef SubscriptMessage (*EventAction_Collision)( const ICustomBody *proto, const ICustomBody *deuter ); typedef Struct::SimpleBodyDescription SimpleBodyDescription; typedef Struct::SphericalBodyDescription SphericalBodyDescription; @@ -271,6 +276,11 @@ namespace Oyster ********************************************************/ virtual State & GetState( State &targetMem ) const = 0; + /******************************************************** + * @return the linear velocity of the rigid body in a vector. + ********************************************************/ + virtual Math::Float3 GetRigidLinearVelocity() const = 0; + /******************************************************** * @todo TODO: need doc ********************************************************/ From af7f0e01a8373782eeffadafb814f66fa4c28fd6 Mon Sep 17 00:00:00 2001 From: dean11 Date: Thu, 12 Dec 2013 10:36:55 +0100 Subject: [PATCH 21/32] Pre-network merge, (again) --- Code/DanBias.sln | 12 +++++++++ Code/Game/DanBiasServer/DanBiasServer.vcxproj | 8 +++--- Code/Game/DanBiasServer/GameServer.cpp | 26 ++++++++++++------- .../ServerObjects/NetworkSession.h | 4 +-- Code/Game/GameProtocols/GameProtocols.vcxproj | 1 + Code/Game/GameProtocols/PlayerProtocols.h | 20 +++++++------- .../GameProtocols/ProtocolIdentificationID.h | 2 ++ .../NetworkAPI/NetworkCallbackHelper.h | 16 +++++++++--- 8 files changed, 59 insertions(+), 30 deletions(-) diff --git a/Code/DanBias.sln b/Code/DanBias.sln index e2ee84d0..315bd416 100644 --- a/Code/DanBias.sln +++ b/Code/DanBias.sln @@ -57,6 +57,7 @@ Global {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Mixed Platforms.ActiveCfg = Release|x64 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Mixed Platforms.Build.0 = Release|x64 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Win32.ActiveCfg = Debug|Win32 + {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Win32.Build.0 = Debug|Win32 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|x64.ActiveCfg = Debug|x64 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|x64.Build.0 = Debug|x64 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Release|Mixed Platforms.ActiveCfg = Release|x64 @@ -68,6 +69,7 @@ Global {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|Mixed Platforms.ActiveCfg = Release|x64 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|Mixed Platforms.Build.0 = Release|x64 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|Win32.ActiveCfg = Debug|Win32 + {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|Win32.Build.0 = Debug|Win32 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|x64.ActiveCfg = Debug|x64 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|x64.Build.0 = Debug|x64 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Release|Mixed Platforms.ActiveCfg = Release|x64 @@ -79,6 +81,7 @@ Global {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Debug|Mixed Platforms.ActiveCfg = Release|x64 {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Debug|Mixed Platforms.Build.0 = Release|x64 {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Debug|Win32.ActiveCfg = Debug|Win32 + {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Debug|Win32.Build.0 = Debug|Win32 {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Debug|x64.ActiveCfg = Debug|x64 {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Debug|x64.Build.0 = Debug|x64 {4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}.Release|Mixed Platforms.ActiveCfg = Release|x64 @@ -90,6 +93,7 @@ Global {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Debug|Mixed Platforms.ActiveCfg = Release|x64 {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Debug|Mixed Platforms.Build.0 = Release|x64 {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Debug|Win32.ActiveCfg = Debug|Win32 + {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Debug|Win32.Build.0 = Debug|Win32 {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Debug|x64.ActiveCfg = Debug|x64 {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Debug|x64.Build.0 = Debug|x64 {34D6295A-00DD-4B1A-8258-97DA2818EC26}.Release|Mixed Platforms.ActiveCfg = Release|x64 @@ -113,6 +117,7 @@ Global {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|Mixed Platforms.ActiveCfg = Release|x64 {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|Mixed Platforms.Build.0 = Release|x64 {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|Win32.ActiveCfg = Debug|Win32 + {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|Win32.Build.0 = Debug|Win32 {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|x64.ActiveCfg = Debug|x64 {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Debug|x64.Build.0 = Debug|x64 {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Release|Mixed Platforms.ActiveCfg = Release|x64 @@ -136,6 +141,7 @@ Global {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|Mixed Platforms.ActiveCfg = Release|x64 {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|Mixed Platforms.Build.0 = Release|x64 {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|Win32.ActiveCfg = Debug|Win32 + {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|Win32.Build.0 = Debug|Win32 {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|x64.ActiveCfg = Debug|x64 {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|x64.Build.0 = Debug|x64 {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Release|Mixed Platforms.ActiveCfg = Release|x64 @@ -147,6 +153,7 @@ Global {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|Mixed Platforms.ActiveCfg = Release|x64 {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|Mixed Platforms.Build.0 = Release|x64 {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|Win32.ActiveCfg = Debug|Win32 + {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|Win32.Build.0 = Debug|Win32 {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|x64.ActiveCfg = Debug|x64 {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|x64.Build.0 = Debug|x64 {6A066806-F43F-4B31-A4E3-57179674F460}.Release|Mixed Platforms.ActiveCfg = Release|x64 @@ -158,6 +165,7 @@ Global {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Mixed Platforms.ActiveCfg = Release|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Mixed Platforms.Build.0 = Release|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Win32.ActiveCfg = Debug|Win32 + {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Win32.Build.0 = Debug|Win32 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|x64.ActiveCfg = Debug|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|x64.Build.0 = Debug|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Release|Mixed Platforms.ActiveCfg = Release|x64 @@ -169,6 +177,7 @@ Global {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Mixed Platforms.ActiveCfg = Release|Win32 {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Mixed Platforms.Build.0 = Release|Win32 {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Win32.ActiveCfg = Debug|Win32 + {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Win32.Build.0 = Debug|Win32 {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|x64.ActiveCfg = Debug|x64 {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|x64.Build.0 = Debug|x64 {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Mixed Platforms.ActiveCfg = Release|Win32 @@ -179,6 +188,7 @@ Global {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|x64.Build.0 = Release|x64 {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|Mixed Platforms.ActiveCfg = Release|Win32 {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|Win32.ActiveCfg = Debug|Win32 + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|Win32.Build.0 = Debug|Win32 {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|x64.ActiveCfg = Debug|Win32 {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|Mixed Platforms.ActiveCfg = Release|Win32 {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|Win32.ActiveCfg = Release|Win32 @@ -197,6 +207,7 @@ Global {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Win32.ActiveCfg = Debug|Win32 + {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Win32.Build.0 = Debug|Win32 {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|x64.ActiveCfg = Debug|x64 {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|x64.Build.0 = Debug|x64 {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|Mixed Platforms.ActiveCfg = Release|Win32 @@ -220,6 +231,7 @@ Global {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Win32.ActiveCfg = Debug|Win32 + {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Win32.Build.0 = Debug|Win32 {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|x64.ActiveCfg = Debug|x64 {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|x64.Build.0 = Debug|x64 {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Release|Mixed Platforms.ActiveCfg = Release|Win32 diff --git a/Code/Game/DanBiasServer/DanBiasServer.vcxproj b/Code/Game/DanBiasServer/DanBiasServer.vcxproj index b919dade..85e6b5e2 100644 --- a/Code/Game/DanBiasServer/DanBiasServer.vcxproj +++ b/Code/Game/DanBiasServer/DanBiasServer.vcxproj @@ -113,7 +113,7 @@ Windows true - GameLogic_$(PlatformShortName)D.dll;%(DelayLoadDLLs) + GameLogic_$(PlatformShortName)D.dll;%(DelayLoadDLLs);NetworkAPI_$(PlatformShortName)D.dll NetworkAPI_$(PlatformShortName)D.lib;WindowManager_$(PlatformShortName)D.lib;%(AdditionalDependencies) @@ -130,7 +130,7 @@ Windows true - GameLogic_$(PlatformShortName)D.dll;%(DelayLoadDLLs) + GameLogic_$(PlatformShortName)D.dll;%(DelayLoadDLLs);NetworkAPI_$(PlatformShortName)D.dll NetworkAPI_$(PlatformShortName)D.lib;WindowManager_$(PlatformShortName)D.lib;%(AdditionalDependencies) @@ -151,7 +151,7 @@ true true true - GameLogic_$(PlatformShortName).dll;%(DelayLoadDLLs) + GameLogic_$(PlatformShortName).dll;%(DelayLoadDLLs);NetworkAPI_$(PlatformShortName).dll NetworkAPI_$(PlatformShortName).lib;WindowManager_$(PlatformShortName).lib;%(AdditionalDependencies) @@ -172,7 +172,7 @@ true true true - GameLogic_$(PlatformShortName).dll;%(DelayLoadDLLs) + GameLogic_$(PlatformShortName).dll;%(DelayLoadDLLs);NetworkAPI_$(PlatformShortName).dll NetworkAPI_$(PlatformShortName).lib;WindowManager_$(PlatformShortName).lib;%(AdditionalDependencies) diff --git a/Code/Game/DanBiasServer/GameServer.cpp b/Code/Game/DanBiasServer/GameServer.cpp index 104841cd..a2c487d8 100644 --- a/Code/Game/DanBiasServer/GameServer.cpp +++ b/Code/Game/DanBiasServer/GameServer.cpp @@ -7,18 +7,18 @@ #include "GameServer.h" #include "Utilities.h" #include "ServerInitReader.h" +#include namespace DanBias { using namespace Oyster::Network; - //void GameServer::ClientConnectCallbackFunction(Oyster::Network::NetworkClient& connectedClient) - //{ - // if( - //} void GameServer::ClientConnectCallback(NetworkClient &client) { - + printf("Client connected!\n"); + GameLogic::Protocol_TEST t; + t.text = "Hello"; + client.Send(t); } GameServer::GameServer() : initiated(0) @@ -42,9 +42,10 @@ namespace DanBias if(!LoadIniFile(data)) return DanBiasServerReturn_Error; NetworkServer::INIT_DESC serverDesc; - serverDesc.port = data.port; this->maxClients = data.clients; - serverDesc.callback = this; + serverDesc.port = data.port; + serverDesc.recvObj = this; + serverDesc.callbackType = Oyster::Network::NetworkClientCallbackType_Object; if(!this->server->Init(serverDesc)) return DanBiasServerReturn_Error; if(!WindowShell::CreateConsoleWindow()) return DanBiasServerReturn_Error; @@ -55,9 +56,11 @@ namespace DanBias } DanBiasServerReturn GameServer::Run() { - if(this->running) return DanBiasServerReturn_Error; - if(this->released) return DanBiasServerReturn_Error; - if(!this->initiated) return DanBiasServerReturn_Error; + if(this->running) return DanBiasServerReturn_Error; + if(this->released) return DanBiasServerReturn_Error; + if(!this->initiated) return DanBiasServerReturn_Error; + + if(!this->server->Start()) return DanBiasServerReturn_Error; this->running = true; while (this->running) @@ -70,6 +73,9 @@ namespace DanBias } DanBiasServerReturn GameServer::Release() { + this->server->Shutdown(); + delete this->server; + delete this->mainLobby; this->released = true; return DanBiasServerReturn_Sucess; } diff --git a/Code/Game/DanBiasServer/ServerObjects/NetworkSession.h b/Code/Game/DanBiasServer/ServerObjects/NetworkSession.h index 6653c297..5776a0f9 100644 --- a/Code/Game/DanBiasServer/ServerObjects/NetworkSession.h +++ b/Code/Game/DanBiasServer/ServerObjects/NetworkSession.h @@ -22,8 +22,8 @@ namespace DanBias void Kick(Utility::DynamicMemory::SmartPointer client); void Kick(); - void Send(Network::CustomNetProtocol& protocol); - void Send(Network::CustomNetProtocol& protocol, int ID); + void Send(Oyster::Network::CustomNetProtocol& protocol); + void Send(Oyster::Network::CustomNetProtocol& protocol, int ID); //TODO: Do more lobby features diff --git a/Code/Game/GameProtocols/GameProtocols.vcxproj b/Code/Game/GameProtocols/GameProtocols.vcxproj index 629ecf72..bf58e575 100644 --- a/Code/Game/GameProtocols/GameProtocols.vcxproj +++ b/Code/Game/GameProtocols/GameProtocols.vcxproj @@ -156,6 +156,7 @@ + diff --git a/Code/Game/GameProtocols/PlayerProtocols.h b/Code/Game/GameProtocols/PlayerProtocols.h index c579d701..5d107fd0 100644 --- a/Code/Game/GameProtocols/PlayerProtocols.h +++ b/Code/Game/GameProtocols/PlayerProtocols.h @@ -13,7 +13,7 @@ namespace GameLogic { - struct Protocol_PlayerMovement :public Network::CustomProtocolObject + struct Protocol_PlayerMovement :public Oyster::Network::CustomProtocolObject { int ProtocolID; bool bForward; @@ -27,15 +27,15 @@ namespace GameLogic { this->protocol[0].value = ProtocolID = protocol_PlayerNavigation; - this->protocol[0].type = Network::NetAttributeType_Int; - this->protocol[1].type = Network::NetAttributeType_Bool; - this->protocol[2].type = Network::NetAttributeType_Bool; - this->protocol[3].type = Network::NetAttributeType_Bool; - this->protocol[4].type = Network::NetAttributeType_Bool; - this->protocol[5].type = Network::NetAttributeType_Bool; - this->protocol[6].type = Network::NetAttributeType_Bool; + this->protocol[0].type = Oyster::Network::NetAttributeType_Int; + 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[4].type = Oyster::Network::NetAttributeType_Bool; + this->protocol[5].type = Oyster::Network::NetAttributeType_Bool; + this->protocol[6].type = Oyster::Network::NetAttributeType_Bool; } - Network::CustomNetProtocol* GetProtocol() override + Oyster::Network::CustomNetProtocol* GetProtocol() override { this->protocol[1].value = bForward; this->protocol[2].value = bBackward; @@ -48,7 +48,7 @@ namespace GameLogic } private: - Network::CustomNetProtocol protocol; + Oyster::Network::CustomNetProtocol protocol; }; } diff --git a/Code/Game/GameProtocols/ProtocolIdentificationID.h b/Code/Game/GameProtocols/ProtocolIdentificationID.h index 5890e9ff..747d25ff 100644 --- a/Code/Game/GameProtocols/ProtocolIdentificationID.h +++ b/Code/Game/GameProtocols/ProtocolIdentificationID.h @@ -5,4 +5,6 @@ #define protocol_PlayerNavigation 0 +#define PROTOCOL_TEST 2 + #endif // !GAMEPROTOCOL_PROTOCOL_DEFINITION_ID_H diff --git a/Code/Network/NetworkAPI/NetworkCallbackHelper.h b/Code/Network/NetworkAPI/NetworkCallbackHelper.h index 5ad2b948..a458760e 100644 --- a/Code/Network/NetworkAPI/NetworkCallbackHelper.h +++ b/Code/Network/NetworkAPI/NetworkCallbackHelper.h @@ -5,6 +5,8 @@ // Created by Dennis Andersen 2013 // ///////////////////////////////////// +#include + namespace Oyster { namespace Network @@ -37,10 +39,16 @@ namespace Oyster union RecieverObject { - ClientConnectCallbackMethod clientConnectFnc; - ProtocolRecieverFunction protocolRecieverFnc; - ClientConnectedObject *clientConnectObject; - ProtocolRecieverObject *protocolRecievedObject; + ClientConnectCallbackMethod clientConnectFnc; // !< A function pointer for sending or recieving NetworkClient + ProtocolRecieverFunction protocolRecieverFnc; // !< A function pointer for sending or recieving CustomNetProtocol + ClientConnectedObject *clientConnectObject; // !< An object for sending or recieving NetworkClient + ProtocolRecieverObject *protocolRecievedObject; // !< An object for sending or recieving CustomNetProtocol + + RecieverObject() { memset(this, 0, sizeof(RecieverObject)); } + RecieverObject(ClientConnectCallbackMethod o) { clientConnectFnc = o; } + RecieverObject(ProtocolRecieverFunction o) { protocolRecieverFnc = o; } + RecieverObject(ClientConnectedObject* o) { clientConnectObject = o; } + RecieverObject(ProtocolRecieverObject* o) { protocolRecievedObject = o; } }; } } From 8f36f64c4f3420a1bb0059c19c883cdb9a423051 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Thu, 12 Dec 2013 12:16:13 +0100 Subject: [PATCH 22/32] updated AttatchmentMassDriver and CollisionManager weapon attatchments now have a owner(player) to facillitate the weapon manipulating the player using it. CollisionManager now works with a tag void* in the rigidbody to link with a game object instead of the RefManager component --- Code/Game/GameLogic/AttatchmentMassDriver.cpp | 30 +++++++++++++++++-- Code/Game/GameLogic/AttatchmentMassDriver.h | 2 ++ Code/Game/GameLogic/CollisionManager.cpp | 20 +++++++------ Code/Game/GameLogic/CollisionManager.h | 2 -- Code/Game/GameLogic/GameLogic.vcxproj | 2 -- Code/Game/GameLogic/IAttatchment.cpp | 16 ---------- Code/Game/GameLogic/IAttatchment.h | 8 +++-- Code/Game/GameLogic/Object.cpp | 11 +++++-- Code/Game/GameLogic/Object.h | 4 ++- Code/Game/GameLogic/Player.cpp | 18 +++++++++-- Code/Game/GameLogic/Player.h | 4 +++ Code/Game/GameLogic/Weapon.h | 5 ++-- 12 files changed, 80 insertions(+), 42 deletions(-) diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp index 18324149..c6639953 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -1,4 +1,5 @@ #include "AttatchmentMassDriver.h" +#include "PhysicsAPI.h" using namespace GameLogic; @@ -19,11 +20,20 @@ struct AttatchmentMassDriver::PrivateData AttatchmentMassDriver::AttatchmentMassDriver(void) { + myData = new PrivateData(); + this->owner = 0; +} + +AttatchmentMassDriver::AttatchmentMassDriver(Player &owner) +{ + myData = new PrivateData(); + this->owner = &owner; } AttatchmentMassDriver::~AttatchmentMassDriver(void) { + delete myData; } /******************************************************** @@ -31,7 +41,17 @@ AttatchmentMassDriver::~AttatchmentMassDriver(void) ********************************************************/ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &fireInput) { - ForcePush(fireInput); + //switch case to determin what functionallity to use in the attatchment + switch (fireInput) + { + case WEAPON_FIRE::WEAPON_USE_PRIMARY_PRESS: + ForcePush(fireInput); + break; + case WEAPON_FIRE::WEAPON_USE_SECONDARY_PRESS: + ForcePull(fireInput); + break; + } + } /******************************************************** @@ -39,7 +59,13 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &fireInp ********************************************************/ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &fireInput) { - + //create coneRigidBody that will then collide with object and push them in the aimed direction +} + + +void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &fireInput) +{ + Oyster::Physics::API::Instance().ApplyForceAt(owner->GetRigidBody(), owner->GetRigidBody()->GetCenter(), owner->GetLookDir() * 100); } diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.h b/Code/Game/GameLogic/AttatchmentMassDriver.h index bc95c327..879938fe 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.h +++ b/Code/Game/GameLogic/AttatchmentMassDriver.h @@ -8,6 +8,7 @@ namespace GameLogic { public: AttatchmentMassDriver(void); + AttatchmentMassDriver(Player &owner); ~AttatchmentMassDriver(void); @@ -15,6 +16,7 @@ namespace GameLogic private: void ForcePush(const WEAPON_FIRE &fireInput); + void ForcePull(const WEAPON_FIRE &fireInput); private: struct PrivateData; diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index b19c7de3..3d1af2a1 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -1,5 +1,4 @@ #include "CollisionManager.h" -#include "RefManager.h" #include "PhysicsAPI.h" #include "Object.h" #include "DynamicObject.h" @@ -13,15 +12,18 @@ namespace GameLogic namespace CollisionManager { + void PlayerVBox(Player &player, DynamicObject &box); + + Physics::ICustomBody::SubscriptMessage PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj) { - Player *player = ((Player*)GameLogic::RefManager::getInstance()->GetMap(*rigidBodyPlayer)); - Object *realObj = GameLogic::RefManager::getInstance()->GetMap(*obj); + Player *player = ((Player*)(rigidBodyPlayer->gameObjectRef)); + Object *realObj = (Object*)obj->gameObjectRef; switch (realObj->GetType()) { case OBJECT_TYPE_BOX: - //PlayerVBox(*player,(*(DynamicObject*) realObj)); + PlayerVBox(*player,(*(DynamicObject*) realObj)); break; case OBJECT_TYPE_PLAYER: @@ -31,15 +33,15 @@ namespace GameLogic return Physics::ICustomBody::SubscriptMessage_none; } - /* void PlayerVBox(Player &player, DynamicObject &box) + void PlayerVBox(Player &player, DynamicObject &box) { - spela ljud? ta skada? etc etc - }*/ + player.DamageLife(20); + } Physics::ICustomBody::SubscriptMessage BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj) { - DynamicObject *box = ((DynamicObject*)GameLogic::RefManager::getInstance()->GetMap(*rigidBodyBox)); - Object *realObj = GameLogic::RefManager::getInstance()->GetMap(*obj); + DynamicObject *box = (DynamicObject*)rigidBodyBox->gameObjectRef; + Object *realObj = (Object*)obj->gameObjectRef; switch (realObj->GetType()) { diff --git a/Code/Game/GameLogic/CollisionManager.h b/Code/Game/GameLogic/CollisionManager.h index 86a05906..d19ce8e3 100644 --- a/Code/Game/GameLogic/CollisionManager.h +++ b/Code/Game/GameLogic/CollisionManager.h @@ -3,8 +3,6 @@ #include "Object.h" #include "PhysicsAPI.h" -//#include "DynamicObject.h" -//#include "Player.h" namespace GameLogic { diff --git a/Code/Game/GameLogic/GameLogic.vcxproj b/Code/Game/GameLogic/GameLogic.vcxproj index 03430feb..13491d28 100644 --- a/Code/Game/GameLogic/GameLogic.vcxproj +++ b/Code/Game/GameLogic/GameLogic.vcxproj @@ -176,7 +176,6 @@ - @@ -191,7 +190,6 @@ - diff --git a/Code/Game/GameLogic/IAttatchment.cpp b/Code/Game/GameLogic/IAttatchment.cpp index c1e2a997..4b0b1961 100644 --- a/Code/Game/GameLogic/IAttatchment.cpp +++ b/Code/Game/GameLogic/IAttatchment.cpp @@ -3,22 +3,6 @@ using namespace GameLogic; -struct IAttatchment::PrivateData -{ - PrivateData() - { - - } - - ~PrivateData() - { - - } - - - -}myData; - IAttatchment::IAttatchment(void) { } diff --git a/Code/Game/GameLogic/IAttatchment.h b/Code/Game/GameLogic/IAttatchment.h index c134026f..0b6cb061 100644 --- a/Code/Game/GameLogic/IAttatchment.h +++ b/Code/Game/GameLogic/IAttatchment.h @@ -1,6 +1,7 @@ #ifndef IATTATCHMENT_H #define IATTATCHMENT_H #include "GameLogicStates.h" +#include "Player.h" namespace GameLogic { @@ -16,9 +17,10 @@ namespace GameLogic virtual void UseAttatchment(const WEAPON_FIRE &fireInput) = 0; - private: - struct PrivateData; - PrivateData *myData; + private: + + protected: + Player *owner; }; } diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp index 7eb4b57f..dcd32bf1 100644 --- a/Code/Game/GameLogic/Object.cpp +++ b/Code/Game/GameLogic/Object.cpp @@ -1,6 +1,6 @@ #include "Object.h" #include "OysterMath.h" -#include "RefManager.h" +#include "CollisionManager.h" using namespace GameLogic; @@ -16,7 +16,7 @@ Object::Object() //poi ICustomBody* temp = rigidBody = API::Instance().CreateRigidBody(sbDesc).Release(); - GameLogic::RefManager::getInstance()->AddMapping(*rigidBody, *this); + rigidBody->gameObjectRef = this; this->type = OBJECT_TYPE_UNKNOWN; @@ -32,7 +32,7 @@ Object::Object(void* collisionFunc, OBJECT_TYPE type) rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Collision)(collisionFunc)); - GameLogic::RefManager::getInstance()->AddMapping(*rigidBody, *this); + rigidBody->gameObjectRef = this; this->type = type; } @@ -48,3 +48,8 @@ OBJECT_TYPE Object::GetType() { return this->type; } + +Oyster::Physics::ICustomBody* Object::GetRigidBody() +{ + return this->rigidBody; +} diff --git a/Code/Game/GameLogic/Object.h b/Code/Game/GameLogic/Object.h index e2c1bee4..c79c5de1 100644 --- a/Code/Game/GameLogic/Object.h +++ b/Code/Game/GameLogic/Object.h @@ -8,7 +8,7 @@ #include "PhysicsAPI.h" #include "GameLogicStates.h" -#include "CollisionManager.h" + namespace GameLogic { @@ -21,6 +21,8 @@ namespace GameLogic OBJECT_TYPE GetType(); + Oyster::Physics::ICustomBody* GetRigidBody(); + private: OBJECT_TYPE type; protected: diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index f7bdc4a6..3ebf979f 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -59,13 +59,16 @@ void Player::Update() ********************************************************/ void Player::Move(const PLAYER_MOVEMENT &movement) { + Oyster::Math::Float3 currentVelocity = rigidBody->GetRigidLinearVelocity(); + switch(movement) { case PLAYER_MOVEMENT_FORWARD: - + API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),myData->lookDir * 100); break; case PLAYER_MOVEMENT_BACKWARD: + API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),-myData->lookDir * 100); break; case PLAYER_MOVEMENT_LEFT: @@ -93,7 +96,7 @@ void Player::UseWeapon(const WEAPON_FIRE &fireInput) ********************************************************/ void Player::Jump() { - + API::Instance().ApplyForceAt(rigidBody,rigidBody->GetCenter(),-Oyster::Math::Float3(0,1,0) * 100); } bool Player::IsWalking() @@ -114,6 +117,11 @@ Oyster::Math::Float3 Player::GetPos() return rigidBody->GetCenter(); } +Oyster::Math::Float3 Player::GetLookDir() +{ + return myData->lookDir; +} + /******************************************************** * Respawns the player on a new chosen position * This resets a set of variables such as life, ammo etcetc @@ -122,3 +130,9 @@ void Player::Respawn() { } + + +void Player::DamageLife(int damage) +{ + myData->life -= damage; +} \ No newline at end of file diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h index 44b28ceb..7cf7187b 100644 --- a/Code/Game/GameLogic/Player.h +++ b/Code/Game/GameLogic/Player.h @@ -26,8 +26,12 @@ namespace GameLogic bool IsIdle(); Oyster::Math::Float3 GetPos(); + Oyster::Math::Float3 GetLookDir(); + void Respawn(); + void DamageLife(int damage); + private: struct PrivateData; PrivateData *myData; diff --git a/Code/Game/GameLogic/Weapon.h b/Code/Game/GameLogic/Weapon.h index b5239b6e..cdd1a3b7 100644 --- a/Code/Game/GameLogic/Weapon.h +++ b/Code/Game/GameLogic/Weapon.h @@ -5,6 +5,7 @@ #define WEAPON_H #include "GameLogicStates.h" #include "IAttatchment.h" +#include "Player.h" namespace GameLogic { @@ -21,8 +22,8 @@ namespace GameLogic void Use(const WEAPON_FIRE &fireInput); - void AddNewAttatchment(IAttatchment *attatchment); - void SwitchAttatchment(IAttatchment *attatchment, int socketID); + void AddNewAttatchment(IAttatchment *attatchment, Player *owner); + void SwitchAttatchment(IAttatchment *attatchment, int socketID, Player *owner); void RemoveAttatchment(int socketID); void SelectAttatchment(int socketID); From 9b9a92556a5341ca765fcc641ad88e9a6aa546cc Mon Sep 17 00:00:00 2001 From: dean11 Date: Thu, 12 Dec 2013 12:17:39 +0100 Subject: [PATCH 23/32] Pre-merge with network, (again) --- Code/Game/DanBiasServer/GameServer.cpp | 2 +- Code/Game/DanBiasServer/GameServer.h | 2 +- Code/Network/NetworkAPI/CustomNetProtocol.cpp | 35 ++++++++++++++++++- Code/Network/NetworkAPI/CustomNetProtocol.h | 2 ++ .../NetworkAPI/NetworkCallbackHelper.h | 2 +- Code/Network/NetworkAPI/Translator.cpp | 10 ++++++ Code/Network/NetworkAPI/Translator.h | 2 ++ 7 files changed, 51 insertions(+), 4 deletions(-) diff --git a/Code/Game/DanBiasServer/GameServer.cpp b/Code/Game/DanBiasServer/GameServer.cpp index a2c487d8..1cddc318 100644 --- a/Code/Game/DanBiasServer/GameServer.cpp +++ b/Code/Game/DanBiasServer/GameServer.cpp @@ -13,7 +13,7 @@ namespace DanBias { using namespace Oyster::Network; - void GameServer::ClientConnectCallback(NetworkClient &client) + void GameServer::ClientConnectCallback(NetworkClient client) { printf("Client connected!\n"); GameLogic::Protocol_TEST t; diff --git a/Code/Game/DanBiasServer/GameServer.h b/Code/Game/DanBiasServer/GameServer.h index b46891db..6354aa35 100644 --- a/Code/Game/DanBiasServer/GameServer.h +++ b/Code/Game/DanBiasServer/GameServer.h @@ -25,7 +25,7 @@ namespace DanBias private: //static void ClientConnectCallbackFunction(Oyster::Network::NetworkClient& connectedClient); - void ClientConnectCallback(Oyster::Network::NetworkClient &client) override; + void ClientConnectCallback(Oyster::Network::NetworkClient client) override; bool initiated; bool running; diff --git a/Code/Network/NetworkAPI/CustomNetProtocol.cpp b/Code/Network/NetworkAPI/CustomNetProtocol.cpp index 6160d674..1933d907 100644 --- a/Code/Network/NetworkAPI/CustomNetProtocol.cpp +++ b/Code/Network/NetworkAPI/CustomNetProtocol.cpp @@ -13,12 +13,34 @@ struct CustomNetProtocol::PrivateData PrivateData() { } + PrivateData( const CustomNetProtocol::PrivateData& o) + { + for (auto i = o.attributes.begin(); i != o.attributes.end(); i++) + { + if(i->second.type == NetAttributeType_CharArray) + { + size_t size = strlen(i->second.value.netCharPtr); + if(size == 0) continue; + + attributes[i->first]; + attributes[i->first].value.netCharPtr = new char[size + 1]; + //strcpy_s(attributes[i->first].value.netCharPtr, size + 1, i->second.value.netCharPtr); + memcpy(&attributes[i->first].value.netCharPtr[0], &i->second.value.netCharPtr[0], size + 1); + } + else + { + attributes[i->first] = i->second; + } + } + attributes = o.attributes; + } ~PrivateData() { for (auto i = attributes.begin(); i != attributes.end(); i++) { RemoveAttribute(i->first); } + attributes.clear(); } void RemoveAttribute(int ID) { @@ -28,7 +50,8 @@ struct CustomNetProtocol::PrivateData switch (i->second.type) { case NetAttributeType_CharArray: - delete [] i->second.value.netCharPtr; + //delete [] i->second.value.netCharPtr; + i->second.value.netCharPtr = 0; break; } } @@ -41,6 +64,16 @@ CustomNetProtocol::CustomNetProtocol() { this->privateData = new PrivateData(); } +CustomNetProtocol::CustomNetProtocol(const CustomNetProtocol& o) +{ + this->privateData = new PrivateData(*o.privateData); +} +const CustomNetProtocol& CustomNetProtocol::operator=(const CustomNetProtocol& o) +{ + delete this->privateData; + this->privateData = new PrivateData(*o.privateData); + return *this; +} CustomNetProtocol::~CustomNetProtocol() { delete this->privateData; diff --git a/Code/Network/NetworkAPI/CustomNetProtocol.h b/Code/Network/NetworkAPI/CustomNetProtocol.h index c1678cf9..4f01fb58 100644 --- a/Code/Network/NetworkAPI/CustomNetProtocol.h +++ b/Code/Network/NetworkAPI/CustomNetProtocol.h @@ -82,6 +82,8 @@ namespace Oyster public: CustomNetProtocol(); ~CustomNetProtocol(); + CustomNetProtocol(const CustomNetProtocol& o); + const CustomNetProtocol& operator=(const CustomNetProtocol& o); NetAttributeContainer& operator[](int ID); diff --git a/Code/Network/NetworkAPI/NetworkCallbackHelper.h b/Code/Network/NetworkAPI/NetworkCallbackHelper.h index a458760e..b0e3194d 100644 --- a/Code/Network/NetworkAPI/NetworkCallbackHelper.h +++ b/Code/Network/NetworkAPI/NetworkCallbackHelper.h @@ -30,7 +30,7 @@ namespace Oyster typedef void(*ProtocolRecieverFunction)(CustomNetProtocol& protocol); struct ClientConnectedObject { - virtual void ClientConnectCallback(NetworkClient &client) = 0; + virtual void ClientConnectCallback(NetworkClient client) = 0; }; struct ProtocolRecieverObject { diff --git a/Code/Network/NetworkAPI/Translator.cpp b/Code/Network/NetworkAPI/Translator.cpp index eb2a3d17..40f80d5f 100644 --- a/Code/Network/NetworkAPI/Translator.cpp +++ b/Code/Network/NetworkAPI/Translator.cpp @@ -220,6 +220,16 @@ Translator::~Translator() privateData = NULL; } } +Translator::Translator(const Translator& obj) +{ + this->privateData = new PrivateData(*obj.privateData); +} +const Translator& Translator::operator=(const Translator& obj) +{ + delete this->privateData; + this->privateData = new PrivateData(*obj.privateData); + return *this; +} void Translator::Pack(SmartPointer &bytes, CustomNetProtocol& protocol) { diff --git a/Code/Network/NetworkAPI/Translator.h b/Code/Network/NetworkAPI/Translator.h index 3f5fe673..ccbe43e2 100644 --- a/Code/Network/NetworkAPI/Translator.h +++ b/Code/Network/NetworkAPI/Translator.h @@ -48,6 +48,8 @@ namespace Oyster public: Translator (); ~Translator(); + Translator(const Translator& obj); + const Translator& operator=(const Translator& obj); void Pack(Utility::DynamicMemory::SmartPointer &bytes, CustomNetProtocol& protocol); From c63e9f1c084adb0a705448e1f745ae602ecc783f Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Thu, 12 Dec 2013 12:21:19 +0100 Subject: [PATCH 24/32] Some comments on the massdriver and player --- Code/Game/GameLogic/AttatchmentMassDriver.cpp | 6 ++++-- Code/Game/GameLogic/Player.cpp | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp index c6639953..b7687acb 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -55,14 +55,16 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &fireInp } /******************************************************** -* This is a specific functionallity of the weapon +* Pushes objects in a cone in front of the weapon when fired ********************************************************/ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &fireInput) { //create coneRigidBody that will then collide with object and push them in the aimed direction } - +/******************************************************** +* Pulls the player in the direction he is looking, used for fast movement(kinda like a jetpack) +********************************************************/ void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &fireInput) { Oyster::Physics::API::Instance().ApplyForceAt(owner->GetRigidBody(), owner->GetRigidBody()->GetCenter(), owner->GetLookDir() * 100); diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 3ebf979f..bae54e9a 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -15,6 +15,7 @@ struct Player::PrivateData life = 100; playerState = PLAYER_STATE_IDLE; + lookDir = Oyster::Math::Float3(1,0,0); } ~PrivateData() From 693b9df92884f53f83544fb9cfbb0763fb73365e Mon Sep 17 00:00:00 2001 From: dean11 Date: Thu, 12 Dec 2013 12:54:08 +0100 Subject: [PATCH 25/32] Some wierd stuff is going on here --- Code/Game/DanBiasServer/GameServer.cpp | 2 ++ Code/Misc/Thread/OysterThread_Impl.cpp | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Code/Game/DanBiasServer/GameServer.cpp b/Code/Game/DanBiasServer/GameServer.cpp index 1cddc318..df352a75 100644 --- a/Code/Game/DanBiasServer/GameServer.cpp +++ b/Code/Game/DanBiasServer/GameServer.cpp @@ -13,12 +13,14 @@ namespace DanBias { using namespace Oyster::Network; + void GameServer::ClientConnectCallback(NetworkClient client) { printf("Client connected!\n"); GameLogic::Protocol_TEST t; t.text = "Hello"; client.Send(t); + c = client; } GameServer::GameServer() : initiated(0) diff --git a/Code/Misc/Thread/OysterThread_Impl.cpp b/Code/Misc/Thread/OysterThread_Impl.cpp index 9605dd78..9e503c54 100644 --- a/Code/Misc/Thread/OysterThread_Impl.cpp +++ b/Code/Misc/Thread/OysterThread_Impl.cpp @@ -42,7 +42,10 @@ using namespace Utility::DynamicMemory; ThreadData() {} ~ThreadData() {} - ThreadData(const ThreadData&) {}; + ThreadData(const ThreadData&) + {}; + const ThreadData& operator =(const ThreadData& o) + {}; }; struct OysterThread::PrivateData { @@ -60,9 +63,14 @@ using namespace Utility::DynamicMemory; { threadData = o.threadData; } + const PrivateData& operator=(const PrivateData& o) + { + threadData = o.threadData; + } ~PrivateData() { //@todo TODO: Make detatch avalible. + //if(!this->threadData->workerThread->joinable()) this->threadData->workerThread->detach(); this->threadData->owner = 0; @@ -75,8 +83,6 @@ using namespace Utility::DynamicMemory; #pragma endregion -int tempId = 0; -std::vector IDS; static void ThreadingFunction(SmartPointer &origin) { @@ -159,6 +165,8 @@ OysterThread::OysterThread(const OysterThread& original) } const OysterThread& OysterThread::operator=(const OysterThread& original) { + delete this->privateData; + this->privateData = new PrivateData(*original.privateData); return *this; } OysterThread::~OysterThread() From 71d31db8843fb6d9b517e47deff58eca8d66228b Mon Sep 17 00:00:00 2001 From: dean11 Date: Thu, 12 Dec 2013 14:37:35 +0100 Subject: [PATCH 26/32] GAMELOGIC - Fixed a minor major huge issue with no problems --- Code/Game/DanBiasServer/GameServer.cpp | 5 ++-- Code/Game/GameProtocols/TEST_PROTOCOLS.h | 35 +++++++++++++++++++++++ Code/Network/NetworkAPI/NetworkClient.cpp | 2 +- Code/Network/NetworkAPI/Translator.cpp | 6 ++-- 4 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 Code/Game/GameProtocols/TEST_PROTOCOLS.h diff --git a/Code/Game/DanBiasServer/GameServer.cpp b/Code/Game/DanBiasServer/GameServer.cpp index df352a75..1c1dff3b 100644 --- a/Code/Game/DanBiasServer/GameServer.cpp +++ b/Code/Game/DanBiasServer/GameServer.cpp @@ -18,9 +18,10 @@ namespace DanBias { printf("Client connected!\n"); GameLogic::Protocol_TEST t; - t.text = "Hello"; + t.text = 'A'; client.Send(t); - c = client; + Sleep(50000); + this->mainLobby->AttachClient(Utility::DynamicMemory::SmartPointer(new NetworkClient(client))); } GameServer::GameServer() : initiated(0) diff --git a/Code/Game/GameProtocols/TEST_PROTOCOLS.h b/Code/Game/GameProtocols/TEST_PROTOCOLS.h new file mode 100644 index 00000000..df171c1f --- /dev/null +++ b/Code/Game/GameProtocols/TEST_PROTOCOLS.h @@ -0,0 +1,35 @@ +#ifndef GAMESERVER_TEST_H +#define GAMESERVER_TEST_H + +#include +#include "ProtocolIdentificationID.h" + + + +namespace GameLogic +{ + struct Protocol_TEST :public Oyster::Network::CustomProtocolObject + { + int ProtocolID; + char text; + + Protocol_TEST() + { + this->protocol[0].value = ProtocolID = PROTOCOL_TEST; + + this->protocol[0].type = Oyster::Network::NetAttributeType_Int; + this->protocol[1].type = Oyster::Network::NetAttributeType_Char; + } + Oyster::Network::CustomNetProtocol* GetProtocol() override + { + this->protocol[1].value = text; + + return &protocol; + } + + private: + Oyster::Network::CustomNetProtocol protocol; + }; +} + +#endif // !GAMESERVER_TEST_H \ No newline at end of file diff --git a/Code/Network/NetworkAPI/NetworkClient.cpp b/Code/Network/NetworkAPI/NetworkClient.cpp index 94077d52..d7b907fb 100644 --- a/Code/Network/NetworkAPI/NetworkClient.cpp +++ b/Code/Network/NetworkAPI/NetworkClient.cpp @@ -125,7 +125,7 @@ int NetworkClient::PrivateData::Send() postBoxMutex.lock(); if(sendPostBox->IsFull()) { - SmartPointer temp = new OysterByte; + SmartPointer temp = new OysterByte(); this->translator.Pack(temp, sendPostBox->FetchMessage()); errorCode = this->connection->Send(temp); } diff --git a/Code/Network/NetworkAPI/Translator.cpp b/Code/Network/NetworkAPI/Translator.cpp index ba42ea66..032fbfdb 100644 --- a/Code/Network/NetworkAPI/Translator.cpp +++ b/Code/Network/NetworkAPI/Translator.cpp @@ -56,7 +56,9 @@ struct Translator::PrivateData auto it = ((MyCastingStruct*)protocol.privateData)->attributes.begin(); auto end = ((MyCastingStruct*)protocol.privateData)->attributes.end(); - size = 4 + 2; //size(int) + number of chars(short) + size = 4; //size(int) + bytes->AddSize(4); + message.SetSize(size); //Find all the data types @@ -81,7 +83,7 @@ struct Translator::PrivateData auto it = ((MyCastingStruct*)protocol.privateData)->attributes.begin(); auto end = ((MyCastingStruct*)protocol.privateData)->attributes.end(); - for(int i = 0; i < (int)headerString.size(); i++) + for(int i = 0; i < (int)headerString.size(); i++, it++) { switch((int)headerString.at(i)) { From 4617523f8bd60b0f554bfd98a7dc8da4c07dea6f Mon Sep 17 00:00:00 2001 From: dean11 Date: Thu, 12 Dec 2013 20:32:54 +0100 Subject: [PATCH 27/32] Gamelogic - Commit because branch switch --- Code/DanBias.sln | 2 -- Code/Game/DanBiasServer/GameServer.cpp | 9 +++++---- .../DanBiasServer/ServerObjects/NetworkSession.cpp | 7 ++++++- Code/Game/GameProtocols/PlayerProtocols.h | 14 +++++++------- Code/Game/GameProtocols/ProtocolIdentificationID.h | 2 +- Code/Network/NetworkDependencies/Listener.cpp | 2 ++ 6 files changed, 21 insertions(+), 15 deletions(-) diff --git a/Code/DanBias.sln b/Code/DanBias.sln index 894caec6..fec93854 100644 --- a/Code/DanBias.sln +++ b/Code/DanBias.sln @@ -196,7 +196,6 @@ Global {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.ActiveCfg = Debug|Win32 - {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.Build.0 = Debug|Win32 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.ActiveCfg = Debug|x64 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.Build.0 = Debug|x64 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|Mixed Platforms.ActiveCfg = Release|Win32 @@ -208,7 +207,6 @@ Global {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Win32.ActiveCfg = Debug|Win32 - {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Win32.Build.0 = Debug|Win32 {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|x64.ActiveCfg = Debug|x64 {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|x64.Build.0 = Debug|x64 {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|Mixed Platforms.ActiveCfg = Release|Win32 diff --git a/Code/Game/DanBiasServer/GameServer.cpp b/Code/Game/DanBiasServer/GameServer.cpp index 1c1dff3b..227359f2 100644 --- a/Code/Game/DanBiasServer/GameServer.cpp +++ b/Code/Game/DanBiasServer/GameServer.cpp @@ -3,11 +3,13 @@ ///////////////////////////////////////////////////////////////////// #include #include +#include #include "GameServer.h" #include "Utilities.h" #include "ServerInitReader.h" #include +#include namespace DanBias { @@ -17,10 +19,7 @@ namespace DanBias void GameServer::ClientConnectCallback(NetworkClient client) { printf("Client connected!\n"); - GameLogic::Protocol_TEST t; - t.text = 'A'; - client.Send(t); - Sleep(50000); + this->mainLobby->AttachClient(Utility::DynamicMemory::SmartPointer(new NetworkClient(client))); } GameServer::GameServer() @@ -65,6 +64,8 @@ namespace DanBias if(!this->server->Start()) return DanBiasServerReturn_Error; + + this->running = true; while (this->running) { diff --git a/Code/Game/DanBiasServer/ServerObjects/NetworkSession.cpp b/Code/Game/DanBiasServer/ServerObjects/NetworkSession.cpp index 569b8a0a..94dc1412 100644 --- a/Code/Game/DanBiasServer/ServerObjects/NetworkSession.cpp +++ b/Code/Game/DanBiasServer/ServerObjects/NetworkSession.cpp @@ -1,20 +1,24 @@ #include "NetworkSession.h" - +#include namespace DanBias { NetworkSession::NetworkSession() { + } NetworkSession::~NetworkSession() { + } void NetworkSession::AttachClient(Utility::DynamicMemory::SmartPointer client) { + } void NetworkSession::DetachClient(Utility::DynamicMemory::SmartPointer client) { + } void NetworkSession::DetachClient(short ID) { @@ -23,6 +27,7 @@ namespace DanBias void NetworkSession::Kick(Utility::DynamicMemory::SmartPointer client) { + } void NetworkSession::Kick() { diff --git a/Code/Game/GameProtocols/PlayerProtocols.h b/Code/Game/GameProtocols/PlayerProtocols.h index 201e8f1d..d620af81 100644 --- a/Code/Game/GameProtocols/PlayerProtocols.h +++ b/Code/Game/GameProtocols/PlayerProtocols.h @@ -51,7 +51,7 @@ namespace GameLogic Oyster::Network::CustomNetProtocol protocol; }; - struct Protocol_PlayerPosition :public Network::CustomProtocolObject + struct Protocol_PlayerPosition :public Oyster::Network::CustomProtocolObject { float position[3]; // look at dir @@ -59,14 +59,14 @@ namespace GameLogic Protocol_PlayerPosition() { this->protocol[0].value = protocol_PlayerPosition; - this->protocol[0].type = Network::NetAttributeType_Int; + this->protocol[0].type = Oyster::Network::NetAttributeType_Int; - this->protocol[1].type = Network::NetAttributeType_Float; - this->protocol[2].type = Network::NetAttributeType_Float; - this->protocol[3].type = Network::NetAttributeType_Float; + this->protocol[1].type = Oyster::Network::NetAttributeType_Float; + this->protocol[2].type = Oyster::Network::NetAttributeType_Float; + this->protocol[3].type = Oyster::Network::NetAttributeType_Float; } - Network::CustomNetProtocol* GetProtocol() override + Oyster::Network::CustomNetProtocol* GetProtocol() override { this->protocol[1].value = position[0]; @@ -76,7 +76,7 @@ namespace GameLogic } private: - Network::CustomNetProtocol protocol; + Oyster::Network::CustomNetProtocol protocol; }; } diff --git a/Code/Game/GameProtocols/ProtocolIdentificationID.h b/Code/Game/GameProtocols/ProtocolIdentificationID.h index cb0eb552..b872618a 100644 --- a/Code/Game/GameProtocols/ProtocolIdentificationID.h +++ b/Code/Game/GameProtocols/ProtocolIdentificationID.h @@ -7,6 +7,6 @@ #define protocol_PlayerPosition 1 #define protocol_ObjectPosition 2 -#define PROTOCOL_TEST 2 +#define PROTOCOL_TEST 1000 #endif // !GAMEPROTOCOL_PROTOCOL_DEFINITION_ID_H diff --git a/Code/Network/NetworkDependencies/Listener.cpp b/Code/Network/NetworkDependencies/Listener.cpp index b82694d3..20d4c927 100644 --- a/Code/Network/NetworkDependencies/Listener.cpp +++ b/Code/Network/NetworkDependencies/Listener.cpp @@ -19,7 +19,9 @@ Listener::~Listener() { if(connection) { + this->thread.Terminate(); delete connection; + connection = 0; } } From 7817003db8683b503f3c848b00c5cc6f5aa2f4ad Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Fri, 13 Dec 2013 11:06:03 +0100 Subject: [PATCH 28/32] updated h.files description, started with level concept --- Code/Game/GameLogic/AttatchmentMassDriver.h | 3 +++ Code/Game/GameLogic/AttatchmentSocket.h | 4 ++++ Code/Game/GameLogic/GameLogic.vcxproj | 2 -- Code/Game/GameLogic/IAttatchment.h | 4 ++++ Code/Game/GameLogic/Level.cpp | 8 ++++++++ Code/Game/GameLogic/Level.h | 2 +- Code/Game/GameLogic/Weapon.cpp | 21 +++++++++++---------- 7 files changed, 31 insertions(+), 13 deletions(-) diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.h b/Code/Game/GameLogic/AttatchmentMassDriver.h index 879938fe..2fac7be4 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.h +++ b/Code/Game/GameLogic/AttatchmentMassDriver.h @@ -1,3 +1,6 @@ +////////////////////////////////////////////////// +//Created by Erik of the GameLogic team +////////////////////////////////////////////////// #ifndef ATTATCHMENTMASSDRIVER_H #define ATTATCHMENTMASSDRIVER_H #include "IAttatchment.h" diff --git a/Code/Game/GameLogic/AttatchmentSocket.h b/Code/Game/GameLogic/AttatchmentSocket.h index f9be588b..2257dd7a 100644 --- a/Code/Game/GameLogic/AttatchmentSocket.h +++ b/Code/Game/GameLogic/AttatchmentSocket.h @@ -1,3 +1,7 @@ +////////////////////////////////////////////////// +//Created by Erik of the GameLogic team +////////////////////////////////////////////////// + #ifndef ATTATCHMENTSOCKET_H #define ATTATCHMENTSOCKET_H #include "IAttatchment.h" diff --git a/Code/Game/GameLogic/GameLogic.vcxproj b/Code/Game/GameLogic/GameLogic.vcxproj index 13491d28..291d2cd0 100644 --- a/Code/Game/GameLogic/GameLogic.vcxproj +++ b/Code/Game/GameLogic/GameLogic.vcxproj @@ -168,7 +168,6 @@ - @@ -182,7 +181,6 @@ - diff --git a/Code/Game/GameLogic/IAttatchment.h b/Code/Game/GameLogic/IAttatchment.h index 0b6cb061..2192ffcf 100644 --- a/Code/Game/GameLogic/IAttatchment.h +++ b/Code/Game/GameLogic/IAttatchment.h @@ -1,3 +1,7 @@ +////////////////////////////////////////////////// +//Created by Erik of the GameLogic team +////////////////////////////////////////////////// + #ifndef IATTATCHMENT_H #define IATTATCHMENT_H #include "GameLogicStates.h" diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 38865f63..835062c1 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -2,6 +2,7 @@ #include "StaticObject.h" #include "DynamicObject.h" #include "GameMode.h" +#include "Player.h" using namespace GameLogic; @@ -15,6 +16,8 @@ struct Level::PrivateData { } + Player *players; + int nrOfPlayers; StaticObject** staticObjects; int nrOfStaticObjects; @@ -37,4 +40,9 @@ Level::~Level(void) delete myData; } +void Level::InitiateLevel(std::string levelPath) +{ + +} + diff --git a/Code/Game/GameLogic/Level.h b/Code/Game/GameLogic/Level.h index 9c7adb1a..89f13af2 100644 --- a/Code/Game/GameLogic/Level.h +++ b/Code/Game/GameLogic/Level.h @@ -14,7 +14,7 @@ namespace GameLogic Level(void); ~Level(void); - void CreateBox(); + void InitiateLevel(std::string levelPath); private: struct PrivateData; diff --git a/Code/Game/GameLogic/Weapon.cpp b/Code/Game/GameLogic/Weapon.cpp index 4bf4311c..e620e0d6 100644 --- a/Code/Game/GameLogic/Weapon.cpp +++ b/Code/Game/GameLogic/Weapon.cpp @@ -9,9 +9,10 @@ struct Weapon::PrivateData PrivateData() { weaponState = WEAPON_STATE_IDLE; - SelectedAttatchment = 0; + selectedAttatchment = 0; currentNrOfAttatchments = 0; selectedSocketID = 0; + maxNrOfSockets = 0; } ~PrivateData() @@ -21,10 +22,10 @@ struct Weapon::PrivateData WEAPON_STATE weaponState; AttatchmentSocket **attatchmentSockets; - int MaxNrOfSockets; + int maxNrOfSockets; int currentNrOfAttatchments; - IAttatchment *SelectedAttatchment; + IAttatchment *selectedAttatchment; int selectedSocketID; }myData; @@ -37,7 +38,7 @@ Weapon::Weapon() Weapon::Weapon(int MaxNrOfSockets) { myData = new PrivateData(); - myData->MaxNrOfSockets = MaxNrOfSockets; + myData->maxNrOfSockets = MaxNrOfSockets; myData->attatchmentSockets = new AttatchmentSocket*[MaxNrOfSockets]; for (int i = 0; i < MaxNrOfSockets; i++) { @@ -56,7 +57,7 @@ Weapon::~Weapon(void) ********************************************************/ void Weapon::Use(const WEAPON_FIRE &fireInput) { - myData->SelectedAttatchment->UseAttatchment(fireInput); + myData->selectedAttatchment->UseAttatchment(fireInput); } /******************************************************** @@ -83,7 +84,7 @@ bool Weapon::IsReloading() bool Weapon::IsValidSocket(int socketID) { - if(socketID < myData->MaxNrOfSockets && socketID >= 0) + if(socketID < myData->maxNrOfSockets && socketID >= 0) { if (myData->attatchmentSockets[socketID]->GetAttatchment() != 0) { @@ -100,16 +101,16 @@ int Weapon::GetCurrentSocketID() } -void Weapon::AddNewAttatchment(IAttatchment *attatchment) +void Weapon::AddNewAttatchment(IAttatchment *attatchment, Player *owner) { - if(myData->currentNrOfAttatchments < myData->MaxNrOfSockets) + if(myData->currentNrOfAttatchments < myData->maxNrOfSockets) { myData->attatchmentSockets[myData->currentNrOfAttatchments]->SetAttatchment(attatchment); myData->currentNrOfAttatchments++; } } -void Weapon::SwitchAttatchment(IAttatchment *attatchment, int socketID) +void Weapon::SwitchAttatchment(IAttatchment *attatchment, int socketID, Player *owner) { if (IsValidSocket(socketID)) { @@ -129,7 +130,7 @@ void Weapon::SelectAttatchment(int socketID) { if (IsValidSocket(socketID)) { - myData->SelectedAttatchment = myData->attatchmentSockets[socketID]->GetAttatchment(); + myData->selectedAttatchment = myData->attatchmentSockets[socketID]->GetAttatchment(); myData->selectedSocketID = socketID; } From f1f9f4d20a1bc6d027d21a8dceb756952e54afb5 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Fri, 13 Dec 2013 11:11:51 +0100 Subject: [PATCH 29/32] added include string in level.h --- Code/Game/GameLogic/Level.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Code/Game/GameLogic/Level.h b/Code/Game/GameLogic/Level.h index 89f13af2..7177531b 100644 --- a/Code/Game/GameLogic/Level.h +++ b/Code/Game/GameLogic/Level.h @@ -3,6 +3,7 @@ ////////////////////////////////////////////////// #ifndef LEVEL_H #define LEVEL_H +#include namespace GameLogic { From 7c1d19946d6f0a7c1a0f72fb6c6a9cb0a9fc9608 Mon Sep 17 00:00:00 2001 From: Linda Andersson Date: Fri, 13 Dec 2013 12:02:49 +0100 Subject: [PATCH 30/32] GL - Connection to network in clinet --- Bin/Content/Shaders/DebugVertex.cso | Bin 12292 -> 0 bytes Bin/Content/Shaders/TextureDebug.cso | Bin 14560 -> 0 bytes Code/DanBias.sln | 1 + Code/Game/DanBiasGame/DanBiasGame.vcxproj | 6 +- Code/Game/DanBiasGame/DanBiasGame_Impl.cpp | 83 ++++++++++-------- .../GameClientState/GameClientState.h | 22 +++++ .../DanBiasGame/GameClientState/GameState.cpp | 31 ++++++- .../DanBiasGame/GameClientState/GameState.h | 15 ++-- .../GameClientState/LobbyState.cpp | 10 +++ .../DanBiasGame/GameClientState/LobbyState.h | 3 + Code/Game/DanBiasGame/Include/DanBiasGame.h | 5 +- .../DanBiasLauncher/DanBiasLauncher.vcxproj | 2 +- Code/Game/DanBiasLauncher/Launcher.cpp | 6 +- Code/Game/GameProtocols/ObjectProtocols.h | 42 ++++----- 14 files changed, 153 insertions(+), 73 deletions(-) delete mode 100644 Bin/Content/Shaders/DebugVertex.cso delete mode 100644 Bin/Content/Shaders/TextureDebug.cso diff --git a/Bin/Content/Shaders/DebugVertex.cso b/Bin/Content/Shaders/DebugVertex.cso deleted file mode 100644 index 4e8292c6b9d3cd124bebd03c7ec3fd0a25ae8a33..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12292 zcmeHNU2GIp6h5;p*e-3^MG6HXnJ6aZ$K5SIwNxa94y8>BZMqdnm{_*E)9uRsWoH*k z)Yzzr`17C%4?b!%z7!MVgBV{V^5%ol7p-qj|oXt1q z-gAG>x##Ykx%bRyNB4J6ezW(ee{kFS~slZuGcMnsl_cK{y(mw*-&90&dc zhO`4cdC1(fhnZ!wbIVZ9^pMupM&1IbKr65bXaGouQt?90%#9V*)}hU6Z-2C3jgH3> zMnUb)W%8*s61zh?BB9;eBau*B`;LyCGSwG7cz7GyLWR@;D&SB}Ik9r3$lySFAM>8_lA<2aa|@HV91t@Tbp+GJ@(e0p>)KaM6rvr`by3s*xzl7ZL&>imHx>Y?C?NJ{MMIw#< z^;(n-ppZJ(0xvNST4OWsdKY-$!kkCL%^)(Kg&G2 zyFK9Sf$r{6dZW9Q2hN7tlpnr(e~A0g_y^aU-Z&o^I9D19K5*{JD^44h&EKc)dvp7I zkyG8{caR6P9a^+k80GS1Q_aLu*;cij$>&V9Q+2{2>SknI;gLrFGmZZGf>A6LvMQ=R*64q3AsW59)#QQM z%d?mHAV0%Pcc=b@X%tLdyZGYg?`85aEtS-@T)dPqvPDxrm@4*`Ms+Qg9Zkhdy*rmM z^nuf6(I^}&#PZ{*xT)JQJe~18J(|ko(}re@me2{WM~p(zm zr7Hnli5t3-sp2?vCCa+u)RnVzB^_O+6))7;oo-sX5|%FOdeWuKHLRr_)FLgW`!E%p z4tPm2z%;PWwcA?EbJ>O;Bg!QDZ_m#5y?p&k#ia()e<#*we9+-+L7N%xW#7lwe7w8| zX_h97I%r?qzW*g=6ZSx_L^BXMSh^K*oa%}ar{XaeRbM3VGYfs{%O<#-5 zK;8?G6#TlZ6uo7~h3I$02`0m=WU#K4^90cgWb5KA2|wS3XYFD=b%$p2K6 z)CIUk)-uNqJ*o;1xaZ%RWLULg-uzdEp`H;-;sM6{*Vl)ya&6aPBWG;`7DA~XodAgsGX6jO0Lw^>`aB45e@k-STQhFqk$tXL;RwcvxXz!4Lp#7ppCCO6 z&iL&()>sQTiE$tmdEOgV1N0?1?jLeL&;-;2oCo@S1<(L+Za6Qzzwo)U3a~aG;2zx` O4>aE%wVu{0@xWil@gIi( diff --git a/Bin/Content/Shaders/TextureDebug.cso b/Bin/Content/Shaders/TextureDebug.cso deleted file mode 100644 index 23c9aa238f2caca3ef27eaef75cc83f52464c37c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 14560 zcmeHOT}&L;6+Q#ThBfOfcEBWdt*PTy;5f@J5ZiH`2!{omioY;G>}VxemH{?dcDJ)j zjO94B)IL~sBe|+ys=oBmE|L0}v}z@{iK?`flD<@GU#hC=&r{{%wn-XQrr&pGE*WgV zsf!~ZbI{p)?|09fd+wP#XYRdoNt}MR{rg+~bM5j}?a=!pU%CG0Gatqc5&6SWk*!FP z$cNx70N(~5FBADKcp%Zy`6h5pfaEv}6$=X$koy|41BrN?SUuPTH-Ha-tHGpKz~w5p z^aqy<`Kw^+tpINUFMyD!x-e2JE+uQaoaK5^V5Y) z7MZ7_EwSiR&9PWCez@gmtIW-HSton1KnL|!f~UYFwySM=2>B90kBF;!WG-kBDRJ7l z4g7VmCgNo3v4%(b`>d|PuD)Iw>^R-t*Ef)m-oAmJ6Wy{{F*i5Y2fGeIp6$>s6Re54 zNS?mI69XqZ2GJMmRLAK8@P6=K@Qatkc!5oiMo7u$zwMPr?wT<5EV!OVEb$8A?PkgKSPDqOf=?3z^`EaPpu}d>f&cs?VYNe(NS-ZiCAIjtk z(V^kSFNH%FBt14WF@a@bzwLB7scG9hW;*s{rdYC_hOt;Ra>s_yx`lO5L=7E8`dx?~R94s7k4 zDY*^1Et&oKA{6=7k&9L|n?u8>(#y(4yv6LzJJTt)@2)f#Yg*0c3rd|{deQ=LIJCrs zuAI+;7W1x4TqmsDeD1F1*@*DLOMyqh`XPJ7TR7eTR_}oYFXg)We(7vcqzMb^mL8E` zKP_?{3;KQCBHze~eB@xU3&jTV-#&=7;*7{|z9@2@n*rW(_kP^sL7|4AoRn98J!Np~+f$$jOd zmErV3MUtc!Kt2vDBI#qv@t2kUN$7Vz)<5p)Pg8$h>7Ug4i)ybr$-tB>D*fY(R7r#- z1}IffVQX#8_u0LsX8Y`253zU8A7jSrxb=;HdEwRFAG~Ym`Nk(5sGOGY8v(D=Ye~*e z8c?S0U;W^3ALUTKf$}I=&s~sJl)|r;t^4a+|GI`Ub&Y~q7tn+C0PkI|9IuJc=|+|8 zlfOT9qg9C>mirjU+Y$vG#SAgE3r zlt>LTZ+dgxm_kLEZo_=D4XGjDQ}PGpnVK!Ysss}XPj028PWo#M?<<+BgBnFNz6B## z5tvNJZmZ>>tSp=<@86JO5f z#Fz6q@jHE9h8@a(!UFb}LpNgl?uXy~&Y#jBOcl4iVO@T0*Du_d6EW)E{r!7qe>#2U zm0cHpVxD>X=OVWte+o=8@Ky^C}-^2D{+z?JaZ`rRKpU7;Cwpq!kWwxp?o?m? zacf@VWxy+4yxEWQ9Z~J#EyO#ed}p{8DB8vs+I&%N&9iKv9Fd`6%CKC9a=p0gb&c_w z1HzTM%zs zIAa*l2KK;eaa+F|HgNX>)9>K{-s7`XakcNa1Ls>Gk~iMsnCJ$ZV6I``0c)y5<`G@+ zQqC1f1+aO?T(JzRtsi@@w(Sy5)q12hb8`6{ktco>onKv7nL0zvNJYD;f^AlM z`ZdPXP%XI?BanH(Tia`@-naEEdVgN|MLUNbXD3|>`|_;$pJ=u7A2*??sXLQIE=%kybY@Qz<%jVNBxxfUDkr$iRbff(4{e9K+18B*&CC?*oAuv6yx48Iz zqxJGxraZBavSob z2JlflUW^Y3F!yyB8xTX(8iHr=wPSdmfsUf{s=@r<1Ui&)hVAbJbH8jCIG|701G_)n T=7QD&4+I_vJP>$bop|8COhD`t diff --git a/Code/DanBias.sln b/Code/DanBias.sln index fec93854..a5d83ac9 100644 --- a/Code/DanBias.sln +++ b/Code/DanBias.sln @@ -196,6 +196,7 @@ Global {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.ActiveCfg = Debug|Win32 + {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.Build.0 = Debug|Win32 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.ActiveCfg = Debug|x64 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|x64.Build.0 = Debug|x64 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|Mixed Platforms.ActiveCfg = Release|Win32 diff --git a/Code/Game/DanBiasGame/DanBiasGame.vcxproj b/Code/Game/DanBiasGame/DanBiasGame.vcxproj index 76a7554e..fe1d05b0 100644 --- a/Code/Game/DanBiasGame/DanBiasGame.vcxproj +++ b/Code/Game/DanBiasGame/DanBiasGame.vcxproj @@ -72,7 +72,7 @@ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName)D $(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath) - $(SolutionDir)Network/NetworkAPI;$(IncludePath) + $(SolutionDir)..\External\Include\;$(SolutionDir)Game\GameProtocols\;$(SolutionDir)Network/NetworkAPI;$(IncludePath) true @@ -106,13 +106,13 @@ Disabled DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true - $(SolutionDir)Game/GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;%(AdditionalIncludeDirectories) + $(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;%(AdditionalIncludeDirectories) Windows true OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;%(AdditionalDependencies) - OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs) + NetworkAPI_$(PlatformShortName)D.dll;OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs) diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index e38b8cc9..1729708d 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -22,33 +22,50 @@ namespace DanBias #pragma region Game Data - struct MyRecieverObject // :public PontusRecieverObject + struct MyRecieverObject :public Oyster::Network::ProtocolRecieverObject { - Oyster::Network::NetworkClient nwClient; - - static void ProtocolRecieved(Network::CustomNetProtocol* p) - { - int pType = ((*p)[0]).value.netInt; - switch (pType) - { - case protocol_PlayerNavigation: - - break; - case protocol_PlayerPosition: - //int x = ((*p)[1]).value.netInt; - //int y = ((*p)[2]).value.netInt; - //int z = ((*p)[3]).value.netInt; - break; + Oyster::Network::NetworkClient* nwClient; + Client::GameClientState* gameClientState; + + void ProtocolRecievedCallback(Oyster::Network::CustomNetProtocol& p) override + { + + int pType = p[0].value.netInt; + Client::GameClientState::ProtocolStruct* protocol; + switch (pType) + { + case protocol_PlayerNavigation: + + break; + case protocol_PlayerPosition: + protocol = new Client::GameClientState::PlayerPos; + for(int i = 0; i< 3; i++) + { + ((Client::GameClientState::PlayerPos*)protocol)->playerPos[i] = p[i].value.netFloat; + } + gameClientState->Protocol(protocol); + delete protocol; + protocol = NULL; + break; - case protocol_ObjectPosition: - // DanBiasGame::protocolRecived(); - break; + case protocol_ObjectPosition: + protocol = new Client::GameClientState::ObjPos; + for(int i = 0; i< 16; i++) + { + ((Client::GameClientState::ObjPos*)protocol)->worldPos[i] = p[i].value.netFloat; + } + gameClientState->Protocol(protocol); + delete protocol; + protocol = NULL; + break; - default: - break; - } - } + default: + break; + } + + + } }; class DanBiasGamePrivateData { @@ -63,24 +80,17 @@ namespace DanBias } - public: - Client::GameClientState* gameClientState; - InputClass* inputObj; - GameLogic::Protocol_PlayerMovement player_move; - //Oyster::Network::NetworkClient nwClient; - MyRecieverObject r; - - // gameClient; + public: + Client::GameClientState* gameClientState; + InputClass* inputObj; + MyRecieverObject* r; } data; #pragma endregion DanBiasGamePrivateData* DanBiasGame::m_data = new DanBiasGamePrivateData(); - void DanBiasGame::protocolRecived() - { - //m_data->gameClientState.setPos() - } + //-------------------------------------------------------------------------------------- // Interface API functions //-------------------------------------------------------------------------------------- @@ -106,6 +116,9 @@ namespace DanBias // Start in lobby state m_data->gameClientState = new Client::LobbyState(); m_data->gameClientState->Init(); + m_data->r = new MyRecieverObject; + m_data->r->nwClient = new Oyster::Network::NetworkClient(); + return DanBiasClientReturn_Sucess; } diff --git a/Code/Game/DanBiasGame/GameClientState/GameClientState.h b/Code/Game/DanBiasGame/GameClientState/GameClientState.h index 5277996d..4e0d723b 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameClientState.h +++ b/Code/Game/DanBiasGame/GameClientState/GameClientState.h @@ -12,6 +12,26 @@ namespace Client class GameClientState { public: + struct ProtocolStruct + { + + }; + struct ObjPos :public ProtocolStruct + { + float worldPos[16]; + }; + struct PlayerPos :public ProtocolStruct + { + float playerPos[3]; + }; + struct PlayerMove :public ProtocolStruct + { + float playerPos[3]; + }; + struct PlayerName :public ProtocolStruct + { + char name[255]; + }; enum ClientState { ClientState_Lobby, @@ -26,6 +46,8 @@ public: virtual ClientState Update(float deltaTime, InputClass* KeyInput) = 0; virtual bool Render() = 0; virtual bool Release() = 0; + virtual void Protocol(ProtocolStruct* protocolStruct) = 0; + }; }; }; diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index a95b6798..64b1babb 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -2,6 +2,8 @@ #include "DllInterfaces/GFXAPI.h" #include "Obj/C_Player.h" #include "Obj/C_DynamicObj.h" +#include "NetworkClient.h" +#include "PlayerProtocols.h" using namespace DanBias::Client; @@ -12,8 +14,9 @@ struct GameState::myData Oyster::Math3D::Float4x4 proj; C_Object* object[3]; int modelCount; - //Oyster::Network::NetworkClient* nwClient; + Oyster::Network::NetworkClient* nwClient; gameStateState state; + }privData; GameState::GameState(void) @@ -33,7 +36,7 @@ bool GameState::Init() privData->state = LoadGame(); return true; } -GameState::gameStateState GameState::LoadGame() +GameState::gameStateState GameState::LoadGame() { LoadModels(L"map"); InitCamera(Oyster::Math::Float3(0,0,5.4f)); @@ -88,9 +91,14 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI // read server data // update objects // Client.send(obj); + { + GameLogic::Protocol_PlayerMovement movePlayer; + + //privData->nwClient->Send(movePlayer); if(KeyInput->IsKeyPressed(DIK_L)) privData->state = GameState::gameStateState_end; + } break; case gameStateState_end: return ClientState_Lobby; @@ -126,4 +134,21 @@ bool GameState::Release() delete privData; privData = NULL; return true; -} \ No newline at end of file +} + +void GameState::Protocol(ProtocolStruct* pos) +{ + if((ObjPos*)pos) + ObjectPosProtocol((ObjPos*)pos); + else if((PlayerPos*)pos) + PlayerPosProtocol((PlayerPos*)pos); +} +void GameState::PlayerPosProtocol(PlayerPos* pos) +{ + +} +void GameState::ObjectPosProtocol(ObjPos* pos) +{ + +} +//void GameState::Protocol(LightPos pos); \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.h b/Code/Game/DanBiasGame/GameClientState/GameState.h index 5ae6aa49..26ec0caa 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.h +++ b/Code/Game/DanBiasGame/GameClientState/GameState.h @@ -23,13 +23,18 @@ public: GameState(void); ~GameState(void); bool Init(); - GameClientState::ClientState Update(float deltaTime, InputClass* KeyInput); - bool LoadModels(std::wstring mapFile); - bool InitCamera(Oyster::Math::Float3 startPos); + GameClientState::ClientState Update(float deltaTime, InputClass* KeyInput) override; + bool LoadModels(std::wstring mapFile) ; + bool InitCamera(Oyster::Math::Float3 startPos) ; gameStateState LoadGame(); - bool Render(); - bool Release(); + bool Render()override; + bool Release()override; + + void Protocol(ProtocolStruct* pos)override; + void PlayerPosProtocol(PlayerPos* pos); + void ObjectPosProtocol(ObjPos* pos); + //void Protocol(LightPos pos); }; }; }; diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp index b107883f..8d54bd24 100644 --- a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp @@ -118,4 +118,14 @@ bool LobbyState::Release() delete privData; privData = NULL; return true; +} +void LobbyState::Protocol(ProtocolStruct* protocol) +{ + if((PlayerName*)protocol) + PlayerJoinProtocol((PlayerName*)protocol); + +} +void LobbyState::PlayerJoinProtocol(PlayerName* name) +{ + } \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.h b/Code/Game/DanBiasGame/GameClientState/LobbyState.h index 7498d448..c00a3b8f 100644 --- a/Code/Game/DanBiasGame/GameClientState/LobbyState.h +++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.h @@ -32,5 +32,8 @@ public: bool Render(); bool Release(); + void Protocol(ProtocolStruct* protocol)override; + void PlayerJoinProtocol(PlayerName* name); + };};}; #endif // ! DANBIAS_CLIENT_GAMECLIENTSTATE_H diff --git a/Code/Game/DanBiasGame/Include/DanBiasGame.h b/Code/Game/DanBiasGame/Include/DanBiasGame.h index 756460d4..a8d1a96f 100644 --- a/Code/Game/DanBiasGame/Include/DanBiasGame.h +++ b/Code/Game/DanBiasGame/Include/DanBiasGame.h @@ -1,6 +1,8 @@ #ifndef DANBIASGAME_DANBIASGAME_H #define DANBIASGAME_DANBIASGAME_H +#define DANBIAS_CLIENT_L + #if defined (DANBIAS_GAME_DLL_EXPORT) #define DANBIAS_GAME_DLL __declspec(dllexport) #else @@ -10,7 +12,7 @@ #define NOMINMAX #include -#define DANBIAS_CLIENT + namespace DanBias { @@ -53,7 +55,6 @@ namespace DanBias static HRESULT Render(float deltaTime); static HRESULT CleanUp(); - static void protocolRecived(); private: static __int64 cntsPerSec; static __int64 prevTimeStamp; diff --git a/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj b/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj index 7eacfd89..23ff7ffc 100644 --- a/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj +++ b/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj @@ -110,7 +110,7 @@ Windows true - DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs) + DanBiasGame_$(PlatformShortName)D.dll;DanBiasServer_$(PlatformShortName)D.dll;%(DelayLoadDLLs) DanBiasGame_$(PlatformShortName)D.lib;DanBiasServer_$(PlatformShortName)D.lib;%(AdditionalDependencies) diff --git a/Code/Game/DanBiasLauncher/Launcher.cpp b/Code/Game/DanBiasLauncher/Launcher.cpp index 1d42d16e..af99f874 100644 --- a/Code/Game/DanBiasLauncher/Launcher.cpp +++ b/Code/Game/DanBiasLauncher/Launcher.cpp @@ -4,8 +4,8 @@ #define NOMINMAX #include -#include "DanBiasServerAPI.h" -//#include "DanBiasGame.h" +//#include "DanBiasServerAPI.h" +#include "DanBiasGame.h" int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdShow) @@ -20,7 +20,7 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh DanBias::DanBiasServerAPI::Run(); DanBias::DanBiasServerAPI::Release(); } -#elif defined(DANBIAS_CLIENT) +#elif defined(DANBIAS_CLIENT_L) if(SetDllDirectory(L"..\\DLL") == FALSE) { return cmdShow; diff --git a/Code/Game/GameProtocols/ObjectProtocols.h b/Code/Game/GameProtocols/ObjectProtocols.h index 32a86259..3f305a11 100644 --- a/Code/Game/GameProtocols/ObjectProtocols.h +++ b/Code/Game/GameProtocols/ObjectProtocols.h @@ -8,7 +8,7 @@ namespace GameLogic { - struct Protocol_ObjectPosition :public Network::CustomProtocolObject + struct Protocol_ObjectPosition :public Oyster::Network::CustomProtocolObject { float worldMatrix[16]; // look at dir @@ -16,27 +16,27 @@ namespace GameLogic Protocol_ObjectPosition() { this->protocol[0].value = protocol_PlayerPosition; - this->protocol[0].type = Network::NetAttributeType_Int; - - this->protocol[1].type = Network::NetAttributeType_Float; - this->protocol[2].type = Network::NetAttributeType_Float; - this->protocol[3].type = Network::NetAttributeType_Float; - this->protocol[4].type = Network::NetAttributeType_Float; - this->protocol[5].type = Network::NetAttributeType_Float; - this->protocol[6].type = Network::NetAttributeType_Float; - this->protocol[7].type = Network::NetAttributeType_Float; - this->protocol[8].type = Network::NetAttributeType_Float; - this->protocol[9].type = Network::NetAttributeType_Float; - this->protocol[10].type = Network::NetAttributeType_Float; - this->protocol[11].type = Network::NetAttributeType_Float; - this->protocol[12].type = Network::NetAttributeType_Float; - this->protocol[13].type = Network::NetAttributeType_Float; - this->protocol[14].type = Network::NetAttributeType_Float; - this->protocol[15].type = Network::NetAttributeType_Float; - this->protocol[16].type = Network::NetAttributeType_Float; + this->protocol[0].type = Oyster::Network::NetAttributeType_Int; + + 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; + this->protocol[7].type = Oyster::Network::NetAttributeType_Float; + this->protocol[8].type = Oyster::Network::NetAttributeType_Float; + this->protocol[9].type = Oyster::Network::NetAttributeType_Float; + this->protocol[10].type = Oyster::Network::NetAttributeType_Float; + this->protocol[11].type = Oyster::Network::NetAttributeType_Float; + this->protocol[12].type = Oyster::Network::NetAttributeType_Float; + this->protocol[13].type = Oyster::Network::NetAttributeType_Float; + this->protocol[14].type = Oyster::Network::NetAttributeType_Float; + this->protocol[15].type = Oyster::Network::NetAttributeType_Float; + this->protocol[16].type = Oyster::Network::NetAttributeType_Float; } - Network::CustomNetProtocol* GetProtocol() override + Oyster::Network::CustomNetProtocol* GetProtocol() override { this->protocol[1].value = worldMatrix[0]; @@ -59,7 +59,7 @@ namespace GameLogic } private: - Network::CustomNetProtocol protocol; + Oyster::Network::CustomNetProtocol protocol; }; } From 8b1c2b91e83809e387ac61978b6493ccab64ac36 Mon Sep 17 00:00:00 2001 From: dean11 Date: Fri, 13 Dec 2013 23:47:16 +0100 Subject: [PATCH 31/32] Fixed some craches and stuff --- Bin/Content/Shaders/DebugVertex.cso | Bin 12292 -> 12292 bytes Bin/Content/Shaders/TextureDebug.cso | Bin 14560 -> 14560 bytes Code/Game/DanBiasGame/DanBiasGame.vcxproj | 8 +- .../DanBiasLauncher/DanBiasLauncher.vcxproj | 16 +- Code/Game/DanBiasLauncher/Launcher.cpp | 2 +- Code/Game/DanBiasServer/GameServer.cpp | 16 +- Code/Game/DanBiasServer/GameServer.h | 4 +- .../DanBiasServer/Include/DanBiasServerAPI.h | 2 + .../ServerObjects/ClientObject.cpp | 20 +- .../ServerObjects/ClientObject.h | 15 +- .../ServerObjects/Lobby/GameLobby.h | 4 +- .../ServerObjects/Lobby/MainLobby.cpp | 8 + .../ServerObjects/Lobby/MainLobby.h | 6 +- .../ServerObjects/NetworkSession.cpp | 23 +- .../ServerObjects/NetworkSession.h | 22 +- Code/Misc/Misc.vcxproj | 2 + Code/Misc/Misc.vcxproj.filters | 6 + Code/Misc/PostBox/IPostBox.h | 22 ++ Code/Misc/PostBox/PostBox.h | 61 ++++ Code/Misc/Thread/IThreadObject.h | 4 +- Code/Misc/Thread/OysterThread.h | 11 +- Code/Misc/Thread/OysterThread_Impl.cpp | 137 ++++----- Code/Network/NetworkAPI/CustomNetProtocol.h | 1 + .../NetworkAPI/NetworkCallbackHelper.h | 2 +- Code/Network/NetworkAPI/NetworkClient.cpp | 276 ++++++++---------- Code/Network/NetworkAPI/NetworkClient.h | 1 + Code/Network/NetworkAPI/NetworkServer.h | 1 + Code/Network/NetworkAPI/Translator.cpp | 96 +++--- Code/Network/NetworkAPI/Translator.h | 4 +- .../NetworkDependencies/Connection.cpp | 16 +- Code/Network/NetworkDependencies/Connection.h | 4 +- .../Network/NetworkDependencies/IConnection.h | 4 +- .../OysterNetworkClient/ClientMain.cpp | 3 +- 33 files changed, 446 insertions(+), 351 deletions(-) create mode 100644 Code/Misc/PostBox/IPostBox.h create mode 100644 Code/Misc/PostBox/PostBox.h diff --git a/Bin/Content/Shaders/DebugVertex.cso b/Bin/Content/Shaders/DebugVertex.cso index 4e8292c6b9d3cd124bebd03c7ec3fd0a25ae8a33..f89275e4cd7a8631664128e0ce2f4b88001cd74b 100644 GIT binary patch delta 697 zcmZokXh{%piEwgOzEZ3qzB0~o?f&LmUG}Um8%4fwOB@kh9mL4Mz;I0Is?zEYB_0co zEK|+B`Pgo=0?!-vtbUM`vsFxJacWUUM7et&MwI>h$+s_&q<7N2{SY?H&@VA z2rkJlDp4pdNX;oNDN9Yx&dJP6FD@v`&q~cMQOHzCFDfl4hzS7klS>rB^NX^9@(M1Q zML=$TQRQSi5zlCd`6(#or<6g>FDAx(uzf)D%c16{z|F7IvYQ+z>MaWN5W^B6_5gVe z2td@*$+1#Cg3^x+7#o1Reqr6WNP+7}&n(FR>PUg=kP@}iMzVtl8|)@W zh@FlMgcLPj(R#kp=0| z0Ai4e1hH*wZa_BNyv>eG{fwJgB;GJG-q`$6(wvX6VzQ=&KXbwBrpeVB<%)-iaH9R> zF3qaR0ZbOMQ}hfOafR}X$%P)WD}cBj=s61@4FWqhE9yLE1^|$krx*YL diff --git a/Bin/Content/Shaders/TextureDebug.cso b/Bin/Content/Shaders/TextureDebug.cso index 23c9aa238f2caca3ef27eaef75cc83f52464c37c..8895fbc0d2427e7c28e904c73ab957ddbefb4b6d 100644 GIT binary patch delta 1338 zcmaD*_@Ge4CBn&ht4{1eHTGAM`+XB)a&OA)*(maZiE{=61W0XWI*&Hk^5=TT=2QdPbe2)G3{Hf%1kIn5j7Kp9Cyms>+o+pfxABb^e&0zsbJ6pws z7N-^!$GD{Cq7sGTg4CSSlCsp~?3~QJ z^x}e|{H)aM5`|2K^rF&&f|vjhKeSp?+f7gbK?6?aZ51zVE>u_gt@ znv^oAHO0hO1GW}uO*zz>6u33H;!a6)@r~}}pW=L62p=teAix#@3_V(TOLuahME~Rz zVb#s7{KbrFpqO6@#LIyAIWUsFfEX0ly39ZV3R;*Z&l7N(Y{2}6Px_Go;~JoF>eZ+) z-XD|SN!W4nKvgZ9oG2-71Tzb!7es^1)d12U&8OGD{gnr`2c-5n<7P$XBw#|5y2Hfe z#khH&tQ$X52;*cnT|edp-T9Nlb#pV90M*eeaoMNR%O+67b2BnbuG34}Y`|Os%t$;e zQn<2OCFA6OdPej}_`dqS^spvZTzB#leQ{NNVBCU$5)g9$u^6YB&9AlNLZd7g3e0~Tf`#($e1 zvit$EIapXE{3}-mF#@F(k{D?)=|ELQ2vsRiRgNaQllL17DG*_tg+j7b3?b7j zCKrge@JT;1U|a)qq~^1zI`Qw5-$~hVg4_%O5|b09g-s6tSqUH>%=bVx2qXfr1`vY` z5PN?3>k1$nq$B}|6E`a|Cj-M*<_;6n0fx={ Level3 Disabled - DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true $(SolutionDir)Game/GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;%(AdditionalIncludeDirectories) @@ -121,7 +121,7 @@ Level3 Disabled - DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true $(SolutionDir)GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) @@ -140,7 +140,7 @@ MaxSpeed true true - DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true $(SolutionDir)GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) @@ -161,7 +161,7 @@ MaxSpeed true true - DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true $(SolutionDir)GameProtocols;$(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) diff --git a/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj b/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj index 7eacfd89..0789eca9 100644 --- a/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj +++ b/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj @@ -71,32 +71,32 @@ $(SolutionDir)..\Bin\Executable\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName)D - $(SolutionDir)..\External\Include\;$(IncludePath) - $(OutDir)..\DLL\;$(LibraryPath) + $(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath) + $(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath) true $(SolutionDir)..\Bin\Executable\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName)D - $(SolutionDir)..\External\Include\;$(IncludePath) - $(OutDir)..\DLL\;$(LibraryPath) + $(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath) + $(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath) false $(SolutionDir)..\Bin\Executable\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName) - $(SolutionDir)..\External\Include\;$(IncludePath) - $(OutDir)..\DLL\;$(LibraryPath) + $(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath) + $(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath) false $(SolutionDir)..\Bin\Executable\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName) - $(SolutionDir)..\External\Include\;$(IncludePath) - $(OutDir)..\DLL\;$(LibraryPath) + $(SolutionDir)..\External\Include\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath) + $(OutDir)..\DLL\;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath) diff --git a/Code/Game/DanBiasLauncher/Launcher.cpp b/Code/Game/DanBiasLauncher/Launcher.cpp index 1d42d16e..41859ab7 100644 --- a/Code/Game/DanBiasLauncher/Launcher.cpp +++ b/Code/Game/DanBiasLauncher/Launcher.cpp @@ -3,7 +3,7 @@ ///////////////////////////////////////////////// #define NOMINMAX #include - +#include #include "DanBiasServerAPI.h" //#include "DanBiasGame.h" diff --git a/Code/Game/DanBiasServer/GameServer.cpp b/Code/Game/DanBiasServer/GameServer.cpp index 227359f2..0a14e31f 100644 --- a/Code/Game/DanBiasServer/GameServer.cpp +++ b/Code/Game/DanBiasServer/GameServer.cpp @@ -10,17 +10,19 @@ #include "ServerInitReader.h" #include #include +#include "ServerObjects\ClientObject.h" namespace DanBias { using namespace Oyster::Network; - void GameServer::ClientConnectCallback(NetworkClient client) + void GameServer::ClientConnectCallback(NetworkClient& client) { printf("Client connected!\n"); - this->mainLobby->AttachClient(Utility::DynamicMemory::SmartPointer(new NetworkClient(client))); + Utility::DynamicMemory::SmartPointer c = new ClientObject(client); + this->mainLobby->AttachClient(c); } GameServer::GameServer() : initiated(0) @@ -64,13 +66,11 @@ namespace DanBias if(!this->server->Start()) return DanBiasServerReturn_Error; - - - this->running = true; - while (this->running) + while (true) { - if(!WindowShell::Frame()) - break; + if(!WindowShell::Frame()) break; + + this->mainLobby->Frame(); } return DanBiasServerReturn_Sucess; diff --git a/Code/Game/DanBiasServer/GameServer.h b/Code/Game/DanBiasServer/GameServer.h index 6354aa35..4045295f 100644 --- a/Code/Game/DanBiasServer/GameServer.h +++ b/Code/Game/DanBiasServer/GameServer.h @@ -4,8 +4,6 @@ #ifndef DANBIASSERVER_GAME_SERVER_H #define DANBIASSERVER_GAME_SERVER_H -#include - #include "Include\DanBiasServerAPI.h" #include "ServerObjects\Lobby\MainLobby.h" #include @@ -25,7 +23,7 @@ namespace DanBias private: //static void ClientConnectCallbackFunction(Oyster::Network::NetworkClient& connectedClient); - void ClientConnectCallback(Oyster::Network::NetworkClient client) override; + void ClientConnectCallback(Oyster::Network::NetworkClient& client) override; bool initiated; bool running; diff --git a/Code/Game/DanBiasServer/Include/DanBiasServerAPI.h b/Code/Game/DanBiasServer/Include/DanBiasServerAPI.h index acf0d5d6..1165ba48 100644 --- a/Code/Game/DanBiasServer/Include/DanBiasServerAPI.h +++ b/Code/Game/DanBiasServer/Include/DanBiasServerAPI.h @@ -4,6 +4,8 @@ #ifndef DANBIAS_SERVER_DANBIAS_SERVER_H #define DANBIAS_SERVER_DANBIAS_SERVER_H +#include + #define DANBIAS_SERVER #ifdef DANBIAS_SERVER_DLL_EXPORT diff --git a/Code/Game/DanBiasServer/ServerObjects/ClientObject.cpp b/Code/Game/DanBiasServer/ServerObjects/ClientObject.cpp index acad56d3..1a97a73f 100644 --- a/Code/Game/DanBiasServer/ServerObjects/ClientObject.cpp +++ b/Code/Game/DanBiasServer/ServerObjects/ClientObject.cpp @@ -2,11 +2,29 @@ using namespace DanBias; -ClientObject::ClientObject() +ClientObject::ClientObject(const Oyster::Network::NetworkClient& client) { + this->client = client; + this->client.SetRecieverObject(this, Oyster::Network::NetworkProtocolCallbackType_Object); + this->box = 0; } ClientObject::~ClientObject() { + this->client.Disconnect(); } +void ClientObject::SetPostbox(Oyster::PostBox* box) +{ + this->box = box; +} +void ClientObject::ProtocolRecievedCallback(Oyster::Network::CustomNetProtocol& protocol) +{ + if(!this->box) return; + + NetworkSession::ClientEvent _event; + _event.protocol = protocol; + _event.reciever = this; + + this->box->Post(_event); +} diff --git a/Code/Game/DanBiasServer/ServerObjects/ClientObject.h b/Code/Game/DanBiasServer/ServerObjects/ClientObject.h index 55acdf6f..b4aa42e1 100644 --- a/Code/Game/DanBiasServer/ServerObjects/ClientObject.h +++ b/Code/Game/DanBiasServer/ServerObjects/ClientObject.h @@ -1,18 +1,27 @@ #ifndef DANBIASSERVER_CLIENT_OBJECT_H #define DANBIASSERVER_CLIENT_OBJECT_H + +#include "NetworkSession.h" #include "NetworkClient.h" +#include namespace DanBias { - class ClientObject + class ClientObject :public Oyster::Network::ProtocolRecieverObject { public: - ClientObject(); + ClientObject(const Oyster::Network::NetworkClient& client); ~ClientObject(); + void SetPostbox(Oyster::PostBox* box); + private: - + void ProtocolRecievedCallback(Oyster::Network::CustomNetProtocol& protocol) override; + + private: + Oyster::Network::NetworkClient client; + Oyster::IPostBox* box; }; }//End namespace DanBias diff --git a/Code/Game/DanBiasServer/ServerObjects/Lobby/GameLobby.h b/Code/Game/DanBiasServer/ServerObjects/Lobby/GameLobby.h index b28d9b31..c4a0718c 100644 --- a/Code/Game/DanBiasServer/ServerObjects/Lobby/GameLobby.h +++ b/Code/Game/DanBiasServer/ServerObjects/Lobby/GameLobby.h @@ -1,5 +1,5 @@ -#ifndef DANBIASSERVER_GAME_LOBBY_H -#define DANBIASSERVER_GAME_LOBBY_H +#ifndef DANBIASSERVER_GAMELOBBY_H +#define DANBIASSERVER_GAMELOBBY_H #include "..\NetworkSession.h" diff --git a/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.cpp b/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.cpp index d518a0c7..f4c8b439 100644 --- a/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.cpp +++ b/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.cpp @@ -13,6 +13,14 @@ namespace DanBias } void MainLobby::Release() { + this->clients.clear(); + } + void MainLobby::Frame() + { + if(!this->box.IsEmpty()) + { + + } } }//End namespace DanBias \ No newline at end of file diff --git a/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.h b/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.h index 456eee9d..9308a4d4 100644 --- a/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.h +++ b/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.h @@ -1,5 +1,5 @@ -#ifndef DANBIASGAME_GAMELOBBY_H -#define DANBIASGAME_GAMELOBBY_H +#ifndef DANBIASSERVER_MAINLOBBY_H +#define DANBIASSERVER_MAINLOBBY_H #include "..\NetworkSession.h" #include @@ -14,6 +14,8 @@ namespace DanBias ~MainLobby(); void Release(); + void Frame(); + private: diff --git a/Code/Game/DanBiasServer/ServerObjects/NetworkSession.cpp b/Code/Game/DanBiasServer/ServerObjects/NetworkSession.cpp index 94dc1412..339408c8 100644 --- a/Code/Game/DanBiasServer/ServerObjects/NetworkSession.cpp +++ b/Code/Game/DanBiasServer/ServerObjects/NetworkSession.cpp @@ -1,3 +1,4 @@ +#include "ClientObject.h" #include "NetworkSession.h" #include @@ -12,11 +13,20 @@ namespace DanBias } - void NetworkSession::AttachClient(Utility::DynamicMemory::SmartPointer client) + void NetworkSession::AttachClient(Utility::DynamicMemory::SmartPointer client) { - + for (unsigned int i = 0; i < this->clients.size(); i++) + { + if(!this->clients[i]) + { + this->clients[i] = client; + //this->clients[i]->SetPostbox(&this->box); + return; + } + } + this->clients.push_back(client); } - void NetworkSession::DetachClient(Utility::DynamicMemory::SmartPointer client) + void NetworkSession::DetachClient(Utility::DynamicMemory::SmartPointer client) { } @@ -25,7 +35,7 @@ namespace DanBias } - void NetworkSession::Kick(Utility::DynamicMemory::SmartPointer client) + void NetworkSession::Kick(Utility::DynamicMemory::SmartPointer client) { } @@ -33,9 +43,4 @@ namespace DanBias { } - - Oyster::Network::NetworkClient* NetworkSession::operator[](int Identification) - { - return 0; - } }//End namespace DanBias \ No newline at end of file diff --git a/Code/Game/DanBiasServer/ServerObjects/NetworkSession.h b/Code/Game/DanBiasServer/ServerObjects/NetworkSession.h index 5776a0f9..75e21090 100644 --- a/Code/Game/DanBiasServer/ServerObjects/NetworkSession.h +++ b/Code/Game/DanBiasServer/ServerObjects/NetworkSession.h @@ -2,24 +2,34 @@ #define DANBIASSERVER_NETWORK_SESSION_H #include "Utilities.h" -#include "ClientObject.h" +#include #include #include namespace DanBias { + class ClientObject; class NetworkSession { + public: + struct ClientEvent + { + ClientObject* reciever; + Oyster::Network::CustomNetProtocol protocol; + ClientEvent() { reciever = 0; } + ~ClientEvent() { } + }; + public: NetworkSession(); ~NetworkSession(); - void AttachClient(Utility::DynamicMemory::SmartPointer client); + void AttachClient(Utility::DynamicMemory::SmartPointer client); - void DetachClient(Utility::DynamicMemory::SmartPointer client); + void DetachClient(Utility::DynamicMemory::SmartPointer client); void DetachClient(short ID); - void Kick(Utility::DynamicMemory::SmartPointer client); + void Kick(Utility::DynamicMemory::SmartPointer client); void Kick(); void Send(Oyster::Network::CustomNetProtocol& protocol); @@ -28,10 +38,8 @@ namespace DanBias //TODO: Do more lobby features protected: - Oyster::Network::NetworkClient* operator[](int Identification); - - private: std::vector> clients; + Oyster::PostBox box; }; }//End namespace DanBias #endif // !DANBIASSERVER_NETWORK_SESSION_H diff --git a/Code/Misc/Misc.vcxproj b/Code/Misc/Misc.vcxproj index 8cb234da..7d3074d3 100644 --- a/Code/Misc/Misc.vcxproj +++ b/Code/Misc/Misc.vcxproj @@ -157,6 +157,8 @@ + + diff --git a/Code/Misc/Misc.vcxproj.filters b/Code/Misc/Misc.vcxproj.filters index 7151e26a..d6fea6e9 100644 --- a/Code/Misc/Misc.vcxproj.filters +++ b/Code/Misc/Misc.vcxproj.filters @@ -86,5 +86,11 @@ Header Files + + Header Files + + + Header Files + \ No newline at end of file diff --git a/Code/Misc/PostBox/IPostBox.h b/Code/Misc/PostBox/IPostBox.h new file mode 100644 index 00000000..30ae170e --- /dev/null +++ b/Code/Misc/PostBox/IPostBox.h @@ -0,0 +1,22 @@ +#ifndef NETWORK_DEPENDENCIES_I_POST_BOX_H +#define NETWORK_DEPENDENCIES_I_POST_BOX_H + +///////////////////////////////////// +// Created by Pontus Fransson 2013 // +///////////////////////////////////// + +namespace Oyster +{ + template + class IPostBox + { + public: + virtual ~IPostBox() {} + virtual void Post(T message) = 0; + virtual T Fetch() = 0; + virtual bool IsEmpty() = 0; + + }; +} + +#endif \ No newline at end of file diff --git a/Code/Misc/PostBox/PostBox.h b/Code/Misc/PostBox/PostBox.h new file mode 100644 index 00000000..c01eeead --- /dev/null +++ b/Code/Misc/PostBox/PostBox.h @@ -0,0 +1,61 @@ +#ifndef NETWORK_DEPENDENCIES_POST_BOX_H +#define NETWORK_DEPENDENCIES_POST_BOX_H + +///////////////////////////////////// +// Created by Pontus Fransson 2013 // +///////////////////////////////////// + +#include "IPostBox.h" +#include "../ThreadSafeQueue.h" + +namespace Oyster +{ + //With this class you can post items to it and then fetch them somewhere else. + //It is thread safe beacause of the ThreadSafeQueue. + template + class PostBox : public IPostBox + { + public: + PostBox(); + virtual ~PostBox(); + + virtual void Post(T message); + virtual T Fetch(); + virtual bool IsEmpty(); + + private: + Oyster::Queue::ThreadSafeQueue messages; + + }; + + //Implementation of PostBox + template + PostBox::PostBox() + { + } + + template + PostBox::~PostBox() + { + } + + template + void PostBox::Post(T message) + { + messages.Push(message); + } + + template + T PostBox::Fetch() + { + return messages.Pop(); + } + + template + bool PostBox::IsEmpty() + { + return !messages.IsEmpty(); + } +} + +#endif \ No newline at end of file diff --git a/Code/Misc/Thread/IThreadObject.h b/Code/Misc/Thread/IThreadObject.h index b21c942e..f6b4d638 100644 --- a/Code/Misc/Thread/IThreadObject.h +++ b/Code/Misc/Thread/IThreadObject.h @@ -26,7 +26,9 @@ namespace Oyster */ virtual void ThreadExit() { } /** - * This function is required to get threading working. + * This function is required to get threading working. + * Note that this function is NOT thread safe. + * OBS! Do not highjack the looping. */ virtual bool DoWork ( ) = 0; }; diff --git a/Code/Misc/Thread/OysterThread.h b/Code/Misc/Thread/OysterThread.h index 05a9f8ad..805dea3b 100644 --- a/Code/Misc/Thread/OysterThread.h +++ b/Code/Misc/Thread/OysterThread.h @@ -15,6 +15,12 @@ namespace Oyster OYSTER_THREAD_ERROR_FAILED, OYSTER_THREAD_ERROR_SUCCESS, }; + enum OYSTER_THREAD_PRIORITY + { + OYSTER_THREAD_PRIORITY_1, //!< High + OYSTER_THREAD_PRIORITY_2, //!< Medium + OYSTER_THREAD_PRIORITY_3, //!< Low + }; class OysterThread { @@ -30,16 +36,17 @@ namespace Oyster OYSTER_THREAD_ERROR Create(IThreadObject* worker, bool start); OYSTER_THREAD_ERROR Start(); - void Stop(); + void Stop(bool wait = false); void Pause(); void Pause(int mSec); void Resume(); OYSTER_THREAD_ERROR Reset(IThreadObject* worker = 0); - void Terminate(); + void Terminate(bool wait = false); void Wait(); void Wait(int mSec); OYSTER_THREAD_ERROR Swap(const OysterThread* other); bool IsActive(); + void SetPriority(OYSTER_THREAD_PRIORITY priority); }; } } diff --git a/Code/Misc/Thread/OysterThread_Impl.cpp b/Code/Misc/Thread/OysterThread_Impl.cpp index 9e503c54..23fb0362 100644 --- a/Code/Misc/Thread/OysterThread_Impl.cpp +++ b/Code/Misc/Thread/OysterThread_Impl.cpp @@ -31,17 +31,27 @@ using namespace Utility::DynamicMemory; struct ThreadData { - std::atomic state; // workerThread; // msec; //owner = 0; + this->state = OYSTER_THREAD_STATE_DEAD; + + if(this->workerThread) + { + //@todo TODO: Make detatch avalible. + if(this->workerThread->joinable()) + this->workerThread->detach(); + } + } ThreadData(const ThreadData&) {}; const ThreadData& operator =(const ThreadData& o) @@ -52,12 +62,14 @@ using namespace Utility::DynamicMemory; SmartPointer threadData; PrivateData() - :threadData(new ThreadData()) { + threadData = new ThreadData(); + threadData->first = true; threadData->owner = 0; threadData->workerThread = 0; threadData->callingThread; threadData->state = OYSTER_THREAD_STATE_STOPED; + threadData->prio = OYSTER_THREAD_PRIORITY_3; } PrivateData(const PrivateData& o) { @@ -69,13 +81,7 @@ using namespace Utility::DynamicMemory; } ~PrivateData() { - //@todo TODO: Make detatch avalible. - //if(!this->threadData->workerThread->joinable()) - this->threadData->workerThread->detach(); - - this->threadData->owner = 0; - - this->threadData->state = OYSTER_THREAD_STATE_DEAD; + threadData.Release(); } }; @@ -86,72 +92,44 @@ using namespace Utility::DynamicMemory; static void ThreadingFunction(SmartPointer &origin) { - bool shouldContinue; + bool shouldContinue = true; SmartPointer w = origin; theBegining: - while(w->state == OYSTER_THREAD_STATE_STOPED) + while(w->state == OYSTER_THREAD_STATE_STOPED) std::this_thread::yield(); + + if(w->owner) w->owner->ThreadEntry(); + w->first = false; + while (w->state != OYSTER_THREAD_STATE_STOPED && w->state != OYSTER_THREAD_STATE_DEAD && shouldContinue) { - std::this_thread::yield(); - } - -// w->mutexLock.LockMutex(); - if(w->owner) - { - w->owner->ThreadEntry(); - } -// w->mutexLock.UnlockMutex(); - - while (w->state != OYSTER_THREAD_STATE_STOPED && w->state != OYSTER_THREAD_STATE_DEAD) - { -// w->mutexLock.LockMutex(); + switch (w->prio) { - if(w->owner) - { - shouldContinue = w->owner->DoWork(); - } - } -// w->mutexLock.UnlockMutex(); - - if(!shouldContinue) - { - goto theEnd; - } - if(w->state == OYSTER_THREAD_STATE_DEAD) - { - goto theEnd; - } - else if(w->state == OYSTER_THREAD_STATE_RESET) - { - goto theBegining; - } - else if(w->msec > 0) - { - std::this_thread::sleep_for(std::chrono::milliseconds(w->msec)); - } - - while (w->state == OYSTER_THREAD_STATE_PAUSED) - { - std::this_thread::yield(); + case Oyster::Thread::OYSTER_THREAD_PRIORITY_2: + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + break; + case Oyster::Thread::OYSTER_THREAD_PRIORITY_3: + std::this_thread::yield(); + break; } + if(w->owner) shouldContinue = w->owner->DoWork(); + + if(w->state == OYSTER_THREAD_STATE_RESET) goto theBegining; + else if(w->msec > 0) std::this_thread::sleep_for(std::chrono::milliseconds(w->msec)); + + while (w->state == OYSTER_THREAD_STATE_PAUSED) std::this_thread::yield(); } if(w->state == OYSTER_THREAD_STATE_DEAD) { - w->workerThread->detach(); + if(w->workerThread->joinable()) w->workerThread->detach(); + return; } theEnd: - -// w->mutexLock.LockMutex(); - if(w->owner) - { - w->owner->ThreadExit(); - } -// w->mutexLock.UnlockMutex(); - + + if(w->owner) w->owner->ThreadExit(); w->state = OYSTER_THREAD_STATE_DEAD; } @@ -208,7 +186,7 @@ OYSTER_THREAD_ERROR OysterThread::Start() this->privateData->threadData->state = OYSTER_THREAD_STATE_RUNNING; return OYSTER_THREAD_ERROR_SUCCESS; } -void OysterThread::Stop() +void OysterThread::Stop(bool wait) { //this->privateData->threadData->mutexLock.LockMutex(); this->privateData->threadData->state = OYSTER_THREAD_STATE_STOPED; @@ -229,10 +207,8 @@ void OysterThread::Pause(int msec) } else { - //this->privateData->threadData->mutexLock.LockMutex(); this->privateData->threadData->state = OYSTER_THREAD_STATE_PAUSED; this->privateData->threadData->msec = msec; - //this->privateData->threadData->mutexLock.UnlockMutex(); } } void OysterThread::Resume() @@ -254,26 +230,35 @@ OYSTER_THREAD_ERROR OysterThread::Reset(IThreadObject* worker) return OYSTER_THREAD_ERROR_SUCCESS; } -void OysterThread::Terminate() +void OysterThread::Terminate(bool wait) { this->privateData->threadData->state = OYSTER_THREAD_STATE_DEAD; } void OysterThread::Wait() { if(this->privateData->threadData->state == OYSTER_THREAD_STATE_DEAD) - { - return; - } + { return; } - if(this->privateData->threadData->workerThread->get_id() == std::this_thread::get_id()) return; + if( this->privateData->threadData->workerThread + && + this->privateData->threadData->workerThread->get_id() == std::this_thread::get_id()) + return; - this->privateData->threadData->workerThread->join(); + //if(this->privateData->threadData->state == OYSTER_THREAD_STATE_STOPED) + if(this->privateData->threadData->first) + { return; } + + if(this->privateData->threadData->workerThread) + if(this->privateData->threadData->workerThread->joinable()) + this->privateData->threadData->workerThread->join(); } void OysterThread::Wait(int msec) { if(this->privateData->threadData->workerThread->get_id() == std::this_thread::get_id()) return; - std::this_thread::sleep_for(std::chrono::milliseconds(msec)); + //TODO: Sync with thread. + + //std::this_thread::sleep_for(std::chrono::milliseconds(msec)); } OYSTER_THREAD_ERROR OysterThread::Swap(const OysterThread* other) { @@ -287,4 +272,8 @@ bool OysterThread::IsActive() return false; } +void OysterThread::SetPriority(OYSTER_THREAD_PRIORITY priority) +{ + this->privateData->threadData->prio = priority; +} diff --git a/Code/Network/NetworkAPI/CustomNetProtocol.h b/Code/Network/NetworkAPI/CustomNetProtocol.h index 4f01fb58..d25c23e5 100644 --- a/Code/Network/NetworkAPI/CustomNetProtocol.h +++ b/Code/Network/NetworkAPI/CustomNetProtocol.h @@ -5,6 +5,7 @@ #define NETWORK_CUSTOM_NETWORK_PROTOCOL_H #include +#include #ifdef CUSTOM_NET_PROTOCOL_EXPORT #define NET_PROTOCOL_EXPORT __declspec(dllexport) diff --git a/Code/Network/NetworkAPI/NetworkCallbackHelper.h b/Code/Network/NetworkAPI/NetworkCallbackHelper.h index 936bef77..c99f2c5f 100644 --- a/Code/Network/NetworkAPI/NetworkCallbackHelper.h +++ b/Code/Network/NetworkAPI/NetworkCallbackHelper.h @@ -30,7 +30,7 @@ namespace Oyster typedef void(*ProtocolRecieverFunction)(CustomNetProtocol& protocol); struct ClientConnectedObject { - virtual void ClientConnectCallback(NetworkClient client) = 0; + virtual void ClientConnectCallback(NetworkClient& client) = 0; }; struct ProtocolRecieverObject { diff --git a/Code/Network/NetworkAPI/NetworkClient.cpp b/Code/Network/NetworkAPI/NetworkClient.cpp index d7b907fb..01d991ca 100644 --- a/Code/Network/NetworkAPI/NetworkClient.cpp +++ b/Code/Network/NetworkAPI/NetworkClient.cpp @@ -23,28 +23,13 @@ using namespace Utility::DynamicMemory; /************************************* PrivateData *************************************/ - -struct NetworkClient::PrivateData : public IThreadObject +struct ClientDataContainer { - PrivateData(); - PrivateData(unsigned int socket); - ~PrivateData(); - - void Start(); - - void Send(CustomNetProtocol& protocol); //Is called from the outside to add messages to send. - - //Called on from the thread - int Send(); - int Recv(); - - bool DoWork(); - - SmartPointer connection; + Connection connection; SmartPointer> sendPostBox; - SmartPointer recvObj; + RecieverObject recvObj; NetworkProtocolCallbackType callbackType; Oyster::Thread::OysterThread thread; @@ -52,123 +37,113 @@ struct NetworkClient::PrivateData : public IThreadObject std::mutex postBoxMutex; Translator translator; + + ClientDataContainer(IThreadObject* o) + { + InitWinSock(); + callbackType = NetworkProtocolCallbackType_Unknown; + sendPostBox = new PostBox(); + connection.SetBlockingMode(false); + } + ClientDataContainer(IThreadObject* o, unsigned int socket ) + :connection(socket) + { + InitWinSock(); + callbackType = NetworkProtocolCallbackType_Unknown; + sendPostBox = new PostBox(); + connection.SetBlockingMode(false); + } + ~ClientDataContainer() + { + thread.Stop(); + thread.Wait(); + connection.Disconnect(); + callbackType = NetworkProtocolCallbackType_Unknown; + + ShutdownWinSock(); + } + +}; +struct NetworkClient::PrivateData : public IThreadObject +{ + Utility::DynamicMemory::SmartPointer data; + + PrivateData() { this->data = new ClientDataContainer(this); } + PrivateData(unsigned int socket) { this->data = new ClientDataContainer(this, socket); } + ~PrivateData() { } + + bool DoWork() + { + if(!this->data)return true; + if(!this->data->connection.IsConnected()) return true; + + Send(); + Recv(); + + return true; + } + + void Send(CustomNetProtocol* protocol) + { + if(!data) return; + + this->data->postBoxMutex.lock(); + this->data->sendPostBox->PostMessage(*protocol); + this->data->postBoxMutex.unlock(); + } + + int Send() + { + int errorCode = 0; + if(!data) return -1; + + this->data->postBoxMutex.lock(); + if(this->data->sendPostBox->IsFull()) + { + SmartPointer temp = new OysterByte(); + this->data->translator.Pack(temp, this->data->sendPostBox->FetchMessage()); + errorCode = this->data->connection.Send(temp); + } + this->data->postBoxMutex.unlock(); + + return errorCode; + } + + int Recv() + { + int errorCode = -1; + + if(this->data->callbackType == NetworkProtocolCallbackType_Function) + { + OysterByte temp = OysterByte(); + errorCode = this->data->connection.Recieve(temp); + + if(errorCode == 0) + { + CustomNetProtocol protocol; + bool ok = this->data->translator.Unpack(protocol, temp); + + //Check if the protocol was unpacked correctly + if(ok) + { + this->data->recvObjMutex.lock(); + if(this->data->callbackType == NetworkProtocolCallbackType_Function) + { + this->data->recvObj.protocolRecieverFnc(protocol); + } + else if(this->data->callbackType == NetworkProtocolCallbackType_Object) + { + this->data->recvObj.protocolRecievedObject->ProtocolRecievedCallback(protocol); + } + this->data->recvObjMutex.unlock(); + } + } + } + return errorCode; + } + }; -NetworkClient::PrivateData::PrivateData() -{ - InitWinSock(); - - callbackType = NetworkProtocolCallbackType_Unknown; - - connection = new Connection(); - sendPostBox = new PostBox; - this->thread.Create(this, false); - - Start(); -} - -NetworkClient::PrivateData::PrivateData(unsigned int socket) -{ - InitWinSock(); - - callbackType = NetworkProtocolCallbackType_Unknown; - - connection = new Connection(socket); - sendPostBox = new PostBox; - this->thread.Create(this, false); - - connection->SetBlockingMode(false); - - Start(); -} - -NetworkClient::PrivateData::~PrivateData() -{ - thread.Stop(); - - /*if(connection) - { - delete connection; - connection = NULL; - }*/ - - /*if(sendPostBox) - { - delete sendPostBox; - sendPostBox = NULL; - }*/ - - callbackType = NetworkProtocolCallbackType_Unknown; - - ShutdownWinSock(); -} - -bool NetworkClient::PrivateData::DoWork() -{ - Send(); - Recv(); - - return true; -} - -void NetworkClient::PrivateData::Send(CustomNetProtocol& protocol) -{ - postBoxMutex.lock(); - sendPostBox->PostMessage(protocol); - postBoxMutex.unlock(); -} - -int NetworkClient::PrivateData::Send() -{ - int errorCode = 0; - - postBoxMutex.lock(); - if(sendPostBox->IsFull()) - { - SmartPointer temp = new OysterByte(); - this->translator.Pack(temp, sendPostBox->FetchMessage()); - errorCode = this->connection->Send(temp); - } - postBoxMutex.unlock(); - - return errorCode; -} - -int NetworkClient::PrivateData::Recv() -{ - int errorCode = -1; - - SmartPointer temp = new OysterByte; - errorCode = this->connection->Recieve(temp); - - if(errorCode == 0) - { - CustomNetProtocol protocol; - bool ok = translator.Unpack(protocol, temp); - - //Check if the protocol was unpacked correctly - if(ok) - { - recvObjMutex.lock(); - if(callbackType == NetworkProtocolCallbackType_Function) - { - recvObj->protocolRecieverFnc(protocol); - } - else if(callbackType == NetworkProtocolCallbackType_Object) - { - recvObj->protocolRecievedObject->ProtocolRecievedCallback(protocol); - } - recvObjMutex.unlock(); - } - } - - return errorCode; -} - -void NetworkClient::PrivateData::Start() -{ - this->thread.Start(); -} /************************************* NetworkClient @@ -187,28 +162,25 @@ NetworkClient::NetworkClient(unsigned int socket) NetworkClient::NetworkClient(RecieverObject recvObj, NetworkProtocolCallbackType type) { privateData = new PrivateData(); - this->privateData->recvObj = SmartPointer(&recvObj);; + this->privateData->data->recvObj = SmartPointer(&recvObj);; } NetworkClient::NetworkClient(RecieverObject recvObj, NetworkProtocolCallbackType type, unsigned int socket) { privateData = new PrivateData(socket); - this->privateData->recvObj = SmartPointer(&recvObj); - this->privateData->callbackType = type; + this->privateData->data->recvObj = SmartPointer(&recvObj); + this->privateData->data->callbackType = type; } NetworkClient::NetworkClient(const NetworkClient& obj) { - this->privateData = new PrivateData(); - - this->privateData = obj.privateData; + this->privateData = new PrivateData(*obj.privateData); } NetworkClient& NetworkClient::operator =(const NetworkClient& obj) { delete privateData; - this->privateData = new PrivateData(); - this->privateData = obj.privateData; + this->privateData = new PrivateData(*obj.privateData); return *this; } @@ -223,16 +195,16 @@ NetworkClient::~NetworkClient() bool NetworkClient::Connect(unsigned short port, const char serverIP[]) { - int result = this->privateData->connection->Connect(port, serverIP); + int result = this->privateData->data->connection.Connect(port, serverIP); //Connect has succeeded if(result == 0) { - privateData->Start(); + privateData->data->thread.Start(); return true; } - privateData->connection->SetBlockingMode(false); + privateData->data->connection.SetBlockingMode(false); //Connect has failed return false; @@ -240,23 +212,25 @@ bool NetworkClient::Connect(unsigned short port, const char serverIP[]) void NetworkClient::Disconnect() { - privateData->connection->Disconnect(); + privateData->data->connection.Disconnect(); } bool NetworkClient::IsConnected() { - return privateData->connection->IsConnected(); + return privateData->data->connection.IsConnected(); } void NetworkClient::Send(CustomProtocolObject& protocol) { - this->privateData->Send(*protocol.GetProtocol()); + this->privateData->Send(protocol.GetProtocol()); } void NetworkClient::SetRecieverObject(RecieverObject recvObj, NetworkProtocolCallbackType type) { - privateData->recvObjMutex.lock(); - privateData->recvObj = SmartPointer(&recvObj); - privateData->callbackType = type; - privateData->recvObjMutex.unlock(); + if (type == NetworkProtocolCallbackType_Unknown) return; + + privateData->data->recvObjMutex.lock(); + privateData->data->recvObj = recvObj; + privateData->data->callbackType = type; + privateData->data->recvObjMutex.unlock(); } \ No newline at end of file diff --git a/Code/Network/NetworkAPI/NetworkClient.h b/Code/Network/NetworkAPI/NetworkClient.h index b3c30419..af95aeac 100644 --- a/Code/Network/NetworkAPI/NetworkClient.h +++ b/Code/Network/NetworkAPI/NetworkClient.h @@ -12,6 +12,7 @@ #endif #include "NetworkCallbackHelper.h" +#include namespace Oyster { diff --git a/Code/Network/NetworkAPI/NetworkServer.h b/Code/Network/NetworkAPI/NetworkServer.h index 5f6f7f3c..8edc59ff 100644 --- a/Code/Network/NetworkAPI/NetworkServer.h +++ b/Code/Network/NetworkAPI/NetworkServer.h @@ -13,6 +13,7 @@ #include "NetworkClient.h" #include "NetworkCallbackHelper.h" +#include namespace Oyster { diff --git a/Code/Network/NetworkAPI/Translator.cpp b/Code/Network/NetworkAPI/Translator.cpp index 032fbfdb..1a2105df 100644 --- a/Code/Network/NetworkAPI/Translator.cpp +++ b/Code/Network/NetworkAPI/Translator.cpp @@ -17,28 +17,6 @@ using namespace std; struct MyCastingStruct { std::map attributes; - - /*MyCastingStruct() - { } - ~MyCastingStruct() - { - for (auto i = attributes.begin(); i != attributes.end(); i++) - { - RemoveAttribute(i->first); - } - } - void RemoveAttribute(int ID) - { - auto i = attributes.find(ID); - if(i == attributes.end()) return; - - switch (i->second.type) - { - case NetAttributeType_CharArray: - delete [] i->second.value.netCharPtr; - break; - } - }*/ }; // TODO: Check if the package has been packed correctly. @@ -51,13 +29,13 @@ struct Translator::PrivateData } //Packages a header with a size(int) and a string of characters(char) - void PackHeader(SmartPointer &bytes, CustomNetProtocol& protocol) + void PackHeader(OysterByte &bytes, CustomNetProtocol& protocol) { auto it = ((MyCastingStruct*)protocol.privateData)->attributes.begin(); auto end = ((MyCastingStruct*)protocol.privateData)->attributes.end(); size = 4; //size(int) - bytes->AddSize(4); + bytes.AddSize(4); message.SetSize(size); @@ -67,18 +45,18 @@ struct Translator::PrivateData headerString.push_back(it->second.type); } - message.PackShort(size, *bytes); + message.PackShort(size, bytes); for(int i = 0; i < (int)headerString.size(); i++) { - message.PackChar(headerString.at(i), *bytes); + message.PackChar(headerString.at(i), bytes); size++; } message.SetSize(bytes); } - void PackMessage(SmartPointer &bytes, CustomNetProtocol& protocol) + void PackMessage(OysterByte &bytes, CustomNetProtocol& protocol) { auto it = ((MyCastingStruct*)protocol.privateData)->attributes.begin(); auto end = ((MyCastingStruct*)protocol.privateData)->attributes.end(); @@ -88,40 +66,40 @@ struct Translator::PrivateData switch((int)headerString.at(i)) { case NetAttributeType_Bool: - message.PackBool(it->second.value.netBool, *bytes); + message.PackBool(it->second.value.netBool, bytes); break; case NetAttributeType_Char: - message.PackChar(it->second.value.netChar, *bytes); + message.PackChar(it->second.value.netChar, bytes); break; case NetAttributeType_UnsignedChar: - message.PackUnsignedChar(it->second.value.netUChar, *bytes); + message.PackUnsignedChar(it->second.value.netUChar, bytes); break; case NetAttributeType_Short: - message.PackShort(it->second.value.netShort, *bytes); + message.PackShort(it->second.value.netShort, bytes); break; case NetAttributeType_UnsignedShort: - message.PackUnsignedShort(it->second.value.netUShort, *bytes); + message.PackUnsignedShort(it->second.value.netUShort, bytes); break; case NetAttributeType_Int: - message.PackInt(it->second.value.netInt, *bytes); + message.PackInt(it->second.value.netInt, bytes); break; case NetAttributeType_UnsignedInt: - message.PackUnsignedInt(it->second.value.netUInt, *bytes); + message.PackUnsignedInt(it->second.value.netUInt, bytes); break; case NetAttributeType_Int64: - message.PackInt64(it->second.value.netInt64, *bytes); + message.PackInt64(it->second.value.netInt64, bytes); break; case NetAttributeType_UnsignedInt64: - message.PackUnsignedInt64(it->second.value.netUInt64, *bytes); + message.PackUnsignedInt64(it->second.value.netUInt64, bytes); break; case NetAttributeType_Float: - message.PackFloat(it->second.value.netFloat, *bytes); + message.PackFloat(it->second.value.netFloat, bytes); break; case NetAttributeType_Double: - message.PackDouble(it->second.value.netDouble, *bytes); + message.PackDouble(it->second.value.netDouble, bytes); break; case NetAttributeType_CharArray: - message.PackStr(it->second.value.netCharPtr, *bytes); + message.PackStr(it->second.value.netCharPtr, bytes); break; default: numberOfUnknownTypes++; @@ -132,27 +110,27 @@ struct Translator::PrivateData message.SetSize(bytes); } - bool UnpackHeader(CustomNetProtocol& protocol, SmartPointer &bytes) + bool UnpackHeader(CustomNetProtocol& protocol, OysterByte &bytes) { message.SetSize(0); - int packageSize = message.UnpackInt(*bytes); - if(packageSize != bytes->GetSize()) + int packageSize = message.UnpackInt(bytes); + if(packageSize != bytes.GetSize()) { return false; } - short numberOfTypes = message.UnpackShort(*bytes); + short numberOfTypes = message.UnpackShort(bytes); for(int i = 0; i < numberOfTypes; i++) { - char temp = message.UnpackChar(*bytes); + char temp = message.UnpackChar(bytes); headerString.push_back(temp); } return true; } - void UnpackMessage(CustomNetProtocol& protocol, SmartPointer &bytes) + void UnpackMessage(CustomNetProtocol& protocol, OysterByte &bytes) { for(int i = 0; i < (int)headerString.size(); i++) { @@ -160,40 +138,40 @@ struct Translator::PrivateData switch(protocol[i].type) { case NetAttributeType_Bool: - protocol[i].value.netBool = message.UnpackBool(*bytes); + protocol[i].value.netBool = message.UnpackBool(bytes); break; case NetAttributeType_Char: - protocol[i].value.netChar = message.UnpackChar(*bytes); + protocol[i].value.netChar = message.UnpackChar(bytes); break; case NetAttributeType_UnsignedChar: - protocol[i].value.netUChar = message.UnpackUnsignedChar(*bytes); + protocol[i].value.netUChar = message.UnpackUnsignedChar(bytes); break; case NetAttributeType_Short: - protocol[i].value.netShort = message.UnpackShort(*bytes); + protocol[i].value.netShort = message.UnpackShort(bytes); break; case NetAttributeType_UnsignedShort: - protocol[i].value.netUShort = message.UnpackUnsignedShort(*bytes); + protocol[i].value.netUShort = message.UnpackUnsignedShort(bytes); break; case NetAttributeType_Int: - protocol[i].value.netInt = message.UnpackInt(*bytes); + protocol[i].value.netInt = message.UnpackInt(bytes); break; case NetAttributeType_UnsignedInt: - protocol[i].value.netUInt = message.UnpackUnsignedInt(*bytes); + protocol[i].value.netUInt = message.UnpackUnsignedInt(bytes); break; case NetAttributeType_Int64: - protocol[i].value.netInt64 = message.UnpackInt64(*bytes); + protocol[i].value.netInt64 = message.UnpackInt64(bytes); break; case NetAttributeType_UnsignedInt64: - protocol[i].value.netUInt64 = message.UnpackUnsignedInt64(*bytes); + protocol[i].value.netUInt64 = message.UnpackUnsignedInt64(bytes); break; case NetAttributeType_Float: - protocol[i].value.netFloat = message.UnpackFloat(*bytes); + protocol[i].value.netFloat = message.UnpackFloat(bytes); break; case NetAttributeType_Double: - protocol[i].value.netDouble = message.UnpackDouble(*bytes); + protocol[i].value.netDouble = message.UnpackDouble(bytes); break; case NetAttributeType_CharArray: - protocol[i].value.netCharPtr = message.UnpackCStr(*bytes); + protocol[i].value.netCharPtr = message.UnpackCStr(bytes); break; default: numberOfUnknownTypes++; @@ -233,7 +211,7 @@ const Translator& Translator::operator=(const Translator& obj) return *this; } -void Translator::Pack(SmartPointer &bytes, CustomNetProtocol& protocol) +void Translator::Pack(OysterByte &bytes, CustomNetProtocol& protocol) { privateData->headerString.clear(); @@ -241,7 +219,7 @@ void Translator::Pack(SmartPointer &bytes, CustomNetProtocol& protoc privateData->PackMessage(bytes, protocol); } -bool Translator::Unpack(CustomNetProtocol& protocol, SmartPointer &bytes) +bool Translator::Unpack(CustomNetProtocol& protocol, OysterByte &bytes) { if(!privateData->UnpackHeader(protocol, bytes)) { diff --git a/Code/Network/NetworkAPI/Translator.h b/Code/Network/NetworkAPI/Translator.h index ccbe43e2..f413492e 100644 --- a/Code/Network/NetworkAPI/Translator.h +++ b/Code/Network/NetworkAPI/Translator.h @@ -51,10 +51,10 @@ namespace Oyster Translator(const Translator& obj); const Translator& operator=(const Translator& obj); - void Pack(Utility::DynamicMemory::SmartPointer &bytes, CustomNetProtocol& protocol); + void Pack(OysterByte &bytes, CustomNetProtocol& protocol); //Returns false if it discovers any faulty stuff with the package. - bool Unpack(CustomNetProtocol& protocol, Utility::DynamicMemory::SmartPointer &bytes); + bool Unpack(CustomNetProtocol& protocol, OysterByte &bytes); private: struct PrivateData; diff --git a/Code/Network/NetworkDependencies/Connection.cpp b/Code/Network/NetworkDependencies/Connection.cpp index b470ebc2..567cd894 100644 --- a/Code/Network/NetworkDependencies/Connection.cpp +++ b/Code/Network/NetworkDependencies/Connection.cpp @@ -9,7 +9,7 @@ using namespace Oyster::Network; Connection::Connection() { - this->socket = 0; + this->socket = -1; bool stillSending = false; bool closed = true; } @@ -104,11 +104,11 @@ int Connection::Disconnect() return 0; } -int Connection::Send(Utility::DynamicMemory::SmartPointer &bytes) +int Connection::Send(OysterByte &bytes) { int nBytes; - nBytes = send(this->socket, *bytes, bytes->GetSize(), 0); + nBytes = send(this->socket, bytes, bytes.GetSize(), 0); if(nBytes == SOCKET_ERROR) { return WSAGetLastError(); @@ -117,20 +117,20 @@ int Connection::Send(Utility::DynamicMemory::SmartPointer &bytes) return 0; } -int Connection::Recieve(Utility::DynamicMemory::SmartPointer &bytes) +int Connection::Recieve(OysterByte &bytes) { int nBytes; - bytes->Resize(1000); - nBytes = recv(this->socket, *bytes, 1000, 0); + bytes.Resize(1000); + nBytes = recv(this->socket, bytes, 1000, 0); if(nBytes == SOCKET_ERROR) { - bytes->SetSize(0); + bytes.SetSize(0); return WSAGetLastError(); } else { - bytes->SetSize(nBytes); + bytes.SetSize(nBytes); } return 0; diff --git a/Code/Network/NetworkDependencies/Connection.h b/Code/Network/NetworkDependencies/Connection.h index 815c1d32..ae76a3f7 100644 --- a/Code/Network/NetworkDependencies/Connection.h +++ b/Code/Network/NetworkDependencies/Connection.h @@ -23,8 +23,8 @@ namespace Oyster virtual int InitiateServer( unsigned short port ); virtual int InitiateClient(); - virtual int Send( Utility::DynamicMemory::SmartPointer &bytes ); - virtual int Recieve( Utility::DynamicMemory::SmartPointer &bytes ); + virtual int Send( OysterByte &bytes ); + virtual int Recieve( OysterByte &bytes ); virtual int Disconnect(); virtual int Connect( unsigned short port , const char serverName[] ); diff --git a/Code/Network/NetworkDependencies/IConnection.h b/Code/Network/NetworkDependencies/IConnection.h index ecfe3869..76736071 100644 --- a/Code/Network/NetworkDependencies/IConnection.h +++ b/Code/Network/NetworkDependencies/IConnection.h @@ -19,8 +19,8 @@ namespace Oyster //sends and recieve functions with bytearrays, //will send to the users connection via socket - virtual int Send( Utility::DynamicMemory::SmartPointer &bytes ) = 0; - virtual int Recieve( Utility::DynamicMemory::SmartPointer &bytes) = 0; + virtual int Send( OysterByte &bytes ) = 0; + virtual int Recieve( OysterByte &bytes) = 0; //initiates sockets and address for server and client virtual int InitiateServer( unsigned short port ) { return false; }; diff --git a/Code/Network/OysterNetworkClient/ClientMain.cpp b/Code/Network/OysterNetworkClient/ClientMain.cpp index bc70190d..99785b41 100644 --- a/Code/Network/OysterNetworkClient/ClientMain.cpp +++ b/Code/Network/OysterNetworkClient/ClientMain.cpp @@ -34,7 +34,8 @@ int main() ThreadedClient* client = new ThreadedClient; //Connect to server - errorCode = client->Connect(15151, "193.11.186.101"); + //errorCode = client->Connect(15151, "193.11.186.101"); + errorCode = client->Connect(15151, "127.0.0.1"); if(errorCode != 0) { From 9eb8fcba40e4dec4f338cd012ba69bc15d456cc9 Mon Sep 17 00:00:00 2001 From: dean11 Date: Mon, 16 Dec 2013 09:00:11 +0100 Subject: [PATCH 32/32] Gamelogic - Publication to others... --- Code/Game/DanBiasServer/DanBiasServer.vcxproj | 1 + Code/Game/DanBiasServer/GameServer.cpp | 1 - .../ServerObjects/ClientObject.h | 7 +++-- .../ServerObjects/Lobby/MainLobby.cpp | 23 +++++++++++++-- .../ServerObjects/Lobby/MainLobby.h | 4 +-- .../ServerObjects/NetworkSession.cpp | 28 +++++++++++++++++-- .../ServerObjects/NetworkSession.h | 15 ++++++---- Code/Game/GameProtocols/GameProtocols.vcxproj | 1 + .../GameProtocols/ProtocolIdentificationID.h | 17 ++++++++--- Code/Network/NetworkAPI/NetworkClient.cpp | 10 +++++++ Code/Network/NetworkAPI/NetworkClient.h | 3 ++ .../OysterNetworkClient/ClientMain.cpp | 2 +- 12 files changed, 90 insertions(+), 22 deletions(-) diff --git a/Code/Game/DanBiasServer/DanBiasServer.vcxproj b/Code/Game/DanBiasServer/DanBiasServer.vcxproj index f0763732..af26345b 100644 --- a/Code/Game/DanBiasServer/DanBiasServer.vcxproj +++ b/Code/Game/DanBiasServer/DanBiasServer.vcxproj @@ -187,6 +187,7 @@ + diff --git a/Code/Game/DanBiasServer/GameServer.cpp b/Code/Game/DanBiasServer/GameServer.cpp index 0c4836d6..c0601b30 100644 --- a/Code/Game/DanBiasServer/GameServer.cpp +++ b/Code/Game/DanBiasServer/GameServer.cpp @@ -54,7 +54,6 @@ namespace DanBias if(!this->server->Init(serverDesc)) return DanBiasServerReturn_Error; if(!WindowShell::CreateConsoleWindow()) return DanBiasServerReturn_Error; - if(!WindowShell::CreateWin(WindowShell::WINDOW_INIT_DESC())) return DanBiasServerReturn_Error; this->initiated = true; return DanBiasServerReturn_Sucess; diff --git a/Code/Game/DanBiasServer/ServerObjects/ClientObject.h b/Code/Game/DanBiasServer/ServerObjects/ClientObject.h index c1cab669..83327d1b 100644 --- a/Code/Game/DanBiasServer/ServerObjects/ClientObject.h +++ b/Code/Game/DanBiasServer/ServerObjects/ClientObject.h @@ -9,7 +9,8 @@ namespace DanBias { - class ClientObject :public Oyster::Network::ProtocolRecieverObject + class ClientObject + :public Oyster::Network::ProtocolRecieverObject { public: ClientObject(const Oyster::Network::NetworkClient& client); @@ -20,8 +21,8 @@ namespace DanBias GameLogic::Player* Logic_Object(); Oyster::Network::NetworkClient* NetClient_Object(); - private: - void ProtocolRecievedCallback(Oyster::Network::CustomNetProtocol& protocol) override; + /** This method is NOT threadsafe. */ + virtual void ProtocolRecievedCallback(Oyster::Network::CustomNetProtocol& protocol) override; private: GameLogic::Player logicPlayer; diff --git a/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.cpp b/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.cpp index f4c8b439..e7edddd4 100644 --- a/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.cpp +++ b/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.cpp @@ -1,5 +1,5 @@ #include "MainLobby.h" - +#include namespace DanBias { @@ -13,14 +13,31 @@ namespace DanBias } void MainLobby::Release() { - this->clients.clear(); + this->DetachClient(); } void MainLobby::Frame() { if(!this->box.IsEmpty()) { - + NetEvent &e = this->box.Fetch(); + ParseEvent(e); } } + +//////// Private + void MainLobby::ParseEvent(NetEvent& e) + { + static const short i = MAXSHORT; + if(e.protocol[0].type != Oyster::Network::NetAttributeType_Short) return; + + short f = e.protocol[0].value.netShort; + + switch (f) + { + default: + break; + } + } + }//End namespace DanBias \ No newline at end of file diff --git a/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.h b/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.h index 9308a4d4..8e8b520a 100644 --- a/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.h +++ b/Code/Game/DanBiasServer/ServerObjects/Lobby/MainLobby.h @@ -2,8 +2,6 @@ #define DANBIASSERVER_MAINLOBBY_H #include "..\NetworkSession.h" -#include -#include namespace DanBias { @@ -17,7 +15,7 @@ namespace DanBias void Frame(); private: - + void ParseEvent(NetEvent& e); }; }//End namespace DanBias diff --git a/Code/Game/DanBiasServer/ServerObjects/NetworkSession.cpp b/Code/Game/DanBiasServer/ServerObjects/NetworkSession.cpp index 24de1dfe..c33af5e0 100644 --- a/Code/Game/DanBiasServer/ServerObjects/NetworkSession.cpp +++ b/Code/Game/DanBiasServer/ServerObjects/NetworkSession.cpp @@ -1,3 +1,4 @@ + #include "ClientObject.h" #include "NetworkSession.h" #include @@ -20,15 +21,38 @@ namespace DanBias if(!this->clients[i]) { this->clients[i] = client; - //this->clients[i]->SetPostbox(&this->box); + this->clients[i]->SetPostbox(&this->box); return; } } this->clients.push_back(client); } + + void NetworkSession::DetachClient(Oyster::Network::NetworkClient* client) + { + for (unsigned int i = 0; i < this->clients.size(); i++) + { + if(this->clients[0]->NetClient_Object()->Id() == client->Id()) + this->clients[i] = 0; + } + } + void NetworkSession::DetachClient(ClientObject* client) + { + for (unsigned int i = 0; i < this->clients.size(); i++) + { + if(this->clients[0]->NetClient_Object()->Id() == client->NetClient_Object()->Id()) + this->clients[i] = 0; + } + + } void NetworkSession::DetachClient(short ID) { - //this->clients[0]->NetClient_Object()-> + for (unsigned int i = 0; i < this->clients.size(); i++) + { + if(this->clients[0]->NetClient_Object()->Id() == ID) + this->clients[i] = 0; + } + } void NetworkSession::DetachClient() { diff --git a/Code/Game/DanBiasServer/ServerObjects/NetworkSession.h b/Code/Game/DanBiasServer/ServerObjects/NetworkSession.h index 43a7bde4..9ff9b016 100644 --- a/Code/Game/DanBiasServer/ServerObjects/NetworkSession.h +++ b/Code/Game/DanBiasServer/ServerObjects/NetworkSession.h @@ -1,10 +1,14 @@ +///////////////////////////////////////////////////////////////////// +// Created by [Dennis Andersen] [2013] +///////////////////////////////////////////////////////////////////// #ifndef DANBIASSERVER_NETWORK_SESSION_H #define DANBIASSERVER_NETWORK_SESSION_H #define NOMINMAX #include "Utilities.h" #include -#include +#include +#include #include namespace DanBias @@ -13,12 +17,10 @@ namespace DanBias class NetworkSession { public: - struct ClientEvent + struct NetEvent { ClientObject* reciever; Oyster::Network::CustomNetProtocol protocol; - ClientEvent() { reciever = 0; } - ~ClientEvent() { } }; public: @@ -27,6 +29,8 @@ namespace DanBias void AttachClient(Utility::DynamicMemory::SmartPointer client); + void DetachClient(Oyster::Network::NetworkClient* client); + void DetachClient(ClientObject* client); void DetachClient(short ID); void DetachClient(); @@ -36,10 +40,11 @@ namespace DanBias void Send(Oyster::Network::CustomNetProtocol& protocol, int ID); //TODO: Do more lobby features + //virtual void protected: std::vector> clients; - Oyster::PostBox box; + Oyster::PostBox box; }; }//End namespace DanBias #endif // !DANBIASSERVER_NETWORK_SESSION_H diff --git a/Code/Game/GameProtocols/GameProtocols.vcxproj b/Code/Game/GameProtocols/GameProtocols.vcxproj index 12584afb..4b0d7c39 100644 --- a/Code/Game/GameProtocols/GameProtocols.vcxproj +++ b/Code/Game/GameProtocols/GameProtocols.vcxproj @@ -154,6 +154,7 @@ + diff --git a/Code/Game/GameProtocols/ProtocolIdentificationID.h b/Code/Game/GameProtocols/ProtocolIdentificationID.h index b872618a..09f1aeed 100644 --- a/Code/Game/GameProtocols/ProtocolIdentificationID.h +++ b/Code/Game/GameProtocols/ProtocolIdentificationID.h @@ -1,12 +1,21 @@ +///////////////////////////////////////////////////////////////////// +// Created 2013 by: +// [Dennis Andersen], [Linda Andersson] +///////////////////////////////////////////////////////////////////// #ifndef GAMEPROTOCOL_PROTOCOL_DEFINITION_ID_H #define GAMEPROTOCOL_PROTOCOL_DEFINITION_ID_H /* THERE CAN ABSOLUTLEY NOT BE TWO DEFINITIONS WITH THE SAME ID!! */ -#define protocol_PlayerNavigation 0 -#define protocol_PlayerPosition 1 -#define protocol_ObjectPosition 2 +#define protocol_PlayerNavigation 0 +#define protocol_PlayerPosition 1 +#define protocol_ObjectPosition 2 -#define PROTOCOL_TEST 1000 +#define protocol_Lobby_Msg 60 + +#define protocol_General_Disconnect 100 +#define protocol_General_Ping 101 + +#define PROTOCOL_TEST 1000 #endif // !GAMEPROTOCOL_PROTOCOL_DEFINITION_ID_H diff --git a/Code/Network/NetworkAPI/NetworkClient.cpp b/Code/Network/NetworkAPI/NetworkClient.cpp index e9de4297..aed1046f 100644 --- a/Code/Network/NetworkAPI/NetworkClient.cpp +++ b/Code/Network/NetworkAPI/NetworkClient.cpp @@ -245,4 +245,14 @@ void NetworkClient::SetRecieverObject(RecieverObject recvObj, NetworkProtocolCal bool NetworkClient::operator ==(const NetworkClient& obj) { return (this->privateData->data->ID == obj.privateData->data->ID); +} + +bool NetworkClient::operator ==(const int& ID) +{ + return this->privateData->data->ID == ID; +} + +int NetworkClient::Id() const +{ + return this->privateData->data->ID; } \ No newline at end of file diff --git a/Code/Network/NetworkAPI/NetworkClient.h b/Code/Network/NetworkAPI/NetworkClient.h index 5c08e794..95463d1c 100644 --- a/Code/Network/NetworkAPI/NetworkClient.h +++ b/Code/Network/NetworkAPI/NetworkClient.h @@ -45,6 +45,9 @@ namespace Oyster //Compares the internal ID. bool operator ==(const NetworkClient& obj); + bool operator ==(const int& ID); + + int Id() const; private: struct PrivateData; diff --git a/Code/Network/OysterNetworkClient/ClientMain.cpp b/Code/Network/OysterNetworkClient/ClientMain.cpp index 3f451315..2274fb5e 100644 --- a/Code/Network/OysterNetworkClient/ClientMain.cpp +++ b/Code/Network/OysterNetworkClient/ClientMain.cpp @@ -41,7 +41,7 @@ int main() //Connect to server //errorCode = client->Connect(15151, "193.11.186.101"); - errorCode = client->Connect(15151, "127.0.0.1"); + errorCode = client.Connect(15151, "127.0.0.1"); client.SetRecieverObject(proc, NetworkProtocolCallbackType_Function); if(errorCode != 0)