2014-01-28 11:29:35 +01:00
|
|
|
//////////////////////////////////
|
|
|
|
// Created by Sam Svensson 2013 //
|
|
|
|
//////////////////////////////////
|
|
|
|
|
|
|
|
#include "ParseFunctions.h"
|
|
|
|
#include "../../../Misc/Packing/Packing.h"
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
using namespace Oyster::Packing;
|
|
|
|
using namespace GameLogic::LevelFileLoader;
|
|
|
|
using namespace GameLogic;
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
namespace GameLogic
|
|
|
|
{
|
|
|
|
namespace LevelFileLoader
|
|
|
|
{
|
2014-01-28 16:15:10 +01:00
|
|
|
void ParseObject(char* buffer, void *header, int size)
|
2014-01-28 11:29:35 +01:00
|
|
|
{
|
|
|
|
memcpy(header, buffer, size);
|
|
|
|
}
|
|
|
|
|
2014-02-04 11:36:10 +01:00
|
|
|
void ParseObject(char* buffer, ObjectHeader& header, int& size)
|
|
|
|
{
|
|
|
|
char tempName[128];
|
2014-02-05 15:46:45 +01:00
|
|
|
unsigned int tempSize = 0;
|
2014-02-04 11:36:10 +01:00
|
|
|
int start = 0;
|
|
|
|
|
|
|
|
memcpy(&header.typeID, &buffer[start], 4);
|
|
|
|
start += 4;
|
|
|
|
|
|
|
|
memcpy(&tempSize, &buffer[start], 4);
|
|
|
|
start += 4;
|
|
|
|
|
|
|
|
memcpy(&tempName, &buffer[start], tempSize);
|
|
|
|
header.ModelFile.assign(&tempName[0], &tempName[tempSize]);
|
|
|
|
start += tempSize;
|
|
|
|
|
2014-02-05 15:46:45 +01:00
|
|
|
//3 float[3], 1 float
|
|
|
|
memcpy(&header.position, &buffer[start], 40);
|
|
|
|
start += 40;
|
|
|
|
|
|
|
|
//2 float[3], 3 float, 2 uint
|
|
|
|
memcpy(&header.usePhysics, &buffer[start], 44);
|
|
|
|
start += 44;
|
2014-02-04 11:36:10 +01:00
|
|
|
|
|
|
|
size += start;
|
|
|
|
}
|
|
|
|
|
2014-01-28 16:15:10 +01:00
|
|
|
void ParseLevelMetaData(char* buffer, LevelMetaData &header, int &size)
|
2014-01-28 11:29:35 +01:00
|
|
|
{
|
|
|
|
int start = 0;
|
2014-02-05 15:46:45 +01:00
|
|
|
unsigned int tempSize;
|
2014-02-04 11:36:10 +01:00
|
|
|
char tempName[128];
|
2014-01-28 16:15:10 +01:00
|
|
|
|
2014-01-28 11:29:35 +01:00
|
|
|
memcpy(&header.typeID, &buffer[start], 4);
|
|
|
|
start += 4;
|
2014-01-28 16:15:10 +01:00
|
|
|
|
2014-01-28 11:29:35 +01:00
|
|
|
memcpy(&tempSize , &buffer[start], 4);
|
|
|
|
start += 4;
|
2014-01-28 16:15:10 +01:00
|
|
|
|
|
|
|
memcpy(&tempName, &buffer[start], tempSize);
|
|
|
|
header.levelName.assign(&tempName[0], &tempName[tempSize]);
|
2014-01-28 11:29:35 +01:00
|
|
|
start += tempSize;
|
2014-01-28 16:15:10 +01:00
|
|
|
|
2014-02-04 14:30:45 +01:00
|
|
|
memcpy(&header.levelVersion, &buffer[start], 4);
|
|
|
|
start += 4;
|
2014-01-28 16:15:10 +01:00
|
|
|
|
2014-01-28 11:29:35 +01:00
|
|
|
memcpy(&tempSize, &buffer[start], 4);
|
|
|
|
start +=4;
|
2014-01-28 16:15:10 +01:00
|
|
|
|
|
|
|
memcpy(&tempName, &buffer[start], tempSize);
|
|
|
|
header.levelDescription.assign(&tempName[0], &tempName[tempSize]);
|
2014-01-28 11:29:35 +01:00
|
|
|
start += tempSize;
|
2014-01-28 16:15:10 +01:00
|
|
|
|
2014-01-28 11:29:35 +01:00
|
|
|
memcpy(&tempSize, &buffer[start], 4);
|
|
|
|
start += 4;
|
2014-01-28 16:15:10 +01:00
|
|
|
|
|
|
|
memcpy(&tempName, &buffer[start], tempSize);
|
|
|
|
header.levelAuthor.assign(&tempName[0], &tempName[tempSize]);
|
2014-01-28 11:29:35 +01:00
|
|
|
start += tempSize;
|
2014-01-28 16:15:10 +01:00
|
|
|
|
|
|
|
memcpy(&header.maxNumberOfPlayer, &buffer[start], 4);
|
2014-01-28 11:29:35 +01:00
|
|
|
start += 4;
|
2014-01-28 16:15:10 +01:00
|
|
|
|
2014-01-28 11:29:35 +01:00
|
|
|
memcpy(&header.worldSize, &buffer[start], 4);
|
|
|
|
start += 4;
|
2014-01-28 16:15:10 +01:00
|
|
|
|
2014-02-04 11:36:10 +01:00
|
|
|
memcpy(&tempSize, &buffer[start], 4);
|
2014-01-28 11:29:35 +01:00
|
|
|
start += 4;
|
2014-01-28 16:15:10 +01:00
|
|
|
|
2014-02-04 11:36:10 +01:00
|
|
|
memcpy(&tempName, &buffer[start], tempSize);
|
|
|
|
header.overviewPicturePath.assign(&tempName[0], &tempName[tempSize]);
|
|
|
|
start += tempSize;
|
|
|
|
|
2014-01-28 11:29:35 +01:00
|
|
|
memcpy(&tempSize, &buffer[start], 4);
|
|
|
|
start += 4;
|
2014-01-28 16:15:10 +01:00
|
|
|
|
|
|
|
int temp;
|
|
|
|
|
|
|
|
for(int i = 0; i < tempSize; i++)
|
|
|
|
{
|
|
|
|
memcpy(&temp, &buffer[start], 4);
|
|
|
|
start += 4;
|
|
|
|
header.gameModesSupported.push_back((GameMode)temp);
|
|
|
|
}
|
|
|
|
|
|
|
|
size += start;
|
2014-01-28 11:29:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|