Skip to content

Commit

Permalink
Fix crash with 'Put the object around another' action when target obj…
Browse files Browse the repository at this point in the history
…ect was not existing (#5931)
  • Loading branch information
4ian authored Nov 21, 2023
1 parent a8f9df3 commit 0a0811e
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 22 deletions.
4 changes: 3 additions & 1 deletion Extensions/3D/Scene3DTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,13 @@ namespace gdjs {

export const turnCameraTowardObject = (
runtimeScene: RuntimeScene,
object: gdjs.RuntimeObject,
object: gdjs.RuntimeObject | null,
layerName: string,
cameraIndex: integer,
isStandingOnY: boolean
) => {
if (!object) return;

const layer = runtimeScene.getLayer(layerName);
const layerRenderer = layer.getRenderer();

Expand Down
10 changes: 5 additions & 5 deletions Extensions/LinkedObjects/linkedobjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ namespace gdjs {

export const linkObjects = function (
instanceContainer: gdjs.RuntimeInstanceContainer,
objA: gdjs.RuntimeObject,
objB: gdjs.RuntimeObject
objA: gdjs.RuntimeObject | null,
objB: gdjs.RuntimeObject | null
) {
if (objA === null || objB === null) {
return;
Expand All @@ -206,8 +206,8 @@ namespace gdjs {

export const removeLinkBetween = function (
instanceContainer: gdjs.RuntimeInstanceContainer,
objA: gdjs.RuntimeObject,
objB: gdjs.RuntimeObject
objA: gdjs.RuntimeObject | null,
objB: gdjs.RuntimeObject | null
) {
if (objA === null || objB === null) {
return;
Expand All @@ -231,7 +231,7 @@ namespace gdjs {
export const pickObjectsLinkedTo = function (
instanceContainer: gdjs.RuntimeInstanceContainer,
objectsLists: Hashtable<gdjs.RuntimeObject[]>,
obj: gdjs.RuntimeObject,
obj: gdjs.RuntimeObject | null,
eventsFunctionContext: EventsFunctionContext | undefined
) {
if (obj === null) {
Expand Down
18 changes: 9 additions & 9 deletions Extensions/Physics2Behavior/physics2runtimebehavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1837,7 +1837,7 @@ namespace gdjs {
addDistanceJoint(
x1: float,
y1: float,
other: gdjs.RuntimeObject,
other: gdjs.RuntimeObject | null,
x2: float,
y2: float,
length: float,
Expand Down Expand Up @@ -2083,7 +2083,7 @@ namespace gdjs {
addRevoluteJointBetweenTwoBodies(
x1: float,
y1: float,
other: gdjs.RuntimeObject,
other: gdjs.RuntimeObject | null,
x2: float,
y2: float,
enableLimit: boolean,
Expand Down Expand Up @@ -2383,7 +2383,7 @@ namespace gdjs {
addPrismaticJoint(
x1: float,
y1: float,
other: gdjs.RuntimeObject,
other: gdjs.RuntimeObject | null,
x2: float,
y2: float,
axisAngle: float,
Expand Down Expand Up @@ -2754,7 +2754,7 @@ namespace gdjs {
addPulleyJoint(
x1: float,
y1: float,
other: gdjs.RuntimeObject,
other: gdjs.RuntimeObject | null,
x2: float,
y2: float,
groundX1: float,
Expand Down Expand Up @@ -3237,7 +3237,7 @@ namespace gdjs {
addWheelJoint(
x1: float,
y1: float,
other: gdjs.RuntimeObject,
other: gdjs.RuntimeObject | null,
x2: float,
y2: float,
axisAngle: float,
Expand Down Expand Up @@ -3522,7 +3522,7 @@ namespace gdjs {
addWeldJoint(
x1: float,
y1: float,
other: gdjs.RuntimeObject,
other: gdjs.RuntimeObject | null,
x2: float,
y2: float,
referenceAngle: float,
Expand Down Expand Up @@ -3673,7 +3673,7 @@ namespace gdjs {
addRopeJoint(
x1: float,
y1: float,
other: gdjs.RuntimeObject,
other: gdjs.RuntimeObject | null,
x2: float,
y2: float,
maxLength: float,
Expand Down Expand Up @@ -3782,7 +3782,7 @@ namespace gdjs {
addFrictionJoint(
x1: float,
y1: float,
other: gdjs.RuntimeObject,
other: gdjs.RuntimeObject | null,
x2: float,
y2: float,
maxForce: float,
Expand Down Expand Up @@ -3914,7 +3914,7 @@ namespace gdjs {

// Motor joint
addMotorJoint(
other: gdjs.RuntimeObject,
other: gdjs.RuntimeObject | null,
offsetX: float,
offsetY: float,
offsetAngle: float,
Expand Down
4 changes: 2 additions & 2 deletions GDJS/Runtime/events-tools/inputtools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ namespace gdjs {
.isMouseInsideCanvas();
};

export const _cursorIsOnObject = function (
const _cursorIsOnObject = function (
obj: gdjs.RuntimeObject,
instanceContainer: gdjs.RuntimeInstanceContainer
) {
Expand All @@ -394,7 +394,7 @@ namespace gdjs {
inverted: boolean
) {
return gdjs.evtTools.object.pickObjectsIf(
gdjs.evtTools.input._cursorIsOnObject,
_cursorIsOnObject,
objectsLists,
inverted,
instanceContainer
Expand Down
4 changes: 2 additions & 2 deletions GDJS/Runtime/events-tools/networktools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ namespace gdjs {
* @deprecated Use `JSON.stringify(variable.toJSObject())` instead.
*/
export const objectVariableStructureToJSON = function (
object: gdjs.RuntimeObject,
object: gdjs.RuntimeObject | null,
variable: gdjs.Variable
): string {
return JSON.stringify(variable.toJSObject());
Expand Down Expand Up @@ -205,7 +205,7 @@ namespace gdjs {
*/
export const jsonToObjectVariableStructure = function (
jsonStr: string,
object: gdjs.RuntimeObject,
object: gdjs.RuntimeObject | null,
variable: gdjs.Variable
) {
variable.fromJSON(jsonStr);
Expand Down
6 changes: 4 additions & 2 deletions GDJS/Runtime/runtimeobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@ namespace gdjs {
* @param multiplier Set the force multiplier
*/
addForceTowardObject(
object: gdjs.RuntimeObject,
object: gdjs.RuntimeObject | null,
len: float,
multiplier: integer
): void {
Expand Down Expand Up @@ -2276,10 +2276,12 @@ namespace gdjs {
* @param angleInDegrees The angle between the object and the target, in degrees.
*/
putAroundObject(
obj: gdjs.RuntimeObject,
obj: gdjs.RuntimeObject | null,
distance: float,
angleInDegrees: float
): void {
if (!obj) return;

this.putAround(
obj.getDrawableX() + obj.getCenterX(),
obj.getDrawableY() + obj.getCenterY(),
Expand Down
2 changes: 1 addition & 1 deletion GDJS/Runtime/spriteruntimeobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,7 @@ namespace gdjs {
* @param scene The scene containing the object
* @deprecated
*/
turnTowardObject(obj: gdjs.RuntimeObject, scene: gdjs.RuntimeScene) {
turnTowardObject(obj: gdjs.RuntimeObject | null, scene: gdjs.RuntimeScene) {
if (obj === null) {
return;
}
Expand Down

0 comments on commit 0a0811e

Please sign in to comment.