From efcf3dc30725e272561687982cfcaaefb2788960 Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Thu, 6 Jun 2024 00:15:51 +0530 Subject: [PATCH] fix various small bugs --- src/Marble.hx | 15 +++++++++++++-- src/MarbleWorld.hx | 3 ++- src/gui/EndGameGui.hx | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Marble.hx b/src/Marble.hx index dca76895..fe6db648 100644 --- a/src/Marble.hx +++ b/src/Marble.hx @@ -848,8 +848,14 @@ class Marble extends GameObject { normP.scale(1 + bounce); velocity.load(velocity.sub(normP.multiply(1 / ourMass))); + if (Math.isNaN(velocity.lengthSq())) { + velocity.set(0, 0, 0); + } otherMarble.velocity.load(otherMarble.velocity.add(normP.multiply(1 / theirMass))); + if (Math.isNaN(otherMarble.velocity.lengthSq())) { + otherMarble.velocity.set(0, 0, 0); + } contacts[i].velocity.load(otherMarble.velocity); } else { if (contacts[i].velocity.length() == 0 && !surfaceSlide && surfaceDot > -this._maxDotSlide * velLen) { @@ -1534,6 +1540,8 @@ class Marble extends GameObject { } function nudgeToContacts(position:Vector, radius:Float, foundContacts:Array, foundMarbles:Array) { + if (Net.isMP) + return position; var it = 0; var concernedContacts = foundContacts; // PathedInteriors have their own nudge logic var prevResolved = 0; @@ -1727,8 +1735,8 @@ class Marble extends GameObject { tdiff = diff; } var expectedPos = finalPosData.position; - var newPos = expectedPos; - // var newPos = nudgeToContacts(expectedPos, _radius, finalPosData.foundContacts, finalPosData.foundMarbles); + // var newPos = expectedPos; + var newPos = nudgeToContacts(expectedPos, _radius, finalPosData.foundContacts, finalPosData.foundMarbles); if (this.velocity.lengthSq() > 1e-8) { var posDiff = newPos.sub(expectedPos); @@ -1847,6 +1855,9 @@ class Marble extends GameObject { } } } + if (Net.isClient && this.megaMarbleUseTick == 0) { + this.collider.radius = this._radius = 0.3; + } if (Net.isMP) { if (m.jump && this.outOfBounds) { diff --git a/src/MarbleWorld.hx b/src/MarbleWorld.hx index 96a32144..c6cc0544 100644 --- a/src/MarbleWorld.hx +++ b/src/MarbleWorld.hx @@ -1095,9 +1095,9 @@ class MarbleWorld extends Scheduler { public function addMarble(marble:Marble, client:GameConnection, onFinish:Void->Void) { marble.level = cast this; - this.marbles.push(marble); if (marble.controllable) { marble.init(cast this, client, () -> { + this.marbles.push(marble); this.scene.addChild(marble.camera); this.marble = marble; // Ugly hack @@ -1110,6 +1110,7 @@ class MarbleWorld extends Scheduler { }); } else { marble.init(cast this, client, () -> { + this.marbles.push(marble); marble.collisionWorld = this.collisionWorld; this.collisionWorld.addMovingEntity(marble.collider); this.collisionWorld.addMarbleEntity(marble.collider); diff --git a/src/gui/EndGameGui.hx b/src/gui/EndGameGui.hx index 04ad5277..84d8e767 100644 --- a/src/gui/EndGameGui.hx +++ b/src/gui/EndGameGui.hx @@ -150,7 +150,7 @@ class EndGameGui extends GuiImage { if (scoreType == Score) egResultRight.text.text = '${Util.formatScore(score)}
${Util.formatScore(bestScore.time)}'; if (scoreType == Time) - egResultRight.text.text = '${Util.formatTime(score)}
${Util.formatTime(mission.qualifyTime)}
${rating}
${Util.formatTime(bestScore.time)}'; + egResultRight.text.text = '${Util.formatTime(score)}
${Util.formatTime(mission.qualifyTime)}
${rating}
${Util.formatTime(bestScore.time)}'; endGameWnd.addChild(egResultRight); var bottomBar = new GuiControl();