diff --git a/ext/crlib b/ext/crlib index 11dc7fe..448e834 160000 --- a/ext/crlib +++ b/ext/crlib @@ -1 +1 @@ -Subproject commit 11dc7fe543fef9d16045e7f9e01fb40668099eda +Subproject commit 448e8341b8bba351c7b9e81ea9949588cedad10a diff --git a/inc/engine.h b/inc/engine.h index ed9bb12..eb0a79b 100644 --- a/inc/engine.h +++ b/inc/engine.h @@ -232,6 +232,9 @@ public: // check the cvar bounds void checkCvarsBounds (); + // modify cvar description + void setCvarDescription (const ConVar &cv, StringRef info); + // sends local registration stack for engine registration void registerCvars (bool gameVars = false); diff --git a/inc/support.h b/inc/support.h index 43a38d8..dcb1367 100644 --- a/inc/support.h +++ b/inc/support.h @@ -8,6 +8,9 @@ #pragma once class BotSupport final : public Singleton { + using AliasInfo = Twin ; + using AliasMap = HashMap >; + private: bool m_needToSendWelcome {}; float m_welcomeReceiveTime {}; @@ -15,7 +18,7 @@ private: StringArray m_sentences {}; SmallArray m_clients {}; - HashMap m_weaponAliases {}; + AliasMap m_weaponAliases {}; public: BotSupport (); @@ -79,6 +82,9 @@ public: // get's the wave length float getWaveLength (StringRef filename); + // set custom cvar descriptions + void setCustomCvarDescriptions (); + public: // re-show welcome after changelevel ? diff --git a/inc/yapb.h b/inc/yapb.h index 0273986..8987055 100644 --- a/inc/yapb.h +++ b/inc/yapb.h @@ -932,6 +932,7 @@ extern ConVar cv_camping_time_max; extern ConVar cv_smoke_grenade_checks; extern ConVar cv_check_darkness; extern ConVar cv_use_hitbox_enemy_targeting; +extern ConVar cv_restricted_weapons; extern ConVar mp_freezetime; extern ConVar mp_roundtime; diff --git a/src/botlib.cpp b/src/botlib.cpp index 81f3957..87d94d8 100644 --- a/src/botlib.cpp +++ b/src/botlib.cpp @@ -31,9 +31,8 @@ ConVar cv_object_pickup_radius ("object_pickup_radius", "450.0", "The radius on ConVar cv_object_destroy_radius ("object_destroy_radius", "400.0", "The radius on which bot destroy breakables around it, when not touching with them.", true, 64.0f, 1024.0f); ConVar cv_chatter_path ("chatter_path", "sound/radio/bot", "Specifies the paths for the bot chatter sound files.", false); -ConVar cv_restricted_weapons ("restricted_weapons", "", "Specifies semicolon separated list of weapons that are not allowed to buy / pickup.", false); - ConVar cv_attack_monsters ("attack_monsters", "0", "Allows or disallows bots to attack monsters."); + ConVar cv_pickup_custom_items ("pickup_custom_items", "0", "Allows or disallows bots to pickup custom items."); ConVar cv_pickup_ammo_and_kits ("pickup_ammo_and_kits", "0", "Allows bots pickup mod items like ammo, health kits and suits."); ConVar cv_pickup_best ("pickup_best", "1", "Allows or disallows bots to pickup best weapons."); diff --git a/src/engine.cpp b/src/engine.cpp index b36c597..8177528 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -468,7 +468,7 @@ void Game::sendServerMessage (StringRef message) { // split up the string into chunks if needed (maybe check if it's multibyte?) if (message.length () > kMaxSendLength) { - auto chunks = message.split (kMaxSendLength); + auto chunks = message.split (kMaxSendLength); // send in chunks for (size_t i = 0; i < chunks.length (); ++i) { @@ -733,6 +733,15 @@ void Game::checkCvarsBounds () { } } +void Game::setCvarDescription (const ConVar &cv, StringRef info) { + for (auto &var : m_cvars) { + if (var.name == cv.name ()) { + var.info = info; + break; + } + } +} + void Game::registerCvars (bool gameVars) { // this function pushes all added global variables to engine registration @@ -911,6 +920,9 @@ bool Game::postload () { // register bot cvars registerCvars (); + // set custom cvar descriptions after registering them + util.setCustomCvarDescriptions (); + // handle prefixes static StringArray prefixes = { product.cmdPri, product.cmdSec }; diff --git a/src/linkage.cpp b/src/linkage.cpp index 11aaed3..bd60fbb 100644 --- a/src/linkage.cpp +++ b/src/linkage.cpp @@ -933,8 +933,8 @@ CR_EXPORT int Meta_Query (char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_t // check for interface version compatibility if (strcmp (ifvers, Plugin_info.ifvers) != 0) { - auto mdll = StringRef (ifvers).split (":"); - auto pdll = StringRef (META_INTERFACE_VERSION).split (":"); + auto mdll = String (ifvers).split (":"); + auto pdll = String (META_INTERFACE_VERSION).split (":"); gpMetaUtilFuncs->pfnLogError (PLID, "%s: meta-interface version mismatch (metamod: %s, %s: %s)", Plugin_info.name, ifvers, Plugin_info.name, Plugin_info.ifvers); diff --git a/src/manager.cpp b/src/manager.cpp index 452f437..d91b707 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -49,6 +49,8 @@ ConVar cv_rotate_bots ("rotate_bots", "0", "Randomly disconnect and connect bots ConVar cv_rotate_stay_min ("rotate_stay_min", "360.0", "Specifies minimum amount of seconds bot keep connected, if rotation active.", true, 120.0f, 7200.0f); ConVar cv_rotate_stay_max ("rotate_stay_max", "3600.0", "Specifies maximum amount of seconds bot keep connected, if rotation active.", true, 1800.0f, 14400.0f); +ConVar cv_restricted_weapons ("restricted_weapons", "", "", false); + ConVar mp_limitteams ("mp_limitteams", nullptr, Var::GameRef); ConVar mp_autoteambalance ("mp_autoteambalance", nullptr, Var::GameRef); ConVar mp_roundtime ("mp_roundtime", nullptr, Var::GameRef); @@ -58,28 +60,12 @@ ConVar mp_freezetime ("mp_freezetime", nullptr, Var::GameRef, true, "0"); BotManager::BotManager () { // this is a bot manager class constructor - m_lastDifficulty = 0; - m_lastWinner = -1; - - m_timeRoundStart = 0.0f; - m_timeRoundMid = 0.0f; - m_timeRoundEnd = 0.0f; - - m_autoKillCheckTime = 0.0f; - m_maintainTime = 0.0f; - m_quotaMaintainTime = 0.0f; - m_difficultyBalanceTime = 0.0f; - - m_bombPlanted = false; - m_botsCanPause = false; - m_roundOver = false; - for (int i = 0; i < kGameTeamNum; ++i) { m_leaderChoosen[i] = false; m_economicsGood[i] = true; m_lastRadioTime[i] = 0.0f; - m_lastRadio[i] = -1; + m_lastRadio[i] = kInvalidRadioSlot; } reset (); diff --git a/src/support.cpp b/src/support.cpp index 9be099a..e405485 100644 --- a/src/support.cpp +++ b/src/support.cpp @@ -46,40 +46,39 @@ BotSupport::BotSupport () { // register weapon aliases m_weaponAliases = { - { Weapon::USP, "usp" }, // HK USP .45 Tactical - { Weapon::Glock18, "glock" }, // Glock18 Select Fire - { Weapon::Deagle, "deagle" }, // Desert Eagle .50AE - { Weapon::P228, "p228" }, // SIG P228 - { Weapon::Elite, "elite" }, // Dual Beretta 96G Elite - { Weapon::FiveSeven, "fn57" }, // FN Five-Seven - { Weapon::M3, "m3" }, // Benelli M3 Super90 - { Weapon::XM1014, "xm1014" }, // Benelli XM1014 - { Weapon::MP5, "mp5" }, // HK MP5-Navy - { Weapon::TMP, "tmp" }, // Steyr Tactical Machine Pistol - { Weapon::P90, "p90" }, // FN P90 - { Weapon::MAC10, "mac10" }, // Ingram MAC-10 - { Weapon::UMP45, "ump45" }, // HK UMP45 - { Weapon::AK47, "ak47" }, // Automat Kalashnikov AK-47 - { Weapon::Galil, "galil" }, // IMI Galil - { Weapon::Famas, "famas" }, // GIAT FAMAS - { Weapon::SG552, "sg552" }, // Sig SG-552 Commando - { Weapon::M4A1, "m4a1" }, // Colt M4A1 Carbine - { Weapon::AUG, "aug" }, // Steyr Aug - { Weapon::Scout, "scout" }, // Steyr Scout - { Weapon::AWP, "awp" }, // AI Arctic Warfare/Magnum - { Weapon::G3SG1, "g3sg1" }, // HK G3/SG-1 Sniper Rifle - { Weapon::SG550, "sg550" }, // Sig SG-550 Sniper - { Weapon::M249, "m249" }, // FN M249 Para - { Weapon::Flashbang, "flash" }, // Concussion Grenade - { Weapon::Explosive, "hegren" }, // High-Explosive Grenade - { Weapon::Smoke, "sgren" }, // Smoke Grenade - { Weapon::Armor, "vest" }, // Kevlar Vest - { Weapon::ArmorHelm, "vesthelm" }, // Kevlar Vest and Helmet - { Weapon::Defuser, "defuser" }, // Defuser Kit - { Weapon::Shield, "shield" }, // Tactical Shield - { Weapon::Knife, "knife" } // Knife + { Weapon::USP, AliasInfo { "usp", "HK USP .45 Tactical" } }, + { Weapon::Glock18, AliasInfo { "glock", "Glock18 Select Fire" } }, + { Weapon::Deagle, AliasInfo { "deagle", "Desert Eagle .50AE" } }, + { Weapon::P228, AliasInfo { "p228", "SIG P228" } }, + { Weapon::Elite, AliasInfo { "elite", "Dual Beretta 96G Elite" } }, + { Weapon::FiveSeven, AliasInfo { "fn57", "FN Five-Seven" } }, + { Weapon::M3, AliasInfo { "m3", "Benelli M3 Super90" } }, + { Weapon::XM1014, AliasInfo { "xm1014", "Benelli XM1014" } }, + { Weapon::MP5, AliasInfo { "mp5", "HK MP5-Navy" } }, + { Weapon::TMP, AliasInfo { "tmp", "Steyr Tactical Machine Pistol" } }, + { Weapon::P90, AliasInfo { "p90", "FN P90" } }, + { Weapon::MAC10, AliasInfo { "mac10", "Ingram MAC-10" } }, + { Weapon::UMP45, AliasInfo { "ump45", "HK UMP45" } }, + { Weapon::AK47, AliasInfo { "ak47", "Automat Kalashnikov AK-47" } }, + { Weapon::Galil, AliasInfo { "galil", "IMI Galil" } }, + { Weapon::Famas, AliasInfo { "famas", "GIAT FAMAS" } }, + { Weapon::SG552, AliasInfo { "sg552", "Sig SG-552 Commando" } }, + { Weapon::M4A1, AliasInfo { "m4a1", "Colt M4A1 Carbine" } }, + { Weapon::AUG, AliasInfo { "aug", "Steyr Aug" } }, + { Weapon::Scout, AliasInfo { "scout", "Steyr Scout" } }, + { Weapon::AWP, AliasInfo { "awp", "AI Arctic Warfare/Magnum" } }, + { Weapon::G3SG1, AliasInfo { "g3sg1", "HK G3/SG-1 Sniper Rifle" } }, + { Weapon::SG550, AliasInfo { "sg550", "Sig SG-550 Sniper" } }, + { Weapon::M249, AliasInfo { "m249", "FN M249 Para" } }, + { Weapon::Flashbang, AliasInfo { "flash", "Concussion Grenade" } }, + { Weapon::Explosive, AliasInfo { "hegren", "High-Explosive Grenade" } }, + { Weapon::Smoke, AliasInfo { "sgren", "Smoke Grenade" } }, + { Weapon::Armor, AliasInfo { "vest", "Kevlar Vest" } }, + { Weapon::ArmorHelm, AliasInfo { "vesthelm", "Kevlar Vest and Helmet" } }, + { Weapon::Defuser, AliasInfo { "defuser", "Defuser Kit" } }, + { Weapon::Shield, AliasInfo { "shield", "Tactical Shield" } }, + { Weapon::Knife, AliasInfo { "knife", "Knife" } } }; - m_clients.resize (kGameMaxPlayers + 1); } @@ -432,7 +431,7 @@ StringRef BotSupport::weaponIdToAlias (int32_t id) { StringRef none = "none"; if (m_weaponAliases.exists (id)) { - return m_weaponAliases[id]; + return m_weaponAliases[id].first; } return none; } @@ -515,3 +514,16 @@ float BotSupport::getWaveLength (StringRef filename) { return length / bps / channels / rate; } + +void BotSupport::setCustomCvarDescriptions () { + // set the cvars custom descriptions here if needed + + String restrictInfo = "Specifies semicolon separated list of weapons that are not allowed to buy / pickup.\n"; + restrictInfo += "The list of weapons for Counter-Strike 1.6:\n"; + + // fill the restrict information + m_weaponAliases.foreach ([&] (const int32_t &, const AliasInfo &alias) { + restrictInfo.appendf ("%s - %s\n", alias.first, alias.second); + }); + game.setCvarDescription (cv_restricted_weapons, restrictInfo); +}