Merge branch 'GameServer' of https://github.com/dean11/Danbias into GameServer

This commit is contained in:
Dennis Andersen 2014-02-19 22:44:46 +01:00
commit 7ab3223280
8 changed files with 101 additions and 70 deletions

View File

@ -7,9 +7,6 @@
#include "EventButtonGUI.h" #include "EventButtonGUI.h"
//Only for testing because we don't have any other input
#include "../WindowManager/WindowShell.h"
namespace DanBias namespace DanBias
{ {
namespace Client namespace Client
@ -18,24 +15,25 @@ namespace DanBias
class ButtonEllipse : public EventButtonGUI<Owner> class ButtonEllipse : public EventButtonGUI<Owner>
{ {
public: public:
ButtonEllipse() ButtonEllipse(std::wstring textureName, std::wstring buttonText,
: EventButtonGUI(), radius(0) 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, ButtonEllipse(std::wstring textureName, std::wstring buttonText,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
: EventButtonGUI(textureName, buttonText, textColor, owner, pos, size, resize) 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, ButtonEllipse(std::wstring textureName, std::wstring buttonText,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
: EventButtonGUI(textureName, buttonText, textColor, func, pos, size, resize) 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, ButtonEllipse(std::wstring textureName, std::wstring buttonText,
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height) Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
: EventButtonGUI(textureName, buttonText, textColor, func, owner, pos, size, resize) 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)
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)
{} {}
virtual ~ButtonEllipse() virtual ~ButtonEllipse()
{} {}
@ -43,7 +41,6 @@ namespace DanBias
//Circle vs point collision //Circle vs point collision
bool Collision(Oyster::Event::MouseInput& input) bool Collision(Oyster::Event::MouseInput& input)
{ {
//Should come from the InputClass
float xMouse = input.x, yMouse = input.y; float xMouse = input.x, yMouse = input.y;
double normx = (xMouse - pos.x) / size.x; double normx = (xMouse - pos.x) / size.x;

View File

@ -6,9 +6,6 @@
#define DANBIAS_CLIENT_BUTTON_RECTANGLE_H #define DANBIAS_CLIENT_BUTTON_RECTANGLE_H
#include "EventButtonGUI.h" #include "EventButtonGUI.h"
#include <iostream>
//Only for testing because we don't have any other input
#include "../WindowManager/WindowShell.h"
namespace DanBias namespace DanBias
{ {
@ -18,55 +15,46 @@ namespace DanBias
class ButtonRectangle : public EventButtonGUI<Owner> class ButtonRectangle : public EventButtonGUI<Owner>
{ {
public: public:
ButtonRectangle() ButtonRectangle(std::wstring textureName, std::wstring buttonText,
: EventButtonGUI(), width(0), height(0) 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)
{} {}
ButtonRectangle(std::wstring textureName, std::wstring buttonText, ButtonRectangle(std::wstring textureName, std::wstring buttonText,
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor, Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
Owner owner, Oyster::Math::Float3 pos, EventFunc func, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None) : EventButtonGUI(textureName, buttonText
: EventButtonGUI(textureName, buttonText, , textColor, backColor, hoverColor, pressedColor
textColor, backColor, hoverColor, pressedColor, , func, pos, size, resize)
owner, pos, size, resize)
{} {}
ButtonRectangle(std::wstring textureName, std::wstring buttonText, ButtonRectangle(std::wstring textureName, std::wstring buttonText,
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor, Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
EventFunc func, Oyster::Math::Float3 pos, EventFunc func, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None) : EventButtonGUI(textureName, buttonText
: EventButtonGUI(textureName, buttonText, , textColor, backColor, hoverColor, pressedColor
textColor, backColor, hoverColor, pressedColor, , func, owner, pos, size, resize)
func, pos, size, resize)
{} {}
ButtonRectangle(std::wstring textureName, std::wstring buttonText, ButtonRectangle(std::wstring textureName, std::wstring buttonText,
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor, Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
EventFunc func, Owner owner, Oyster::Math::Float3 pos, EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None) : EventButtonGUI(textureName, buttonText
: EventButtonGUI(textureName, buttonText, , textColor, backColor, hoverColor, pressedColor
textColor, backColor, hoverColor, pressedColor, , func, owner, userData, pos, size, resize)
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)
{} {}
virtual ~ButtonRectangle() virtual ~ButtonRectangle()
{} {}
//Circle vs point collision //Rectangle vs point collision
bool Collision(Oyster::Event::MouseInput& input) bool Collision(Oyster::Event::MouseInput& input)
{ {
//Should come from the InputClass
float xMouse = input.x, yMouse = input.y; float xMouse = input.x, yMouse = input.y;
float widthTemp = pos.x - size.x * 0.5f; float widthTemp = pos.x - size.x * 0.5f;
float widthTemp2 = pos.x + size.x * 0.5f; float widthTemp2 = pos.x + size.x * 0.5f;
float heightTemp = pos.y - size.y * 0.5f; float heightTemp = pos.y - size.y * 0.5f;
float heightTemp2 = 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 && if(xMouse >= widthTemp && xMouse <= widthTemp2 &&
yMouse >= heightTemp && yMouse <= heightTemp2) yMouse >= heightTemp && yMouse <= heightTemp2)

View File

@ -7,6 +7,7 @@
#include "EventHandler/EventButton.h" #include "EventHandler/EventButton.h"
#include "DllInterfaces/GFXAPI.h" #include "DllInterfaces/GFXAPI.h"
#include "../WindowManager/WindowShell.h"
namespace DanBias namespace DanBias
{ {
@ -37,26 +38,27 @@ namespace DanBias
textColor(textColor), backColor(backColor), hoverColor(hoverColor), pressedColor(pressedColor) textColor(textColor), backColor(backColor), hoverColor(hoverColor), pressedColor(pressedColor)
{ {
CreateTexture(textureName); CreateTexture(textureName);
this->resizedSize = size;
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize); if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
} }
EventButtonGUI(std::wstring textureName, std::wstring buttonText, EventButtonGUI(std::wstring textureName, std::wstring buttonText,
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor, Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
EventFunc func, Oyster::Math::Float3 pos, EventFunc func, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
: EventButton(func), pos(pos), size(size), texture(NULL), buttonText(buttonText), : EventButton(func), pos(pos), size(size), texture(NULL), buttonText(buttonText),
textColor(textColor), backColor(backColor), hoverColor(hoverColor), pressedColor(pressedColor) textColor(textColor), backColor(backColor), hoverColor(hoverColor), pressedColor(pressedColor)
{ {
CreateTexture(textureName); CreateTexture(textureName);
this->resizedSize = size;
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize); if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
} }
EventButtonGUI(std::wstring textureName, std::wstring buttonText, EventButtonGUI(std::wstring textureName, std::wstring buttonText,
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor, Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
EventFunc func, Owner owner, Oyster::Math::Float3 pos, EventFunc func, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
: EventButton(func, owner), pos(pos), size(size), texture(NULL), buttonText(buttonText), : EventButton(func, owner), pos(pos), size(size), texture(NULL), buttonText(buttonText),
textColor(textColor), backColor(backColor), hoverColor(hoverColor), pressedColor(pressedColor) textColor(textColor), backColor(backColor), hoverColor(hoverColor), pressedColor(pressedColor)
{ {
CreateTexture(textureName); CreateTexture(textureName);
this->resizedSize = size;
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize); if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
} }
EventButtonGUI(std::wstring textureName, std::wstring buttonText, EventButtonGUI(std::wstring textureName, std::wstring buttonText,
@ -66,6 +68,7 @@ namespace DanBias
textColor(textColor), backColor(backColor), hoverColor(hoverColor), pressedColor(pressedColor) textColor(textColor), backColor(backColor), hoverColor(hoverColor), pressedColor(pressedColor)
{ {
CreateTexture(textureName); CreateTexture(textureName);
this->resizedSize = size;
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize); if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
} }
virtual ~EventButtonGUI() virtual ~EventButtonGUI()
@ -92,15 +95,15 @@ namespace DanBias
if(EventButton<Owner>::GetState() == ButtonState_None) if(EventButton<Owner>::GetState() == ButtonState_None)
{ {
Oyster::Graphics::API::RenderGuiElement(texture, pos, size, backColor); Oyster::Graphics::API::RenderGuiElement(texture, pos, resizedSize, backColor);
} }
else if(EventButton<Owner>::GetState() == ButtonState_Hover) else if(EventButton<Owner>::GetState() == ButtonState_Hover)
{ {
Oyster::Graphics::API::RenderGuiElement(texture, pos, size, hoverColor); Oyster::Graphics::API::RenderGuiElement(texture, pos, resizedSize, hoverColor);
} }
else 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); GetClientRect(WindowShell::GetHWND(), &r);
if(resize == ResizeAspectRatio_Height) 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) else if(resize == ResizeAspectRatio_Width)
size.x *= (float)r.bottom/(float)r.right; resizedSize.x = size.x * ((float)r.bottom/(float)r.right);
} }
protected: protected:
Oyster::Math::Float3 pos; Oyster::Math::Float3 pos;
Oyster::Math::Float2 size; 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; Oyster::Graphics::API::Texture texture;
std::wstring buttonText; std::wstring buttonText;

View File

@ -4,6 +4,12 @@
using namespace ::Oyster::Math3D; using namespace ::Oyster::Math3D;
using namespace ::Utility::Value; using namespace ::Utility::Value;
inline Quaternion Transform( const Quaternion &transformer, const Quaternion &transformee )
{
// return transformer * transformee;
return transformee * transformer;
}
Camera_FPSV2::Camera_FPSV2() Camera_FPSV2::Camera_FPSV2()
{ // this->head is default set to identity uniformprojection at origo { // this->head is default set to identity uniformprojection at origo
this->pitchUp = 0.0f; this->pitchUp = 0.0f;
@ -46,7 +52,7 @@ void Camera_FPSV2::SetRotation( const Quaternion &rotation )
} }
this->body.rotation = 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; this->pitchHaveChanged = false;
} }
@ -74,7 +80,7 @@ void Camera_FPSV2::UpdateOrientation()
{ {
if( this->pitchHaveChanged ) 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; this->pitchHaveChanged = false;
} }
@ -87,7 +93,7 @@ void Camera_FPSV2::UpdateOrientation()
void Camera_FPSV2::SnapUpToNormal( const Float3 &normal ) 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->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; this->pitchHaveChanged = false;
} }
@ -130,6 +136,11 @@ void Camera_FPSV2::StrafeLeft( Float distance )
void Camera_FPSV2::PitchUp( Float radian ) 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->pitchUp = Clamp( this->pitchUp + radian, -0.48f * pi, 0.48f * pi );
this->pitchHaveChanged = true; this->pitchHaveChanged = true;
} }
@ -164,7 +175,7 @@ Float4x4 & Camera_FPSV2::GetViewMatrix( Float4x4 &targetMem ) const
{ {
if( this->pitchHaveChanged ) 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; this->pitchHaveChanged = false;
} }
@ -180,7 +191,7 @@ Float4x4 & Camera_FPSV2::GetViewsProjMatrix( Float4x4 &targetMem ) const
{ {
if( this->pitchHaveChanged ) 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; this->pitchHaveChanged = false;
} }
@ -191,7 +202,7 @@ Float3 Camera_FPSV2::GetNormalOf( const Float3 &axis ) const
{ {
if( this->pitchHaveChanged ) 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; this->pitchHaveChanged = false;
} }
@ -212,7 +223,7 @@ Float3 Camera_FPSV2::GetLook() const
{ {
if( this->pitchHaveChanged ) 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; this->pitchHaveChanged = false;
} }

View File

@ -480,6 +480,12 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState
// if is this player. Remember to change camera // if is this player. Remember to change camera
if( this->privData->myId == decoded.object_ID ) 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.SetPosition( position );
this->privData->camera.SetRotation( rotation ); this->privData->camera.SetRotation( rotation );
this->privData->player.setPos( position ); this->privData->player.setPos( position );

View File

@ -61,6 +61,8 @@ using namespace DanBias;
switch (e.args.type) switch (e.args.type)
{ {
case NetworkClient::ClientEventArgs::EventType_Disconnect: case NetworkClient::ClientEventArgs::EventType_Disconnect:
this->gClients[temp]->GetClient()->Disconnect();
this->gClients[temp] = 0;
break; break;
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToRecieve: case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToRecieve:
break; break;
@ -128,6 +130,12 @@ using namespace DanBias;
int id = movedObject->GetID(); int id = movedObject->GetID();
//Protocol_ObjectPosition p(movedObject->GetPosition(), id); //Protocol_ObjectPosition p(movedObject->GetPosition(), id);
Protocol_ObjectPositionRotation p(movedObject->GetPosition(), movedObject->GetRotation(), 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()); GameSession::gameSession->Send(p.GetProtocol());
//} //}
} }

View File

@ -337,7 +337,11 @@ namespace Utility
template<typename ValueType> template<typename ValueType>
inline ValueType Clamp( const ValueType &value, const ValueType &min, const ValueType &max ) 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<typename ValueType> template<typename ValueType>
inline ValueType Average( const ValueType &valueA, const ValueType &valueB ) inline ValueType Average( const ValueType &valueA, const ValueType &valueB )

View File

@ -104,6 +104,16 @@ struct NetworkClient::PrivateData : public IThreadObject
errorCode = this->connection.Send(temp); errorCode = this->connection.Send(temp);
if(errorCode != 0 && errorCode != WSAEWOULDBLOCK) if(errorCode != 0 && errorCode != WSAEWOULDBLOCK)
{
if( errorCode == WSAECONNABORTED || errorCode == WSAENOTCONN)
{
CEA parg;
parg.type = CEA::EventType_Disconnect;
parg.data.protocol = p;
NetEvent<NetworkClient*, CEA> e = { this->parent, parg };
this->recieveQueue.Push(e);
}
else
{ {
CEA parg; CEA parg;
parg.type = CEA::EventType_ProtocolFailedToSend; parg.type = CEA::EventType_ProtocolFailedToSend;
@ -112,6 +122,7 @@ struct NetworkClient::PrivateData : public IThreadObject
this->recieveQueue.Push(e); this->recieveQueue.Push(e);
} }
} }
}
return errorCode; return errorCode;
} }