Minor changes.
This commit is contained in:
parent
d9d3d435ec
commit
54da53c5eb
5 changed files with 17 additions and 11 deletions
|
|
@ -85,14 +85,14 @@ public:
|
||||||
|
|
||||||
template <typename ...Args> size_t puts (const char *fmt, Args ...args) {
|
template <typename ...Args> size_t puts (const char *fmt, Args ...args) {
|
||||||
if (!*this) {
|
if (!*this) {
|
||||||
return false;
|
return 0;
|
||||||
}
|
}
|
||||||
return fprintf (m_handle, fmt, cr::forward <Args> (args)...);
|
return fprintf (m_handle, fmt, cr::forward <Args> (args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool puts (const String &buffer) {
|
bool puts (const String &buffer) {
|
||||||
if (!*this) {
|
if (!*this) {
|
||||||
return false;
|
return 0;
|
||||||
}
|
}
|
||||||
if (fputs (buffer.chars (), m_handle) < 0) {
|
if (fputs (buffer.chars (), m_handle) < 0) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -57,11 +57,9 @@ CR_NAMESPACE_END
|
||||||
|
|
||||||
#if defined(CR_WINDOWS)
|
#if defined(CR_WINDOWS)
|
||||||
# include <direct.h>
|
# include <direct.h>
|
||||||
# define stricmp _stricmp
|
|
||||||
#else
|
#else
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
# include <sys/stat.h>
|
# include <sys/stat.h>
|
||||||
# define stricmp strcasecmp
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
@ -147,6 +145,14 @@ struct Platform : public Singleton <Platform> {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool caseStrMatch (const char *str1, const char *str2) {
|
||||||
|
#if defined(CR_WINDOWS)
|
||||||
|
return _stricmp (str1, str2) == 0;
|
||||||
|
#else
|
||||||
|
return strcasecmp (str1, str2) == 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void abort (const char *msg = "OUT OF MEMORY!") noexcept {
|
void abort (const char *msg = "OUT OF MEMORY!") noexcept {
|
||||||
fprintf (stderr, "%s\n", msg);
|
fprintf (stderr, "%s\n", msg);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1653,7 +1653,7 @@ void BotControl::showMenu (int id) {
|
||||||
|
|
||||||
for (auto &display : m_menus) {
|
for (auto &display : m_menus) {
|
||||||
if (display.ident == id) {
|
if (display.ident == id) {
|
||||||
const char *text = (game.is (GameFlags::Xash3D | GameFlags::Mobility) && !yb_display_menu_text.bool_ ()) ? " " : display.text.chars ();
|
auto text = (game.is (GameFlags::Xash3D | GameFlags::Mobility) && !yb_display_menu_text.bool_ ()) ? " " : display.text.chars ();
|
||||||
MessageWriter msg;
|
MessageWriter msg;
|
||||||
|
|
||||||
while (strlen (text) >= 64) {
|
while (strlen (text) >= 64) {
|
||||||
|
|
|
||||||
|
|
@ -1310,7 +1310,7 @@ bool BotGraph::convertOldFormat () {
|
||||||
if (header.fileVersion != StorageVersion::Podbot) {
|
if (header.fileVersion != StorageVersion::Podbot) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (!!stricmp (header.mapName, map)) {
|
else if (!plat.caseStrMatch (header.mapName, map)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -363,10 +363,10 @@ void BotManager::maintainQuota () {
|
||||||
int desiredBotCount = yb_quota.int_ ();
|
int desiredBotCount = yb_quota.int_ ();
|
||||||
int botsInGame = getBotCount ();
|
int botsInGame = getBotCount ();
|
||||||
|
|
||||||
if (stricmp (yb_quota_mode.str (), "fill") == 0) {
|
if (plat.caseStrMatch (yb_quota_mode.str (), "fill")) {
|
||||||
botsInGame += humanPlayersInGame;
|
botsInGame += humanPlayersInGame;
|
||||||
}
|
}
|
||||||
else if (stricmp (yb_quota_mode.str (), "match") == 0) {
|
else if (plat.caseStrMatch (yb_quota_mode.str (), "match")) {
|
||||||
int detectQuotaMatch = yb_quota_match.int_ () == 0 ? yb_quota.int_ () : yb_quota_match.int_ ();
|
int detectQuotaMatch = yb_quota_match.int_ () == 0 ? yb_quota.int_ () : yb_quota_match.int_ ();
|
||||||
|
|
||||||
desiredBotCount = cr::max <int> (0, detectQuotaMatch * humanPlayersInGame);
|
desiredBotCount = cr::max <int> (0, detectQuotaMatch * humanPlayersInGame);
|
||||||
|
|
@ -1269,7 +1269,7 @@ void BotManager::captureChatRadio (const char *cmd, const char *arg, edict_t *en
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stricmp (cmd, "say") == 0 || stricmp (cmd, "say_team") == 0) {
|
if (plat.caseStrMatch (cmd, "say") || plat.caseStrMatch (cmd, "say_team")) {
|
||||||
if (strcmp (arg, "dropme") == 0 || strcmp (arg, "dropc4") == 0) {
|
if (strcmp (arg, "dropme") == 0 || strcmp (arg, "dropc4") == 0) {
|
||||||
Bot *bot = nullptr;
|
Bot *bot = nullptr;
|
||||||
|
|
||||||
|
|
@ -1605,7 +1605,7 @@ void BotConfig::loadMainConfig () {
|
||||||
if (cvar != nullptr) {
|
if (cvar != nullptr) {
|
||||||
auto value = const_cast <char *> (keyval[1].trim ().trim ("\"").trim ().chars ());
|
auto value = const_cast <char *> (keyval[1].trim ().trim ("\"").trim ().chars ());
|
||||||
|
|
||||||
if (needsToIgnoreVar (ignore, key) && !!stricmp (value, cvar->string)) {
|
if (needsToIgnoreVar (ignore, key) && !plat.caseStrMatch (value, cvar->string)) {
|
||||||
game.print ("Bot CVAR '%s' differs from the stored in the config (%s/%s). Ignoring.", cvar->name, cvar->string, value);
|
game.print ("Bot CVAR '%s' differs from the stored in the config (%s/%s). Ignoring.", cvar->name, cvar->string, value);
|
||||||
|
|
||||||
// ensure cvar will have old value
|
// ensure cvar will have old value
|
||||||
|
|
@ -2112,7 +2112,7 @@ void BotConfig::initWeapons () {
|
||||||
// fill array with available weapons
|
// fill array with available weapons
|
||||||
m_weapons.emplace (Weapon::Knife, "weapon_knife", "knife.mdl", 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, true );
|
m_weapons.emplace (Weapon::Knife, "weapon_knife", "knife.mdl", 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, true );
|
||||||
m_weapons.emplace (Weapon::USP, "weapon_usp", "usp.mdl", 500, 1, -1, -1, 1, 1, 2, 2, 0, 12, false );
|
m_weapons.emplace (Weapon::USP, "weapon_usp", "usp.mdl", 500, 1, -1, -1, 1, 1, 2, 2, 0, 12, false );
|
||||||
m_weapons.emplace (Weapon::Glock18, "weapon_glock18", "glock18.mdl", 400, 1, -1, -1, 1, 2, 1, 1, 0, 20, false );
|
m_weapons.emplace (Weapon::Glock18, "weapon_glock18", "glock18.mdl", 400, 1, -1, -1, 1, 2, 1, 1, 0, 20, false );
|
||||||
m_weapons.emplace (Weapon::Deagle, "weapon_deagle", "deagle.mdl", 650, 1, 2, 2, 1, 3, 4, 4, 2, 7, false );
|
m_weapons.emplace (Weapon::Deagle, "weapon_deagle", "deagle.mdl", 650, 1, 2, 2, 1, 3, 4, 4, 2, 7, false );
|
||||||
m_weapons.emplace (Weapon::P228, "weapon_p228", "p228.mdl", 600, 1, 2, 2, 1, 4, 3, 3, 0, 13, false );
|
m_weapons.emplace (Weapon::P228, "weapon_p228", "p228.mdl", 600, 1, 2, 2, 1, 4, 3, 3, 0, 13, false );
|
||||||
m_weapons.emplace (Weapon::Elite, "weapon_elite", "elite.mdl", 800, 1, 0, 0, 1, 5, 5, 5, 0, 30, false );
|
m_weapons.emplace (Weapon::Elite, "weapon_elite", "elite.mdl", 800, 1, 0, 0, 1, 5, 5, 5, 0, 30, false );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue