From 450f4249f34a80d6f5509af32c50d2f61eaadc69 Mon Sep 17 00:00:00 2001 From: Dennis Andersen Date: Mon, 10 Feb 2014 22:25:31 +0100 Subject: [PATCH 1/2] Documentation - Updated uml diagrams --- Code/Dokumentation/Danbias Structure.uxf | 455 ++++++++++-------- Code/Dokumentation/GameServer.uxf | 311 ++++++------ Code/Dokumentation/Resource.uxf | 260 ++++++++-- .../GameClientState/LobbyState.cpp | 2 +- .../GameClientState/LoginState.cpp | 1 + Code/Misc/Misc.vcxproj | 42 +- Code/Misc/Resource/ResourceManager.h | 3 +- 7 files changed, 657 insertions(+), 417 deletions(-) diff --git a/Code/Dokumentation/Danbias Structure.uxf b/Code/Dokumentation/Danbias Structure.uxf index c24380c9..d52aa795 100644 --- a/Code/Dokumentation/Danbias Structure.uxf +++ b/Code/Dokumentation/Danbias Structure.uxf @@ -1,212 +1,197 @@ - 11 + 7 com.umlet.element.Class - 847 - 363 - 132 - 33 + 728 + 413 + 91 + 21 - Graphics + Graphics <<module>> +bg=orange com.umlet.element.Class - 561 - 363 - 132 - 33 + 546 + 413 + 84 + 21 - Sound + Sound<<?>> com.umlet.element.Class - 671 - 209 - 132 - 33 + 616 + 322 + 84 + 21 - Physics + Physics <<module>> +bg=orange com.umlet.element.Class - 858 - 132 - 121 - 33 + 735 + 238 + 77 + 21 - Game client + Game client <<dll>> +bg=red com.umlet.element.Class - 484 - 209 - 154 - 33 + 616 + 287 + 98 + 21 - Gamelogic + Gamelogic <<dll>> +bg=red com.umlet.element.Class - 506 - 132 - 121 - 33 + 504 + 238 + 84 + 21 - Game server + Game server <<dll>> +bg=red com.umlet.element.Class - 671 - 132 - 132 - 33 + 616 + 238 + 84 + 21 - Network + Network <<module>> +bg=orange com.umlet.element.Class - 704 - 363 - 132 - 33 + 637 + 413 + 84 + 21 - Input + Input<<lib>> +bg=blue com.umlet.element.Class - 495 - 55 - 176 - 44 + 714 + 182 + 98 + 28 - DanBiasClientLauncher + GameLauncher <<exe>> bg=green com.umlet.element.Relation - 880 - 132 - 54 - 252 + 749 + 238 + 34 + 188 lt=<- - 33;231;33;209;33;33 + 21;175;21;161;21;21 com.umlet.element.Relation - 583 - 132 - 351 - 252 + 560 + 238 + 223 + 188 lt=<- - 33;231;33;209;330;209;330;33 + 21;175;21;161;210;161;210;21 com.umlet.element.Relation - 528 - 132 - 54 - 98 + 525 + 238 + 146 + 62 lt=<- - 33;77;33;33 + 133;49;133;35;21;35;21;21 com.umlet.element.Relation - 594 - 110 - 98 - 54 + 567 + 224 + 62 + 34 lt=<- - 77;33;33;33 + 49;21;21;21 com.umlet.element.Relation - 605 - 187 - 87 - 54 + 637 + 287 + 34 + 48 lt=<- - 66;33;33;33 + 21;35;21;21 com.umlet.element.Relation - 737 - 132 - 197 - 252 + 658 + 238 + 125 + 188 lt=<- - 33;231;33;209;176;209;176;33 + 21;175;21;161;112;161;112;21 com.umlet.element.Relation - 770 - 110 - 109 - 54 + 679 + 224 + 69 + 34 lt=<- - 33;33;88;33 - - - com.umlet.element.Relation - - 880 - 66 - 54 - 87 - - lt=>- - 33;33;33;66 - - - com.umlet.element.Relation - - 528 - 66 - 54 - 87 - - lt=>- - 33;33;33;66 + 21;21;56;21 com.umlet.element.Package - 440 - 22 - 550 - 396 + 455 + 161 + 371 + 287 GameEngine @@ -214,21 +199,21 @@ bg=green com.umlet.element.Relation - 880 - 363 - 54 - 164 + 749 + 413 + 34 + 104 lt=<<. - 33;33;33;143 + 21;21;21;91 com.umlet.element.Package - 891 - 506 - 319 - 220 + 756 + 504 + 203 + 140 Graphics @@ -236,10 +221,10 @@ bg=green com.umlet.element.Class - 902 - 539 - 297 - 176 + 763 + 525 + 189 + 112 <<interface>> OysterGfx @@ -256,10 +241,10 @@ Release(resource :Model*) :void com.umlet.element.Package - 561 - 506 - 308 - 242 + 546 + 504 + 196 + 154 Input @@ -267,21 +252,21 @@ Release(resource :Model*) :void com.umlet.element.Relation - 649 - 363 - 142 - 175 + 602 + 413 + 90 + 111 lt=<<. - 121;33;121;154;33;154 + 77;21;77;98;21;98 com.umlet.element.Class - 572 - 539 - 286 - 198 + 553 + 525 + 182 + 126 <<interface>> RawInput @@ -299,32 +284,33 @@ Enable(Enable :bool) :void com.umlet.element.Class - 451 - 363 - 99 - 33 + 462 + 413 + 77 + 21 - Window API + Window API<<lib>> +bg=blue com.umlet.element.Relation - 462 - 132 - 472 - 252 + 483 + 238 + 300 + 188 lt=<- - 33;231;33;209;451;209;451;33 + 21;175;21;161;287;161;287;21 com.umlet.element.Package - 176 - 506 - 374 - 242 + 301 + 504 + 238 + 154 Sound @@ -332,10 +318,10 @@ Enable(Enable :bool) :void com.umlet.element.Class - 187 - 539 - 352 - 121 + 308 + 525 + 224 + 77 <<interface>> SoundWrapper @@ -349,10 +335,10 @@ Release(Resource :ResourceHandle*) :void com.umlet.element.Class - 187 - 693 - 352 - 44 + 308 + 623 + 224 + 28 <<API>> -- @@ -362,79 +348,152 @@ FMOD com.umlet.element.Relation - 330 - 627 - 54 - 87 + 399 + 581 + 34 + 55 lt=<<. - 33;66;33;33 + 21;42;21;21 com.umlet.element.Relation - 286 - 363 - 362 - 175 + 371 + 413 + 230 + 111 lt=<<. - 341;33;341;88;253;88;253;154;33;154 + 217;21;217;56;161;56;161;98;21;98 com.umlet.element.Class - 781 - 55 - 198 - 44 + 476 + 329 + 84 + 28 - DanBiasServerLauncher + Math <<lib>> +-- +/Is used globaly/ +bg=blue + + + + com.umlet.element.Relation + + 539 + 238 + 237 + 125 + + lt=<- + 21;112;224;112;224;21 + + + com.umlet.element.Class + + 476 + 294 + 77 + 28 + + Misc <<lib>> +-- +/Is used globaly/ +bg=blue + + + + com.umlet.element.Relation + + 539 + 273 + 90 + 76 + + lt=<- + 21;63;56;63;56;21;77;21 + + + UMLClass + + 105 + 168 + 245 + 140 + + /*HISTORY*/ +-- +10/2-2014 +Renamed DanBiasClientLauncher -> GameLauncher +Removed DanBiasServerLauncher - connected to GameClient +Added missing cconnections +Specified what type of box and added a colour +-- +elementstyle=wordwrap +bg=gray + + + + + com.umlet.element.Relation + + 749 + 189 + 34 + 62 + + lt=<- + 21;49;21;21 + + + com.umlet.element.Class + + 504 + 189 + 91 + 28 + + ServerUI <<exe>> +-- +/template for future/ bg=green - com.umlet.element.Class + com.umlet.element.Relation - 671 - 253 - 132 - 33 + 525 + 196 + 34 + 55 - Math - + lt=<- + 21;42;21;21 com.umlet.element.Relation - 770 - 132 - 153 - 164 + 539 + 308 + 90 + 48 lt=<- - 33;143;132;143;132;33 - - - com.umlet.element.Class - - 682 - 297 - 99 - 33 - - Misc - + 21;35;63;35;63;21;77;21 com.umlet.element.Relation - 605 - 198 - 87 - 98 + 532 + 273 + 97 + 41 lt=<- - 66;77;44;77;44;33;33;33 + 21;28;56;28;56;21;84;21 diff --git a/Code/Dokumentation/GameServer.uxf b/Code/Dokumentation/GameServer.uxf index 735a2592..890e2cbb 100644 --- a/Code/Dokumentation/GameServer.uxf +++ b/Code/Dokumentation/GameServer.uxf @@ -1,13 +1,13 @@ - - 10 + + 8 UMLClass - 610 - 340 - 100 - 30 + 632 + 344 + 104 + 24 GameLobby @@ -16,137 +16,100 @@ UMLClass - 580 - 480 - 160 - 80 + 624 + 416 + 128 + 48 GameSession -- /One instance of a game/ -/including x number of/ -/players./ +/including n players./ com.umlet.element.Relation - 620 - 340 - 60 - 160 + 664 + 344 + 40 + 88 lt=->>>> - 30;140;40;30 + 24;72;24;24 com.umlet.element.Relation - 710 - 480 - 100 - 50 + 664 + 440 + 40 + 104 lt=>>>>- - 80;30;30;30 + 24;88;24;24 UMLClass - 600 - 180 - 120 - 120 + 40 + 120 + 368 + 344 - GameServer + GameServerAPI <<singleton>> +-- +{innerclass ++ServerInitDesc<<struct>> +-- +serverName :char pointer +listenPort :int +bool broadcast :bool +ServerInitDesc() :void +innerclass} +{innerclass ++GameServerInfo<<struct>> +-- +listenPort :unsigned int +serverIp :const char pointer +innerclass} + ++static DanBiasServerReturn ServerInitiate(const ServerInitDesc& desc); ++static ServerStart() :void ++static ServerStop() :void ++static ServerUpdate() :void ++static ServerGetInfo() :GameServerInfo ++static ServerIsRunning() :bool ++static GameSetMapId( val :const int& ) :void ++static GameSetMaxClients( val :const int& ) :void ++static GameSetGameMode(val :const int&) :void ++static GameSetGameTime(val :const int&) :void ++static GameGetMapId() :int ++static GameGetMaxClients() :int ++static GameGetGameMode() :int ++static GameGetGameTime() :int ++static GameGetGameName() :const char pointer ++static GameStart() :bool com.umlet.element.Relation - 630 - 270 - 50 - 90 - - lt=>>>>- - 30;70;30;30 - - - UMLClass - - 590 - 100 - 130 + 384 + 328 + 264 40 - <<wrapper>> -DanBiasServerAPI - - - - com.umlet.element.Relation - - 630 - 110 - 50 - 90 - - lt=>>>>- - - 30;70;30;30 - - - UMLClass - - 1060 - 330 - 120 - 50 - - NetworkSession - - - - com.umlet.element.Relation - - 690 - 220 - 390 - 50 - - lt=-<<<< - 30;30;370;30 - - - com.umlet.element.Relation - - 680 - 320 - 400 - 50 - - lt=->>>>> - 30;30;380;30 - - - com.umlet.element.Relation - - 690 - 340 - 390 - 160 - - lt=->>>>> - 30;140;40;40;370;30 + lt=>>>>- + 248;24;24;24 com.umlet.element.Package - 460 - 640 - 120 - 50 + 440 + 424 + 96 + 40 GameLogicAPI bg=blue @@ -155,21 +118,21 @@ bg=blue com.umlet.element.Relation - 370 - 530 - 350 - 290 + 512 + 424 + 128 + 40 lt=<<. - 90;150;30;270;330;240;240;30 + 24;24;112;24 UMLClass - 790 - 500 - 100 - 30 + 624 + 528 + 144 + 24 GameClient @@ -177,21 +140,21 @@ bg=blue com.umlet.element.Relation - 670 - 530 - 150 - 180 + 520 + 416 + 120 + 104 lt=<<. - 130;160;30;30 + 24;88;64;88;64;24;104;24 com.umlet.element.Package - 800 - 670 - 120 - 40 + 448 + 480 + 96 + 48 GameProtocols bg=#aaaaa @@ -200,10 +163,10 @@ bg=#aaaaa com.umlet.element.Package - 1040 - 200 - 160 - 190 + 720 + 160 + 152 + 24 NetworkAPI bg=#a21aff @@ -212,56 +175,84 @@ bg=#a21aff UMLClass - 1060 - 280 - 120 - 40 + 40 + 24 + 320 + 64 - NetworkClient - - - - UMLClass - - 1060 - 230 - 120 - 40 - - NetworkServer + /*HISTORY*/ +-- +10/2-2014 +Restructured old +-- +elementstyle=wordwrap +bg=gray com.umlet.element.Relation - 690 - 240 - 390 - 80 + 720 + 160 + 40 + 272 - lt=-> - 30;30;200;30;200;60;370;60 + lt=<<. + 24;24;24;256 com.umlet.element.Relation - 690 - 260 - 390 - 100 + 704 + 160 + 40 + 200 - lt=-<<<< - 30;30;180;30;180;80;370;80 + lt=<<. + 24;24;24;184 com.umlet.element.Relation - 860 - 270 - 380 - 260 + 384 + 152 + 352 + 40 - lt=>>>- - 320;30;360;30;360;230;30;240 + lt=<<. + 336;24;24;24 + + + com.umlet.element.Relation + + 736 + 160 + 40 + 384 + + lt=<<. + 24;24;24;368 + + + com.umlet.element.Relation + + 520 + 480 + 136 + 64 + + lt=<<. + 24;24;120;24;120;48 + + + com.umlet.element.Relation + + 512 + 432 + 160 + 112 + + lt=<<. + 24;24;72;24;72;72;144;72;144;96 diff --git a/Code/Dokumentation/Resource.uxf b/Code/Dokumentation/Resource.uxf index c62ae895..1258c9af 100644 --- a/Code/Dokumentation/Resource.uxf +++ b/Code/Dokumentation/Resource.uxf @@ -1,13 +1,13 @@ - - 16 + + 6 com.umlet.element.Class - 560 - 80 - 176 - 80 + 198 + 300 + 66 + 30 <<interface>> OysterResource @@ -16,23 +16,23 @@ OysterResource com.umlet.element.Relation - 528 - 112 - 206 - 160 + 186 + 312 + 76 + 60 lt=>> implements - 112;128;112;48 + 42;48;42;18 com.umlet.element.Actor - 352 - 240 - 128 - 192 + 120 + 360 + 48 + 72 Dev @@ -40,22 +40,22 @@ implements com.umlet.element.Relation - 320 - 32 - 272 - 240 + 108 + 282 + 102 + 90 lt=<. interacts> - 240;80;96;80;96;208 + 90;30;36;30;36;78 com.umlet.element.Class - 576 - 576 - 160 - 32 + 204 + 486 + 60 + 12 CustomLoader @@ -63,10 +63,10 @@ interacts> com.umlet.element.Class - 576 - 528 - 160 - 32 + 204 + 468 + 60 + 12 ByteLoader @@ -75,33 +75,33 @@ ByteLoader com.umlet.element.Relation - 464 - 384 - 144 - 192 + 162 + 414 + 54 + 72 lt=<<- - 80;48;48;48;48;160;112;160 + 30;18;18;18;18;60;42;60 com.umlet.element.Relation - 368 - 384 - 266 - 240 + 126 + 414 + 98 + 90 lt=<<- implements partly - 176;48;144;48;144;208;208;208 + 66;18;54;18;54;78;78;78 UMLClass - 544 - 240 - 208 - 128 + 192 + 360 + 78 + 48 -- <<interface>> @@ -115,10 +115,10 @@ halign=center UMLClass - 544 - 400 - 208 - 80 + 192 + 420 + 78 + 30 OResource @@ -130,13 +130,171 @@ halign=center com.umlet.element.Relation - 688 - 256 - 196 - 224 + 252 + 366 + 66 + 84 lt=>>>> manages> - 64;192;112;192;112;48;64;48 + 18;72;36;72;36;18;18;18 + + + UMLClass + + 108 + 282 + 240 + 234 + + old +bg=gray + + + + UMLClass + + 402 + 342 + 576 + 204 + + ResourceManager +-- ++ ResourceManager() :void ++ ~ResourceManager() :void ++ HBYTEARRAY LoadBytes(const wchar_t filename[], ResourceType type, int customId = -1, bool force = false) ++ HRESOURCE LoadResource(const wchar_t filename[], LoadFunction loadFnc = 0, UnloadFunction unloadFnc = 0, int customId = -1, bool force = false) ++ HRESOURCE ReloadResource(const wchar_t filename[]) ++ HRESOURCE ReloadResource(HRESOURCE& resource) ++ void Clean() ++ void ReleaseResource(const HRESOURCE& resource) ++ void ReleaseResource(const wchar_t filename[]) ++ void SetResourceId(const HRESOURCE& resource, unsigned int id) ++ void SetResourceId(const wchar_t filename[], unsigned int id) ++ ResourceType GetResourceType(const HRESOURCE& resource) ++ ResourceType GetResourceType (const wchar_t filename[]) ++ const wchar_t* GetResourceFilename(const HRESOURCE& resource); ++ HRESOURCE GetResourceHandle(const wchar_t filename[]) ++ int GetResourceId(const HRESOURCE& resource); ++ int GetResourceId(const wchar_t filename[]); +-- +- ResourceManager(const ResourceManager& obj); +- const ResourceManager& operator=(const ResourceManager&); +- std::map<std::wstring, ResourceData*> resources; + + + + UMLClass + + 390 + 198 + 600 + 360 + + Oyster <<namespace>> +-- + + + + + UMLClass + + 396 + 222 + 588 + 330 + + Resource <<namespace>> +-- + + + + + UMLClass + + 534 + 282 + 126 + 18 + + HRESOURCE: void* <<typedef>> + + + + UMLClass + + 534 + 300 + 126 + 18 + + HBYTE: char <<typedef>> + + + + UMLClass + + 534 + 318 + 126 + 18 + + HBYTEARRAY: char* <<typedef>> + + + + UMLClass + + 534 + 246 + 264 + 18 + + UnloadFunction :void(*UnloadFunction)(void* loadedData) <<typedef>> + + + + UMLClass + + 534 + 264 + 288 + 18 + + LoadFunction :void*(*LoadFunction)(const wchar_t filename[]) <<typedef>> + + + + UMLClass + + 402 + 246 + 126 + 90 + + ResourceType <<enum>> +-- +ResourceType_Byte_Raw +ResourceType_Byte_ANSI +ResourceType_Byte_UTF8 +ResourceType_Byte_UNICODE +ResourceType_Byte_UTF16LE +ResourceType_CUSTOM +ResourceType_INVALID + + + + + UMLClass + + 378 + 174 + 630 + 396 + + New +bg=green + diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp index ccfe636d..98d192dd 100644 --- a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp @@ -95,7 +95,7 @@ GameClientState::ClientState LobbyState::Update(float deltaTime, InputClass* Key { if(!DanBias::GameServerAPI::GameStart()) { - //this->nwClient->Send(GameLogic::Protocol_LobbyStartGame()); + } } } diff --git a/Code/Game/DanBiasGame/GameClientState/LoginState.cpp b/Code/Game/DanBiasGame/GameClientState/LoginState.cpp index e2392558..4b6c8df9 100644 --- a/Code/Game/DanBiasGame/GameClientState/LoginState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LoginState.cpp @@ -119,6 +119,7 @@ GameClientState::ClientState LoginState::Update(float deltaTime, InputClass* Key { // game ip nwClient->Connect(15152, "127.0.0.1"); + //nwClient->Connect(15152, "83.254.217.248"); if (!nwClient->IsConnected()) { diff --git a/Code/Misc/Misc.vcxproj b/Code/Misc/Misc.vcxproj index 2d9392a3..512784e7 100644 --- a/Code/Misc/Misc.vcxproj +++ b/Code/Misc/Misc.vcxproj @@ -147,10 +147,30 @@ - - - - + + false + false + false + false + + + false + false + false + false + + + false + false + false + false + + + false + false + false + false + false false @@ -171,8 +191,18 @@ - - + + false + false + false + false + + + false + false + false + false + false false diff --git a/Code/Misc/Resource/ResourceManager.h b/Code/Misc/Resource/ResourceManager.h index 4c90966e..43aa0215 100644 --- a/Code/Misc/Resource/ResourceManager.h +++ b/Code/Misc/Resource/ResourceManager.h @@ -13,6 +13,7 @@ namespace Oyster typedef void* HRESOURCE; typedef char HBYTE; typedef HBYTE* HBYTEARRAY; + /** Typedef on a fuction required for custom unloading */ typedef void(*UnloadFunction)(void* loadedData); @@ -30,7 +31,7 @@ namespace Oyster ResourceType_Byte_UTF16LE, /**< Handle can be interpeted as char[] or char* */ ResourceType_CUSTOM, /**< Handle can be interpeted as whatever */ - ResourceType_INVALID, /**< Handle can be interpeted as whatever */ + ResourceType_INVALID, }; /** A resource handler interface to interact with when loading resources. From 327472792360668f23cf2b58a90a6d4d093c1ba2 Mon Sep 17 00:00:00 2001 From: dean11 Date: Tue, 11 Feb 2014 10:21:47 +0100 Subject: [PATCH 2/2] GameServer - Added more gameplay protocols and structured the old mess --- Code/DanBias.sln | 44 -- .../Game/DanBiasGame/GameClientRecieverFunc.h | 29 - .../GameClientState/GameClientState.h | 5 + .../DanBiasGame/GameClientState/GameState.cpp | 29 +- .../GameClientState/LobbyState.cpp | 2 +- .../GameClientState/LoginState.cpp | 1 + Code/Game/GameLogic/Level.cpp | 6 +- Code/Game/GameProtocols/ObjectProtocols.h | 602 +++++++++++++++--- Code/Game/GameProtocols/PlayerProtocols.h | 121 ++-- .../GameProtocols/ProtocolIdentificationID.h | 37 +- Code/Game/GameServer/GameSession.h | 7 +- .../Implementation/GameSession_Gameplay.cpp | 103 +-- .../Implementation/GameSession_General.cpp | 1 + 13 files changed, 683 insertions(+), 304 deletions(-) diff --git a/Code/DanBias.sln b/Code/DanBias.sln index 4dedaaa2..7df9f29a 100644 --- a/Code/DanBias.sln +++ b/Code/DanBias.sln @@ -37,14 +37,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NetworkAPI", "Network\Netwo EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameProtocols", "Game\GameProtocols\GameProtocols.vcxproj", "{DA2AA800-ED64-4649-8B3B-E7F1E3968B78}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasServerLauncher", "Game\DanBiasServerLauncher\DanBiasServerLauncher.vcxproj", "{060B1890-CBF3-4808-BA99-A4776222093B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Physics lab", "Physics lab\Physics lab.vcxproj", "{5128BD77-6472-4C4A-BE6F-724AD0E589C2}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameServer", "Game\GameServer\GameServer.vcxproj", "{143BD516-20A1-4890-A3E4-F8BFD02220E7}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aDanBiasGameLauncher", "Game\aDanBiasGameLauncher\aDanBiasGameLauncher.vcxproj", "{666FEA52-975F-41CD-B224-B19AF3C0ABBA}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Mixed Platforms = Debug|Mixed Platforms @@ -247,30 +241,6 @@ Global {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Release|Win32.Build.0 = Release|Win32 {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Release|x64.ActiveCfg = Release|x64 {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Release|x64.Build.0 = Release|x64 - {060B1890-CBF3-4808-BA99-A4776222093B}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {060B1890-CBF3-4808-BA99-A4776222093B}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {060B1890-CBF3-4808-BA99-A4776222093B}.Debug|Win32.ActiveCfg = Debug|Win32 - {060B1890-CBF3-4808-BA99-A4776222093B}.Debug|Win32.Build.0 = Debug|Win32 - {060B1890-CBF3-4808-BA99-A4776222093B}.Debug|x64.ActiveCfg = Debug|x64 - {060B1890-CBF3-4808-BA99-A4776222093B}.Debug|x64.Build.0 = Debug|x64 - {060B1890-CBF3-4808-BA99-A4776222093B}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {060B1890-CBF3-4808-BA99-A4776222093B}.Release|Mixed Platforms.Build.0 = Release|Win32 - {060B1890-CBF3-4808-BA99-A4776222093B}.Release|Win32.ActiveCfg = Release|Win32 - {060B1890-CBF3-4808-BA99-A4776222093B}.Release|Win32.Build.0 = Release|Win32 - {060B1890-CBF3-4808-BA99-A4776222093B}.Release|x64.ActiveCfg = Release|x64 - {060B1890-CBF3-4808-BA99-A4776222093B}.Release|x64.Build.0 = Release|x64 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|Win32.ActiveCfg = Debug|Win32 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|Win32.Build.0 = Debug|Win32 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|x64.ActiveCfg = Debug|x64 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|x64.Build.0 = Debug|x64 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|Mixed Platforms.Build.0 = Release|Win32 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|Win32.ActiveCfg = Release|Win32 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|Win32.Build.0 = Release|Win32 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|x64.ActiveCfg = Release|x64 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|x64.Build.0 = Release|x64 {143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|Win32.ActiveCfg = Debug|Win32 @@ -283,18 +253,6 @@ Global {143BD516-20A1-4890-A3E4-F8BFD02220E7}.Release|Win32.Build.0 = Release|Win32 {143BD516-20A1-4890-A3E4-F8BFD02220E7}.Release|x64.ActiveCfg = Release|x64 {143BD516-20A1-4890-A3E4-F8BFD02220E7}.Release|x64.Build.0 = Release|x64 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Win32.ActiveCfg = Debug|Win32 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Win32.Build.0 = Debug|Win32 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|x64.ActiveCfg = Debug|x64 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|x64.Build.0 = Debug|x64 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Mixed Platforms.Build.0 = Release|Win32 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Win32.ActiveCfg = Release|Win32 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Win32.Build.0 = Release|Win32 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|x64.ActiveCfg = Release|x64 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -308,8 +266,6 @@ Global {B1195BB9-B3A5-47F0-906C-8DEA384D1520} = {20720CA7-795C-45AD-A302-9383A6DD503A} {8690FDDF-C5B7-4C42-A337-BD5243F29B85} = {20720CA7-795C-45AD-A302-9383A6DD503A} {DA2AA800-ED64-4649-8B3B-E7F1E3968B78} = {20720CA7-795C-45AD-A302-9383A6DD503A} - {060B1890-CBF3-4808-BA99-A4776222093B} = {20720CA7-795C-45AD-A302-9383A6DD503A} {143BD516-20A1-4890-A3E4-F8BFD02220E7} = {20720CA7-795C-45AD-A302-9383A6DD503A} - {666FEA52-975F-41CD-B224-B19AF3C0ABBA} = {20720CA7-795C-45AD-A302-9383A6DD503A} EndGlobalSection EndGlobal diff --git a/Code/Game/DanBiasGame/GameClientRecieverFunc.h b/Code/Game/DanBiasGame/GameClientRecieverFunc.h index 15b0cdab..8c01d9c7 100644 --- a/Code/Game/DanBiasGame/GameClientRecieverFunc.h +++ b/Code/Game/DanBiasGame/GameClientRecieverFunc.h @@ -38,34 +38,6 @@ namespace DanBias } } break; - case protocol_Gameplay_PlayerMovement: - { - Client::GameClientState::KeyInput* protocolData = new Client::GameClientState::KeyInput; - for(int i = 0; i< 6; i++) - { - protocolData->key[i] = p[i+1].value.netBool; - } - - if(dynamic_cast(gameClientState)) - ((Client::GameState*)gameClientState)->Protocol(protocolData); - delete protocolData; - protocolData = NULL; - } - break; - //case protocol_Gameplay_PlayerPosition: - // { - // Client::GameClientState::PlayerPos* protocolData = new Client::GameClientState::PlayerPos; - // for(int i = 0; i< 3; i++) - // { - // protocolData->playerPos[i] = p[i].value.netFloat; - // } - // if(dynamic_cast(gameClientState)) - // ((Client::GameState*)gameClientState)->Protocol(protocolData); - // delete protocolData; - // protocolData = NULL; - // } - // break; - case protocol_Gameplay_ObjectCreate: { Client::GameClientState::NewObj protocolData;// = new Client::GameClientState::NewObj; @@ -114,7 +86,6 @@ namespace DanBias { if(dynamic_cast(gameClientState)) { - GameLogic::Protocol_LobbyCreateGame tp(); int id = p.Get(1).value.netInt; std::string name = p.Get(19).value.netCharPtr; Oyster::Math::Float4x4 w; diff --git a/Code/Game/DanBiasGame/GameClientState/GameClientState.h b/Code/Game/DanBiasGame/GameClientState/GameClientState.h index 378eeefc..0545b866 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameClientState.h +++ b/Code/Game/DanBiasGame/GameClientState/GameClientState.h @@ -35,6 +35,11 @@ public: }; struct KeyInput :public ProtocolStruct { + /* + * key[0] = + * + * + */ bool key[6]; }; struct PlayerPos :public ProtocolStruct diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index 57b39ede..50417236 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -309,20 +309,11 @@ bool GameState::Release() void GameState::readKeyInput(InputClass* KeyInput) { - bool send = false; - GameLogic::Protocol_PlayerMovement movePlayer; - movePlayer.bForward = false; - movePlayer.bBackward = false; - movePlayer.bLeft = false; - movePlayer.bRight = false; - if(KeyInput->IsKeyPressed(DIK_W)) { - if(!key_forward) { - movePlayer.bForward = true; - send = true; + privData->nwClient->Send(GameLogic::Protocol_PlayerMovementForward()); key_forward = true; } } @@ -333,8 +324,7 @@ void GameState::readKeyInput(InputClass* KeyInput) { if(!key_backward) { - movePlayer.bBackward = true; - send = true; + privData->nwClient->Send(GameLogic::Protocol_PlayerMovementBackward()); key_backward = true; } } @@ -345,8 +335,7 @@ void GameState::readKeyInput(InputClass* KeyInput) { if(!key_strafeLeft) { - movePlayer.bLeft = true; - send = true; + privData->nwClient->Send(GameLogic::Protocol_PlayerMovementLeft()); key_strafeLeft = true; } } @@ -357,8 +346,7 @@ void GameState::readKeyInput(InputClass* KeyInput) { if(!key_strafeRight) { - movePlayer.bRight = true; - send = true; + privData->nwClient->Send(GameLogic::Protocol_PlayerMovementRight()); key_strafeRight = true; } } @@ -366,11 +354,6 @@ void GameState::readKeyInput(InputClass* KeyInput) key_strafeRight = false; - if (privData->nwClient->IsConnected() && send) - { - privData->nwClient->Send(movePlayer); - } - //send delta mouse movement if (KeyInput->IsMousePressed()) { @@ -437,9 +420,7 @@ void GameState::readKeyInput(InputClass* KeyInput) { if(!key_Jump) { - GameLogic::Protocol_PlayerJump playerJump; - playerJump.hasJumped = true; - privData->nwClient->Send(playerJump); + privData->nwClient->Send(GameLogic::Protocol_PlayerJump()); key_Jump = true; } } diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp index ccfe636d..98d192dd 100644 --- a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp @@ -95,7 +95,7 @@ GameClientState::ClientState LobbyState::Update(float deltaTime, InputClass* Key { if(!DanBias::GameServerAPI::GameStart()) { - //this->nwClient->Send(GameLogic::Protocol_LobbyStartGame()); + } } } diff --git a/Code/Game/DanBiasGame/GameClientState/LoginState.cpp b/Code/Game/DanBiasGame/GameClientState/LoginState.cpp index e2392558..4b6c8df9 100644 --- a/Code/Game/DanBiasGame/GameClientState/LoginState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LoginState.cpp @@ -119,6 +119,7 @@ GameClientState::ClientState LoginState::Update(float deltaTime, InputClass* Key { // game ip nwClient->Connect(15152, "127.0.0.1"); + //nwClient->Connect(15152, "83.254.217.248"); if (!nwClient->IsConnected()) { diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index e449f14d..15f74ae7 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -71,9 +71,9 @@ void Level::InitiateLevel(float radius) state.SetRestitutionCoeff(0.2); rigidBody->SetState(state); - levelObj = new StaticObject(rigidBody, LevelCollisionBefore, LevelCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_WORLD); - levelObj->objectID = idCount++; - rigidBody->SetCustomTag(levelObj); + this->levelObj = new StaticObject(rigidBody, LevelCollisionBefore, LevelCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_WORLD); + this->levelObj->objectID = idCount++; + rigidBody->SetCustomTag(this->levelObj); /* // add box diff --git a/Code/Game/GameProtocols/ObjectProtocols.h b/Code/Game/GameProtocols/ObjectProtocols.h index 5ce10b27..2feadc5d 100644 --- a/Code/Game/GameProtocols/ObjectProtocols.h +++ b/Code/Game/GameProtocols/ObjectProtocols.h @@ -1,3 +1,8 @@ +////////////////////////////////////////////////////////// +// Created 2013 // +// Dennis Andersen, Linda Andersson // +////////////////////////////////////////////////////////// + #ifndef GAMELOGIC_OBJECT_PROTOCOLS_H #define GAMELOGIC_OBJECT_PROTOCOLS_H @@ -6,6 +11,7 @@ namespace GameLogic { + //#define protocol_Gameplay_ObjectPickup 350 struct Protocol_ObjectPickup :public Oyster::Network::CustomProtocolObject { short object_ID; @@ -50,10 +56,11 @@ namespace GameLogic Oyster::Network::CustomNetProtocol protocol; }; + //#define protocol_Gameplay_ObjectDamage 351 struct Protocol_ObjectDamage :public Oyster::Network::CustomProtocolObject { int object_ID; - float health; //Precentage% + float healthLost; //Precentage% Protocol_ObjectDamage() { @@ -64,7 +71,7 @@ namespace GameLogic this->protocol[2].type = Oyster::Network::NetAttributeType_Float; object_ID = -1; - health = 0.0f; + healthLost = 0.0f; } Protocol_ObjectDamage(Oyster::Network::CustomNetProtocol& p) { @@ -78,12 +85,12 @@ namespace GameLogic this->protocol[2].type = Oyster::Network::NetAttributeType_Float; object_ID = id; - health = hp; + healthLost = hp; } Oyster::Network::CustomNetProtocol GetProtocol() override { this->protocol[1].value = object_ID; - this->protocol[2].value = health; + this->protocol[2].value = healthLost; return protocol; } @@ -91,51 +98,89 @@ namespace GameLogic Oyster::Network::CustomNetProtocol protocol; }; + //#define protocol_Gameplay_ObjectHealthStatus 352 + struct Protocol_ObjectHealthStatus :public Oyster::Network::CustomProtocolObject + { + float currentHealth; + int id; + + Protocol_ObjectHealthStatus() + { + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[0].value.netShort = protocol_Gameplay_ObjectHealthStatus; + this->protocol[1].type = Oyster::Network::NetAttributeType_Int; + this->protocol[2].type = Oyster::Network::NetAttributeType_Float; + this->id = 0; + this->currentHealth = 0.0f; + } + Protocol_ObjectHealthStatus(int id, float health) + { + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[0].value.netShort = protocol_Gameplay_ObjectHealthStatus; + this->protocol[1].type = Oyster::Network::NetAttributeType_Int; + this->protocol[2].type = Oyster::Network::NetAttributeType_Float; + this->id = id; this->currentHealth = health; + } + Protocol_ObjectHealthStatus(Oyster::Network::CustomNetProtocol& p) + { + this->id = p[1].value.netInt; + this->currentHealth = p[2].value.netFloat; + } + Oyster::Network::CustomNetProtocol GetProtocol() override + { + this->protocol[1].value = this->id; + this->protocol[2].value = this->currentHealth; + + return protocol; + } + + private: + Oyster::Network::CustomNetProtocol protocol; + }; + + //#define protocol_Gameplay_ObjectPosition 353 struct Protocol_ObjectPosition :public Oyster::Network::CustomProtocolObject { - int object_ID; - float worldMatrix[16]; - + short object_ID; + float position[3]; + Protocol_ObjectPosition() { this->protocol[0].value = protocol_Gameplay_ObjectPosition; - this->protocol[0].type = Oyster::Network::NetAttributeType_Short; - - this->protocol[1].type = Oyster::Network::NetAttributeType_Int; + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[1].type = Oyster::Network::NetAttributeType_Short; + this->protocol[2].type = Oyster::Network::NetAttributeType_Float; + this->protocol[3].type = Oyster::Network::NetAttributeType_Float; + this->protocol[4].type = Oyster::Network::NetAttributeType_Float; - for (int i = 2; i <= 17; i++) - { - this->protocol[i].type = Oyster::Network::NetAttributeType_Float; - } - object_ID = -1; - memset(&worldMatrix[0], 0, sizeof(float) * 16); + object_ID = 0; + memset(&position[0], 0, sizeof(float) * 3); } Protocol_ObjectPosition(Oyster::Network::CustomNetProtocol& p) { - + object_ID = p[1].value.netShort; + position[0] = p[2].value.netFloat; + position[1] = p[3].value.netFloat; + position[2] = p[4].value.netFloat; } - Protocol_ObjectPosition(float m[16], int id) + Protocol_ObjectPosition(float v[3], int id) { this->protocol[0].value = protocol_Gameplay_ObjectPosition; this->protocol[0].type = Oyster::Network::NetAttributeType_Short; - - this->protocol[1].type = Oyster::Network::NetAttributeType_Int; - - for (int i = 2; i <= 17; i++) - { - this->protocol[i].type = Oyster::Network::NetAttributeType_Float; - } + this->protocol[1].type = Oyster::Network::NetAttributeType_Short; + this->protocol[2].type = Oyster::Network::NetAttributeType_Float; + this->protocol[3].type = Oyster::Network::NetAttributeType_Float; + this->protocol[4].type = Oyster::Network::NetAttributeType_Float; object_ID = id; - memcpy(&worldMatrix[0], &m[0], sizeof(float)*16); + memcpy(&position[0], &v[0], sizeof(float) * 3); } Oyster::Network::CustomNetProtocol GetProtocol() override { this->protocol[1].value = object_ID; - for (int i = 2; i <= 17; i++) - { - this->protocol[i].value = worldMatrix[i-2]; - } + this->protocol[2].value = position[0]; + this->protocol[3].value = position[1]; + this->protocol[4].value = position[2]; return protocol; } @@ -143,49 +188,132 @@ namespace GameLogic Oyster::Network::CustomNetProtocol protocol; }; + //#define protocol_Gameplay_ObjectScale 354 + struct Protocol_ObjectScale :public Oyster::Network::CustomProtocolObject + { + short object_ID; + float position[3]; + + Protocol_ObjectScale() + { + this->protocol[0].value = protocol_Gameplay_ObjectScale; + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[1].type = Oyster::Network::NetAttributeType_Short; + this->protocol[2].type = Oyster::Network::NetAttributeType_Float; + this->protocol[3].type = Oyster::Network::NetAttributeType_Float; + this->protocol[4].type = Oyster::Network::NetAttributeType_Float; + + object_ID = 0; + memset(&position[0], 0, sizeof(float) * 3); + } + Protocol_ObjectScale(Oyster::Network::CustomNetProtocol& p) + { + object_ID = p[1].value.netShort; + position[0] = p[2].value.netFloat; + position[1] = p[3].value.netFloat; + position[2] = p[4].value.netFloat; + } + Protocol_ObjectScale(float v[3], int id) + { + this->protocol[0].value = protocol_Gameplay_ObjectScale; + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[1].type = Oyster::Network::NetAttributeType_Short; + this->protocol[2].type = Oyster::Network::NetAttributeType_Float; + this->protocol[3].type = Oyster::Network::NetAttributeType_Float; + this->protocol[4].type = Oyster::Network::NetAttributeType_Float; + + object_ID = id; + memcpy(&position[0], &v[0], sizeof(float) * 3); + } + Oyster::Network::CustomNetProtocol GetProtocol() override + { + this->protocol[1].value = object_ID; + this->protocol[2].value = position[0]; + this->protocol[3].value = position[1]; + this->protocol[4].value = position[2]; + return protocol; + } + + private: + Oyster::Network::CustomNetProtocol protocol; + }; + + //#define protocol_Gameplay_ObjectRotation 355 + struct Protocol_ObjectRotation :public Oyster::Network::CustomProtocolObject + { + short object_ID; + float position[3]; + + Protocol_ObjectRotation() + { + this->protocol[0].value = protocol_Gameplay_ObjectRotation; + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[1].type = Oyster::Network::NetAttributeType_Short; + this->protocol[2].type = Oyster::Network::NetAttributeType_Float; + this->protocol[3].type = Oyster::Network::NetAttributeType_Float; + this->protocol[4].type = Oyster::Network::NetAttributeType_Float; + + object_ID = 0; + memset(&position[0], 0, sizeof(float) * 3); + } + Protocol_ObjectRotation(Oyster::Network::CustomNetProtocol& p) + { + object_ID = p[1].value.netShort; + position[0] = p[2].value.netFloat; + position[1] = p[3].value.netFloat; + position[2] = p[4].value.netFloat; + } + Protocol_ObjectRotation(float v[3], int id) + { + this->protocol[0].value = protocol_Gameplay_ObjectRotation; + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[1].type = Oyster::Network::NetAttributeType_Short; + this->protocol[2].type = Oyster::Network::NetAttributeType_Float; + this->protocol[3].type = Oyster::Network::NetAttributeType_Float; + this->protocol[4].type = Oyster::Network::NetAttributeType_Float; + + object_ID = id; + memcpy(&position[0], &v[0], sizeof(float) * 3); + } + Oyster::Network::CustomNetProtocol GetProtocol() override + { + this->protocol[1].value = object_ID; + this->protocol[2].value = position[0]; + this->protocol[3].value = position[1]; + this->protocol[4].value = position[2]; + return protocol; + } + + private: + Oyster::Network::CustomNetProtocol protocol; + }; + + //#define protocol_Gameplay_ObjectEnabled 356 struct Protocol_ObjectEnable :public Oyster::Network::CustomProtocolObject { - int object_ID; - float worldMatrix[16]; + int objectID; Protocol_ObjectEnable() { this->protocol[0].value = protocol_Gameplay_ObjectEnabled; - this->protocol[0].type = Oyster::Network::NetAttributeType_Short; - + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; this->protocol[1].type = Oyster::Network::NetAttributeType_Int; - - for (int i = 2; i <= 17; i++) - { - this->protocol[i].type = Oyster::Network::NetAttributeType_Float; - } - object_ID = -1; - memset(&worldMatrix[0], 0, sizeof(float) * 16); + this->objectID = -1; + } + Protocol_ObjectEnable(int objectID) + { + this->protocol[0].value = protocol_Gameplay_ObjectEnabled; + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[1].type = Oyster::Network::NetAttributeType_Int; + this->objectID = objectID; } Protocol_ObjectEnable(Oyster::Network::CustomNetProtocol& p) { - - } - Protocol_ObjectEnable(float m[16], int id) - { - this->protocol[0].value = protocol_Gameplay_ObjectEnabled; - this->protocol[0].type = Oyster::Network::NetAttributeType_Short; - - this->protocol[1].type = Oyster::Network::NetAttributeType_Int; - - for (int i = 2; i <= 17; i++) - { this->protocol[i].type = Oyster::Network::NetAttributeType_Float; } - - object_ID = id; - memcpy(&worldMatrix[0], &m[0], sizeof(float)*16); + this->objectID = p[1].value.netInt; } Oyster::Network::CustomNetProtocol GetProtocol() override { - this->protocol[1].value = object_ID; - for (int i = 2; i <= 17; i++) - { - this->protocol[i].value = worldMatrix[i-2]; - } + this->protocol[1].value = this->objectID; return protocol; } @@ -193,38 +321,39 @@ namespace GameLogic Oyster::Network::CustomNetProtocol protocol; }; + //#define protocol_Gameplay_ObjectDisabled 357 struct Protocol_ObjectDisable :public Oyster::Network::CustomProtocolObject { - int object_ID; - float timer; + int objectID; + float seconds; Protocol_ObjectDisable() { this->protocol[0].value = protocol_Gameplay_ObjectDisabled; this->protocol[0].type = Oyster::Network::NetAttributeType_Short; - this->protocol[1].type = Oyster::Network::NetAttributeType_Int; this->protocol[2].type = Oyster::Network::NetAttributeType_Float; + this->objectID = 0; + this->seconds = 0.0f; } - Protocol_ObjectDisable(Oyster::Network::CustomNetProtocol& p) - { - - } - Protocol_ObjectDisable(int id, float time) + Protocol_ObjectDisable(int objctID, float seconds) { this->protocol[0].value = protocol_Gameplay_ObjectDisabled; this->protocol[0].type = Oyster::Network::NetAttributeType_Short; - this->protocol[1].type = Oyster::Network::NetAttributeType_Int; this->protocol[2].type = Oyster::Network::NetAttributeType_Float; - - object_ID = id; - timer = time; + this->objectID = objctID; + this->seconds = seconds; + } + Protocol_ObjectDisable(Oyster::Network::CustomNetProtocol& p) + { + this->objectID = p[1].value.netInt; + this->seconds = p[2].value.netFloat; } Oyster::Network::CustomNetProtocol GetProtocol() override { - this->protocol[1].value = object_ID; - this->protocol[2].value = timer; + this->protocol[1].value = this->objectID; + this->protocol[2].value = this->seconds; return protocol; } @@ -232,6 +361,7 @@ namespace GameLogic Oyster::Network::CustomNetProtocol protocol; }; + //#define protocol_Gameplay_ObjectCreate 358 struct Protocol_ObjectCreate :public Oyster::Network::CustomProtocolObject { //ObjectType type; //ie player, box or whatever @@ -304,6 +434,330 @@ namespace GameLogic private: Oyster::Network::CustomNetProtocol protocol; }; + + //#define protocol_Gameplay_ObjectCreatePlayer 359 + struct Protocol_ObjectCreatePlayer :public Oyster::Network::CustomProtocolObject + { + //ObjectType type; //ie player, box or whatever + int object_ID; + int teamId; + std::string name; + std::string meshName; + float position[3]; + float rotation[3]; + float scale[3]; + + Protocol_ObjectCreatePlayer() + { + this->protocol[0].value = protocol_Gameplay_ObjectCreatePlayer; + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + + //PLAYER_ID + this->protocol[1].type = Oyster::Network::NetAttributeType_Int; + //TEAM_ID + this->protocol[2].type = Oyster::Network::NetAttributeType_Int; + //PLAYER-NAME + this->protocol[3].type = Oyster::Network::NetAttributeType_CharArray; + //MESH-NAME + this->protocol[4].type = Oyster::Network::NetAttributeType_CharArray; + //POSITION + this->protocol[5].type = Oyster::Network::NetAttributeType_Float; + this->protocol[6].type = Oyster::Network::NetAttributeType_Float; + this->protocol[7].type = Oyster::Network::NetAttributeType_Float; + //ROTATION + this->protocol[8].type = Oyster::Network::NetAttributeType_Float; + this->protocol[9].type = Oyster::Network::NetAttributeType_Float; + this->protocol[10].type = Oyster::Network::NetAttributeType_Float; + //SCALE + this->protocol[11].type = Oyster::Network::NetAttributeType_Float; + this->protocol[12].type = Oyster::Network::NetAttributeType_Float; + this->protocol[13].type = Oyster::Network::NetAttributeType_Float; + } + Protocol_ObjectCreatePlayer(Oyster::Network::CustomNetProtocol& p) + { + + } + Protocol_ObjectCreatePlayer(float position[3], float rotation[3], float scale[3], int ObjectID, int teamID, std::string name, std::string meshName) + { + this->protocol[0].value = protocol_Gameplay_ObjectCreatePlayer; + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + + //PLAYER_ID + this->protocol[1].type = Oyster::Network::NetAttributeType_Int; + //TEAM_ID + this->protocol[2].type = Oyster::Network::NetAttributeType_Int; + //PLAYER-NAME + this->protocol[3].type = Oyster::Network::NetAttributeType_CharArray; + //MESH-NAME + this->protocol[4].type = Oyster::Network::NetAttributeType_CharArray; + //POSITION + this->protocol[5].type = Oyster::Network::NetAttributeType_Float; + this->protocol[6].type = Oyster::Network::NetAttributeType_Float; + this->protocol[7].type = Oyster::Network::NetAttributeType_Float; + //ROTATION + this->protocol[8].type = Oyster::Network::NetAttributeType_Float; + this->protocol[9].type = Oyster::Network::NetAttributeType_Float; + this->protocol[10].type = Oyster::Network::NetAttributeType_Float; + //SCALE + this->protocol[11].type = Oyster::Network::NetAttributeType_Float; + this->protocol[12].type = Oyster::Network::NetAttributeType_Float; + this->protocol[13].type = Oyster::Network::NetAttributeType_Float; + + this->object_ID = ObjectID; + this->teamId = teamID; + this->name = name; + this->meshName = meshName; + memcpy(&this->position[0], &position[0], sizeof(float)*3); + memcpy(&this->rotation[0], &rotation[0], sizeof(float)*3); + memcpy(&this->scale[0], &scale[0], sizeof(float)*3); + } + Oyster::Network::CustomNetProtocol GetProtocol() override + { + + this->protocol[1].value = this->object_ID; + this->protocol[2].value = this->teamId; + this->protocol.Set(3, this->name); + this->protocol.Set(4, this->meshName); + + //POSITION + this->protocol[5].value = this->position[0]; + this->protocol[6].value = this->position[1]; + this->protocol[7].value = this->position[2]; + //ROTATION + this->protocol[8].value = this->rotation[0]; + this->protocol[9].value = this->rotation[1]; + this->protocol[10].value = this->rotation[2]; + //SCALE + this->protocol[11].value = this->scale[0]; + this->protocol[12].value = this->scale[1]; + this->protocol[13].value = this->scale[2]; + + return protocol; + } + + private: + Oyster::Network::CustomNetProtocol protocol; + }; + + //#define protocol_Gameplay_ObjectJoinTeam 360 + struct Protocol_ObjectJoinTeam :public Oyster::Network::CustomProtocolObject + { + int objectID; + int teamID; + + Protocol_ObjectJoinTeam() + { + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[0].value.netShort = protocol_Gameplay_ObjectJoinTeam; + this->protocol[1].type = Oyster::Network::NetAttributeType_Int; + this->protocol[2].type = Oyster::Network::NetAttributeType_Int; + this->objectID = 0; + this->teamID = 0; + } + Protocol_ObjectJoinTeam(int objID, int teamID) + { + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[0].value.netShort = protocol_Gameplay_ObjectJoinTeam; + this->protocol[1].type = Oyster::Network::NetAttributeType_Int; + this->protocol[2].type = Oyster::Network::NetAttributeType_Int; + this->objectID = objID; + this->teamID = teamID; + } + Protocol_ObjectJoinTeam(Oyster::Network::CustomNetProtocol& p) + { + this->objectID = p[1].value.netInt; + this->teamID = p[2].value.netInt; + } + Oyster::Network::CustomNetProtocol GetProtocol() override + { + this->protocol[1].value = this->objectID; + this->protocol[2].value = this->teamID; + return protocol; + } + + private: + Oyster::Network::CustomNetProtocol protocol; + }; + + //#define protocol_Gameplay_ObjectLeaveTeam 361 + struct Protocol_ObjectLeaveTeam :public Oyster::Network::CustomProtocolObject + { + int objectID; + Protocol_ObjectLeaveTeam() + { + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[0].value.netShort = protocol_Gameplay_ObjectLeaveTeam; + this->protocol[0].type = Oyster::Network::NetAttributeType_Int; + this->objectID = 0; + } + Protocol_ObjectLeaveTeam(int objectID) + { + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[0].value.netShort = protocol_Gameplay_ObjectLeaveTeam; + this->protocol[1].type = Oyster::Network::NetAttributeType_Int; + this->objectID = objectID; + } + Protocol_ObjectLeaveTeam(Oyster::Network::CustomNetProtocol& p) + { + this->objectID = p[1].value.netInt; + } + Oyster::Network::CustomNetProtocol GetProtocol() override + { + this->protocol[1].value = this->objectID; + return protocol; + } + + private: + Oyster::Network::CustomNetProtocol protocol; + }; + + //#define protocol_Gameplay_ObjectWeaponCooldown 362 + struct Protocol_ObjectWeaponCooldown :public Oyster::Network::CustomProtocolObject + { + float seconds; + Protocol_ObjectWeaponCooldown() + { + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[0].value.netShort = protocol_Gameplay_ObjectWeaponCooldown; + this->protocol[1].type = Oyster::Network::NetAttributeType_Float; + this->seconds = 0.0f; + } + Protocol_ObjectWeaponCooldown(float seconds) + { + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[0].value.netShort = protocol_Gameplay_ObjectWeaponCooldown; + this->protocol[1].type = Oyster::Network::NetAttributeType_Float; + this->seconds = seconds; + } + Protocol_ObjectWeaponCooldown(Oyster::Network::CustomNetProtocol& p) + { + this->seconds = p[1].value.netFloat; + } + Oyster::Network::CustomNetProtocol GetProtocol() override + { + this->protocol[1].value = this->seconds; + return protocol; + } + + private: + Oyster::Network::CustomNetProtocol protocol; + }; + + //#define protocol_Gameplay_ObjectWeaponEnergy 363 + struct Protocol_ObjectWeaponEnergy :public Oyster::Network::CustomProtocolObject + { + float energy; + Protocol_ObjectWeaponEnergy() + { + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[0].value.netShort = protocol_Gameplay_ObjectWeaponEnergy; + this->protocol[1].type = Oyster::Network::NetAttributeType_Float; + this->energy = 0.0f; + } + Protocol_ObjectWeaponEnergy(float energy) + { + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[0].value.netShort = protocol_Gameplay_ObjectWeaponEnergy; + this->protocol[1].type = Oyster::Network::NetAttributeType_Float; + this->energy = energy; + } + Protocol_ObjectWeaponEnergy(Oyster::Network::CustomNetProtocol& p) + { + this->energy = p[1].value.netFloat; + } + Oyster::Network::CustomNetProtocol GetProtocol() override + { + this->protocol[1].value = this->energy; + return protocol; + } + + private: + Oyster::Network::CustomNetProtocol protocol; + }; + + //#define protocol_Gameplay_ObjectRespawn 364 + struct Protocol_ObjectRespawn :public Oyster::Network::CustomProtocolObject + { + float position[3]; + + Protocol_ObjectRespawn() + { + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[0].value.netShort = protocol_Gameplay_ObjectRespawn; + + this->protocol[1].type = Oyster::Network::NetAttributeType_Float; + this->protocol[2].type = Oyster::Network::NetAttributeType_Float; + this->protocol[3].type = Oyster::Network::NetAttributeType_Float; + memset(&this->position[0], 0, sizeof(float) * 3); + } + Protocol_ObjectRespawn(float position[3]) + { + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[0].value.netShort = protocol_Gameplay_ObjectRespawn; + this->protocol[1].type = Oyster::Network::NetAttributeType_Float; + this->protocol[2].type = Oyster::Network::NetAttributeType_Float; + this->protocol[3].type = Oyster::Network::NetAttributeType_Float; + + memcpy(&this->position[0], &position[0], sizeof(float) * 3); + } + Protocol_ObjectRespawn(Oyster::Network::CustomNetProtocol& p) + { + this->position[0] = p[1].value.netFloat; + this->position[1] = p[2].value.netFloat; + this->position[2] = p[3].value.netFloat; + } + Oyster::Network::CustomNetProtocol GetProtocol() override + { + this->protocol[1].value = this->position[0]; + this->protocol[2].value = this->position[1]; + this->protocol[3].value = this->position[2]; + return protocol; + } + + private: + Oyster::Network::CustomNetProtocol protocol; + }; + + //#define protocol_Gameplay_ObjectDie 365 + struct Protocol_ObjectDie :public Oyster::Network::CustomProtocolObject + { + int objectID; + float seconds; + + Protocol_ObjectDie() + { + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[0].value.netShort = protocol_Gameplay_ObjectDie; + this->protocol[1].type = Oyster::Network::NetAttributeType_Int; + this->protocol[2].type = Oyster::Network::NetAttributeType_Float; + this->objectID = 0; + this->seconds = 0.0f; + } + Protocol_ObjectDie(int objectID, float seconds) + { + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + this->protocol[0].value.netShort = protocol_Gameplay_ObjectDie; + this->protocol[1].type = Oyster::Network::NetAttributeType_Int; + this->protocol[2].type = Oyster::Network::NetAttributeType_Float; + this->objectID = objectID; + this->seconds = seconds; + } + Protocol_ObjectDie(Oyster::Network::CustomNetProtocol& p) + { + this->objectID = p[1].value.netInt; + this->seconds = p[2].value.netFloat; + } + Oyster::Network::CustomNetProtocol GetProtocol() override + { + this->protocol[1].value = this->objectID; + this->protocol[2].value = this->seconds; + return protocol; + } + + private: + Oyster::Network::CustomNetProtocol protocol; + }; + } #endif // !GAMELOGIC_PLAYER_PROTOCOLS_H \ No newline at end of file diff --git a/Code/Game/GameProtocols/PlayerProtocols.h b/Code/Game/GameProtocols/PlayerProtocols.h index 81e6fbb8..a3c3501e 100644 --- a/Code/Game/GameProtocols/PlayerProtocols.h +++ b/Code/Game/GameProtocols/PlayerProtocols.h @@ -8,56 +8,67 @@ #include #include "ProtocolIdentificationID.h" -#include - -//protocol_Gameplay_PlayerMovement 300 -//protocol_Gameplay_PlayerMouseMovement 301 -//protocol_Gameplay_PlayerChangeWeapon 302 namespace GameLogic { - struct Protocol_PlayerMovement :public Oyster::Network::CustomProtocolObject + struct Protocol_PlayerMovementRight :public Oyster::Network::CustomProtocolObject { - bool bForward; - bool bBackward; - bool bLeft; - bool bRight; - - Protocol_PlayerMovement() + Protocol_PlayerMovementRight() { - this->protocol[0].value = protocol_Gameplay_PlayerMovement; + this->protocol[0].value = protocol_Gameplay_PlayerMovementRight; this->protocol[0].type = Oyster::Network::NetAttributeType_Short; - - this->protocol[1].type = Oyster::Network::NetAttributeType_Bool; - this->protocol[2].type = Oyster::Network::NetAttributeType_Bool; - this->protocol[3].type = Oyster::Network::NetAttributeType_Bool; - this->protocol[4].type = Oyster::Network::NetAttributeType_Bool; - } - Protocol_PlayerMovement(Oyster::Network::CustomNetProtocol& p) - { - bForward = p[1].value.netBool; - bBackward = p[2].value.netBool; - bLeft = p[3].value.netBool; - bRight = p[4].value.netBool; - } - const Protocol_PlayerMovement& operator=(Oyster::Network::CustomNetProtocol& val) - { - bForward = val[1].value.netBool; - bBackward = val[2].value.netBool; - bLeft = val[3].value.netBool; - bRight = val[4].value.netBool; - - return *this; } Oyster::Network::CustomNetProtocol GetProtocol() override - { - this->protocol[1].value = bForward; - this->protocol[2].value = bBackward; - this->protocol[3].value = bLeft; - this->protocol[4].value = bRight; + { return protocol; } - return protocol; + private: + Oyster::Network::CustomNetProtocol protocol; + }; + struct Protocol_PlayerMovementLeft :public Oyster::Network::CustomProtocolObject + { + Protocol_PlayerMovementLeft() + { + this->protocol[0].value = protocol_Gameplay_PlayerMovementLeft; + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; } + Oyster::Network::CustomNetProtocol GetProtocol() override { return protocol; } + + private: + Oyster::Network::CustomNetProtocol protocol; + }; + struct Protocol_PlayerMovementForward :public Oyster::Network::CustomProtocolObject + { + Protocol_PlayerMovementForward() + { + this->protocol[0].value = protocol_Gameplay_PlayerMovementForward; + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + } + Oyster::Network::CustomNetProtocol GetProtocol() override { return protocol; } + + private: + Oyster::Network::CustomNetProtocol protocol; + }; + struct Protocol_PlayerMovementBackward :public Oyster::Network::CustomProtocolObject + { + Protocol_PlayerMovementBackward() + { + this->protocol[0].value = protocol_Gameplay_PlayerMovementBackward; + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + } + Oyster::Network::CustomNetProtocol GetProtocol() override { return protocol; } + + private: + Oyster::Network::CustomNetProtocol protocol; + }; + + struct Protocol_PlayerJump :public Oyster::Network::CustomProtocolObject + { + Protocol_PlayerJump() + { + this->protocol[0].value = protocol_Gameplay_PlayerJump; + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + } + Oyster::Network::CustomNetProtocol GetProtocol() override { return protocol; } private: Oyster::Network::CustomNetProtocol protocol; @@ -65,7 +76,6 @@ namespace GameLogic struct Protocol_PlayerLook :public Oyster::Network::CustomProtocolObject { - float lookDirX; float lookDirY; float lookDirZ; @@ -180,35 +190,6 @@ namespace GameLogic Oyster::Network::CustomNetProtocol protocol; }; - struct Protocol_PlayerJump :public Oyster::Network::CustomProtocolObject - { - bool hasJumped; - - Protocol_PlayerJump() - { - this->protocol[0].value = protocol_Gameplay_PlayerJump; - this->protocol[0].type = Oyster::Network::NetAttributeType_Short; - - this->protocol[1].type = Oyster::Network::NetAttributeType_Bool; - } - Protocol_PlayerJump(Oyster::Network::CustomNetProtocol& p) - { - hasJumped = p[1].value.netBool; - } - const Protocol_PlayerJump& operator=(Oyster::Network::CustomNetProtocol& val) - { - hasJumped = val[1].value.netBool; - return *this; - } - Oyster::Network::CustomNetProtocol GetProtocol() override - { - this->protocol[1].value = hasJumped; - return protocol; - } - - private: - Oyster::Network::CustomNetProtocol protocol; - }; } #endif // !GAMELOGIC_PLAYER_PROTOCOLS_H diff --git a/Code/Game/GameProtocols/ProtocolIdentificationID.h b/Code/Game/GameProtocols/ProtocolIdentificationID.h index cb596a1c..46c6a213 100644 --- a/Code/Game/GameProtocols/ProtocolIdentificationID.h +++ b/Code/Game/GameProtocols/ProtocolIdentificationID.h @@ -41,17 +41,32 @@ /********* GAMEPLAY PROTOCOLS ***************************************************************************************************/ /***********[ 300 - 399 ]***********/ #define protocol_GameplayMIN 300 -#define protocol_Gameplay_PlayerMovement 300 -#define protocol_Gameplay_PlayerLookDir 301 -#define protocol_Gameplay_PlayerChangeWeapon 302 -#define protocol_Gameplay_PlayerShot 303 -#define protocol_Gameplay_PlayerJump 304 -#define protocol_Gameplay_ObjectPickup 305 -#define protocol_Gameplay_ObjectDamage 306 -#define protocol_Gameplay_ObjectPosition 307 -#define protocol_Gameplay_ObjectEnabled 308 -#define protocol_Gameplay_ObjectDisabled 309 -#define protocol_Gameplay_ObjectCreate 310 +#define protocol_Gameplay_PlayerMovementRight 300 +#define protocol_Gameplay_PlayerMovementLeft 301 +#define protocol_Gameplay_PlayerMovementForward 302 +#define protocol_Gameplay_PlayerMovementBackward 303 +#define protocol_Gameplay_PlayerLookDir 304 +#define protocol_Gameplay_PlayerChangeWeapon 305 +#define protocol_Gameplay_PlayerShot 306 +#define protocol_Gameplay_PlayerJump 307 + +#define protocol_Gameplay_ObjectPickup 350 +#define protocol_Gameplay_ObjectDamage 351 +#define protocol_Gameplay_ObjectHealthStatus 352 +#define protocol_Gameplay_ObjectPosition 353 +#define protocol_Gameplay_ObjectScale 354 +#define protocol_Gameplay_ObjectRotation 355 +#define protocol_Gameplay_ObjectEnabled 356 +#define protocol_Gameplay_ObjectDisabled 357 +#define protocol_Gameplay_ObjectCreate 358 +#define protocol_Gameplay_ObjectCreatePlayer 359 +#define protocol_Gameplay_ObjectJoinTeam 360 +#define protocol_Gameplay_ObjectLeaveTeam 361 + +#define protocol_Gameplay_ObjectWeaponCooldown 362 +#define protocol_Gameplay_ObjectWeaponEnergy 363 +#define protocol_Gameplay_ObjectRespawn 364 +#define protocol_Gameplay_ObjectDie 365 #define protocol_GameplayMAX 399 diff --git a/Code/Game/GameServer/GameSession.h b/Code/Game/GameServer/GameSession.h index 80d43a19..3b18f616 100644 --- a/Code/Game/GameServer/GameSession.h +++ b/Code/Game/GameServer/GameSession.h @@ -74,11 +74,14 @@ namespace DanBias private: void ParseProtocol ( Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c ); - void Gameplay_PlayerMovement ( GameLogic::Protocol_PlayerMovement& p, DanBias::GameClient* c ); + void Gameplay_PlayerMovementRight ( DanBias::GameClient* c ); + void Gameplay_PlayerMovementLeft ( DanBias::GameClient* c ); + void Gameplay_PlayerMovementBack ( DanBias::GameClient* c ); + void Gameplay_PlayerMovementForth ( DanBias::GameClient* c ); + void Gameplay_PlayerJump ( DanBias::GameClient* c ); void Gameplay_PlayerLookDir ( GameLogic::Protocol_PlayerLook& p, DanBias::GameClient* c ); void Gameplay_PlayerChangeWeapon ( GameLogic::Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c ); void Gameplay_PlayerShot ( GameLogic::Protocol_PlayerShot& p, DanBias::GameClient* c ); - void Gameplay_PlayerJump ( GameLogic::Protocol_PlayerJump& p, DanBias::GameClient* c ); void Gameplay_ObjectPickup ( GameLogic::Protocol_ObjectPickup& p, DanBias::GameClient* c ); void Gameplay_ObjectDamage ( GameLogic::Protocol_ObjectDamage& p, DanBias::GameClient* c ); void Gameplay_ObjectPosition ( GameLogic::Protocol_ObjectPosition& p, DanBias::GameClient* c ); diff --git a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp index b7d11e42..1d37d262 100644 --- a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp @@ -85,7 +85,7 @@ namespace DanBias void GameSession::ObjectMove(GameLogic::IObjectData* movedObject) { - float dt = GameSession::gameSession->networkTimer.getElapsedSeconds(); + //float dt = (float)GameSession::gameSession->networkTimer.getElapsedSeconds(); //Duh... This was causing alot of problems, it's in the wrong place... //Need to figure out where to put this frame locker. //We only need to send network packages when necessary, ie not 120 times per frame. @@ -93,18 +93,10 @@ namespace DanBias //graphics update (60 fps) on the client side. To send more than this would be lost //bandwidth. //if( dt >= GameSession::gameSession->networkFrameTime ) - { + //{ GameSession::gameSession->networkTimer.reset(); - - GameLogic::IObjectData* obj = movedObject; - if(movedObject->GetID() == testID) //TODO: TEST - { - float sec = (float)testTimer.getElapsedSeconds(); - sec = 0; - } - - int id = obj->GetID(); - Protocol_ObjectPosition p(obj->GetOrientation(), id); + int id = movedObject->GetID(); + Protocol_ObjectPosition p(movedObject->GetPosition(), id); //if(id != 1) GameSession::gameSession->Send(p.GetProtocol()); @@ -150,7 +142,7 @@ namespace DanBias } } */ - } + //} } void GameSession::ObjectDisabled( GameLogic::IObjectData* movedObject, float seconds ) @@ -168,43 +160,64 @@ namespace DanBias switch (p[0].value.netShort) { - case protocol_Gameplay_PlayerMovement: this->Gameplay_PlayerMovement ( Protocol_PlayerMovement (p), c ); + case protocol_Gameplay_PlayerMovementBackward: this->Gameplay_PlayerMovementBack ( c ); break; - case protocol_Gameplay_PlayerLookDir: this->Gameplay_PlayerLookDir ( Protocol_PlayerLook (p), c ); + case protocol_Gameplay_PlayerMovementForward: this->Gameplay_PlayerMovementForth ( c ); break; - case protocol_Gameplay_PlayerChangeWeapon: this->Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon (p), c ); + case protocol_Gameplay_PlayerMovementLeft: this->Gameplay_PlayerMovementLeft ( c ); break; - case protocol_Gameplay_PlayerShot: this->Gameplay_PlayerShot ( Protocol_PlayerShot (p), c ); + case protocol_Gameplay_PlayerMovementRight: this->Gameplay_PlayerMovementRight ( c ); break; - case protocol_Gameplay_PlayerJump: this->Gameplay_PlayerJump ( Protocol_PlayerJump (p), c ); + case protocol_Gameplay_PlayerJump: this->Gameplay_PlayerJump ( c ); break; - case protocol_Gameplay_ObjectPickup: this->Gameplay_ObjectPickup ( Protocol_ObjectPickup (p), c ); + case protocol_Gameplay_PlayerLookDir: this->Gameplay_PlayerLookDir ( Protocol_PlayerLook (p), c ); break; - case protocol_Gameplay_ObjectDamage: this->Gameplay_ObjectDamage ( Protocol_ObjectDamage (p), c ); + case protocol_Gameplay_PlayerChangeWeapon: this->Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon (p), c ); break; - case protocol_Gameplay_ObjectPosition: this->Gameplay_ObjectPosition ( Protocol_ObjectPosition (p), c ); + case protocol_Gameplay_PlayerShot: this->Gameplay_PlayerShot ( Protocol_PlayerShot (p), c ); break; - case protocol_Gameplay_ObjectEnabled: this->Gameplay_ObjectEnabled ( Protocol_ObjectEnable (p), c ); + + case protocol_Gameplay_ObjectPickup: this->Gameplay_ObjectPickup ( Protocol_ObjectPickup (p), c ); break; - case protocol_Gameplay_ObjectDisabled: this->Gameplay_ObjectDisabled ( Protocol_ObjectDisable (p), c ); + case protocol_Gameplay_ObjectDamage: this->Gameplay_ObjectDamage ( Protocol_ObjectDamage (p), c ); break; - case protocol_Gameplay_ObjectCreate: this->Gameplay_ObjectCreate ( Protocol_ObjectCreate (p), c ); + case protocol_Gameplay_ObjectPosition: this->Gameplay_ObjectPosition ( Protocol_ObjectPosition (p), c ); break; - case protocol_General_Status: this->General_Status ( Protocol_General_Status (p), c ); + case protocol_Gameplay_ObjectEnabled: this->Gameplay_ObjectEnabled ( Protocol_ObjectEnable (p), c ); break; - case protocol_General_Text: this->General_Text ( Protocol_General_Text (p), c ); + case protocol_Gameplay_ObjectDisabled: this->Gameplay_ObjectDisabled ( Protocol_ObjectDisable (p), c ); + break; + case protocol_Gameplay_ObjectCreate: this->Gameplay_ObjectCreate ( Protocol_ObjectCreate (p), c ); + break; + + case protocol_General_Status: this->General_Status ( Protocol_General_Status (p), c ); + break; + case protocol_General_Text: this->General_Text ( Protocol_General_Text (p), c ); break; } } - void GameSession::Gameplay_PlayerMovement ( Protocol_PlayerMovement& p, DanBias::GameClient* c ) + void GameSession::Gameplay_PlayerMovementBack ( DanBias::GameClient* c ) { - if(p.bForward) c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD); - if(p.bBackward) c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD); - if(p.bLeft) c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT); - if(p.bRight) c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT); + c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD); } - void GameSession::Gameplay_PlayerLookDir ( Protocol_PlayerLook& p, DanBias::GameClient* c ) + void GameSession::Gameplay_PlayerMovementForth ( DanBias::GameClient* c ) + { + c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD); + } + void GameSession::Gameplay_PlayerMovementLeft ( DanBias::GameClient* c ) + { + c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT); + } + void GameSession::Gameplay_PlayerMovementRight ( DanBias::GameClient* c ) + { + c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT); + } + void GameSession::Gameplay_PlayerJump ( DanBias::GameClient* c ) + { + c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_JUMP); + } + void GameSession::Gameplay_PlayerLookDir ( Protocol_PlayerLook& p, DanBias::GameClient* c ) { Oyster::Math3D::Float4 lookDir; lookDir.x = p.lookDirX; @@ -213,46 +226,44 @@ namespace DanBias lookDir.w = p.deltaX; c->GetPlayer()->Rotate(lookDir); } - void GameSession::Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c ) + void GameSession::Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c ) { } - void GameSession::Gameplay_PlayerShot ( Protocol_PlayerShot& p, DanBias::GameClient* c ) + void GameSession::Gameplay_PlayerShot ( Protocol_PlayerShot& p, DanBias::GameClient* c ) { if(p.secondaryPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_SECONDARY_PRESS); if(p.primaryPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS); if(p.utilityPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_UTILLITY_PRESS); } - void GameSession::Gameplay_PlayerJump ( Protocol_PlayerJump& p, DanBias::GameClient* c ) - { - if(p.hasJumped) c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_JUMP); - } - void GameSession::Gameplay_ObjectPickup ( Protocol_ObjectPickup& p, DanBias::GameClient* c ) + + + void GameSession::Gameplay_ObjectPickup ( Protocol_ObjectPickup& p, DanBias::GameClient* c ) { } - void GameSession::Gameplay_ObjectDamage ( Protocol_ObjectDamage& p, DanBias::GameClient* c ) + void GameSession::Gameplay_ObjectDamage ( Protocol_ObjectDamage& p, DanBias::GameClient* c ) { } - void GameSession::Gameplay_ObjectPosition ( Protocol_ObjectPosition& p, DanBias::GameClient* c ) + void GameSession::Gameplay_ObjectPosition ( Protocol_ObjectPosition& p, DanBias::GameClient* c ) { } - void GameSession::Gameplay_ObjectEnabled ( Protocol_ObjectEnable& p, DanBias::GameClient* c ) + void GameSession::Gameplay_ObjectEnabled ( Protocol_ObjectEnable& p, DanBias::GameClient* c ) { } - void GameSession::Gameplay_ObjectDisabled ( Protocol_ObjectDisable& p, DanBias::GameClient* c ) + void GameSession::Gameplay_ObjectDisabled ( Protocol_ObjectDisable& p, DanBias::GameClient* c ) { } - void GameSession::Gameplay_ObjectCreate ( Protocol_ObjectCreate& p, DanBias::GameClient* c ) + void GameSession::Gameplay_ObjectCreate ( Protocol_ObjectCreate& p, DanBias::GameClient* c ) { } - void GameSession::General_Status ( Protocol_General_Status& p, DanBias::GameClient* c ) + void GameSession::General_Status ( Protocol_General_Status& p, DanBias::GameClient* c ) { switch (p.status) { @@ -276,7 +287,7 @@ namespace DanBias break; } } - void GameSession::General_Text ( Protocol_General_Text& p, DanBias::GameClient* c ) + void GameSession::General_Text ( Protocol_General_Text& p, DanBias::GameClient* c ) { printf("Message recieved from (%i):\t %s\n", c->GetClient()->GetID(), p.text.c_str()); } diff --git a/Code/Game/GameServer/Implementation/GameSession_General.cpp b/Code/Game/GameServer/Implementation/GameSession_General.cpp index d6e6106c..f76428d8 100644 --- a/Code/Game/GameServer/Implementation/GameSession_General.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_General.cpp @@ -156,6 +156,7 @@ namespace DanBias { if((this->clients[k] && readyList[i]) && readyList[i]->GetClient()->GetID() != this->clients[k]->GetClient()->GetID()) { + //Protocol_ObjectCreatePlayer Protocol_ObjectCreate p(this->clients[k]->GetPlayer()->GetOrientation(), this->clients[k]->GetPlayer()->GetID(), "char_white.dan"); //The model name will be custom later.. readyList[i]->GetClient()->Send(p); }