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

This commit is contained in:
lindaandersson 2014-01-30 14:58:30 +01:00
commit 2bb2d0cd56
25 changed files with 1123 additions and 798 deletions

BIN
Bin/Level.txt Normal file

Binary file not shown.

BIN
Bin/map Normal file

Binary file not shown.

BIN
Bin/map.txt Normal file

Binary file not shown.

View File

@ -2,21 +2,67 @@
<diagram program="umlet" version="12.0">
<zoom_level>8</zoom_level>
<element>
<type>com.umlet.element.Package</type>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>552</x>
<y>320</y>
<w>584</w>
<h>368</h>
<x>632</x>
<y>232</y>
<w>88</w>
<h>176</h>
</coordinates>
<panel_attributes>LevelLoader</panel_attributes>
<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>
<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>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;&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>440</x>
<y>88</y>
<x>232</x>
<y>112</y>
<w>128</w>
<h>40</h>
</coordinates>
@ -25,26 +71,26 @@
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<type>com.umlet.element.Class</type>
<coordinates>
<x>768</x>
<y>472</y>
<w>136</w>
<h>104</h>
<x>120</x>
<y>232</y>
<w>80</w>
<h>24</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>560</x>
<y>544</y>
<x>352</x>
<y>568</y>
<w>232</w>
<h>136</h>
</coordinates>
<panel_attributes>&lt;&lt;Interface&gt;&gt;
Parser
LevelParser
--
Functions:
vector&lt;struct&gt; Parse();
@ -53,164 +99,39 @@ Privates:
enum headerType;
const int FileHeaderSize;
const int FileVersion;
</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>624</x>
<y>208</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>640</x>
<y>208</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>176</y>
<w>256</w>
<h>56</h>
</coordinates>
<panel_attributes>lt=-&gt;&gt;&gt;&gt;
m1=1..1
m2=1..1
&lt;Knows about</panel_attributes>
<additional_attributes>240;40;24;40</additional_attributes>
</element>
<element>
<type>com.umlet.element.Package</type>
<coordinates>
<x>248</x>
<y>320</y>
<w>248</w>
<x>336</x>
<y>88</y>
<w>136</w>
<h>160</h>
</coordinates>
<panel_attributes>Defines</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>800</x>
<y>360</y>
<w>208</w>
<h>136</h>
</coordinates>
<panel_attributes>&lt;&lt;Interface&gt;&gt;
Loader
--
Functions:
wchar* LoadFile(string fileName);
Model* LoadModel(string modelName);
Model* LoadModel(int modelID);
-
Privates:</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>328</x>
<y>208</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>256</x>
<y>360</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.Relation</type>
<coordinates>
<x>680</x>
<y>176</y>
<w>152</w>
<h>56</h>
</coordinates>
<panel_attributes>lt=-
<panel_attributes>lt=lt=-&gt;&gt;&gt;&gt;
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>816</x>
<y>192</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>928</x>
<y>560</y>
<w>200</w>
<h>120</h>
</coordinates>
<panel_attributes>Collection of functions
&lt;&lt;lots of functions&gt;&gt;
--
functions for creating the right structs</panel_attributes>
<additional_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>576</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.Class</type>
<coordinates>
<x>560</x>
<y>360</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>
@ -229,49 +150,128 @@ Privates:
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>344</x>
<y>208</y>
<w>40</w>
<h>168</h>
<x>560</x>
<y>600</y>
<w>176</w>
<h>56</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>840</x>
<y>208</y>
<w>88</w>
<h>168</h>
</coordinates>
<panel_attributes>lt=.
&lt;Uses</panel_attributes>
<additional_attributes>24;24;24;64;72;64;72;152</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>656</x>
<y>472</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>544</x>
<y>64</y>
<w>136</w>
<h>160</h>
</coordinates>
<panel_attributes>lt=lt=-&gt;&gt;&gt;&gt;
<panel_attributes>lt=-
m1=1..1
m2=1..1
Uses&gt;</panel_attributes>
<additional_attributes>24;40;80;40;120;40;120;144</additional_attributes>
<additional_attributes>24;40;160;40</additional_attributes>
</element>
<element>
<type>com.umlet.element.Package</type>
<coordinates>
<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>416</x>
<y>232</y>
<w>80</w>
<h>24</h>
</coordinates>
<panel_attributes>LevelLoader
</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<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>
<panel_attributes>Collection of functions
&lt;&lt;lots of functions&gt;&gt;
--
functions for creating the right structs</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Package</type>
<coordinates>
<x>40</x>
<y>344</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>592</x>
<y>392</y>
<w>208</w>
<h>128</h>
</coordinates>
<panel_attributes>&lt;&lt;Interface&gt;&gt;
Loader
--
Functions:
wchar* LoadFile(string fileName);
//Model* LoadHitBoxes(string modelName);
//Model* LoadHitBoxes(int modelID);
-
Privates:</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>176</x>
<y>200</y>
<w>256</w>
<h>56</h>
</coordinates>
<panel_attributes>lt=-&gt;&gt;&gt;&gt;
m1=1..1
m2=1..1
&lt;Knows about</panel_attributes>
<additional_attributes>240;40;24;40</additional_attributes>
</element>
</diagram>

View File

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

View File

@ -0,0 +1,18 @@
//////////////////////////////////
// Created by Sam Svensson 2013 //
//////////////////////////////////
#include "LevelLoader.h"
using namespace GameLogic;
using namespace GameLogic::LevelFileLoader;
std::vector<ObjectTypeHeader> LevelLoader::LoadLevel(std::string fileName)
{
return parser.Parse(fileName);
}
LevelMetaData LevelLoader::LoadLevelHeader(std::string fileName)
{
return parser.ParseHeader(fileName);
}

View File

@ -0,0 +1,42 @@
//////////////////////////////////
// Created by Sam Svensson 2013 //
//////////////////////////////////
#ifndef LEVELLOADER_H
#define LEVELLOADER_H
#include <string>
#include <vector>
#include <Vector.h>
#include "ObjectDefines.h"
#include "LevelParser.h"
namespace GameLogic
{
class LevelLoader
{
public:
LevelLoader(){this->parser = GameLogic::LevelFileLoader::LevelParser(); }
~LevelLoader(){}
/********************************************************
* Loads the level and objects from file.
* @param fileName: Path to the level-file that you want to load.
* @return: Returns all structs with objects and information about the level.
********************************************************/
std::vector<ObjectTypeHeader> LoadLevel(std::string fileName);
/********************************************************
* Just for fast access for the meta information about the level.
* @param fileName: Path to the level-file that you want to load.
* @return: Returns the meta information about the level.
********************************************************/
LevelMetaData LoadLevelHeader(std::string fileName); //.
private:
GameLogic::LevelFileLoader::LevelParser parser;
};
}
#endif

View File

@ -0,0 +1,117 @@
#include "LevelParser.h"
#include "Loader.h"
#include "ParseFunctions.h"
using namespace GameLogic;
using namespace ::LevelFileLoader;
LevelParser::LevelParser()
{
formatVersion.formatVersionMajor = 1;
formatVersion.formatVersionMinor = 0;
}
LevelParser::~LevelParser()
{
}
std::vector<ObjectTypeHeader> LevelParser::Parse(std::string filename)
{
int bufferSize = 0;
int counter = 0;
std::vector<ObjectTypeHeader> objects;
//Read entire level file.
Loader loader;
char* buffer = (char*)loader.LoadFile(filename.c_str(), bufferSize);
//Read format version
FormatVersion levelFormatVersion;
//ParseObject(&buffer[counter], &levelFormatVersion, sizeof(formatVersion));
if(this->formatVersion != levelFormatVersion)
{
//Do something if it's not the same version
}
while(counter < bufferSize)
{
//Get typeID
ObjectTypeHeader typeID;
ParseObject(&buffer[counter], &typeID, sizeof(typeID));
switch((int)typeID.typeID)
{
case ObjectType_LevelMetaData:
{
LevelMetaData header;
ParseLevelMetaData(&buffer[counter], header, counter);
objects.push_back(header);
break;
}
case ObjectType_Dynamic:
{
ObjectHeader header;
ParseObject(&buffer[counter], &header, sizeof(header));
objects.push_back(header);
counter += sizeof(header);
break;
}
default:
//Couldn't find typeID. FAIL!!!!!!
break;
}
}
return objects;
}
//för meta information om leveln.
LevelMetaData LevelParser::ParseHeader(std::string filename)
{
int bufferSize = 0;
int counter = 0;
LevelMetaData levelHeader;
levelHeader.typeID = ObjectType::ObjectType_Unknown;
//Read entire level file.
Loader loader;
char* buffer = (char*)loader.LoadFile(filename.c_str(), bufferSize);
//Read format version
FormatVersion levelFormatVersion;
//ParseObject(&buffer[counter], &levelFormatVersion, sizeof(formatVersion));
if(this->formatVersion != levelFormatVersion)
{
//Do something if it's not the same version
}
//Find the header in the returned string.
while(counter < bufferSize)
{
ObjectTypeHeader typeID;
ParseObject(&buffer[counter], &typeID, sizeof(typeID));
switch(typeID.typeID)
{
case ObjectType_LevelMetaData:
ParseLevelMetaData(&buffer[counter], levelHeader, counter);
return levelHeader;
break;
case ObjectType_Dynamic:
//Do not call parse this object, since we are only interested in the LevelMetaData
//Only increase the counter size
counter += sizeof(ObjectHeader);
break;
default:
//Couldn't find typeID. FAIL!!!!!!
break;
}
}
return levelHeader;
}

View File

@ -0,0 +1,30 @@
#ifndef LEVEL_PARSER_H
#define LEVEL_PARSER_H
#include <string>
#include <vector>
#include "ObjectDefines.h"
namespace GameLogic
{
namespace LevelFileLoader
{
class LevelParser
{
public:
LevelParser();
~LevelParser();
//
std::vector<ObjectTypeHeader> Parse(std::string filename);
//
LevelMetaData ParseHeader(std::string filename);
private:
FormatVersion formatVersion;
};
}
}
#endif

View File

@ -0,0 +1,22 @@
//////////////////////////////////
// Created by Sam Svensson 2013 //
//////////////////////////////////
#include "Loader.h"
#include <fstream>
using namespace GameLogic::LevelFileLoader;
using namespace Oyster::Resource;
using namespace std;
char* Loader::LoadFile(std::string fileName, int &size)
{
//convert from string to wstring
std::wstring temp(fileName.begin(), fileName.end());
//convert from wstring to wchar then loads the file
char* buffer = (char*)OysterResource::LoadResource(temp.c_str(), Oyster::Resource::ResourceType::ResourceType_Byte_Raw, -1 , false);
size = OysterResource::GetResourceSize(buffer);
return buffer;
}

