fixed duplicate names after multiple level changes

This commit is contained in:
jeefo 2014-08-05 22:26:16 +04:00
commit eab08307da
3 changed files with 52 additions and 8 deletions

View file

@ -587,6 +587,8 @@ void InitConfig (void)
// NAMING SYSTEM INITIALIZATION // NAMING SYSTEM INITIALIZATION
if (OpenConfig ("names.cfg", "Name configuration file not found.", &fp , true)) if (OpenConfig ("names.cfg", "Name configuration file not found.", &fp , true))
{ {
g_botNames.RemoveAll ();
while (fp.GetBuffer (line, 255)) while (fp.GetBuffer (line, 255))
{ {
SKIP_COMMENTS (); SKIP_COMMENTS ();
@ -1045,13 +1047,15 @@ void CommandHandler_NotMM (void)
void GameDLLInit (void) void GameDLLInit (void)
{ {
// this function is a one-time call, and appears to be the second function called in the // this function is a one-time call, and appears to be the second function called in the
// DLL after FuncPointers_t() has been called. Its purpose is to tell the MOD DLL to // DLL after GiveFntprsToDll() has been called. Its purpose is to tell the MOD DLL to
// initialize the game before the engine actually hooks into it with its video frames and // initialize the game before the engine actually hooks into it with its video frames and
// clients connecting. Note that it is a different step than the *server* initialization. // clients connecting. Note that it is a different step than the *server* initialization.
// This one is called once, and only once, when the game process boots up before the first // This one is called once, and only once, when the game process boots up before the first
// server is enabled. Here is a good place to do our own game session initialization, and // server is enabled. Here is a good place to do our own game session initialization, and
// to register by the engine side the server commands we need to administrate our bots. // to register by the engine side the server commands we need to administrate our bots.
DetectCSVersion ();
// register server command(s) // register server command(s)
RegisterCommand ("yapb", CommandHandler); RegisterCommand ("yapb", CommandHandler);
RegisterCommand ("yb", CommandHandler); RegisterCommand ("yb", CommandHandler);
@ -1078,7 +1082,7 @@ int Spawn (edict_t *ent)
if (strcmp (STRING (ent->v.classname), "worldspawn") == 0) if (strcmp (STRING (ent->v.classname), "worldspawn") == 0)
{ {
DetectCSVersion (); g_convarWrapper->PushRegisteredConVarsToEngine (true);
PRECACHE_SOUND (ENGINE_STR ("weapons/xbow_hit1.wav")); // waypoint add PRECACHE_SOUND (ENGINE_STR ("weapons/xbow_hit1.wav")); // waypoint add
PRECACHE_SOUND (ENGINE_STR ("weapons/mine_activate.wav")); // waypoint delete PRECACHE_SOUND (ENGINE_STR ("weapons/mine_activate.wav")); // waypoint delete

View file

@ -941,12 +941,13 @@ PriorityQueue::PriorityQueue (void)
{ {
m_size = 0; m_size = 0;
m_heapSize = MAX_WAYPOINTS * 4; m_heapSize = MAX_WAYPOINTS * 4;
m_heap = new HeapNode_t[sizeof (HeapNode_t) * m_heapSize]; m_heap = (HeapNode_t *) malloc (sizeof (HeapNode_t) * m_heapSize);
} }
PriorityQueue::~PriorityQueue (void) PriorityQueue::~PriorityQueue (void)
{ {
delete [] m_heap; free (m_heap);
m_heap = NULL; m_heap = NULL;
} }
@ -1149,7 +1150,7 @@ int gfunctionKillsCTWithHostage (int currentIndex, int parentIndex)
Path *current = g_waypoint->GetPath (currentIndex); Path *current = g_waypoint->GetPath (currentIndex);
if (current->flags & FLAG_NOHOSTAGE) if (current->flags & FLAG_NOHOSTAGE)
return 65536; return 65355;
else if (current->flags & (FLAG_CROUCH | FLAG_LADDER)) else if (current->flags & (FLAG_CROUCH | FLAG_LADDER))
return gfunctionKillsDistCT (currentIndex, parentIndex) * 500; return gfunctionKillsDistCT (currentIndex, parentIndex) * 500;
@ -1157,6 +1158,40 @@ int gfunctionKillsCTWithHostage (int currentIndex, int parentIndex)
return gfunctionKillsCT (currentIndex, parentIndex); return gfunctionKillsCT (currentIndex, parentIndex);
} }
int gfunctionPathDist (int currentIndex, int parentIndex)
{
if (parentIndex == -1)
return 0;
Path *parent = g_waypoint->GetPath (parentIndex);
Path *current = g_waypoint->GetPath (currentIndex);
for (int i = 0; i < MAX_PATH_INDEX; i++)
{
if (parent->index[i] == currentIndex)
{
// we don't like ladder or crouch point
if (current->flags & (FLAG_CROUCH | FLAG_LADDER))
return parent->distances[i] * 1.5;
return parent->distances[i];
}
}
return 65355;
}
int gfunctionPathDistWithHostage (int currentIndex, int parentIndex)
{
Path *current = g_waypoint->GetPath (currentIndex);
if (current->flags & FLAG_NOHOSTAGE)
return 65355;
else if (current->flags & (FLAG_CROUCH | FLAG_LADDER))
return gfunctionPathDist (currentIndex, parentIndex) * 500;
return gfunctionPathDist (currentIndex, parentIndex);
}
int hfunctionSquareDist (int startIndex, int goalIndex) int hfunctionSquareDist (int startIndex, int goalIndex)
{ {
// square distance heuristic // square distance heuristic
@ -1186,6 +1221,12 @@ int hfunctionNone (int startIndex, int goalIndex)
return hfunctionSquareDist (startIndex, goalIndex) / (128 * 10); return hfunctionSquareDist (startIndex, goalIndex) / (128 * 10);
} }
int hfunctionNumberNodes (int startIndex, int goalIndex)
{
return hfunctionSquareDist (startIndex, goalIndex) / 128 * g_highestKills;
}
void Bot::FindPath (int srcIndex, int destIndex, unsigned char pathType) void Bot::FindPath (int srcIndex, int destIndex, unsigned char pathType)
{ {
// this function finds a path from srcIndex to destIndex // this function finds a path from srcIndex to destIndex
@ -1236,12 +1277,12 @@ void Bot::FindPath (int srcIndex, int destIndex, unsigned char pathType)
case 0: case 0:
if ((g_mapType & MAP_CS) && HasHostage ()) if ((g_mapType & MAP_CS) && HasHostage ())
{ {
gcalc = hfunctionNone; gcalc = gfunctionPathDistWithHostage;
hcalc = hfunctionSquareDistWithHostage; hcalc = hfunctionSquareDistWithHostage;
} }
else else
{ {
gcalc = hfunctionNone; gcalc = gfunctionPathDist;
hcalc = hfunctionSquareDist; hcalc = hfunctionSquareDist;
} }
break; break;

View file

@ -1147,7 +1147,6 @@ void DetectCSVersion (void)
ServerPrint (infoBuffer, "CZ (Steam)", sizeof (Bot)); ServerPrint (infoBuffer, "CZ (Steam)", sizeof (Bot));
break; break;
} }
g_convarWrapper->PushRegisteredConVarsToEngine (true);
} }
void PlaySound (edict_t *ent, const char *name) void PlaySound (edict_t *ent, const char *name)