From 62c85140b5182c8d81014918e24b63e1f2210e24 Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Mon, 2 Oct 2023 23:44:04 +0530 Subject: [PATCH] fixes --- src/Analytics.hx | 15 +++----- src/DifBuilder.hx | 61 ++++--------------------------- src/DtsObject.hx | 4 +-- src/Http.hx | 1 - src/Main.hx | 3 ++ src/Marble.hx | 3 +- src/MarbleGame.hx | 14 +++----- src/MarbleWorld.hx | 14 +------- src/rewind/RewindFrame.hx | 71 ------------------------------------- src/rewind/RewindManager.hx | 7 +++- 10 files changed, 29 insertions(+), 164 deletions(-) diff --git a/src/Analytics.hx b/src/Analytics.hx index b388024b..2eea1b7d 100644 --- a/src/Analytics.hx +++ b/src/Analytics.hx @@ -4,7 +4,6 @@ import haxe.Json; import src.Util; import src.Settings; import src.Http; -import src.Console; typedef PayloadData = { type:String, @@ -44,14 +43,12 @@ class Analytics { }); } - public static function trackLevelScore(levelName:String, levelFile:String, time:Int, oobs:Int, respawns:Int, rewind:Bool) { + public static function trackLevelScore(levelName:String, levelFile:String, time:Int, rewind:Bool) { var p = payload("level-score", { level_play: Json.stringify({ name: levelName, file: levelFile, time: time, - oobs: oobs, - respawns: respawns, rewind: rewind }) }); @@ -63,14 +60,12 @@ class Analytics { }); } - public static function trackLevelQuit(levelName:String, levelFile:String, time:Int, oobs:Int, respawns:Int, rewind:Bool) { + public static function trackLevelQuit(levelName:String, levelFile:String, time:Int, rewind:Bool) { var p = payload("level-quit", { level_quit: Json.stringify({ name: levelName, file: levelFile, time: time, - oobs: oobs, - respawns: respawns, rewind: rewind }) }); @@ -103,9 +98,9 @@ class Analytics { language: language(), referrer: referrer(), screen: screen(), - title: "MBHaxe Platinum", + title: "MBHaxe Gold", url: "/", - website: "e6da43f0-fc6a-49cb-a4a9-4b7e7745e538", + website: "737bbe05-ad2e-43a5-820b-4e3014f5683e", name: eventName } }; @@ -120,7 +115,7 @@ class Analytics { return js.Browser.window.location.hostname; #end #if hl - return "marbleblast.randomityguy.me"; + return "marbleblastgold.randomityguy.me"; #end } diff --git a/src/DifBuilder.hx b/src/DifBuilder.hx index 867a99e7..e2974a51 100644 --- a/src/DifBuilder.hx +++ b/src/DifBuilder.hx @@ -167,8 +167,6 @@ class DifBuilder { colliderSurface.normals = []; colliderSurface.indices = []; colliderSurface.transformKeys = []; - colliderSurface.edgeData = []; - colliderSurface.edgeConcavities = []; colliderSurface.originalIndices = []; colliderSurface.originalSurfaceIndex = surfaceindex; @@ -243,12 +241,12 @@ class DifBuilder { colliderSurface.friction = minfo.friction; colliderSurface.restitution = minfo.restitution; } - colliderSurface.points.push(new Vector(-p1.x, p1.y, p1.z)); - colliderSurface.points.push(new Vector(-p2.x, p2.y, p2.z)); - colliderSurface.points.push(new Vector(-p3.x, p3.y, p3.z)); - colliderSurface.normals.push(new Vector(-normal.x, normal.y, normal.z)); - colliderSurface.normals.push(new Vector(-normal.x, normal.y, normal.z)); - colliderSurface.normals.push(new Vector(-normal.x, normal.y, normal.z)); + colliderSurface.addPoint(-p1.x, p1.y, p1.z); + colliderSurface.addPoint(-p2.x, p2.y, p2.z); + colliderSurface.addPoint(-p3.x, p3.y, p3.z); + colliderSurface.addNormal(-normal.x, normal.y, normal.z); + colliderSurface.addNormal(-normal.x, normal.y, normal.z); + colliderSurface.addNormal(-normal.x, normal.y, normal.z); colliderSurface.indices.push(colliderSurface.indices.length); colliderSurface.indices.push(colliderSurface.indices.length); colliderSurface.indices.push(colliderSurface.indices.length); @@ -405,52 +403,6 @@ class DifBuilder { return vec; } - for (colliderSurface in colliderSurfaces) { - var i = 0; - while (i < colliderSurface.indices.length) { - var e1e2 = hashEdge(colliderSurface.originalIndices[i], colliderSurface.originalIndices[i + 1]); - var e2e3 = hashEdge(colliderSurface.originalIndices[i + 1], colliderSurface.originalIndices[i + 2]); - var e1e3 = hashEdge(colliderSurface.originalIndices[i], colliderSurface.originalIndices[i + 2]); - - var edgeData = 0; - if (difEdges.exists(e1e2)) { - // if (getEdgeDot(difEdges[e1e2]) < Math.cos(Math.PI / 12)) { - edgeData |= 1; - // } - colliderSurface.edgeConcavities.push(getEdgeConcavity(difEdges[e1e2])); - // colliderSurface.edgeNormals.push(getEdgeNormal(difEdges[e1e2])); - } else { - colliderSurface.edgeConcavities.push(false); - // colliderSurface.edgeNormals.push(new Vector(0, 0, 0)); - } - if (difEdges.exists(e2e3)) { - // if (getEdgeDot(difEdges[e2e3]) < Math.cos(Math.PI / 12)) { - edgeData |= 2; - // } - colliderSurface.edgeConcavities.push(getEdgeConcavity(difEdges[e2e3])); - // colliderSurface.edgeNormals.push(getEdgeNormal(difEdges[e2e3])); - // colliderSurface.edgeDots.push(dot); - } else { - colliderSurface.edgeConcavities.push(false); - // colliderSurface.edgeNormals.push(new Vector(0, 0, 0)); - } - if (difEdges.exists(e1e3)) { - // if (getEdgeDot(difEdges[e1e3]) < Math.cos(Math.PI / 12)) { - edgeData |= 4; - // } - colliderSurface.edgeConcavities.push(getEdgeConcavity(difEdges[e1e3])); - // colliderSurface.edgeNormals.push(getEdgeNormal(difEdges[e1e3])); - // colliderSurface.edgeDots.push(dot); - } else { - colliderSurface.edgeConcavities.push(false); - // colliderSurface.edgeNormals.push(new Vector(0, 0, 0)); - } - - colliderSurface.edgeData.push(edgeData); - i += 3; - } - } - for (vtex => buckets in vertexBuckets) { for (i in 0...buckets.length) { var bucket = buckets[i]; @@ -483,7 +435,6 @@ class DifBuilder { } } - collider.difEdgeMap = difEdges; collider.finalize(); itr.collider = collider; diff --git a/src/DtsObject.hx b/src/DtsObject.hx index 6252a6b9..2051ade1 100644 --- a/src/DtsObject.hx +++ b/src/DtsObject.hx @@ -560,11 +560,11 @@ class DtsObject extends GameObject { for (index in [i1, i2, i3]) { var vertex = vertices[index]; - hs.points.push(new Vector(vertex.x, vertex.y, vertex.z)); + hs.addPoint(vertex.x, vertex.y, vertex.z); hs.transformKeys.push(0); var normal = vertexNormals[index]; - hs.normals.push(new Vector(normal.x, normal.y, normal.z)); + hs.addNormal(normal.x, normal.y, normal.z); } hs.indices.push(hs.indices.length); diff --git a/src/Http.hx b/src/Http.hx index fc33df86..ed35765d 100644 --- a/src/Http.hx +++ b/src/Http.hx @@ -1,6 +1,5 @@ package src; -import src.Console; import src.Util; typedef HttpRequest = { diff --git a/src/Main.hx b/src/Main.hx index 2d548997..5fd38050 100644 --- a/src/Main.hx +++ b/src/Main.hx @@ -1,5 +1,6 @@ package; +import src.Http; import hxd.Key; import src.Util; import src.ResourceLoader; @@ -18,6 +19,7 @@ import h2d.Text; import h3d.Vector; import src.ProfilerUI; import src.Gamepad; +import src.Http; class Main extends hxd.App { var marbleGame:MarbleGame; @@ -58,6 +60,7 @@ class Main extends hxd.App { #end ResourceLoader.init(s2d, () -> { + Http.init(); Settings.init(); Gamepad.init(); AudioManager.init(); diff --git a/src/Marble.hx b/src/Marble.hx index 837463b8..e9ec31f8 100644 --- a/src/Marble.hx +++ b/src/Marble.hx @@ -1131,8 +1131,7 @@ class Marble extends GameObject { continue; } - var tsi = Collision.TriangleSphereIntersection(testTri.v[0], testTri.v[1], testTri.v[2], testTri.n, position, radius, testTri.edge, - testTri.concavity); + var tsi = Collision.TriangleSphereIntersection(testTri.v[0], testTri.v[1], testTri.v[2], testTri.n, position, radius); if (tsi.result) { var separatingDistance = position.sub(tsi.point).normalized(); var distToContactPlane = tsi.point.distance(position); diff --git a/src/MarbleGame.hx b/src/MarbleGame.hx index a0fff5e6..d19cd716 100644 --- a/src/MarbleGame.hx +++ b/src/MarbleGame.hx @@ -18,6 +18,7 @@ import src.Util; import src.ProfilerUI; import src.Gamepad; import src.Analytics; +import src.Settings; @:publicFields class MarbleGame { @@ -224,15 +225,7 @@ class MarbleGame { public function quitMission() { world.setCursorLock(false); - if (!Settings.levelStatistics.exists(world.mission.path)) { - Settings.levelStatistics.set(world.mission.path, { - oobs: 0, - respawns: 0, - totalTime: 0, - }); - } - var stats = Settings.levelStatistics[world.mission.path]; - Analytics.trackLevelQuit(world.mission.title, world.mission.path, Std.int(world.timeState.timeSinceLoad * 1000), stats.oobs, stats.respawns, + Analytics.trackLevelQuit(world.mission.title, world.mission.path, Std.int(world.timeState.timeSinceLoad * 1000), Settings.optionsSettings.rewindEnabled); paused = false; var pmg = new PlayMissionGui(); @@ -258,6 +251,9 @@ class MarbleGame { public function watchMissionReplay(mission:Mission, replay:Replay) { canvas.clearContent(); + if (world != null) { + world.dispose(); + } Analytics.trackSingle("replay-watch"); world = new MarbleWorld(scene, scene2d, mission); world.replay = replay; diff --git a/src/MarbleWorld.hx b/src/MarbleWorld.hx index 0097bc4d..e087dc59 100644 --- a/src/MarbleWorld.hx +++ b/src/MarbleWorld.hx @@ -1336,15 +1336,7 @@ class MarbleWorld extends Scheduler { this.finishYaw = this.marble.camera.CameraYaw; this.finishPitch = this.marble.camera.CameraPitch; displayAlert("Congratulations! You've finished!"); - if (!Settings.levelStatistics.exists(mission.path)) { - Settings.levelStatistics.set(mission.path, { - oobs: 0, - respawns: 0, - totalTime: 0, - }); - } - Analytics.trackLevelScore(mission.title, mission.path, Std.int(finishTime.gameplayClock * 1000), Settings.levelStatistics[mission.path].oobs, - Settings.levelStatistics[mission.path].respawns, Settings.optionsSettings.rewindEnabled); + Analytics.trackLevelScore(mission.title, mission.path, Std.int(finishTime.gameplayClock * 1000), Settings.optionsSettings.rewindEnabled); if (!this.isWatching) this.schedule(this.timeState.currentAttemptTime + 2, () -> cast showFinishScreen()); // Stop the ongoing sounds @@ -1578,7 +1570,6 @@ class MarbleWorld extends Scheduler { for (textureResource in this.textureResources) { textureResource.release(); } - gems = null; sky.dispose(); sky = null; @@ -1586,11 +1577,8 @@ class MarbleWorld extends Scheduler { collisionWorld.dispose(); collisionWorld = null; particleManager = null; - namedObjects = null; shapeOrTriggerInside = null; shapeImmunity = null; - currentCheckpoint = null; - checkpointCollectedGems = null; marble = null; this._disposed = true; diff --git a/src/rewind/RewindFrame.hx b/src/rewind/RewindFrame.hx index 5abeb48c..8de9c147 100644 --- a/src/rewind/RewindFrame.hx +++ b/src/rewind/RewindFrame.hx @@ -116,25 +116,9 @@ class RewindFrame { framesize += 1; // s.lastDirection framesize += 8; // s.lastCompletion } - framesize += 8; // blastAmt if (oobState.oob) framesize += 1; // oobState.oob framesize += 32; // oobState.timeState - framesize += 1; // Null - if (checkpointState != null) { - framesize += 4; // checkpointState.currentCheckpoint - } - framesize += 2; // checkpointState.currentCheckpointTrigger - framesize += 2; // checkpointState.checkpointCollectedGems.length - for (gem in checkpointState.checkpointCollectedGems.keys()) { - framesize += 2; // gem - framesize += 1; // checkpointState.checkpointCollectedGems[gem] - } - framesize += 2; // checkpointState.checkpointHeldPowerup - framesize += 1; // Null - if (checkpointState.checkpointUp != null) - framesize += 24; // checkpointState.checkpointUp - framesize += 8; // checkpointState.checkpointBlast bb.prepare(framesize); // Now actually write bb.writeDouble(timeState.currentAttemptTime); @@ -197,7 +181,6 @@ class RewindFrame { bb.writeByte(s.lastDirection); bb.writeDouble(s.lastCompletion); } - bb.writeDouble(blastAmt); bb.writeByte(oobState.oob ? 1 : 0); if (oobState.oob) { bb.writeDouble(oobState.timeState.currentAttemptTime); @@ -205,29 +188,6 @@ class RewindFrame { bb.writeDouble(oobState.timeState.gameplayClock); bb.writeDouble(oobState.timeState.dt); } - bb.writeByte(checkpointState.currentCheckpoint == null ? 0 : 1); - if (checkpointState.currentCheckpoint != null) { - bb.writeInt16(rm.allocGO(checkpointState.currentCheckpoint.obj)); - bb.writeInt16(rm.allocME(checkpointState.currentCheckpoint.elem)); - } - bb.writeInt16(rm.allocGO(checkpointState.currentCheckpointTrigger)); - var chkgemcount = 0; - for (g in checkpointState.checkpointCollectedGems) { - chkgemcount++; - } - bb.writeInt16(chkgemcount); - for (gem in checkpointState.checkpointCollectedGems.keys()) { - bb.writeInt16(rm.allocGO(gem)); - bb.writeByte(checkpointState.checkpointCollectedGems[gem] ? 1 : 0); - } - bb.writeInt16(rm.allocGO(checkpointState.checkpointHeldPowerup)); - bb.writeByte(checkpointState.checkpointUp == null ? 0 : 1); - if (checkpointState.checkpointUp != null) { - bb.writeDouble(checkpointState.checkpointUp.x); - bb.writeDouble(checkpointState.checkpointUp.y); - bb.writeDouble(checkpointState.checkpointUp.z); - } - bb.writeDouble(checkpointState.checkpointBlast); return bb.getBytes(); } @@ -321,7 +281,6 @@ class RewindFrame { trapdoorStates_item.lastCompletion = br.readDouble(); trapdoorStates.push(trapdoorStates_item); } - blastAmt = br.readDouble(); oobState = { oob: br.readByte() != 0, timeState: null @@ -333,35 +292,5 @@ class RewindFrame { oobState.timeState.gameplayClock = br.readDouble(); oobState.timeState.dt = br.readDouble(); } - var hasCheckpoint = br.readByte() != 0; - checkpointState = { - currentCheckpoint: null, - currentCheckpointTrigger: null, - checkpointCollectedGems: new Map(), - checkpointHeldPowerup: null, - checkpointUp: null, - checkpointBlast: 0.0, - }; - if (hasCheckpoint) { - var co = rm.getGO(br.readInt16()); - var ce = rm.getME(br.readInt16()); - checkpointState.currentCheckpoint = {obj: cast co, elem: ce}; - } - checkpointState.currentCheckpointTrigger = cast rm.getGO(br.readInt16()); - var checkpointState_checkpointCollectedGems_len = br.readInt16(); - for (i in 0...checkpointState_checkpointCollectedGems_len) { - var gem = cast rm.getGO(br.readInt16()); - var c = br.readByte() != 0; - checkpointState.checkpointCollectedGems.set(cast gem, c); - } - checkpointState.checkpointHeldPowerup = cast rm.getGO(br.readInt16()); - var checkpointState_checkpointUp_has = br.readByte() != 0; - if (checkpointState_checkpointUp_has) { - checkpointState.checkpointUp = new Vector(); - checkpointState.checkpointUp.x = br.readDouble(); - checkpointState.checkpointUp.y = br.readDouble(); - checkpointState.checkpointUp.z = br.readDouble(); - } - checkpointState.checkpointBlast = br.readDouble(); } } diff --git a/src/rewind/RewindManager.hx b/src/rewind/RewindManager.hx index 43b2de9c..4dab48b4 100644 --- a/src/rewind/RewindManager.hx +++ b/src/rewind/RewindManager.hx @@ -96,7 +96,12 @@ class RewindManager { oob: level.outOfBounds, timeState: level.outOfBoundsTime != null ? level.outOfBoundsTime.clone() : null }; - frames.push(rf); + frameElapsedTimes.push(level.timeState.currentAttemptTime); + frameDataOffsets.push(frameData.length); + var frameDataSerialized = rf.serialize(this); + frameSizes.push(frameDataSerialized.length); + frameData.addBytes(frameDataSerialized, 0, frameDataSerialized.length); + // frames.push(rf); } public function applyFrame(rf:RewindFrame) {