Gradually adding support for all features

This commit is contained in:
Pavel Shevaev 2022-12-07 16:39:53 +03:00
parent a9e4265c19
commit d9ea902c9b
1 changed files with 58 additions and 1 deletions

View File

@ -490,7 +490,18 @@ public class {{o.name}} : IRpc
{
bool is_equal = true;
$compare_fn_str
{%- if has_token(o, 'bitfields') ~%}
a.ResetFieldMask();
{%- endif -%}
{%- for f in o.fields ~%}
{{_self.field_compare(o, f, loop.index0)}}
{%- endfor -%}
{%- if has_token(o, 'bitfields') ~%}
if(!is_equal)
a.SetPrimaryFieldsChanged();
{%- endif -%}
return is_equal;
}
@ -501,6 +512,52 @@ public class {{o.name}} : IRpc
{{has_token(u, 'bitfields')?'CompareAndMarkFields':'IsEqual'}}
{% endmacro %}
{%- macro field_compare(o, f, field_idx) -%}
{% if f.type is instanceof('\\mtgArrType') ~%}
if(a.{{f.name}} == null ||
b.{{f.name}} == null ||
a.{{f.name}}.Count != b.{{f.name}}.Count)
return false;
for(int i=0;i<a.{{f.name}}.Count;++i)
{
{%- if f.type.value is instanceof('\\mtgMetaStruct') ~%}
if(!IsEqual(ref a.{{f.name}}[i], b.{{f.name}}[i]))
return false;
{%- else -%}
if(a.{{f.name}}[i] != b.{{f.name}}[i])
return false;
{%- endif -%}
}
{% elseif f.type is instanceof('\\mtgMetaStruct') ~%}
if(!IsEqual(ref a.{{f.name}}, b.{{f.name}}))
return false;
{% elseif f.type is instanceof('\\mtgBuiltinType') and f.type.isstring ~%}
if((a.{{f.name}} == null ? "" : a.{{f.name}})
!= (b.{{f.name}} == null ? "" : b.{{f.name}}))
{% if has_token(o, 'bitfields') ~%}
{
Meta.SetFieldDirty(ref a.fields_mask, {{field_idx}});
is_equal = false;
}
{% else ~%}
return false;
{%- endif -%}
{% else ~%}
if(a.{{f.name}} != b.{{f.name}}))
{% if has_token(o, 'bitfields') ~%}
{
Meta.SetFieldDirty(ref a.fields_mask, {{field_idx}});
is_equal = false;
}
{% else ~%}
return false;
{%- endif -%}
{%- endif -%}
{% endmacro %}
{%- macro field_diff(f, field_idx) -%}
{% if f.type is instanceof('\\mtgMetaStruct') %}