FWGS / hlsdk-portable

Portable Half-Life SDK. GoldSource and Xash3D. Crossplatform.
https://xash.su
Other
266 stars 121 forks source link

[bot-10] respawn configured bots / part 2 #426

Open d47081 opened 7 months ago

d47081 commented 7 months ago

Update for PR #422

Removes bot state reset on bot thinking, also the kicked state was changed from BOT_IDLE to BOT_NEED_TO_RESPAWN

I think this model more useful in bot container and looks not conflicting with it logic. That allows to respawn configured bots only (from queue not from default BOT_IDLE slots registry)

Solution looks stable, but please let me test it for few days before merge.

d47081 commented 7 months ago

Well, in last commit have fixed players online counter and make code optimizations:

  1. fixed online counter as bots generated in wrong quantity after player disconnect / map rotation events
  2. removed duplicated construction with BotCreate - as calling twice
  3. renamed count variable to online as more clear, defined it also on init with integer data type
  4. fixed bot_check_time as found the loop never stops - it reduces the CPU load

After this commit I need additional time for tests, it looks better just doubts that everything stable.

d47081 commented 7 months ago

Last 2 commits includes:

testing..

d47081 commented 7 months ago

Everything works, but I found bots and players sometimes freeze / stuck - maybe after disconnection. It happened on high online and/or session is closer to map rotate.

I think this problem related with slot.state changes, it's not frames or CPU issue as debug of timing works well.