passing some of the vectors by reference, instead of copying
This commit is contained in:
parent
02fe78ceee
commit
44512457c8
5 changed files with 44 additions and 38 deletions
|
|
@ -998,7 +998,7 @@ private:
|
||||||
edict_t *FindNearestButton (const char *className);
|
edict_t *FindNearestButton (const char *className);
|
||||||
edict_t *FindBreakable (void);
|
edict_t *FindBreakable (void);
|
||||||
int FindCoverWaypoint (float maxDistance);
|
int FindCoverWaypoint (float maxDistance);
|
||||||
int FindDefendWaypoint (Vector origin);
|
int FindDefendWaypoint (const Vector &origin);
|
||||||
int FindGoal (void);
|
int FindGoal (void);
|
||||||
void FilterGoals (const Array <int> &goals, int *result);
|
void FilterGoals (const Array <int> &goals, int *result);
|
||||||
void FindItem (void);
|
void FindItem (void);
|
||||||
|
|
@ -1012,7 +1012,7 @@ private:
|
||||||
bool HeadTowardWaypoint (void);
|
bool HeadTowardWaypoint (void);
|
||||||
int InFieldOfView (const Vector &dest);
|
int InFieldOfView (const Vector &dest);
|
||||||
|
|
||||||
bool IsBombDefusing (Vector bombOrigin);
|
bool IsBombDefusing (const Vector &bombOrigin);
|
||||||
bool IsBlockedLeft (void);
|
bool IsBlockedLeft (void);
|
||||||
bool IsBlockedRight (void);
|
bool IsBlockedRight (void);
|
||||||
bool IsPointOccupied (int index);
|
bool IsPointOccupied (int index);
|
||||||
|
|
@ -1034,7 +1034,7 @@ private:
|
||||||
bool ReactOnEnemy (void);
|
bool ReactOnEnemy (void);
|
||||||
void ResetCollideState (void);
|
void ResetCollideState (void);
|
||||||
void SetConditions (void);
|
void SetConditions (void);
|
||||||
void SetStrafeSpeed (Vector moveDir, float strafeSpeed);
|
void SetStrafeSpeed (const Vector &moveDir, float strafeSpeed);
|
||||||
void StartGame (void);
|
void StartGame (void);
|
||||||
void TaskComplete (void);
|
void TaskComplete (void);
|
||||||
bool GetBestNextWaypoint (void);
|
bool GetBestNextWaypoint (void);
|
||||||
|
|
@ -1045,7 +1045,7 @@ private:
|
||||||
byte ThrottledMsec (void);
|
byte ThrottledMsec (void);
|
||||||
void GetValidWaypoint (void);
|
void GetValidWaypoint (void);
|
||||||
void ChangeWptIndex (int waypointIndex);
|
void ChangeWptIndex (int waypointIndex);
|
||||||
bool IsDeadlyDrop (Vector targetOriginPos);
|
bool IsDeadlyDrop (const Vector &to);
|
||||||
bool OutOfBombTimer (void);
|
bool OutOfBombTimer (void);
|
||||||
void SelectLeaderEachTeam (int team);
|
void SelectLeaderEachTeam (int team);
|
||||||
|
|
||||||
|
|
@ -1069,13 +1069,14 @@ private:
|
||||||
void SelectBestWeapon (void);
|
void SelectBestWeapon (void);
|
||||||
void SelectPistol (void);
|
void SelectPistol (void);
|
||||||
bool IsFriendInLineOfFire (float distance);
|
bool IsFriendInLineOfFire (float distance);
|
||||||
bool IsGroupOfEnemies (Vector location, int numEnemies = 1, int radius = 256);
|
bool IsGroupOfEnemies (const Vector &location, int numEnemies = 1, int radius = 256);
|
||||||
|
|
||||||
bool IsShootableThruObstacle (const Vector &dest);
|
bool IsShootableThruObstacle (const Vector &dest);
|
||||||
bool IsShootableThruObstacleEx (const Vector &dest);
|
bool IsShootableThruObstacleEx (const Vector &dest);
|
||||||
|
|
||||||
int GetNearbyEnemiesNearPosition (Vector origin, int radius);
|
int GetNearbyEnemiesNearPosition (const Vector &origin, int radius);
|
||||||
int GetNearbyFriendsNearPosition (Vector origin, int radius);
|
int GetNearbyFriendsNearPosition (const Vector &origin, int radius);
|
||||||
|
|
||||||
void SelectWeaponByName (const char *name);
|
void SelectWeaponByName (const char *name);
|
||||||
void SelectWeaponbyNumber (int num);
|
void SelectWeaponbyNumber (int num);
|
||||||
int GetHighestWeapon (void);
|
int GetHighestWeapon (void);
|
||||||
|
|
@ -1087,7 +1088,8 @@ private:
|
||||||
float GetEstimatedReachTime (void);
|
float GetEstimatedReachTime (void);
|
||||||
|
|
||||||
int GetAimingWaypoint (void);
|
int GetAimingWaypoint (void);
|
||||||
int GetAimingWaypoint (Vector targetOriginPos);
|
int GetAimingWaypoint (const Vector &to);
|
||||||
|
|
||||||
void FindShortestPath (int srcIndex, int destIndex);
|
void FindShortestPath (int srcIndex, int destIndex);
|
||||||
void FindPath (int srcIndex, int destIndex, unsigned char pathType = 0);
|
void FindPath (int srcIndex, int destIndex, unsigned char pathType = 0);
|
||||||
void DebugMsg (const char *format, ...);
|
void DebugMsg (const char *format, ...);
|
||||||
|
|
@ -1248,7 +1250,7 @@ public:
|
||||||
void Kill (void);
|
void Kill (void);
|
||||||
void Kick (void);
|
void Kick (void);
|
||||||
void ResetDoubleJumpState (void);
|
void ResetDoubleJumpState (void);
|
||||||
void MoveToVector (Vector to);
|
void MoveToVector (const Vector &to);
|
||||||
int FindPlantedBomb(void);
|
int FindPlantedBomb(void);
|
||||||
|
|
||||||
bool HasHostage (void);
|
bool HasHostage (void);
|
||||||
|
|
@ -1432,10 +1434,10 @@ public:
|
||||||
void AddPath (short int addIndex, short int pathIndex, float distance);
|
void AddPath (short int addIndex, short int pathIndex, float distance);
|
||||||
|
|
||||||
int GetFacingIndex (void);
|
int GetFacingIndex (void);
|
||||||
int FindFarest (Vector origin, float maxDistance = 32.0);
|
int FindFarest (const Vector &origin, float maxDistance = 32.0);
|
||||||
int FindNearest (Vector origin, float minDistance = 9999.0, int flags = -1);
|
int FindNearest (const Vector &origin, float minDistance = 9999.0, int flags = -1);
|
||||||
void FindInRadius (Vector origin, float radius, int *holdTab, int *count);
|
void FindInRadius (const Vector &origin, float radius, int *holdTab, int *count);
|
||||||
void FindInRadius (Array <int> &queueID, float radius, Vector origin);
|
void FindInRadius (Array <int> &queueID, float radius, const Vector &origin);
|
||||||
|
|
||||||
void Add (int flags, const Vector &waypointOrigin = nullvec);
|
void Add (int flags, const Vector &waypointOrigin = nullvec);
|
||||||
void Delete (void);
|
void Delete (void);
|
||||||
|
|
@ -1448,7 +1450,7 @@ public:
|
||||||
void DeletePath (void);
|
void DeletePath (void);
|
||||||
void CacheWaypoint (void);
|
void CacheWaypoint (void);
|
||||||
|
|
||||||
float GetTravelTime (float maxSpeed, Vector src, Vector origin);
|
float GetTravelTime (float maxSpeed, const Vector &src, const Vector &origin);
|
||||||
bool IsVisible (int srcIndex, int destIndex);
|
bool IsVisible (int srcIndex, int destIndex);
|
||||||
bool IsStandVisible (int srcIndex, int destIndex);
|
bool IsStandVisible (int srcIndex, int destIndex);
|
||||||
bool IsDuckVisible (int srcIndex, int destIndex);
|
bool IsDuckVisible (int srcIndex, int destIndex);
|
||||||
|
|
@ -1458,7 +1460,7 @@ public:
|
||||||
void Save (void);
|
void Save (void);
|
||||||
|
|
||||||
bool Reachable (Bot *bot, int index);
|
bool Reachable (Bot *bot, int index);
|
||||||
bool IsNodeReachable (Vector src, Vector destination);
|
bool IsNodeReachable (const Vector &src, const Vector &destination);
|
||||||
void Think (void);
|
void Think (void);
|
||||||
bool NodesValid (void);
|
bool NodesValid (void);
|
||||||
void SaveExperienceTab (void);
|
void SaveExperienceTab (void);
|
||||||
|
|
@ -1483,7 +1485,11 @@ public:
|
||||||
bool IsGoalVisited (int index);
|
bool IsGoalVisited (int index);
|
||||||
void SetGoalVisited (int index);
|
void SetGoalVisited (int index);
|
||||||
|
|
||||||
inline Vector GetBombPosition (void) { return m_foundBombOrigin; }
|
inline const Vector &GetBombPosition (void)
|
||||||
|
{
|
||||||
|
return m_foundBombOrigin;
|
||||||
|
}
|
||||||
|
|
||||||
void SetBombPosition (bool shouldReset = false);
|
void SetBombPosition (bool shouldReset = false);
|
||||||
String CheckSubfolderFile (void);
|
String CheckSubfolderFile (void);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ bool Bot::CheckVisibility (entvars_t *targetEntity, Vector *origin, byte *bodyPa
|
||||||
{
|
{
|
||||||
// this function checks visibility of a bot target.
|
// this function checks visibility of a bot target.
|
||||||
|
|
||||||
Vector botHead = EyePosition ();
|
const Vector &botHead = EyePosition ();
|
||||||
TraceResult tr;
|
TraceResult tr;
|
||||||
|
|
||||||
*bodyPart = 0;
|
*bodyPart = 0;
|
||||||
|
|
@ -5766,7 +5766,7 @@ Vector Bot::CheckBombAudible (void)
|
||||||
return nullvec;
|
return nullvec;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bot::MoveToVector (Vector to)
|
void Bot::MoveToVector (const Vector &to)
|
||||||
{
|
{
|
||||||
if (to == nullvec)
|
if (to == nullvec)
|
||||||
return;
|
return;
|
||||||
|
|
@ -6109,7 +6109,7 @@ void Bot::EquipInBuyzone (int buyCount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Bot::IsBombDefusing (Vector bombOrigin)
|
bool Bot::IsBombDefusing (const Vector &bombOrigin)
|
||||||
{
|
{
|
||||||
// this function finds if somebody currently defusing the bomb.
|
// this function finds if somebody currently defusing the bomb.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ ConVar yb_csdm_mode ("yb_csdm_mode", "0", VT_NOSERVER);
|
||||||
|
|
||||||
ConVar mp_friendlyfire ("mp_friendlyfire", NULL, VT_NOREGISTER);
|
ConVar mp_friendlyfire ("mp_friendlyfire", NULL, VT_NOREGISTER);
|
||||||
|
|
||||||
int Bot::GetNearbyFriendsNearPosition (Vector origin, int radius)
|
int Bot::GetNearbyFriendsNearPosition (const Vector &origin, int radius)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@ int Bot::GetNearbyFriendsNearPosition (Vector origin, int radius)
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Bot::GetNearbyEnemiesNearPosition (Vector origin, int radius)
|
int Bot::GetNearbyEnemiesNearPosition (const Vector &origin, int radius)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
|
@ -1406,7 +1406,7 @@ void Bot::CommandTeam (void)
|
||||||
m_timeTeamOrder = GetWorldTime () + Random.Float (5.0, 30.0);
|
m_timeTeamOrder = GetWorldTime () + Random.Float (5.0, 30.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Bot::IsGroupOfEnemies (Vector location, int numEnemies, int radius)
|
bool Bot::IsGroupOfEnemies (const Vector &location, int numEnemies, int radius)
|
||||||
{
|
{
|
||||||
int numPlayers = 0;
|
int numPlayers = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1715,7 +1715,7 @@ void Bot::DeleteSearchNodes (void)
|
||||||
m_chosenGoalIndex = -1;
|
m_chosenGoalIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Bot::GetAimingWaypoint (Vector targetOriginPos)
|
int Bot::GetAimingWaypoint (const Vector &to)
|
||||||
{
|
{
|
||||||
// return the most distant waypoint which is seen from the Bot to the Target and is within count
|
// return the most distant waypoint which is seen from the Bot to the Target and is within count
|
||||||
|
|
||||||
|
|
@ -1723,7 +1723,7 @@ int Bot::GetAimingWaypoint (Vector targetOriginPos)
|
||||||
ChangeWptIndex (g_waypoint->FindNearest (pev->origin));
|
ChangeWptIndex (g_waypoint->FindNearest (pev->origin));
|
||||||
|
|
||||||
int srcIndex = m_currentWaypointIndex;
|
int srcIndex = m_currentWaypointIndex;
|
||||||
int destIndex = g_waypoint->FindNearest (targetOriginPos);
|
int destIndex = g_waypoint->FindNearest (to);
|
||||||
int bestIndex = srcIndex;
|
int bestIndex = srcIndex;
|
||||||
|
|
||||||
PathNode *node = new PathNode;
|
PathNode *node = new PathNode;
|
||||||
|
|
@ -2022,7 +2022,7 @@ int Bot::ChooseBombWaypoint (void)
|
||||||
return goal;
|
return goal;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Bot::FindDefendWaypoint (Vector origin)
|
int Bot::FindDefendWaypoint (const Vector &origin)
|
||||||
{
|
{
|
||||||
// this function tries to find a good position which has a line of sight to a position,
|
// this function tries to find a good position which has a line of sight to a position,
|
||||||
// provides enough cover point, and is far away from the defending position
|
// provides enough cover point, and is far away from the defending position
|
||||||
|
|
@ -2887,17 +2887,17 @@ bool Bot::CheckWallOnRight (void)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Bot::IsDeadlyDrop (Vector targetOriginPos)
|
bool Bot::IsDeadlyDrop (const Vector &to)
|
||||||
{
|
{
|
||||||
// this function eturns if given location would hurt Bot with falling damage
|
// this function eturns if given location would hurt Bot with falling damage
|
||||||
|
|
||||||
Vector botPos = pev->origin;
|
Vector botPos = pev->origin;
|
||||||
TraceResult tr;
|
TraceResult tr;
|
||||||
|
|
||||||
Vector move ((targetOriginPos - botPos).ToYaw (), 0, 0);
|
Vector move ((to - botPos).ToYaw (), 0, 0);
|
||||||
MakeVectors (move);
|
MakeVectors (move);
|
||||||
|
|
||||||
Vector direction = (targetOriginPos - botPos).Normalize (); // 1 unit long
|
Vector direction = (to - botPos).Normalize (); // 1 unit long
|
||||||
Vector check = botPos;
|
Vector check = botPos;
|
||||||
Vector down = botPos;
|
Vector down = botPos;
|
||||||
|
|
||||||
|
|
@ -2911,7 +2911,7 @@ bool Bot::IsDeadlyDrop (Vector targetOriginPos)
|
||||||
float height;
|
float height;
|
||||||
float lastHeight = tr.flFraction * 1000.0; // height from ground
|
float lastHeight = tr.flFraction * 1000.0; // height from ground
|
||||||
|
|
||||||
float distance = (targetOriginPos - check).GetLength (); // distance from goal
|
float distance = (to - check).GetLength (); // distance from goal
|
||||||
|
|
||||||
while (distance > 16.0)
|
while (distance > 16.0)
|
||||||
{
|
{
|
||||||
|
|
@ -2931,7 +2931,7 @@ bool Bot::IsDeadlyDrop (Vector targetOriginPos)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
lastHeight = height;
|
lastHeight = height;
|
||||||
distance = (targetOriginPos - check).GetLength (); // distance from goal
|
distance = (to - check).GetLength (); // distance from goal
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -3236,11 +3236,11 @@ void Bot::FacePosition (void)
|
||||||
pev->angles.z = pev->v_angle.z = 0.0; // ignore Z component
|
pev->angles.z = pev->v_angle.z = 0.0; // ignore Z component
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bot::SetStrafeSpeed (Vector moveDir, float strafeSpeed)
|
void Bot::SetStrafeSpeed (const Vector &moveDir, float strafeSpeed)
|
||||||
{
|
{
|
||||||
MakeVectors (pev->angles);
|
MakeVectors (pev->angles);
|
||||||
|
|
||||||
Vector los = (moveDir - pev->origin).Normalize2D ();
|
const Vector &los = (moveDir - pev->origin).Normalize2D ();
|
||||||
float dot = los | g_pGlobals->v_forward.SkipZ ();
|
float dot = los | g_pGlobals->v_forward.SkipZ ();
|
||||||
|
|
||||||
if (dot > 0 && !CheckWallOnRight ())
|
if (dot > 0 && !CheckWallOnRight ())
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ void Waypoint::AddPath (short int addIndex, short int pathIndex, float distance)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Waypoint::FindFarest (Vector origin, float maxDistance)
|
int Waypoint::FindFarest (const Vector &origin, float maxDistance)
|
||||||
{
|
{
|
||||||
// find the farest waypoint to that Origin, and return the index to this waypoint
|
// find the farest waypoint to that Origin, and return the index to this waypoint
|
||||||
|
|
||||||
|
|
@ -102,7 +102,7 @@ int Waypoint::FindFarest (Vector origin, float maxDistance)
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Waypoint::FindNearest (Vector origin, float minDistance, int flags)
|
int Waypoint::FindNearest (const Vector &origin, float minDistance, int flags)
|
||||||
{
|
{
|
||||||
// find the nearest waypoint to that origin and return the index
|
// find the nearest waypoint to that origin and return the index
|
||||||
|
|
||||||
|
|
@ -124,7 +124,7 @@ int Waypoint::FindNearest (Vector origin, float minDistance, int flags)
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Waypoint::FindInRadius (Vector origin, float radius, int *holdTab, int *count)
|
void Waypoint::FindInRadius (const Vector &origin, float radius, int *holdTab, int *count)
|
||||||
{
|
{
|
||||||
// returns all waypoints within radius from position
|
// returns all waypoints within radius from position
|
||||||
|
|
||||||
|
|
@ -145,7 +145,7 @@ void Waypoint::FindInRadius (Vector origin, float radius, int *holdTab, int *cou
|
||||||
*count -= 1;
|
*count -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Waypoint::FindInRadius (Array <int> &queueID, float radius, Vector origin)
|
void Waypoint::FindInRadius (Array <int> &queueID, float radius, const Vector &origin)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < g_numWaypoints; i++)
|
for (int i = 0; i < g_numWaypoints; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -1234,7 +1234,7 @@ String Waypoint::CheckSubfolderFile (void)
|
||||||
return FormatBuffer ("%s%s.pwf", GetWaypointDir (), GetMapName ());
|
return FormatBuffer ("%s%s.pwf", GetWaypointDir (), GetMapName ());
|
||||||
}
|
}
|
||||||
|
|
||||||
float Waypoint::GetTravelTime (float maxSpeed, Vector src, Vector origin)
|
float Waypoint::GetTravelTime (float maxSpeed, const Vector &src, const Vector &origin)
|
||||||
{
|
{
|
||||||
// this function returns 2D traveltime to a position
|
// this function returns 2D traveltime to a position
|
||||||
|
|
||||||
|
|
@ -1277,7 +1277,7 @@ bool Waypoint::Reachable (Bot *bot, int index)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Waypoint::IsNodeReachable (Vector src, Vector destination)
|
bool Waypoint::IsNodeReachable (const Vector &src, const Vector &destination)
|
||||||
{
|
{
|
||||||
TraceResult tr;
|
TraceResult tr;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue