Project

General

Profile

Bug #483 » 0002-generate_packets.py-always-transmit-new-elements-in-.patch

main v2 - Alina Lenk, 04/21/2024 02:02 PM

View differences:

common/generate_packets.py
"""Helper method. Generate array-diff put code."""
# we're nesting two levels deep in the JSON structure
sub = location.sub_full(2)
inner_put = prefix(" ", self.elem.get_code_put(sub, True))
# Note: At the moment, we're only deep-diffing our elements
# if our array size is constant
inner_put = prefix(" ", self.elem.get_code_put(sub, self.size.constant))
inner_cmp = prefix(" ", self.elem.get_code_cmp(sub))
index_put = prefix(" ", self.size.index_put(location.index))
index_put_sentinel = prefix(" ", self.size.index_put(self.size.real))
if not self.size.constant:
inner_cmp = f"""\
if ({location.index} < {self.size.old}) {{
{prefix(" ", inner_cmp)}\
}} else {{
/* Always transmit new elements */
differ = TRUE;
}}
"""
return f"""\
{self.size.size_check_index(location.name)}\
{{
common/networking/packets.def
diff: use the array-diff feature. This will reduce the amount of
traffic for large arrays in which only a few elements change.
Note that in multidemensional arrays, the individual sub-arrays
only get diff'd if the higher levels have constant length.
add-cap: only transfer this field if the given capability is
available at runtime. If you have a capability named
(2-2/2)