mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user