Skip to content

Commit

Permalink
print some longs when kills disagree
Browse files Browse the repository at this point in the history
  • Loading branch information
Quantumplation committed Dec 10, 2024
1 parent 0ab7de3 commit 1702cdd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/utils/HydraMultiplayer/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export abstract class HydraMultiplayer {
kills: number[],
data: Uint8Array,
): Promise<void> {
console.log("SendPacket", kills);
const ephemeralKey = this.key.publicKeyHashBytes;
this.packetQueue.push({ to, from, ephemeralKey, kills, data });
await this.sendPacketQueue();
Expand Down
7 changes: 7 additions & 0 deletions src/utils/HydraMultiplayer/dedicated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,19 @@ export class HydraMultiplayerDedicated extends HydraMultiplayer {
this.clients[packet.from].kills = packet.kills;
this.clients[packet.from].tic += 1;

console.log("Kills: ", this.clients);

let keys = Object.keys(this.clients);
for(let i = 0; i < keys.length; i++) {
for(let j = i + 1; j < keys.length; j++) {
const clientA = this.clients[keys[i]];
const clientB = this.clients[keys[j]];
if(clientA && clientB) {
console.log(`Comparing ${keys[i]} and ${keys[j]}`);
console.log(`Client A: ${clientA.kills}`);
console.log(`Client B: ${clientB.kills}`);
console.log(`Client A tic: ${clientA.tic}`);
console.log(`Client B tic: ${clientB.tic}`);
if(clientA.kills != clientB.kills && Math.abs(clientA.tic - clientB.tic) < 10) {
console.log(`Players disagree on kills!`);
this.onDisagreement?.();
Expand Down

0 comments on commit 1702cdd

Please sign in to comment.