.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   Bug Reports (http://forums.bots-united.com/forumdisplay.php?f=49)
-   -   explanation on the changelevel issue (http://forums.bots-united.com/showthread.php?t=1505)

Pierre-Marie Baty 26-04-2004 23:18

explanation on the changelevel issue
 
OK, from what I've read in some other thread I believe an explanation on the "changelevel" command issue with bots is needed.

"changelevel" is an engine command.

When you type it into the console, it goes DIRECTLY to the engine. It does NOT pass through the bot DLL and the bot DLL has NO means to know that this command has been entered.

Since the engine kicks all the bots automatically before each "changelevel", the bot DLL must then "prepare" the bots to be respawned on the next round. That's because if players are respawned automatically, bots are not. It's a different code inside the engine.

But SINCE the bot DLL has no means to know when a "changelevel" command is issued, the bot DLL can't prepare the bots to be respawned when they get kicked by the engine.

That's why the bots don't respawn in the next map when you use the "changelevel" command.

On the other hand, the "map" command does not go directly to the engine, it passes through the bot DLL first. Hence the bot DLL *KNOWS* when you're about to change level using the "map" command.

That's why the bots respawn in the next map correctly when you use the "map" command.

On the other hand it appears that the "map" command make external players disconnect when you change levels. That's because the "map" commands cleanly shuts down and restarts the server, COMPLETELY, whereas the "changelevel" command does NOT reset everything in order to allow players to stay connected. This is unclean, but that's unfortunately what all the dedicated server admins do to force a level change.

Get it right : Changelevel WORKS, but it's an UNCLEAN and UNSAFE command.
The more you use it, the more chances you get that your server crashes randomly after some time.

I've just been hacking around the bot again to try to make the bot "guess" when a changelevel command has been entered, but it's a NASTY, WICKED, KLUDGEY, UGLY hack. I don't even know if it works. I'll probably update the bot DLL today again.

Keep in mind that despite the fact that every server admin uses it happily on a daily basis, changelevel was meant originally to be a SINGLE-PLAYER command.

SoUlFaThEr 26-04-2004 23:51

Re: explanation on the changelevel issue
 
i dont understand why people have a problem using our BOT menu commands for fill server with bots.......after a changelevel command

why does it HAVE TO replace all the bots automatically anyway??

>BKA< T Wrecks 27-04-2004 00:13

Re: explanation on the changelevel issue
 
Yes, that's a good example of how things that are totally unimportant to oneself can be so important for others... I even removed all addbot lines from the cfg and ALWAYS added bots via the menu. But hey, if it's one of those little things that makes some fellows happy and increases the popularity of this bot... Others may wonder what all the fuss about the WP editor is about, although it's very important to you and me.

Pierre-Marie Baty 27-04-2004 01:19

Re: explanation on the changelevel issue
 
Mainly people who run bots on a DEDICATED server may be interested in this feature.

I've updated the bot again. I've put in a hack to make the bots be added from the config file after a changelevel command. But I don't guarantee this command will not cause problems in the future ! In short: if it works, fine. If it doesn't, don't complain.

I've also modified the way the addbot code works so that bot skills are displayed when you enter the bot names manually. I had to change a few things. I hope it will make KWo happy at last.

[NvT]_KaszpiR_ 28-04-2004 14:39

Re: explanation on the changelevel issue
 
okay, interesting and helpful explanation.
Then, what happends when the timelimit is reached?
because i have noticed that making mp_timelimit 1 is sometimes better than changelevel command
(of course in server.cfg i got mp_timelimit 20)

Pierre-Marie Baty 28-04-2004 15:38

Re: explanation on the changelevel issue
 
when the time limit is reached it's the GAME DLL which decides of the level change, not the engine. The game DLL thus tells the engine about the level change, by calling ServerDeactivate() properly, followed by a new ServerActivate(). Then the engine executes the level change, *upon GameDLL command* (and not by itself). Since the game DLL calls them in the engine, our bot DLL can hook them.

Were it the engine only, that decided to change maps, not only the server would be shutdown abruptly (because the game DLL wouldn't even be told), but we couldn't even hook it since nothing from the process passes through the bot DLL.

Huntkillaz 28-04-2004 22:53

Re: explanation on the changelevel issue
 
Quote:

Originally Posted by SoUlFaThEr
i dont understand why people have a problem using our BOT menu commands for fill server with bots.......after a changelevel command

why does it HAVE TO replace all the bots automatically anyway??

is there a way to dectect a level has been changed..ie not through the dll but maybe a diffrence in the map or a restart in the map?

Pierre-Marie Baty 29-04-2004 00:42

Re: explanation on the changelevel issue
 
yes, we CAN detect that a level has been changed, and this without problems ; however the tricky part is to recall WHICH bots were on the server before the map change occured.

It would be much more simple if the server was telling us that it's bringing the map down. Then we save the bots for next time, load the new map, and slap the bots back in. Just like what we do when it's the game DLL and not the engine that decides a level change.

We could eventually save all of the bot's parms each frame in a backup structure, preventively, but that would be ugly.

KWo 29-04-2004 02:08

Re: explanation on the changelevel issue
 
PMB - I'm not a coder, so maybe my suggestion is stupid, but maybe is the way to find solution...

What I can see in my log files (on listenserver) after changelevel commands:

L 04/29/2004 - 01:44:01: [STATSME] "KWo<1><4294967295><CT>" triggered "latency" (ping "37")
L 04/29/2004 - 01:44:01: [STATSME] "KWo<1><4294967295><CT>" triggered "time" (Time "0:33")
L 04/29/2004 - 01:44:01: [STATSME] Saving statsme rank (file "cstrike\addons\statsme\statsme.log") (game "cstrike") (version "14")

L 04/29/2004 - 01:44:02: [META] ini: Begin re-reading plugins list: d:/cs/cstrike/addons/metamod/plugins.ini
L 04/29/2004 - 01:44:02: [META] ini: Read plugin config for: ClanMod
L 04/29/2004 - 01:44:02: [META] ini: Read plugin config for: STATSME
L 04/29/2004 - 01:44:02: [META] ini: Read plugin config for: POD-Bot
L 04/29/2004 - 01:44:02: [META] ini: Read plugin config for: BotAim
L 04/29/2004 - 01:44:02: [META] ini: Finished reading plugins list: d:/cs/cstrike/addons/metamod/plugins.ini; Found 4 plugins
L 04/29/2004 - 01:44:02: [META] dll: Updating plugins...
L 04/29/2004 - 01:44:02: [META] dll: Finished updating 4 plugins; kept 4, loaded 0, unloaded 0, reloaded 0, delayed 0
L 04/29/2004 - 01:44:02: "KWo<1><4294967295><CT>" disconnected
L 04/29/2004 - 01:44:02: World triggered "Round_Draw" (CT "0") (T "0")
L 04/29/2004 - 01:44:02: World triggered "Round_End"
L 04/29/2004 - 01:44:02: Log file closed

L 04/29/2004 - 01:44:02: Log file started (file "D:\CS\cstrike\logs\L0429001.log") (game "cstrike") (version "46/1.1.1.0/2056")
L 04/29/2004 - 01:44:02: Loading map "de_bridge"
L 04/29/2004 - 01:44:02: Server cvars start
L 04/29/2004 - 01:44:02: Server cvar "mp_logfile" = "1"
L 04/29/2004 - 01:44:02: Server cvar "deathmatch" = "1"
L 04/29/2004 - 01:44:02: Server cvar "coop" = "0"

In the first part I can see re-reading plugins list by metamod - it means metamod knows this, that the changelevel command is executed. So maybe it's possible take this information from metamod or simply trigger this meta re-reading to start the procedure of clearing all before map change?
In the second part I can see this Loading map - maybe You can trigger thishttp://forums.bots-united.com/images/icons/icon4.gif?

sPlOrYgOn 29-04-2004 02:41

Re: explanation on the changelevel issue
 
I think what PMB is saying is..
He can detect when a new map starts after a changelevel command but he cannot detect when the map ends due to a changelevel command..
as you can see metamod only detects when it's starting new level after it has already kicked all the bots..
So he has no way of getting the bots from the last map to continue in the new map.

[NvT]_KaszpiR_ 29-04-2004 08:33

Re: explanation on the changelevel issue
 
does this "feature" of changelevel was form the very beginnign or it showed up since cs 1.6?

Pierre-Marie Baty 29-04-2004 16:06

Re: explanation on the changelevel issue
 
there has always been issues with changelevel, by the fact that it's not a game command but an engine command. But it seems it's gotten worse with CS 1.6 as far as the random crashes are concerned.

I think it may come that now in CS 1.6 it's not the engine but Counter-Strike itself that holds the repository of the entity list. The CS developers did that to speedup all the entity-related operations and take load away from the engine. Hence changelevel may have the engine clean up its own entity list, but NOT the Counter-Strike DLL -----> entities out of sync ----> crashes.

botmeister 29-04-2004 19:21

Re: explanation on the changelevel issue
 
Quote:

Originally Posted by Pierre-Marie Baty
when the time limit is reached it's the GAME DLL which decides of the level change, not the engine. The game DLL thus tells the engine about the level change, by calling ServerDeactivate() properly, followed by a new ServerActivate(). Then the engine executes the level change, *upon GameDLL command* (and not by itself). Since the game DLL calls them in the engine, our bot DLL can hook them.

Were it the engine only, that decided to change maps, not only the server would be shutdown abruptly (because the game DLL wouldn't even be told), but we couldn't even hook it since nothing from the process passes through the bot DLL.

Pierre, we ought to be able to get something that's not ugly to work for this.

I don;t have my head fully wrapped around the problem yet, so please bare with me if I ask you a few silly questions.

With a CHANGELEVEL command, it seems the server will autokick all the bots out and on next round they won't automatically respawn unless your bot code does this. The problem is knowing how many bots to respawn and what the status of each bot was (eg skin, skill, ect)

Correct?

Some assumptions:

a. CHANGELEVEL is the only way to change a map without knowing in advance.

b. All other methods to change a map can be trapped in advance.

c. We can always reliably detect when a new map has loaded.

My first question:

Why won't this work?

On each new map detection, you should be able to scan through your bot list, and for each bot that is flagged as "spawned" but is missing, you respawn it. I am assuming that your bot code will keep all the needed details inside your bot list structure.

Pierre-Marie Baty 30-04-2004 00:44

Re: explanation on the changelevel issue
 
it's not that simple... first I think if I recall well that the bots structures are reset completely at ServerActivate to free all the bad pointers that may remain in them. Then, there is a LOT of code everywhere else that relies on this flag to determine if a bot is present or not, and if so, make it do things. If this flag is on and the bot is not here, my guess is that you'll have more crashes than anything else.

botmeister 30-04-2004 04:44

Re: explanation on the changelevel issue
 
How about you create a new secondary structure that holds the essential information for respawning bots.

If the a new map is loaded using a "safe" method, then set a flag in the structure (or somewhere) which indicates that bots do not need to be respawned - I'm assuming the old bot code will respawn all the bots correctly.

After ServerActivate clears everything (but not the secondary structure if the bots are to be respawned) and our special flag says that the bots should be respawned, then do so using the info contained in the secondary structure.

The structure can be updated from whatever changes the original structure (addbot, kickbot) not sure, because this part could be full of spaghetti.

What do you think?

Pierre-Marie Baty 30-04-2004 15:03

Re: explanation on the changelevel issue
 
I think I'm done with podbot at the moment. :)
I've been reopening RACC again and there's a lot of work still left to do :)

Hope you understand :)


Certainly in a few months I'll be wrapping my head around it again, but right now... I'm just recovering from a podbot overdose. :)

SoUlFaThEr 30-04-2004 15:12

Re: explanation on the changelevel issue
 
go do that man.......its Burger King and you deserve a break this month :)

botmeister 01-05-2004 05:25

Re: explanation on the changelevel issue
 
Don't blame ya, you've done shit loads of work, so a break is in order :)


All times are GMT +2. The time now is 02:38.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.