mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-07 08:52:01 +00:00
Merge branch 'name-stuck' into 'master'
Fix game hanging on server creation/splitscreen if your name is whack See merge request STJr/SRB2!752
This commit is contained in:
commit
700d9426d4
3 changed files with 20 additions and 2 deletions
|
@ -1275,8 +1275,14 @@ static boolean CL_SendJoin(void)
|
||||||
netbuffer->u.clientcfg.localplayers = localplayers;
|
netbuffer->u.clientcfg.localplayers = localplayers;
|
||||||
netbuffer->u.clientcfg.version = VERSION;
|
netbuffer->u.clientcfg.version = VERSION;
|
||||||
netbuffer->u.clientcfg.subversion = SUBVERSION;
|
netbuffer->u.clientcfg.subversion = SUBVERSION;
|
||||||
|
|
||||||
|
CleanupPlayerName(consoleplayer, cv_playername.zstring);
|
||||||
|
if (splitscreen)
|
||||||
|
CleanupPlayerName(1, cv_playername2.zstring);/* 1 is a HACK? oh no */
|
||||||
|
|
||||||
strncpy(netbuffer->u.clientcfg.names[0], cv_playername.zstring, MAXPLAYERNAME);
|
strncpy(netbuffer->u.clientcfg.names[0], cv_playername.zstring, MAXPLAYERNAME);
|
||||||
strncpy(netbuffer->u.clientcfg.names[1], cv_playername2.zstring, MAXPLAYERNAME);
|
strncpy(netbuffer->u.clientcfg.names[1], cv_playername2.zstring, MAXPLAYERNAME);
|
||||||
|
|
||||||
return HSendPacket(servernode, true, 0, sizeof (clientconfig_pak));
|
return HSendPacket(servernode, true, 0, sizeof (clientconfig_pak));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -624,7 +624,7 @@ void D_RegisterClientCommands(void)
|
||||||
// Set default player names
|
// Set default player names
|
||||||
// Monster Iestyn (12/08/19): not sure where else I could have actually put this, but oh well
|
// Monster Iestyn (12/08/19): not sure where else I could have actually put this, but oh well
|
||||||
for (i = 0; i < MAXPLAYERS; i++)
|
for (i = 0; i < MAXPLAYERS; i++)
|
||||||
sprintf(player_names[i], "Player %d", i);
|
sprintf(player_names[i], "Player %d", 1 + i);
|
||||||
|
|
||||||
if (dedicated)
|
if (dedicated)
|
||||||
return;
|
return;
|
||||||
|
@ -982,7 +982,7 @@ boolean EnsurePlayerNameIsGood(char *name, INT32 playernum)
|
||||||
* SetPlayerName
|
* SetPlayerName
|
||||||
* \author Graue <graue@oceanbase.org>
|
* \author Graue <graue@oceanbase.org>
|
||||||
*/
|
*/
|
||||||
static void CleanupPlayerName(INT32 playernum, const char *newname)
|
void CleanupPlayerName(INT32 playernum, const char *newname)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
char *p;
|
char *p;
|
||||||
|
@ -1010,6 +1010,17 @@ static void CleanupPlayerName(INT32 playernum, const char *newname)
|
||||||
|
|
||||||
tmpname = p;
|
tmpname = p;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
/* from EnsurePlayerNameIsGood */
|
||||||
|
if (!isprint(*p) || *p == ';' || (UINT8)*p >= 0x80)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
while (*++p) ;
|
||||||
|
|
||||||
|
if (*p)/* bad char found */
|
||||||
|
break;
|
||||||
|
|
||||||
// Remove trailing spaces.
|
// Remove trailing spaces.
|
||||||
p = &tmpname[strlen(tmpname)-1]; // last character
|
p = &tmpname[strlen(tmpname)-1]; // last character
|
||||||
while (*p == ' ' && p >= tmpname)
|
while (*p == ' ' && p >= tmpname)
|
||||||
|
|
|
@ -194,6 +194,7 @@ typedef union {
|
||||||
// add game commands, needs cleanup
|
// add game commands, needs cleanup
|
||||||
void D_RegisterServerCommands(void);
|
void D_RegisterServerCommands(void);
|
||||||
void D_RegisterClientCommands(void);
|
void D_RegisterClientCommands(void);
|
||||||
|
void CleanupPlayerName(INT32 playernum, const char *newname);
|
||||||
boolean EnsurePlayerNameIsGood(char *name, INT32 playernum);
|
boolean EnsurePlayerNameIsGood(char *name, INT32 playernum);
|
||||||
void D_SendPlayerConfig(void);
|
void D_SendPlayerConfig(void);
|
||||||
void Command_ExitGame_f(void);
|
void Command_ExitGame_f(void);
|
||||||
|
|
Loading…
Reference in a new issue