bot: some fixes to radio handling (ref #560)

This commit is contained in:
jeefo 2024-05-07 22:01:57 +03:00
commit 6663cdab7b
No known key found for this signature in database
GPG key ID: D696786B81B667C8
4 changed files with 12 additions and 9 deletions

@ -1 +1 @@
Subproject commit 3e2bd997a6048a0c2d9318e65a63b30a35c67dfa Subproject commit b13855d46f848daa43eee990081b97f3e83d87fd

View file

@ -441,6 +441,7 @@ constexpr auto kGameMaxPlayers = 32;
constexpr auto kGameTeamNum = 2; constexpr auto kGameTeamNum = 2;
constexpr auto kInvalidNodeIndex = -1; constexpr auto kInvalidNodeIndex = -1;
constexpr auto kGrenadeInventoryEmpty = -1; constexpr auto kGrenadeInventoryEmpty = -1;
constexpr auto kInvalidRadioSlot = -1;
constexpr auto kConfigExtension = "cfg"; constexpr auto kConfigExtension = "cfg";
// weapon masks // weapon masks

View file

@ -947,7 +947,7 @@ void Bot::pushChatterMessage (int message) {
} }
if (!sendMessage) { if (!sendMessage) {
m_radioSelect = -1; m_radioSelect = kInvalidRadioSlot;
return; return;
} }
m_radioSelect = message; m_radioSelect = message;
@ -1047,14 +1047,14 @@ void Bot::checkMsgQueue () {
// if same message like previous just do a yes/no // if same message like previous just do a yes/no
if (m_radioSelect != Radio::RogerThat && m_radioSelect != Radio::Negative) { if (m_radioSelect != Radio::RogerThat && m_radioSelect != Radio::Negative) {
if (m_radioSelect == bots.getLastRadio (m_team) && bots.getLastRadioTimestamp (m_team) + delayResponseTime * 0.5f > game.time ()) { if (m_radioSelect == bots.getLastRadio (m_team) && bots.getLastRadioTimestamp (m_team) + delayResponseTime * 0.5f > game.time ()) {
m_radioSelect = -1; m_radioSelect = kInvalidRadioSlot;
} }
else { else {
if (m_radioSelect != Radio::ReportingIn) { if (m_radioSelect != Radio::ReportingIn) {
bots.setLastRadio (m_team, m_radioSelect); bots.setLastRadio (m_team, m_radioSelect);
} }
else { else {
bots.setLastRadio (m_team, -1); bots.setLastRadio (m_team, kInvalidRadioSlot);
} }
for (const auto &bot : bots) { for (const auto &bot : bots) {
@ -1066,26 +1066,28 @@ void Bot::checkMsgQueue () {
} }
} }
if (m_radioSelect != -1) { if (m_radioSelect != kInvalidRadioSlot) {
if ((m_radioSelect != Radio::ReportingIn && m_forceRadio) if ((m_radioSelect != Radio::ReportingIn && m_forceRadio)
|| cv_radio_mode.as <int> () != 2 || cv_radio_mode.as <int> () != 2
|| !conf.hasChatterBank (m_radioSelect) || !conf.hasChatterBank (m_radioSelect)
|| !game.is (GameFlags::HasBotVoice)) { || !game.is (GameFlags::HasBotVoice)) {
auto radioSlot = m_radioSelect;
if (m_radioSelect < Radio::GoGoGo) { if (m_radioSelect < Radio::GoGoGo) {
issueCommand ("radio1"); issueCommand ("radio1");
} }
else if (m_radioSelect < Radio::RogerThat) { else if (m_radioSelect < Radio::RogerThat) {
m_radioSelect -= Radio::GoGoGo - 1; radioSlot -= Radio::GoGoGo - 1;
issueCommand ("radio2"); issueCommand ("radio2");
} }
else { else {
m_radioSelect -= Radio::RogerThat - 1; radioSlot -= Radio::RogerThat - 1;
issueCommand ("radio3"); issueCommand ("radio3");
} }
// select correct menu item for this radio message // select correct menu item for this radio message
issueCommand ("menuselect %d", m_radioSelect); issueCommand ("menuselect %d", radioSlot);
} }
else if (m_radioSelect != Radio::ReportingIn) { else if (m_radioSelect != Radio::ReportingIn) {
instantChatter (m_radioSelect); instantChatter (m_radioSelect);

View file

@ -227,7 +227,7 @@ void MessageDispatcher::netMsgMoney () {
if (amount < 0) { if (amount < 0) {
amount = 800; amount = 800;
} }
else if (amount > INT32_MAX) { else if (amount >= INT32_MAX) {
amount = 16000; amount = 16000;
} }
m_bot->m_moneyAmount = amount; m_bot->m_moneyAmount = amount;