View File

@ -0,0 +1,28 @@
//////////////////////////////////
// Created by Sam Svensson 2013 //
//////////////////////////////////
#ifndef LOADER_H
#define LOADER_H
#include "..\Misc\Resource\OysterResource.h"
#include <string>
namespace GameLogic
{
namespace LevelFileLoader
{
class Loader
{
public:
Loader (){};
~Loader(){};
char* LoadFile(std::string fileName, int &size);
//TODO:
//Add functionality to load physicsObjects (hitboxes)
};
}
}
#endif;

View File

@ -0,0 +1,109 @@
#ifndef OBJECT_DEFINES_H
#define OBJECT_DEFINES_H
#include <string>
#include <vector>
namespace GameLogic
{
/************************************
Enums
*************************************/
enum ObjectType
{
ObjectType_LevelMetaData,
ObjectType_Static,
ObjectType_Dynamic,
//Etc
ObjectType_NUM_OF_TYPES,
ObjectType_Unknown = -1,
};
enum UsePhysics
{
UsePhysics_UseFullPhysics,
UsePhysics_IgnoreGravity,
UsePhysics_IgnorePhysics,
UsePhysics_Count,
UsePhysics_Unknown = -1,
};
//Should this be moved somewhere else?
enum GameMode
{
GameMode_FreeForAll,
GameMode_TeamDeathMatch,
//Etc
GameMode_Count,
GameMode_Unknown = -1,
};
/************************************
Structs
*************************************/
struct FormatVersion
{
int formatVersionMajor;
int formatVersionMinor;
bool operator ==(const FormatVersion& obj)
{
return (this->formatVersionMajor != obj.formatVersionMajor && this->formatVersionMinor != obj.formatVersionMinor);
}
bool operator !=(const FormatVersion& obj)
{
return !(*this == obj);
}
};
struct ObjectTypeHeader
{
ObjectType typeID;
};
struct PhysicsObject
{
float mass;
float elasticity;
float frictionCoeffStatic;
float frictionCoeffDynamic;
float inertiaTensor[16];
UsePhysics usePhysics;
};
struct LevelMetaData : ObjectTypeHeader
{
std::string levelName;
FormatVersion levelVersion;
std::string levelDescription;
std::string levelAuthor;
int maxNumberOfPlayer;
float worldSize;
int overviewPictureID;
std::vector<GameMode> gameModesSupported;
};
struct ObjectHeader : public ObjectTypeHeader
{
//Model,
int ModelID;
//Texture
int TextureID;
//Position
float position[3];
//Rotation
float rotation[3];
//Scale
float scale[3];
};
}
#endif

View File

@ -0,0 +1,80 @@
//////////////////////////////////
// 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(char* buffer, void *header, int size)
{
memcpy(header, buffer, size);
}
void ParseLevelMetaData(char* buffer, LevelMetaData &header, int &size)
{
int start = 0;
int tempSize;
char tempName[100];
memcpy(&header.typeID, &buffer[start], 4);
start += 4;
memcpy(&tempSize , &buffer[start], 4);
start += 4;
memcpy(&tempName, &buffer[start], tempSize);
header.levelName.assign(&tempName[0], &tempName[tempSize]);
start += tempSize;
memcpy(&header.levelVersion, &buffer[start], 8);
start += 8;
memcpy(&tempSize, &buffer[start], 4);
start +=4;
memcpy(&tempName, &buffer[start], tempSize);
header.levelDescription.assign(&tempName[0], &tempName[tempSize]);
start += tempSize;
memcpy(&tempSize, &buffer[start], 4);
start += 4;
memcpy(&tempName, &buffer[start], tempSize);
header.levelAuthor.assign(&tempName[0], &tempName[tempSize]);
start += tempSize;
memcpy(&header.maxNumberOfPlayer, &buffer[start], 4);
start += 4;
memcpy(&header.worldSize, &buffer[start], 4);
start += 4;
memcpy(&header.overviewPictureID, &buffer[start], 4);
start += 4;
memcpy(&tempSize, &buffer[start], 4);
start += 4;
int temp;
for(int i = 0; i < tempSize; i++)
{
memcpy(&temp, &buffer[start], 4);
start += 4;
header.gameModesSupported.push_back((GameMode)temp);
}
size += start;
}
}
}

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(char* buffer, void *header, int size);
void ParseLevelMetaData(char* buffer, LevelMetaData &header, int &size);
}
}
#endif

View File

@ -146,6 +146,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Packing\Packing.cpp" />
<ClCompile Include="Resource\Loaders\ByteLoader.cpp" />
<ClCompile Include="Resource\Loaders\CustomLoader.cpp" />
<ClCompile Include="Resource\OResourceHandler.cpp" />
@ -164,6 +165,7 @@
<ClInclude Include="GID.h" />
<ClInclude Include="IQueue.h" />
<ClInclude Include="OysterCallback.h" />
<ClInclude Include="Packing\Packing.h" />
<ClInclude Include="PostBox\IPostBox.h" />
<ClInclude Include="PostBox\PostBox.h" />
<ClInclude Include="Queue.h" />

View File

