From fd80b392b65c776fb8dc67850199fb090a83339b Mon Sep 17 00:00:00 2001 From: Alina Lenk Date: Sat, 14 May 2022 21:20:40 +0200 Subject: [PATCH 11/12] generate_packets.py: format individual parts in Variant.get_receive() instead of concatenating format strings See osdn#44598 Signed-off-by: Alina Lenk --- common/generate_packets.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/common/generate_packets.py b/common/generate_packets.py index af56b6c8c5..4f30eb9000 100755 --- a/common/generate_packets.py +++ b/common/generate_packets.py @@ -1395,7 +1395,7 @@ static char *stats_{self.name}_names[] = {{{names}}}; struct %(packet_name)s *old; struct genhash **hash = pc->phs.received + %(type)s; #endif /* FREECIV_DELTA_PROTOCOL */ -''' +''' % self.__dict__ delta_body1=''' #ifdef FREECIV_DELTA_PROTOCOL #ifdef FREECIV_JSON_CONNECTION @@ -1405,9 +1405,9 @@ static char *stats_{self.name}_names[] = {{{names}}}; ''' body1="" for field in self.key_fields: - body1=body1+prefix(" ",field.get_get(1))+"\n" + body1 += prefix(" ", field.get_get(1) % self.__dict__) + "\n" body1=body1+"\n#else /* FREECIV_DELTA_PROTOCOL */\n" - body2=self.get_delta_receive_body() + body2 = self.get_delta_receive_body() % self.__dict__ else: delta_header="" delta_body1="" @@ -1415,18 +1415,18 @@ static char *stats_{self.name}_names[] = {{{names}}}; body2="" nondelta="" for field in self.fields: - nondelta=nondelta+prefix(" ",field.get_get(0))+"\n" + nondelta += prefix(" ", field.get_get(0) % self.__dict__) + "\n" if not nondelta: nondelta=" real_packet->__dummy = 0xff;" body1=body1+nondelta+"\n#endif\n" if self.gen_log: - log=' %(log_macro)s("%(name)s: got info about (%(keys_format)s)"%(keys_arg)s);\n' + log = ' %(log_macro)s("%(name)s: got info about (%(keys_format)s)"%(keys_arg)s);\n' % self.__dict__ else: log="" if self.want_post_recv: - post=" post_receive_%(packet_name)s(pc, real_packet);\n" + post = " post_receive_%(packet_name)s(pc, real_packet);\n" % self.__dict__ else: post="" @@ -1447,11 +1447,11 @@ static char *stats_{self.name}_names[] = {{{names}}}; """\ %(receive_prototype)s { -""", +""" % self.__dict__, delta_header, """\ RECEIVE_PACKET_START(%(packet_name)s, real_packet); -""", +""" % self.__dict__, faddr, delta_body1, body1, @@ -1463,7 +1463,7 @@ static char *stats_{self.name}_names[] = {{{names}}}; } """, - )) % self.get_dict(vars()) + )) # Helper for get_receive() def get_delta_receive_body(self): -- 2.17.1