From 66a9418da4ab8aba783437332707ca8c5f5df25c Mon Sep 17 00:00:00 2001 From: Alina Lenk Date: Fri, 1 Jul 2022 23:27:51 +0200 Subject: [PATCH 2/2] generate_packets.py: Remove no-packet flag See osdn#44975 Signed-off-by: Alina Lenk --- common/generate_packets.py | 13 ++++++++----- common/networking/packets.def | 3 --- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/common/generate_packets.py b/common/generate_packets.py index fb51ab235a..819b930716 100755 --- a/common/generate_packets.py +++ b/common/generate_packets.py @@ -1689,9 +1689,6 @@ class Packet: self.delta="no-delta" not in arr if not self.delta: arr.remove("no-delta") - self.no_packet="no-packet" in arr - if self.no_packet: arr.remove("no-packet") - self.handle_via_packet="handle-via-packet" in arr if self.handle_via_packet: arr.remove("handle-via-packet") @@ -1731,9 +1728,9 @@ class Packet: self.key_fields = [field for field in self.fields if field.is_key] self.other_fields = [field for field in self.fields if not field.is_key] - if len(self.fields)==0: + # valid, since self.fields is already set + if self.no_packet: self.delta = False - self.no_packet = True if self.want_dsend: raise ValueError("requested dsend for %s without fields isn't useful" % self.name) @@ -1762,6 +1759,12 @@ class Packet: """Snake-case name of this packet type""" return self.type.lower() + @property + def no_packet(self) -> bool: + """Whether this packet's send functions should take no packet + argument. This is the case iff this packet has no fields.""" + return not self.fields + @property def extra_send_args(self) -> str: """Argements for the regular send function""" diff --git a/common/networking/packets.def b/common/networking/packets.def index 7eb3808ef8..68711c2ebc 100644 --- a/common/networking/packets.def +++ b/common/networking/packets.def @@ -106,9 +106,6 @@ Syntax: (packet_req_join_game). Sadly this also disables the use of 0 as the default value. - no-packet: don't generate a packet argument for the send - function. Currently only used by packet_generic_empty. - no-handle: don't generate handle_* prototypes. The generated switch statements (server/hand_gen.c, client/packhand_gen.c) doesn't include code for this packet. You have to handle this by -- 2.34.1