@ -48,6 +48,9 @@
<ClCompile Include="Resource\ResourceManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Packing\Packing.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Utilities.h">
@ -110,5 +113,8 @@
<ClInclude Include="Resource\ResourceManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Packing\Packing.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -0,0 +1,346 @@
#include "Packing.h"
/***************************
Packing
***************************/
#include <stdint.h>
namespace Oyster
{
namespace Packing
{
//bool (1-bit)
void Pack(unsigned char buffer[], bool i)
{
*buffer++ = i;
}
//char (8-bit)
void Pack(unsigned char buffer[], char i)
{
*buffer++ = i;
}
void Pack(unsigned char buffer[], unsigned char i)
{
*buffer++ = i;
}
//short (16-bit)
void Pack(unsigned char buffer[], short i)
{
*buffer++ = i >> 8;
*buffer++ = (char)i;
}
void Pack(unsigned char buffer[], unsigned short i)
{
*buffer++ = i >> 8;
*buffer++ = (char)i;
}
//int (32-bit)
void Pack(unsigned char buffer[], int i)
{
*buffer++ = i >> 24;
*buffer++ = i >> 16;
*buffer++ = i >> 8;
*buffer++ = i;
}
void Pack(unsigned char buffer[], unsigned int i)
{
*buffer++ = i >> 24;
*buffer++ = i >> 16;
*buffer++ = i >> 8;
*buffer++ = i;
}
//__int64 (64-bit)
void Pack(unsigned char buffer[], __int64 i)
{
*buffer++ = (char)(i >> 56);
*buffer++ = (char)(i >> 48);
*buffer++ = (char)(i >> 40);
*buffer++ = (char)(i >> 32);
*buffer++ = (char)(i >> 24);
*buffer++ = (char)(i >> 16);
*buffer++ = (char)(i >> 8);
*buffer++ = (char)i;
}
void Pack(unsigned char buffer[], unsigned __int64 i)
{
*buffer++ = (char)(i >> 56);
*buffer++ = (char)(i >> 48);
*buffer++ = (char)(i >> 40);
*buffer++ = (char)(i >> 32);
*buffer++ = (char)(i >> 24);
*buffer++ = (char)(i >> 16);
*buffer++ = (char)(i >> 8);
*buffer++ = (char)i;
}
//floating point (32, 64-bit)
void Pack(unsigned char buffer[], float i)
{
int tempFloat = (int)Pack754(i, 32, 8);
Pack(buffer, tempFloat);
}
void Pack(unsigned char buffer[], double i)
{
__int64 tempDouble = Pack754(i, 64, 11);
Pack(buffer, tempDouble);
}
//string
void Pack(unsigned char buffer[], char str[])
{
short len = (short)strlen(str);
Pack(buffer, len);
buffer += 2;
memcpy(buffer, str, len);
}
void Pack(unsigned char buffer[], std::string& str)
{
short len = (short)str.length();
Pack(buffer, len);
buffer += 2;
memcpy(buffer, str.c_str(), len);
}
unsigned __int64 Pack754(long double f, unsigned bits, unsigned expbits)
{
long double fnorm;
int shift;
long long sign, exp, significand;
unsigned significandbits = bits - expbits - 1; // -1 for sign bit
if (f == 0.0)
return 0; // get this special case out of the way
// check sign and begin normalization
if (f < 0)
{
sign = 1;
fnorm = -f;
}
else
{
sign = 0;
fnorm = f;
}
// get the normalized form of f and track the exponent
shift = 0;
while(fnorm >= 2.0)
{
fnorm /= 2.0;
shift++;
}
while(fnorm < 1.0)
{
fnorm *= 2.0;
shift--;
}
fnorm = fnorm - 1.0;
// calculate the binary form (non-float) of the significand data
significand = (long long)(fnorm * ((1LL << significandbits) + 0.5f));
// get the biased exponent
exp = shift + ((1 << (expbits - 1)) - 1); // shift + bias
// return the final answer
return (sign << (bits - 1)) | (exp << (bits - expbits - 1)) | significand;
}
/******************************
Unpacking
******************************/
//bool (1-bit)
bool Unpackb(unsigned char buffer[])
{
return *buffer;
}
//char (8-bit)
char Unpackc(unsigned char buffer[])
{
if(*buffer <= 0x7f)
{
return *buffer;
}
else
{
return (-1 - (unsigned char)(0xffu - *buffer));
}
}
unsigned char UnpackC(unsigned char buffer[])
{
return *buffer;
}
//short (16-bit)
short Unpacks(unsigned char buffer[])
{
short i = ((short)buffer[0] << 8) | buffer[1];
if(i > 0x7fffu)
{
i = -1 - (unsigned short)(0xffffu - i);
}
return i;
}
unsigned short UnpackS(unsigned char buffer[])
{
return ((unsigned int)buffer[0] << 8) | buffer[1];
}
//int (32-bit)
int Unpacki(unsigned char buffer[])
{
int i = ((int)buffer[0] << 24) |
((int)buffer[1] << 16) |
((int)buffer[2] << 8) |
((int)buffer[3]);
if(i > 0x7fffffffu)
{
i = -1 - (int)(0xffffffffu - i);
}
return i;
}
unsigned int UnpackI(unsigned char buffer[])
{
return ((unsigned int)buffer[0] << 24) |
((unsigned int)buffer[1] << 16) |
((unsigned int)buffer[2] << 8) |
((unsigned int)buffer[3]);
}
//__int64 (64-bit)
__int64 Unpacki64(unsigned char buffer[])
{
__int64 i = ((__int64)buffer[0] << 56) |
((__int64)buffer[1] << 48) |
((__int64)buffer[2] << 40) |
((__int64)buffer[3] << 32) |
((__int64)buffer[4] << 24) |
((__int64)buffer[5] << 16) |
((__int64)buffer[6] << 8) |
(buffer[7]);
if(i > 0x7fffffffffffffffu)
{
i = -1 - (__int64)(0xffffffffffffffffu - i);
}
return i;
}
unsigned __int64 UnpackI64(unsigned char buffer[])
{
return ((__int64)buffer[0] << 56) |
((__int64)buffer[1] << 48) |
((__int64)buffer[2] << 40) |
((__int64)buffer[3] << 32) |
((__int64)buffer[4] << 24) |
((__int64)buffer[5] << 16) |
((__int64)buffer[6] << 8) |
((__int64)buffer[7]);
}
//floating point (32, 64-bit)
float Unpackf(unsigned char buffer[])
{
int tempFloat = Unpacki(buffer);
return (float)Unpack754(tempFloat, 32, 8);
}
double Unpackd(unsigned char buffer[])
{
__int64 tempDouble = Unpacki64(buffer);
return Unpack754(tempDouble, 64, 11);
}
//string
char* UnpackCStr(unsigned char buffer[])
{
short len = UnpackS(buffer);
char* str = new char[len+1];
buffer += 2;
for(int i = 0; i < len; i++)
{
str[i] = buffer[i];
}
str[len] = '\0';
return str;
}
std::string UnpackStr(unsigned char buffer[])
{
short len = UnpackS(buffer);
std::string temp;
temp.resize(len);
buffer += 2;
for(int i = 0; i < len; i++)
{
temp[i] = buffer[i];
}
return temp;
}
long double Unpack754(unsigned __int64 i, unsigned bits, unsigned expbits)
{
long double result;
long long shift;
unsigned bias;
unsigned significandbits = bits - expbits - 1; // -1 for sign bit
if (i == 0)
return 0.0;
// pull the significand
result = (long double)(i&((1LL << significandbits) - 1)); // mask
result /= (1LL << significandbits); // convert back to float
result += 1.0f; // add the one back on
// deal with the exponent
bias = (1 << (expbits - 1)) - 1;
shift = ((i >> significandbits) & ((1LL << expbits) - 1)) - bias;
while(shift > 0)
{
result *= 2.0;
shift--;
}
while(shift < 0)
{
result /= 2.0;
shift++;
}
// sign it
result *= (i >> (bits - 1)) & 1 ? -1.0 : 1.0;
return result;
}
}
}

