bug fixes
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 3m42s
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 3m42s
This commit is contained in:
@@ -2,6 +2,9 @@ async function sendChunk() {
|
||||
const ticksToSend = currentTick - lastSentTick;
|
||||
if (ticksToSend <= 0) return;
|
||||
|
||||
|
||||
const snapshotobstacles = JSON.parse(JSON.stringify(obstacles));
|
||||
|
||||
const payload = {
|
||||
sessionId: sessionID,
|
||||
inputs: [...inputLog],
|
||||
@@ -20,15 +23,29 @@ async function sendChunk() {
|
||||
|
||||
const data = await res.json();
|
||||
|
||||
if (data.serverObs) serverObstacles = data.serverObs;
|
||||
// Update für visuelles Debugging
|
||||
if (data.serverObs) {
|
||||
serverObstacles = data.serverObs;
|
||||
|
||||
// --- NEU: DEBUG MODUS VERGLEICH ---
|
||||
if (typeof DEBUG_SYNC !== 'undefined' && DEBUG_SYNC) {
|
||||
compareState(snapshotobstacles, data.serverObs);
|
||||
}
|
||||
// ----------------------------------
|
||||
}
|
||||
|
||||
if (data.status === "dead") {
|
||||
console.error("SERVER TOT", data);
|
||||
console.error("💀 SERVER KILL", data);
|
||||
gameOver("Vom Server gestoppt");
|
||||
} else {
|
||||
const sScore = data.verifiedScore;
|
||||
if (Math.abs(score - sScore) > 200) score = sScore;
|
||||
// Score Korrektur
|
||||
if (Math.abs(score - sScore) > 200) {
|
||||
console.warn(`⚠️ SCORE DRIFT: Client=${score} Server=${sScore}`);
|
||||
score = sScore;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error("Netzwerkfehler:", e);
|
||||
}
|
||||
@@ -89,4 +106,76 @@ async function loadStartScreenLeaderboard() {
|
||||
});
|
||||
listEl.innerHTML = html;
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
function compareState(clientObs, serverObs) {
|
||||
// 1. Anzahl prüfen
|
||||
if (clientObs.length !== serverObs.length) {
|
||||
console.error(`🚨 ANZAHL MISMATCH! Client: ${clientObs.length}, Server: ${serverObs.length}`);
|
||||
}
|
||||
|
||||
const report = [];
|
||||
const maxLen = Math.max(clientObs.length, serverObs.length);
|
||||
let hasMajorDrift = false;
|
||||
|
||||
for (let i = 0; i < maxLen; i++) {
|
||||
const cli = clientObs[i];
|
||||
const srv = serverObs[i];
|
||||
|
||||
let drift = 0;
|
||||
let status = "✅ OK";
|
||||
|
||||
// Client Objekt vorbereiten
|
||||
let cID = "---";
|
||||
let cX = 0;
|
||||
if (cli) {
|
||||
cID = cli.def.id; // Struktur beachten: cli.def.id
|
||||
cX = cli.x;
|
||||
}
|
||||
|
||||
// Server Objekt vorbereiten
|
||||
let sID = "---";
|
||||
let sX = 0;
|
||||
if (srv) {
|
||||
sID = srv.id; // Struktur vom Server: srv.id
|
||||
sX = srv.x;
|
||||
}
|
||||
|
||||
// Vergleich
|
||||
if (cli && srv) {
|
||||
// IDs unterschiedlich? (z.B. Tisch vs Lehrer)
|
||||
if (cID !== sID) {
|
||||
status = "❌ ID ERROR";
|
||||
hasMajorDrift = true;
|
||||
} else {
|
||||
drift = cX - sX;
|
||||
if (Math.abs(drift) > SYNC_TOLERANCE) {
|
||||
status = "⚠️ DRIFT";
|
||||
hasMajorDrift = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
status = "❌ MISSING";
|
||||
hasMajorDrift = true;
|
||||
}
|
||||
|
||||
// In Tabelle eintragen
|
||||
report.push({
|
||||
Index: i,
|
||||
Status: status,
|
||||
"C-ID": cID,
|
||||
"S-ID": sID,
|
||||
"C-Pos": cX.toFixed(1),
|
||||
"S-Pos": sX.toFixed(1),
|
||||
"Drift (px)": drift.toFixed(2)
|
||||
});
|
||||
}
|
||||
|
||||
// Nur loggen, wenn Fehler da sind oder alle 5 Sekunden (Tick 300)
|
||||
if (hasMajorDrift || currentTick % 300 === 0) {
|
||||
if (hasMajorDrift) console.warn("--- SYNC PROBLEME GEFUNDEN ---");
|
||||
else console.log("--- Sync Check (Routine) ---");
|
||||
|
||||
console.table(report); // Das erstellt eine super lesbare Tabelle im Browser
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user