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
|
|
@ -104,7 +104,7 @@ bool Bot::CheckVisibility (entvars_t *targetEntity, Vector *origin, byte *bodyPa
|
|||
{
|
||||
// this function checks visibility of a bot target.
|
||||
|
||||
Vector botHead = EyePosition ();
|
||||
const Vector &botHead = EyePosition ();
|
||||
TraceResult tr;
|
||||
|
||||
*bodyPart = 0;
|
||||
|
|
@ -5766,7 +5766,7 @@ Vector Bot::CheckBombAudible (void)
|
|||
return nullvec;
|
||||
}
|
||||
|
||||
void Bot::MoveToVector (Vector to)
|
||||
void Bot::MoveToVector (const Vector &to)
|
||||
{
|
||||
if (to == nullvec)
|
||||
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.
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ ConVar yb_csdm_mode ("yb_csdm_mode", "0", VT_NOSERVER);
|
|||
|
||||
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;
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ int Bot::GetNearbyFriendsNearPosition (Vector origin, int radius)
|
|||
return count;
|
||||
}
|
||||
|
||||
int Bot::GetNearbyEnemiesNearPosition (Vector origin, int radius)
|
||||
int Bot::GetNearbyEnemiesNearPosition (const Vector &origin, int radius)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
|
|
@ -1406,7 +1406,7 @@ void Bot::CommandTeam (void)
|
|||
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;
|
||||
|
||||
|
|
|
|||
|
|
@ -1715,7 +1715,7 @@ void Bot::DeleteSearchNodes (void)
|
|||
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
|
||||
|
||||
|
|
@ -1723,7 +1723,7 @@ int Bot::GetAimingWaypoint (Vector targetOriginPos)
|
|||
ChangeWptIndex (g_waypoint->FindNearest (pev->origin));
|
||||
|
||||
int srcIndex = m_currentWaypointIndex;
|
||||
int destIndex = g_waypoint->FindNearest (targetOriginPos);
|
||||
int destIndex = g_waypoint->FindNearest (to);
|
||||
int bestIndex = srcIndex;
|
||||
|
||||
PathNode *node = new PathNode;
|
||||
|
|
@ -2022,7 +2022,7 @@ int Bot::ChooseBombWaypoint (void)
|
|||
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,
|
||||
// provides enough cover point, and is far away from the defending position
|
||||
|
|
@ -2887,17 +2887,17 @@ bool Bot::CheckWallOnRight (void)
|
|||
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
|
||||
|
||||
Vector botPos = pev->origin;
|
||||
TraceResult tr;
|
||||
|
||||
Vector move ((targetOriginPos - botPos).ToYaw (), 0, 0);
|
||||
Vector move ((to - botPos).ToYaw (), 0, 0);
|
||||
MakeVectors (move);
|
||||
|
||||
Vector direction = (targetOriginPos - botPos).Normalize (); // 1 unit long
|
||||
Vector direction = (to - botPos).Normalize (); // 1 unit long
|
||||
Vector check = botPos;
|
||||
Vector down = botPos;
|
||||
|
||||
|
|
@ -2911,7 +2911,7 @@ bool Bot::IsDeadlyDrop (Vector targetOriginPos)
|
|||
float height;
|
||||
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)
|
||||
{
|
||||
|
|
@ -2931,7 +2931,7 @@ bool Bot::IsDeadlyDrop (Vector targetOriginPos)
|
|||
return true;
|
||||
|
||||
lastHeight = height;
|
||||
distance = (targetOriginPos - check).GetLength (); // distance from goal
|
||||
distance = (to - check).GetLength (); // distance from goal
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -3236,11 +3236,11 @@ void Bot::FacePosition (void)
|
|||
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);
|
||||
|
||||
Vector los = (moveDir - pev->origin).Normalize2D ();
|
||||
const Vector &los = (moveDir - pev->origin).Normalize2D ();
|
||||
float dot = los | g_pGlobals->v_forward.SkipZ ();
|
||||
|
||||
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
|
||||
|
||||
|
|
@ -102,7 +102,7 @@ int Waypoint::FindFarest (Vector origin, float maxDistance)
|
|||
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
|
||||
|
||||
|
|
@ -124,7 +124,7 @@ int Waypoint::FindNearest (Vector origin, float minDistance, int flags)
|
|||
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
|
||||
|
||||
|
|
@ -145,7 +145,7 @@ void Waypoint::FindInRadius (Vector origin, float radius, int *holdTab, int *cou
|
|||
*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++)
|
||||
{
|
||||
|
|
@ -1234,7 +1234,7 @@ String Waypoint::CheckSubfolderFile (void)
|
|||
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
|
||||
|
||||
|
|
@ -1277,7 +1277,7 @@ bool Waypoint::Reachable (Bot *bot, int index)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Waypoint::IsNodeReachable (Vector src, Vector destination)
|
||||
bool Waypoint::IsNodeReachable (const Vector &src, const Vector &destination)
|
||||
{
|
||||
TraceResult tr;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue