mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
WIP: Social restrictions until you've played some games
This commit is contained in:
parent
5085bdfdd8
commit
5b4725a011
5 changed files with 58 additions and 13 deletions
|
|
@ -2984,6 +2984,8 @@ static void Command_Nodes(void)
|
|||
CONS_Printf(" [%.4d PWR]", clientpowerlevels[i][K_UsingPowerLevels()]);
|
||||
}
|
||||
|
||||
CONS_Printf(" [%d games]", SV_GetStatsByPlayerIndex(i)->finishedrounds);
|
||||
|
||||
|
||||
CONS_Printf(" [RRID-%s]", GetPrettyRRID(players[i].public_key, true));
|
||||
|
||||
|
|
@ -4195,10 +4197,10 @@ boolean SV_SpawnServer(void)
|
|||
SINT8 node = 0;
|
||||
for (; node < MAXNETNODES; node++)
|
||||
result |= SV_AddWaitingPlayers(node, availabilitiesbuffer,
|
||||
cv_playername[0].zstring, PR_GetLocalPlayerProfile(0)->public_key, SV_RetrieveStats(PR_GetLocalPlayerProfile(0)->public_key)->powerlevels,
|
||||
cv_playername[1].zstring, PR_GetLocalPlayerProfile(1)->public_key, SV_RetrieveStats(PR_GetLocalPlayerProfile(1)->public_key)->powerlevels,
|
||||
cv_playername[2].zstring, PR_GetLocalPlayerProfile(2)->public_key, SV_RetrieveStats(PR_GetLocalPlayerProfile(2)->public_key)->powerlevels,
|
||||
cv_playername[3].zstring, PR_GetLocalPlayerProfile(3)->public_key, SV_RetrieveStats(PR_GetLocalPlayerProfile(3)->public_key)->powerlevels);
|
||||
cv_playername[0].zstring, PR_GetLocalPlayerProfile(0)->public_key, SV_GetStatsByKey(PR_GetLocalPlayerProfile(0)->public_key)->powerlevels,
|
||||
cv_playername[1].zstring, PR_GetLocalPlayerProfile(1)->public_key, SV_GetStatsByKey(PR_GetLocalPlayerProfile(1)->public_key)->powerlevels,
|
||||
cv_playername[2].zstring, PR_GetLocalPlayerProfile(2)->public_key, SV_GetStatsByKey(PR_GetLocalPlayerProfile(2)->public_key)->powerlevels,
|
||||
cv_playername[3].zstring, PR_GetLocalPlayerProfile(3)->public_key, SV_GetStatsByKey(PR_GetLocalPlayerProfile(3)->public_key)->powerlevels);
|
||||
}
|
||||
return result;
|
||||
#endif
|
||||
|
|
@ -4517,10 +4519,10 @@ static void HandleConnect(SINT8 node)
|
|||
}
|
||||
|
||||
SV_AddWaitingPlayers(node, availabilitiesbuffer,
|
||||
names[0], lastReceivedKey[node][0], SV_RetrieveStats(lastReceivedKey[node][0])->powerlevels,
|
||||
names[1], lastReceivedKey[node][1], SV_RetrieveStats(lastReceivedKey[node][1])->powerlevels,
|
||||
names[2], lastReceivedKey[node][2], SV_RetrieveStats(lastReceivedKey[node][2])->powerlevels,
|
||||
names[3], lastReceivedKey[node][3], SV_RetrieveStats(lastReceivedKey[node][3])->powerlevels);
|
||||
names[0], lastReceivedKey[node][0], SV_GetStatsByKey(lastReceivedKey[node][0])->powerlevels,
|
||||
names[1], lastReceivedKey[node][1], SV_GetStatsByKey(lastReceivedKey[node][1])->powerlevels,
|
||||
names[2], lastReceivedKey[node][2], SV_GetStatsByKey(lastReceivedKey[node][2])->powerlevels,
|
||||
names[3], lastReceivedKey[node][3], SV_GetStatsByKey(lastReceivedKey[node][3])->powerlevels);
|
||||
joindelay += cv_joindelay.value * TICRATE;
|
||||
player_joining = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -430,8 +430,6 @@ void K_CashInPowerLevels(void)
|
|||
|
||||
//CONS_Printf("%s: %d -> %d (%d)\n", player_names[i], clientpowerlevels[i][powerType] - inc, clientpowerlevels[i][powerType], inc);
|
||||
}
|
||||
|
||||
clientPowerAdd[i] = 0;
|
||||
}
|
||||
|
||||
SV_UpdateStats();
|
||||
|
|
|
|||
|
|
@ -112,6 +112,13 @@ void SV_LoadStats(void)
|
|||
{
|
||||
trackedList[i].powerlevels[j] = READUINT16(save.p);
|
||||
}
|
||||
|
||||
// Migration 1 -> 2: Add finishedrounds
|
||||
if (version < 2)
|
||||
trackedList[i].finishedrounds = 0;
|
||||
else
|
||||
trackedList[i].finishedrounds = READUINT32(save.p);
|
||||
|
||||
trackedList[i].hash = quickncasehash((char*)trackedList[i].public_key, PUBKEYLENGTH);
|
||||
}
|
||||
}
|
||||
|
|
@ -149,6 +156,7 @@ void SV_SaveStats(void)
|
|||
{
|
||||
WRITEUINT16(save.p, trackedList[i].powerlevels[j]);
|
||||
}
|
||||
WRITEUINT32(save.p, trackedList[i].finishedrounds);
|
||||
}
|
||||
|
||||
length = save.p - save.buffer;
|
||||
|
|
@ -162,7 +170,7 @@ void SV_SaveStats(void)
|
|||
}
|
||||
|
||||
// New player, grab their stats from trackedList or initialize new ones if they're new
|
||||
serverplayer_t *SV_RetrieveStats(uint8_t *key)
|
||||
serverplayer_t *SV_GetStatsByKey(uint8_t *key)
|
||||
{
|
||||
UINT32 j, hash;
|
||||
|
||||
|
|
@ -189,6 +197,7 @@ serverplayer_t *SV_RetrieveStats(uint8_t *key)
|
|||
{
|
||||
trackedList[numtracked].powerlevels[j] = PR_IsKeyGuest(key) ? 0 : PWRLVRECORD_START;
|
||||
}
|
||||
trackedList[numtracked].finishedrounds = 0;
|
||||
trackedList[numtracked].hash = quickncasehash((char*)key, PUBKEYLENGTH);
|
||||
|
||||
numtracked++;
|
||||
|
|
@ -196,7 +205,18 @@ serverplayer_t *SV_RetrieveStats(uint8_t *key)
|
|||
return &trackedList[numtracked - 1];
|
||||
}
|
||||
|
||||
serverplayer_t *SV_GetStatsByPlayerIndex(UINT8 p)
|
||||
{
|
||||
return SV_GetStatsByKey(players[p].public_key);
|
||||
}
|
||||
|
||||
serverplayer_t *SV_GetStats(player_t *player)
|
||||
{
|
||||
return SV_GetStatsByKey(player->public_key);
|
||||
}
|
||||
|
||||
// Write player stats to trackedList, then save to disk
|
||||
// (NB: Some stats changes are made directly to trackedList via K_CashInPowerLevels)
|
||||
void SV_UpdateStats(void)
|
||||
{
|
||||
UINT32 i, j, hash;
|
||||
|
|
@ -234,3 +254,21 @@ void SV_UpdateStats(void)
|
|||
|
||||
SV_SaveStats();
|
||||
}
|
||||
|
||||
void SV_BumpMatchStats(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
if (!playeringame[i])
|
||||
continue;
|
||||
if (players[i].spectator)
|
||||
continue;
|
||||
|
||||
serverplayer_t *stat = SV_GetStatsByPlayerIndex(i);
|
||||
|
||||
if (!(players[i].pflags & PF_NOCONTEST))
|
||||
stat->finishedrounds++;
|
||||
}
|
||||
}
|
||||
|
|
@ -27,13 +27,14 @@ extern "C" {
|
|||
|
||||
#define SERVERSTATSFILE "srvstats.dat"
|
||||
#define SERVERSTATSHEADER "Doctor Robotnik's Ring Racers Server Stats"
|
||||
#define SERVERSTATSVER 1
|
||||
#define SERVERSTATSVER 2
|
||||
|
||||
struct serverplayer_t
|
||||
{
|
||||
uint8_t public_key[PUBKEYLENGTH];
|
||||
UINT32 lastseen;
|
||||
UINT16 powerlevels[PWRLV_NUMTYPES];
|
||||
UINT32 finishedrounds;
|
||||
|
||||
UINT32 hash; // Not persisted! Used for early outs during key comparisons
|
||||
};
|
||||
|
|
@ -42,10 +43,14 @@ void SV_SaveStats(void);
|
|||
|
||||
void SV_LoadStats(void);
|
||||
|
||||
serverplayer_t *SV_RetrieveStats(uint8_t *key);
|
||||
serverplayer_t *SV_GetStatsByKey(uint8_t *key);
|
||||
serverplayer_t *SV_GetStatsByPlayerIndex(UINT8 p);
|
||||
serverplayer_t *SV_GetStats(player_t *player);
|
||||
|
||||
void SV_UpdateStats(void);
|
||||
|
||||
void SV_BumpMatchStats(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@
|
|||
#include "k_boss.h"
|
||||
#include "k_pwrlv.h"
|
||||
#include "k_grandprix.h"
|
||||
#include "k_serverstats.h" // SV_BumpMatchStats
|
||||
|
||||
#ifdef HWRENDER
|
||||
#include "hardware/hw_main.h"
|
||||
|
|
@ -847,6 +848,7 @@ void Y_StartIntermission(void)
|
|||
}
|
||||
|
||||
K_CashInPowerLevels();
|
||||
SV_BumpMatchStats();
|
||||
}
|
||||
|
||||
Automate_Run(AEV_INTERMISSIONSTART);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue