Page MenuHomeWildfire Games

Fix UnitmotionFlying and implement CMessageMotionUpdate::FromJSVal
ClosedPublic

Authored by Silier on Dec 3 2019, 2:00 PM.

Details

Reviewers
None
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Commits
rP23208: Fix UnitmotionFlying and implement CMessageMotionUpdate::FromJSVal
Trac Tickets
#5626
Summary

In rP22526 have been changed message from MotionChanged to MotionUpdate and CMessageMotionUpdate::FromJSVal was not implemented to reflect changes in message structure.
As a result UnitMotionFlying tries to send MotionChanged message which not only was renamed, but sending it from js is not supported anymore.

I am not 100% sure, message implementation is the best solution, but I was not able to cast number to needed enum type.

Test Plan

Run game.
Use cheat "how do you turn this on?"
Move plane, command to attack units.

Errors should pop up.

Apply patch.
Run game.
Use cheat "how do you turn this on?"
Move plane, command to attack units.

No errors or warnings about unitmotion should be visible.

Event Timeline

Silier created this revision.Dec 3 2019, 2:00 PM
Owners added a subscriber: Restricted Owners Package.Dec 3 2019, 2:00 PM
Vulcan added a comment.Dec 3 2019, 2:01 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/674/display/redirect

Silier added a reviewer: Restricted Owners Package.Dec 3 2019, 2:02 PM
Vulcan added a comment.Dec 3 2019, 2:06 PM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 101| 101| 				this.pitch = 0;
| 102| 102| 				// We've stopped.
| 103| 103| 				if (cmpGarrisonHolder)
| 104|    |-					cmpGarrisonHolder.AllowGarrisoning(true,"UnitMotionFlying");
|    | 104|+					cmpGarrisonHolder.AllowGarrisoning(true, "UnitMotionFlying");
| 105| 105| 				canTurn = false;
| 106| 106| 				this.hasTarget = false;
| 107| 107| 				this.landing = false;
|    | [NORMAL] ESLintBear (space-unary-ops):
|    | Unexpected space after unary operator '-'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 138| 138| 			var targetHeight = ground;
| 139| 139| 			// Steep, then gradual descent.
| 140| 140| 			if ((pos.y - targetHeight) / this.template.FlyingHeight > 1 / SHORT_FINAL)
| 141|    |-				this.pitch = - Math.PI / 18;
|    | 141|+				this.pitch = -Math.PI / 18;
| 142| 142| 			else
| 143| 143| 				this.pitch = Math.PI / 18;
| 144| 144| 			var descentRate = ((pos.y - targetHeight) / this.template.FlyingHeight * this.template.ClimbRate + SHORT_FINAL) * SHORT_FINAL;
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 163| 163| 		if (this.speed < this.template.TakeoffSpeed && this.onGround)
| 164| 164| 		{
| 165| 165| 			if (cmpGarrisonHolder)
| 166|    |-				cmpGarrisonHolder.AllowGarrisoning(false,"UnitMotionFlying");
|    | 166|+				cmpGarrisonHolder.AllowGarrisoning(false, "UnitMotionFlying");
| 167| 167| 			this.pitch = 0;
| 168| 168| 			// Accelerate forwards
| 169| 169| 			this.speed = Math.min(this.template.MaxSpeed, this.speed + turnLength * this.template.AccelRate);
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 203| 203| 	if (!this.reachedTarget && this.targetMinRange <= distFromTarget && distFromTarget <= this.targetMaxRange)
| 204| 204| 	{
| 205| 205| 		this.reachedTarget = true;
| 206|    |-		Engine.PostMessage(this.entity, MT_MotionUpdate, {"updateStr": "likelySuccess"});
|    | 206|+		Engine.PostMessage(this.entity, MT_MotionUpdate, { "updateStr": "likelySuccess"});
| 207| 207| 	}
| 208| 208| 
| 209| 209| 	// If we're facing away from the target, and are still fairly close to it,
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 203| 203| 	if (!this.reachedTarget && this.targetMinRange <= distFromTarget && distFromTarget <= this.targetMaxRange)
| 204| 204| 	{
| 205| 205| 		this.reachedTarget = true;
| 206|    |-		Engine.PostMessage(this.entity, MT_MotionUpdate, {"updateStr": "likelySuccess"});
|    | 206|+		Engine.PostMessage(this.entity, MT_MotionUpdate, {"updateStr": "likelySuccess" });
| 207| 207| 	}
| 208| 208| 
| 209| 209| 	// If we're facing away from the target, and are still fairly close to it,
|    | [NORMAL] ESLintBear (space-unary-ops):
|    | Unexpected space after unary operator '-'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 230| 230| 		if (newangle - angle > Math.PI / 18)
| 231| 231| 			this.roll = Math.PI / 9;
| 232| 232| 		else if (newangle - angle < -Math.PI / 18)
| 233|    |-			this.roll = - Math.PI / 9;
|    | 233|+			this.roll = -Math.PI / 9;
| 234| 234| 		else
| 235| 235| 			this.roll = newangle - angle;
| 236| 236| 	}
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 323| 323| 
| 324| 324| UnitMotionFlying.prototype.StopMoving = function()
| 325| 325| {
| 326|    |-	//Invert
|    | 326|+	// Invert
| 327| 327| 	if (!this.waterDeath)
| 328| 328| 		this.landing = !this.landing;
| 329| 329| 

binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 182| »   »   »   var·targetHeight·=·ground·+·(+this.template.FlyingHeight);
|    | [NORMAL] JSHintBear:
|    | 'targetHeight' is already defined.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1190/display/redirect

Silier updated this revision to Diff 10484.EditedDec 6 2019, 11:20 AM
Silier added a subscriber: gameboy.

Fix

ERROR: Error calling component script function IsMoveRequested

reported by @gameboy https://wildfiregames.com/forum/index.php?/topic/27294-cheats-error/&tab=comments#comment-389344

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/689/display/redirect

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 101| 101| 				this.pitch = 0;
| 102| 102| 				// We've stopped.
| 103| 103| 				if (cmpGarrisonHolder)
| 104|    |-					cmpGarrisonHolder.AllowGarrisoning(true,"UnitMotionFlying");
|    | 104|+					cmpGarrisonHolder.AllowGarrisoning(true, "UnitMotionFlying");
| 105| 105| 				canTurn = false;
| 106| 106| 				this.hasTarget = false;
| 107| 107| 				this.landing = false;
|    | [NORMAL] ESLintBear (space-unary-ops):
|    | Unexpected space after unary operator '-'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 138| 138| 			var targetHeight = ground;
| 139| 139| 			// Steep, then gradual descent.
| 140| 140| 			if ((pos.y - targetHeight) / this.template.FlyingHeight > 1 / SHORT_FINAL)
| 141|    |-				this.pitch = - Math.PI / 18;
|    | 141|+				this.pitch = -Math.PI / 18;
| 142| 142| 			else
| 143| 143| 				this.pitch = Math.PI / 18;
| 144| 144| 			var descentRate = ((pos.y - targetHeight) / this.template.FlyingHeight * this.template.ClimbRate + SHORT_FINAL) * SHORT_FINAL;
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 163| 163| 		if (this.speed < this.template.TakeoffSpeed && this.onGround)
| 164| 164| 		{
| 165| 165| 			if (cmpGarrisonHolder)
| 166|    |-				cmpGarrisonHolder.AllowGarrisoning(false,"UnitMotionFlying");
|    | 166|+				cmpGarrisonHolder.AllowGarrisoning(false, "UnitMotionFlying");
| 167| 167| 			this.pitch = 0;
| 168| 168| 			// Accelerate forwards
| 169| 169| 			this.speed = Math.min(this.template.MaxSpeed, this.speed + turnLength * this.template.AccelRate);
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required after '{'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 203| 203| 	if (!this.reachedTarget && this.targetMinRange <= distFromTarget && distFromTarget <= this.targetMaxRange)
| 204| 204| 	{
| 205| 205| 		this.reachedTarget = true;
| 206|    |-		Engine.PostMessage(this.entity, MT_MotionUpdate, {"updateStr": "likelySuccess"});
|    | 206|+		Engine.PostMessage(this.entity, MT_MotionUpdate, { "updateStr": "likelySuccess"});
| 207| 207| 	}
| 208| 208| 
| 209| 209| 	// If we're facing away from the target, and are still fairly close to it,
|    | [NORMAL] ESLintBear (object-curly-spacing):
|    | A space is required before '}'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 203| 203| 	if (!this.reachedTarget && this.targetMinRange <= distFromTarget && distFromTarget <= this.targetMaxRange)
| 204| 204| 	{
| 205| 205| 		this.reachedTarget = true;
| 206|    |-		Engine.PostMessage(this.entity, MT_MotionUpdate, {"updateStr": "likelySuccess"});
|    | 206|+		Engine.PostMessage(this.entity, MT_MotionUpdate, {"updateStr": "likelySuccess" });
| 207| 207| 	}
| 208| 208| 
| 209| 209| 	// If we're facing away from the target, and are still fairly close to it,
|    | [NORMAL] ESLintBear (space-unary-ops):
|    | Unexpected space after unary operator '-'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 230| 230| 		if (newangle - angle > Math.PI / 18)
| 231| 231| 			this.roll = Math.PI / 9;
| 232| 232| 		else if (newangle - angle < -Math.PI / 18)
| 233|    |-			this.roll = - Math.PI / 9;
|    | 233|+			this.roll = -Math.PI / 9;
| 234| 234| 		else
| 235| 235| 			this.roll = newangle - angle;
| 236| 236| 	}
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 294| 294| UnitMotionFlying.prototype.IsMoveRequested = function()
| 295| 295| {
| 296| 296| 	return this.hasTarget;
| 297|    |-}
|    | 297|+};
| 298| 298| 
| 299| 299| UnitMotionFlying.prototype.GetCurrentSpeed = function()
| 300| 300| {
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 328| 328| 
| 329| 329| UnitMotionFlying.prototype.StopMoving = function()
| 330| 330| {
| 331|    |-	//Invert
|    | 331|+	// Invert
| 332| 332| 	if (!this.waterDeath)
| 333| 333| 		this.landing = !this.landing;
| 334| 334| 

binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 182| »   »   »   var·targetHeight·=·ground·+·(+this.template.FlyingHeight);
|    | [NORMAL] JSHintBear:
|    | 'targetHeight' is already defined.

binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 297| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1205/display/redirect

Vulcan added a comment.Dec 6 2019, 1:22 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/690/display/redirect

Vulcan added a comment.Dec 6 2019, 1:28 PM

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 101| 101| 				this.pitch = 0;
| 102| 102| 				// We've stopped.
| 103| 103| 				if (cmpGarrisonHolder)
| 104|    |-					cmpGarrisonHolder.AllowGarrisoning(true,"UnitMotionFlying");
|    | 104|+					cmpGarrisonHolder.AllowGarrisoning(true, "UnitMotionFlying");
| 105| 105| 				canTurn = false;
| 106| 106| 				this.hasTarget = false;
| 107| 107| 				this.landing = false;
|    | [NORMAL] ESLintBear (space-unary-ops):
|    | Unexpected space after unary operator '-'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 138| 138| 			var targetHeight = ground;
| 139| 139| 			// Steep, then gradual descent.
| 140| 140| 			if ((pos.y - targetHeight) / this.template.FlyingHeight > 1 / SHORT_FINAL)
| 141|    |-				this.pitch = - Math.PI / 18;
|    | 141|+				this.pitch = -Math.PI / 18;
| 142| 142| 			else
| 143| 143| 				this.pitch = Math.PI / 18;
| 144| 144| 			var descentRate = ((pos.y - targetHeight) / this.template.FlyingHeight * this.template.ClimbRate + SHORT_FINAL) * SHORT_FINAL;
|    | [NORMAL] ESLintBear (comma-spacing):
|    | A space is required after ','.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 163| 163| 		if (this.speed < this.template.TakeoffSpeed && this.onGround)
| 164| 164| 		{
| 165| 165| 			if (cmpGarrisonHolder)
| 166|    |-				cmpGarrisonHolder.AllowGarrisoning(false,"UnitMotionFlying");
|    | 166|+				cmpGarrisonHolder.AllowGarrisoning(false, "UnitMotionFlying");
| 167| 167| 			this.pitch = 0;
| 168| 168| 			// Accelerate forwards
| 169| 169| 			this.speed = Math.min(this.template.MaxSpeed, this.speed + turnLength * this.template.AccelRate);
|    | [NORMAL] ESLintBear (space-unary-ops):
|    | Unexpected space after unary operator '-'.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 230| 230| 		if (newangle - angle > Math.PI / 18)
| 231| 231| 			this.roll = Math.PI / 9;
| 232| 232| 		else if (newangle - angle < -Math.PI / 18)
| 233|    |-			this.roll = - Math.PI / 9;
|    | 233|+			this.roll = -Math.PI / 9;
| 234| 234| 		else
| 235| 235| 			this.roll = newangle - angle;
| 236| 236| 	}
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 294| 294| UnitMotionFlying.prototype.IsMoveRequested = function()
| 295| 295| {
| 296| 296| 	return this.hasTarget;
| 297|    |-}
|    | 297|+};
| 298| 298| 
| 299| 299| UnitMotionFlying.prototype.GetCurrentSpeed = function()
| 300| 300| {
|    | [NORMAL] ESLintBear (spaced-comment):
|    | Expected space or tab after '//' in comment.
|----|    | /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
|    |++++| /zpool0/trunk/binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 328| 328| 
| 329| 329| UnitMotionFlying.prototype.StopMoving = function()
| 330| 330| {
| 331|    |-	//Invert
|    | 331|+	// Invert
| 332| 332| 	if (!this.waterDeath)
| 333| 333| 		this.landing = !this.landing;
| 334| 334| 

binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 182| »   »   »   var·targetHeight·=·ground·+·(+this.template.FlyingHeight);
|    | [NORMAL] JSHintBear:
|    | 'targetHeight' is already defined.

binaries/data/mods/public/simulation/components/UnitMotionFlying.js
| 297| }
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1206/display/redirect

This revision was not accepted when it landed; it landed in state Needs Review.Dec 6 2019, 6:36 PM
This revision was automatically updated to reflect the committed changes.