From 5cc858ba1b5ec89191c92a94811d1dab31fe064e Mon Sep 17 00:00:00 2001 From: lanariel Date: Wed, 19 Feb 2014 13:38:36 +0100 Subject: [PATCH 01/16] Normal normals --- Code/Game/GameClient/DanBiasGame_Impl.cpp | 6 +++--- .../GameClientState/C_obj/C_Player.cpp | 2 +- .../OysterGraphics/Render/DefaultRenderer.cpp | 17 +++++++++------ .../Shader/Passes/Gather/GatherPixel.hlsl | 21 +++++++++++++------ .../Shader/Passes/Gather/GatherVertex.hlsl | 2 +- .../Shader/Passes/Light/LightPass.hlsl | 10 +++++++-- .../Shader/Passes/Post/PostPass.hlsl | 18 +++------------- 7 files changed, 42 insertions(+), 34 deletions(-) diff --git a/Code/Game/GameClient/DanBiasGame_Impl.cpp b/Code/Game/GameClient/DanBiasGame_Impl.cpp index b978597c..15918adf 100644 --- a/Code/Game/GameClient/DanBiasGame_Impl.cpp +++ b/Code/Game/GameClient/DanBiasGame_Impl.cpp @@ -108,7 +108,7 @@ namespace DanBias data.capFrame += dt; if(data.capFrame > 0.03) { - switch( Update(dt) ) + switch( Update(data.capFrame) ) { case Result_continue: break; case Result_quit: return DanBiasClientReturn_Success; @@ -117,7 +117,7 @@ namespace DanBias } if(Render() != S_OK) return DanBiasClientReturn_Error; - data.capFrame = 0; + data.capFrame -= 0.03; } if(data.networkClient.IsConnected()) @@ -143,7 +143,7 @@ namespace DanBias p.texturePath = L"..\\Content\\Textures\\"; p.Resolution = Oyster::Math::Float2( 1280.0f, 720.0f ); //! @todo fix proper amb value - p.AmbientValue = 1.0f; + p.AmbientValue = 1.3f; if(Oyster::Graphics::API::Init(data.window->GetHWND(), false, false, p) != Oyster::Graphics::API::Sucsess) return E_FAIL; diff --git a/Code/Game/GameClient/GameClientState/C_obj/C_Player.cpp b/Code/Game/GameClient/GameClientState/C_obj/C_Player.cpp index b6420f53..60d3f184 100644 --- a/Code/Game/GameClient/GameClientState/C_obj/C_Player.cpp +++ b/Code/Game/GameClient/GameClientState/C_obj/C_Player.cpp @@ -20,5 +20,5 @@ bool C_Player::Init(ModelInitData modelInit) void C_Player::playAnimation(std::wstring animation, bool loop) { if(model) - Oyster::Graphics::API::PlayAnimation(model, L"movement", loop); + Oyster::Graphics::API::PlayAnimation(model, animation, loop); } \ No newline at end of file diff --git a/Code/OysterGraphics/Render/DefaultRenderer.cpp b/Code/OysterGraphics/Render/DefaultRenderer.cpp index 22b71df7..689c3abe 100644 --- a/Code/OysterGraphics/Render/DefaultRenderer.cpp +++ b/Code/OysterGraphics/Render/DefaultRenderer.cpp @@ -50,7 +50,12 @@ namespace Oyster if(models[i].Visible) { Definitions::PerModel pm; - pm.WV = View * models[i].WorldMatrix.GetTranspose().GetInverse(); + Math::Float3x3 normalTransform; + normalTransform = Math::Float3x3(models[i].WorldMatrix.v[0].xyz, models[i].WorldMatrix.v[1].xyz, models[i].WorldMatrix.v[2].xyz); + normalTransform.Transpose().Invert(); + Math::Matrix m = Math::Matrix(Math::Vector4(normalTransform.v[0],0.0f), Math::Vector4(normalTransform.v[1],0.0f), Math::Vector4(normalTransform.v[2],0.0f), Math::Vector4(0.0f)); + pm.WV = View * m; + //pm.WV = models[i].WorldMatrix.GetTranspose().GetInverse(); pm.WVP = Projection * View * models[i].WorldMatrix; Model::ModelInfo* info = models[i].info; @@ -159,10 +164,10 @@ namespace Oyster { Definitions::BlurrData bd; bd.BlurMask = Math::Float4(1,1,1,1); - bd.StopX = Core::resolution.x/2; - bd.StopY = Core::resolution.y; + bd.StopX = (UINT)Core::resolution.x/2; + bd.StopY = (UINT)Core::resolution.y; bd.StartX = 0; - bd.StartY = Core::resolution.y/2; + bd.StartY = (UINT)Core::resolution.y/2; void* data = Resources::Blur::Data.Map(); memcpy(data,&bd,sizeof(Definitions::BlurrData)); @@ -179,8 +184,8 @@ namespace Oyster { Definitions::BlurrData bd; bd.BlurMask = Math::Float4(0,0,0,1); - bd.StopX = Core::resolution.x/2; - bd.StopY = Core::resolution.y/2; + bd.StopX = (UINT)Core::resolution.x/2; + bd.StopY = (UINT)Core::resolution.y/2; bd.StartX = 0; bd.StartY = 0; diff --git a/Code/OysterGraphics/Shader/Passes/Gather/GatherPixel.hlsl b/Code/OysterGraphics/Shader/Passes/Gather/GatherPixel.hlsl index 2a6f3972..d9545573 100644 --- a/Code/OysterGraphics/Shader/Passes/Gather/GatherPixel.hlsl +++ b/Code/OysterGraphics/Shader/Passes/Gather/GatherPixel.hlsl @@ -17,8 +17,8 @@ float3x3 cotangent_frame( float3 N, float3 p, float2 uv ) float3 B = dp2perp * duv1.y + dp1perp * duv2.y; // construct a scale-invariant frame - float invmax = 1/sqrt( max( dot(T,T), dot(B,B) ) ); - return float3x3( T * invmax, B * invmax, N ); + float invmax = rsqrt( max( dot(T,T), dot(B,B) ) ); + return transpose(float3x3( T * invmax, B * invmax, N )); } float3 perturb_normal( float3 N, float3 V, float2 texcoord ) @@ -41,11 +41,20 @@ PixelOut main(VertexOut input) { PixelOut output; output.DiffuseGlow = Diffuse.Sample(S1, input.UV) * float4(Color, 1); - float3 normal = normalize(input.normal); - normal = perturb_normal( normal, normalize(-input.ViewPos), input.UV ); + //NORMALIZE + float3x3 CoTangentFrame = cotangent_frame(input.normal, normalize(input.ViewPos), input.UV); - //output.NormalSpec = float4(normal, Normal.Sample(S1, input.UV).w*255); - output.NormalSpec = float4(normal, Normal.Sample(S1, input.UV).w*0); + float3 map = Normal.Sample(S1,input.UV).xyz; + //map = normalize((map * 2) -1); + map = map * 255./127. - 128./127.; + //map = map * 255; + float3 normal = normalize(mul(CoTangentFrame, map)); + //normal = perturb_normal( normal, normalize(-input.ViewPos), input.UV ); + + output.NormalSpec = float4(normal, Normal.Sample(S1, input.UV).w*255); + + //output.NormalSpec = float4(input.normal, Normal.Sample(S1, input.UV).w * 0); + //output.NormalSpec = float4(map,0); return output; } \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/Passes/Gather/GatherVertex.hlsl b/Code/OysterGraphics/Shader/Passes/Gather/GatherVertex.hlsl index fd3da6b1..79c21eec 100644 --- a/Code/OysterGraphics/Shader/Passes/Gather/GatherVertex.hlsl +++ b/Code/OysterGraphics/Shader/Passes/Gather/GatherVertex.hlsl @@ -11,7 +11,7 @@ VertexOut main( VertexIn input ) input.pos = mul(boneTrans,float4(input.pos,1)).xyz * Animated + input.pos * int(1-Animated); - input.normal = mul(boneTrans,float4(input.normal,1)).xyz * Animated + input.normal * int(1-Animated); + input.normal = mul(boneTrans,float4(input.normal,0)).xyz * Animated + input.normal * int(1-Animated); output.pos = mul(WVP, float4(input.pos,1)); output.ViewPos = mul(WV, float4(input.pos,1)); diff --git a/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl b/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl index 9a5345bf..96b8ab69 100644 --- a/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl +++ b/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl @@ -39,10 +39,16 @@ void main( uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID ) DiffBase += DiffuseGlow[DTid.xy + uint2(0,1)]; DiffBase += DiffuseGlow[DTid.xy + uint2(1,1)]; DiffBase = DiffBase / 4; + + float4 DepthBase = DepthTexture[DTid.xy]; + DepthBase = DepthTexture[DTid.xy + uint2(1,0)]; + DepthBase = DepthTexture[DTid.xy + uint2(0,1)]; + DepthBase = DepthTexture[DTid.xy + uint2(1,1)]; + DepthBase = DepthBase /4; Ambient[DTid.xy/2] = float4(DiffBase.xyz, AmbValue); Ambient[DTid.xy/2 + float2(Pixels.x/2, 0)] = GUI[DTid.xy]; - Ambient[DTid.xy/2 + float2(0, Pixels.y/2)] = float4(DiffBase.xyz * DiffBase.w,1); - Ambient[DTid.xy/2 + Pixels/2] = float4(NormalSpec[DTid.xy].xyz,1); + Ambient[DTid.xy/2 + float2(0, Pixels.y/2)] = float4(DiffBase.xyz * DiffBase.w * 10 /* * (2-DepthBase) */,1); + Ambient[DTid.xy/2 + Pixels/2] = float4(NormalSpec[DTid.xy].xyz * float3(1,1,-1),1); } } \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl index decf5526..4135bdcb 100644 --- a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl +++ b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl @@ -11,24 +11,12 @@ cbuffer Size : register(b0) float AmbFactor; } -float4 SuperSample(float4 Glow, uint3 DTid) -{ - // Line X - float2 index = (float2)(DTid.xy/2); - index += float2(0,Output.Length.y/2); - index = index / Output.Length; - Glow = Ambient.SampleLevel(S1, index,1); - Glow = Glow; - - return Glow; -} - [numthreads(16, 16, 1)] void main( uint3 DTid : SV_DispatchThreadID ) { float4 Light = Diffuse[DTid.xy] + saturate(Specular[DTid.xy]); - float4 Amb = float4(Ambient[DTid.xy/2].xyz /* * Ambient[DTid.xy/2].w*/, 0); - float4 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)]; + float3 Amb = Ambient[DTid.xy/2].xyz /* * Ambient[DTid.xy/2].w */; + float3 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)].xyz; float4 GUI; uint2 index = DTid.xy/2 + uint2((uint)Output.Length.x/(uint)2,0); @@ -38,6 +26,6 @@ void main( uint3 DTid : SV_DispatchThreadID ) PostLight = PostLight * (1 - GUI.w); Output[DTid.xy] = float4((GUI.xyz * GUI.w) + PostLight, 1); - //Output[DTid.xy] = float4(Ambient[DTid.xy/2 + uint2(0,Output.Length.y*0.5f)].xyz,1); + //Output[DTid.xy] = float4(Ambient[DTid.xy/2 + uint2(Output.Length*0.5f)].xyz,1); //Output[DTid.xy] = Ambient[DTid.xy]; } \ No newline at end of file From 03efca45b87665fdaeb17d61097ea59d7766da89 Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Wed, 19 Feb 2014 15:40:09 +0100 Subject: [PATCH 02/16] Fixed ButonEllipse it was not up to date. And only resizing the buttons now. --- .../GameClientState/Buttons/ButtonEllipse.h | 35 +++++++------- .../GameClientState/Buttons/ButtonRectangle.h | 46 +++++++------------ .../GameClientState/Buttons/EventButtonGUI.h | 24 ++++++---- 3 files changed, 48 insertions(+), 57 deletions(-) diff --git a/Code/Game/GameClient/GameClientState/Buttons/ButtonEllipse.h b/Code/Game/GameClient/GameClientState/Buttons/ButtonEllipse.h index 7d9a9a5d..57c6008d 100644 --- a/Code/Game/GameClient/GameClientState/Buttons/ButtonEllipse.h +++ b/Code/Game/GameClient/GameClientState/Buttons/ButtonEllipse.h @@ -7,9 +7,6 @@ #include "EventButtonGUI.h" -//Only for testing because we don't have any other input -#include "../WindowManager/WindowShell.h" - namespace DanBias { namespace Client @@ -18,24 +15,25 @@ namespace DanBias class ButtonEllipse : public EventButtonGUI { public: - ButtonEllipse() - : EventButtonGUI(), radius(0) + ButtonEllipse(std::wstring textureName, std::wstring buttonText, + Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor, + Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) + : EventButtonGUI(textureName, buttonText, textColor, backColor, hoverColor, pressedColor, owner, pos, size, resize) {} - ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, Owner owner, Oyster::Math::Float3 pos, - Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) - : EventButtonGUI(textureName, buttonText, textColor, owner, pos, size, resize) + ButtonEllipse(std::wstring textureName, std::wstring buttonText, + Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor, + EventFunc func, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) + : EventButtonGUI(textureName, buttonText, textColor, backColor, hoverColor, pressedColor, func, pos, size, resize) {} - ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Oyster::Math::Float3 pos, - Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) - : EventButtonGUI(textureName, buttonText, textColor, func, pos, size, resize) + ButtonEllipse(std::wstring textureName, std::wstring buttonText, + Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor, + EventFunc func, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) + : EventButtonGUI(textureName, buttonText, textColor, backColor, hoverColor, pressedColor, func, owner, pos, size, resize) {} - ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Owner owner, Oyster::Math::Float3 pos, - Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) - : EventButtonGUI(textureName, buttonText, textColor, func, owner, pos, size, resize) - {} - ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos, - Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) - : EventButtonGUI(textureName, buttonText, textColor, func, owner, userData, pos, size, resize) + ButtonEllipse(std::wstring textureName, std::wstring buttonText, + Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor, + EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) + : EventButtonGUI(textureName, buttonText, textColor, backColor, hoverColor, pressedColor, func, owner, userData, pos, size, resize) {} virtual ~ButtonEllipse() {} @@ -43,7 +41,6 @@ namespace DanBias //Circle vs point collision bool Collision(Oyster::Event::MouseInput& input) { - //Should come from the InputClass float xMouse = input.x, yMouse = input.y; double normx = (xMouse - pos.x) / size.x; diff --git a/Code/Game/GameClient/GameClientState/Buttons/ButtonRectangle.h b/Code/Game/GameClient/GameClientState/Buttons/ButtonRectangle.h index 7f3db825..33098568 100644 --- a/Code/Game/GameClient/GameClientState/Buttons/ButtonRectangle.h +++ b/Code/Game/GameClient/GameClientState/Buttons/ButtonRectangle.h @@ -6,9 +6,6 @@ #define DANBIAS_CLIENT_BUTTON_RECTANGLE_H #include "EventButtonGUI.h" -#include -//Only for testing because we don't have any other input -#include "../WindowManager/WindowShell.h" namespace DanBias { @@ -18,55 +15,46 @@ namespace DanBias class ButtonRectangle : public EventButtonGUI { public: - ButtonRectangle() - : EventButtonGUI(), width(0), height(0) - {} ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor, - Owner owner, Oyster::Math::Float3 pos, - Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None) - : EventButtonGUI(textureName, buttonText, - textColor, backColor, hoverColor, pressedColor, - owner, pos, size, resize) + Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None) + : EventButtonGUI(textureName, buttonText + , textColor, backColor, hoverColor, pressedColor + , owner, pos, size, resize) {} ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor, - EventFunc func, Oyster::Math::Float3 pos, - Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None) - : EventButtonGUI(textureName, buttonText, - textColor, backColor, hoverColor, pressedColor, - func, pos, size, resize) + EventFunc func, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None) + : EventButtonGUI(textureName, buttonText + , textColor, backColor, hoverColor, pressedColor + , func, pos, size, resize) {} ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor, - EventFunc func, Owner owner, Oyster::Math::Float3 pos, - Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None) - : EventButtonGUI(textureName, buttonText, - textColor, backColor, hoverColor, pressedColor, - func, owner, pos, size, resize) + EventFunc func, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None) + : EventButtonGUI(textureName, buttonText + , textColor, backColor, hoverColor, pressedColor + , func, owner, pos, size, resize) {} ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor, - EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos, - Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None) - : EventButtonGUI(textureName, buttonText, - textColor, backColor, hoverColor, pressedColor, - func, owner, userData, pos, size, resize) + EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None) + : EventButtonGUI(textureName, buttonText + , textColor, backColor, hoverColor, pressedColor + , func, owner, userData, pos, size, resize) {} virtual ~ButtonRectangle() {} - //Circle vs point collision + //Rectangle vs point collision bool Collision(Oyster::Event::MouseInput& input) { - //Should come from the InputClass float xMouse = input.x, yMouse = input.y; float widthTemp = pos.x - size.x * 0.5f; float widthTemp2 = pos.x + size.x * 0.5f; float heightTemp = pos.y - size.y * 0.5f; float heightTemp2 = pos.y + size.y * 0.5f; - //std::cout << p.x << ' ' << p.y << ' ' << widthTemp << ' ' << heightTemp << std::endl; if(xMouse >= widthTemp && xMouse <= widthTemp2 && yMouse >= heightTemp && yMouse <= heightTemp2) diff --git a/Code/Game/GameClient/GameClientState/Buttons/EventButtonGUI.h b/Code/Game/GameClient/GameClientState/Buttons/EventButtonGUI.h index 3ae09043..c14d24f2 100644 --- a/Code/Game/GameClient/GameClientState/Buttons/EventButtonGUI.h +++ b/Code/Game/GameClient/GameClientState/Buttons/EventButtonGUI.h @@ -7,6 +7,7 @@ #include "EventHandler/EventButton.h" #include "DllInterfaces/GFXAPI.h" +#include "../WindowManager/WindowShell.h" namespace DanBias { @@ -37,26 +38,27 @@ namespace DanBias textColor(textColor), backColor(backColor), hoverColor(hoverColor), pressedColor(pressedColor) { CreateTexture(textureName); + this->resizedSize = size; if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize); } EventButtonGUI(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor, - EventFunc func, Oyster::Math::Float3 pos, - Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None) + EventFunc func, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None) : EventButton(func), pos(pos), size(size), texture(NULL), buttonText(buttonText), textColor(textColor), backColor(backColor), hoverColor(hoverColor), pressedColor(pressedColor) { CreateTexture(textureName); + this->resizedSize = size; if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize); } EventButtonGUI(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor, - EventFunc func, Owner owner, Oyster::Math::Float3 pos, - Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None) + EventFunc func, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None) : EventButton(func, owner), pos(pos), size(size), texture(NULL), buttonText(buttonText), textColor(textColor), backColor(backColor), hoverColor(hoverColor), pressedColor(pressedColor) { CreateTexture(textureName); + this->resizedSize = size; if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize); } EventButtonGUI(std::wstring textureName, std::wstring buttonText, @@ -66,6 +68,7 @@ namespace DanBias textColor(textColor), backColor(backColor), hoverColor(hoverColor), pressedColor(pressedColor) { CreateTexture(textureName); + this->resizedSize = size; if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize); } virtual ~EventButtonGUI() @@ -92,15 +95,15 @@ namespace DanBias if(EventButton::GetState() == ButtonState_None) { - Oyster::Graphics::API::RenderGuiElement(texture, pos, size, backColor); + Oyster::Graphics::API::RenderGuiElement(texture, pos, resizedSize, backColor); } else if(EventButton::GetState() == ButtonState_Hover) { - Oyster::Graphics::API::RenderGuiElement(texture, pos, size, hoverColor); + Oyster::Graphics::API::RenderGuiElement(texture, pos, resizedSize, hoverColor); } else { - Oyster::Graphics::API::RenderGuiElement(texture, pos, size, pressedColor); + Oyster::Graphics::API::RenderGuiElement(texture, pos, resizedSize, pressedColor); } } @@ -121,15 +124,18 @@ namespace DanBias GetClientRect(WindowShell::GetHWND(), &r); if(resize == ResizeAspectRatio_Height) - size.y *= (float)r.right/(float)r.bottom; + resizedSize.y = size.y * ((float)r.right/(float)r.bottom); else if(resize == ResizeAspectRatio_Width) - size.x *= (float)r.bottom/(float)r.right; + resizedSize.x = size.x * ((float)r.bottom/(float)r.right); } protected: Oyster::Math::Float3 pos; Oyster::Math::Float2 size; + //The new calculated resize, it's only used for the button not the text right now. + Oyster::Math::Float2 resizedSize; + Oyster::Graphics::API::Texture texture; std::wstring buttonText; From c2226fa9d13babf20022668269ae9537010c3957 Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Wed, 19 Feb 2014 15:47:02 +0100 Subject: [PATCH 03/16] Clamp fixed WTF!? I'm 100% positive that I already did this fix. WTF!? --- Code/Misc/Utilities/Utilities.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Code/Misc/Utilities/Utilities.h b/Code/Misc/Utilities/Utilities.h index c259a845..b97d62d7 100644 --- a/Code/Misc/Utilities/Utilities.h +++ b/Code/Misc/Utilities/Utilities.h @@ -337,7 +337,11 @@ namespace Utility template inline ValueType Clamp( const ValueType &value, const ValueType &min, const ValueType &max ) - { return value < min ? Max( value, max ) : min; } + { + if( value < min ) return min; + if( value > max ) return max; + return value; + } template inline ValueType Average( const ValueType &valueA, const ValueType &valueB ) From 908d52020a94fab89a90f5bc32c2fb90be1b079c Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Wed, 19 Feb 2014 15:47:43 +0100 Subject: [PATCH 04/16] Some fixes and traps --- .../GameClientState/Camera_FPSV2.cpp | 25 +++++++++++++------ .../GameClient/GameClientState/GameState.cpp | 6 +++++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp b/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp index f2f3c1ad..0cf4500d 100644 --- a/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp +++ b/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp @@ -4,6 +4,12 @@ using namespace ::Oyster::Math3D; using namespace ::Utility::Value; +inline Quaternion Transform( const Quaternion &transformer, const Quaternion &transformee ) +{ +// return transformer * transformee; + return transformee * transformer; +} + Camera_FPSV2::Camera_FPSV2() { // this->head is default set to identity uniformprojection at origo this->pitchUp = 0.0f; @@ -46,7 +52,7 @@ void Camera_FPSV2::SetRotation( const Quaternion &rotation ) } this->body.rotation = rotation; - this->head.SetRotation( rotation * Rotation(this->pitchUp, WorldAxisOf(rotation, Float3::standard_unit_x) ) ); + this->head.SetRotation( Transform(rotation, Rotation(this->pitchUp, WorldAxisOf(rotation, Float3::standard_unit_x))) ); this->pitchHaveChanged = false; } @@ -74,7 +80,7 @@ void Camera_FPSV2::UpdateOrientation() { if( this->pitchHaveChanged ) { - this->head.SetRotation( this->body.rotation * Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x) ) ); + this->head.SetRotation( Transform(this->body.rotation, Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x))) ); this->pitchHaveChanged = false; } @@ -87,7 +93,7 @@ void Camera_FPSV2::UpdateOrientation() void Camera_FPSV2::SnapUpToNormal( const Float3 &normal ) { this->body.rotation = Rotation( SnapAngularAxis(AngularAxis(this->body.rotation), WorldAxisOf(this->body.rotation, Float3::standard_unit_y), normal) ); - this->head.SetRotation( this->body.rotation * Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x) ) ); + this->head.SetRotation( Transform(this->body.rotation, Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x))) ); this->pitchHaveChanged = false; } @@ -130,6 +136,11 @@ void Camera_FPSV2::StrafeLeft( Float distance ) void Camera_FPSV2::PitchUp( Float radian ) { + if( radian >= 0.5f ) + { // HACK: debugging + const char *breakPoint = ""; + } + this->pitchUp = Clamp( this->pitchUp + radian, -0.48f * pi, 0.48f * pi ); this->pitchHaveChanged = true; } @@ -164,7 +175,7 @@ Float4x4 & Camera_FPSV2::GetViewMatrix( Float4x4 &targetMem ) const { if( this->pitchHaveChanged ) { - this->head.SetRotation( this->body.rotation * Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x) ) ); + this->head.SetRotation( Transform(this->body.rotation, Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x))) ); this->pitchHaveChanged = false; } @@ -180,7 +191,7 @@ Float4x4 & Camera_FPSV2::GetViewsProjMatrix( Float4x4 &targetMem ) const { if( this->pitchHaveChanged ) { - this->head.SetRotation( this->body.rotation * Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x) ) ); + this->head.SetRotation( Transform(this->body.rotation, Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x))) ); this->pitchHaveChanged = false; } @@ -191,7 +202,7 @@ Float3 Camera_FPSV2::GetNormalOf( const Float3 &axis ) const { if( this->pitchHaveChanged ) { - this->head.SetRotation( this->body.rotation * Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x) ) ); + this->head.SetRotation( Transform(this->body.rotation, Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x))) ); this->pitchHaveChanged = false; } @@ -212,7 +223,7 @@ Float3 Camera_FPSV2::GetLook() const { if( this->pitchHaveChanged ) { - this->head.SetRotation( this->body.rotation * Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x) ) ); + this->head.SetRotation( Transform(this->body.rotation, Rotation(this->pitchUp, WorldAxisOf(this->body.rotation, Float3::standard_unit_x))) ); this->pitchHaveChanged = false; } diff --git a/Code/Game/GameClient/GameClientState/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp index ed04c009..4192779f 100644 --- a/Code/Game/GameClient/GameClientState/GameState.cpp +++ b/Code/Game/GameClient/GameClientState/GameState.cpp @@ -480,6 +480,12 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState // if is this player. Remember to change camera if( this->privData->myId == decoded.object_ID ) { + if( !Within(position.Dot(position), 2500.0f, 90000.0f) ) + { // HACK: bug trap + const char *breakPoint = "Something is wrong."; + //position = Float3( 0.0f, 160.0f, 0.0f ); + } + this->privData->camera.SetPosition( position ); this->privData->camera.SetRotation( rotation ); this->privData->player.setPos( position ); From a2979a2bf51fb7011e67a217380671e5834a715f Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Wed, 19 Feb 2014 15:53:28 +0100 Subject: [PATCH 05/16] GameClient - modified player Data and out commented physics --- Code/Game/GameLogic/Game_PlayerData.cpp | 8 +-- Code/Game/GameLogic/Player.cpp | 81 ++++++++++++++----------- 2 files changed, 48 insertions(+), 41 deletions(-) diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index a79b2a9f..d8e17b8a 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -26,15 +26,15 @@ Game::PlayerData::PlayerData(int playerID,int teamID) { Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(-50,180,0); - Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,2.0f,0.5f); - Oyster::Math::Float mass = 60; + Oyster::Math::Float height = 2.0f; + Oyster::Math::Float radius = 0.5f; + Oyster::Math::Float mass = 40; Oyster::Math::Float restitutionCoeff = 0.5f; Oyster::Math::Float frictionCoeff_Static = 0.4f; Oyster::Math::Float frictionCoeff_Dynamic = 0.3f; - //sbDesc.quaternion = Oyster::Math::Float3(0, Oyster::Math::pi, 0); //create rigid body - Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCollisionBox(size, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, 0.5f, 0.8f, 0.6f ); + Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCharacter(height, radius, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, restitutionCoeff, frictionCoeff_Static, frictionCoeff_Dynamic ); rigidBody->SetAngularFactor(0.0f); //create player with this rigid body this->player = new Player(rigidBody, Player::PlayerCollision, ObjectSpecialType_Player,playerID,teamID); diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index b067d036..93ba37be 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -27,6 +27,8 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision) key_backward = 0; key_strafeRight = 0; key_strafeLeft = 0; + key_jump = 0; + invincibleCooldown = 0; this->previousPosition = Oyster::Math::Float3(0,0,0); @@ -50,6 +52,8 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustom key_backward = 0; key_strafeRight = 0; key_strafeLeft = 0; + key_jump = 0; + invincibleCooldown = 0; this->previousPosition = Oyster::Math::Float3(0,0,0); this->moveDir = Oyster::Math::Float3(0,0,0); @@ -71,12 +75,12 @@ Player::~Player(void) void Player::BeginFrame() { //weapon->Update(0.002f); - Object::BeginFrame(); + //Object::BeginFrame(); Oyster::Math::Float maxSpeed = 30; - Oyster::Math::Float4x4 xform; - xform = this->rigidBody->GetState().GetOrientation(); + /*Oyster::Math::Float4x4 xform; + xform = this->rigidBody->GetState().GetOrientation();*/ /* Handle turning */ /*if (left) @@ -86,11 +90,11 @@ void Player::BeginFrame() //xform.setRotation (btQuaternion (btVector3(0.0, 1.0, 0.0), m_turnAngle)); - Oyster::Math::Float3 linearVelocity = this->rigidBody->GetLinearVelocity(); + Oyster::Math::Float3 linearVelocity(0,0,0); // = this->rigidBody->GetLinearVelocity(); Oyster::Math::Float speed = this->rigidBody->GetLinearVelocity().GetLength(); - Oyster::Math::Float3 forwardDir = xform.v[2]; - Oyster::Math::Float3 rightDir = xform.v[0]; + Oyster::Math::Float3 forwardDir(0,0,1); //= xform.v[2]; + Oyster::Math::Float3 rightDir(1,0,0); // = xform.v[0]; forwardDir.Normalize(); rightDir.Normalize(); Oyster::Math::Float3 walkDirection = Oyster::Math::Float3(0.0, 0.0, 0.0); @@ -98,50 +102,50 @@ void Player::BeginFrame() if (key_forward > 0.001) { - key_forward -= gameInstance->GetFrameTime(); - walkDirection += forwardDir; - walkDirection.Normalize(); + key_forward -= gameInstance->GetFrameTime(); + walkDirection += forwardDir; + walkDirection.Normalize(); } if (key_backward > 0.001) { - key_backward -= gameInstance->GetFrameTime(); - walkDirection -= forwardDir; - walkDirection.Normalize(); + key_backward -= gameInstance->GetFrameTime(); + walkDirection -= forwardDir; + walkDirection.Normalize(); } if (key_strafeRight > 0.001) { - key_strafeRight -= gameInstance->GetFrameTime(); - walkDirection -= rightDir; - walkDirection.Normalize(); + key_strafeRight -= gameInstance->GetFrameTime(); + walkDirection -= rightDir; + walkDirection.Normalize(); } if (key_strafeLeft > 0.001) { - key_strafeLeft -= gameInstance->GetFrameTime(); - walkDirection += rightDir; - walkDirection.Normalize(); - maxSpeed = 40; + key_strafeLeft -= gameInstance->GetFrameTime(); + walkDirection += rightDir; + walkDirection.Normalize(); + maxSpeed = 40; } - if (key_forward <= 0.001 && key_backward <= 0.001 && key_strafeRight <= 0.001 && key_strafeLeft <= 0.001 && key_jump <= 0.001 && this->rigidBody->GetLambda() < 0.7f) + if (key_forward <= 0.001 && key_backward <= 0.001 && key_strafeRight <= 0.001 && key_strafeLeft <= 0.001 && key_jump <= 0.001 ) //&& this->rigidBody->GetLambda() < 0.7f) { /* Dampen when on the ground and not being moved by the player */ linearVelocity *= 0.2f; - this->rigidBody->SetLinearVelocity (linearVelocity); + //this->rigidBody->SetLinearVelocity (linearVelocity); } - else - { - if (speed < maxSpeed && this->rigidBody->GetLambda() < 1.0f) - { - Oyster::Math::Float3 velocity = linearVelocity + walkDirection * walkSpeed; - this->rigidBody->SetLinearVelocity(velocity); - } - else if(speed < maxSpeed) - { - Oyster::Math::Float3 velocity = linearVelocity + (walkDirection * walkSpeed)*0.2f; - this->rigidBody->SetLinearVelocity(velocity); - } - } + //else + //{ + // if (speed < maxSpeed && this->rigidBody->GetLambda() < 1.0f) + // { + // Oyster::Math::Float3 velocity = linearVelocity + walkDirection * walkSpeed; + // this->rigidBody->SetLinearVelocity(velocity); + // } + // else if(speed < maxSpeed) + // { + // Oyster::Math::Float3 velocity = linearVelocity + (walkDirection * walkSpeed)*0.2f; + // this->rigidBody->SetLinearVelocity(velocity); + // } + //} if (key_jump > 0.001) { @@ -153,8 +157,11 @@ void Player::BeginFrame() this->playerState = PLAYER_STATE::PLAYER_STATE_JUMPING; } } + Oyster::Math::Float3 pos = this->rigidBody->GetState().centerPos; + if(pos.x < -300000) + int i =0; - this->weapon->Update(0.01f); + //this->weapon->Update(0.01f); } void Player::EndFrame() @@ -162,9 +169,9 @@ void Player::EndFrame() // snap to axis Oyster::Math::Float4 rotation; - this->rigidBody->SetUp(this->rigidBody->GetState().centerPos.GetNormalized()); + //this->rigidBody->SetUp(this->rigidBody->GetState().centerPos.GetNormalized()); - Object::EndFrame(); + //Object::EndFrame(); } void Player::Move(const PLAYER_MOVEMENT &movement) From 4697b85e3b3bc368297f142000524b6494ab9802 Mon Sep 17 00:00:00 2001 From: lanariel Date: Wed, 19 Feb 2014 15:57:52 +0100 Subject: [PATCH 06/16] Small fixes --- Code/Game/GameClient/DanBiasGame_Impl.cpp | 4 ++-- .../GameClient/GameClientState/GameState.cpp | 4 ++++ Code/Game/GameLogic/Game.cpp | 2 +- Code/Game/GameLogic/Level.cpp | 4 ++-- Code/Misc/Utilities/Resource/OResource.h | 6 +++--- Code/Network/NetworkAPI/NetworkServer.cpp | 2 +- Code/OysterGraphics/DllInterfaces/GFXAPI.cpp | 4 ++-- .../OysterGraphics/FileLoader/ShaderLoader.cpp | 2 +- Code/OysterGraphics/Render/GuiRenderer.cpp | 2 +- Code/OysterGraphics/Render/Resources.cpp | 3 --- .../Shader/Passes/Post/PostPass.hlsl | 18 +++++++++++++++--- 11 files changed, 32 insertions(+), 19 deletions(-) diff --git a/Code/Game/GameClient/DanBiasGame_Impl.cpp b/Code/Game/GameClient/DanBiasGame_Impl.cpp index 15918adf..b0107a17 100644 --- a/Code/Game/GameClient/DanBiasGame_Impl.cpp +++ b/Code/Game/GameClient/DanBiasGame_Impl.cpp @@ -106,7 +106,7 @@ namespace DanBias Graphics::API::Update( dt ); data.capFrame += dt; - if(data.capFrame > 0.03) + if(data.capFrame > 0.03f) { switch( Update(data.capFrame) ) { @@ -117,7 +117,7 @@ namespace DanBias } if(Render() != S_OK) return DanBiasClientReturn_Error; - data.capFrame -= 0.03; + data.capFrame -= 0.03f; } if(data.networkClient.IsConnected()) diff --git a/Code/Game/GameClient/GameClientState/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp index 7ab0aeac..3dd547ba 100644 --- a/Code/Game/GameClient/GameClientState/GameState.cpp +++ b/Code/Game/GameClient/GameClientState/GameState.cpp @@ -89,6 +89,8 @@ bool GameState::Init( SharedStateContent &shared ) Float aspectRatio = gfxOp.Resolution.x / gfxOp.Resolution.y; this->privData->camera.SetPerspectiveProjection( Utility::Value::Radian(90.0f), aspectRatio, 0.1f, 1000.0f ); Graphics::API::SetProjection( this->privData->camera.GetProjectionMatrix() ); + gfxOp.AmbientValue = 2.0f; + Graphics::API::SetOptions(gfxOp); //tell server ready this->privData->nwClient->Send( Protocol_General_Status(Protocol_General_Status::States_ready) ); @@ -105,6 +107,7 @@ bool GameState::Init( SharedStateContent &shared ) light->second->Render(); } + return true; } @@ -237,6 +240,7 @@ bool GameState::Render() bool GameState::Release() { + Graphics::API::Option o = Graphics::API::GetOption(); if( privData ) { auto staticObject = this->privData->staticObjects->begin(); diff --git a/Code/Game/GameLogic/Game.cpp b/Code/Game/GameLogic/Game.cpp index aee57be8..f1053482 100644 --- a/Code/Game/GameLogic/Game.cpp +++ b/Code/Game/GameLogic/Game.cpp @@ -77,7 +77,7 @@ Game::PlayerData* Game::CreatePlayer() found = true; freeID = i; - for(int j = 0; j < players.Size(); j++) + for(int j = 0; j < (int)players.Size(); j++) { if(this->players[j] && this->players[j]->GetID() == freeID) diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index b3a8b101..0a207d2b 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -209,7 +209,7 @@ bool Level::InitiateLevel(std::wstring levelPath) //Convert from wstring to string typedef std::codecvt_utf8 convert_typeX; - std::wstring_convert converterX; + std::wstring_convert converterX; std::string convertedLevelPath = converterX.to_bytes(levelPath); objects = ll.LoadLevel(convertedLevelPath); @@ -220,7 +220,7 @@ bool Level::InitiateLevel(std::wstring levelPath) API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0)); API::Instance().SetGravity(200); - int objCount = objects.size(); + int objCount = (int)objects.size(); for (int i = 0; i < objCount; i++) { diff --git a/Code/Misc/Utilities/Resource/OResource.h b/Code/Misc/Utilities/Resource/OResource.h index 83ed474f..6af78781 100644 --- a/Code/Misc/Utilities/Resource/OResource.h +++ b/Code/Misc/Utilities/Resource/OResource.h @@ -40,15 +40,15 @@ namespace Oyster } inline unsigned int GetResourceSize() const { - return this->resourceSize; + return (unsigned int)this->resourceSize; } inline unsigned int GetResourceElementSize() const { - return this->resourceElementSize; + return (unsigned int)this->resourceElementSize; } inline unsigned int GetResourceID() const { - return this->resourceID; + return (unsigned int)this->resourceID; } inline void SetResourceID(int id) { diff --git a/Code/Network/NetworkAPI/NetworkServer.cpp b/Code/Network/NetworkAPI/NetworkServer.cpp index 3e840dd8..028ca58e 100644 --- a/Code/Network/NetworkAPI/NetworkServer.cpp +++ b/Code/Network/NetworkAPI/NetworkServer.cpp @@ -58,7 +58,7 @@ void Broadcast() addr.append(buff); dest.sin_addr.s_addr = inet_addr( addr.c_str() ); // send the pkt - int ret = sendto( s, pkt, pkt_length, 0, (sockaddr *)&dest, sizeof(dest) ); + int ret = sendto( s, pkt, pkt_length, 0, (sockaddr *)&dest, (int)sizeof(dest) ); } } diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp index ccb811c1..89849f03 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -205,9 +205,9 @@ namespace Oyster void API::StartRenderWireFrame() { - Core::deviceContext->OMSetRenderTargets(Render::Resources::Gather::Pass.RTV.size(),&Render::Resources::Gather::Pass.RTV[0],NULL); + Core::deviceContext->OMSetRenderTargets((UINT)Render::Resources::Gather::Pass.RTV.size(),&Render::Resources::Gather::Pass.RTV[0],NULL); Core::deviceContext->RSSetState(wire); - Core::deviceContext->OMSetRenderTargets(Render::Resources::Gather::Pass.RTV.size(),&Render::Resources::Gather::Pass.RTV[0],NULL); + Core::deviceContext->OMSetRenderTargets((UINT)Render::Resources::Gather::Pass.RTV.size(),&Render::Resources::Gather::Pass.RTV[0],NULL); } void API::RenderDebugCube(Math::Matrix world) diff --git a/Code/OysterGraphics/FileLoader/ShaderLoader.cpp b/Code/OysterGraphics/FileLoader/ShaderLoader.cpp index 033be403..a5f207f3 100644 --- a/Code/OysterGraphics/FileLoader/ShaderLoader.cpp +++ b/Code/OysterGraphics/FileLoader/ShaderLoader.cpp @@ -146,7 +146,7 @@ namespace Oyster return NULL; } #endif - Core::UsedMem += data.size; + Core::UsedMem += (int)data.size; return Core::PipelineManager::CreateShader(data, Core::PipelineManager::ShaderType(type)); } } diff --git a/Code/OysterGraphics/Render/GuiRenderer.cpp b/Code/OysterGraphics/Render/GuiRenderer.cpp index 02e202e4..b71be6d7 100644 --- a/Code/OysterGraphics/Render/GuiRenderer.cpp +++ b/Code/OysterGraphics/Render/GuiRenderer.cpp @@ -103,7 +103,7 @@ namespace Oyster Resources::Gui::Text::Vertex.Unmap(); - Core::deviceContext->Draw(text.length(), 0); + Core::deviceContext->Draw((UINT)text.length(), 0); } } } diff --git a/Code/OysterGraphics/Render/Resources.cpp b/Code/OysterGraphics/Render/Resources.cpp index 124b1bf1..1de7d4ce 100644 --- a/Code/OysterGraphics/Render/Resources.cpp +++ b/Code/OysterGraphics/Render/Resources.cpp @@ -349,9 +349,6 @@ namespace Oyster Core::device->CreateDepthStencilView(depthstencil,NULL,&Gui::depth); depthstencil->Release(); - - D3D11_DEPTH_STENCIL_DESC dDesc; - return Core::Init::Success; } diff --git a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl index 4135bdcb..258d0f25 100644 --- a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl +++ b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl @@ -14,18 +14,30 @@ cbuffer Size : register(b0) [numthreads(16, 16, 1)] void main( uint3 DTid : SV_DispatchThreadID ) { + float SSAO = 0; + for(int x = 0; x < 4; ++x) + { + for(int y = 0; y < 4; ++y) + { + SSAO += Ambient[DTid.xy/2 + uint2(-2+x,-2+y)].w; + } + } + + SSAO = SSAO / 16; + float4 Light = Diffuse[DTid.xy] + saturate(Specular[DTid.xy]); - float3 Amb = Ambient[DTid.xy/2].xyz /* * Ambient[DTid.xy/2].w */; + float3 Amb = Ambient[DTid.xy/2].xyz * SSAO; + float3 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)].xyz; float4 GUI; uint2 index = DTid.xy/2 + uint2((uint)Output.Length.x/(uint)2,0); - float3 PostLight = Amb.xyz * AmbFactor; + float3 PostLight = Amb * AmbFactor; PostLight = PostLight + Light.xyz + Glow; GUI = float4(Ambient[index]); PostLight = PostLight * (1 - GUI.w); Output[DTid.xy] = float4((GUI.xyz * GUI.w) + PostLight, 1); //Output[DTid.xy] = float4(Ambient[DTid.xy/2 + uint2(Output.Length*0.5f)].xyz,1); - //Output[DTid.xy] = Ambient[DTid.xy]; + //Output[DTid.xy] = SSAO * float4(1,1,1,1); } \ No newline at end of file From b656ce448d839991d9e2e832cb216f5e67aad551 Mon Sep 17 00:00:00 2001 From: dean11 Date: Wed, 19 Feb 2014 16:22:14 +0100 Subject: [PATCH 07/16] GameServer - Debuging GameLogic --- .../Implementation/GameSession_Gameplay.cpp | 8 +++++++ Code/Network/NetworkAPI/NetworkClient.cpp | 21 ++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp index 8cbb542d..64625cd0 100644 --- a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp @@ -61,6 +61,8 @@ using namespace DanBias; switch (e.args.type) { case NetworkClient::ClientEventArgs::EventType_Disconnect: + this->gClients[temp]->GetClient()->Disconnect(); + this->gClients[temp] = 0; break; case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToRecieve: break; @@ -128,6 +130,12 @@ using namespace DanBias; int id = movedObject->GetID(); //Protocol_ObjectPosition p(movedObject->GetPosition(), id); Protocol_ObjectPositionRotation p(movedObject->GetPosition(), movedObject->GetRotation(), id); + + Oyster::Math::Float3 temp = movedObject->GetPosition(); + + if(temp.x < -300) + id = 0; + GameSession::gameSession->Send(p.GetProtocol()); //} } diff --git a/Code/Network/NetworkAPI/NetworkClient.cpp b/Code/Network/NetworkAPI/NetworkClient.cpp index fc561845..e904bb20 100644 --- a/Code/Network/NetworkAPI/NetworkClient.cpp +++ b/Code/Network/NetworkAPI/NetworkClient.cpp @@ -105,11 +105,22 @@ struct NetworkClient::PrivateData : public IThreadObject if(errorCode != 0 && errorCode != WSAEWOULDBLOCK) { - CEA parg; - parg.type = CEA::EventType_ProtocolFailedToSend; - parg.data.protocol = p; - NetEvent e = { this->parent, parg }; - this->recieveQueue.Push(e); + if( errorCode == WSAECONNABORTED || errorCode == WSAENOTCONN) + { + CEA parg; + parg.type = CEA::EventType_Disconnect; + parg.data.protocol = p; + NetEvent e = { this->parent, parg }; + this->recieveQueue.Push(e); + } + else + { + CEA parg; + parg.type = CEA::EventType_ProtocolFailedToSend; + parg.data.protocol = p; + NetEvent e = { this->parent, parg }; + this->recieveQueue.Push(e); + } } } From b5639bec90cd3731deb38e654ce583aac6f7ade8 Mon Sep 17 00:00:00 2001 From: Dennis Andersen Date: Wed, 19 Feb 2014 22:07:53 +0100 Subject: [PATCH 08/16] GameServer - Some white spaces etc.. --- .../GameClientState/LanMenuState.cpp | 4 +- Code/Game/GameLogic/Game.cpp | 20 +- Code/Game/GameLogic/Game_PlayerData.cpp | 36 ++-- .../StandAloneLauncher/Form1.Designer.cs | 192 +++++++++--------- 4 files changed, 128 insertions(+), 124 deletions(-) diff --git a/Code/Game/GameClient/GameClientState/LanMenuState.cpp b/Code/Game/GameClient/GameClientState/LanMenuState.cpp index 11ca95da..8c096617 100644 --- a/Code/Game/GameClient/GameClientState/LanMenuState.cpp +++ b/Code/Game/GameClient/GameClientState/LanMenuState.cpp @@ -60,8 +60,8 @@ bool LanMenuState::Init( SharedStateContent &shared ) // create guiElements this->privData->connectIP = new TextField( L"color_white.png", Float4(1.0f), Float4(0.0f), this, Float3(0.5f, 0.3f, 0.5f), Float2(0.8f, 0.09f), ResizeAspectRatio_None ); this->privData->connectIP->ReserveLines( 1 ); - //this->privData->connectIP->AppendText( L"127.0.0.1" ); - this->privData->connectIP->AppendText( L"194.47.150.206" ); // HACK: connecting to Dennis's server + this->privData->connectIP->AppendText( L"127.0.0.1" ); + //this->privData->connectIP->AppendText( L"194.47.150.206" ); // HACK: connecting to Dennis's server this->privData->connectIP->SetFontHeight( 0.08f ); this->privData->connectIP->SetLineSpacing( 0.005f ); this->privData->connectIP->SetTopAligned(); diff --git a/Code/Game/GameLogic/Game.cpp b/Code/Game/GameLogic/Game.cpp index ba294349..fc5567f0 100644 --- a/Code/Game/GameLogic/Game.cpp +++ b/Code/Game/GameLogic/Game.cpp @@ -68,12 +68,13 @@ void Game::GetAllPlayerPositions() const Game::PlayerData* Game::CreatePlayer() { // Find a free space in array or insert at end - int i = InsertObject(this->players, (PlayerData*)0); + + PlayerData *temp = new PlayerData(); + temp->player->GetRigidBody()->SetSubscription(Game::PhysicsOnMove); - this->players[i] = new PlayerData(); - this->players[i]->player->GetRigidBody()->SetSubscription(Game::PhysicsOnMove); + int i = InsertObject(this->players, temp); - return this->players[i]; + return temp; } Game::LevelData* Game::CreateLevel(const wchar_t mapName[255]) @@ -95,22 +96,15 @@ bool Game::NewFrame() { for (unsigned int i = 0; i < this->players.Size(); i++) { - if(this->players[i]->player) this->players[i]->player->BeginFrame(); + if(this->players[i] && this->players[i]->player) this->players[i]->player->BeginFrame(); } API::Instance().UpdateWorld(); for (unsigned int i = 0; i < this->players.Size(); i++) { - if(this->players[i]->player) this->players[i]->player->EndFrame(); - gameInstance.onMoveFnc(this->players[i]); + if(this->players[i] && this->players[i]->player) this->players[i]->player->EndFrame(); } - for (unsigned int i = 0; i < this->level->level->dynamicObjects.Size(); i++) - { - gameInstance.onMoveFnc(this->level->level->dynamicObjects[i]); - } - - return true; } diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index e7a77bbd..f34cf95f 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -5,29 +5,39 @@ using namespace GameLogic; Game::PlayerData::PlayerData() { - //set some stats that are appropriate to a player - - Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(50,130,0); - - Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,2.0f,0.5f); - Oyster::Math::Float mass = 60; + Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(-50,250,0); + Oyster::Math::Float height = 2.0f; + Oyster::Math::Float radius = 0.5f; + Oyster::Math::Float mass = 40; Oyster::Math::Float restitutionCoeff = 0.5f; Oyster::Math::Float frictionCoeff_Static = 0.4f; Oyster::Math::Float frictionCoeff_Dynamic = 0.3f; - //sbDesc.quaternion = Oyster::Math::Float3(0, Oyster::Math::pi, 0); //create rigid body - Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCollisionBox(size, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, 0.5f, 0.8f, 0.6f ); + Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCharacter( height, radius, Oyster::Math::Float4(0, 0, 0, 1), + centerPosition, mass, restitutionCoeff, + frictionCoeff_Static, frictionCoeff_Dynamic ); rigidBody->SetAngularFactor(0.0f); //create player with this rigid body - this->player = new Player(rigidBody, Player::PlayerCollision, ObjectSpecialType_Player,0,0); - - //this->player->GetRigidBody()->SetCustomTag(this); - player->EndFrame(); + this->player = new Player(rigidBody, Player::PlayerCollision, ObjectSpecialType_Player, 0, 0); } Game::PlayerData::PlayerData(int playerID,int teamID) { - this->player = new Player(); + Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(-50,250,0); + Oyster::Math::Float height = 2.0f; + Oyster::Math::Float radius = 0.5f; + Oyster::Math::Float mass = 40; + Oyster::Math::Float restitutionCoeff = 0.5f; + Oyster::Math::Float frictionCoeff_Static = 0.4f; + Oyster::Math::Float frictionCoeff_Dynamic = 0.3f; + + //create rigid body + Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCharacter( height, radius, Oyster::Math::Float4(0, 0, 0, 1), + centerPosition, mass, restitutionCoeff, + frictionCoeff_Static, frictionCoeff_Dynamic ); + rigidBody->SetAngularFactor(0.0f); + //create player with this rigid body + this->player = new Player(rigidBody, Player::PlayerCollision, ObjectSpecialType_Player,playerID,teamID); } Game::PlayerData::~PlayerData() { diff --git a/Code/Game/LanServer/StandAloneLauncher/Form1.Designer.cs b/Code/Game/LanServer/StandAloneLauncher/Form1.Designer.cs index 73ef627c..4f9c169d 100644 --- a/Code/Game/LanServer/StandAloneLauncher/Form1.Designer.cs +++ b/Code/Game/LanServer/StandAloneLauncher/Form1.Designer.cs @@ -37,11 +37,13 @@ this.panel_serverOptions = new System.Windows.Forms.Panel(); this.panel_commands = new System.Windows.Forms.Panel(); this.timeLimit = new System.Windows.Forms.NumericUpDown(); + this.mapName = new System.Windows.Forms.ComboBox(); this.gameModes = new System.Windows.Forms.ComboBox(); this.label3 = new System.Windows.Forms.Label(); this.forceStart = new System.Windows.Forms.CheckBox(); this.label2 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); this.labelClientsConnected = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.nrOfClients = new System.Windows.Forms.NumericUpDown(); @@ -51,22 +53,20 @@ this.splitter1 = new System.Windows.Forms.Splitter(); this.clientInfoBox = new System.Windows.Forms.ListBox(); this.panel_CommanArea = new System.Windows.Forms.Panel(); - this.label5 = new System.Windows.Forms.Label(); - this.mapName = new System.Windows.Forms.ComboBox(); this.panelServerCommands = new System.Windows.Forms.Panel(); - this.buttonExecuteSend = new System.Windows.Forms.Button(); + this.dataProtocolFields = new System.Windows.Forms.TableLayoutPanel(); this.panel2 = new System.Windows.Forms.Panel(); + this.button2 = new System.Windows.Forms.Button(); + this.textBox1 = new System.Windows.Forms.TextBox(); this.comboBox1 = new System.Windows.Forms.ComboBox(); this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); - this.textBox1 = new System.Windows.Forms.TextBox(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.label6 = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label(); this.label8 = new System.Windows.Forms.Label(); - this.dataProtocolFields = new System.Windows.Forms.TableLayoutPanel(); - this.buttonAddNewDataField = new System.Windows.Forms.Button(); - this.button2 = new System.Windows.Forms.Button(); this.buttonsAtBottom = new System.Windows.Forms.TableLayoutPanel(); + this.buttonAddNewDataField = new System.Windows.Forms.Button(); + this.buttonExecuteSend = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.listenPort)).BeginInit(); this.panel_serverOptions.SuspendLayout(); this.panel_commands.SuspendLayout(); @@ -75,10 +75,10 @@ this.panel_clientArea.SuspendLayout(); this.panel_CommanArea.SuspendLayout(); this.panelServerCommands.SuspendLayout(); + this.dataProtocolFields.SuspendLayout(); this.panel2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); this.tableLayoutPanel1.SuspendLayout(); - this.dataProtocolFields.SuspendLayout(); this.buttonsAtBottom.SuspendLayout(); this.SuspendLayout(); // @@ -204,6 +204,18 @@ 0, 0}); // + // mapName + // + this.mapName.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.mapName.FormattingEnabled = true; + this.mapName.IntegralHeight = false; + this.mapName.Items.AddRange(new object[] { + "Set default"}); + this.mapName.Location = new System.Drawing.Point(72, 7); + this.mapName.Name = "mapName"; + this.mapName.Size = new System.Drawing.Size(163, 21); + this.mapName.TabIndex = 10; + // // gameModes // this.gameModes.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -255,6 +267,15 @@ this.label4.TabIndex = 8; this.label4.Text = "Map name"; // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(23, 147); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(81, 13); + this.label5.TabIndex = 8; + this.label5.Text = "Lobby clients: 0"; + // // labelClientsConnected // this.labelClientsConnected.AutoSize = true; @@ -360,27 +381,6 @@ this.panel_CommanArea.Size = new System.Drawing.Size(241, 616); this.panel_CommanArea.TabIndex = 9; // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(23, 147); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(81, 13); - this.label5.TabIndex = 8; - this.label5.Text = "Lobby clients: 0"; - // - // mapName - // - this.mapName.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.mapName.FormattingEnabled = true; - this.mapName.IntegralHeight = false; - this.mapName.Items.AddRange(new object[] { - "Set default"}); - this.mapName.Location = new System.Drawing.Point(72, 7); - this.mapName.Name = "mapName"; - this.mapName.Size = new System.Drawing.Size(163, 21); - this.mapName.TabIndex = 10; - // // panelServerCommands // this.panelServerCommands.Controls.Add(this.dataProtocolFields); @@ -391,17 +391,24 @@ this.panelServerCommands.TabIndex = 8; this.panelServerCommands.Visible = false; // - // buttonExecuteSend + // dataProtocolFields // - this.buttonExecuteSend.Dock = System.Windows.Forms.DockStyle.Fill; - this.buttonExecuteSend.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.buttonExecuteSend.Location = new System.Drawing.Point(116, 0); - this.buttonExecuteSend.Margin = new System.Windows.Forms.Padding(0); - this.buttonExecuteSend.Name = "buttonExecuteSend"; - this.buttonExecuteSend.Size = new System.Drawing.Size(117, 21); - this.buttonExecuteSend.TabIndex = 0; - this.buttonExecuteSend.Text = "Send"; - this.buttonExecuteSend.UseVisualStyleBackColor = true; + this.dataProtocolFields.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single; + this.dataProtocolFields.ColumnCount = 1; + this.dataProtocolFields.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 21F)); + this.dataProtocolFields.Controls.Add(this.panel2, 0, 1); + this.dataProtocolFields.Controls.Add(this.tableLayoutPanel1, 0, 0); + this.dataProtocolFields.Controls.Add(this.buttonsAtBottom, 0, 2); + this.dataProtocolFields.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataProtocolFields.Location = new System.Drawing.Point(0, 0); + this.dataProtocolFields.Margin = new System.Windows.Forms.Padding(0); + this.dataProtocolFields.Name = "dataProtocolFields"; + this.dataProtocolFields.RowCount = 3; + this.dataProtocolFields.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 27F)); + this.dataProtocolFields.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 27F)); + this.dataProtocolFields.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.dataProtocolFields.Size = new System.Drawing.Size(241, 85); + this.dataProtocolFields.TabIndex = 9; // // panel2 // @@ -415,6 +422,27 @@ this.panel2.Size = new System.Drawing.Size(233, 21); this.panel2.TabIndex = 0; // + // button2 + // + this.button2.Dock = System.Windows.Forms.DockStyle.Fill; + this.button2.FlatAppearance.BorderColor = System.Drawing.Color.Black; + this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.button2.Location = new System.Drawing.Point(184, 0); + this.button2.Margin = new System.Windows.Forms.Padding(0); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(49, 21); + this.button2.TabIndex = 0; + this.button2.Text = "remove"; + this.button2.UseVisualStyleBackColor = true; + // + // textBox1 + // + this.textBox1.Dock = System.Windows.Forms.DockStyle.Left; + this.textBox1.Location = new System.Drawing.Point(120, 0); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(64, 20); + this.textBox1.TabIndex = 12; + // // comboBox1 // this.comboBox1.Dock = System.Windows.Forms.DockStyle.Left; @@ -447,21 +475,13 @@ this.numericUpDown1.Size = new System.Drawing.Size(42, 20); this.numericUpDown1.TabIndex = 11; // - // textBox1 - // - this.textBox1.Dock = System.Windows.Forms.DockStyle.Left; - this.textBox1.Location = new System.Drawing.Point(120, 0); - this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(64, 20); - this.textBox1.TabIndex = 12; - // // tableLayoutPanel1 // this.tableLayoutPanel1.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single; this.tableLayoutPanel1.ColumnCount = 3; this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 35.29412F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 64.70588F)); - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 110F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 118F)); this.tableLayoutPanel1.Controls.Add(this.label6, 0, 0); this.tableLayoutPanel1.Controls.Add(this.label7, 1, 0); this.tableLayoutPanel1.Controls.Add(this.label8, 2, 0); @@ -486,7 +506,7 @@ // label7 // this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(46, 1); + this.label7.Location = new System.Drawing.Point(44, 1); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(31, 13); this.label7.TabIndex = 8; @@ -495,57 +515,12 @@ // label8 // this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(123, 1); + this.label8.Location = new System.Drawing.Point(116, 1); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(34, 13); this.label8.TabIndex = 8; this.label8.Text = "Value"; // - // dataProtocolFields - // - this.dataProtocolFields.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single; - this.dataProtocolFields.ColumnCount = 1; - this.dataProtocolFields.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 21F)); - this.dataProtocolFields.Controls.Add(this.panel2, 0, 1); - this.dataProtocolFields.Controls.Add(this.tableLayoutPanel1, 0, 0); - this.dataProtocolFields.Controls.Add(this.buttonsAtBottom, 0, 2); - this.dataProtocolFields.Dock = System.Windows.Forms.DockStyle.Fill; - this.dataProtocolFields.Location = new System.Drawing.Point(0, 0); - this.dataProtocolFields.Margin = new System.Windows.Forms.Padding(0); - this.dataProtocolFields.Name = "dataProtocolFields"; - this.dataProtocolFields.RowCount = 3; - this.dataProtocolFields.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 27F)); - this.dataProtocolFields.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 27F)); - this.dataProtocolFields.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.dataProtocolFields.Size = new System.Drawing.Size(241, 85); - this.dataProtocolFields.TabIndex = 9; - // - // buttonAddNewDataField - // - this.buttonAddNewDataField.Dock = System.Windows.Forms.DockStyle.Fill; - this.buttonAddNewDataField.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.buttonAddNewDataField.Location = new System.Drawing.Point(0, 0); - this.buttonAddNewDataField.Margin = new System.Windows.Forms.Padding(0); - this.buttonAddNewDataField.Name = "buttonAddNewDataField"; - this.buttonAddNewDataField.Size = new System.Drawing.Size(116, 21); - this.buttonAddNewDataField.TabIndex = 1; - this.buttonAddNewDataField.Text = "Add field"; - this.buttonAddNewDataField.UseVisualStyleBackColor = true; - this.buttonAddNewDataField.Click += new System.EventHandler(this.buttonAddNewDataField_Click); - // - // button2 - // - this.button2.Dock = System.Windows.Forms.DockStyle.Fill; - this.button2.FlatAppearance.BorderColor = System.Drawing.Color.Black; - this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.button2.Location = new System.Drawing.Point(184, 0); - this.button2.Margin = new System.Windows.Forms.Padding(0); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(49, 21); - this.button2.TabIndex = 0; - this.button2.Text = "remove"; - this.button2.UseVisualStyleBackColor = true; - // // buttonsAtBottom // this.buttonsAtBottom.ColumnCount = 2; @@ -561,6 +536,31 @@ this.buttonsAtBottom.Size = new System.Drawing.Size(233, 21); this.buttonsAtBottom.TabIndex = 10; // + // buttonAddNewDataField + // + this.buttonAddNewDataField.Dock = System.Windows.Forms.DockStyle.Fill; + this.buttonAddNewDataField.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.buttonAddNewDataField.Location = new System.Drawing.Point(0, 0); + this.buttonAddNewDataField.Margin = new System.Windows.Forms.Padding(0); + this.buttonAddNewDataField.Name = "buttonAddNewDataField"; + this.buttonAddNewDataField.Size = new System.Drawing.Size(116, 21); + this.buttonAddNewDataField.TabIndex = 1; + this.buttonAddNewDataField.Text = "Add field"; + this.buttonAddNewDataField.UseVisualStyleBackColor = true; + this.buttonAddNewDataField.Click += new System.EventHandler(this.buttonAddNewDataField_Click); + // + // buttonExecuteSend + // + this.buttonExecuteSend.Dock = System.Windows.Forms.DockStyle.Fill; + this.buttonExecuteSend.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.buttonExecuteSend.Location = new System.Drawing.Point(116, 0); + this.buttonExecuteSend.Margin = new System.Windows.Forms.Padding(0); + this.buttonExecuteSend.Name = "buttonExecuteSend"; + this.buttonExecuteSend.Size = new System.Drawing.Size(117, 21); + this.buttonExecuteSend.TabIndex = 0; + this.buttonExecuteSend.Text = "Send"; + this.buttonExecuteSend.UseVisualStyleBackColor = true; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -581,12 +581,12 @@ this.panel_clientArea.ResumeLayout(false); this.panel_CommanArea.ResumeLayout(false); this.panelServerCommands.ResumeLayout(false); + this.dataProtocolFields.ResumeLayout(false); this.panel2.ResumeLayout(false); this.panel2.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); this.tableLayoutPanel1.ResumeLayout(false); this.tableLayoutPanel1.PerformLayout(); - this.dataProtocolFields.ResumeLayout(false); this.buttonsAtBottom.ResumeLayout(false); this.ResumeLayout(false); From f872cfffd1a917ad3635a47857392ffcd026261b Mon Sep 17 00:00:00 2001 From: Dennis Andersen Date: Thu, 20 Feb 2014 08:33:07 +0100 Subject: [PATCH 09/16] Added debug project to game server and some other stuff --- Code/DanBias.sln | 37 ++++ Code/Game/GameLogic/Level.cpp | 8 +- Code/Game/GameLogic/Level.h | 2 +- Code/Game/GameServer/GameClient.h | 8 + .../GameServer/Implementation/DLLMain.cpp | 1 - .../GameServer/Implementation/GameClient.cpp | 19 ++ .../Implementation/GameSession_Gameplay.cpp | 9 +- .../GameServerDebugEnvironment.vcxproj | 183 ++++++++++++++++++ .../GameServerDebugEnvironment.vcxproj.user | 22 +++ .../GameServerDebugEnvironment/Source.cpp | 48 +++++ .../StandAloneLauncher/Form1.Designer.cs | 6 +- Code/Game/LevelLoader/LevelLoader.cpp | 2 + Code/Network/NetworkAPI/NetworkClient.cpp | 40 +++- Code/Network/NetworkAPI/NetworkClient.h | 13 ++ 14 files changed, 379 insertions(+), 19 deletions(-) create mode 100644 Code/Game/LanServer/GameServerDebugEnvironment/GameServerDebugEnvironment.vcxproj create mode 100644 Code/Game/LanServer/GameServerDebugEnvironment/GameServerDebugEnvironment.vcxproj.user create mode 100644 Code/Game/LanServer/GameServerDebugEnvironment/Source.cpp diff --git a/Code/DanBias.sln b/Code/DanBias.sln index e14d2c37..033e050e 100644 --- a/Code/DanBias.sln +++ b/Code/DanBias.sln @@ -47,6 +47,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Utilities", "Misc\Utilities EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LevelLoader", "Game\LevelLoader\LevelLoader.vcxproj", "{6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameServerDebugEnvironment", "Game\LanServer\GameServerDebugEnvironment\GameServerDebugEnvironment.vcxproj", "{67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -715,6 +717,40 @@ Global {6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.RelWithDebInfo|x64.ActiveCfg = Release|Win32 {6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.RelWithDebInfo|x86.ActiveCfg = Release|Win32 {6391E709-D9FA-4FEF-A3B9-4343DB5A0C63}.RelWithDebInfo|x86.Build.0 = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.Debug|Win32.ActiveCfg = Debug|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.Debug|Win32.Build.0 = Debug|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.Debug|x64.ActiveCfg = Debug|x64 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.Debug|x64.Build.0 = Debug|x64 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.Debug|x86.ActiveCfg = Debug|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.Debug|x86.Build.0 = Debug|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.MinSizeRel|Any CPU.ActiveCfg = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.MinSizeRel|Mixed Platforms.ActiveCfg = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.MinSizeRel|Mixed Platforms.Build.0 = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.MinSizeRel|Win32.ActiveCfg = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.MinSizeRel|Win32.Build.0 = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.MinSizeRel|x64.ActiveCfg = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.MinSizeRel|x86.ActiveCfg = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.MinSizeRel|x86.Build.0 = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.Release|Any CPU.ActiveCfg = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.Release|Mixed Platforms.Build.0 = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.Release|Win32.ActiveCfg = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.Release|Win32.Build.0 = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.Release|x64.ActiveCfg = Release|x64 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.Release|x64.Build.0 = Release|x64 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.Release|x86.ActiveCfg = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.Release|x86.Build.0 = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.RelWithDebInfo|Mixed Platforms.ActiveCfg = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.RelWithDebInfo|Mixed Platforms.Build.0 = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.RelWithDebInfo|Win32.ActiveCfg = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.RelWithDebInfo|Win32.Build.0 = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.RelWithDebInfo|x64.ActiveCfg = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.RelWithDebInfo|x86.ActiveCfg = Release|Win32 + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE}.RelWithDebInfo|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -737,5 +773,6 @@ Global {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE} = {1322B12B-5E37-448A-AAAF-F637460DCB23} {604A12A7-07BF-4482-BDF3-7101C811F121} = {C83A6FAD-E71F-4B1E-9D63-E93E61DDC012} {C8CBA520-5D7D-4D61-A8DA-6E05FD132BCB} = {C83A6FAD-E71F-4B1E-9D63-E93E61DDC012} + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE} = {C83A6FAD-E71F-4B1E-9D63-E93E61DDC012} EndGlobalSection EndGlobal diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index b3a8b101..4c79a0e9 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -4,6 +4,7 @@ #include "JumpPad.h" #include "ExplosiveCrate.h" #include "Portal.h" +#include //Conversion from wstring to string #include @@ -22,7 +23,7 @@ Level::~Level(void) delete this->levelObj; this->levelObj = NULL; } -Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody) +Object* Level::CreateGameObj(ObjectHeader* obj, ICustomBody* rigidBody) { Object* gameObj = NULL; @@ -55,6 +56,7 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody) { gameObj = new StaticObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID); } + break; case ObjectSpecialType_Stone: { gameObj = new DynamicObject(rigidBody, Object::DefaultOnCollision, (ObjectSpecialType)obj->specialTypeID, objID); @@ -261,7 +263,7 @@ bool Level::InitiateLevel(std::wstring levelPath) if(rigidBody_Static != NULL) { // create game object - Object* staticGameObj = createGameObj(staticObjData, rigidBody_Static); + Object* staticGameObj = CreateGameObj(staticObjData, rigidBody_Static); if(staticGameObj != NULL) { this->staticObjects.Push((StaticObject*)staticGameObj); @@ -295,7 +297,7 @@ bool Level::InitiateLevel(std::wstring levelPath) if(rigidBody_Dynamic != NULL) { // create game object - Object* dynamicGameObj = createGameObj(dynamicObjData, rigidBody_Dynamic); + Object* dynamicGameObj = CreateGameObj(dynamicObjData, rigidBody_Dynamic); if (dynamicGameObj != NULL) { this->dynamicObjects.Push((DynamicObject*)dynamicGameObj); diff --git a/Code/Game/GameLogic/Level.h b/Code/Game/GameLogic/Level.h index fb26280c..9dce227d 100644 --- a/Code/Game/GameLogic/Level.h +++ b/Code/Game/GameLogic/Level.h @@ -35,7 +35,7 @@ namespace GameLogic Oyster::Physics::ICustomBody* InitRigidBodyCube( const ObjectHeader* obj); Oyster::Physics::ICustomBody* InitRigidBodySphere( const ObjectHeader* obj); - Object* createGameObj(ObjectHeader* obj, Oyster::Physics::ICustomBody* rigidBody); + Object* CreateGameObj(ObjectHeader* obj, Oyster::Physics::ICustomBody* rigidBody); /******************************************************** * Creates a team in the level * @param teamSize: The size of the team you want to create diff --git a/Code/Game/GameServer/GameClient.h b/Code/Game/GameServer/GameClient.h index 6fcf6b05..497e6c2e 100644 --- a/Code/Game/GameServer/GameClient.h +++ b/Code/Game/GameServer/GameClient.h @@ -22,6 +22,7 @@ namespace DanBias { ClientState_CreatingGame, ClientState_Ready, + ClientState_Invalid, }; public: @@ -41,6 +42,7 @@ namespace DanBias inline GameLogic::IPlayerData* GetPlayer() const { return this->player; } Oyster::Network::NetClient GetClient() const { return this->client; } ClientState GetState() const { return this->state; } + int GetFailedProtocolCount() const { return this->failedPackagesCount; } void SetPlayer(GameLogic::IPlayerData* player); @@ -53,6 +55,10 @@ namespace DanBias GameLogic::IPlayerData* ReleasePlayer(); Oyster::Network::NetClient ReleaseClient(); + void Invalidate(); + int IncrementFailedProtocol(); + void ResetFailedProtocolCount(); + //NetworkSpecific void SetOwner(Oyster::Network::NetworkSession* owner); void UpdateClient(); @@ -62,7 +68,9 @@ namespace DanBias Oyster::Network::NetClient client; bool isReady; + bool isInvalid; float secondsSinceLastResponse; + int failedPackagesCount; std::wstring alias; std::wstring character; diff --git a/Code/Game/GameServer/Implementation/DLLMain.cpp b/Code/Game/GameServer/Implementation/DLLMain.cpp index 7adceac7..814a15f1 100644 --- a/Code/Game/GameServer/Implementation/DLLMain.cpp +++ b/Code/Game/GameServer/Implementation/DLLMain.cpp @@ -6,6 +6,5 @@ BOOL WINAPI DllMain( _In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpvReserved ) { - return TRUE; } \ No newline at end of file diff --git a/Code/Game/GameServer/Implementation/GameClient.cpp b/Code/Game/GameServer/Implementation/GameClient.cpp index 9c04007f..3293a383 100644 --- a/Code/Game/GameServer/Implementation/GameClient.cpp +++ b/Code/Game/GameServer/Implementation/GameClient.cpp @@ -14,6 +14,8 @@ using namespace GameLogic; GameClient::GameClient(Utility::DynamicMemory::SmartPointer nwClient) { + this->isInvalid = false; + this->failedPackagesCount = 0; this->client = nwClient; this->player = 0; isReady = false; @@ -23,6 +25,7 @@ GameClient::GameClient(Utility::DynamicMemory::SmartPointerclient = 0; this->player = 0; this->isReady = false; this->character = L"crate_colonists.dan"; @@ -55,6 +58,22 @@ void GameClient::SetState(ClientState state) this->state = state; } +void GameClient::Invalidate() +{ + this->isInvalid = true; + this->isReady = false; + this->state = ClientState_Invalid; + this->client->Disconnect(); +} +int GameClient::IncrementFailedProtocol() +{ + this->failedPackagesCount++; + return this->failedPackagesCount; +} +void GameClient::ResetFailedProtocolCount() +{ + this->failedPackagesCount = 0; +} void GameClient::SetOwner(Oyster::Network::NetworkSession* owner) { diff --git a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp index 64625cd0..53e24739 100644 --- a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp @@ -61,14 +61,15 @@ using namespace DanBias; switch (e.args.type) { case NetworkClient::ClientEventArgs::EventType_Disconnect: - this->gClients[temp]->GetClient()->Disconnect(); - this->gClients[temp] = 0; + //printf("\t(%i : %s) - EventType_Disconnect\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str()); + this->gClients[temp]->Invalidate(); break; case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToRecieve: break; case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend: - printf("\t(%i : %s) - EventType_ProtocolFailedToSend\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str()); - //this->Detach(e.sender); + //printf("\t(%i : %s) - EventType_ProtocolFailedToSend\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str()); + if(this->gClients[temp]->IncrementFailedProtocol() >= 5/*client->threshold*/) + this->gClients[temp]->Invalidate(); break; case NetworkClient::ClientEventArgs::EventType_ProtocolRecieved: //printf("\t(%i : %s) - EventType_ProtocolRecieved\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str()); diff --git a/Code/Game/LanServer/GameServerDebugEnvironment/GameServerDebugEnvironment.vcxproj b/Code/Game/LanServer/GameServerDebugEnvironment/GameServerDebugEnvironment.vcxproj new file mode 100644 index 00000000..5f715fad --- /dev/null +++ b/Code/Game/LanServer/GameServerDebugEnvironment/GameServerDebugEnvironment.vcxproj @@ -0,0 +1,183 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {67D0FB00-FF1F-4DE4-84BD-664AE93D25EE} + Win32Proj + GameServerDebugEnvironment + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)..\Bin\Executable\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName)_$(Configuration) + $(SolutionDir)Game\GameServer\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)Misc\WindowManager;$(IncludePath) + C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath) + + + true + $(SolutionDir)..\Bin\Executable\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName)_$(Configuration) + $(SolutionDir)Game\GameServer\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)Misc\WindowManager;$(IncludePath) + C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath) + + + false + $(SolutionDir)..\Bin\Executable\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName)_$(Configuration) + $(SolutionDir)Game\GameServer\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)Misc\WindowManager;$(IncludePath) + C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath) + + + false + $(SolutionDir)..\Bin\Executable\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName)_$(Configuration) + $(SolutionDir)Game\GameServer\;C:\Program Files %28x86%29\Visual Leak Detector\include;$(SolutionDir)Misc\WindowManager;$(IncludePath) + C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath) + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + GameServer_$(PlatformShortName)D.dll;%(DelayLoadDLLs) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + GameServer_$(PlatformShortName)D.dll;%(DelayLoadDLLs) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + GameServer_$(PlatformShortName).dll;%(DelayLoadDLLs) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + GameServer_$(PlatformShortName).dll;%(DelayLoadDLLs) + + + + + {35aea3c0-e0a7-4e1e-88cd-514aa5a442b1} + + + {143bd516-20a1-4890-a3e4-f8bfd02220e7} + + + + + + + + + \ No newline at end of file diff --git a/Code/Game/LanServer/GameServerDebugEnvironment/GameServerDebugEnvironment.vcxproj.user b/Code/Game/LanServer/GameServerDebugEnvironment/GameServerDebugEnvironment.vcxproj.user new file mode 100644 index 00000000..ea7197bf --- /dev/null +++ b/Code/Game/LanServer/GameServerDebugEnvironment/GameServerDebugEnvironment.vcxproj.user @@ -0,0 +1,22 @@ + + + + $(OutDir) + WindowsLocalDebugger + + + $(OutDir) + WindowsLocalDebugger + + + $(OutDir) + WindowsLocalDebugger + + + $(OutDir) + WindowsLocalDebugger + + + true + + \ No newline at end of file diff --git a/Code/Game/LanServer/GameServerDebugEnvironment/Source.cpp b/Code/Game/LanServer/GameServerDebugEnvironment/Source.cpp new file mode 100644 index 00000000..f2561a52 --- /dev/null +++ b/Code/Game/LanServer/GameServerDebugEnvironment/Source.cpp @@ -0,0 +1,48 @@ +///////////////////////////////////////////////// +// Launcher to launch Danbias server or client // +///////////////////////////////////////////////// +#define NOMINMAX +#include +#include + +#include +#include + +using namespace DanBias; + +int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdShow) +{ + if(SetDllDirectory(L"..\\DLL") == FALSE) + { + return cmdShow; + } + + WindowShell::CreateConsoleWindow(); + + GameServerAPI::ServerInitDesc desc; + desc.listenPort = 15151; + desc.serverName = L"bla"; + + if(GameServerAPI::ServerInitiate(desc) == DanBiasServerReturn_Sucess) + { + GameServerAPI::ServerStart(); + + GameServerAPI::GameSetGameMode(L"free-for-all"); + GameServerAPI::GameSetGameName(L"DebugServer"); + GameServerAPI::GameSetGameTime(15); + GameServerAPI::GameSetMapName(L"2ofAll.bias"); + GameServerAPI::GameSetMaxClients(10); + + if(GameServerAPI::GameStart(true)) + { + int Q = 0x51; + while ( GetAsyncKeyState(Q) == 0) + { + GameServerAPI::ServerUpdate(); + } + } + GameServerAPI::ServerStop(); + } + + return 0; +} \ No newline at end of file diff --git a/Code/Game/LanServer/StandAloneLauncher/Form1.Designer.cs b/Code/Game/LanServer/StandAloneLauncher/Form1.Designer.cs index 2fc06cef..b07868f7 100644 --- a/Code/Game/LanServer/StandAloneLauncher/Form1.Designer.cs +++ b/Code/Game/LanServer/StandAloneLauncher/Form1.Designer.cs @@ -482,7 +482,7 @@ this.tableLayoutPanel1.ColumnCount = 3; this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 35.29412F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 64.70588F)); - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 112F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 114F)); this.tableLayoutPanel1.Controls.Add(this.label6, 0, 0); this.tableLayoutPanel1.Controls.Add(this.label7, 1, 0); this.tableLayoutPanel1.Controls.Add(this.label8, 2, 0); @@ -507,7 +507,7 @@ // label7 // this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(44, 1); + this.label7.Location = new System.Drawing.Point(45, 1); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(31, 13); this.label7.TabIndex = 8; @@ -516,7 +516,7 @@ // label8 // this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(122, 1); + this.label8.Location = new System.Drawing.Point(120, 1); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(34, 13); this.label8.TabIndex = 8; diff --git a/Code/Game/LevelLoader/LevelLoader.cpp b/Code/Game/LevelLoader/LevelLoader.cpp index 82583696..588c4a34 100644 --- a/Code/Game/LevelLoader/LevelLoader.cpp +++ b/Code/Game/LevelLoader/LevelLoader.cpp @@ -4,6 +4,7 @@ #include "LevelLoader.h" #include "LevelParser.h" +#include using namespace GameLogic; using namespace GameLogic::LevelFileLoader; @@ -29,6 +30,7 @@ LevelLoader::LevelLoader(std::string folderPath) LevelLoader::~LevelLoader() { + Oyster::Resource::OysterResource::Clean(); } std::vector> LevelLoader::LoadLevel(std::string fileName) diff --git a/Code/Network/NetworkAPI/NetworkClient.cpp b/Code/Network/NetworkAPI/NetworkClient.cpp index e904bb20..a4bc4581 100644 --- a/Code/Network/NetworkAPI/NetworkClient.cpp +++ b/Code/Network/NetworkAPI/NetworkClient.cpp @@ -48,6 +48,7 @@ struct NetworkClient::PrivateData : public IThreadObject Connection connection; Translator translator; OysterThread thread; + bool outputEvent; OysterByte recieveBuffer; @@ -63,6 +64,7 @@ struct NetworkClient::PrivateData : public IThreadObject : ID(currID++) , parent(0) , owner(0) + , outputEvent(1) { InitWinSock(); this->thread.Create(this, false); @@ -97,9 +99,6 @@ struct NetworkClient::PrivateData : public IThreadObject OysterByte temp; CustomNetProtocol p = this->sendQueue.Pop(); - if(p[0].value.netShort == 304) - int i = 0; - this->translator.Pack(temp, p); errorCode = this->connection.Send(temp); @@ -112,6 +111,11 @@ struct NetworkClient::PrivateData : public IThreadObject parg.data.protocol = p; NetEvent e = { this->parent, parg }; this->recieveQueue.Push(e); + + if(this->outputEvent) + { + printf("\t(ID: %i | IP: %s | Protocol: %i) - EventType_Disconnect && EventType_ProtocolFailedToSend \n", this->ID, this->connection.GetIpAddress().c_str(), p[0].value.netShort); + } } else { @@ -120,8 +124,18 @@ struct NetworkClient::PrivateData : public IThreadObject parg.data.protocol = p; NetEvent e = { this->parent, parg }; this->recieveQueue.Push(e); + + if(this->outputEvent) + { + printf("\t(ID: %i | IP: %s | Protocol: %i) - EventType_ProtocolFailedToSend\n", this->ID, this->connection.GetIpAddress().c_str(), p[0].value.netShort); + } } } + + if(this->outputEvent) + { + printf("\t(ID: %i | IP: %s | Protocol: %i) Message sent!\n", this->ID, this->connection.GetIpAddress().c_str(), p[0].value.netShort); + } } return errorCode; @@ -236,6 +250,18 @@ struct NetworkClient::PrivateData : public IThreadObject e.args.type = parg.type; this->recieveQueue.Push(e); + + if(this->outputEvent) + { + printf("\t(ID: %i | IP: %s | Protocol: %i) Message recieved!\n", this->ID, this->connection.GetIpAddress().c_str(), protocol[0].value.netShort); + } + } + else + { + if(this->outputEvent) + { + printf("\t(ID: %i | IP: %s) Failed to unpack CustomNetProtocol!\n", this->ID, this->connection.GetIpAddress().c_str()); + } } } }; @@ -277,7 +303,6 @@ void NetworkClient::Update() NetEvent temp = this->privateData->recieveQueue.Pop(); this->DataRecieved(temp); - } } @@ -412,10 +437,11 @@ void NetworkClient::DataRecieved(NetEvent e) } } -//void NetworkClient::NetworkCallback(Oyster::Network::CustomNetProtocol& p) -//{} - std::string NetworkClient::GetIpAddress() { return this->privateData->connection.GetIpAddress(); } +void NetworkClient::OutputEventData(bool output) +{ + this->privateData->outputEvent; +} \ No newline at end of file diff --git a/Code/Network/NetworkAPI/NetworkClient.h b/Code/Network/NetworkAPI/NetworkClient.h index a7f3b0bb..dddef221 100644 --- a/Code/Network/NetworkAPI/NetworkClient.h +++ b/Code/Network/NetworkAPI/NetworkClient.h @@ -138,8 +138,21 @@ namespace Oyster */ virtual void DataRecieved(NetEvent e); + /** + * + */ std::string GetIpAddress(); + /** Dumps all activity to std::io + * + */ + void OutputEventData(bool output); + + /** Dumps all activity to std::io + * + */ + void SetOutputEventDataStream(FILE out); + private: NetworkClient(const NetworkClient& obj); NetworkClient& operator =(const NetworkClient& obj); From 74145447743c425350f25f75d2681aef0d305336 Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Thu, 20 Feb 2014 08:43:54 +0100 Subject: [PATCH 10/16] GameClient exclude RB rendering from release --- .../GameClient/GameClientState/GameState.cpp | 84 ++++++++++--------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/Code/Game/GameClient/GameClientState/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp index 7d04edda..92ab341d 100644 --- a/Code/Game/GameClient/GameClientState/GameState.cpp +++ b/Code/Game/GameClient/GameClientState/GameState.cpp @@ -189,47 +189,49 @@ bool GameState::Render() light->second->Render(); }*/ - // RB DEBUG render wire frame - //if(this->privData->renderWhireframe) - //{ - // Oyster::Graphics::API::StartRenderWireFrame(); - // - // Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(Float3( 0,132, 20)); - // Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(Float3( 0.5f, 0.5f, 0.5f)); - // Oyster::Math3D::Float4x4 world = translation * scale; - // Oyster::Graphics::API::RenderDebugCube( world ); - // Oyster::Graphics::API::RenderDebugCube(this->privData->player.getRBWorld()); - // - // staticObject = this->privData->staticObjects->begin(); - // for( ; staticObject != this->privData->staticObjects->end(); ++staticObject ) - // { - // if( staticObject->second->getBRtype() == RB_Type_Cube) - // { - // Oyster::Graphics::API::RenderDebugCube( staticObject->second->getRBWorld()); - // } - // if( staticObject->second->getBRtype() == RB_Type_Sphere) - // { - // Oyster::Graphics::API::RenderDebugSphere( staticObject->second->getRBWorld()); - // } - // } - // - // dynamicObject = this->privData->dynamicObjects->begin(); - // for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject ) - // { - // if( dynamicObject->second ) - // { - // if( dynamicObject->second->getBRtype() == RB_Type_Cube) - // { - // Oyster::Graphics::API::RenderDebugCube( dynamicObject->second->getRBWorld()); - // } - // if( dynamicObject->second->getBRtype() == RB_Type_Sphere) - // { - // Oyster::Graphics::API::RenderDebugSphere( dynamicObject->second->getRBWorld()); - // } - // } - // } - //} - // !RB DEBUG +#ifdef _DEBUG + //RB DEBUG render wire frame + if(this->privData->renderWhireframe) + { + Oyster::Graphics::API::StartRenderWireFrame(); + + Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(Float3( 0,132, 20)); + Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(Float3( 0.5f, 0.5f, 0.5f)); + Oyster::Math3D::Float4x4 world = translation * scale; + Oyster::Graphics::API::RenderDebugCube( world ); + Oyster::Graphics::API::RenderDebugCube(this->privData->player.getRBWorld()); + + staticObject = this->privData->staticObjects->begin(); + for( ; staticObject != this->privData->staticObjects->end(); ++staticObject ) + { + if( staticObject->second->getBRtype() == RB_Type_Cube) + { + Oyster::Graphics::API::RenderDebugCube( staticObject->second->getRBWorld()); + } + if( staticObject->second->getBRtype() == RB_Type_Sphere) + { + Oyster::Graphics::API::RenderDebugSphere( staticObject->second->getRBWorld()); + } + } + + dynamicObject = this->privData->dynamicObjects->begin(); + for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject ) + { + if( dynamicObject->second ) + { + if( dynamicObject->second->getBRtype() == RB_Type_Cube) + { + Oyster::Graphics::API::RenderDebugCube( dynamicObject->second->getRBWorld()); + } + if( dynamicObject->second->getBRtype() == RB_Type_Sphere) + { + Oyster::Graphics::API::RenderDebugSphere( dynamicObject->second->getRBWorld()); + } + } + } + } + //!RB DEBUG +#endif Oyster::Graphics::API::EndFrame(); return true; From 745a3802dcc215a50543c9bcfc37f15aaea0cbfc Mon Sep 17 00:00:00 2001 From: lanariel Date: Thu, 20 Feb 2014 09:00:02 +0100 Subject: [PATCH 11/16] touched up SSAO and fixed wireframe rendering in release --- .../GameClient/GameClientState/GameState.cpp | 82 +++++++++---------- .../GameClientState/NetLoadState.cpp | 8 +- Code/OysterGraphics/DllInterfaces/GFXAPI.cpp | 20 +++++ .../Shader/Passes/Light/SSAO.hlsli | 4 +- 4 files changed, 67 insertions(+), 47 deletions(-) diff --git a/Code/Game/GameClient/GameClientState/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp index 61e1d9fc..763563ff 100644 --- a/Code/Game/GameClient/GameClientState/GameState.cpp +++ b/Code/Game/GameClient/GameClientState/GameState.cpp @@ -89,7 +89,7 @@ bool GameState::Init( SharedStateContent &shared ) Float aspectRatio = gfxOp.Resolution.x / gfxOp.Resolution.y; this->privData->camera.SetPerspectiveProjection( Utility::Value::Radian(90.0f), aspectRatio, 0.1f, 1000.0f ); Graphics::API::SetProjection( this->privData->camera.GetProjectionMatrix() ); - gfxOp.AmbientValue = 2.0f; + gfxOp.AmbientValue = 1.0f; Graphics::API::SetOptions(gfxOp); //tell server ready @@ -193,45 +193,45 @@ bool GameState::Render() }*/ // RB DEBUG render wire frame - //if(this->privData->renderWhireframe) - //{ - // Oyster::Graphics::API::StartRenderWireFrame(); - // - // Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(Float3( 0,132, 20)); - // Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(Float3( 0.5f, 0.5f, 0.5f)); - // Oyster::Math3D::Float4x4 world = translation * scale; - // Oyster::Graphics::API::RenderDebugCube( world ); - // Oyster::Graphics::API::RenderDebugCube(this->privData->player.getRBWorld()); - // - // staticObject = this->privData->staticObjects->begin(); - // for( ; staticObject != this->privData->staticObjects->end(); ++staticObject ) - // { - // if( staticObject->second->getBRtype() == RB_Type_Cube) - // { - // Oyster::Graphics::API::RenderDebugCube( staticObject->second->getRBWorld()); - // } - // if( staticObject->second->getBRtype() == RB_Type_Sphere) - // { - // Oyster::Graphics::API::RenderDebugSphere( staticObject->second->getRBWorld()); - // } - // } - // - // dynamicObject = this->privData->dynamicObjects->begin(); - // for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject ) - // { - // if( dynamicObject->second ) - // { - // if( dynamicObject->second->getBRtype() == RB_Type_Cube) - // { - // Oyster::Graphics::API::RenderDebugCube( dynamicObject->second->getRBWorld()); - // } - // if( dynamicObject->second->getBRtype() == RB_Type_Sphere) - // { - // Oyster::Graphics::API::RenderDebugSphere( dynamicObject->second->getRBWorld()); - // } - // } - // } - //} + if(this->privData->renderWhireframe) + { + Oyster::Graphics::API::StartRenderWireFrame(); + + Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(Float3( 0,132, 20)); + Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(Float3( 0.5f, 0.5f, 0.5f)); + Oyster::Math3D::Float4x4 world = translation * scale; + Oyster::Graphics::API::RenderDebugCube( world ); + Oyster::Graphics::API::RenderDebugCube(this->privData->player.getRBWorld()); + + staticObject = this->privData->staticObjects->begin(); + for( ; staticObject != this->privData->staticObjects->end(); ++staticObject ) + { + if( staticObject->second->getBRtype() == RB_Type_Cube) + { + Oyster::Graphics::API::RenderDebugCube( staticObject->second->getRBWorld()); + } + if( staticObject->second->getBRtype() == RB_Type_Sphere) + { + Oyster::Graphics::API::RenderDebugSphere( staticObject->second->getRBWorld()); + } + } + + dynamicObject = this->privData->dynamicObjects->begin(); + for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject ) + { + if( dynamicObject->second ) + { + if( dynamicObject->second->getBRtype() == RB_Type_Cube) + { + Oyster::Graphics::API::RenderDebugCube( dynamicObject->second->getRBWorld()); + } + if( dynamicObject->second->getBRtype() == RB_Type_Sphere) + { + Oyster::Graphics::API::RenderDebugSphere( dynamicObject->second->getRBWorld()); + } + } + } + } // !RB DEBUG Oyster::Graphics::API::EndFrame(); @@ -487,7 +487,7 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState if( !Within(position.Dot(position), 2500.0f, 90000.0f) ) { // HACK: bug trap const char *breakPoint = "Something is wrong."; - //position = Float3( 0.0f, 160.0f, 0.0f ); + position = Float3( 0.0f, 160.0f, 0.0f ); } this->privData->camera.SetPosition( position ); diff --git a/Code/Game/GameClient/GameClientState/NetLoadState.cpp b/Code/Game/GameClient/GameClientState/NetLoadState.cpp index b2475cc6..e3e453ad 100644 --- a/Code/Game/GameClient/GameClientState/NetLoadState.cpp +++ b/Code/Game/GameClient/GameClientState/NetLoadState.cpp @@ -154,7 +154,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) { RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position; RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation - RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size; + RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size*2; RBData.type = RB_Type_Cube; staticObject->InitRB( RBData ); } @@ -163,7 +163,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) { RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position; RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation - RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius; + RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius*2; RBData.type = RB_Type_Sphere; staticObject->InitRB( RBData ); } @@ -198,7 +198,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) { RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position; RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation - RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size; + RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size*2; RBData.type = RB_Type_Cube; dynamicObject->InitRB( RBData ); } @@ -207,7 +207,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) { RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position; RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation - RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius; + RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius*2; RBData.type = RB_Type_Sphere; dynamicObject->InitRB( RBData ); } diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp index 89849f03..36cbfd54 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -221,6 +221,26 @@ namespace Oyster sphere->WorldMatrix = world; Render::DefaultRenderer::RenderScene(sphere,1,View,Projection); } +#else + API::State API::ReloadShaders() + { + + } + + void API::StartRenderWireFrame() + { + + } + + void API::RenderDebugCube(Math::Matrix world) + { + + } + + void API::RenderDebugSphere(Math::Matrix world) + { + + } #endif API::Option API::GetOption() diff --git a/Code/OysterGraphics/Shader/Passes/Light/SSAO.hlsli b/Code/OysterGraphics/Shader/Passes/Light/SSAO.hlsli index bf71b92b..f2258905 100644 --- a/Code/OysterGraphics/Shader/Passes/Light/SSAO.hlsli +++ b/Code/OysterGraphics/Shader/Passes/Light/SSAO.hlsli @@ -1,7 +1,7 @@ #include "Defines.hlsli" #include "PosManipulation.hlsli" -static float Radius = 100; +static float Radius = 10; float GetSSAO(float3 pos, float2 uv, int2 texCoord2, uint2 rndID) { @@ -41,7 +41,7 @@ float GetSSAO(float3 pos, float2 uv, int2 texCoord2, uint2 rndID) float sampleDepth = ViewPos.z; //compare to depth from sample - float rangeCheck = (abs(pos.z - sampleDepth) < Radius) ? 1.0f : 0.0f; + float rangeCheck = (abs(pos.z - sampleDepth) > Radius) ? 1.0f : 0.0f; occlusion += (sampleDepth <= sampled.z ? 1.0f : 0.0f) * rangeCheck; } occlusion /= (float)(SSAOKernel.Length.x); From 3527d3acb0059ab850d7015172abe73068095b34 Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Thu, 20 Feb 2014 09:07:02 +0100 Subject: [PATCH 12/16] Network - Fixed memory leak in NetworkServer. --- Code/Network/NetworkAPI/NetworkServer.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Code/Network/NetworkAPI/NetworkServer.cpp b/Code/Network/NetworkAPI/NetworkServer.cpp index 028ca58e..7d1cbdc5 100644 --- a/Code/Network/NetworkAPI/NetworkServer.cpp +++ b/Code/Network/NetworkAPI/NetworkServer.cpp @@ -83,7 +83,13 @@ public: , broadcastTime(1.0f, 0.0f) { } ~PrivateData() - { } + { + if(listener) + { + delete listener; + listener = NULL; + } + } bool DoWork(); From d93d900d401d19fa9825bc7c3b56c926c06daa77 Mon Sep 17 00:00:00 2001 From: dean11 Date: Thu, 20 Feb 2014 09:14:42 +0100 Subject: [PATCH 13/16] GameServer - Misc --- Code/Game/GameLogic/CollisionManager.cpp | 4 +++- Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp | 4 +--- Code/Game/LanServer/GameServerDebugEnvironment/Source.cpp | 2 ++ Code/Network/NetworkAPI/NetworkClient.cpp | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index 4c21fc8a..cde9b401 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -22,10 +22,12 @@ using namespace GameLogic; //Physics::ICustomBody::SubscriptMessage void Player::PlayerCollision(Oyster::Physics::ICustomBody *rigidBodyPlayer, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss) { - Player *player = ((Player*)(rigidBodyPlayer->GetCustomTag())); Object *realObj = (Object*)obj->GetCustomTag(); //needs to be changed? + if(!realObj) return; + if(!player) return; + switch (realObj->GetObjectType()) { case ObjectSpecialType::ObjectSpecialType_Generic: diff --git a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp index 53e24739..e2a2961d 100644 --- a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp @@ -61,18 +61,16 @@ using namespace DanBias; switch (e.args.type) { case NetworkClient::ClientEventArgs::EventType_Disconnect: - //printf("\t(%i : %s) - EventType_Disconnect\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str()); + printf("\t(%i : %s) - EventType_Disconnect\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str()); this->gClients[temp]->Invalidate(); break; case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToRecieve: break; case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend: - //printf("\t(%i : %s) - EventType_ProtocolFailedToSend\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str()); if(this->gClients[temp]->IncrementFailedProtocol() >= 5/*client->threshold*/) this->gClients[temp]->Invalidate(); break; case NetworkClient::ClientEventArgs::EventType_ProtocolRecieved: - //printf("\t(%i : %s) - EventType_ProtocolRecieved\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str()); this->ParseProtocol(e.args.data.protocol, cl); break; } diff --git a/Code/Game/LanServer/GameServerDebugEnvironment/Source.cpp b/Code/Game/LanServer/GameServerDebugEnvironment/Source.cpp index f2561a52..62332541 100644 --- a/Code/Game/LanServer/GameServerDebugEnvironment/Source.cpp +++ b/Code/Game/LanServer/GameServerDebugEnvironment/Source.cpp @@ -10,6 +10,8 @@ using namespace DanBias; + + int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdShow) { if(SetDllDirectory(L"..\\DLL") == FALSE) diff --git a/Code/Network/NetworkAPI/NetworkClient.cpp b/Code/Network/NetworkAPI/NetworkClient.cpp index a4bc4581..3463ed8a 100644 --- a/Code/Network/NetworkAPI/NetworkClient.cpp +++ b/Code/Network/NetworkAPI/NetworkClient.cpp @@ -64,7 +64,7 @@ struct NetworkClient::PrivateData : public IThreadObject : ID(currID++) , parent(0) , owner(0) - , outputEvent(1) + , outputEvent(0) { InitWinSock(); this->thread.Create(this, false); From d80dec600b4c9326c8065585fee27cdc164b189d Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Thu, 20 Feb 2014 09:20:26 +0100 Subject: [PATCH 14/16] Memory leak dealt with + removed obsolete debug trap --- Code/Game/GameClient/GameClient.vcxproj.user | 2 +- Code/Game/GameClient/GameClientState/C_Object.cpp | 4 +++- Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp | 5 ----- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Code/Game/GameClient/GameClient.vcxproj.user b/Code/Game/GameClient/GameClient.vcxproj.user index 2e28d6f7..4b847ee6 100644 --- a/Code/Game/GameClient/GameClient.vcxproj.user +++ b/Code/Game/GameClient/GameClient.vcxproj.user @@ -1,7 +1,7 @@  - true + false $(OutDir) diff --git a/Code/Game/GameClient/GameClientState/C_Object.cpp b/Code/Game/GameClient/GameClientState/C_Object.cpp index ccea9a86..50664a92 100644 --- a/Code/Game/GameClient/GameClientState/C_Object.cpp +++ b/Code/Game/GameClient/GameClientState/C_Object.cpp @@ -16,8 +16,10 @@ C_Object::C_Object() } C_Object::~C_Object() { - + if( this->model ) + this->Release(); } + bool C_Object::Init(ModelInitData modelInit) { position = modelInit.position; diff --git a/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp b/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp index 0cf4500d..14b16838 100644 --- a/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp +++ b/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp @@ -136,11 +136,6 @@ void Camera_FPSV2::StrafeLeft( Float distance ) void Camera_FPSV2::PitchUp( Float radian ) { - if( radian >= 0.5f ) - { // HACK: debugging - const char *breakPoint = ""; - } - this->pitchUp = Clamp( this->pitchUp + radian, -0.48f * pi, 0.48f * pi ); this->pitchHaveChanged = true; } From 7b877077144933cfe8d23ed4b261dd70433c73b0 Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Thu, 20 Feb 2014 09:21:38 +0100 Subject: [PATCH 15/16] GmaeClient fix RBsphere radius --- .../GameClientState/NetLoadState.cpp | 8 +-- Code/Game/GameLogic/Level.cpp | 4 +- Code/Game/GameLogic/Player.cpp | 72 +++++++++---------- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/Code/Game/GameClient/GameClientState/NetLoadState.cpp b/Code/Game/GameClient/GameClientState/NetLoadState.cpp index 8eb65fa8..de4f57d5 100644 --- a/Code/Game/GameClient/GameClientState/NetLoadState.cpp +++ b/Code/Game/GameClient/GameClientState/NetLoadState.cpp @@ -152,7 +152,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) RBInitData RBData; if(oh->boundingVolume.geoType == CollisionGeometryType_Box) { - RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position; + RBData.position = ((Float3)oh->position + (Float3)oh->boundingVolume.box.position) * (Float3)oh->scale; RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size * 2; RBData.type = RB_Type_Cube; @@ -161,7 +161,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) if(oh->boundingVolume.geoType == CollisionGeometryType_Sphere) { - RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position; + RBData.position = ((Float3)oh->position + (Float3)oh->boundingVolume.box.position) * (Float3)oh->scale; RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius * 2; RBData.type = RB_Type_Sphere; @@ -196,7 +196,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) RBInitData RBData; if(oh->boundingVolume.geoType == CollisionGeometryType_Box) { - RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position; + RBData.position = ((Float3)oh->position + (Float3)oh->boundingVolume.box.position) * (Float3)oh->scale; RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size * 2; RBData.type = RB_Type_Cube; @@ -205,7 +205,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) if(oh->boundingVolume.geoType == CollisionGeometryType_Sphere) { - RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position; + RBData.position = ((Float3)oh->position + (Float3)oh->boundingVolume.box.position) * (Float3)oh->scale; RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius * 2; RBData.type = RB_Type_Sphere; diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 82cd4364..9febbe47 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -196,8 +196,8 @@ ICustomBody* Level::InitRigidBodySphere( const ObjectHeader* obj) rigidBodyMass = obj->scale[0] * obj->scale[1] * obj->scale[2] * obj->boundingVolume.sphere.mass; //Radius scaled - //rigidBodyRadius = (staticObjData->scale[0] + staticObjData->scale[1] + staticObjData->scale[2] / 3) * staticObjData->boundingVolume.sphere.radius; - rigidBodyRadius = (obj->scale[0] * obj->scale[1] * obj->scale[2]) * obj->boundingVolume.sphere.radius; + rigidBodyRadius = (obj->scale[0]) * obj->boundingVolume.sphere.radius; + //rigidBodyRadius = (obj->scale[0] * obj->scale[1] * obj->scale[2]) * obj->boundingVolume.sphere.radius; //create the rigid body rigidBody = API::Instance().AddCollisionSphere( rigidBodyRadius , rigidWorldRotation , rigidWorldPos , rigidBodyMass, obj->boundingVolume.sphere.restitutionCoeff , obj->boundingVolume.sphere.frictionCoeffStatic , obj->boundingVolume.sphere.frictionCoeffDynamic); diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 93ba37be..77953d43 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -79,22 +79,22 @@ void Player::BeginFrame() Oyster::Math::Float maxSpeed = 30; - /*Oyster::Math::Float4x4 xform; - xform = this->rigidBody->GetState().GetOrientation();*/ + Oyster::Math::Float4x4 xform; + xform = this->rigidBody->GetState().GetOrientation(); /* Handle turning */ /*if (left) m_turnAngle -= dt * m_turnVelocity; if (right) - m_turnAngle += dt * m_turnVelocity;*/ + m_turnAngle += dt * m_turnVelocity; - //xform.setRotation (btQuaternion (btVector3(0.0, 1.0, 0.0), m_turnAngle)); + xform.setRotation (btQuaternion (btVector3(0.0, 1.0, 0.0), m_turnAngle));*/ - Oyster::Math::Float3 linearVelocity(0,0,0); // = this->rigidBody->GetLinearVelocity(); + Oyster::Math::Float3 linearVelocity = this->rigidBody->GetLinearVelocity(); Oyster::Math::Float speed = this->rigidBody->GetLinearVelocity().GetLength(); - Oyster::Math::Float3 forwardDir(0,0,1); //= xform.v[2]; - Oyster::Math::Float3 rightDir(1,0,0); // = xform.v[0]; + Oyster::Math::Float3 forwardDir = xform.v[2]; + Oyster::Math::Float3 rightDir = xform.v[0]; forwardDir.Normalize(); rightDir.Normalize(); Oyster::Math::Float3 walkDirection = Oyster::Math::Float3(0.0, 0.0, 0.0); @@ -102,28 +102,28 @@ void Player::BeginFrame() if (key_forward > 0.001) { - key_forward -= gameInstance->GetFrameTime(); - walkDirection += forwardDir; - walkDirection.Normalize(); + key_forward -= gameInstance->GetFrameTime(); + walkDirection += forwardDir; + walkDirection.Normalize(); } if (key_backward > 0.001) { - key_backward -= gameInstance->GetFrameTime(); - walkDirection -= forwardDir; - walkDirection.Normalize(); + key_backward -= gameInstance->GetFrameTime(); + walkDirection -= forwardDir; + walkDirection.Normalize(); } if (key_strafeRight > 0.001) { - key_strafeRight -= gameInstance->GetFrameTime(); - walkDirection -= rightDir; - walkDirection.Normalize(); + key_strafeRight -= gameInstance->GetFrameTime(); + walkDirection -= rightDir; + walkDirection.Normalize(); } if (key_strafeLeft > 0.001) { - key_strafeLeft -= gameInstance->GetFrameTime(); - walkDirection += rightDir; - walkDirection.Normalize(); - maxSpeed = 40; + key_strafeLeft -= gameInstance->GetFrameTime(); + walkDirection += rightDir; + walkDirection.Normalize(); + maxSpeed = 40; } @@ -131,21 +131,21 @@ void Player::BeginFrame() { /* Dampen when on the ground and not being moved by the player */ linearVelocity *= 0.2f; - //this->rigidBody->SetLinearVelocity (linearVelocity); + this->rigidBody->SetLinearVelocity (linearVelocity); } - //else - //{ - // if (speed < maxSpeed && this->rigidBody->GetLambda() < 1.0f) - // { - // Oyster::Math::Float3 velocity = linearVelocity + walkDirection * walkSpeed; - // this->rigidBody->SetLinearVelocity(velocity); - // } - // else if(speed < maxSpeed) - // { - // Oyster::Math::Float3 velocity = linearVelocity + (walkDirection * walkSpeed)*0.2f; - // this->rigidBody->SetLinearVelocity(velocity); - // } - //} + else + { + if (speed < maxSpeed && this->rigidBody->GetLambda() < 1.0f) + { + Oyster::Math::Float3 velocity = linearVelocity + walkDirection * walkSpeed; + this->rigidBody->SetLinearVelocity(velocity); + } + else if(speed < maxSpeed) + { + Oyster::Math::Float3 velocity = linearVelocity + (walkDirection * walkSpeed)*0.2f; + this->rigidBody->SetLinearVelocity(velocity); + } + } if (key_jump > 0.001) { @@ -158,7 +158,7 @@ void Player::BeginFrame() } } Oyster::Math::Float3 pos = this->rigidBody->GetState().centerPos; - if(pos.x < -300000) + if(pos == Oyster::Math::Float3(0,0,0)) int i =0; //this->weapon->Update(0.01f); @@ -169,7 +169,7 @@ void Player::EndFrame() // snap to axis Oyster::Math::Float4 rotation; - //this->rigidBody->SetUp(this->rigidBody->GetState().centerPos.GetNormalized()); + this->rigidBody->SetUp(this->rigidBody->GetState().centerPos.GetNormalized()); //Object::EndFrame(); } From 641442854eec41157c7c6a14c844685402d3ff54 Mon Sep 17 00:00:00 2001 From: dean11 Date: Thu, 20 Feb 2014 09:23:33 +0100 Subject: [PATCH 16/16] GameServer - Added debug traps --- Code/Game/GameLogic/CollisionManager.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index cde9b401..7b2b7ce1 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -25,8 +25,10 @@ using namespace GameLogic; Player *player = ((Player*)(rigidBodyPlayer->GetCustomTag())); Object *realObj = (Object*)obj->GetCustomTag(); //needs to be changed? - if(!realObj) return; - if(!player) return; + if(!realObj) + return; + if(!player) + return; switch (realObj->GetObjectType()) {