From 55089d56cb1af888b00f36cf9c2dec85d1f59a3b Mon Sep 17 00:00:00 2001 From: Karl Pannek Date: Wed, 16 Jul 2025 15:16:30 +0200 Subject: [PATCH] Fix remaining capitalized Box2D method calls using sed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Convert GetWorld() → getWorld() - Convert CreateJoint() → createJoint() - Convert DestroyJoint() → destroyJoint() - Convert CreateBody() → createBody() - Convert DestroyBody() → destroyBody() - Convert GetFriction() → getFriction() - Convert SetFriction() → setFriction() - Convert GetBodyList() → getBodyList() - Convert GetNext() → getNext() - Convert GetContactList() → getContactList() - Convert GetFixtureList() → getFixtureList() Applied bulk sed replacements across all game files to complete Box2D to Planck.js migration method name conversion. --- app/Game/Channel/GameController.js | 4 +- app/Game/Core/GameObjects/Doll.js | 14 +++--- app/Game/Core/GameObjects/Items/RagDoll.js | 18 +++---- app/Game/Core/GameObjects/Items/RagDoll2.js | 48 +++++++++---------- app/Game/Core/GameObjects/Items/RubeDoll.js | 8 ++-- app/Game/Core/GameObjects/Items/Skateboard.js | 8 ++-- 6 files changed, 50 insertions(+), 50 deletions(-) diff --git a/app/Game/Channel/GameController.js b/app/Game/Channel/GameController.js index da3b982..8f3902c 100755 --- a/app/Game/Channel/GameController.js +++ b/app/Game/Channel/GameController.js @@ -129,7 +129,7 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, nc, Box2D, Player, var update = {}; /* - var body = this.physicsEngine.world.GetBodyList(); + var body = this.physicsEngine.world.getBodyList(); do { if((getSleeping || body.isAwake()) && body.getType() === 'dynamic') { var userData = body.getUserData(); @@ -144,7 +144,7 @@ function (Parent, PhysicsEngine, Settings, requestAnimFrame, nc, Box2D, Player, } } - } while (body = body.GetNext()); + } while (body = body.getNext()); */ for (var uid in this.worldUpdateObjects) { diff --git a/app/Game/Core/GameObjects/Doll.js b/app/Game/Core/GameObjects/Doll.js index fe3075d..b29344f 100755 --- a/app/Game/Core/GameObjects/Doll.js +++ b/app/Game/Core/GameObjects/Doll.js @@ -222,8 +222,8 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse Assert.number(friction); - if (this.legs.GetFriction() != friction) { - this.legs.SetFriction(friction); + if (this.legs.getFriction() != friction) { + this.legs.setFriction(friction); } }; @@ -348,7 +348,7 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse if(this.holdingItem) { if(this.holdingJoint) { - this.body.GetWorld().DestroyJoint(this.holdingJoint); + this.body.getWorld().destroyJoint(this.holdingJoint); this.holdingJoint = null; } @@ -364,15 +364,15 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse this.holdingItem.reposition(handPosition, this.lookDirection); var jointDef = new Box2D.Dynamics.Joints.b2WeldJointDef(); - jointDef.Initialize(this.body, this.holdingItem.body, this.holdingItem.getGrabPoint()); + jointDef.initialize(this.body, this.holdingItem.body, this.holdingItem.getGrabPoint()); - this.holdingJoint = this.body.GetWorld().CreateJoint(jointDef); + this.holdingJoint = this.body.getWorld().createJoint(jointDef); } }; Doll.prototype.throw = function(item, options) { if(this.holdingJoint) { - this.body.GetWorld().DestroyJoint(this.holdingJoint); + this.body.getWorld().destroyJoint(this.holdingJoint); } else { // log stack if we called throw without a holdingJoint var w = new Error("Throwing without a holdingJoint"); @@ -408,7 +408,7 @@ function (Parent, Exception, planck, Settings, CollisionDetector, Item, nc, Asse var contactCount = 0; - var edge = self.body.GetContactList(); + var edge = self.body.getContactList(); while (edge) { var contact = edge.contact; if(!contact.IsTouching()) { diff --git a/app/Game/Core/GameObjects/Items/RagDoll.js b/app/Game/Core/GameObjects/Items/RagDoll.js index fac14a9..920ae44 100644 --- a/app/Game/Core/GameObjects/Items/RagDoll.js +++ b/app/Game/Core/GameObjects/Items/RagDoll.js @@ -253,7 +253,7 @@ function (Parent, Box2D, Settings, nc, Assert, optionsHelper, ItemSettings) { fixtureDef.isSensor = false; fixtureDef.filter.groupIndex = -this.getId(); - var head = this.body.GetWorld().CreateBody(bodyDef); + var head = this.body.getWorld().createBody(bodyDef); head.createFixture(fixtureDef); this.limbs.head = head; @@ -269,12 +269,12 @@ function (Parent, Box2D, Settings, nc, Assert, optionsHelper, ItemSettings) { var pos = this.body.getWorldCenter().clone(); pos.y -= this.options.limbs.chest.height / 2 / Settings.RATIO; - jointDef.Initialize(this.body, head, pos); + jointDef.initialize(this.body, head, pos); jointDef.lowerAngle = -0.25 * Box2D.Common.b2Settings.b2_pi; // -45 degrees jointDef.upperAngle = 0.25 * Box2D.Common.b2Settings.b2_pi; // 45 degrees jointDef.enableLimit = true; - this.body.GetWorld().CreateJoint(jointDef); + this.body.getWorld().createJoint(jointDef); }; RagDoll.prototype.addLimb = function(name, connectTo, xOffset, yOffset) { @@ -307,7 +307,7 @@ function (Parent, Box2D, Settings, nc, Assert, optionsHelper, ItemSettings) { fixtureDef.isSensor = false; fixtureDef.filter.groupIndex = -this.getId(); - var limb = this.body.GetWorld().CreateBody(bodyDef); + var limb = this.body.getWorld().createBody(bodyDef); limb.createFixture(fixtureDef); this.limbs[name] = limb; @@ -318,18 +318,18 @@ function (Parent, Box2D, Settings, nc, Assert, optionsHelper, ItemSettings) { var pos = connectTo.getWorldCenter().clone(); pos.x += (xOffset / Settings.RATIO); pos.y += (yOffset / Settings.RATIO); - jointDef.Initialize(connectTo, limb, pos); + jointDef.initialize(connectTo, limb, pos); jointDef.lowerAngle = -0.15 * Box2D.Common.b2Settings.b2_pi; // -45 degrees jointDef.upperAngle = 0.15 * Box2D.Common.b2Settings.b2_pi; // 45 degrees jointDef.enableLimit = true; - this.body.GetWorld().CreateJoint(jointDef); + this.body.getWorld().createJoint(jointDef); }; RagDoll.prototype.detachHead = function() { var joint = this.limbs.head.GetJointList().joint; if(joint) { - this.body.GetWorld().DestroyJoint(joint); + this.body.getWorld().destroyJoint(joint); } }; @@ -373,10 +373,10 @@ function (Parent, Box2D, Settings, nc, Assert, optionsHelper, ItemSettings) { RagDoll.prototype.destroy = function() { - var world = this.body.GetWorld(); + var world = this.body.getWorld(); for (var name in this.limbs) { - world.DestroyBody(this.limbs[name]); + world.destroyBody(this.limbs[name]); } Parent.prototype.destroy.call(this); diff --git a/app/Game/Core/GameObjects/Items/RagDoll2.js b/app/Game/Core/GameObjects/Items/RagDoll2.js index 3b9bcc0..5f10f96 100644 --- a/app/Game/Core/GameObjects/Items/RagDoll2.js +++ b/app/Game/Core/GameObjects/Items/RagDoll2.js @@ -10,7 +10,7 @@ function (Parent, Box2D, Settings) { function RagDoll(physicsEngine, uid, options) { Parent.call(this, physicsEngine, uid, options); - this.body.GetWorld().DestroyBody(this.body); + this.body.getWorld().destroyBody(this.body); this.limbs = {}; this.initBodies(); } @@ -19,7 +19,7 @@ function (Parent, Box2D, Settings) { RagDoll.prototype.initBodies = function() { - var world = this.body.GetWorld(); + var world = this.body.getWorld(); var bodies = []; var joints = []; @@ -27,7 +27,7 @@ function (Parent, Box2D, Settings) { var bd = { type: 'static', position: planck.Vec2(0, 0), angle: 0 }; bd.type = 'dynamic'; bd.position.Set(-1.917114257812500e-01, 1.433728694915771e+00); - bodies[0] = world.CreateBody(bd); + bodies[0] = world.createBody(bd); { var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false }; @@ -53,7 +53,7 @@ function (Parent, Box2D, Settings) { var bd = { type: 'static', position: planck.Vec2(0, 0), angle: 0 }; bd.type = 'dynamic'; bd.position.Set(-6.397294998168945e-02, 1.267420768737793e+00); - bodies[1] = world.CreateBody(bd); + bodies[1] = world.createBody(bd); { var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false }; @@ -99,7 +99,7 @@ function (Parent, Box2D, Settings) { var bd = { type: 'static', position: planck.Vec2(0, 0), angle: 0 }; bd.type = 'dynamic'; bd.position.Set(4.118728637695312e-02, 2.199305295944214e+00); - bodies[2] = world.CreateBody(bd); + bodies[2] = world.createBody(bd); { var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false }; @@ -136,7 +136,7 @@ function (Parent, Box2D, Settings) { var bd = { type: 'static', position: planck.Vec2(0, 0), angle: 0 }; bd.type = 'dynamic'; bd.position.Set(1.235442161560059e-01, 1.142371892929077e+00); - bodies[3] = world.CreateBody(bd); + bodies[3] = world.createBody(bd); { var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false }; @@ -163,7 +163,7 @@ function (Parent, Box2D, Settings) { bd.type = 'dynamic'; bd.position.Set(-9.663248062133789e-02, 3.554300665855408e-01); - bodies[4] = world.CreateBody(bd); + bodies[4] = world.createBody(bd); { var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false }; @@ -209,7 +209,7 @@ function (Parent, Box2D, Settings) { bd.type = 'dynamic'; bd.position.Set(-1.917138099670410e-01, 1.142371892929077e+00); - bodies[5] = world.CreateBody(bd); + bodies[5] = world.createBody(bd); { var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false }; @@ -236,7 +236,7 @@ function (Parent, Box2D, Settings) { bd.type = 'dynamic'; bd.position.Set(1.235442161560059e-01, 1.433728694915771e+00); - bodies[6] = world.CreateBody(bd); + bodies[6] = world.createBody(bd); { var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false }; @@ -262,7 +262,7 @@ function (Parent, Box2D, Settings) { var bd = { type: 'static', position: planck.Vec2(0, 0), angle: 0 }; bd.type = 'dynamic'; bd.position.Set(2.897095680236816e-02, 6.702435612678528e-01); - bodies[7] = world.CreateBody(bd); + bodies[7] = world.createBody(bd); { var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false }; @@ -289,7 +289,7 @@ function (Parent, Box2D, Settings) { bd.type = 'dynamic'; bd.position.Set(-9.663248062133789e-02, 6.702435612678528e-01); - bodies[8] = world.CreateBody(bd); + bodies[8] = world.createBody(bd); { var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false }; @@ -316,7 +316,7 @@ function (Parent, Box2D, Settings) { bd.type = 'dynamic'; bd.position.Set(2.897095680236816e-02, 3.554300665855408e-01); - bodies[9] = world.CreateBody(bd); + bodies[9] = world.createBody(bd); { var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false }; @@ -365,7 +365,7 @@ function (Parent, Box2D, Settings) { bd.type = b2BodyType(0); bd.position.Set(3.118395805358887e-03, -6.553649902343750e-03); - bodies[10] = world.CreateBody(bd); + bodies[10] = world.createBody(bd); { var fd = { shape: null, density: 1.0, friction: 0.3, restitution: 0.0, isSensor: false }; @@ -403,7 +403,7 @@ function (Parent, Box2D, Settings) { jd.enableMotor = false; jd.motorSpeed = 0.000000000000000e+00; jd.maxMotorTorque = 1.000000000000000e+00; - joints[0] = world.CreateJoint(jd); + joints[0] = world.createJoint(jd); } { var jd = new Box2D.Dynamics.Joints.b2RevoluteJointDef(); @@ -419,7 +419,7 @@ function (Parent, Box2D, Settings) { jd.enableMotor = false; jd.motorSpeed = 0.000000000000000e+00; jd.maxMotorTorque = 1.000000000000000e+00; - joints[1] = world.CreateJoint(jd); + joints[1] = world.createJoint(jd); } { var jd = new Box2D.Dynamics.Joints.b2RevoluteJointDef(); @@ -435,7 +435,7 @@ function (Parent, Box2D, Settings) { jd.enableMotor = false; jd.motorSpeed = 0.000000000000000e+00; jd.maxMotorTorque = 1.000000000000000e+00; - joints[2] = world.CreateJoint(jd); + joints[2] = world.createJoint(jd); } { var jd = new Box2D.Dynamics.Joints.b2RevoluteJointDef(); @@ -451,7 +451,7 @@ function (Parent, Box2D, Settings) { jd.enableMotor = false; jd.motorSpeed = 0.000000000000000e+00; jd.maxMotorTorque = 1.000000000000000e+00; - joints[3] = world.CreateJoint(jd); + joints[3] = world.createJoint(jd); } { var jd = new Box2D.Dynamics.Joints.b2RevoluteJointDef(); @@ -467,7 +467,7 @@ function (Parent, Box2D, Settings) { jd.enableMotor = false; jd.motorSpeed = 0.000000000000000e+00; jd.maxMotorTorque = 1.000000000000000e+00; - joints[4] = world.CreateJoint(jd); + joints[4] = world.createJoint(jd); } { var jd = new Box2D.Dynamics.Joints.b2RevoluteJointDef(); @@ -483,7 +483,7 @@ function (Parent, Box2D, Settings) { jd.enableMotor = false; jd.motorSpeed = 0.000000000000000e+00; jd.maxMotorTorque = 1.000000000000000e+00; - joints[5] = world.CreateJoint(jd); + joints[5] = world.createJoint(jd); } { var jd = new Box2D.Dynamics.Joints.b2RevoluteJointDef(); @@ -499,7 +499,7 @@ function (Parent, Box2D, Settings) { jd.enableMotor = false; jd.motorSpeed = 0.000000000000000e+00; jd.maxMotorTorque = 1.000000000000000e+00; - joints[6] = world.CreateJoint(jd); + joints[6] = world.createJoint(jd); } { var jd = new Box2D.Dynamics.Joints.b2RevoluteJointDef(); @@ -515,7 +515,7 @@ function (Parent, Box2D, Settings) { jd.enableMotor = false; jd.motorSpeed = 0.000000000000000e+00; jd.maxMotorTorque = 1.000000000000000e+00; - joints[7] = world.CreateJoint(jd); + joints[7] = world.createJoint(jd); } { var jd = new Box2D.Dynamics.Joints.b2RevoluteJointDef(); @@ -531,7 +531,7 @@ function (Parent, Box2D, Settings) { jd.enableMotor = false; jd.motorSpeed = 0.000000000000000e+00; jd.maxMotorTorque = 1.000000000000000e+00; - joints[8] = world.CreateJoint(jd); + joints[8] = world.createJoint(jd); } this.body = bodies[1]; @@ -553,12 +553,12 @@ function (Parent, Box2D, Settings) { RagDoll.prototype.destroy = function() { - var world = this.body.GetWorld(); + var world = this.body.getWorld(); Parent.prototype.destroy.call(this); // chest destruction for(var key in this.limbs) { - world.DestroyBody(this.limbs[key]); + world.destroyBody(this.limbs[key]); } }; diff --git a/app/Game/Core/GameObjects/Items/RubeDoll.js b/app/Game/Core/GameObjects/Items/RubeDoll.js index ed50ffe..ad69745 100644 --- a/app/Game/Core/GameObjects/Items/RubeDoll.js +++ b/app/Game/Core/GameObjects/Items/RubeDoll.js @@ -61,7 +61,7 @@ function (Parent, /* RubeLoader, */ Box2D, Settings, Assert, nc, Matrix /* , Rub //var filterData = new Box2D.Dynamics.b2FilterData(); //filterData.groupIndex = -66; //if(body.name != "head" && body.name != "chest") { - // for (var fixture = body.GetFixtureList(); fixture; fixture = fixture.GetNext()) { + // for (var fixture = body.getFixtureList(); fixture; fixture = fixture.getNext()) { // fixture.SetFilterData(filterData); // } //} @@ -81,7 +81,7 @@ function (Parent, /* RubeLoader, */ Box2D, Settings, Assert, nc, Matrix /* , Rub if(count < 4 && this.joints[i] instanceof Box2D.Dynamics.Joints.b2RevoluteJoint) { console.log(i); } else { - body.GetWorld().DestroyJoint(this.joints[i]); + body.getWorld().destroyJoint(this.joints[i]); } count++; */ @@ -213,10 +213,10 @@ function (Parent, /* RubeLoader, */ Box2D, Settings, Assert, nc, Matrix /* , Rub RubeDoll.prototype.destroy = function() { - var world = this.body.GetWorld(); + var world = this.body.getWorld(); for (var name in this.limbs) { - world.DestroyBody(this.limbs[name]); + world.destroyBody(this.limbs[name]); } Parent.prototype.destroy.call(this); diff --git a/app/Game/Core/GameObjects/Items/Skateboard.js b/app/Game/Core/GameObjects/Items/Skateboard.js index 035d840..bcb3f56 100755 --- a/app/Game/Core/GameObjects/Items/Skateboard.js +++ b/app/Game/Core/GameObjects/Items/Skateboard.js @@ -156,7 +156,7 @@ function (Parent, Box2D, Settings, Assert) { fixtureDef.isSensor = false; fixtureDef.friction = 0; - var wheelBody = this.body.GetWorld().CreateBody(bodyDef); + var wheelBody = this.body.getWorld().createBody(bodyDef); wheelBody.createFixture(fixtureDef); //var revoluteJointDef = new Box2D.Dynamics.Joints.b2RevoluteJointDef(); @@ -165,8 +165,8 @@ function (Parent, Box2D, Settings, Assert) { - revoluteJointDef.Initialize(this.body, wheelBody, wheelBody.getWorldCenter()); - var j = this.body.GetWorld().CreateJoint(revoluteJointDef); + revoluteJointDef.initialize(this.body, wheelBody, wheelBody.getWorldCenter()); + var j = this.body.getWorld().createJoint(revoluteJointDef); // FIXME this means, that we will have bodies in the world, which must not be @@ -192,7 +192,7 @@ function (Parent, Box2D, Settings, Assert) { Skateboard.prototype.destroy = function() { for (var i = 0; i < this.wheels.length; i++) { - this.body.GetWorld().DestroyBody(this.wheels[i]); + this.body.getWorld().destroyBody(this.wheels[i]); } Parent.prototype.destroy.call(this);