mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-17 21:42:49 +00:00
Move guest profile checks into dedicated method
This commit is contained in:
parent
baedcc6ade
commit
936da9870c
4 changed files with 11 additions and 7 deletions
|
|
@ -844,10 +844,7 @@ static boolean CL_SendJoin(void)
|
|||
uint8_t signature[64];
|
||||
profile_t *localProfile = PR_GetLocalPlayerProfile(i);
|
||||
|
||||
char allZero[32];
|
||||
memset(allZero, 0, 32);
|
||||
|
||||
if (cv_lastprofile[i].value == 0) // GUESTS don't have keys
|
||||
if (PR_IsLocalPlayerGuest(i)) // GUESTS don't have keys
|
||||
{
|
||||
memset(signature, 0, 64);
|
||||
}
|
||||
|
|
@ -4203,11 +4200,11 @@ static void HandleConnect(SINT8 node)
|
|||
if (node == 0) // Server
|
||||
{
|
||||
memcpy(lastReceivedKey[node][i], PR_GetLocalPlayerProfile(i)->public_key, sizeof(lastReceivedKey[node][i]));
|
||||
CONS_Printf("We're SERVER! Setting lastReceivedKey on node %d to %s\n", node, GetPrettyRRID(lastReceivedKey[node][i], true));
|
||||
CONS_Printf("Adding SERVER. Setting lastReceivedKey on node %d to %s\n", node, GetPrettyRRID(lastReceivedKey[node][i], true));
|
||||
}
|
||||
else
|
||||
{
|
||||
CONS_Printf("We're a client. Doing sigcheck for node %d, ID %s\n", node, GetPrettyRRID(lastReceivedKey[node][i], true));
|
||||
CONS_Printf("Adding clients. Doing sigcheck for node %d, ID %s\n", node, GetPrettyRRID(lastReceivedKey[node][i], true));
|
||||
if (memcmp(lastReceivedKey[node], allZero, 32)) // We're a GUEST and the server throws out our keys anyway.
|
||||
{
|
||||
sigcheck = 0; // Always succeeds. Yes, this is a success response. C R Y P T O
|
||||
|
|
|
|||
|
|
@ -1033,7 +1033,7 @@ boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlen
|
|||
{
|
||||
const void* message = &netbuffer->u;
|
||||
//CONS_Printf("Signing packet type %d of length %d\n", netbuffer->packettype, packetlength);
|
||||
if (cv_lastprofile[i].value == 0)
|
||||
if (PR_IsLocalPlayerGuest(i))
|
||||
memset(netbuffer->signature[i], 0, sizeof(netbuffer->signature[i]));
|
||||
else
|
||||
crypto_eddsa_sign(netbuffer->signature[i], PR_GetLocalPlayerProfile(i)->secret_key, message, packetlength);
|
||||
|
|
|
|||
|
|
@ -577,6 +577,11 @@ profile_t *PR_GetLocalPlayerProfile(INT32 player)
|
|||
return PR_GetProfile(cv_lastprofile[player].value);
|
||||
}
|
||||
|
||||
boolean PR_IsLocalPlayerGuest(INT32 player)
|
||||
{
|
||||
return !(cv_lastprofile[player].value);
|
||||
}
|
||||
|
||||
char *GetPrettyRRID(const unsigned char *bin, boolean brief)
|
||||
{
|
||||
char *out;
|
||||
|
|
|
|||
|
|
@ -161,6 +161,8 @@ profile_t *PR_GetPlayerProfile(player_t *player);
|
|||
|
||||
profile_t *PR_GetLocalPlayerProfile(INT32 player);
|
||||
|
||||
boolean PR_IsLocalPlayerGuest(INT32 player);
|
||||
|
||||
char *GetPrettyRRID(const unsigned char *bin, boolean brief);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue