add: implemented #122.

fix: bots try to defuse already beeing defused bomb (fixes #116).
fix: line ending in source code.
fix:  do not retreat with sniper weapon, if currently shooting and have ammo.
crlib: added deque class.
This commit is contained in:
ds 2020-09-16 13:07:47 +03:00
commit fa47e418b2
19 changed files with 420 additions and 73 deletions

View file

@ -332,6 +332,26 @@ void MessageDispatcher::netMsgTeamInfo () {
client.team = game.is (GameFlags::FreeForAll) ? m_args[index].long_ : client.team2;
}
void MessageDispatcher::netMsgScoreInfo () {
// this message gets sent when scoreboard info is update, we're use it to track k-d ratio
enum args { index = 0, score = 1, deaths = 2, class_id = 3, team_id = 4, min = 5 };
// check the minimum states
if (m_args.length () < min) {
return;
}
auto &client = util.getClient (m_args[index].long_ - 1);
// get the bot in this msg
auto bot = bots[client.ent];
// if we're have bot, set the kd ratio
if (bot != nullptr) {
bot->m_kpdRatio = bot->pev->frags / cr::max <long> (m_args[deaths].long_, 1);
}
}
void MessageDispatcher::netMsgBarTime () {
enum args { enabled = 0, min = 1 };
@ -415,6 +435,7 @@ MessageDispatcher::MessageDispatcher () {
addWanted ("ItemStatus", NetMsg::ItemStatus, &MessageDispatcher::netMsgItemStatus);
addWanted ("NVGToggle", NetMsg::NVGToggle, &MessageDispatcher::netMsgNVGToggle);
addWanted ("FlashBat", NetMsg::FlashBat, &MessageDispatcher::netMsgFlashBat);
addWanted ("ScoreInfo", NetMsg::ScoreInfo, &MessageDispatcher::netMsgScoreInfo);
// we're need next messages IDs but we're won't handle them, so they will be removed from wanted list as soon as they get engine IDs
addWanted ("BotVoice", NetMsg::BotVoice, nullptr);