diff --git a/Code/Game/GameLogic/LevelLoader/LevelLoader.cpp b/Code/Game/GameLogic/LevelLoader/LevelLoader.cpp index 55a39725..8fe880f3 100644 --- a/Code/Game/GameLogic/LevelLoader/LevelLoader.cpp +++ b/Code/Game/GameLogic/LevelLoader/LevelLoader.cpp @@ -17,7 +17,14 @@ struct LevelLoader::PrivData LevelLoader::LevelLoader() : pData(new PrivData) { - pData->folderPath = "Standard path"; + //standard path + pData->folderPath = ""; +} + +LevelLoader::LevelLoader(std::string folderPath) + : pData(new PrivData) +{ + pData->folderPath = folderPath; } LevelLoader::~LevelLoader() @@ -26,10 +33,20 @@ LevelLoader::~LevelLoader() std::vector> LevelLoader::LoadLevel(std::string fileName) { - return pData->parser.Parse(fileName); + return pData->parser.Parse(pData->folderPath + fileName); } LevelMetaData LevelLoader::LoadLevelHeader(std::string fileName) { - return pData->parser.ParseHeader(fileName); + return pData->parser.ParseHeader(pData->folderPath + fileName); +} + +std::string LevelLoader::GetFolderPath() +{ + return this->pData->folderPath; +} + +void LevelLoader::SetFolderPath(std::string folderPath) +{ + } \ No newline at end of file diff --git a/Code/Game/GameLogic/LevelLoader/LevelLoader.h b/Code/Game/GameLogic/LevelLoader/LevelLoader.h index bcd6e587..184a7005 100644 --- a/Code/Game/GameLogic/LevelLoader/LevelLoader.h +++ b/Code/Game/GameLogic/LevelLoader/LevelLoader.h @@ -17,11 +17,15 @@ namespace GameLogic public: LevelLoader(); + /*********************************************************** + * Lets you set the standard folderpath for the levels + ********************************************************/ + LevelLoader(std::string folderPath); ~LevelLoader(); /******************************************************** * Loads the level and objects from file. - * @param fileName: Path to the level-file that you want to load. + * @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); @@ -33,10 +37,20 @@ namespace GameLogic ********************************************************/ LevelMetaData LoadLevelHeader(std::string fileName); //. + /*********************************************************** + * @return: Returns the current standard folder path + ********************************************************/ + std::string GetFolderPath(); + + /*********************************************************** + * Sets the standard folder path + ********************************************************/ + void SetFolderPath(std::string folderPath); + private: struct PrivData; Utility::DynamicMemory::SmartPointer pData; - }; + }; } #endif \ No newline at end of file diff --git a/Code/Game/GameLogic/LevelLoader/LevelParser.cpp b/Code/Game/GameLogic/LevelLoader/LevelParser.cpp index a6f806e8..f66fbe08 100644 --- a/Code/Game/GameLogic/LevelLoader/LevelParser.cpp +++ b/Code/Game/GameLogic/LevelLoader/LevelParser.cpp @@ -13,7 +13,7 @@ using namespace Utility::DynamicMemory; LevelParser::LevelParser() { - formatVersion.formatVersionMajor = 2; + formatVersion.formatVersionMajor = 3; formatVersion.formatVersionMinor = 0; } @@ -71,7 +71,6 @@ std::vector> LevelParser::Parse(std::string filen { //These three does not have any specail variables at this time. //There for they are using the same 'parser'. - case ObjectSpecialType_World: case ObjectSpecialType_Building: case ObjectSpecialType_Damaging: case ObjectSpecialType_Explosive: @@ -113,17 +112,26 @@ std::vector> LevelParser::Parse(std::string filen break; } - case ObjectSpecialType_SpawnPoint: + + case ObjectSpecialType_World: { - SpawnPointAttributes* header = new SpawnPointAttributes; + WorldAttributes* header = new WorldAttributes; ParseObject(&buffer[counter], *header, counter); - ParseObject(&buffer[counter], header->spawnPosition, 12); + ParseObject(&buffer[counter], &header->worldSize, 8); objects.push_back(header); - break; } + case ObjectSpecialType_Sky: + { + SkyAttributes* header = new SkyAttributes; + ParseObject(&buffer[counter], *header, counter); + + ParseObject(&buffer[counter], &header->skySize, 4); + objects.push_back(header); + break; + } default: //Couldn't find specialType break; @@ -240,9 +248,6 @@ LevelMetaData LevelParser::ParseHeader(std::string filename) case ObjectSpecialType_Portal: counter += sizeof(12); break; - case ObjectSpecialType_SpawnPoint: - counter += sizeof(12); - break; default: break; } diff --git a/Code/Game/GameLogic/LevelLoader/ObjectDefines.h b/Code/Game/GameLogic/LevelLoader/ObjectDefines.h index 46cb2465..05d09714 100644 --- a/Code/Game/GameLogic/LevelLoader/ObjectDefines.h +++ b/Code/Game/GameLogic/LevelLoader/ObjectDefines.h @@ -32,7 +32,7 @@ namespace GameLogic ObjectSpecialType_JumpPad, ObjectSpecialType_BoostPad, ObjectSpecialType_Portal, - ObjectSpecialType_SpawnPoint, + ObjectSpecialType_Sky, ObjectSpecialType_Count, ObjectSpecialType_Unknown = -1 @@ -134,7 +134,7 @@ namespace GameLogic namespace LevelLoaderInternal { - const FormatVersion boundingVolumeVersion(1, 0); + const FormatVersion boundingVolumeVersion(2, 0); struct BoundingVolumeBase { @@ -224,11 +224,19 @@ namespace GameLogic float destination[3]; }; - struct SpawnPointAttributes : public ObjectHeader + struct WorldAttributes : public ObjectHeader { - float spawnPosition[3]; + float worldSize; + float atmoSphereSize; }; + struct SkyAttributes : public ObjectHeader + { + float skySize; + }; + + + /************************************ Lights *************************************/ diff --git a/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp b/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp index 722bd609..d917a146 100644 --- a/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp +++ b/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp @@ -16,6 +16,7 @@ namespace GameLogic { namespace LevelFileLoader { + //can parse any struct without strings or char[] void ParseObject(char* buffer, void *header, int size) { memcpy(header, buffer, size);