Skip to content

Commit

Permalink
chore (plugin): add clipMap_t struct pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloliverx committed Nov 8, 2024
1 parent 726fc5b commit 5994f9d
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 53 deletions.
25 changes: 7 additions & 18 deletions plugins/xenon/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,38 +96,27 @@ void (*SV_LinkEntity)(gentity_s *ent) = reinterpret_cast<void (*)(gentity_s *ent

// Variables
serverStaticHeader_t *svsHeader = reinterpret_cast<serverStaticHeader_t *>(0x849F1580);
clipMap_t *cm = reinterpret_cast<clipMap_t *>(0x82A23240);

std::vector<int> originalBrushContents;
std::string lastMapName;

void RemoveBrushCollisions(int heightLimit)
{
// cm.numBrushes
uintptr_t cm_numBrushesOffset = 0x82A232CC;
unsigned __int16 *cm_numBrushesPtr = reinterpret_cast<unsigned __int16 *>(cm_numBrushesOffset);
unsigned __int16 cm_numBrushes = *cm_numBrushesPtr;

// cm.brushes
uintptr_t cm_brushesOffset = 0x82A232D0;
cbrush_t **cm_brushesArrayPtr = reinterpret_cast<cbrush_t **>(cm_brushesOffset);
cbrush_t *cm_brushesFirst = *cm_brushesArrayPtr;

dvar_s *mapname = Dvar_FindMalleableVar("mapname");
if (lastMapName != mapname->current.string)
{
originalBrushContents.clear();
originalBrushContents.resize(cm_numBrushes);
for (int i = 0; i < cm_numBrushes; i++)
{
cbrush_t &brush = *(cm_brushesFirst + i);
originalBrushContents[i] = brush.contents;
}
originalBrushContents.resize(cm->numBrushes);
for (int i = 0; i < cm->numBrushes; i++)
originalBrushContents[i] = cm->brushes[i].contents;

lastMapName = mapname->current.string;
}

for (int i = 0; i < cm_numBrushes; i++)
for (int i = 0; i < cm->numBrushes; i++)
{
cbrush_t &brush = *(cm_brushesFirst + i);
cbrush_t &brush = cm->brushes[i];
float height = brush.maxs[2] - brush.mins[2];
if (height > heightLimit)
brush.contents &= ~0x10000;
Expand Down
171 changes: 136 additions & 35 deletions plugins/xenon/src/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -710,41 +710,6 @@ struct gentity_s

static_assert(offsetof(gentity_s, client) == 0x0015C, "");

/* 8761 */
struct cplane_s
{
float normal[3];
float dist;
unsigned __int8 type;
unsigned __int8 signbits;
unsigned __int8 pad[2];
};

/* 8798 */
struct __declspec(align(2)) cbrushside_t
{
cplane_s *plane;
unsigned int materialNum;
__int16 firstAdjacentSideOffset;
unsigned __int8 edgeCount;
};

/* 8961 */
struct __declspec(align(16)) cbrush_t
{
float mins[3];
int contents;
float maxs[3];
unsigned int numsides;
cbrushside_t *sides;
__int16 axialMaterialNum[2][3];
unsigned __int8 *baseAdjacentSide;
__int16 firstAdjacentSideOffsets[2][3];
unsigned __int8 edgeCount[2][3];
};

static_assert(sizeof(cbrush_t) == 80, "");

struct scr_entref_t
{
unsigned __int16 entnum;
Expand Down Expand Up @@ -983,3 +948,139 @@ struct BuiltinFunctionDef
void(__cdecl *actionFunc)();
int type;
};

/* 8951 */
struct __declspec(align(4)) cLeaf_t
{
unsigned __int16 firstCollAabbIndex;
unsigned __int16 collAabbCount;
int brushContents;
int terrainContents;
float mins[3];
float maxs[3];
int leafBrushNode;
__int16 cluster;
};

/* 8960 */
struct cmodel_t
{
float mins[3];
float maxs[3];
float radius;
cLeaf_t leaf;
};

static_assert(sizeof(cmodel_t) == 72, "");

/* 8761 */
struct cplane_s
{
float normal[3];
float dist;
unsigned __int8 type;
unsigned __int8 signbits;
unsigned __int8 pad[2];
};

/* 8798 */
struct __declspec(align(2)) cbrushside_t
{
cplane_s *plane;
unsigned int materialNum;
__int16 firstAdjacentSideOffset;
unsigned __int8 edgeCount;
};

/* 8961 */
struct __declspec(align(16)) cbrush_t
{
float mins[3];
int contents;
float maxs[3];
unsigned int numsides;
cbrushside_t *sides;
__int16 axialMaterialNum[2][3];
unsigned __int8 *baseAdjacentSide;
__int16 firstAdjacentSideOffsets[2][3];
unsigned __int8 edgeCount[2][3];
};

static_assert(sizeof(cbrush_t) == 80, "");

/* 9073 */
struct MapEnts
{
const char *name;
char *entityString;
int numEntityChars;
};

// stubs
struct cStaticModel_s;
struct dmaterial_t;
struct cNode_t;
struct cLeaf_t;
struct cLeafBrushNode_s;
struct CollisionBorder;
struct CollisionPartition;
struct CollisionAabbTree;
struct DynEntityDef;
struct DynEntityPose;
struct DynEntityClient;
struct DynEntityColl;

/* 9079 */
struct clipMap_t
{
const char *name;
int isInUse; // 82A23244
int planeCount;
cplane_s *planes;
unsigned int numStaticModels;
cStaticModel_s *staticModelList;
unsigned int numMaterials;
dmaterial_t *materials;
unsigned int numBrushSides;
cbrushside_t *brushsides;
unsigned int numBrushEdges;
unsigned __int8 *brushEdges;
unsigned int numNodes;
cNode_t *nodes;
unsigned int numLeafs;
cLeaf_t *leafs;
unsigned int leafbrushNodesCount;
cLeafBrushNode_s *leafbrushNodes;
unsigned int numLeafBrushes;
unsigned __int16 *leafbrushes;
unsigned int numLeafSurfaces;
unsigned int *leafsurfaces;
unsigned int vertCount;
float (*verts)[3];
int triCount;
unsigned __int16 *triIndices;
unsigned __int8 *triEdgeIsWalkable;
int borderCount;
CollisionBorder *borders;
int partitionCount;
CollisionPartition *partitions;
int aabbTreeCount;
CollisionAabbTree *aabbTrees;
unsigned int numSubModels;
cmodel_t *cmodels;
unsigned __int16 numBrushes;
cbrush_t *brushes;
int numClusters;
int clusterBytes;
unsigned __int8 *visibility;
int vised;
MapEnts *mapEnts;
cbrush_t *box_brush;
cmodel_t box_model;
unsigned __int16 dynEntCount[2];
DynEntityDef *dynEntDefList[2];
DynEntityPose *dynEntPoseList[2];
DynEntityClient *dynEntClientList[2];
DynEntityColl *dynEntCollList[2];
unsigned int checksum;
};

0 comments on commit 5994f9d

Please sign in to comment.