Skip to content

Commit

Permalink
cmod: Workaround to allow bots to join password protected servers
Browse files Browse the repository at this point in the history
  • Loading branch information
Chomenor committed May 9, 2021
1 parent 50c8ae6 commit a6942b5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions code/cmod/cmod_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@
// Has some potential for for CPU load spikes, but seems to be generally okay on most maps in testing
#define CMOD_BOT_RANDOM_GOALS

// [BUGFIX] Workaround to allow bots to join password-protected server
#define CMOD_BOT_PASSWORD_FIX

// [BUGFIX] Fixes for several issues that can interfere with the server being listed on
// master servers and/or server browser tools
#define CMOD_GETSTATUS_FIXES
Expand Down
13 changes: 13 additions & 0 deletions code/server/sv_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,19 @@ void SV_GetUserinfo( int index, char *buffer, int bufferSize ) {
Com_Error (ERR_DROP, "SV_GetUserinfo: bad index %i", index);
}
Q_strncpyz( buffer, svs.clients[ index ].userinfo, bufferSize );
#ifdef CMOD_BOT_PASSWORD_FIX
{
static cvar_t *passwordCvar;
if ( !passwordCvar ) {
passwordCvar = Cvar_Get( "g_password", "", 0 );
}
if ( passwordCvar && passwordCvar->string && passwordCvar->string[0] && Q_stricmp(passwordCvar->string, "none") &&
( svs.clients[index].netchan.remoteAddress.type == NA_BOT ||
svs.clients[index].netchan.remoteAddress.type == NA_LOOPBACK ) ) {
Info_SetValueForKey( buffer, "password", passwordCvar->string );
}
}
#endif
}


Expand Down

0 comments on commit a6942b5

Please sign in to comment.