1
0
forked from 0ad/0ad

Fix 9fc6c3c897 - Set entity/template before deserializing.

Following 9fc6c3c897, components Deserialize() was called before
entity/template were set, which is incorrect.

Refs #4698.

Differential Revision: https://code.wildfiregames.com/D3337
This was SVN commit r24561.
This commit is contained in:
wraitii 2021-01-12 16:15:40 +00:00
parent a3c810b5eb
commit 78764926f8
2 changed files with 12 additions and 3 deletions

View File

@ -87,8 +87,18 @@ function TestScript1_consts() {}
TestScript1_consts.prototype.Schema = "<ref name='anything'/>";
TestScript1_consts.prototype.Init = function() {
this.cached = (+this.entity) + (+this.template.x);
};
TestScript1_consts.prototype.Serialize = null;
TestScript1_consts.prototype.Deserialize = function(data) {
this.Init();
};
TestScript1_consts.prototype.GetX = function() {
return (+this.entity) + (+this.template.x);
return this.cached;
};
Engine.RegisterComponentType(IID_Test1, "TestScript1_consts", TestScript1_consts);

View File

@ -62,9 +62,8 @@ void CComponentTypeScript::Deserialize(const CParamNode& paramNode, IDeserialize
{
ScriptRequest rq(m_ScriptInterface);
deserialize.ScriptObjectAssign("comp", m_Instance);
m_ScriptInterface.SetProperty(m_Instance, "entity", (int)ent, true, false);
m_ScriptInterface.SetProperty(m_Instance, "template", paramNode, true, false);
deserialize.ScriptObjectAssign("comp", m_Instance);
}