fixed race-condition in bomb location detection
fixed visited goals are not cleared on round-start
This commit is contained in:
parent
4204f4e9f2
commit
aeb712c2b3
6 changed files with 45 additions and 25 deletions
|
|
@ -1584,6 +1584,7 @@ public:
|
|||
|
||||
bool IsGoalVisited (int index);
|
||||
void SetGoalVisited (int index);
|
||||
void ClearVisitedGoals (void);
|
||||
|
||||
inline const Vector &GetBombPosition (void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -587,6 +587,7 @@ void Bot::FindItem (void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemExists)
|
||||
return;
|
||||
|
||||
|
|
@ -787,7 +788,7 @@ void Bot::FindItem (void)
|
|||
}
|
||||
else if (pickupType == PICKUP_PLANTED_C4 && !OutOfBombTimer ())
|
||||
{
|
||||
if (m_states & (STATE_SEEING_ENEMY | STATE_SUSPECT_ENEMY))
|
||||
if (IsValidPlayer (m_enemy))
|
||||
{
|
||||
allowPickup = false;
|
||||
return;
|
||||
|
|
@ -5667,7 +5668,7 @@ Vector Bot::CheckBombAudible (void)
|
|||
{
|
||||
// this function checks if bomb is can be heard by the bot, calculations done by manual testing.
|
||||
|
||||
if (!g_bombPlanted || (GetTaskId () == TASK_ESCAPEFROMBOMB))
|
||||
if (!g_bombPlanted || GetTaskId () == TASK_ESCAPEFROMBOMB)
|
||||
return Vector::GetZero (); // reliability check
|
||||
|
||||
if (m_difficulty >= 3)
|
||||
|
|
|
|||
|
|
@ -1220,7 +1220,7 @@ bool Bot::DoWaypointNav (void)
|
|||
|
||||
if ((g_mapType & MAP_DE) && g_bombPlanted && m_team == TEAM_CF && GetTaskId () != TASK_ESCAPEFROMBOMB && GetTask ()->data != -1)
|
||||
{
|
||||
Vector bombOrigin = CheckBombAudible ();
|
||||
const Vector &bombOrigin = CheckBombAudible ();
|
||||
|
||||
// bot within 'hearable' bomb tick noises?
|
||||
if (!bombOrigin.IsZero ())
|
||||
|
|
@ -2039,7 +2039,7 @@ int Bot::ChooseBombWaypoint (void)
|
|||
bombOrigin = pev->origin;
|
||||
|
||||
int goal = 0, count = 0;
|
||||
float lastDistance = 99999.0f;
|
||||
float lastDistance = 999999.0f;
|
||||
|
||||
// find nearest goal waypoint either to bomb (if "heard" or player)
|
||||
FOR_EACH_AE (goals, i)
|
||||
|
|
|
|||
|
|
@ -426,6 +426,8 @@ void NetworkMsg::Execute (void *p)
|
|||
}
|
||||
else if (!g_bombPlanted && FStrEq (PTR_TO_STR (p), "#Bomb_Planted"))
|
||||
{
|
||||
waypoints.SetBombPosition ();
|
||||
|
||||
g_bombPlanted = g_bombSayString = true;
|
||||
g_timeBombPlanted = GetWorldTime ();
|
||||
|
||||
|
|
@ -442,7 +444,6 @@ void NetworkMsg::Execute (void *p)
|
|||
bot->ChatterMessage (Chatter_WhereIsTheBomb);
|
||||
}
|
||||
}
|
||||
waypoints.SetBombPosition ();
|
||||
}
|
||||
else if (m_bot != NULL && FStrEq (PTR_TO_STR (p), "#Switch_To_BurstFire"))
|
||||
m_bot->m_weaponBurstMode = BM_ON;
|
||||
|
|
|
|||
|
|
@ -747,6 +747,7 @@ void RoundInit (void)
|
|||
g_radioSelect[i] = 0;
|
||||
}
|
||||
waypoints.SetBombPosition (true);
|
||||
waypoints.ClearVisitedGoals ();
|
||||
|
||||
g_bombSayString = false;
|
||||
g_timeBombPlanted = 0.0f;
|
||||
|
|
@ -1176,7 +1177,6 @@ void AddLogEntry (bool outputToConsole, int logLevel, const char *format, ...)
|
|||
printf ("%s", buffer);
|
||||
#endif
|
||||
|
||||
|
||||
#if defined (PLATFORM_WIN32)
|
||||
_exit (1);
|
||||
#else
|
||||
|
|
@ -1535,4 +1535,33 @@ int GetWeaponReturn (bool needString, const char *weaponAlias, int weaponIndex)
|
|||
return weaponTab[i].weaponIndex;
|
||||
}
|
||||
return -1; // no weapon was found return -1
|
||||
}
|
||||
}
|
||||
|
||||
class ISkyBotIf
|
||||
{
|
||||
public:
|
||||
virtual int GetVersion () = 0;
|
||||
};
|
||||
|
||||
class IEntity : public ISkyBotIf
|
||||
{
|
||||
public:
|
||||
};
|
||||
|
||||
class IPlayer : public IEntity
|
||||
{
|
||||
public:
|
||||
};
|
||||
|
||||
class IWeapon : public ISkyBotIf
|
||||
{
|
||||
public:
|
||||
virtual IPlayer *GetOwner () = 0;
|
||||
};
|
||||
|
||||
class IGame : public ISkyBotIf
|
||||
{
|
||||
public:
|
||||
virtual bool IsBombPlanted () = 0;
|
||||
virtual const Vector &GetBombPlantedOrigin () = 0;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2182,25 +2182,13 @@ void Waypoint::SetGoalVisited (int index)
|
|||
if (index < 0 || index >= g_numWaypoints)
|
||||
return;
|
||||
|
||||
if (!IsGoalVisited (index) || !(m_paths[index]->flags & FLAG_GOAL))
|
||||
{
|
||||
#if 0
|
||||
int bombPoint = FindNearest (GetBombPosition ());
|
||||
|
||||
Array <int> markAsVisited;
|
||||
FindInRadius (markAsVisited, 356.0f, GetPath (index)->origin);
|
||||
|
||||
IterateArray (markAsVisited, i)
|
||||
{
|
||||
// skip still valid bomb point
|
||||
if (markAsVisited[i] == bombPoint)
|
||||
continue;
|
||||
|
||||
m_visitedGoals.Push (markAsVisited[i]);
|
||||
}
|
||||
#endif
|
||||
if (!IsGoalVisited (index) && (m_paths[index]->flags & FLAG_GOAL))
|
||||
m_visitedGoals.Push (index);
|
||||
}
|
||||
}
|
||||
|
||||
void Waypoint::ClearVisitedGoals (void)
|
||||
{
|
||||
m_visitedGoals.RemoveAll ();
|
||||
}
|
||||
|
||||
bool Waypoint::IsGoalVisited (int index)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue