diff --git a/include/core.h b/include/core.h index 02c7688..28e4a98 100644 --- a/include/core.h +++ b/include/core.h @@ -641,6 +641,7 @@ struct WavHeader // botname structure definition struct BotName { + String steamId; String name; bool used; }; @@ -1204,7 +1205,7 @@ public: Array m_tasks; - Bot (edict_t *bot, int difficulty, int personality, int team, int member); + Bot (edict_t *bot, int difficulty, int personality, int team, int member, const String &steamId); ~Bot (void); int GetAmmo (void); diff --git a/include/corelib.h b/include/corelib.h index 16bf58c..9719988 100644 --- a/include/corelib.h +++ b/include/corelib.h @@ -2694,7 +2694,7 @@ public: // Returns: // True if string is empty, false otherwise. // - bool IsEmpty (void) + bool IsEmpty (void) const { if (m_bufferPtr == NULL || m_stringLength == 0) return true; diff --git a/source/interface.cpp b/source/interface.cpp index 0936148..8f3f407 100644 --- a/source/interface.cpp +++ b/source/interface.cpp @@ -485,6 +485,11 @@ void InitConfig (void) { SKIP_COMMENTS (); + Array pair = String (line).Split ("\t\t"); + + if (pair.GetElementNumber () > 1) + strcpy (line, pair[0].Trim ().GetBuffer ()); + strtrim (line); line[32] = 0; @@ -494,6 +499,9 @@ void InitConfig (void) item.name = line; item.used = false; + if (pair.GetElementNumber () > 1) + item.steamId = pair[1].Trim (); + g_botNames.Push (item); } fp.Close (); diff --git a/source/manager.cpp b/source/manager.cpp index 4c6f151..5048135 100644 --- a/source/manager.cpp +++ b/source/manager.cpp @@ -21,7 +21,8 @@ ConVar yb_join_team ("yb_join_team", "any"); ConVar yb_name_prefix ("yb_name_prefix", "", VT_NOSERVER); ConVar yb_difficulty ("yb_difficulty", "4"); -ConVar yb_latency_display ("yb_latency_display", "2"); +ConVar yb_latency_display ("yb_latency_display", "2", VT_NOSERVER); +ConVar yb_avatar_display ("yb_avatar_display", "1", VT_NOSERVER); BotManager::BotManager (void) { @@ -106,6 +107,8 @@ int BotManager::CreateBot (String name, int difficulty, int personality, int tea } } + String steamId = ""; + // setup name if (name.IsEmpty ()) { @@ -128,6 +131,8 @@ int BotManager::CreateBot (String name, int difficulty, int personality, int tea pickedName->used = nameFound = true; strcpy (outputName, pickedName->name); + + steamId = pickedName->steamId; } } else @@ -159,7 +164,7 @@ int BotManager::CreateBot (String name, int difficulty, int personality, int tea InternalAssert (index >= 0 && index <= 32); // check index InternalAssert (m_bots[index] == NULL); // check bot slot - m_bots[index] = new Bot (bot, difficulty, personality, team, member); + m_bots[index] = new Bot (bot, difficulty, personality, team, member, steamId); if (m_bots == NULL) TerminateOnMalloc (); @@ -725,7 +730,7 @@ void BotManager::Free (int index) m_bots[index] = NULL; } -Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member) +Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member, const String &steamId) { // this function does core operation of creating bot, it's called by CreateBot (), // when bot setup completed, (this is a bot class constructor) @@ -747,11 +752,17 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member) BotManager::CallGameEntity (&bot->v); // set all info buffer keys for this bot - char *buffer = GET_INFOKEYBUFFER (bot);; + char *buffer = GET_INFOKEYBUFFER (bot); SET_CLIENT_KEYVALUE (clientIndex, buffer, "_vgui_menus", "0"); - if (g_gameVersion != CSV_OLD && yb_latency_display.GetInt () == 1) - SET_CLIENT_KEYVALUE (clientIndex, buffer, "*bot", "1"); + if (g_gameVersion != CSV_OLD) + { + if (yb_latency_display.GetInt () == 1) + SET_CLIENT_KEYVALUE (clientIndex, buffer, "*bot", "1"); + + if (yb_avatar_display.GetBool () && !steamId.IsEmpty ()) + SET_CLIENT_KEYVALUE (clientIndex, buffer, "*sid", const_cast (steamId.GetBuffer ())); + } rejectReason[0] = 0; // reset the reject reason template string MDLL_ClientConnect (bot, "BOT", FormatBuffer ("127.0.0.%d", IndexOfEntity (bot) + 100), rejectReason);