View File

@ -0,0 +1,81 @@
#ifndef PACKING_H
#define PACKING_H
/////////////////////////////////////
// Created by Pontus Fransson 2013 //
/////////////////////////////////////
#include <string>
/******************************
Packing
******************************/
namespace Oyster
{
namespace Packing
{
//bool (1-bit)
void Pack(unsigned char buffer[], bool i);
//char (8-bit)
void Pack(unsigned char buffer[], char i);
void Pack(unsigned char buffer[], unsigned char i); // unsigned
//short (16-bit)
void Pack(unsigned char buffer[], short i);
void Pack(unsigned char buffer[], unsigned short i); // unsigned
//int (32-bit)
void Pack(unsigned char buffer[], int i);
void Pack(unsigned char buffer[], unsigned int i); // unsigned
//__int64 (64-bit)
void Pack(unsigned char buffer[], __int64 i);
void Pack(unsigned char buffer[], unsigned __int64 i); // unsigned
//floating point (32, 64-bit)
void Pack(unsigned char buffer[], float i);
void Pack(unsigned char buffer[], double i);
//string
void Pack(unsigned char buffer[], char str[]);
void Pack(unsigned char buffer[], std::string& str);
unsigned __int64 Pack754(long double f, unsigned bits, unsigned expbits);
/******************************
Unpacking
******************************/
//bool (1-bit)
bool Unpackb(unsigned char buffer[]);
//char (8-bit)
char Unpackc(unsigned char buffer[]);
unsigned char UnpackC(unsigned char buffer[]); // unsigned
//short (16-bit)
short Unpacks(unsigned char buffer[]);
unsigned short UnpackS(unsigned char buffer[]); // unsigned
//int (32-bit)
int Unpacki(unsigned char buffer[]);
unsigned int UnpackI(unsigned char buffer[]); // unsigned
//__int64 (64-bit)
__int64 Unpacki64(unsigned char buffer[]);
unsigned __int64 UnpackI64(unsigned char buffer[]); // unsigned
//floating point (32, 64-bit)
float Unpackf(unsigned char buffer[]);
double Unpackd(unsigned char buffer[]);
//string
char* UnpackCStr(unsigned char buffer[]);
std::string UnpackStr(unsigned char buffer[]);
long double Unpack754(unsigned __int64 i, unsigned bits, unsigned expbits);
}
}
#endif

View File

@ -214,7 +214,14 @@ int OysterResource::GetResourceId(const wchar_t c[])
return -1;
}
int OysterResource::GetResourceSize(const OHRESOURCE& resource)
{
OResource* t = resourcePrivate.FindResource(resource);
if(t) return t->GetResourceSize();
return -1;
}
OResource* ResourcePrivate::FindResource(const OHRESOURCE& h) const
{

View File

@ -151,6 +151,11 @@ namespace Oyster
*/
static int GetResourceId(const wchar_t filename[]);
static int GetResourceSize(const OHRESOURCE& resource);
};
}
}

View File

@ -1,8 +1,9 @@
#include "MessageHeader.h"
#include "../Packing.h"
#include "../../../Misc/Packing/Packing.h"
#include <iostream>
using namespace std;
using namespace Oyster::Packing;
using namespace Oyster::Network;
using namespace Oyster::Network::Messages;
using namespace Oyster::Network::Protocols;

View File

@ -157,7 +157,6 @@
<ClCompile Include="Messages\MessagePlayerPos.cpp" />
<ClCompile Include="Messages\MessageTest.cpp" />
<ClCompile Include="OysterByte.cpp" />
<ClCompile Include="Packing.cpp" />
<ClCompile Include="ThreadedClient.cpp" />
<ClCompile Include="WinsockFunctions.cpp" />
</ItemGroup>
@ -171,7 +170,6 @@
<ClInclude Include="Messages\MessagesInclude.h" />
<ClInclude Include="Messages\MessageTest.h" />
<ClInclude Include="OysterByte.h" />
<ClInclude Include="Packing.h" />
<ClInclude Include="ITranslate.h" />
<ClInclude Include="PostBox.h" />
<ClInclude Include="Protocols.h" />

View File

@ -7,7 +7,6 @@
<ClCompile Include="Messages\MessagePlayerPos.cpp" />
<ClCompile Include="Messages\MessageTest.cpp" />
<ClCompile Include="OysterByte.cpp" />
<ClCompile Include="Packing.cpp" />
<ClCompile Include="ThreadedClient.cpp" />
<ClCompile Include="WinsockFunctions.cpp" />
</ItemGroup>
@ -21,7 +20,6 @@
<ClInclude Include="Messages\MessagesInclude.h" />
<ClInclude Include="Messages\MessageTest.h" />
<ClInclude Include="OysterByte.h" />
<ClInclude Include="Packing.h" />
<ClInclude Include="ITranslate.h" />
<ClInclude Include="PostBox.h" />
<ClInclude Include="Protocols.h" />

View File

