From c9c562fda6d92303312d8f77812ec7c4390e8c45 Mon Sep 17 00:00:00 2001 From: Dennis Andersen Date: Fri, 31 Jan 2014 10:50:38 +0100 Subject: [PATCH] GameServer - Added some functionality in windowshell --- Code/Game/DanBiasGame/DanBiasGame_Impl.cpp | 2 +- Code/Game/GameLogic/Game_PlayerData.cpp | 2 +- Code/Game/GameLogic/Level.cpp | 4 +- .../Implementation/GameSession_Gameplay.cpp | 4 +- Code/Network/NetworkAPI/NetworkClient.cpp | 2 + Code/WindowManager/WindowShell.h | 79 +++++++++++++++---- 6 files changed, 73 insertions(+), 20 deletions(-) diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index 93c4a60a..a22963a8 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -56,7 +56,7 @@ namespace DanBias { WindowShell::CreateConsoleWindow(); - if(! m_data->window->CreateWin(WindowShell::WINDOW_INIT_DESC())) + if(! m_data->window->CreateWin(WindowShell::WINDOW_INIT_DESC(L"Window", cPOINT(1600, 900), cPOINT()))) return DanBiasClientReturn_Error; if( FAILED( InitDirect3D() ) ) diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index f2ae7c19..78a1f05a 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -7,7 +7,7 @@ Game::PlayerData::PlayerData() { //set some stats that are appropriate to a player Oyster::Physics::API::SimpleBodyDescription sbDesc; - sbDesc.centerPosition = Oyster::Math::Float3(0,165,0); + sbDesc.centerPosition = Oyster::Math::Float3(0,16,0); sbDesc.size = Oyster::Math::Float3(4,7,4); //create rigid body diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index f631979d..1fbc160e 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -25,7 +25,7 @@ void Level::InitiateLevel(float radius) API::SphericalBodyDescription sbDesc; sbDesc.centerPosition = Oyster::Math::Float4(0,0,0,1); sbDesc.ignoreGravity = true; - sbDesc.radius = 150; + sbDesc.radius = 8; sbDesc.mass = 10e12f; ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release(); @@ -59,7 +59,7 @@ void Level::InitiateLevel(float radius) // add gravitation API::Gravity gravityWell; gravityWell.gravityType = API::Gravity::GravityType_Well; - gravityWell.well.mass = 10e16f; + gravityWell.well.mass = 10e14f; gravityWell.well.position = Oyster::Math::Float4(0,0,0,1); API::Instance().AddGravity(gravityWell); } diff --git a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp index c0041301..cc3c9740 100644 --- a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp @@ -92,9 +92,9 @@ namespace DanBias Protocol_ObjectPosition p(world, 2); GameSession::gameSession->Send(*p.GetProtocol()); } - GameLogic::IObjectData* obj = NULL; - if(dynamic_cast(movedObject)) + else if(dynamic_cast(movedObject)) { + GameLogic::IObjectData* obj = NULL; obj = ((GameLogic::ILevelData*)movedObject)->GetObjectAt(0); if(obj) { diff --git a/Code/Network/NetworkAPI/NetworkClient.cpp b/Code/Network/NetworkAPI/NetworkClient.cpp index 717a2946..d7ec5d34 100644 --- a/Code/Network/NetworkAPI/NetworkClient.cpp +++ b/Code/Network/NetworkAPI/NetworkClient.cpp @@ -291,6 +291,8 @@ bool NetworkClient::Connect(unsigned short port, const char serverIP[]) void NetworkClient::Disconnect() { + if(!privateData) return; + privateData->connection.Disconnect(); privateData->thread.Terminate(); } diff --git a/Code/WindowManager/WindowShell.h b/Code/WindowManager/WindowShell.h index 86726ccf..04bb9931 100644 --- a/Code/WindowManager/WindowShell.h +++ b/Code/WindowManager/WindowShell.h @@ -7,7 +7,11 @@ #include - +struct cPOINT :public POINT +{ + cPOINT() { x=(0); y=(0); } + cPOINT(int width, int height) { x=(width); y=(height); } +}; class WindowShell { public: @@ -28,23 +32,70 @@ public: HCURSOR cursor; //!< Optional HBRUSH background; //!< Optional - WINDOW_INIT_DESC() + WINDOW_INIT_DESC( + HWND _parent = 0, + HINSTANCE _hInstance = 0, + WNDPROC _windowProcCallback = 0, + const wchar_t* _windowName = L"Window", + POINT _windowSize = cPOINT(800, 600), + POINT _windowPosition = cPOINT(0,0), + UINT _windowClassStyle = (CS_HREDRAW | CS_VREDRAW | CS_OWNDC), + UINT _windowStyle = (WS_POPUPWINDOW|WS_SYSMENU|WS_CAPTION), + HICON _icon = LoadIcon(0, IDI_APPLICATION), + HCURSOR _cursor = LoadCursor(NULL, IDC_ARROW), + HBRUSH _background = (HBRUSH)GetStockObject(BLACK_BRUSH) + ) { - parent = 0; - hInstance = NULL; - windowName = L"Window"; - 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; + parent = _parent; + hInstance = _hInstance; + windowName = _windowName; + windowSize = _windowSize; + windowPosition = _windowPosition; + windowProcCallback = _windowProcCallback; + windowClassStyle = _windowClassStyle; + windowStyle = _windowStyle; + icon = _icon; + cursor = _cursor; + background = _background; + } + WINDOW_INIT_DESC( + HWND _parent, + HINSTANCE _hInstance, + WNDPROC _windowProcCallback, + const wchar_t* _windowName, + cPOINT _windowSize, + cPOINT _windowPosition + ) + { + parent = _parent; + hInstance = _hInstance; + windowName = _windowName; + windowSize = _windowSize; + windowPosition = _windowPosition; + windowProcCallback = _windowProcCallback; + windowClassStyle = (CS_HREDRAW | CS_VREDRAW | CS_OWNDC); + windowStyle = (WS_POPUPWINDOW|WS_SYSMENU|WS_CAPTION); + icon = LoadIcon(0, IDI_APPLICATION); + cursor = LoadCursor(NULL, IDC_ARROW); + background = (HBRUSH)GetStockObject(BLACK_BRUSH); + } + WINDOW_INIT_DESC( + const wchar_t* _windowName, + cPOINT _windowSize, + cPOINT _windowPosition + ) + { + parent = 0; + hInstance = 0; + windowName = _windowName; + windowSize = _windowSize; + windowPosition = _windowPosition; + windowProcCallback = 0; + windowClassStyle = (CS_HREDRAW | CS_VREDRAW | CS_OWNDC); + windowStyle = (WS_POPUPWINDOW|WS_SYSMENU|WS_CAPTION); icon = LoadIcon(0, IDI_APPLICATION); cursor = LoadCursor(NULL, IDC_ARROW); background = (HBRUSH)GetStockObject(BLACK_BRUSH); - //background = (HBRUSH)GetStockObject(BACKGROUND_BLUE);(HBRUSH)(COLOR_WINDOW+1); } };