added support for bot avatars in scoreboard in cs 1.6

This commit is contained in:
jeefo 2015-06-20 13:38:13 +03:00
commit ac8bf86c18
4 changed files with 28 additions and 8 deletions

View file

@ -641,6 +641,7 @@ struct WavHeader
// botname structure definition // botname structure definition
struct BotName struct BotName
{ {
String steamId;
String name; String name;
bool used; bool used;
}; };
@ -1204,7 +1205,7 @@ public:
Array <TaskItem> m_tasks; Array <TaskItem> 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); ~Bot (void);
int GetAmmo (void); int GetAmmo (void);

View file

@ -2694,7 +2694,7 @@ public:
// Returns: // Returns:
// True if string is empty, false otherwise. // True if string is empty, false otherwise.
// //
bool IsEmpty (void) bool IsEmpty (void) const
{ {
if (m_bufferPtr == NULL || m_stringLength == 0) if (m_bufferPtr == NULL || m_stringLength == 0)
return true; return true;

View file

@ -485,6 +485,11 @@ void InitConfig (void)
{ {
SKIP_COMMENTS (); SKIP_COMMENTS ();
Array <String> pair = String (line).Split ("\t\t");
if (pair.GetElementNumber () > 1)
strcpy (line, pair[0].Trim ().GetBuffer ());
strtrim (line); strtrim (line);
line[32] = 0; line[32] = 0;
@ -494,6 +499,9 @@ void InitConfig (void)
item.name = line; item.name = line;
item.used = false; item.used = false;
if (pair.GetElementNumber () > 1)
item.steamId = pair[1].Trim ();
g_botNames.Push (item); g_botNames.Push (item);
} }
fp.Close (); fp.Close ();

View file

@ -21,7 +21,8 @@ ConVar yb_join_team ("yb_join_team", "any");
ConVar yb_name_prefix ("yb_name_prefix", "", VT_NOSERVER); ConVar yb_name_prefix ("yb_name_prefix", "", VT_NOSERVER);
ConVar yb_difficulty ("yb_difficulty", "4"); 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) BotManager::BotManager (void)
{ {
@ -106,6 +107,8 @@ int BotManager::CreateBot (String name, int difficulty, int personality, int tea
} }
} }
String steamId = "";
// setup name // setup name
if (name.IsEmpty ()) if (name.IsEmpty ())
{ {
@ -128,6 +131,8 @@ int BotManager::CreateBot (String name, int difficulty, int personality, int tea
pickedName->used = nameFound = true; pickedName->used = nameFound = true;
strcpy (outputName, pickedName->name); strcpy (outputName, pickedName->name);
steamId = pickedName->steamId;
} }
} }
else else
@ -159,7 +164,7 @@ int BotManager::CreateBot (String name, int difficulty, int personality, int tea
InternalAssert (index >= 0 && index <= 32); // check index InternalAssert (index >= 0 && index <= 32); // check index
InternalAssert (m_bots[index] == NULL); // check bot slot 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) if (m_bots == NULL)
TerminateOnMalloc (); TerminateOnMalloc ();
@ -725,7 +730,7 @@ void BotManager::Free (int index)
m_bots[index] = NULL; 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 (), // this function does core operation of creating bot, it's called by CreateBot (),
// when bot setup completed, (this is a bot class constructor) // 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); BotManager::CallGameEntity (&bot->v);
// set all info buffer keys for this bot // 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"); SET_CLIENT_KEYVALUE (clientIndex, buffer, "_vgui_menus", "0");
if (g_gameVersion != CSV_OLD && yb_latency_display.GetInt () == 1) if (g_gameVersion != CSV_OLD)
SET_CLIENT_KEYVALUE (clientIndex, buffer, "*bot", "1"); {
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 <char *> (steamId.GetBuffer ()));
}
rejectReason[0] = 0; // reset the reject reason template string rejectReason[0] = 0; // reset the reject reason template string
MDLL_ClientConnect (bot, "BOT", FormatBuffer ("127.0.0.%d", IndexOfEntity (bot) + 100), rejectReason); MDLL_ClientConnect (bot, "BOT", FormatBuffer ("127.0.0.%d", IndexOfEntity (bot) + 100), rejectReason);