refactor client prediction tolerances; simplify logic and update thresholds for better handling of position corrections
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 8m41s
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 8m41s
This commit is contained in:
@@ -132,33 +132,25 @@ func (g *Game) ReconcileWithServer(serverState game.PlayerState) {
|
||||
|
||||
const (
|
||||
// Toleranzen für Client-Abweichungen
|
||||
smallTolerance = 4.0 // 2px - sofort korrigieren
|
||||
normalTolerance = 225.0 // 15px - akzeptable Abweichung, sanfte Korrektur
|
||||
largeTolerance = 900.0 // 30px - Warnschwelle, nur noch Monitoring
|
||||
hugeTolerance = 10000.0 // 100px - kritisch (Teleport/Respawn)
|
||||
acceptTolerance = 400.0 // 20px - Client-Wert wird akzeptiert, keine Korrektur
|
||||
warnTolerance = 2500.0 // 50px - Warnung, nur noch Monitoring
|
||||
criticalTolerance = 10000.0 // 100px - kritisch (Teleport/Respawn/Desync)
|
||||
)
|
||||
|
||||
if dist < smallTolerance {
|
||||
// Bei sehr kleinen Abweichungen (<2px): Sofort korrigieren um Drift zu vermeiden
|
||||
g.predictedX = replayX
|
||||
g.predictedY = replayY
|
||||
} else if dist < normalTolerance {
|
||||
// Bei kleinen Abweichungen (2-15px): Sanfte Korrektur, Client hat etwas Spielraum
|
||||
interpFactor := 0.3 // Nur 30% Korrektur - mehr Client-Freiheit
|
||||
if dist < acceptTolerance {
|
||||
// Bei kleinen Abweichungen (<20px): Client-Position akzeptieren, KEINE Korrektur
|
||||
// Server nimmt Client-Wert an
|
||||
// (Client-seitige Prediction bleibt unverändert)
|
||||
} else if dist < warnTolerance {
|
||||
// Bei mittleren Abweichungen (20-50px): Nur Monitoring, KEINE Korrektur
|
||||
// Der Unterschied wird toleriert - Client-Position wird akzeptiert
|
||||
// Server überwacht weiterhin, greift aber nicht ein
|
||||
} else if dist < criticalTolerance {
|
||||
// Bei großen Abweichungen (50-100px): Sanfte Korrektur
|
||||
interpFactor := 0.3 // Nur 30% Korrektur
|
||||
g.predictedX += diffX * interpFactor
|
||||
g.predictedY += diffY * interpFactor
|
||||
g.correctionCount++
|
||||
} else if dist < largeTolerance {
|
||||
// Bei mittleren Abweichungen (15-30px): Stärkere Korrektur
|
||||
interpFactor := 0.5 // 50% Korrektur
|
||||
g.predictedX += diffX * interpFactor
|
||||
g.predictedY += diffY * interpFactor
|
||||
g.correctionCount++
|
||||
} else if dist < hugeTolerance {
|
||||
// Bei großen Abweichungen (30-100px): Nur noch Monitoring, KEINE Korrektur mehr
|
||||
// Der Unterschied ist zu groß geworden - Client-Position wird akzeptiert
|
||||
// Server überwacht weiterhin, greift aber nicht mehr ein
|
||||
// (Dies verhindert "Ruckeln" bei starker Latenz)
|
||||
} else {
|
||||
// Bei kritischen Abweichungen (>100px): Sofort korrigieren (Teleport/Respawn/Desync)
|
||||
g.predictedX = replayX
|
||||
|
||||
@@ -292,15 +292,37 @@ async function initWASM() {
|
||||
|
||||
// Enable start buttons after WASM is ready
|
||||
function enableStartButtons() {
|
||||
const buttons = ['startBtn', 'coopBtn', 'createRoomBtn', 'joinRoomBtn'];
|
||||
buttons.forEach(btnId => {
|
||||
const btn = document.getElementById(btnId);
|
||||
if (btn) {
|
||||
btn.disabled = false;
|
||||
btn.style.opacity = '1';
|
||||
btn.style.cursor = 'pointer';
|
||||
}
|
||||
});
|
||||
const startBtn = document.getElementById('startBtn');
|
||||
if (startBtn) {
|
||||
startBtn.disabled = false;
|
||||
startBtn.style.opacity = '1';
|
||||
startBtn.style.cursor = 'pointer';
|
||||
startBtn.innerHTML = 'SOLO STARTEN';
|
||||
}
|
||||
|
||||
const coopBtn = document.getElementById('coopBtn');
|
||||
if (coopBtn) {
|
||||
coopBtn.disabled = false;
|
||||
coopBtn.style.opacity = '1';
|
||||
coopBtn.style.cursor = 'pointer';
|
||||
}
|
||||
|
||||
const createRoomBtn = document.getElementById('createRoomBtn');
|
||||
if (createRoomBtn) {
|
||||
createRoomBtn.disabled = false;
|
||||
createRoomBtn.style.opacity = '1';
|
||||
createRoomBtn.style.cursor = 'pointer';
|
||||
createRoomBtn.innerHTML = 'RAUM ERSTELLEN';
|
||||
}
|
||||
|
||||
const joinRoomBtn = document.getElementById('joinRoomBtn');
|
||||
if (joinRoomBtn) {
|
||||
joinRoomBtn.disabled = false;
|
||||
joinRoomBtn.style.opacity = '1';
|
||||
joinRoomBtn.style.cursor = 'pointer';
|
||||
joinRoomBtn.innerHTML = 'RAUM BEITRETEN';
|
||||
}
|
||||
|
||||
console.log('✅ Start-Buttons aktiviert (Solo + Coop)');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user