View Single Post
Re: Reporting of Bugs and Errors for E[POD]bot
Old
  (#12)
preztoo
Member
 
Status: Offline
Posts: 18
Join Date: Oct 2005
Default Re: Reporting of Bugs and Errors for E[POD]bot - 31-10-2005

I believe I have found a bug in the code. Not being a c++ freak, I have not pinpointed the exact location but there seems to be a programming error in the creation of bots.

First, the code in dll.cpp checks to see how many clients are on server and compares to max_bots:

// check if time to see if a bot needs to be created...
if (bot_check_time < gpGlobals->time)
{
int count = 0;
bot_check_time = gpGlobals->time + 0.5;
for (i = 0; i < 32; i++)
{
if (clients[i].pEntity != NULL)
count++;
}
// if there are currently less than the maximum number of "players"
// then add another bot using the default skill level...
//Bot auto-adding
if ((count < max_bots) && (max_bots != -1) && (g_bAutoFill))
{
BotCreate(NULL, NULL, NULL, NULL, NULL);
}
}

I believe the above code has some type of logic error. Maybe the check for clients doesn't include bots? Then it will never stop.... that's what happens on my dedicated server. The above code will then call the creation routine in bot.cpp, void BotCreate.

Here is another logical error. When trying to create a bot, but failing (probably because it has reached the maxuser limit, the code writes out the error code,

"Max. Players reached. Can't create bot!\n"

That is the message I get in my server console. It just creates this error in an ongoing process creating lagg and CPU consumption.

The code then does this:

max_bots = index; //Sets maxbots to the server limit.

That is an error, for now it sets max_bots to a number other than the one in epb.conf!!!

i.e. I have max_bots 4 in my config. I have maxusers 12
When I start server, this code adds 12 bots ignoring my config settings. Thats why I say there is a logical error in the first code. Then, when the code tries to create the 13th bot, it sets the max_bot from 4 to 12! Why??? Anyway, the code repeats itself. Fails to not create bot in dll.cpp, then tries to create a bot in bot.cpp

// This call creates the Fakeclient
BotEnt = g_engfuncs.pfnCreateFakeClient(c_name);

This code that creates a bot will fail when the number of bots have reached the maxusers thus envoking

// Did the Call succeed ?
if (FNullEnt(BotEnt))
{
if (pPlayer)
UTIL_HostPrint("#Bot_Create_ServerFull");
else if (IS_DEDICATED_SERVER())
printf("Max. Players reached. Can't create bot!\n");
botcreation_time = 0.0;
max_bots = index; //Sets maxbots to the server limit.
}

So, whoever is coding this stuff, please take a look and fix this.

I believe the error is here:

for (i = 0; i < 32; i++)
{
if (clients[i].pEntity != NULL)
count++;
}

First, we don't need to check for 32 but for maxbots
Second, I think that the array clients.pEntity doesn't include the amount of bots, does it? That would explain why the code tries to add more bots. I'm too tired now to go through the code and find oyut if it does or not....:-) Going to bed now...
  
Reply With Quote