GL - Fixed ParseFunction so now we only have 1 + specialcases functions instead of 1 function for every case

This commit is contained in:
Sam Mario Svensson 2014-01-28 11:29:35 +01:00
parent dd2b214122
commit d2ebad7445
13 changed files with 261 additions and 238 deletions

View File

@ -4,8 +4,20 @@
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>640</x>
<y>256</y>
<x>632</x>
<y>232</y>
<w>88</w>
<h>176</h>
</coordinates>
<panel_attributes>lt=.
&lt;Uses</panel_attributes>
<additional_attributes>24;24;24;64;72;64;72;160</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>136</x>
<y>232</y>
<w>40</w>
<h>168</h>
</coordinates>
@ -15,20 +27,111 @@
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>840</x>
<y>256</y>
<w>88</w>
<x>448</x>
<y>496</y>
<w>40</w>
<h>88</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>24;72;24;24</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>432</x>
<y>232</y>
<w>40</w>
<h>168</h>
</coordinates>
<panel_attributes>lt=.
&lt;Uses</panel_attributes>
<additional_attributes>24;24;24;64;72;64;72;152</additional_attributes>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>24;24;24;152</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>608</x>
<y>216</y>
<w>128</w>
<h>40</h>
</coordinates>
<panel_attributes>Resource Loader
&lt;&lt;Dennis&gt;&gt;&lt;&lt;Singleton&gt;</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>232</x>
<y>112</y>
<w>128</w>
<h>40</h>
</coordinates>
<panel_attributes>GameLogic
&lt;&lt;Erik&gt;&gt;</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>120</x>
<y>232</y>
<w>80</w>
<h>24</h>
</coordinates>
<panel_attributes>Defines</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>352</x>
<y>568</y>
<w>232</w>
<h>136</h>
</coordinates>
<panel_attributes>&lt;&lt;Interface&gt;&gt;
LevelParser
--
Functions:
vector&lt;struct&gt; Parse();
-
Privates:
enum headerType;
const int FileHeaderSize;
const int FileVersion;
</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>336</x>
<y>88</y>
<w>136</w>
<h>160</h>
</coordinates>
<panel_attributes>lt=lt=-&gt;&gt;&gt;&gt;
m1=1..1
m2=1..1
Uses&gt;</panel_attributes>
<additional_attributes>24;40;80;40;120;40;120;144</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>560</x>
<y>408</y>
<y>496</y>
<w>136</w>
<h>104</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>120;24;120;88;24;88</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>352</x>
<y>384</y>
<w>232</w>
<h>136</h>
</coordinates>
@ -45,54 +148,79 @@ Privates:
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>440</x>
<y>136</y>
<w>128</w>
<h>40</h>
<x>560</x>
<y>600</y>
<w>176</w>
<h>56</h>
</coordinates>
<panel_attributes>GameLogic
&lt;&lt;Erik&gt;&gt;</panel_attributes>
<additional_attributes/>
<panel_attributes>lt=-
m1=1..1
m2=1..1
Uses&gt;</panel_attributes>
<additional_attributes>24;40;160;40</additional_attributes>
</element>
<element>
<type>com.umlet.element.Package</type>
<coordinates>
<x>552</x>
<y>368</y>
<x>344</x>
<y>344</y>
<w>584</w>
<h>368</h>
</coordinates>
<panel_attributes>LevelLoader</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>472</x>
<y>200</y>
<w>152</w>
<h>56</h>
</coordinates>
<panel_attributes>lt=-
m1=1..1
m2=1..1
Uses&gt;</panel_attributes>
<additional_attributes>24;40;136;40</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>560</x>
<y>592</y>
<w>232</w>
<h>136</h>
<x>416</x>
<y>232</y>
<w>80</w>
<h>24</h>
</coordinates>
<panel_attributes>&lt;&lt;Interface&gt;&gt;
Parser
--
Functions:
vector&lt;struct&gt; Parse();
-
Privates:
enum headerType;
const int FileHeaderSize;
const int FileVersion;
<panel_attributes>LevelLoader
</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>928</x>
<y>608</y>
<x>48</x>
<y>384</y>
<w>232</w>
<h>104</h>
</coordinates>
<panel_attributes>ObjectDefines.h
&lt;&lt;Header file&gt;&gt;
--
Enum ObjectType(static, dynamic, specials);
.
Struct static;
Struct dynamic;
Struct specials</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>720</x>
<y>584</y>
<w>200</w>
<h>120</h>
</coordinates>
@ -103,23 +231,23 @@ functions for creating the right structs</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<type>com.umlet.element.Package</type>
<coordinates>
<x>768</x>
<y>520</y>
<w>136</w>
<h>104</h>
<x>40</x>
<y>344</y>
<w>248</w>
<h>160</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>120;24;120;88;24;88</additional_attributes>
<panel_attributes>Defines</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>800</x>
<y>408</y>
<x>592</x>
<y>392</y>
<w>208</w>
<h>136</h>
<h>128</h>
</coordinates>
<panel_attributes>&lt;&lt;Interface&gt;&gt;
Loader
@ -135,67 +263,8 @@ Privates:</panel_attributes>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>656</x>
<y>520</y>
<w>40</w>
<h>88</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>24;72;24;24</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>328</x>
<y>256</y>
<w>80</w>
<h>24</h>
</coordinates>
<panel_attributes>Defines</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>680</x>
<y>224</y>
<w>152</w>
<h>56</h>
</coordinates>
<panel_attributes>lt=-
m1=1..1
m2=1..1
Uses&gt;</panel_attributes>
<additional_attributes>24;40;136;40</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>624</x>
<y>256</y>
<w>80</w>
<h>24</h>
</coordinates>
<panel_attributes>LevelLoader
</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>344</x>
<y>256</y>
<w>40</w>
<h>168</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>24;24;24;152</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>384</x>
<y>224</y>
<x>176</x>
<y>200</y>
<w>256</w>
<h>56</h>
</coordinates>
@ -205,73 +274,4 @@ m2=1..1
&lt;Knows about</panel_attributes>
<additional_attributes>240;40;24;40</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>544</x>
<y>112</y>
<w>136</w>
<h>160</h>
</coordinates>
<panel_attributes>lt=lt=-&gt;&gt;&gt;&gt;
m1=1..1
m2=1..1
Uses&gt;</panel_attributes>
<additional_attributes>24;40;80;40;120;40;120;144</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>768</x>
<y>624</y>
<w>176</w>
<h>56</h>
</coordinates>
<panel_attributes>lt=-
m1=1..1
m2=1..1
Uses&gt;</panel_attributes>
<additional_attributes>24;40;160;40</additional_attributes>
</element>
<element>
<type>com.umlet.element.Package</type>
<coordinates>
<x>248</x>
<y>368</y>
<w>248</w>
<h>160</h>
</coordinates>
<panel_attributes>Defines</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>256</x>
<y>408</y>
<w>232</w>
<h>104</h>
</coordinates>
<panel_attributes>Defines.h
&lt;&lt;Header file&gt;&gt;
--
Enum ObjectType(static, dynamic, specials);
.
Struct static;
Struct dynamic;
Struct specials</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>816</x>
<y>240</y>
<w>128</w>
<h>40</h>
</coordinates>
<panel_attributes>Resource Loader
&lt;&lt;Dennis&gt;&gt;&lt;&lt;Singleton&gt;</panel_attributes>
<additional_attributes/>
</element>
</diagram>

View File

@ -184,12 +184,12 @@
<ClInclude Include="GameMode.h" />
<ClInclude Include="IAttatchment.h" />
<ClInclude Include="Level.h" />
<ClInclude Include="LevelLoader.h" />
<ClInclude Include="Loader.h" />
<ClInclude Include="LevelLoader\LevelLoader.h" />
<ClInclude Include="LevelLoader\Loader.h" />
<ClInclude Include="Object.h" />
<ClInclude Include="ObjectDefines.h" />
<ClInclude Include="LevelParser.h" />
<ClInclude Include="ParseFunctions.h" />
<ClInclude Include="LevelLoader\ObjectDefines.h" />
<ClInclude Include="LevelLoader\LevelParser.h" />
<ClInclude Include="LevelLoader\ParseFunctions.h" />
<ClInclude Include="Player.h" />
<ClInclude Include="StaticObject.h" />
<ClInclude Include="Team.h" />
@ -207,11 +207,11 @@
<ClCompile Include="Game_PlayerData.cpp" />
<ClCompile Include="IAttatchment.cpp" />
<ClCompile Include="Level.cpp" />
<ClCompile Include="LevelLoader.cpp" />
<ClCompile Include="Loader.cpp" />
<ClCompile Include="LevelParser.cpp" />
<ClCompile Include="LevelLoader\LevelLoader.cpp" />
<ClCompile Include="LevelLoader\Loader.cpp" />
<ClCompile Include="LevelLoader\LevelParser.cpp" />
<ClCompile Include="Object.cpp" />
<ClCompile Include="ParseFunctions.cpp" />
<ClCompile Include="LevelLoader\ParseFunctions.cpp" />
<ClCompile Include="Player.cpp" />
<ClCompile Include="StaticObject.cpp" />
<ClCompile Include="Team.cpp" />

View File

@ -15,7 +15,6 @@ LevelParser::~LevelParser()
{
}
//
std::vector<ObjectTypeHeader> LevelParser::Parse(std::string filename)
{
int stringSize = 0;

View File

@ -15,6 +15,8 @@ unsigned char* Loader::LoadFile(std::string fileName, int &size)
//convert from wstring to wchar then loads the file
unsigned char* buffer = (unsigned char*)OysterResource::LoadResource(temp.c_str(), Oyster::Resource::ResourceType::ResourceType_Byte_Raw, -1 , false);
//gets the size of the char buffer.
size = OysterResource::GetResourceSize(buffer);
return buffer;
}

View File

@ -5,7 +5,7 @@
#ifndef LOADER_H
#define LOADER_H
#include "Resource\OysterResource.h"
#include "..\Misc\Resource\OysterResource.h"
#include <string>
namespace GameLogic

View File

@ -0,0 +1,55 @@
//////////////////////////////////
// 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
{
void ParseObject(unsigned char* buffer, void* header, int size)
{
memcpy(header, buffer, size);
}
void ParseLevelMetaData(unsigned char* buffer, struct LevelMetaData &header)
{
int start = 0;
int tempSize;
memcpy(&header.typeID, &buffer[start], 4);
start += 4;
memcpy(&tempSize , &buffer[start], 4);
start += 4;
memcpy(&header.levelName, &buffer[start], tempSize);
start += tempSize;
memcpy(&header.levelVersion, &buffer[start], 8)
start += 8;
memcpy(&tempSize, &buffer[start], 4);
start +=4;
memcpy(&header.description, &buffer[start], tempSize);
start += tempSize;
memcpy(&tempSize, &buffer[start], 4);
start += 4;
memcpy(&header.author, &buffer[start], tempSize);
start += tempSize;
memcpy(&header.nrOfPlayers, &buffer[start], 4);
start += 4;
memcpy(&header.worldSize, &buffer[start], 4);
start += 4;
memcpy(&header.map, &buffer[start], 4);
start += 4;
memcpy(&tempSize, &buffer[start], 4);
start += 4;
memcpy(&header.gameModes, &buffer[start], 4 * tempSize);
start += tempSize;
}
}
}

View File

@ -0,0 +1,19 @@
//////////////////////////////////
// Created by Sam Svensson 2013 //
//////////////////////////////////
#ifndef PARSERFUNCTIONS_H
#define PARSERFUNCTIONS_H
#include "ObjectDefines.h"
namespace GameLogic
{
namespace LevelFileLoader
{
void ParseObject(unsigned char* buffer, void* header, int size);
void ParseLevelMetaData(unsigned char* buffer, struct ObjectTypeHeader &header);
}
}
#endif

View File

@ -1,33 +0,0 @@
//////////////////////////////////
// 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
{
ObjectTypeHeader ParseObjectTypeHeader(unsigned char* buffer)
{
struct ObjectTypeHeader header;
memcpy(&header, buffer, sizeof(ObjectTypeHeader));
return header;
}
ObjectHeader ParseObjectHeader (unsigned char* buffer)
{
struct ObjectHeader header;
memcpy(&header, buffer, sizeof(ObjectHeader));
return header;
}
}
}

View File

@ -1,19 +0,0 @@
//////////////////////////////////
// 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