diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index f1474eed..109308a1 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -47,10 +47,10 @@ bool GameState::Init(Oyster::Network::NetworkClient* nwClient) GameState::gameStateState GameState::LoadGame() { Oyster::Graphics::Definitions::Pointlight plight; - plight.Pos = Oyster::Math::Float3(0,3,0); - plight.Color = Oyster::Math::Float3(0,1,0); - plight.Radius = 5; - plight.Bright = 2; + plight.Pos = Oyster::Math::Float3(0,8,8); + plight.Color = Oyster::Math::Float3(1,1,1); + plight.Radius = 20; + plight.Bright = 0.5; Oyster::Graphics::API::AddLight(plight); LoadModels(L"map"); InitCamera(Oyster::Math::Float3(0,0,5.4f)); @@ -264,7 +264,7 @@ void GameState::Protocol( ObjPos* pos ) world[i] = pos->worldPos[i]; } - for (int i = 0; i < privData->object.size(); i++) + for (unsigned int i = 0; i < privData->object.size(); i++) { if(privData->object[i]->GetId() == pos->object_ID) { diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp index 69e3504a..89d8b1b7 100644 --- a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp @@ -43,7 +43,7 @@ bool LobbyState::LoadModels(std::wstring file) plight.Pos = Oyster::Math::Float3(-2,3,0); plight.Color = Oyster::Math::Float3(0,1,0); plight.Radius = 10; - plight.Bright = 3; + plight.Bright = 1; Oyster::Graphics::API::AddLight(plight); // open file // read file diff --git a/Code/Game/DanBiasServer/GameSession/GameSession_Events.cpp b/Code/Game/DanBiasServer/GameSession/GameSession_Events.cpp index 1fa526f5..c14b8e41 100644 --- a/Code/Game/DanBiasServer/GameSession/GameSession_Events.cpp +++ b/Code/Game/DanBiasServer/GameSession/GameSession_Events.cpp @@ -63,7 +63,7 @@ namespace DanBias case protocol_Gameplay_PlayerChangeWeapon: break; - case protocol_Gameplay_PlayerDamage: + case protocol_Gameplay_ObjectDamage: break; } diff --git a/Code/Game/DanBiasServer/GameSession/GameSession_Logic.cpp b/Code/Game/DanBiasServer/GameSession/GameSession_Logic.cpp index 7c47d4a7..ddf41582 100644 --- a/Code/Game/DanBiasServer/GameSession/GameSession_Logic.cpp +++ b/Code/Game/DanBiasServer/GameSession/GameSession_Logic.cpp @@ -37,7 +37,7 @@ namespace DanBias if(GetAsyncKeyState(VK_DOWN)) { Oyster::Math::Float4x4 world = Oyster::Math::Matrix::identity; - Protocol_CreateObject p(world, 2, "../Content/crate"); + Protocol_ObjectCreate p(world, 2, "../Content/crate"); Send(p.GetProtocol()); Sleep(100); } diff --git a/Code/Game/DanBiasServer/LobbySessions/MainLobby.cpp b/Code/Game/DanBiasServer/LobbySessions/MainLobby.cpp index 9b8899ca..ffdfa62e 100644 --- a/Code/Game/DanBiasServer/LobbySessions/MainLobby.cpp +++ b/Code/Game/DanBiasServer/LobbySessions/MainLobby.cpp @@ -104,7 +104,7 @@ namespace DanBias void MainLobby::SendUpdate() { //Send Lobbys - GameLogic::Protocol_LobbyUpdate(); + GameLogic::Protocol_LobbyRefresh(); } }//End namespace DanBias \ No newline at end of file diff --git a/Code/Game/GameProtocols/GameplayProtocols.h b/Code/Game/GameProtocols/GameplayProtocols.h index b595ce36..8ffcd827 100644 --- a/Code/Game/GameProtocols/GameplayProtocols.h +++ b/Code/Game/GameProtocols/GameplayProtocols.h @@ -7,57 +7,7 @@ namespace GameLogic { - struct Protocol_GameplayInitiateSession :public Oyster::Network::CustomProtocolObject - { - struct SessionInitData - { - int id; - int type; - //std::string text; - }; - std::vector element; - Protocol_GameplayInitiateSession() - { - this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_Initiate; - this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short; - } - Protocol_GameplayInitiateSession(Oyster::Network::CustomNetProtocol& p) - { - int size = p[1].value.netInt; - for (int i = 0; i < size; i++) - { - SessionInitData d = { p[i+2].value.netInt, p[i+3].value.netInt /*, p[i+4].value.netCharPtr */ }; - element.push_back(d); - } - } - void Add(int id, int type, std::string text) - { - SessionInitData d = { id, type /*, text*/ }; - element.push_back(d); - } - Oyster::Network::CustomNetProtocol* GetProtocol() override - { - //Store the elements count - this->protocol[1].value = element.size(); - this->protocol[1].type = Oyster::Network::NetAttributeType_Int; - - for (unsigned int i = 0; i < element.size(); i+=3) - { - this->protocol[i+2].value = element[i].id; - this->protocol[i+3].value = element[i].type; - //element[i].text.copy(this->protocol[i+4].value.netCharPtr, element[i].text.size()); - - this->protocol[i+2].type = Oyster::Network::NetAttributeType_Int; - this->protocol[i+3].type = Oyster::Network::NetAttributeType_Int; - //this->protocol[i+4].type = Oyster::Network::NetAttributeType_CharArray; - } - return &protocol; - } - - private: - Oyster::Network::CustomNetProtocol protocol; - }; } #endif // !GAMEPROTOCOLS_GAMEPLAYPROTOCOLS_H diff --git a/Code/Game/GameProtocols/LobbyProtocols.h b/Code/Game/GameProtocols/LobbyProtocols.h index 71e6e3b6..ae175691 100644 --- a/Code/Game/GameProtocols/LobbyProtocols.h +++ b/Code/Game/GameProtocols/LobbyProtocols.h @@ -9,6 +9,13 @@ #include #include "ProtocolIdentificationID.h" +//#define protocol_Lobby_CreateGame 200 +//#define protocol_Lobby_StartGame 201 +//#define protocol_Lobby_JoinGame 202 +//#define protocol_Lobby_JoinLobby 203 +//#define protocol_Lobby_LeaveLobby 204 +//#define protocol_Lobby_Refresh 205 + namespace GameLogic { struct Protocol_LobbyCreateGame :public Oyster::Network::CustomProtocolObject @@ -40,13 +47,13 @@ namespace GameLogic Oyster::Network::CustomNetProtocol protocol; }; - struct Protocol_LobbyJoinGame :public Oyster::Network::CustomProtocolObject + struct Protocol_LobbyStartGame :public Oyster::Network::CustomProtocolObject { char gameId; - Protocol_LobbyJoinGame() + Protocol_LobbyStartGame() { - this->protocol[protocol_INDEX_ID].value = protocol_Lobby_JoinGame; + this->protocol[protocol_INDEX_ID].value = protocol_Lobby_StartGame; this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short; this->protocol[1].type = Oyster::Network::NetAttributeType_Char; @@ -61,13 +68,13 @@ namespace GameLogic Oyster::Network::CustomNetProtocol protocol; }; - struct Protocol_LobbyStartGame :public Oyster::Network::CustomProtocolObject + struct Protocol_LobbyJoinGame :public Oyster::Network::CustomProtocolObject { char gameId; - Protocol_LobbyStartGame() + Protocol_LobbyJoinGame() { - this->protocol[protocol_INDEX_ID].value = protocol_Lobby_StartGame; + this->protocol[protocol_INDEX_ID].value = protocol_Lobby_JoinGame; this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short; this->protocol[1].type = Oyster::Network::NetAttributeType_Char; @@ -125,7 +132,7 @@ namespace GameLogic Oyster::Network::CustomNetProtocol protocol; }; - struct Protocol_LobbyUpdate :public Oyster::Network::CustomProtocolObject + struct Protocol_LobbyRefresh :public Oyster::Network::CustomProtocolObject { struct LobbyUpdateData { @@ -134,14 +141,14 @@ namespace GameLogic }; int count; LobbyUpdateData* data; - Protocol_LobbyUpdate() + Protocol_LobbyRefresh() { - this->protocol[protocol_INDEX_ID].value = protocol_Lobby_LeaveLobby; + this->protocol[protocol_INDEX_ID].value = protocol_Lobby_Refresh; this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short; this->protocol[1].type = Oyster::Network::NetAttributeType_Int; } - Protocol_LobbyUpdate( Oyster::Network::CustomNetProtocol* p ) + Protocol_LobbyRefresh( Oyster::Network::CustomNetProtocol* p ) { count = (*p)[1].value.netInt; data = new LobbyUpdateData[count]; @@ -150,7 +157,7 @@ namespace GameLogic //data[i].mapName = (*p)[i].value. } } - ~Protocol_LobbyUpdate() + ~Protocol_LobbyRefresh() { delete [] data; data = 0; diff --git a/Code/Game/GameProtocols/ObjectProtocols.h b/Code/Game/GameProtocols/ObjectProtocols.h index e52a4d2f..31452d68 100644 --- a/Code/Game/GameProtocols/ObjectProtocols.h +++ b/Code/Game/GameProtocols/ObjectProtocols.h @@ -4,14 +4,99 @@ #include #include "ProtocolIdentificationID.h" +//protocol_Gameplay_PlayerMovement 300 +//protocol_Gameplay_PlayerMouseMovement 301 +//protocol_Gameplay_PlayerChangeWeapon 302 + +//#define protocol_Gameplay_ObjectPickup 303 +//#define protocol_Gameplay_ObjectDamage 304 +//#define protocol_Gameplay_ObjectPosition 305 +//#define protocol_Gameplay_ObjectEnabled 306 +//#define protocol_Gameplay_ObjectDisabled 307 +//#define protocol_Gameplay_ObjectCreate 308 namespace GameLogic { + struct Protocol_ObjectPickup :public Oyster::Network::CustomProtocolObject + { + int object_ID; + short pickup_ID; + + Protocol_ObjectPickup() + { + this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_ObjectPickup; + this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short; + + this->protocol[1].type = Oyster::Network::NetAttributeType_Int; + this->protocol[2].type = Oyster::Network::NetAttributeType_Short; + + object_ID = -1; + pickup_ID = -1; + } + Protocol_ObjectPickup(int objectID, short pickupID) + { + this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_ObjectPosition; + this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short; + + this->protocol[1].type = Oyster::Network::NetAttributeType_Int; + this->protocol[2].type = Oyster::Network::NetAttributeType_Short; + + object_ID = objectID; + pickup_ID = pickupID; + + } + Oyster::Network::CustomNetProtocol* GetProtocol() override + { + this->protocol[1].value = object_ID; + this->protocol[2].value = pickup_ID; + return &protocol; + } + + private: + Oyster::Network::CustomNetProtocol protocol; + }; + + struct Protocol_ObjectDamage :public Oyster::Network::CustomProtocolObject + { + int object_ID; + float health; //Precentage% + + Protocol_ObjectDamage() + { + this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_ObjectDamage; + this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short; + + this->protocol[1].type = Oyster::Network::NetAttributeType_Int; + this->protocol[2].type = Oyster::Network::NetAttributeType_Float; + + object_ID = -1; + health = 0.0f; + } + Protocol_ObjectDamage(int id, float hp) + { + this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_ObjectDamage; + this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short; + + this->protocol[2].type = Oyster::Network::NetAttributeType_Float; + + object_ID = id; + health = hp; + } + Oyster::Network::CustomNetProtocol* GetProtocol() override + { + this->protocol[1].value = object_ID; + this->protocol[2].value = health; + return &protocol; + } + + private: + Oyster::Network::CustomNetProtocol protocol; + }; + struct Protocol_ObjectPosition :public Oyster::Network::CustomProtocolObject { int object_ID; float worldMatrix[16]; - // look at dir Protocol_ObjectPosition() { @@ -60,7 +145,6 @@ namespace GameLogic { int object_ID; float worldMatrix[16]; - // look at dir Protocol_ObjectEnable() { @@ -116,6 +200,17 @@ namespace GameLogic this->protocol[1].type = Oyster::Network::NetAttributeType_Int; this->protocol[2].type = Oyster::Network::NetAttributeType_Float; } + Protocol_ObjectDisable(int id, float time) + { + this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_ObjectDisabled; + this->protocol[protocol_INDEX_ID].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; + } Oyster::Network::CustomNetProtocol* GetProtocol() override { this->protocol[1].value = object_ID; @@ -127,14 +222,13 @@ namespace GameLogic Oyster::Network::CustomNetProtocol protocol; }; - struct Protocol_CreateObject :public Oyster::Network::CustomProtocolObject + struct Protocol_ObjectCreate :public Oyster::Network::CustomProtocolObject { int object_ID; - char *path; + char *name; float worldMatrix[16]; - - Protocol_CreateObject() + Protocol_ObjectCreate() { this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_ObjectCreate; this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short; @@ -147,7 +241,7 @@ namespace GameLogic this->protocol[i].type = Oyster::Network::NetAttributeType_Float; } } - Protocol_CreateObject(float m[16], int id, char *path) + Protocol_ObjectCreate(float m[16], int id, char *path) { this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_ObjectCreate; this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Int; @@ -161,14 +255,14 @@ namespace GameLogic } object_ID = id; - this->path = path; + this->name = path; memcpy(&worldMatrix[0], &m[0], sizeof(float)*16); } Oyster::Network::CustomNetProtocol* GetProtocol() override { this->protocol[1].value = object_ID; - this->protocol[2].value = path; + this->protocol[2].value = name; this->protocol[3].value = worldMatrix[0]; this->protocol[4].value = worldMatrix[1]; this->protocol[5].value = worldMatrix[2]; diff --git a/Code/Game/GameProtocols/PlayerProtocols.h b/Code/Game/GameProtocols/PlayerProtocols.h index eb89b1c6..36ccf497 100644 --- a/Code/Game/GameProtocols/PlayerProtocols.h +++ b/Code/Game/GameProtocols/PlayerProtocols.h @@ -124,7 +124,7 @@ namespace GameLogic Protocol_PlayerDamage() { - this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_PlayerDamage; + this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_ObjectDamage; this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short; this->protocol[1].type = Oyster::Network::NetAttributeType_Int; @@ -151,7 +151,7 @@ namespace GameLogic Protocol_PlayerPickup() { - this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_PlayerPickup; + this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_ObjectPickup; this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short; this->protocol[1].type = Oyster::Network::NetAttributeType_Int; diff --git a/Code/Game/GameProtocols/ProtocolIdentificationID.h b/Code/Game/GameProtocols/ProtocolIdentificationID.h index a48d5594..5293093b 100644 --- a/Code/Game/GameProtocols/ProtocolIdentificationID.h +++ b/Code/Game/GameProtocols/ProtocolIdentificationID.h @@ -15,46 +15,47 @@ /***********************************/ /********* RESERVERD PROTOCOLS ***************************************************************************************************/ -/********** [ 0 - 100 ] *********/ +/********** [ 0 - 99 ] *********/ #define protocol_RESERVED_MIN 0 #define protocol_RESERVED_MAX 99 /***********************************/ /********* GENERAL PROTOCOLS ***************************************************************************************************/ -/***********[ 100 - 200 ]***********/ +/***********[ 100 - 199 ]***********/ #define protocol_GeneralMIN 100 #define protocol_General_Status 100 #define protocol_General_Text 101 +#define protocol_General_Disconnect 102 +#define protocol_General_Login 110 #define protocol_GeneralMAX 199 /***********************************/ /********* LOBBY PROTOCOLS ***************************************************************************************************/ -/***********[ 200 - 300 ]***********/ +/***********[ 200 - 299 ]***********/ #define protocol_LobbyMIN 200 #define protocol_Lobby_CreateGame 200 -#define protocol_Lobby_JoinGame 201 -#define protocol_Lobby_StartGame 202 +#define protocol_Lobby_StartGame 201 +#define protocol_Lobby_JoinGame 202 #define protocol_Lobby_JoinLobby 203 #define protocol_Lobby_LeaveLobby 204 -#define protocol_Lobby_CreateGameLobby 205 +#define protocol_Lobby_Refresh 205 #define protocol_LobbyMAX 299 /***********************************/ /********* GAMEPLAY PROTOCOLS ***************************************************************************************************/ -/***********[ 300 - 400 ]***********/ +/***********[ 300 - 399 ]***********/ #define protocol_GameplayMIN 300 #define protocol_Gameplay_PlayerMovement 300 #define protocol_Gameplay_PlayerMouseMovement 301 #define protocol_Gameplay_PlayerChangeWeapon 302 -#define protocol_Gameplay_PlayerDamage 303 -#define protocol_Gameplay_PlayerPickup 304 +#define protocol_Gameplay_ObjectPickup 303 +#define protocol_Gameplay_ObjectDamage 304 #define protocol_Gameplay_ObjectPosition 305 #define protocol_Gameplay_ObjectEnabled 306 #define protocol_Gameplay_ObjectDisabled 307 #define protocol_Gameplay_ObjectCreate 308 -#define protocol_Gameplay_Initiate 309 #define protocol_GameplayMAX 399 diff --git a/Code/Misc/OysterCallback.h b/Code/Misc/OysterCallback.h index 258408cb..48e967ed 100644 --- a/Code/Misc/OysterCallback.h +++ b/Code/Misc/OysterCallback.h @@ -59,11 +59,11 @@ namespace Oyster switch (callbackType) { case CallbackType_Function: - value.callbackFunction(e); + if(value.callbackFunction) value.callbackFunction(e); return true; break; case CallbackType_Object: - value.callbackObject->ObjectCallback(e); + if(value.callbackObject) value.callbackObject->ObjectCallback(e); return true; break; case CallbackType_PostBox: