Formatted navigate source files

This commit is contained in:
smallmodel 2023-10-22 21:06:43 +02:00
parent 4a9f9a45c2
commit b996918d3b
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512
2 changed files with 2738 additions and 3294 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
/* /*
=========================================================================== ===========================================================================
Copyright (C) 2015 the OpenMoHAA team Copyright (C) 2023 the OpenMoHAA team
This file is part of OpenMoHAA source code. This file is part of OpenMoHAA source code.
@ -25,8 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// is currently unfinished. // is currently unfinished.
// //
#ifndef __NAVIGATE_H__ #pragma once
#define __NAVIGATE_H__
#include "g_local.h" #include "g_local.h"
#include "class.h" #include "class.h"
@ -37,7 +36,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "sentient.h" #include "sentient.h"
#include "../qcommon/qfiles.h" #include "../qcommon/qfiles.h"
extern Event EV_AI_SavePaths; extern Event EV_AI_SavePaths;
extern Event EV_AI_SaveNodes; extern Event EV_AI_SaveNodes;
extern Event EV_AI_LoadNodes; extern Event EV_AI_LoadNodes;
@ -75,10 +73,11 @@ class PathNode;
#define MAX_HEIGHT 128 #define MAX_HEIGHT 128
#define CHECK_PATH(path, width, height) \ #define CHECK_PATH(path, width, height) \
( ( ( ( width ) >= MAX_WIDTH ) || ( ( width ) < 0 ) ) ? false : \ ((((width) >= MAX_WIDTH) || ((width) < 0)) ? false \
( ( int )( path )->maxheight[ ( ( width ) / WIDTH_STEP ) - 1 ] < ( int )( height ) ) ) : ((int)(path)->maxheight[((width) / WIDTH_STEP) - 1] < (int)(height)))
class pathway_ref { class pathway_ref
{
public: public:
short int from; short int from;
short int to; short int to;
@ -94,7 +93,8 @@ typedef struct {
float pos2[3]; float pos2[3];
} pathway_t; } pathway_t;
class PathInfo { class PathInfo
{
public: public:
bool bAccurate; bool bAccurate;
float point[3]; float point[3];
@ -105,10 +105,7 @@ public:
void Archive(Archiver& arc); void Archive(Archiver& arc);
}; };
inline void PathInfo::Archive inline void PathInfo::Archive(Archiver& arc)
(
Archiver& arc
)
{ {
arc.ArchiveBool(&bAccurate); arc.ArchiveBool(&bAccurate);
arc.ArchiveVec3(point); arc.ArchiveVec3(point);
@ -116,7 +113,11 @@ inline void PathInfo::Archive
arc.ArchiveVec2(dir); arc.ArchiveVec2(dir);
} }
typedef enum { NOT_IN_LIST, IN_OPEN, IN_CLOSED } pathlist_t; typedef enum {
NOT_IN_LIST,
IN_OPEN,
IN_CLOSED
} pathlist_t;
#define PATH_DONT_LINK 1 #define PATH_DONT_LINK 1
#define AI_DUCK 2 #define AI_DUCK 2
@ -200,12 +201,12 @@ class PathNode : public SimpleEntity
void IsTouching(Event *ev); void IsTouching(Event *ev);
qboolean IsTouching(Entity *e1); qboolean IsTouching(Entity *e1);
void setOriginEvent(Vector org) override; void setOriginEvent(Vector org) override;
}; };
typedef SafePtr<PathNode> PathNodePtr; typedef SafePtr<PathNode> PathNodePtr;
class nodeinfo { class nodeinfo
{
public: public:
PathNode *pNode; PathNode *pNode;
float fDistSquared; float fDistSquared;
@ -293,19 +294,40 @@ public:
static PathInfo *GeneratePathNear(PathInfo *path); static PathInfo *GeneratePathNear(PathInfo *path);
static PathInfo *GeneratePathAway(PathInfo *path); static PathInfo *GeneratePathAway(PathInfo *path);
static class PathNode *GetSpawnNode(ClassDef *cls); static class PathNode *GetSpawnNode(ClassDef *cls);
static int FindPath( float *start, float *end, Entity *ent, float maxPath, float *vLeashHome, float fLeashDistSquared, int fallheight ); static int FindPath(
static int FindPathAway( float *start, float *avoid, float *vPreferredDir, Entity *ent, float fMinSafeDist, float *vLeashHome, float fLeashDistSquared, int fallheight ); float *start, float *end, Entity *ent, float maxPath, float *vLeashHome, float fLeashDistSquared, int fallheight
static int FindPathNear( float *start, float *end, Entity *ent, float maxPath, float fRadiusSquared, float *vLeashHome, float fLeashDistSquared, int fallheight ); );
static class PathNode *FindCornerNodeForWall( float *start, float *end, class SimpleActor *ent, float maxPath, float *plane ); static int FindPathAway(
float *start,
float *avoid,
float *vPreferredDir,
Entity *ent,
float fMinSafeDist,
float *vLeashHome,
float fLeashDistSquared,
int fallheight
);
static int FindPathNear(
float *start,
float *end,
Entity *ent,
float maxPath,
float fRadiusSquared,
float *vLeashHome,
float fLeashDistSquared,
int fallheight
);
static class PathNode *
FindCornerNodeForWall(float *start, float *end, class SimpleActor *ent, float maxPath, float *plane);
static class PathNode *FindCornerNodeForExactPath(class SimpleActor *self, Sentient *enemy, float fMaxPath); static class PathNode *FindCornerNodeForExactPath(class SimpleActor *self, Sentient *enemy, float fMaxPath);
static int FindPotentialCover( class SimpleActor *pEnt, Vector& vPos, Entity *pEnemy, PathNode **ppFoundNodes, int iMaxFind ); static int
FindPotentialCover(class SimpleActor *pEnt, Vector& vPos, Entity *pEnemy, PathNode **ppFoundNodes, int iMaxFind);
static void PlayerCover(class Player *pPlayer); static void PlayerCover(class Player *pPlayer);
static class PathNode *FindNearestCover(class SimpleActor *pEnt, Vector& vPos, Entity *pEnemy); static class PathNode *FindNearestCover(class SimpleActor *pEnt, Vector& vPos, Entity *pEnemy);
static class PathNode *FindNearestSniperNode(class SimpleActor *pEnt, Vector& vPos, Entity *pEnemy); static class PathNode *FindNearestSniperNode(class SimpleActor *pEnt, Vector& vPos, Entity *pEnemy);
private: private:
static int NearestNodeSetup(vec3_t pos, MapCell *cell, int *nodes, vec3_t *deltas); static int NearestNodeSetup(vec3_t pos, MapCell *cell, int *nodes, vec3_t *deltas);
}; };
extern PathSearch PathManager; extern PathSearch PathManager;
@ -356,10 +378,7 @@ public:
typedef SafePtr<AttractiveNode> AttractiveNodePtr; typedef SafePtr<AttractiveNode> AttractiveNodePtr;
inline void AttractiveNode::Archive inline void AttractiveNode::Archive(Archiver& arc)
(
Archiver& arc
)
{ {
arc.ArchiveInteger(&m_iPriority); arc.ArchiveInteger(&m_iPriority);
arc.ArchiveBool(&m_bUse); arc.ArchiveBool(&m_bUse);
@ -368,5 +387,3 @@ inline void AttractiveNode::Archive
} }
extern Container<AttractiveNode *> attractiveNodes; extern Container<AttractiveNode *> attractiveNodes;
#endif