diff --git a/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp b/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp index b1863242..12506d3c 100644 --- a/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp +++ b/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp @@ -36,11 +36,15 @@ void Camera_FPSV2::SetPosition( const Float3 &translation ) this->body.translation = translation; } +void Camera_FPSV2::SetRotation( const Quaternion &rotation ) +{ + this->body.rotation = rotation; + this->head.SetRotation( rotation * Rotation(this->pitchUp, this->GetNormalOf(Float3::standard_unit_x) ) ); +} + void Camera_FPSV2::SetAngular( const Float3 &axis ) { - this->body.rotation = Rotation( axis ); - this->head.SetRotation( this->body.rotation ); - this->pitchUp = 0.0f; + this->SetRotation( Rotation(axis) ); } void Camera_FPSV2::SetProjection( const Float4x4 &matrix ) diff --git a/Code/Game/GameClient/GameClientState/Camera_FPSV2.h b/Code/Game/GameClient/GameClientState/Camera_FPSV2.h index 968053c7..7f66b185 100644 --- a/Code/Game/GameClient/GameClientState/Camera_FPSV2.h +++ b/Code/Game/GameClient/GameClientState/Camera_FPSV2.h @@ -14,6 +14,7 @@ public: void SetHeadOffset( const ::Oyster::Math::Float3 &translation ); void SetPosition( const ::Oyster::Math::Float3 &translation ); + void SetRotation( const ::Oyster::Math::Quaternion &rotation ); void SetAngular( const ::Oyster::Math::Float3 &axis ); void SetProjection( const ::Oyster::Math::Float4x4 &matrix ); void SetOrthographicProjection( ::Oyster::Math::Float width, ::Oyster::Math::Float height, ::Oyster::Math::Float nearClip, ::Oyster::Math::Float farClip ); diff --git a/Code/Game/GameClient/GameClientState/GameClientState.cpp b/Code/Game/GameClient/GameClientState/GameClientState.cpp index dab88b2e..add8c15b 100644 --- a/Code/Game/GameClient/GameClientState/GameClientState.cpp +++ b/Code/Game/GameClient/GameClientState/GameClientState.cpp @@ -3,9 +3,14 @@ using namespace DanBias::Client; using namespace ::Oyster::Network; +const GameClientState::NetEvent GameClientState::event_processed = GameClientState::NetEvent(); + GameClientState::GameClientState() {} GameClientState::~GameClientState() {} -void GameClientState::DataRecieved( NetEvent e ) -{ /* do nothing */ } \ No newline at end of file +const GameClientState::NetEvent & GameClientState::DataRecieved( const GameClientState::NetEvent &message ) +{ + /* do nothing */ + return message; +} \ No newline at end of file diff --git a/Code/Game/GameClient/GameClientState/GameClientState.h b/Code/Game/GameClient/GameClientState/GameClientState.h index 3822c7b0..9891a16c 100644 --- a/Code/Game/GameClient/GameClientState/GameClientState.h +++ b/Code/Game/GameClient/GameClientState/GameClientState.h @@ -22,7 +22,9 @@ namespace DanBias { namespace Client ClientState_Quit }; - public: + typedef ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> NetEvent; + static const NetEvent event_processed; + GameClientState(); virtual ~GameClientState(); virtual bool Init( SharedStateContent &shared ) = 0; @@ -31,7 +33,11 @@ namespace DanBias { namespace Client virtual bool Release() = 0; virtual void ChangeState( ClientState next ) = 0; - virtual void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e ); + /****************************************************************** + * @param message of the event + * @return message or GameClientState::event_processed. + ******************************************************************/ + virtual const NetEvent & DataRecieved( const NetEvent &message ); }; } } diff --git a/Code/Game/GameClient/GameClientState/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp index 7118191e..bfd15532 100644 --- a/Code/Game/GameClient/GameClientState/GameState.cpp +++ b/Code/Game/GameClient/GameClientState/GameState.cpp @@ -2,7 +2,7 @@ #include "DllInterfaces/GFXAPI.h" #include #include "NetworkClient.h" -#include "Camera_FPS.h" +#include "Camera_FPSV2.h" #include #include "C_obj/C_Player.h" @@ -39,7 +39,7 @@ struct GameState::MyData bool key_Reload_Shaders; C_Player player; - Camera_FPS camera; + Camera_FPSV2 camera; int myId; @@ -146,7 +146,8 @@ bool GameState::Render() auto dynamicObject = this->privData->dynamicObjects->begin(); for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject ) { - dynamicObject->second->Render(); + if( dynamicObject->second ) + dynamicObject->second->Render(); } Oyster::Graphics::API::EndFrame(); @@ -311,13 +312,22 @@ void GameState::ReadKeyInput() // TODO: implement sub-menu } -void GameState::DataRecieved( NetEvent e ) +const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState::NetEvent &message ) { - CustomNetProtocol data = e.args.data.protocol; - short ID = data[0].value.netShort; // fetching the id data. - + if( message.args.type == NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend ) + { // TODO: Reconnect + const char *breakpoint = "temp trap"; + this->privData->nwClient->Disconnect(); + this->ChangeState( GameClientState::ClientState_Main ); + } + + // fetching the id data. + short ID = message.args.data.protocol[0].value.netShort; + if( ProtocolIsGameplay(ID) ) { + CustomNetProtocol data = message.args.data.protocol; + switch(ID) { case protocol_Gameplay_ObjectPickup: break; /** @todo TODO: implement */ @@ -333,13 +343,13 @@ void GameState::DataRecieved( NetEventprivData->dynamicObjects)[decoded.object_ID]->setPos( decoded.position ); } - break; + return GameClientState::event_processed; case protocol_Gameplay_ObjectScale: { Protocol_ObjectScale decoded(data); (*this->privData->dynamicObjects)[decoded.object_ID]->setScale( decoded.scale ); } - break; + return GameClientState::event_processed; case protocol_Gameplay_ObjectRotation: { Protocol_ObjectRotation decoded(data); @@ -347,11 +357,11 @@ void GameState::DataRecieved( NetEventprivData->myId == decoded.object_ID ) - this->privData->camera.SetAngular( AngularAxis(rotation) ); + this->privData->camera.SetRotation( rotation ); (*this->privData->dynamicObjects)[decoded.object_ID]->setRot( rotation ); } - break; + return GameClientState::event_processed; case protocol_Gameplay_ObjectPositionRotation: { Protocol_ObjectPositionRotation decoded(data); @@ -362,14 +372,17 @@ void GameState::DataRecieved( NetEventprivData->myId == decoded.object_ID ) { this->privData->camera.SetPosition( position ); - this->privData->camera.SetAngular( AngularAxis(rotation) ); + this->privData->camera.SetRotation( rotation ); } C_DynamicObj *object = (*this->privData->dynamicObjects)[decoded.object_ID]; - object->setPos( position ); - object->setRot( rotation ); + if( object ) + { + object->setPos( position ); + object->setRot( rotation ); + } } - break; + return GameClientState::event_processed; case protocol_Gameplay_ObjectEnabled: break; /** @todo TODO: implement */ case protocol_Gameplay_ObjectDisabled: { @@ -382,7 +395,7 @@ void GameState::DataRecieved( NetEventprivData->dynamicObjects->erase( object ); } } - break; + return GameClientState::event_processed; case protocol_Gameplay_ObjectCreate: { Protocol_ObjectCreate decoded(data); @@ -403,13 +416,13 @@ void GameState::DataRecieved( NetEventprivData->dynamicObjects)[decoded.object_ID] = object; } - break; + return GameClientState::event_processed; case protocol_Gameplay_ObjectCreatePlayer: { Protocol_ObjectCreatePlayer decoded(data); this->InitiatePlayer( decoded.object_ID, decoded.meshName, decoded.position, decoded.rotationQ, decoded.scale, decoded.owner ); } - break; + return GameClientState::event_processed; case protocol_Gameplay_ObjectJoinTeam: break; /** @todo TODO: implement */ case protocol_Gameplay_ObjectLeaveTeam: break; /** @todo TODO: implement */ case protocol_Gameplay_ObjectWeaponCooldown: break; /** @todo TODO: implement */ @@ -428,4 +441,6 @@ void GameState::DataRecieved( NetEvent e ); + const NetEvent & DataRecieved( const NetEvent &message ); private: struct MyData; diff --git a/Code/Game/GameClient/GameClientState/LanMenuState.cpp b/Code/Game/GameClient/GameClientState/LanMenuState.cpp index 6d3d991b..11ca95da 100644 --- a/Code/Game/GameClient/GameClientState/LanMenuState.cpp +++ b/Code/Game/GameClient/GameClientState/LanMenuState.cpp @@ -60,7 +60,8 @@ bool LanMenuState::Init( SharedStateContent &shared ) // create guiElements this->privData->connectIP = new TextField( L"color_white.png", Float4(1.0f), Float4(0.0f), this, Float3(0.5f, 0.3f, 0.5f), Float2(0.8f, 0.09f), ResizeAspectRatio_None ); this->privData->connectIP->ReserveLines( 1 ); - this->privData->connectIP->AppendText( L"127.0.0.1" ); + //this->privData->connectIP->AppendText( L"127.0.0.1" ); + this->privData->connectIP->AppendText( L"194.47.150.206" ); // HACK: connecting to Dennis's server this->privData->connectIP->SetFontHeight( 0.08f ); this->privData->connectIP->SetLineSpacing( 0.005f ); this->privData->connectIP->SetTopAligned(); diff --git a/Code/Game/GameClient/GameClientState/LobbyAdminState.cpp b/Code/Game/GameClient/GameClientState/LobbyAdminState.cpp index 070d8b48..43419e88 100644 --- a/Code/Game/GameClient/GameClientState/LobbyAdminState.cpp +++ b/Code/Game/GameClient/GameClientState/LobbyAdminState.cpp @@ -112,10 +112,10 @@ void LobbyAdminState::ChangeState( ClientState next ) using namespace ::Oyster::Network; -void LobbyAdminState::DataRecieved( NetEvent e ) +const GameClientState::NetEvent & LobbyAdminState::DataRecieved( const GameClientState::NetEvent &message ) { - CustomNetProtocol data = e.args.data.protocol; - short ID = data[0].value.netShort; // fetching the id data. + // fetching the id data. + short ID = message.args.data.protocol[0].value.netShort; // Block irrelevant messages. if( ProtocolIsLobby(ID) ) @@ -141,6 +141,7 @@ void LobbyAdminState::DataRecieved( NetEvent& e ) diff --git a/Code/Game/GameClient/GameClientState/LobbyAdminState.h b/Code/Game/GameClient/GameClientState/LobbyAdminState.h index 49ae9274..7e201e94 100644 --- a/Code/Game/GameClient/GameClientState/LobbyAdminState.h +++ b/Code/Game/GameClient/GameClientState/LobbyAdminState.h @@ -29,8 +29,8 @@ namespace DanBias bool Render(); bool Release(); void ChangeState( ClientState next ); - void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e ); - + const NetEvent & DataRecieved( const NetEvent &message ); + private: struct MyData; ::Utility::DynamicMemory::UniquePointer privData; diff --git a/Code/Game/GameClient/GameClientState/LobbyState.cpp b/Code/Game/GameClient/GameClientState/LobbyState.cpp index a6d03527..0b117016 100644 --- a/Code/Game/GameClient/GameClientState/LobbyState.cpp +++ b/Code/Game/GameClient/GameClientState/LobbyState.cpp @@ -112,10 +112,10 @@ void LobbyState::ChangeState( ClientState next ) using namespace ::Oyster::Network; -void LobbyState::DataRecieved( NetEvent e ) +const GameClientState::NetEvent & LobbyState::DataRecieved( const GameClientState::NetEvent &message ) { - CustomNetProtocol data = e.args.data.protocol; - short ID = data[0].value.netShort; // fetching the id data. + // fetching the id data. + short ID = message.args.data.protocol[0].value.netShort; // Block irrelevant messages. if( ProtocolIsLobby(ID) ) @@ -141,6 +141,8 @@ void LobbyState::DataRecieved( NetEvent& e ) diff --git a/Code/Game/GameClient/GameClientState/LobbyState.h b/Code/Game/GameClient/GameClientState/LobbyState.h index 694aaa38..496c54ed 100644 --- a/Code/Game/GameClient/GameClientState/LobbyState.h +++ b/Code/Game/GameClient/GameClientState/LobbyState.h @@ -31,7 +31,7 @@ namespace DanBias bool Render(); bool Release(); void ChangeState( ClientState next ); - void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e ); + const NetEvent & DataRecieved( const NetEvent &message ); private: struct MyData; diff --git a/Code/Game/GameClient/GameClientState/NetLoadState.cpp b/Code/Game/GameClient/GameClientState/NetLoadState.cpp index d120cac2..29906d77 100644 --- a/Code/Game/GameClient/GameClientState/NetLoadState.cpp +++ b/Code/Game/GameClient/GameClientState/NetLoadState.cpp @@ -90,16 +90,25 @@ void NetLoadState::ChangeState( ClientState next ) this->privData->nextState = next; } -void NetLoadState::DataRecieved( NetEvent e ) +const GameClientState::NetEvent & NetLoadState::DataRecieved( const GameClientState::NetEvent &message ) { // fetching the id data. - short ID = e.args.data.protocol[0].value.netShort; + short ID = message.args.data.protocol[0].value.netShort; - if( ID == protocol_Lobby_CreateGame && !this->privData->loading ) + if( ID == protocol_Lobby_CreateGame ) { - this->LoadGame( Protocol_LobbyCreateGame(e.args.data.protocol).mapName ); - this->ChangeState( ClientState_Game ); - this->privData->loading = false; + if( !this->privData->loading ) + { + this->LoadGame( Protocol_LobbyCreateGame(message.args.data.protocol).mapName ); + this->ChangeState( ClientState_Game ); + this->privData->loading = false; + } + return GameClientState::event_processed; + } + else + { // HACK: Debug trap + const char *breakPoint = "Being greedy."; + return message; } } @@ -107,7 +116,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) { this->privData->loading = true; - LevelLoader loader; + LevelLoader loader( "..\\Content\\Worlds\\" ); auto objects = loader.LoadLevel( fileName ); auto object = objects.begin(); ObjectTypeHeader *oth; diff --git a/Code/Game/GameClient/GameClientState/NetLoadState.h b/Code/Game/GameClient/GameClientState/NetLoadState.h index ea9f9f6a..16e32867 100644 --- a/Code/Game/GameClient/GameClientState/NetLoadState.h +++ b/Code/Game/GameClient/GameClientState/NetLoadState.h @@ -21,7 +21,7 @@ namespace DanBias bool Release(); void ChangeState( ClientState next ); - void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e ); + const NetEvent & DataRecieved( const NetEvent &message ); private: struct MyData; diff --git a/Code/Game/GameLogic/Game.cpp b/Code/Game/GameLogic/Game.cpp index 900799e3..ba294349 100644 --- a/Code/Game/GameLogic/Game.cpp +++ b/Code/Game/GameLogic/Game.cpp @@ -76,14 +76,12 @@ Game::PlayerData* Game::CreatePlayer() return this->players[i]; } -Game::LevelData* Game::CreateLevel() +Game::LevelData* Game::CreateLevel(const wchar_t mapName[255]) { if(this->level) return this->level; this->level = new LevelData(); - //this->level->level->InitiateLevel(1000); - this->level->level->InitiateLevel("../Content/Worlds/ccc.bias"); - + this->level->level->InitiateLevel(mapName); return this->level; } diff --git a/Code/Game/GameLogic/Game.h b/Code/Game/GameLogic/Game.h index 9c21ec1b..6623756f 100644 --- a/Code/Game/GameLogic/Game.h +++ b/Code/Game/GameLogic/Game.h @@ -72,7 +72,7 @@ namespace GameLogic void GetAllPlayerPositions() const override; PlayerData* CreatePlayer() override; - LevelData* CreateLevel() override; + LevelData* CreateLevel(const wchar_t mapName[255] ) override; void CreateTeam() override; bool NewFrame() override; void SetFPS( int FPS ) override; diff --git a/Code/Game/GameLogic/GameAPI.h b/Code/Game/GameLogic/GameAPI.h index 3325115f..65d606d8 100644 --- a/Code/Game/GameLogic/GameAPI.h +++ b/Code/Game/GameLogic/GameAPI.h @@ -139,7 +139,7 @@ namespace GameLogic /** Creates a level * @return Returns a ILevelData container to use for level manipulation */ - virtual ILevelData* CreateLevel( void ) = 0; + virtual ILevelData* CreateLevel( const wchar_t mapName[255] ) = 0; /** Creates a team * @return ? diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 4d3cf703..4106dabf 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -197,12 +197,16 @@ ICustomBody* Level::InitRigidBodySphere( const ObjectHeader* obj) rigidBody = API::Instance().AddCollisionSphere( rigidBodyRadius , rigidWorldRotation , rigidWorldPos , rigidBodyMass, obj->boundingVolume.sphere.restitutionCoeff , obj->boundingVolume.sphere.frictionCoeffStatic , obj->boundingVolume.sphere.frictionCoeffDynamic); return rigidBody; } -void Level::InitiateLevel(std::string levelPath) +bool Level::InitiateLevel(std::wstring levelPath) { LevelLoader ll; + ll.SetFolderPath(L"..\\Content\\Worlds\\"); std::vector> objects; objects = ll.LoadLevel(levelPath); + if(objects.size() == 0) + return false; + API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0)); API::Instance().SetGravity(200); int objCount = objects.size(); @@ -332,8 +336,9 @@ void Level::InitiateLevel(std::string levelPath) break; } } + return true; } -void Level::InitiateLevel(float radius) +bool Level::InitiateLevel(float radius) { API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0)); API::Instance().SetGravity(200); @@ -396,6 +401,7 @@ void Level::InitiateLevel(float radius) ICustomBody* rigidBody_Jumppad = API::Instance().AddCollisionBox(Oyster::Math::Float3(1.0f, 1.0f, 1.0f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(4.0f, 600.3f, 0.0f), 5.0f, 0.5f, 0.8f, 0.6f); this->staticObjects.Push(new JumpPad(rigidBody_Jumppad, ObjectSpecialType_JumpPad,idCount++ ,Oyster::Math::Float3(0,2000,0))); + return true; } void Level::AddPlayerToTeam(Player *player, int teamID) diff --git a/Code/Game/GameLogic/Level.h b/Code/Game/GameLogic/Level.h index 623d04b2..14269c73 100644 --- a/Code/Game/GameLogic/Level.h +++ b/Code/Game/GameLogic/Level.h @@ -30,8 +30,8 @@ namespace GameLogic * Initiates a level for players to play on * @param levelPath: Path to a file that contains all information on the level ********************************************************/ - void InitiateLevel(std::string levelPath); - void InitiateLevel(float radius); + bool InitiateLevel(std::wstring levelPath); + bool InitiateLevel(float radius); Oyster::Physics::ICustomBody* InitRigidBodyCube( const ObjectHeader* obj); Oyster::Physics::ICustomBody* InitRigidBodySphere( const ObjectHeader* obj); diff --git a/Code/Game/GameLogic/LevelLoader/LevelLoader.cpp b/Code/Game/GameLogic/LevelLoader/LevelLoader.cpp index 8fe880f3..205da712 100644 --- a/Code/Game/GameLogic/LevelLoader/LevelLoader.cpp +++ b/Code/Game/GameLogic/LevelLoader/LevelLoader.cpp @@ -11,17 +11,17 @@ using namespace GameLogic::LevelFileLoader; struct LevelLoader::PrivData { LevelParser parser; - std::string folderPath; + std::wstring folderPath; }; LevelLoader::LevelLoader() : pData(new PrivData) { //standard path - pData->folderPath = ""; + pData->folderPath = L""; } -LevelLoader::LevelLoader(std::string folderPath) +LevelLoader::LevelLoader(std::wstring folderPath) : pData(new PrivData) { pData->folderPath = folderPath; @@ -31,22 +31,22 @@ LevelLoader::~LevelLoader() { } -std::vector> LevelLoader::LoadLevel(std::string fileName) +std::vector> LevelLoader::LoadLevel(std::wstring fileName) { return pData->parser.Parse(pData->folderPath + fileName); } -LevelMetaData LevelLoader::LoadLevelHeader(std::string fileName) +LevelMetaData LevelLoader::LoadLevelHeader(std::wstring fileName) { return pData->parser.ParseHeader(pData->folderPath + fileName); } -std::string LevelLoader::GetFolderPath() +std::wstring LevelLoader::GetFolderPath() { return this->pData->folderPath; } -void LevelLoader::SetFolderPath(std::string folderPath) +void LevelLoader::SetFolderPath(std::wstring folderPath) { - + this->pData->folderPath = folderPath; } \ No newline at end of file diff --git a/Code/Game/GameLogic/LevelLoader/LevelLoader.h b/Code/Game/GameLogic/LevelLoader/LevelLoader.h index aa67c4f5..c14e2c4c 100644 --- a/Code/Game/GameLogic/LevelLoader/LevelLoader.h +++ b/Code/Game/GameLogic/LevelLoader/LevelLoader.h @@ -20,7 +20,7 @@ namespace GameLogic /*********************************************************** * Lets you set the standard folderpath for the levels ********************************************************/ - LevelLoader(std::string folderPath); + LevelLoader(std::wstring folderPath); ~LevelLoader(); /******************************************************** @@ -28,24 +28,24 @@ namespace GameLogic * @param fileName: Path/name to the level-file that you want to load. * @return: Returns all structs with objects and information about the level. ********************************************************/ - std::vector> LoadLevel(std::string fileName); + std::vector> LoadLevel(std::wstring fileName); /******************************************************** * Just for fast access for the meta information about the level. * @param fileName: Path to the level-file that you want to load. * @return: Returns the meta information about the level. ********************************************************/ - LevelMetaData LoadLevelHeader(std::string fileName); //. + LevelMetaData LoadLevelHeader(std::wstring fileName); //. /*********************************************************** * @return: Returns the current standard folder path ********************************************************/ - std::string GetFolderPath(); + std::wstring GetFolderPath(); /*********************************************************** * Sets the standard folder path ********************************************************/ - void SetFolderPath(std::string folderPath); + void SetFolderPath(std::wstring folderPath); private: struct PrivData; diff --git a/Code/Game/GameLogic/LevelLoader/LevelParser.cpp b/Code/Game/GameLogic/LevelLoader/LevelParser.cpp index 1e33361d..2d23f069 100644 --- a/Code/Game/GameLogic/LevelLoader/LevelParser.cpp +++ b/Code/Game/GameLogic/LevelLoader/LevelParser.cpp @@ -20,7 +20,7 @@ LevelParser::~LevelParser() { } -std::vector> LevelParser::Parse(std::string filename) +std::vector> LevelParser::Parse(std::wstring filename) { int bufferSize = 0; int counter = 0; @@ -32,6 +32,12 @@ std::vector> LevelParser::Parse(std::string filen Loader loader; char* buffer = (char*)loader.LoadFile(filename.c_str(), bufferSize); + // Check if file was loaded, else return empty vector + if(!buffer) + { + return std::vector>(); + } + //Read format version LevelLoaderInternal::FormatVersion levelFormatVersion; ParseObject(&buffer[counter], &levelFormatVersion, sizeof(levelFormatVersion)); @@ -215,7 +221,7 @@ std::vector> LevelParser::Parse(std::string filen } //för meta information om leveln. -LevelMetaData LevelParser::ParseHeader(std::string filename) +LevelMetaData LevelParser::ParseHeader(std::wstring filename) { int bufferSize = 0; int counter = 0; diff --git a/Code/Game/GameLogic/LevelLoader/LevelParser.h b/Code/Game/GameLogic/LevelLoader/LevelParser.h index 8f2a9150..d0cb1f03 100644 --- a/Code/Game/GameLogic/LevelLoader/LevelParser.h +++ b/Code/Game/GameLogic/LevelLoader/LevelParser.h @@ -17,10 +17,10 @@ namespace GameLogic ~LevelParser(); // - std::vector> Parse(std::string filename); + std::vector> Parse(std::wstring filename); // - LevelMetaData ParseHeader(std::string filename); + LevelMetaData ParseHeader(std::wstring filename); private: LevelLoaderInternal::FormatVersion formatVersion; diff --git a/Code/Game/GameLogic/LevelLoader/Loader.cpp b/Code/Game/GameLogic/LevelLoader/Loader.cpp index 3e15315c..19ffa0f1 100644 --- a/Code/Game/GameLogic/LevelLoader/Loader.cpp +++ b/Code/Game/GameLogic/LevelLoader/Loader.cpp @@ -9,13 +9,13 @@ using namespace GameLogic::LevelFileLoader; using namespace Oyster::Resource; using namespace std; -char* Loader::LoadFile(std::string fileName, int &size) +char* Loader::LoadFile(std::wstring fileName, int &size) { //convert from string to wstring - std::wstring temp(fileName.begin(), fileName.end()); + //std::wstring temp(fileName.begin(), fileName.end()); //convert from wstring to wchar then loads the file - char* buffer = (char*)OysterResource::LoadResource(temp.c_str(), Oyster::Resource::ResourceType::ResourceType_Byte_Raw, -1 , false); + char* buffer = (char*)OysterResource::LoadResource(fileName.c_str(), Oyster::Resource::ResourceType::ResourceType_Byte_Raw, -1 , false); size = OysterResource::GetResourceSize(buffer); return buffer; diff --git a/Code/Game/GameLogic/LevelLoader/Loader.h b/Code/Game/GameLogic/LevelLoader/Loader.h index 0433194e..6deb8900 100644 --- a/Code/Game/GameLogic/LevelLoader/Loader.h +++ b/Code/Game/GameLogic/LevelLoader/Loader.h @@ -17,7 +17,7 @@ namespace GameLogic public: Loader (){}; ~Loader(){}; - char* LoadFile(std::string fileName, int &size); + char* LoadFile(std::wstring fileName, int &size); //TODO: //Add functionality to load physicsObjects (hitboxes) diff --git a/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp b/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp index daa62752..76d7d6c3 100644 --- a/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp +++ b/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp @@ -5,6 +5,7 @@ #include "ParseFunctions.h" #include "Packing/Packing.h" #include "Loader.h" +#include "Utilities.h" #include using namespace Oyster::Packing; @@ -149,7 +150,7 @@ namespace GameLogic //Läs in filen. int fileLength = 0; Loader loader; - char* buf = loader.LoadFile("../Content/Worlds/cgf/"+ fileName, fileLength); + char* buf = loader.LoadFile(L"../Content/Worlds/cgf/" + Utility::String::StringToWstring(fileName, wstring()), fileLength); start = 0; LevelLoaderInternal::FormatVersion version; diff --git a/Code/Game/GameServer/Implementation/GameSession_General.cpp b/Code/Game/GameServer/Implementation/GameSession_General.cpp index 8b5bd8cb..933807a4 100644 --- a/Code/Game/GameServer/Implementation/GameSession_General.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_General.cpp @@ -99,7 +99,7 @@ bool GameSession::Create(GameDescription& desc, bool forceStart) } /* Create the game level */ - if(!(this->levelData = this->gameInstance.CreateLevel())) + if(!(this->levelData = this->gameInstance.CreateLevel(this->description.mapName.c_str()))) { printf("Level not created!"); return false; diff --git a/Code/Game/LanServer/StandAloneLauncher/App.config b/Code/Game/LanServer/StandAloneLauncher/App.config index 32412984..efeb1570 100644 --- a/Code/Game/LanServer/StandAloneLauncher/App.config +++ b/Code/Game/LanServer/StandAloneLauncher/App.config @@ -1,5 +1,10 @@  + + +
+ + @@ -8,4 +13,11 @@ + + + + .\..\Content\ + + + diff --git a/Code/Game/LanServer/StandAloneLauncher/Form1.Designer.cs b/Code/Game/LanServer/StandAloneLauncher/Form1.Designer.cs index bd168c3c..73ef627c 100644 --- a/Code/Game/LanServer/StandAloneLauncher/Form1.Designer.cs +++ b/Code/Game/LanServer/StandAloneLauncher/Form1.Designer.cs @@ -36,7 +36,6 @@ this.label_listenPort = new System.Windows.Forms.Label(); this.panel_serverOptions = new System.Windows.Forms.Panel(); this.panel_commands = new System.Windows.Forms.Panel(); - this.mapName = new System.Windows.Forms.TextBox(); this.timeLimit = new System.Windows.Forms.NumericUpDown(); this.gameModes = new System.Windows.Forms.ComboBox(); this.label3 = new System.Windows.Forms.Label(); @@ -52,6 +51,22 @@ this.splitter1 = new System.Windows.Forms.Splitter(); this.clientInfoBox = new System.Windows.Forms.ListBox(); this.panel_CommanArea = new System.Windows.Forms.Panel(); + this.label5 = new System.Windows.Forms.Label(); + this.mapName = new System.Windows.Forms.ComboBox(); + this.panelServerCommands = new System.Windows.Forms.Panel(); + this.buttonExecuteSend = new System.Windows.Forms.Button(); + this.panel2 = new System.Windows.Forms.Panel(); + this.comboBox1 = new System.Windows.Forms.ComboBox(); + this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.label6 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); + this.dataProtocolFields = new System.Windows.Forms.TableLayoutPanel(); + this.buttonAddNewDataField = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.buttonsAtBottom = new System.Windows.Forms.TableLayoutPanel(); ((System.ComponentModel.ISupportInitialize)(this.listenPort)).BeginInit(); this.panel_serverOptions.SuspendLayout(); this.panel_commands.SuspendLayout(); @@ -59,13 +74,20 @@ ((System.ComponentModel.ISupportInitialize)(this.nrOfClients)).BeginInit(); this.panel_clientArea.SuspendLayout(); this.panel_CommanArea.SuspendLayout(); + this.panelServerCommands.SuspendLayout(); + this.panel2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); + this.tableLayoutPanel1.SuspendLayout(); + this.dataProtocolFields.SuspendLayout(); + this.buttonsAtBottom.SuspendLayout(); this.SuspendLayout(); // // serverToggle // - this.serverToggle.Location = new System.Drawing.Point(9, 106); + this.serverToggle.Dock = System.Windows.Forms.DockStyle.Bottom; + this.serverToggle.Location = new System.Drawing.Point(0, 83); this.serverToggle.Name = "serverToggle"; - this.serverToggle.Size = new System.Drawing.Size(75, 23); + this.serverToggle.Size = new System.Drawing.Size(241, 20); this.serverToggle.TabIndex = 0; this.serverToggle.Text = "Start server"; this.serverToggle.UseVisualStyleBackColor = true; @@ -140,46 +162,40 @@ this.panel_serverOptions.Dock = System.Windows.Forms.DockStyle.Top; this.panel_serverOptions.Location = new System.Drawing.Point(0, 0); this.panel_serverOptions.Name = "panel_serverOptions"; - this.panel_serverOptions.Size = new System.Drawing.Size(200, 141); + this.panel_serverOptions.Size = new System.Drawing.Size(241, 103); this.panel_serverOptions.TabIndex = 6; // // panel_commands // - this.panel_commands.Controls.Add(this.mapName); this.panel_commands.Controls.Add(this.timeLimit); + this.panel_commands.Controls.Add(this.mapName); this.panel_commands.Controls.Add(this.gameModes); this.panel_commands.Controls.Add(this.label3); this.panel_commands.Controls.Add(this.forceStart); this.panel_commands.Controls.Add(this.label2); this.panel_commands.Controls.Add(this.label4); + this.panel_commands.Controls.Add(this.label5); this.panel_commands.Controls.Add(this.labelClientsConnected); this.panel_commands.Controls.Add(this.label1); this.panel_commands.Controls.Add(this.nrOfClients); this.panel_commands.Controls.Add(this.buttonStartGame); - this.panel_commands.Location = new System.Drawing.Point(3, 150); + this.panel_commands.Dock = System.Windows.Forms.DockStyle.Top; + this.panel_commands.Location = new System.Drawing.Point(0, 103); this.panel_commands.Name = "panel_commands"; - this.panel_commands.Size = new System.Drawing.Size(191, 202); + this.panel_commands.Size = new System.Drawing.Size(241, 188); this.panel_commands.TabIndex = 7; this.panel_commands.Visible = false; // - // mapName - // - this.mapName.Location = new System.Drawing.Point(75, 10); - this.mapName.Name = "mapName"; - this.mapName.Size = new System.Drawing.Size(113, 20); - this.mapName.TabIndex = 12; - this.mapName.Text = "2ofAll_updated.bias"; - // // timeLimit // - this.timeLimit.Location = new System.Drawing.Point(109, 94); + this.timeLimit.Location = new System.Drawing.Point(112, 89); this.timeLimit.Minimum = new decimal(new int[] { 5, 0, 0, 0}); this.timeLimit.Name = "timeLimit"; - this.timeLimit.Size = new System.Drawing.Size(68, 20); + this.timeLimit.Size = new System.Drawing.Size(123, 20); this.timeLimit.TabIndex = 11; this.timeLimit.ThousandsSeparator = true; this.timeLimit.Value = new decimal(new int[] { @@ -195,9 +211,9 @@ this.gameModes.Items.AddRange(new object[] { "Free-for-all", "Team death-match"}); - this.gameModes.Location = new System.Drawing.Point(78, 66); + this.gameModes.Location = new System.Drawing.Point(77, 61); this.gameModes.Name = "gameModes"; - this.gameModes.Size = new System.Drawing.Size(110, 21); + this.gameModes.Size = new System.Drawing.Size(158, 21); this.gameModes.TabIndex = 10; // // label3 @@ -242,11 +258,11 @@ // labelClientsConnected // this.labelClientsConnected.AutoSize = true; - this.labelClientsConnected.Location = new System.Drawing.Point(9, 149); + this.labelClientsConnected.Location = new System.Drawing.Point(131, 147); this.labelClientsConnected.Name = "labelClientsConnected"; - this.labelClientsConnected.Size = new System.Drawing.Size(104, 13); + this.labelClientsConnected.Size = new System.Drawing.Size(80, 13); this.labelClientsConnected.TabIndex = 8; - this.labelClientsConnected.Text = "Clients connected: 0"; + this.labelClientsConnected.Text = "Game clients: 0"; // // label1 // @@ -259,7 +275,7 @@ // // nrOfClients // - this.nrOfClients.Location = new System.Drawing.Point(78, 36); + this.nrOfClients.Location = new System.Drawing.Point(72, 34); this.nrOfClients.Maximum = new decimal(new int[] { 20, 0, @@ -271,7 +287,7 @@ 0, 0}); this.nrOfClients.Name = "nrOfClients"; - this.nrOfClients.Size = new System.Drawing.Size(39, 20); + this.nrOfClients.Size = new System.Drawing.Size(163, 20); this.nrOfClients.TabIndex = 7; this.nrOfClients.Value = new decimal(new int[] { 10, @@ -281,9 +297,10 @@ // // buttonStartGame // - this.buttonStartGame.Location = new System.Drawing.Point(9, 176); + this.buttonStartGame.Dock = System.Windows.Forms.DockStyle.Bottom; + this.buttonStartGame.Location = new System.Drawing.Point(0, 166); this.buttonStartGame.Name = "buttonStartGame"; - this.buttonStartGame.Size = new System.Drawing.Size(75, 23); + this.buttonStartGame.Size = new System.Drawing.Size(241, 22); this.buttonStartGame.TabIndex = 6; this.buttonStartGame.Text = "Start game"; this.buttonStartGame.UseVisualStyleBackColor = true; @@ -295,9 +312,9 @@ this.panel_clientArea.Controls.Add(this.splitter1); this.panel_clientArea.Controls.Add(this.clientInfoBox); this.panel_clientArea.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel_clientArea.Location = new System.Drawing.Point(200, 0); + this.panel_clientArea.Location = new System.Drawing.Point(241, 0); this.panel_clientArea.Name = "panel_clientArea"; - this.panel_clientArea.Size = new System.Drawing.Size(535, 616); + this.panel_clientArea.Size = new System.Drawing.Size(494, 616); this.panel_clientArea.TabIndex = 8; // // ServerInfoTextArea @@ -307,19 +324,19 @@ this.ServerInfoTextArea.Dock = System.Windows.Forms.DockStyle.Fill; this.ServerInfoTextArea.Font = new System.Drawing.Font("GulimChe", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.ServerInfoTextArea.ForeColor = System.Drawing.SystemColors.Info; - this.ServerInfoTextArea.Location = new System.Drawing.Point(0, 152); + this.ServerInfoTextArea.Location = new System.Drawing.Point(0, 269); this.ServerInfoTextArea.Name = "ServerInfoTextArea"; this.ServerInfoTextArea.ReadOnly = true; - this.ServerInfoTextArea.Size = new System.Drawing.Size(535, 464); + this.ServerInfoTextArea.Size = new System.Drawing.Size(494, 347); this.ServerInfoTextArea.TabIndex = 1; this.ServerInfoTextArea.Text = ""; // // splitter1 // this.splitter1.Dock = System.Windows.Forms.DockStyle.Top; - this.splitter1.Location = new System.Drawing.Point(0, 147); + this.splitter1.Location = new System.Drawing.Point(0, 264); this.splitter1.Name = "splitter1"; - this.splitter1.Size = new System.Drawing.Size(535, 5); + this.splitter1.Size = new System.Drawing.Size(494, 5); this.splitter1.TabIndex = 2; this.splitter1.TabStop = false; // @@ -329,19 +346,221 @@ this.clientInfoBox.FormattingEnabled = true; this.clientInfoBox.Location = new System.Drawing.Point(0, 0); this.clientInfoBox.Name = "clientInfoBox"; - this.clientInfoBox.Size = new System.Drawing.Size(535, 147); + this.clientInfoBox.Size = new System.Drawing.Size(494, 264); this.clientInfoBox.TabIndex = 0; // // panel_CommanArea // + this.panel_CommanArea.Controls.Add(this.panelServerCommands); this.panel_CommanArea.Controls.Add(this.panel_commands); this.panel_CommanArea.Controls.Add(this.panel_serverOptions); this.panel_CommanArea.Dock = System.Windows.Forms.DockStyle.Left; this.panel_CommanArea.Location = new System.Drawing.Point(0, 0); this.panel_CommanArea.Name = "panel_CommanArea"; - this.panel_CommanArea.Size = new System.Drawing.Size(200, 616); + this.panel_CommanArea.Size = new System.Drawing.Size(241, 616); this.panel_CommanArea.TabIndex = 9; // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(23, 147); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(81, 13); + this.label5.TabIndex = 8; + this.label5.Text = "Lobby clients: 0"; + // + // mapName + // + this.mapName.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.mapName.FormattingEnabled = true; + this.mapName.IntegralHeight = false; + this.mapName.Items.AddRange(new object[] { + "Set default"}); + this.mapName.Location = new System.Drawing.Point(72, 7); + this.mapName.Name = "mapName"; + this.mapName.Size = new System.Drawing.Size(163, 21); + this.mapName.TabIndex = 10; + // + // panelServerCommands + // + this.panelServerCommands.Controls.Add(this.dataProtocolFields); + this.panelServerCommands.Dock = System.Windows.Forms.DockStyle.Top; + this.panelServerCommands.Location = new System.Drawing.Point(0, 291); + this.panelServerCommands.Name = "panelServerCommands"; + this.panelServerCommands.Size = new System.Drawing.Size(241, 85); + this.panelServerCommands.TabIndex = 8; + this.panelServerCommands.Visible = false; + // + // buttonExecuteSend + // + this.buttonExecuteSend.Dock = System.Windows.Forms.DockStyle.Fill; + this.buttonExecuteSend.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.buttonExecuteSend.Location = new System.Drawing.Point(116, 0); + this.buttonExecuteSend.Margin = new System.Windows.Forms.Padding(0); + this.buttonExecuteSend.Name = "buttonExecuteSend"; + this.buttonExecuteSend.Size = new System.Drawing.Size(117, 21); + this.buttonExecuteSend.TabIndex = 0; + this.buttonExecuteSend.Text = "Send"; + this.buttonExecuteSend.UseVisualStyleBackColor = true; + // + // panel2 + // + this.panel2.Controls.Add(this.button2); + this.panel2.Controls.Add(this.textBox1); + this.panel2.Controls.Add(this.comboBox1); + this.panel2.Controls.Add(this.numericUpDown1); + this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel2.Location = new System.Drawing.Point(4, 32); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(233, 21); + this.panel2.TabIndex = 0; + // + // comboBox1 + // + this.comboBox1.Dock = System.Windows.Forms.DockStyle.Left; + this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBox1.FormattingEnabled = true; + this.comboBox1.IntegralHeight = false; + this.comboBox1.Items.AddRange(new object[] { + "netBool;", + "netChar;", + "netUChar;", + "netShort;", + "netUShort;", + "netInt;", + "netUInt;", + "netInt64;", + "netUInt64;", + "netFloat;", + "netDouble;", + "netCharPtr;"}); + this.comboBox1.Location = new System.Drawing.Point(42, 0); + this.comboBox1.Name = "comboBox1"; + this.comboBox1.Size = new System.Drawing.Size(78, 21); + this.comboBox1.TabIndex = 10; + // + // numericUpDown1 + // + this.numericUpDown1.Dock = System.Windows.Forms.DockStyle.Left; + this.numericUpDown1.Location = new System.Drawing.Point(0, 0); + this.numericUpDown1.Name = "numericUpDown1"; + this.numericUpDown1.Size = new System.Drawing.Size(42, 20); + this.numericUpDown1.TabIndex = 11; + // + // textBox1 + // + this.textBox1.Dock = System.Windows.Forms.DockStyle.Left; + this.textBox1.Location = new System.Drawing.Point(120, 0); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(64, 20); + this.textBox1.TabIndex = 12; + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single; + this.tableLayoutPanel1.ColumnCount = 3; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 35.29412F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 64.70588F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 110F)); + this.tableLayoutPanel1.Controls.Add(this.label6, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.label7, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.label8, 2, 0); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(4, 4); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 1; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 27.05882F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(233, 21); + this.tableLayoutPanel1.TabIndex = 9; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(4, 1); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(18, 13); + this.label6.TabIndex = 8; + this.label6.Text = "ID"; + this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(46, 1); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(31, 13); + this.label7.TabIndex = 8; + this.label7.Text = "Type"; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(123, 1); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(34, 13); + this.label8.TabIndex = 8; + this.label8.Text = "Value"; + // + // dataProtocolFields + // + this.dataProtocolFields.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single; + this.dataProtocolFields.ColumnCount = 1; + this.dataProtocolFields.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 21F)); + this.dataProtocolFields.Controls.Add(this.panel2, 0, 1); + this.dataProtocolFields.Controls.Add(this.tableLayoutPanel1, 0, 0); + this.dataProtocolFields.Controls.Add(this.buttonsAtBottom, 0, 2); + this.dataProtocolFields.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataProtocolFields.Location = new System.Drawing.Point(0, 0); + this.dataProtocolFields.Margin = new System.Windows.Forms.Padding(0); + this.dataProtocolFields.Name = "dataProtocolFields"; + this.dataProtocolFields.RowCount = 3; + this.dataProtocolFields.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 27F)); + this.dataProtocolFields.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 27F)); + this.dataProtocolFields.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.dataProtocolFields.Size = new System.Drawing.Size(241, 85); + this.dataProtocolFields.TabIndex = 9; + // + // buttonAddNewDataField + // + this.buttonAddNewDataField.Dock = System.Windows.Forms.DockStyle.Fill; + this.buttonAddNewDataField.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.buttonAddNewDataField.Location = new System.Drawing.Point(0, 0); + this.buttonAddNewDataField.Margin = new System.Windows.Forms.Padding(0); + this.buttonAddNewDataField.Name = "buttonAddNewDataField"; + this.buttonAddNewDataField.Size = new System.Drawing.Size(116, 21); + this.buttonAddNewDataField.TabIndex = 1; + this.buttonAddNewDataField.Text = "Add field"; + this.buttonAddNewDataField.UseVisualStyleBackColor = true; + this.buttonAddNewDataField.Click += new System.EventHandler(this.buttonAddNewDataField_Click); + // + // button2 + // + this.button2.Dock = System.Windows.Forms.DockStyle.Fill; + this.button2.FlatAppearance.BorderColor = System.Drawing.Color.Black; + this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.button2.Location = new System.Drawing.Point(184, 0); + this.button2.Margin = new System.Windows.Forms.Padding(0); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(49, 21); + this.button2.TabIndex = 0; + this.button2.Text = "remove"; + this.button2.UseVisualStyleBackColor = true; + // + // buttonsAtBottom + // + this.buttonsAtBottom.ColumnCount = 2; + this.buttonsAtBottom.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.buttonsAtBottom.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.buttonsAtBottom.Controls.Add(this.buttonAddNewDataField, 0, 0); + this.buttonsAtBottom.Controls.Add(this.buttonExecuteSend, 1, 0); + this.buttonsAtBottom.Dock = System.Windows.Forms.DockStyle.Fill; + this.buttonsAtBottom.Location = new System.Drawing.Point(4, 60); + this.buttonsAtBottom.Name = "buttonsAtBottom"; + this.buttonsAtBottom.RowCount = 1; + this.buttonsAtBottom.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.buttonsAtBottom.Size = new System.Drawing.Size(233, 21); + this.buttonsAtBottom.TabIndex = 10; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -361,6 +580,14 @@ ((System.ComponentModel.ISupportInitialize)(this.nrOfClients)).EndInit(); this.panel_clientArea.ResumeLayout(false); this.panel_CommanArea.ResumeLayout(false); + this.panelServerCommands.ResumeLayout(false); + this.panel2.ResumeLayout(false); + this.panel2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.dataProtocolFields.ResumeLayout(false); + this.buttonsAtBottom.ResumeLayout(false); this.ResumeLayout(false); } @@ -387,10 +614,25 @@ private System.Windows.Forms.NumericUpDown timeLimit; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label4; - private System.Windows.Forms.TextBox mapName; private System.Windows.Forms.CheckBox forceStart; private System.Windows.Forms.Label labelClientsConnected; private System.Windows.Forms.Panel panel_CommanArea; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.ComboBox mapName; + private System.Windows.Forms.Panel panelServerCommands; + private System.Windows.Forms.Button buttonExecuteSend; + private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.ComboBox comboBox1; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.NumericUpDown numericUpDown1; + private System.Windows.Forms.TableLayoutPanel dataProtocolFields; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.Button buttonAddNewDataField; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.TableLayoutPanel buttonsAtBottom; } } diff --git a/Code/Game/LanServer/StandAloneLauncher/Form1.cs b/Code/Game/LanServer/StandAloneLauncher/Form1.cs index 58deb2a9..8b7e9474 100644 --- a/Code/Game/LanServer/StandAloneLauncher/Form1.cs +++ b/Code/Game/LanServer/StandAloneLauncher/Form1.cs @@ -11,6 +11,7 @@ using System.Windows.Interop; using System.Runtime.InteropServices; using System.Threading; using System.Timers; +using System.IO; namespace StandAloneLauncher { @@ -18,12 +19,22 @@ namespace StandAloneLauncher { System.Windows.Interop.StandaloneGameServerCLI gameServer; bool serverIsRunning = false; + bool gameIsStarted = false; public Form1() { InitializeComponent(); + + string[] maps = Directory.GetFiles("..\\Content\\Worlds\\"); + + for (int i = 0; i < maps.Length; i++) + { + string temp = maps[i].Split('\\').Last() ; + this.mapName.Items.Add(temp); + } + this.gameModes.SelectedIndex = 0; - + this.mapName.SelectedIndex = 0; } public bool Initiate() @@ -55,6 +66,7 @@ namespace StandAloneLauncher this.serverToggle.Text = "Start server"; this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Server terminated!\n"); this.panel_commands.Visible = false; + this.panelServerCommands.Visible = false; } else { @@ -77,6 +89,7 @@ namespace StandAloneLauncher this.gameServer.ServerStart(); this.panel_commands.Visible = true; this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Server initiated!\n\tListening on port " + this.listenPort.Value.ToString() + "\n\tLocal IP: " + info.serverIp + "\n"); + this.panelServerCommands.Visible = true; } else { @@ -87,18 +100,38 @@ namespace StandAloneLauncher private void buttonStartGame_Click(object sender, EventArgs e) { - //this.gameServer.GameSetGameMode(this.gameModes.SelectedText); - this.gameServer.GameSetGameTime((int)this.timeLimit.Value); - this.gameServer.GameSetMapName(this.mapName.Text); - this.gameServer.GameSetMaxClients((int)this.nrOfClients.Value); - - if (!this.gameServer.GameStart( this.forceStart.Checked )) + if (!gameIsStarted) { - this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Failed to start the game session!\n"); + //this.gameServer.GameSetGameMode(this.gameModes.SelectedText); + this.gameServer.GameSetGameTime((int)this.timeLimit.Value); + this.gameServer.GameSetMapName(this.mapName.Text); + this.gameServer.GameSetMaxClients((int)this.nrOfClients.Value); + + if (!(gameIsStarted = this.gameServer.GameStart(this.forceStart.Checked))) + { + this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Failed to start the game session!\n"); + } + else + { + this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Game session started!\n"); + this.buttonStartGame.Text = "Stop Game"; + + this.mapName.Enabled = false; + this.nrOfClients.Enabled = false; + this.gameModes.Enabled = false; + this.timeLimit.Enabled = false; + this.forceStart.Enabled = false; + } } else { - this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Game session started!\n"); + this.gameIsStarted = false; + this.buttonStartGame.Text = "Start Game"; + this.mapName.Enabled = true; + this.nrOfClients.Enabled = true; + this.gameModes.Enabled = true; + this.timeLimit.Enabled = true; + this.forceStart.Enabled = true; } } @@ -109,5 +142,17 @@ namespace StandAloneLauncher this.gameServer.ServerStop(); } } + + private void buttonAddNewDataField_Click(object sender, EventArgs e) + { + this.dataProtocolFields.RowCount++; + this.dataProtocolFields.SetRow(this.buttonsAtBottom, this.dataProtocolFields.RowCount - 1); + + Panel p = new Panel(); + p = this.panel2; + + this.dataProtocolFields.RowStyles.Add(new RowStyle(SizeType.Absolute, 27)); + + } } } diff --git a/Code/Game/LanServer/StandAloneLauncher/Properties/Settings.Designer.cs b/Code/Game/LanServer/StandAloneLauncher/Properties/Settings.Designer.cs index 18c7c5f4..5c383ce6 100644 --- a/Code/Game/LanServer/StandAloneLauncher/Properties/Settings.Designer.cs +++ b/Code/Game/LanServer/StandAloneLauncher/Properties/Settings.Designer.cs @@ -8,23 +8,31 @@ // //------------------------------------------------------------------------------ -namespace StandAloneLauncher.Properties -{ - - +namespace StandAloneLauncher.Properties { + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { + + public static Settings Default { + get { return defaultInstance; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute(".\\..\\Content\\")] + public string Dennis { + get { + return ((string)(this["Dennis"])); + } + set { + this["Dennis"] = value; + } + } } } diff --git a/Code/Game/LanServer/StandAloneLauncher/Properties/Settings.settings b/Code/Game/LanServer/StandAloneLauncher/Properties/Settings.settings index 39645652..f260c659 100644 --- a/Code/Game/LanServer/StandAloneLauncher/Properties/Settings.settings +++ b/Code/Game/LanServer/StandAloneLauncher/Properties/Settings.settings @@ -1,7 +1,9 @@  - - - - - - + + + + + .\..\Content\ + + + \ No newline at end of file diff --git a/Code/Game/LanServer/StandAloneLauncher/StandAloneLauncher.csproj b/Code/Game/LanServer/StandAloneLauncher/StandAloneLauncher.csproj index 2d2c86fe..ec2a45b0 100644 --- a/Code/Game/LanServer/StandAloneLauncher/StandAloneLauncher.csproj +++ b/Code/Game/LanServer/StandAloneLauncher/StandAloneLauncher.csproj @@ -80,6 +80,7 @@ + diff --git a/Code/Network/NetworkAPI/CustomNetProtocol.cpp b/Code/Network/NetworkAPI/CustomNetProtocol.cpp index ecb57bf9..90fb100d 100644 --- a/Code/Network/NetworkAPI/CustomNetProtocol.cpp +++ b/Code/Network/NetworkAPI/CustomNetProtocol.cpp @@ -40,12 +40,13 @@ CustomNetProtocol::CustomNetProtocol() { this->privateData = new PrivateData(); } -CustomNetProtocol::CustomNetProtocol(CustomNetProtocol& o) +CustomNetProtocol::CustomNetProtocol(const CustomNetProtocol& o) { this->privateData = new PrivateData(); this->privateData->attributes = o.privateData->attributes; } -const CustomNetProtocol& CustomNetProtocol::operator=(CustomNetProtocol& o) + +CustomNetProtocol& CustomNetProtocol::operator=(const CustomNetProtocol& o) { if(this->privateData) { @@ -56,11 +57,29 @@ const CustomNetProtocol& CustomNetProtocol::operator=(CustomNetProtocol& o) this->privateData->attributes = o.privateData->attributes; return *this; } + CustomNetProtocol::~CustomNetProtocol() { delete this->privateData; this->privateData = 0; } + +const NetAttributeContainer& CustomNetProtocol::operator[](int ID) const +{ + //if(!this->privateData) this->privateData = new PrivateData(); + if((unsigned int)ID >= this->privateData->attributes.Size()) + { + NetAttributeContainer temp; + + temp.type = NetAttributeType_UNKNOWN; + memset(&temp.value, 0, sizeof(NetAttributeValue)); + + this->privateData->attributes.Push(ID, temp); + } + + return this->privateData->attributes[ID]; +} + NetAttributeContainer& CustomNetProtocol::operator[](int ID) { //if(!this->privateData) this->privateData = new PrivateData(); diff --git a/Code/Network/NetworkAPI/CustomNetProtocol.h b/Code/Network/NetworkAPI/CustomNetProtocol.h index 48feb3a9..24df6ebf 100644 --- a/Code/Network/NetworkAPI/CustomNetProtocol.h +++ b/Code/Network/NetworkAPI/CustomNetProtocol.h @@ -130,10 +130,12 @@ namespace Oyster public: CustomNetProtocol(); ~CustomNetProtocol(); - CustomNetProtocol(CustomNetProtocol& o); - const CustomNetProtocol& operator=(CustomNetProtocol& o); + CustomNetProtocol( const CustomNetProtocol& o); + CustomNetProtocol& operator=(const CustomNetProtocol& o); + + const NetAttributeContainer& operator[](int ID) const; + NetAttributeContainer& operator[](int ID); - NetAttributeContainer& operator[](int ID); void Set(int id, Oyster::Network::NetAttributeValue val, Oyster::Network::NetAttributeType type); void Set(int ID, std::string s); const NetAttributeContainer& Get(int id); diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp index bdfa0bde..96e2bbe2 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -197,6 +197,7 @@ namespace Oyster void API::StartRenderWireFrame() { Core::deviceContext->RSSetState(wire); + Core::deviceContext->OMSetRenderTargets(Render::Resources::Gather::Pass.RTV.size(),&Render::Resources::Gather::Pass.RTV[0],NULL); } void API::RenderDebugCube(Math::Matrix world) diff --git a/Code/OysterGraphics/Render/Resources.cpp b/Code/OysterGraphics/Render/Resources.cpp index 514960cf..124b1bf1 100644 --- a/Code/OysterGraphics/Render/Resources.cpp +++ b/Code/OysterGraphics/Render/Resources.cpp @@ -338,8 +338,8 @@ namespace Oyster dTDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL; dTDesc.CPUAccessFlags=0; dTDesc.MiscFlags=0; - dTDesc.Height = Core::resolution.y; - dTDesc.Width = Core::resolution.x; + dTDesc.Height = (UINT)Core::resolution.y; + dTDesc.Width = (UINT)Core::resolution.x; dTDesc.SampleDesc.Count=1; dTDesc.SampleDesc.Quality=0;