mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-29 03:44:40 +00:00
remove player id from Schemas, fix archive bug (#907)
## Description: Remove all references to playerID in the archive schema, since we reference players by client id. Also fixed the game not archiving bug, due to invalid reference. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: <DISCORD USERNAME>
This commit is contained in:
@@ -201,7 +201,6 @@ export class ClientGameRunner {
|
|||||||
}
|
}
|
||||||
const players: PlayerRecord[] = [
|
const players: PlayerRecord[] = [
|
||||||
{
|
{
|
||||||
playerID: this.myPlayer.id(),
|
|
||||||
persistentID: getPersistentID(),
|
persistentID: getPersistentID(),
|
||||||
username: this.lobby.playerName,
|
username: this.lobby.playerName,
|
||||||
clientID: this.lobby.clientID,
|
clientID: this.lobby.clientID,
|
||||||
|
|||||||
@@ -176,7 +176,6 @@ export class LocalServer {
|
|||||||
}
|
}
|
||||||
const players: PlayerRecord[] = [
|
const players: PlayerRecord[] = [
|
||||||
{
|
{
|
||||||
playerID: this.lobbyConfig.clientID, // hack?
|
|
||||||
persistentID: getPersistentID(),
|
persistentID: getPersistentID(),
|
||||||
username: this.lobbyConfig.playerName,
|
username: this.lobbyConfig.playerName,
|
||||||
clientID: this.lobbyConfig.clientID,
|
clientID: this.lobbyConfig.clientID,
|
||||||
|
|||||||
@@ -435,7 +435,6 @@ export class SinglePlayerModal extends LitElement {
|
|||||||
gameID: gameID,
|
gameID: gameID,
|
||||||
players: [
|
players: [
|
||||||
{
|
{
|
||||||
playerID: generateID(),
|
|
||||||
clientID,
|
clientID,
|
||||||
username: usernameInput.getCurrentUsername(),
|
username: usernameInput.getCurrentUsername(),
|
||||||
flag:
|
flag:
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export async function createGameRunner(
|
|||||||
: fixProfaneUsername(sanitize(p.username)),
|
: fixProfaneUsername(sanitize(p.username)),
|
||||||
PlayerType.Human,
|
PlayerType.Human,
|
||||||
p.clientID,
|
p.clientID,
|
||||||
p.playerID,
|
random.nextID(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -338,7 +338,6 @@ export const ServerPrestartMessageSchema = ServerBaseMessageSchema.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const PlayerSchema = z.object({
|
export const PlayerSchema = z.object({
|
||||||
playerID: ID,
|
|
||||||
clientID: ID,
|
clientID: ID,
|
||||||
username: SafeString,
|
username: SafeString,
|
||||||
flag: SafeString.optional(),
|
flag: SafeString.optional(),
|
||||||
|
|||||||
@@ -78,18 +78,17 @@ async function archiveAnalyticsToR2(gameRecord: GameRecord) {
|
|||||||
|
|
||||||
async function archiveFullGameToR2(gameRecord: GameRecord) {
|
async function archiveFullGameToR2(gameRecord: GameRecord) {
|
||||||
// Create a deep copy to avoid modifying the original
|
// Create a deep copy to avoid modifying the original
|
||||||
const recordCopy = JSON.parse(JSON.stringify(gameRecord));
|
const recordCopy: GameRecord = JSON.parse(JSON.stringify(gameRecord));
|
||||||
|
|
||||||
// Players may see this so make sure to clear PII
|
// Players may see this so make sure to clear PII
|
||||||
recordCopy.info.players.forEach((p) => {
|
recordCopy.info.players.forEach((p) => {
|
||||||
p.ip = "REDACTED";
|
|
||||||
p.persistentID = "REDACTED";
|
p.persistentID = "REDACTED";
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await r2.putObject({
|
await r2.putObject({
|
||||||
Bucket: bucket,
|
Bucket: bucket,
|
||||||
Key: `${gameFolder}/${recordCopy.id}`,
|
Key: `${gameFolder}/${recordCopy.info.gameID}`,
|
||||||
Body: JSON.stringify(recordCopy),
|
Body: JSON.stringify(recordCopy),
|
||||||
ContentType: "application/json",
|
ContentType: "application/json",
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
import WebSocket from "ws";
|
import WebSocket from "ws";
|
||||||
import { TokenPayload } from "../core/ApiSchemas";
|
import { TokenPayload } from "../core/ApiSchemas";
|
||||||
import { PlayerID, Tick } from "../core/game/Game";
|
import { Tick } from "../core/game/Game";
|
||||||
import { ClientID } from "../core/Schemas";
|
import { ClientID } from "../core/Schemas";
|
||||||
import { generateID } from "../core/Util";
|
|
||||||
|
|
||||||
export class Client {
|
export class Client {
|
||||||
public lastPing: number;
|
public lastPing: number;
|
||||||
|
|
||||||
public hashes: Map<Tick, number> = new Map();
|
public hashes: Map<Tick, number> = new Map();
|
||||||
|
|
||||||
public readonly playerID: PlayerID = generateID();
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public readonly clientID: ClientID,
|
public readonly clientID: ClientID,
|
||||||
public readonly persistentID: string,
|
public readonly persistentID: string,
|
||||||
|
|||||||
@@ -300,7 +300,6 @@ export class GameServer {
|
|||||||
gameID: this.id,
|
gameID: this.id,
|
||||||
config: this.gameConfig,
|
config: this.gameConfig,
|
||||||
players: this.activeClients.map((c) => ({
|
players: this.activeClients.map((c) => ({
|
||||||
playerID: c.playerID,
|
|
||||||
username: c.username,
|
username: c.username,
|
||||||
clientID: c.clientID,
|
clientID: c.clientID,
|
||||||
flag: c.flag,
|
flag: c.flag,
|
||||||
@@ -547,7 +546,6 @@ export class GameServer {
|
|||||||
this.log.warn(`Unable to find stats for clientID ${client.clientID}`);
|
this.log.warn(`Unable to find stats for clientID ${client.clientID}`);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
playerID: client.playerID,
|
|
||||||
clientID: client.clientID,
|
clientID: client.clientID,
|
||||||
username: client.username,
|
username: client.username,
|
||||||
persistentID: client.persistentID,
|
persistentID: client.persistentID,
|
||||||
|
|||||||
Reference in New Issue
Block a user