Merge branch 'GameLogic' of https://github.com/dean11/Danbias into GameLogic

This commit is contained in:
lindaandersson 2014-02-10 16:29:04 +01:00
commit f473136ae1
5 changed files with 63 additions and 18 deletions

View File

@ -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<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> 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)
{
}

View File

@ -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<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> LoadLevel(std::string fileName);
@ -33,6 +37,16 @@ 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<PrivData> pData;

View File

@ -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<SmartPointer<ObjectTypeHeader>> 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<SmartPointer<ObjectTypeHeader>> 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;
}

View File

@ -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
*************************************/

View File

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