Skip to content

Commit

Permalink
Reformat: Common
Browse files Browse the repository at this point in the history
  • Loading branch information
invokr committed Jan 15, 2017
1 parent 5f64707 commit 716dc03
Show file tree
Hide file tree
Showing 20 changed files with 2,522 additions and 2,738 deletions.
12 changes: 4 additions & 8 deletions src/Common/GUID.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,16 @@ class xrGUID
public:
u64 g[2];

ICF bool operator== (const xrGUID &that) const
{ return g[0]==that.g[0] && g[1]==that.g[1]; }

ICF bool operator!= (const xrGUID &that) const
{ return !(*this==that); }

ICF void LoadLTX(CInifile &ini, const char *section, const char *name)
ICF bool operator==(const xrGUID& that) const { return g[0] == that.g[0] && g[1] == that.g[1]; }
ICF bool operator!=(const xrGUID& that) const { return !(*this == that); }
ICF void LoadLTX(CInifile& ini, const char* section, const char* name)
{
string128 buff;
g[0] = ini.r_u64(section, strconcat(sizeof(buff), buff, name, "_g0"));
g[1] = ini.r_u64(section, strconcat(sizeof(buff), buff, name, "_g1"));
}

ICF void SaveLTX(CInifile &ini, const char *section, const char *name)
ICF void SaveLTX(CInifile& ini, const char* section, const char* name)
{
string128 buff;
ini.w_u64(section, strconcat(sizeof(buff), buff, name, "_g0"), g[0]);
Expand Down
87 changes: 46 additions & 41 deletions src/Common/LevelGameDef.h
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
#pragma once

#define RPOINT_CHOOSE_NAME "$rpoint"
#define ENVMOD_CHOOSE_NAME "$env_mod"
#define RPOINT_CHOOSE_NAME "$rpoint"
#define ENVMOD_CHOOSE_NAME "$env_mod"

enum EPointType{
ptRPoint=0,
enum EPointType
{
ptRPoint = 0,
ptEnvMod,
ptSpawnPoint,
ptMaxType,
pt_force_dword=u32(-1)
pt_force_dword = u32(-1)
};

enum EWayType{
wtPatrolPath=0,
enum EWayType
{
wtPatrolPath = 0,
wtMaxType,
wt_force_dword=u32(-1)
wt_force_dword = u32(-1)
};

enum ERPpointType{ // [0..255]
rptActorSpawn = 0,
rptArtefactSpawn,
enum ERPpointType
{ // [0..255]
rptActorSpawn = 0,
rptArtefactSpawn,
rptItemSpawn,
rptLast = 0xff
};

enum EEnvModUsedParams{ eViewDist =(1<<0),
eFogColor =(1<<1),
eFogDensity =(1<<2),
eAmbientColor =(1<<3),
eSkyColor =(1<<4),
eHemiColor =(1<<5)
enum EEnvModUsedParams
{
eViewDist = (1 << 0),
eFogColor = (1 << 1),
eFogDensity = (1 << 2),
eAmbientColor = (1 << 3),
eSkyColor = (1 << 4),
eHemiColor = (1 << 5)
};

/* // XXX: find better place for this (need cpp)
Expand All @@ -42,64 +47,64 @@ xr_token rpoint_type[] = {
*/

// BASE offset
#define WAY_BASE 0x1000
#define POINT_BASE 0x2000
#define WAY_BASE 0x1000
#define POINT_BASE 0x2000

// POINT chunks
#define RPOINT_CHUNK POINT_BASE+ptRPoint
#define RPOINT_CHUNK POINT_BASE + ptRPoint

// WAY chunks
#define WAY_PATROLPATH_CHUNK WAY_BASE+wtPatrolPath
#define WAY_PATROLPATH_CHUNK WAY_BASE + wtPatrolPath
//----------------------------------------------------

#define WAYOBJECT_VERSION 0x0013
#define WAYOBJECT_VERSION 0x0013
//----------------------------------------------------
#define WAYOBJECT_CHUNK_VERSION 0x0001
#define WAYOBJECT_CHUNK_POINTS 0x0002
#define WAYOBJECT_CHUNK_LINKS 0x0003
#define WAYOBJECT_CHUNK_TYPE 0x0004
#define WAYOBJECT_CHUNK_NAME 0x0005
#define WAYOBJECT_CHUNK_VERSION 0x0001
#define WAYOBJECT_CHUNK_POINTS 0x0002
#define WAYOBJECT_CHUNK_LINKS 0x0003
#define WAYOBJECT_CHUNK_TYPE 0x0004
#define WAYOBJECT_CHUNK_NAME 0x0005

/*
- chunk RPOINT_CHUNK
- chunk #0
- chunk #0
vector3 (PPosition);
vector3 (PRotation);
u8 (team_id);
u8 (type)
u16 (reserved)
...
- chunk #n
- chunk WAY_PATH_CHUNK
- chunk #0
chunk WAYOBJECT_CHUNK_VERSION
word (version)
chunk WAYOBJECT_CHUNK_NAME
stringZ (Name)
- chunk #0
chunk WAYOBJECT_CHUNK_VERSION
word (version)
chunk WAYOBJECT_CHUNK_NAME
stringZ (Name)
chunk WAY_CHUNK_TYPE
dword EWayType (type)
dword EWayType (type)
chunk WAY_CHUNK_POINTS
word (count)
for (i=0; i<count; ++i){
Fvector (pos)
Fvector (pos)
dword (flags)
stringZ (name)
}
chunk WAY_CHUNK_LINKS
word (count)
for (i=0; i<count; ++i){
word (from)
word (to)
word (from)
word (to)
float (probability)
}
...
- chunk #n
- chunk WAY_JUMP_CHUNK
-//-
-//-
- chunk WAY_TRAFFIC_CHUNK
-//-
-//-
- chunk WAY_CUSTOM_CHUNK
-//-
-//-
*/
114 changes: 44 additions & 70 deletions src/Common/LevelStructure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@

enum fsL_Chunks
{
fsL_HEADER = 1, //*
fsL_SHADERS = 2, //*
fsL_VISUALS = 3, //*
fsL_PORTALS = 4, //* - Portal polygons
fsL_LIGHT_DYNAMIC = 6, //*
fsL_GLOWS = 7, //* - All glows inside level
fsL_SECTORS = 8, //* - All sectors on level
fsL_VB = 9, //* - Static geometry
fsL_IB = 10, //*
fsL_SWIS = 11, //* - collapse info, usually for trees
fsL_HEADER = 1, //*
fsL_SHADERS = 2, //*
fsL_VISUALS = 3, //*
fsL_PORTALS = 4, //* - Portal polygons
fsL_LIGHT_DYNAMIC = 6, //*
fsL_GLOWS = 7, //* - All glows inside level
fsL_SECTORS = 8, //* - All sectors on level
fsL_VB = 9, //* - Static geometry
fsL_IB = 10, //*
fsL_SWIS = 11, //* - collapse info, usually for trees
fsL_forcedword = 0xFFFFFFFF
};

enum fsESectorChunks
{
fsP_Portals = 1, // - portal polygons
fsP_Root = 2, // - geometry root
fsP_Portals = 1, // - portal polygons
fsP_Root = 2, // - geometry root
fsP_forcedword = u32(-1)
};

enum fsSLS_Chunks
{
fsSLS_Description = 1, // Name of level
fsSLS_Description = 1, // Name of level
fsSLS_ServerState = 2,
fsSLS_forcedword = u32(-1)
};
Expand Down Expand Up @@ -73,27 +73,12 @@ class NodePosition
u8 data[5];

ICF void xz(u32 value) { CopyMemory(data, &value, 3); }

ICF void y(u16 value) { CopyMemory(data+3, &value, 2); }

ICF void y(u16 value) { CopyMemory(data + 3, &value, 2); }
public:
ICF u32 xz() const
{
return ((*((u32*)data)) & 0x00ffffff);
}
ICF u32 x(u32 row) const
{
return (xz() / row);
}
ICF u32 z(u32 row) const
{
return (xz() % row);
}
ICF u32 y() const
{
return (*((u16*)(data + 3)));
}

ICF u32 xz() const { return ((*((u32*)data)) & 0x00ffffff); }
ICF u32 x(u32 row) const { return (xz() / row); }
ICF u32 z(u32 row) const { return (xz() % row); }
ICF u32 y() const { return (*((u16*)(data + 3))); }
friend class CLevelGraph;
friend struct CNodePositionCompressor;
friend struct CNodePositionConverter;
Expand All @@ -116,25 +101,23 @@ struct NodeCompressed
break;
case 1:
value <<= 7;
value |= *(u32*)(data+2) & 0xc000007f;
CopyMemory(data+2, &value, sizeof(u32));
value |= *(u32*)(data + 2) & 0xc000007f;
CopyMemory(data + 2, &value, sizeof(u32));
break;
case 2:
value <<= 6;
value |= *(u32*)(data+5) & 0xe000003f;
CopyMemory(data+5, &value, sizeof(u32));
value |= *(u32*)(data + 5) & 0xe000003f;
CopyMemory(data + 5, &value, sizeof(u32));
break;
case 3:
value <<= 5;
value |= *(u32*)(data+8) & 0xf000001f;
CopyMemory(data+8, &value, sizeof(u32));
value |= *(u32*)(data + 8) & 0xf000001f;
CopyMemory(data + 8, &value, sizeof(u32));
break;
}
}

ICF void light(u8 value)
{ data[10] |= value << 4; }

ICF void light(u8 value) { data[10] |= value << 4; }
public:
struct SCover
{
Expand Down Expand Up @@ -169,16 +152,11 @@ struct NodeCompressed
{
switch (index)
{
case 0:
return ((*(u32*)data) & 0x007fffff);
case 1:
return (((*(u32*)(data + 2)) >> 7) & 0x007fffff);
case 2:
return (((*(u32*)(data + 5)) >> 6) & 0x007fffff);
case 3:
return (((*(u32*)(data + 8)) >> 5) & 0x007fffff);
default:
NODEFAULT;
case 0: return ((*(u32*)data) & 0x007fffff);
case 1: return (((*(u32*)(data + 2)) >> 7) & 0x007fffff);
case 2: return (((*(u32*)(data + 5)) >> 6) & 0x007fffff);
case 3: return (((*(u32*)(data + 8)) >> 5) & 0x007fffff);
default: NODEFAULT;
}
#ifdef DEBUG
return (0);
Expand Down Expand Up @@ -210,25 +188,23 @@ struct NodeCompressed6
break;
case 1:
value <<= 5;
value |= *(u32*)(data+2) & 0xfc00001f;
CopyMemory(data+2, &value, sizeof(u32));
value |= *(u32*)(data + 2) & 0xfc00001f;
CopyMemory(data + 2, &value, sizeof(u32));
break;
case 2:
value <<= 2;
value |= *(u32*)(data+5) & 0xff800003;
CopyMemory(data+5, &value, sizeof(u32));
value |= *(u32*)(data + 5) & 0xff800003;
CopyMemory(data + 5, &value, sizeof(u32));
break;
case 3:
value <<= 7;
value |= *(u32*)(data+7) & 0xf000007f;
CopyMemory(data+7, &value, sizeof(u32));
value |= *(u32*)(data + 7) & 0xf000007f;
CopyMemory(data + 7, &value, sizeof(u32));
break;
}
}

ICF void light(u8 value)
{ data[10] |= value << 4; }

ICF void light(u8 value) { data[10] |= value << 4; }
public:
u16 cover0 : 4;
u16 cover1 : 4;
Expand All @@ -242,19 +218,17 @@ struct NodeCompressed6
switch (index)
{
case 0: return *(u32*)data & 0x001fffff;
case 1: return (*(u32*)(data+2) >> 5) & 0x001fffff;
case 2: return (*(u32*)(data+5) >> 2) & 0x001fffff;
case 3: return (*(u32*)(data+7) >> 7) & 0x001fffff;
case 1: return (*(u32*)(data + 2) >> 5) & 0x001fffff;
case 2: return (*(u32*)(data + 5) >> 2) & 0x001fffff;
case 3: return (*(u32*)(data + 7) >> 7) & 0x001fffff;
default: NODEFAULT;
}
#ifdef DEBUG
return 0;
#endif
}

ICF u8 light() const
{ return data[10] >> 4; }

ICF u8 light() const { return data[10] >> 4; }
ICF u16 cover(u8 index) const
{
switch (index)
Expand All @@ -273,7 +247,7 @@ struct NodeCompressed6
friend class CLevelGraph;
friend struct CNodeCompressed;
friend class CNodeRenumberer;
}; // 2+5+2+11 = 20b
}; // 2+5+2+11 = 20b
#endif

struct SNodePositionOld
Expand All @@ -290,8 +264,8 @@ typedef SNodePositionOld NodePosition;

const char LEVEL_GRAPH_NAME[] = "level.ai";

const u32 XRCL_CURRENT_VERSION = 18; // input
const u32 XRCL_PRODUCTION_VERSION = 14; // output
const u32 XRCL_CURRENT_VERSION = 18; // input
const u32 XRCL_PRODUCTION_VERSION = 14; // output
const u32 CFORM_CURRENT_VERSION = 4;
const u32 MAX_NODE_BIT_COUNT = 23;
const u32 XRAI_CURRENT_VERSION = 10;
4 changes: 2 additions & 2 deletions src/Common/Noncopyable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ class Noncopyable
{
public:
Noncopyable() = default;
Noncopyable(Noncopyable &) = delete;
Noncopyable &operator=(Noncopyable &) = delete;
Noncopyable(Noncopyable&) = delete;
Noncopyable& operator=(Noncopyable&) = delete;
};
Loading

0 comments on commit 716dc03

Please sign in to comment.