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);