Skip to content

Commit

Permalink
SV_New_f: Deny new connection twice at a time if user messages are re…
Browse files Browse the repository at this point in the history
…ceived

SV_ReadClientMessage: Fix empty names on bad read
  • Loading branch information
s1lentq committed Jun 15, 2021
1 parent f3d6024 commit 3a9bfb9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion rehlds/engine/sv_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ void SV_New_f(void)
return;
}

if (!host_client->active && host_client->spawned)
if ((host_client->hasusrmsgs && host_client->m_bSentNewResponse) || (!host_client->active && host_client->spawned))
{
return;
}
Expand Down Expand Up @@ -1564,6 +1564,7 @@ void SV_New_f(void)
}
Netchan_CreateFragments(TRUE, &host_client->netchan, &msg);
Netchan_FragSend(&host_client->netchan);
host_client->m_bSentNewResponse = TRUE;
}

void SV_SendRes_f(void)
Expand Down Expand Up @@ -7371,6 +7372,8 @@ void SV_InactivateClients(void)
cl->connected = TRUE;
cl->spawned = FALSE;
cl->fully_connected = FALSE;
cl->hasusrmsgs = FALSE;
cl->m_bSentNewResponse = FALSE;

SZ_Clear(&cl->netchan.message);
SZ_Clear(&cl->datagram);
Expand Down
8 changes: 7 additions & 1 deletion rehlds/engine/sv_user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1779,14 +1779,20 @@ void EXT_FUNC SV_HandleClientMessage_api(IGameClient* client, uint8 opcode) {
return;
}

#ifdef REHLDS_FIXES
// Save current name of the client before a possible kick
char name[32];
Q_strlcpy(name, host_client->name);
#endif

void(*func)(client_t *) = sv_clcfuncs[opcode].pfnParse;
if (func)
func(cl);

#ifdef REHLDS_FIXES
if (msg_badread)
{
Con_Printf("SV_ReadClientMessage: badread on %s, opcode %s\n", host_client->name, sv_clcfuncs[opcode].pszname);
Con_Printf("SV_ReadClientMessage: badread on %s, opcode %s\n", name, sv_clcfuncs[opcode].pszname);
}
#endif

Expand Down

0 comments on commit 3a9bfb9

Please sign in to comment.