mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
fix weird crash, fix timer on mid-game join, fix client game state on end
This commit is contained in:
parent
059f8a2add
commit
7884e829a2
3 changed files with 16 additions and 13 deletions
|
|
@ -1810,18 +1810,18 @@ class MarbleWorld extends Scheduler {
|
|||
var gameplayHigh = ourStartTime - ticksSinceTimerStart * 0.032;
|
||||
var gameplayLow = ourStartTime - (ticksSinceTimerStart + 1) * 0.032;
|
||||
// Clamp timer to be between these two
|
||||
if (gameplayLow > this.timeState.gameplayClock) {
|
||||
this.timeState.gameplayClock = gameplayLow - this.timeState.gameplayClock + gameplayHigh;
|
||||
}
|
||||
|
||||
if (gameplayHigh < this.timeState.gameplayClock) {
|
||||
this.timeState.gameplayClock = gameplayLow + this.timeState.gameplayClock - gameplayHigh;
|
||||
if (gameplayHigh < this.timeState.gameplayClock || gameplayLow > this.timeState.gameplayClock) {
|
||||
var clockTicks = Math.floor((ourStartTime - this.timeState.gameplayClock) / 0.032);
|
||||
var clockTickTime = ourStartTime - clockTicks * 0.032;
|
||||
var delta = clockTickTime - this.timeState.gameplayClock;
|
||||
this.timeState.gameplayClock = gameplayHigh - delta;
|
||||
}
|
||||
}
|
||||
|
||||
this.timeState.gameplayClock += dt * timeMultiplier;
|
||||
}
|
||||
if (this.timeState.gameplayClock < 0)
|
||||
if (this.timeState.gameplayClock < 0 && !Net.isClient)
|
||||
this.gameMode.onTimeExpire();
|
||||
}
|
||||
if (!this.isMultiplayer || this.multiplayerStarted)
|
||||
|
|
|
|||
|
|
@ -634,14 +634,13 @@ class HuntMode extends NullMode {
|
|||
level.cancel(@:privateAccess level.marble.oobSchedule);
|
||||
if (!level.isWatching) {
|
||||
if (level.isMultiplayer) {
|
||||
if (Net.isHost) {
|
||||
for (marble in level.marbles) {
|
||||
marble.setMode(Start);
|
||||
level.cancel(@:privateAccess marble.oobSchedule);
|
||||
}
|
||||
|
||||
NetCommands.timerRanOut();
|
||||
for (marble in level.marbles) {
|
||||
marble.setMode(Start);
|
||||
level.cancel(@:privateAccess marble.oobSchedule);
|
||||
}
|
||||
if (Net.isHost)
|
||||
NetCommands.timerRanOut();
|
||||
|
||||
if (!level.isWatching) {
|
||||
@:privateAccess level.schedule(level.timeState.currentAttemptTime + 5, () -> cast level.mpFinish());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,6 +140,8 @@ class Net {
|
|||
var finishSdp = () -> {
|
||||
if (sdpFinished)
|
||||
return;
|
||||
if (peer == null)
|
||||
return;
|
||||
sdpFinished = true;
|
||||
var sdpObj = StringTools.trim(peer.localDescription);
|
||||
sdpObj = sdpObj + '\r\n' + candidates.join('\r\n') + '\r\n';
|
||||
|
|
@ -218,6 +220,8 @@ class Net {
|
|||
if (sdpFinished)
|
||||
return;
|
||||
sdpFinished = true;
|
||||
if (client == null)
|
||||
return;
|
||||
Console.log("Local Description Set!");
|
||||
var sdpObj = StringTools.trim(client.localDescription);
|
||||
sdpObj = sdpObj + '\r\n' + candidates.join('\r\n') + '\r\n';
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue