Minor changes.

This commit is contained in:
Dmitry 2019-07-28 23:21:24 +03:00 committed by jeefo
commit 54da53c5eb
5 changed files with 17 additions and 11 deletions

View file

@ -85,14 +85,14 @@ public:
template <typename ...Args> size_t puts (const char *fmt, Args ...args) {
if (!*this) {
return false;
return 0;
}
return fprintf (m_handle, fmt, cr::forward <Args> (args)...);
}
bool puts (const String &buffer) {
if (!*this) {
return false;
return 0;
}
if (fputs (buffer.chars (), m_handle) < 0) {
return false;

View file

@ -57,11 +57,9 @@ CR_NAMESPACE_END
#if defined(CR_WINDOWS)
# include <direct.h>
# define stricmp _stricmp
#else
# include <unistd.h>
# include <sys/stat.h>
# define stricmp strcasecmp
#endif
#include <assert.h>
@ -147,6 +145,14 @@ struct Platform : public Singleton <Platform> {
#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 {
fprintf (stderr, "%s\n", msg);

View file

@ -1653,7 +1653,7 @@ void BotControl::showMenu (int id) {
for (auto &display : m_menus) {
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;
while (strlen (text) >= 64) {

View file

@ -1310,7 +1310,7 @@ bool BotGraph::convertOldFormat () {
if (header.fileVersion != StorageVersion::Podbot) {
return false;
}
else if (!!stricmp (header.mapName, map)) {
else if (!plat.caseStrMatch (header.mapName, map)) {
return false;
}
else {

View file

@ -363,10 +363,10 @@ void BotManager::maintainQuota () {
int desiredBotCount = yb_quota.int_ ();
int botsInGame = getBotCount ();
if (stricmp (yb_quota_mode.str (), "fill") == 0) {
if (plat.caseStrMatch (yb_quota_mode.str (), "fill")) {
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_ ();
desiredBotCount = cr::max <int> (0, detectQuotaMatch * humanPlayersInGame);
@ -1269,7 +1269,7 @@ void BotManager::captureChatRadio (const char *cmd, const char *arg, edict_t *en
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) {
Bot *bot = nullptr;
@ -1605,7 +1605,7 @@ void BotConfig::loadMainConfig () {
if (cvar != nullptr) {
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);
// ensure cvar will have old value