@ -1,486 +0,0 @@
#include "Packing.h"
/***************************
Packing
***************************/
#include <stdint.h>
namespace Oyster
{
namespace Network
{
namespace Packing
{
//bool (1-bit)
void Pack(unsigned char buffer[], bool i)
{
*buffer++ = i;
}
//char (8-bit)
void Pack(unsigned char buffer[], char i)
{
*buffer++ = i;
}
void Pack(unsigned char buffer[], unsigned char i)
{
*buffer++ = i;
}
//short (16-bit)
void Pack(unsigned char buffer[], short i)
{
*buffer++ = i >> 8;
*buffer++ = (char)i;
}
void Pack(unsigned char buffer[], unsigned short i)
{
*buffer++ = i >> 8;
*buffer++ = (char)i;
}
//int (32-bit)
void Pack(unsigned char buffer[], int i)
{
*buffer++ = i >> 24;
*buffer++ = i >> 16;
*buffer++ = i >> 8;
*buffer++ = i;
}
void Pack(unsigned char buffer[], unsigned int i)
{
*buffer++ = i >> 24;
*buffer++ = i >> 16;
*buffer++ = i >> 8;
*buffer++ = i;
}
//__int64 (64-bit)
void Pack(unsigned char buffer[], __int64 i)
{
*buffer++ = (char)(i >> 56);
*buffer++ = (char)(i >> 48);
*buffer++ = (char)(i >> 40);
*buffer++ = (char)(i >> 32);
*buffer++ = (char)(i >> 24);
*buffer++ = (char)(i >> 16);
*buffer++ = (char)(i >> 8);
*buffer++ = (char)i;
}
void Pack(unsigned char buffer[], unsigned __int64 i)
{
*buffer++ = (char)(i >> 56);
*buffer++ = (char)(i >> 48);
*buffer++ = (char)(i >> 40);
*buffer++ = (char)(i >> 32);
*buffer++ = (char)(i >> 24);
*buffer++ = (char)(i >> 16);
*buffer++ = (char)(i >> 8);
*buffer++ = (char)i;
}
//floating point (32, 64-bit)
void Pack(unsigned char buffer[], float i)
{
int tempFloat = (int)Pack754(i, 32, 8);
Pack(buffer, tempFloat);
}
void Pack(unsigned char buffer[], double i)
{
__int64 tempDouble = Pack754(i, 64, 11);
Pack(buffer, tempDouble);
}
//string
void Pack(unsigned char buffer[], char str[])
{
short len = (short)strlen(str);
Pack(buffer, len);
buffer += 2;
memcpy(buffer, str, len);
}
void Pack(unsigned char buffer[], std::string& str)
{
short len = (short)str.length();
Pack(buffer, len);
buffer += 2;
memcpy(buffer, str.c_str(), len);
}
unsigned __int64 Pack754(long double f, unsigned bits, unsigned expbits)
{
long double fnorm;
int shift;
long long sign, exp, significand;
unsigned significandbits = bits - expbits - 1; // -1 for sign bit
if (f == 0.0)
return 0; // get this special case out of the way
// check sign and begin normalization
if (f < 0)
{
sign = 1;
fnorm = -f;
}
else
{
sign = 0;
fnorm = f;
}
// get the normalized form of f and track the exponent
shift = 0;
while(fnorm >= 2.0)
{
fnorm /= 2.0;
shift++;
}
while(fnorm < 1.0)
{
fnorm *= 2.0;
shift--;
}
fnorm = fnorm - 1.0;
// calculate the binary form (non-float) of the significand data
significand = (long long)(fnorm * ((1LL << significandbits) + 0.5f));
// get the biased exponent
exp = shift + ((1 << (expbits - 1)) - 1); // shift + bias
// return the final answer
return (sign << (bits - 1)) | (exp << (bits - expbits - 1)) | significand;
}
/******************************
Unpacking
******************************/
//bool (1-bit)
bool Unpackb(unsigned char buffer[])
{
return *buffer;
}
//char (8-bit)
char Unpackc(unsigned char buffer[])
{
if(*buffer <= 0x7f)
{
return *buffer;
}
else
{
return (-1 - (unsigned char)(0xffu - *buffer));
}
}
unsigned char UnpackC(unsigned char buffer[])
{
return *buffer;
}
//short (16-bit)
short Unpacks(unsigned char buffer[])
{
short i = ((short)buffer[0] << 8) | buffer[1];
if(i > 0x7fffu)
{
i = -1 - (unsigned short)(0xffffu - i);
}
return i;
}
unsigned short UnpackS(unsigned char buffer[])
{
return ((unsigned int)buffer[0] << 8) | buffer[1];
}
//int (32-bit)
int Unpacki(unsigned char buffer[])
{
int i = ((int)buffer[0] << 24) |
((int)buffer[1] << 16) |
((int)buffer[2] << 8) |
((int)buffer[3]);
if(i > 0x7fffffffu)
{
i = -1 - (int)(0xffffffffu - i);
}
return i;
}
unsigned int UnpackI(unsigned char buffer[])
{
return ((unsigned int)buffer[0] << 24) |
((unsigned int)buffer[1] << 16) |
((unsigned int)buffer[2] << 8) |
((unsigned int)buffer[3]);
}
//__int64 (64-bit)
__int64 Unpacki64(unsigned char buffer[])
{
__int64 i = ((__int64)buffer[0] << 56) |
((__int64)buffer[1] << 48) |
((__int64)buffer[2] << 40) |
((__int64)buffer[3] << 32) |
((__int64)buffer[4] << 24) |
((__int64)buffer[5] << 16) |
((__int64)buffer[6] << 8) |
(buffer[7]);
if(i > 0x7fffffffffffffffu)
{
i = -1 - (__int64)(0xffffffffffffffffu - i);
}
return i;
}
unsigned __int64 UnpackI64(unsigned char buffer[])
{
return ((__int64)buffer[0] << 56) |
((__int64)buffer[1] << 48) |
((__int64)buffer[2] << 40) |
((__int64)buffer[3] << 32) |
((__int64)buffer[4] << 24) |
((__int64)buffer[5] << 16) |
((__int64)buffer[6] << 8) |
((__int64)buffer[7]);
}
//floating point (32, 64-bit)
float Unpackf(unsigned char buffer[])
{
int tempFloat = Unpacki(buffer);
return (float)Unpack754(tempFloat, 32, 8);
}
double Unpackd(unsigned char buffer[])
{
__int64 tempDouble = Unpacki64(buffer);
return Unpack754(tempDouble, 64, 11);
}
//string
char* UnpackCStr(unsigned char buffer[])
{
short len = UnpackS(buffer);
char* str = new char[len+1];
buffer += 2;
for(int i = 0; i < len; i++)
{
str[i] = buffer[i];
}
str[len] = '\0';
return str;
}
std::string UnpackStr(unsigned char buffer[])
{
short len = UnpackS(buffer);
std::string temp;
temp.resize(len);
buffer += 2;
for(int i = 0; i < len; i++)
{
temp[i] = buffer[i];
}
return temp;
}
long double Unpack754(unsigned __int64 i, unsigned bits, unsigned expbits)
{
long double result;
long long shift;
unsigned bias;
unsigned significandbits = bits - expbits - 1; // -1 for sign bit
if (i == 0)
return 0.0;
// pull the significand
result = (long double)(i&((1LL << significandbits) - 1)); // mask
result /= (1LL << significandbits); // convert back to float
result += 1.0f; // add the one back on
// deal with the exponent
bias = (1 << (expbits - 1)) - 1;
shift = ((i >> significandbits) & ((1LL << expbits) - 1)) - bias;
while(shift > 0)
{
result *= 2.0;
shift--;
}
while(shift < 0)
{
result /= 2.0;
shift++;
}
// sign it
result *= (i >> (bits - 1)) & 1 ? -1.0 : 1.0;
return result;
}
}
}
}
/*
int32_t pack(unsigned char* buffer, char* format, ...)
{
va_list ap;
int16_t h;
int32_t l;
int8_t c;
float f;
double d;
char* s;
int32_t size = 0, len;
va_start(ap, format);
for(; *format != '\0'; format++)
{
switch(*format)
{
case 'h': // 16-bit
size += 2;
h = (int16_t)va_arg(ap, int);
packi16(buffer, h);
buffer += 2;
break;
case 'l': // 32-bit
size += 4;
l = va_arg(ap, int32_t);
packi32(buffer, l);
buffer += 4;
break;
case 'c': // 8-bit
size += 1;
c = (int8_t)va_arg(ap, int);
*buffer++ = (c >> 0)&0xff;
break;
case 'f': // float (32-bit)
size += 4;
f = (float)va_arg(ap, double);
//l = pack754(f, 32, 8);
packi32(buffer, l);
buffer += 4;
break;
case 'd': // double (64-bit)
size += 8;
d = (float)va_arg(ap, double);
//l = pack754(f, 64, 11);
packi32(buffer, l);
buffer += 4;
break;
case 's': // string
s = va_arg(ap, char*);
len = strlen(s);
size += len + 2;
packi16(buffer, len);
buffer += 2;
memcpy(buffer, s, len);
buffer += len;
break;
}
}
va_end(ap);
return size;
}
*/
/*
void unpack(unsigned char* buffer, char* format, ...)
{
va_list ap;
int16_t* h;
int32_t* l;
int32_t pf;
int64_t pd;
int8_t* c;
float* f;
double* d;
char* s;
int32_t len, count, maxstrlen = 0;
va_start(ap, format);
for(; *format != '\0'; format++)
{
switch(*format)
{
case 'h': // 16-bit
h = va_arg(ap, int16_t*);
*h = unpacki16(buffer);
buffer += 2;
break;
case 'l': // 32-bit
l = va_arg(ap, int32_t*);
*l = unpacki32(buffer);
buffer += 4;
break;
case 'c': // 8-bit
c = va_arg(ap, int8_t*);
*c = *buffer++;
break;
case 'f': // float
f = va_arg(ap, float*);
pf = unpacki32(buffer);
buffer += 4;
//*f = unpack754(pf, 32, 8);
break;
case 'd': // double (64-bit)
d = va_arg(ap, double*);
pd = unpacki64(buffer);
buffer += 8;
//*d = unpack754(pf, 64, 11);
break;
case 's': // string
s = va_arg(ap, char*);
len = unpacki16(buffer);
buffer += 2;
if (maxstrlen > 0 && len > maxstrlen) count = maxstrlen - 1;
else count = len;
memcpy(s, buffer, count);
s[count] = '\0';
buffer += len;
break;
default:
if (isdigit(*format)) // track max str len
{
maxstrlen = maxstrlen * 10 + (*format-'0');
}
}
if(!isdigit(*format))
maxstrlen = 0;
}
va_end(ap);
}*/

