GL- LevelFormat fix
This commit is contained in:
parent
d6432b2c73
commit
91bf6ce901
Binary file not shown.
|
@ -189,7 +189,7 @@
|
||||||
<ClInclude Include="Object.h" />
|
<ClInclude Include="Object.h" />
|
||||||
<ClInclude Include="ObjectDefines.h" />
|
<ClInclude Include="ObjectDefines.h" />
|
||||||
<ClInclude Include="LevelParser.h" />
|
<ClInclude Include="LevelParser.h" />
|
||||||
<ClInclude Include="ParserFunctions.h" />
|
<ClInclude Include="ParseFunctions.h" />
|
||||||
<ClInclude Include="Player.h" />
|
<ClInclude Include="Player.h" />
|
||||||
<ClInclude Include="StaticObject.h" />
|
<ClInclude Include="StaticObject.h" />
|
||||||
<ClInclude Include="Team.h" />
|
<ClInclude Include="Team.h" />
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
#include "LevelParser.h"
|
#include "LevelParser.h"
|
||||||
|
|
||||||
#include "Loader.h"
|
#include "Loader.h"
|
||||||
|
#include "ParseFunctions.h"
|
||||||
|
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
using namespace ::LevelFileLoader;
|
using namespace ::LevelFileLoader;
|
||||||
|
|
||||||
|
|
||||||
LevelParser::LevelParser()
|
LevelParser::LevelParser()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -16,22 +18,23 @@ LevelParser::~LevelParser()
|
||||||
//
|
//
|
||||||
std::vector<ObjectTypeHeader> LevelParser::Parse(std::string filename)
|
std::vector<ObjectTypeHeader> LevelParser::Parse(std::string filename)
|
||||||
{
|
{
|
||||||
|
int stringSize = 0;
|
||||||
//Read entire level file.
|
//Read entire level file.
|
||||||
Loader loader;
|
Loader loader;
|
||||||
unsigned char* buffer = (unsigned char*)loader.LoadFile(filename.c_str());
|
unsigned char* buffer = (unsigned char*)loader.LoadFile(filename.c_str(), stringSize);
|
||||||
|
|
||||||
std::vector<ObjectTypeHeader> objects;
|
std::vector<ObjectTypeHeader> objects;
|
||||||
|
|
||||||
unsigned int counter = 0;
|
unsigned int counter = 0;
|
||||||
unsigned int stringSize = 0;
|
|
||||||
while(counter < stringSize)
|
while(counter < stringSize)
|
||||||
{
|
{
|
||||||
//Get typeID
|
//Get typeID
|
||||||
int typeID = 0;
|
ObjectTypeHeader typeID;
|
||||||
|
typeID = parseObjectTypeHeader(buffer);
|
||||||
//Unpack ID
|
//Unpack ID
|
||||||
|
|
||||||
switch(typeID)
|
switch((int)typeID.typeID)
|
||||||
{
|
{
|
||||||
case TypeID_LevelHeader:
|
case TypeID_LevelHeader:
|
||||||
//Call function
|
//Call function
|
||||||
|
@ -51,24 +54,27 @@ std::vector<ObjectTypeHeader> LevelParser::Parse(std::string filename)
|
||||||
return objects;
|
return objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//för meta information om leveln. Måste göra så den returnerar rätt strukt så fort vi
|
||||||
|
//vi definierat en!
|
||||||
ObjectTypeHeader LevelParser::ParseHeader(std::string filename)
|
ObjectTypeHeader LevelParser::ParseHeader(std::string filename)
|
||||||
{
|
{
|
||||||
|
int stringSize = 0;
|
||||||
//Read entire level file.
|
//Read entire level file.
|
||||||
Loader loader;
|
Loader loader;
|
||||||
unsigned char* buffer = (unsigned char*)loader.LoadFile(filename.c_str());
|
unsigned char* buffer = (unsigned char*)loader.LoadFile(filename.c_str(), stringSize);
|
||||||
|
|
||||||
//Find the header in the returned string.
|
//Find the header in the returned string.
|
||||||
unsigned int counter = 0;
|
unsigned int counter = 0;
|
||||||
unsigned int stringSize = 0;
|
|
||||||
|
|
||||||
ObjectTypeHeader header;
|
ObjectTypeHeader header;
|
||||||
header.typeID = ObjectType_Level;
|
header.typeID = ObjectType_Level;
|
||||||
|
|
||||||
while(counter < stringSize)
|
while(counter < stringSize)
|
||||||
{
|
{
|
||||||
int typeID = 0;
|
ObjectTypeHeader typeID;
|
||||||
switch(typeID)
|
typeID = parseObjectTypeHeader(buffer);
|
||||||
|
switch(typeID.typeID)
|
||||||
{
|
{
|
||||||
case TypeID_LevelHeader:
|
case TypeID_LevelHeader:
|
||||||
//Call function
|
//Call function
|
||||||
|
|
|
@ -2,82 +2,88 @@
|
||||||
// Created by Sam Svensson 2013 //
|
// Created by Sam Svensson 2013 //
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
|
|
||||||
#include "ParserFunctions.h"
|
#include "ParseFunctions.h"
|
||||||
#include "../../Misc/Packing/Packing.h"
|
#include "../../Misc/Packing/Packing.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace Oyster::Packing;
|
using namespace Oyster::Packing;
|
||||||
|
using namespace GameLogic::LevelFileLoader;
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
ObjectTypeHeader parseObjectTypeHeader(unsigned char* buffer)
|
namespace GameLogic
|
||||||
{
|
{
|
||||||
int i = Unpacki(buffer);
|
namespace LevelFileLoader
|
||||||
|
{
|
||||||
|
ObjectTypeHeader parseObjectTypeHeader(unsigned char* buffer)
|
||||||
|
{
|
||||||
|
struct ObjectTypeHeader header;
|
||||||
|
int i = Unpacki(buffer);
|
||||||
|
header.typeID = (ObjectType)i;
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
struct ObjectTypeHeader header;
|
ObjectHeader parseObjectHeader (unsigned char* buffer)
|
||||||
header.typeID = (ObjectType)i;
|
{
|
||||||
|
struct ObjectHeader header;
|
||||||
|
int x, y,z;
|
||||||
|
string s;
|
||||||
|
int start = 0;
|
||||||
|
|
||||||
return header;
|
|
||||||
}
|
//ModelID
|
||||||
ObjectHeader parseObjectHeader (unsigned char* buffer)
|
x = Unpacki(buffer);
|
||||||
{
|
header.ModelID = (ObjectType)x;
|
||||||
struct ObjectHeader header;
|
|
||||||
int x, y,z;
|
//TextureID
|
||||||
string s;
|
start += 4;
|
||||||
int start = 0;
|
x = Unpacki(&buffer[start]);
|
||||||
|
header.TextureID = x;
|
||||||
|
|
||||||
//ModelID
|
//Position
|
||||||
x = Unpacki(buffer);
|
start += 4;
|
||||||
header.ModelID = (ObjectType)x;
|
x = Unpacki(&buffer[start]);
|
||||||
|
|
||||||
//TextureID
|
start += 4;
|
||||||
start += 4;
|
y = Unpacki(&buffer[start]);
|
||||||
x = Unpacki(&buffer[start]);
|
|
||||||
header.TextureID = x;
|
start += 4;
|
||||||
|
z = Unpacki(&buffer[start]);
|
||||||
//Position
|
|
||||||
start += 4;
|
header.position[0] = x;
|
||||||
x = Unpacki(&buffer[start]);
|
header.position[1] = y;
|
||||||
|
header.position[2] = z;
|
||||||
start += 4;
|
|
||||||
y = Unpacki(&buffer[start]);
|
//Rotation
|
||||||
|
start += 4;
|
||||||
start += 4;
|
x = Unpacki(&buffer[start]);
|
||||||
z = Unpacki(&buffer[start]);
|
|
||||||
|
start += 4;
|
||||||
header.position[0] = x;
|
y = Unpacki(&buffer[start]);
|
||||||
header.position[1] = y;
|
|
||||||
header.position[2] = z;
|
start += 4;
|
||||||
|
z = Unpacki(&buffer[start]);
|
||||||
//Rotation
|
|
||||||
start += 4;
|
header.rotation[0] = x;
|
||||||
x = Unpacki(&buffer[start]);
|
header.rotation[1] = y;
|
||||||
|
header.rotation[2] = z;
|
||||||
start += 4;
|
|
||||||
y = Unpacki(&buffer[start]);
|
//Scale
|
||||||
|
start += 4;
|
||||||
start += 4;
|
x = Unpacki(&buffer[start]);
|
||||||
z = Unpacki(&buffer[start]);
|
|
||||||
|
start += 4;
|
||||||
header.rotation[0] = x;
|
y = Unpacki(&buffer[start]);
|
||||||
header.rotation[1] = y;
|
|
||||||
header.rotation[2] = z;
|
start += 4;
|
||||||
|
z = Unpacki(&buffer[start]);
|
||||||
//Scale
|
|
||||||
start += 4;
|
header.scale[0] = x;
|
||||||
x = Unpacki(&buffer[start]);
|
header.scale[1] = y;
|
||||||
|
header.scale[2] = z;
|
||||||
start += 4;
|
|
||||||
y = Unpacki(&buffer[start]);
|
|
||||||
|
return header;
|
||||||
start += 4;
|
}
|
||||||
z = Unpacki(&buffer[start]);
|
}
|
||||||
|
|
||||||
header.scale[0] = x;
|
|
||||||
header.scale[1] = y;
|
|
||||||
header.scale[2] = z;
|
|
||||||
|
|
||||||
|
|
||||||
return header;
|
|
||||||
}
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
//////////////////////////////////
|
||||||
|
// Created by Sam Svensson 2013 //
|
||||||
|
//////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef PARSERFUNCTIONS_H
|
||||||
|
#define PARSERFUNCTIONS_H
|
||||||
|
#include "ObjectDefines.h"
|
||||||
|
|
||||||
|
namespace GameLogic
|
||||||
|
{
|
||||||
|
namespace LevelFileLoader
|
||||||
|
{
|
||||||
|
ObjectTypeHeader parseObjectTypeHeader(unsigned char* buffer); //send in a char buffer, this function will seperate it and then return the right struct with the values.
|
||||||
|
ObjectHeader parseObjectHeader (unsigned char* buffer); //send in a char buffer, this function will seperate it and then return the right struct with the values.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,22 +0,0 @@
|
||||||
//////////////////////////////////
|
|
||||||
// Created by Sam Svensson 2013 //
|
|
||||||
//////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef PARSERFUNCTIONS_H
|
|
||||||
#define PARSERFUNCTIONS_H
|
|
||||||
#include "ObjectDefines.h"
|
|
||||||
|
|
||||||
namespace GameLogic
|
|
||||||
{
|
|
||||||
namespace LevelFileLoader
|
|
||||||
{
|
|
||||||
namespace parseFunctions
|
|
||||||
{
|
|
||||||
ObjectTypeHeader parseObjectTypeHeader(unsigned char* buffer); //send in a char buffer, this function will seperate it and then return the right struct with the values.
|
|
||||||
ObjectHeader parseObjectHeader (unsigned char* buffer); //send in a char buffer, this function will seperate it and then return the right struct with the values.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue