Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
// Stack utlity in case of recursion of types like struct*, array<struct>* etc..
#define STACK_SIZE 100
void push(uint32 ioStack[], uint32& ioStackSize, uint32 iValue)
{
ioStack[ioStackSize] = iValue;
++ioStackSize;
}
uint32 getValue(uint32 ioStack[], uint32& ioStackSize, uint16 iOffset)
{
return ioStack[ioStackSize - 1 - iOffset];
}
void pop(uint32& ioStackSize)
{
--ioStackSize;
}
local uint32 sOffsetStack[STACK_SIZE];
local uint32 sOffsetStackSize = 0;
local uint32 sCountStack[STACK_SIZE];
local uint32 sCountStackSize = 0;
local uint32 sLoopIndexStack[STACK_SIZE];
local uint32 sLoopIndexStackSize = 0;
void pushOffset(uint32 iValue) { push(sOffsetStack, sOffsetStackSize, iValue); }
uint32 getOffsetValue(uint16 iOffset) { return getValue(sOffsetStack, sOffsetStackSize, iOffset); }
void popOffset() { pop(sOffsetStackSize); }
void pushCount(uint32 iValue) { push(sCountStack, sCountStackSize, iValue); }
uint32 getCountValue(uint16 iOffset) { return getValue(sCountStack, sCountStackSize, iOffset); }
void popCount() { pop(sCountStackSize); }
void pushLoopIndex(uint32 iValue) { push(sLoopIndexStack, sLoopIndexStackSize, iValue); }
uint32 getLoopIndexValue(uint16 iOffset) { return getValue(sLoopIndexStack, sLoopIndexStackSize, iOffset); }
void popLoopIndex() { pop(sLoopIndexStackSize); }
// 0x00 -- end
// 0x01 -- array<struct>
// 0x02 -- array<struct>*
#define TSTRUCT_ARRAY_PTR_START \
pushCount(ReadUInt(FTell())); \
FSkip(sizeof(uint32)); \
pushOffset(FTell()); \
pushOffset(ReadUInt(FTell())); \
FSkip(sizeof(uint32)); \
if (getOffsetValue(0) != 0 && getCountValue(0) != 0) \
{ \
FSeek(getOffsetValue(1) + getOffsetValue(0));
#define TSTRUCT_ARRAY_PTR_END \
[getCountValue(0)]; \
FSeek(getOffsetValue(1) + sizeof(uint32)); \
} \
popOffset(); \
popOffset(); \
popCount();
// 0x03 -- array<struct*>*
local uint32 sTempLoopIndex<hidden=true>;
#define TSTRUCT_PTR_ARRAY_PTR_START \
pushCount(ReadUInt(FTell())); \
FSkip(sizeof(uint32)); \
pushOffset(FTell()); \
pushOffset(ReadUInt(FTell())); \
FSkip(sizeof(uint32)); \
if (getOffsetValue(0) != 0 && getCountValue(0) != 0) \
{ \
FSeek(getOffsetValue(1) + getOffsetValue(0)); \
pushLoopIndex(0); \
while (getLoopIndexValue(0) < getCountValue(0)) \
{ \
pushOffset(FTell()); \
pushOffset(ReadUInt(FTell())); \
FSkip(sizeof(uint32)); \
if (getOffsetValue(0) != 0) \
{ \
FSeek(getOffsetValue(1) + getOffsetValue(0));
#define TSTRUCT_PTR_ARRAY_PTR_END \
; \
FSeek(getOffsetValue(1) + sizeof(uint32)); \
} \
popOffset(); \
popOffset(); \
sTempLoopIndex = getLoopIndexValue(0) + 1; \
popLoopIndex(); \
pushLoopIndex(sTempLoopIndex); \
} \
popLoopIndex(); \
FSeek(getOffsetValue(1) + sizeof(uint32)); \
} \
popOffset(); \
popOffset(); \
popCount();
// 0x10 -- struct*
#define TPTR_START \
pushOffset(FTell()); \
pushOffset(ReadUInt(FTell())); \
FSkip(sizeof(uint32)); \
if (getOffsetValue(0) != 0) \
{ \
FSeek(getOffsetValue(1) + getOffsetValue(0));
#define TPTR_END \
; \
FSeek(getOffsetValue(1) + sizeof(uint32)); \
} \
popOffset(); \
popOffset();
// 0x04 --
// 0x05 -- byte
// 0x06 -- byte4
typedef struct
{
byte data[4];
} byte4;
// 0x07 -- double
// 0x08 --
// 0x09 --
// 0x0A -- dword
typedef int32 dword;
// 0x0B -- filename
struct filename;
string readFilename(const filename& iFilename)
{
if (exists(iFilename.data))
{
string result;
SPrintf(result, "%d", 0xFF00 * (iFilename.data.highValue - 0x100) + (iFilename.data.lowValue - 0x100) + 1);
return result;
}
return "0";
}
typedef struct
{
TPTR_START
struct
{
uint16 lowValue;
uint16 highValue;
uint16 zero;
} data TPTR_END;
} filename<read=readFilename, optimize=false>;
// 0x0C -- float
// 0x0D -- float2
typedef struct
{
float data[2];
} float2;
// 0x0E -- float3
typedef struct
{
float data[3];
} float3;
// 0x0F -- float4
typedef struct
{
float data[4];
} float4;
// 0x11 -- qword
typedef int64 qword;
// 0x12 -- wchar*
struct wchar_ptr;
wstring readWCharPtr(wchar_ptr& iWCharPtr)
{
if (exists(iWCharPtr.data))
{
return iWCharPtr.data;
}
return "0";
}
typedef struct
{
TPTR_START wstring data TPTR_END;
} wchar_ptr<read=readWCharPtr, optimize=false>;
// 0x13 -- char*
struct char_ptr;
wstring readCharPtr(char_ptr& iCharPtr)
{
if (exists(iCharPtr.data))
{
return iCharPtr.data;
}
return "0";
}
typedef struct
{
TPTR_START string data TPTR_END;
} char_ptr<read=readCharPtr, optimize=false>;
// 0x14 -- struct
// 0x15 -- word
typedef int16 word;
// 0x16 -- byte16
typedef struct
{
byte data[16];
} byte16;
// 0x17 -- byte3
typedef struct
{
byte data[3];
} byte3;
// 0x18 -- dword2
typedef struct
{
dword data[2];
} dword2;
// 0x19 -- dword4
typedef struct
{
dword data[4];
} dword4;
// 0x1A -- word3
typedef struct
{
word data[3];
} word3;
// 0x1B -- fileref
typedef int32 fileref;
// 0x1C --
// 0x1D -- struct