View File

@ -1,107 +0,0 @@
#ifndef PACKING_H
#define PACKING_H
/////////////////////////////////////
// Created by Pontus Fransson 2013 //
/////////////////////////////////////
#include <string>
/******************************
Packing
******************************/
namespace Oyster
{
namespace Network
{
namespace Packing
{
//bool (1-bit)
void Pack(unsigned char buffer[], bool i);
//char (8-bit)
void Pack(unsigned char buffer[], char i);
void Pack(unsigned char buffer[], unsigned char i); // unsigned
//short (16-bit)
void Pack(unsigned char buffer[], short i);
void Pack(unsigned char buffer[], unsigned short i); // unsigned
//int (32-bit)
void Pack(unsigned char buffer[], int i);
void Pack(unsigned char buffer[], unsigned int i); // unsigned
//__int64 (64-bit)
void Pack(unsigned char buffer[], __int64 i);
void Pack(unsigned char buffer[], unsigned __int64 i); // unsigned
//floating point (32, 64-bit)
void Pack(unsigned char buffer[], float i);
void Pack(unsigned char buffer[], double i);
//string
void Pack(unsigned char buffer[], char str[]);
void Pack(unsigned char buffer[], std::string& str);
unsigned __int64 Pack754(long double f, unsigned bits, unsigned expbits);
/******************************
Unpacking
******************************/
//bool (1-bit)
bool Unpackb(unsigned char buffer[]);
//char (8-bit)
char Unpackc(unsigned char buffer[]);
unsigned char UnpackC(unsigned char buffer[]); // unsigned
//short (16-bit)
short Unpacks(unsigned char buffer[]);
unsigned short UnpackS(unsigned char buffer[]); // unsigned
//int (32-bit)
int Unpacki(unsigned char buffer[]);
unsigned int UnpackI(unsigned char buffer[]); // unsigned
//__int64 (64-bit)
__int64 Unpacki64(unsigned char buffer[]);
unsigned __int64 UnpackI64(unsigned char buffer[]); // unsigned
//floating point (32, 64-bit)
float Unpackf(unsigned char buffer[]);
double Unpackd(unsigned char buffer[]);
//string
char* UnpackCStr(unsigned char buffer[]);
std::string UnpackStr(unsigned char buffer[]);
long double Unpack754(unsigned __int64 i, unsigned bits, unsigned expbits);
}
}
}
//int32_t pack(unsigned char* buffer, char* format, ...);
//void unpack(unsigned char* buffer, char* format, ...);
/***********************************************
* This table is used for naming pack/unpack functions.
* It's also used to identify types in the 'format' string in function pack()/unpack()
*
* bits |signed unsigned float string
* -----+----------------------------------
* 1 | b
* 8 | c C
* 16 | s S f
* 32 | i I d
* 64 | q Q g
* - | str
*
* (16-bit unsigned length is automatically added in front of strings)
*
*/
#endif