Files
Henrique Gemignani Passos Lima b6a64cee06 CGameAreaResource
2023-02-18 14:51:58 -08:00

86 lines
1.4 KiB
Plaintext

#ifndef _COMMON
#define _COMMON
typedef uchar bool;
typedef struct
{
string text;
} CString <bgcolor=0xCDE6FF, read=StringRead>;
typedef struct
{
uint size;
char text[size];
} CStringFixed <bgcolor=0xCDE6FF, read=StringReadFixed>;
string StringRead(CString &str)
{
return str.text;
}
string StringReadFixed(CStringFixed &str)
{
return str.text;
}
typedef char FourCC[4] <fgcolor=cLtGreen>;
FourCC FourCCInt(uint32 in)
{
FourCC fcc;
fcc[0] = (in >> 24) & 0xFF;
fcc[1] = (in >> 16) & 0xFF;
fcc[2] = (in >> 8) & 0xFF;
fcc[3] = (in >> 0) & 0xFF;
return fcc;
}
string FormatBytes(uint64 size)
{
byte order = 0;
while (size >= 1024 && order < 5)
{
order++;
size /= 1024;
}
string suffix;
switch (order)
{
case 0:
suffix = "";
break;
case 1:
suffix = " KiB";
break;
case 2:
suffix = " MiB";
break;
case 3:
suffix = " GiB";
break;
case 4:
suffix = " TiB";
break;
}
return Str("%d%s", size, suffix);
}
string SizeComment(uint64 size)
{
return Str("Size: %s (0x%X)", FormatBytes(size), size);
}
local GUID GUIDZero <hidden=true>;
typedef enum <byte>
{
NONE = 0x0,
LZSS_8 = 0x1,
LZSS_16 = 0x2,
LZSS_32 = 0x3,
ZLIB = 0xD,
} CompressionType;
#endif// _COMMON