From d9ea902c9b79065470cdd4038006048e9129e280 Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Wed, 7 Dec 2022 16:39:53 +0300 Subject: [PATCH] Gradually adding support for all features --- tpl/macro.twig | 59 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/tpl/macro.twig b/tpl/macro.twig index d5f8c65..c0b53e5 100644 --- a/tpl/macro.twig +++ b/tpl/macro.twig @@ -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