1
0
forked from mirrors/0ad

Fix UnitmotionFlying and implement CMessageMotionUpdate::FromJSVal

In 32e8ed51aa 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.
Also reported at this thread:
https://wildfiregames.com/forum/index.php?/topic/27294-cheats-error/

Differential Revision: https://code.wildfiregames.com/D2450
Tested by: @gameboy
Tested on: Jenkins/vs2015, Jenkins/gcc6
Fixes: #5626

This was SVN commit r23208.
This commit is contained in:
Angen
2019-12-06 17:36:25 +00:00
parent 53d00a63bb
commit a3941e8cca
2 changed files with 18 additions and 3 deletions
@@ -203,7 +203,7 @@ UnitMotionFlying.prototype.OnUpdate = function(msg)
if (!this.reachedTarget && this.targetMinRange <= distFromTarget && distFromTarget <= this.targetMaxRange)
{
this.reachedTarget = true;
Engine.PostMessage(this.entity, MT_MotionChanged, { "starting": false, "error": false });
Engine.PostMessage(this.entity, MT_MotionUpdate, { "updateString": "likelySuccess" });
}
// If we're facing away from the target, and are still fairly close to it,
@@ -291,6 +291,11 @@ UnitMotionFlying.prototype.GetRunMultiplier = function()
return 1;
};
UnitMotionFlying.prototype.IsMoveRequested = function()
{
return this.hasTarget;
};
UnitMotionFlying.prototype.GetCurrentSpeed = function()
{
return this.speed;
@@ -281,9 +281,19 @@ JS::Value CMessageMotionUpdate::ToJSVal(const ScriptInterface& scriptInterface)
return JS::ObjectValue(*obj);
}
CMessage* CMessageMotionUpdate::FromJSVal(const ScriptInterface&, JS::HandleValue)
CMessage* CMessageMotionUpdate::FromJSVal(const ScriptInterface& scriptInterface, JS::HandleValue val)
{
LOGWARNING("CMessageMotionUpdate::FromJSVal not implemented");
FROMJSVAL_SETUP();
GET_MSG_PROPERTY(std::wstring, updateString);
if (updateString == L"likelySuccess")
return new CMessageMotionUpdate(CMessageMotionUpdate::LIKELY_SUCCESS);
if (updateString == L"likelyFailure")
return new CMessageMotionUpdate(CMessageMotionUpdate::LIKELY_FAILURE);
if (updateString == L"obstructed")
return new CMessageMotionUpdate(CMessageMotionUpdate::OBSTRUCTED);
LOGWARNING("CMessageMotionUpdate::FromJSVal passed wrong updateString");
return NULL;
}