From 9c98901a2d80edef656e98a6cd21dab2f1093721 Mon Sep 17 00:00:00 2001 From: Alina Lenk Date: Sun, 4 Sep 2022 16:56:19 +0200 Subject: [PATCH] generate_packets.py: Don't automatically add handle-via-packets See osdn#45567 Requested by Marko Lindqvist Signed-off-by: Alina Lenk --- common/generate_packets.py | 3 - common/networking/packets.def | 124 +++++++++++++++++----------------- 2 files changed, 62 insertions(+), 65 deletions(-) diff --git a/common/generate_packets.py b/common/generate_packets.py index 4af087e5ce..a76603a9a0 100755 --- a/common/generate_packets.py +++ b/common/generate_packets.py @@ -2248,9 +2248,6 @@ class Packet: if self.want_dsend: raise ValueError("requested dsend for %s without fields isn't useful" % self.name) - if len(self.fields)>5 or self.name.split("_")[1]=="ruleset": - self.handle_via_packet = True - # create cap variants all_caps = self.all_caps # valid, since self.fields is already set self.variants = [ diff --git a/common/networking/packets.def b/common/networking/packets.def index 8bdd1a1c1e..6b8ff227f7 100644 --- a/common/networking/packets.def +++ b/common/networking/packets.def @@ -114,8 +114,8 @@ Syntax: handle-via-packet: force the packet type of the handle function. Otherwise the fields are passed to the handle function. - This is invoked automatically for packets with more than 5 fields - or packets whose names are of the form foo_ruleset. + This should usually be given for packets with more than ~5 fields, + and is generally also used for all ruleset packets. handle-per-conn: normally the first parameter of the handle function is the player. handle-per-conn changes this to the @@ -451,7 +451,7 @@ end # greatly. Packet spam from excess sending of tiles has slowed the client # greatly in the past. However see the comment on is-game-info at the top # about the dangers. -PACKET_TILE_INFO = 15; sc, lsend, is-game-info +PACKET_TILE_INFO = 15; sc, lsend, is-game-info, handle-via-packet TILE tile; key CONTINENT continent; @@ -470,7 +470,7 @@ PACKET_TILE_INFO = 15; sc, lsend, is-game-info end # The variables in the packet are listed in alphabetical order. -PACKET_GAME_INFO = 16; sc, is-info +PACKET_GAME_INFO = 16; sc, is-info, handle-via-packet UINT8 add_to_size_limit; PLAYER aifill; PERSISTENT_READY persistent_ready; @@ -625,7 +625,7 @@ PACKET_TIMEOUT_INFO = 244; sc SFLOAT10x3 last_turn_change_time; end -PACKET_MAP_INFO = 17; sc, lsend +PACKET_MAP_INFO = 17; sc, lsend, handle-via-packet XYSIZE xsize; XYSIZE ysize; UINT8 topology_id; @@ -653,7 +653,7 @@ end /* This MUST have identical structure to PACKET_EARLY_CHAT_MSG as there's casting * the two. */ -PACKET_CHAT_MSG = 25; sc, lsend +PACKET_CHAT_MSG = 25; sc, lsend, handle-via-packet STRING message[MAX_LEN_MSG]; TILE tile; EVENT event; @@ -664,7 +664,7 @@ end /* This MUST have identical structure to PACKET_CHAT_MSG as there's casting * the two. */ -PACKET_EARLY_CHAT_MSG = 28; sc, lsend +PACKET_EARLY_CHAT_MSG = 28; sc, lsend, handle-via-packet STRING message[MAX_LEN_MSG]; TILE tile; EVENT event; @@ -693,7 +693,7 @@ PACKET_CITY_REMOVE = 30; sc, dsend, lsend, cancel(PACKET_CITY_INFO), cancel(PACK CITY city_id; end -PACKET_CITY_INFO = 31; sc, lsend, is-game-info, force, cancel(PACKET_CITY_SHORT_INFO) +PACKET_CITY_INFO = 31; sc, lsend, is-game-info, force, cancel(PACKET_CITY_SHORT_INFO), handle-via-packet CITY id; key TILE tile; @@ -770,7 +770,7 @@ PACKET_CITY_INFO = 31; sc, lsend, is-game-info, force, cancel(PACKET_CITY_SHORT_ UNIT_ORDER rally_point_orders[MAX_LEN_ROUTE:rally_point_length]; end -PACKET_CITY_SHORT_INFO = 32; sc, lsend, is-game-info, cancel(PACKET_CITY_INFO), cancel(PACKET_WEB_CITY_INFO_ADDITION) +PACKET_CITY_SHORT_INFO = 32; sc, lsend, is-game-info, cancel(PACKET_CITY_INFO), cancel(PACKET_WEB_CITY_INFO_ADDITION), handle-via-packet CITY id; key TILE tile; @@ -895,7 +895,7 @@ PACKET_PLAYER_REMOVE = 50; sc, dsend, cancel(PACKET_PLAYER_INFO) PLAYER playerno; end -PACKET_PLAYER_INFO = 51; sc, is-info +PACKET_PLAYER_INFO = 51; sc, is-info, handle-via-packet PLAYER playerno; key STRING name[MAX_LEN_NAME]; STRING username[MAX_LEN_NAME]; @@ -981,7 +981,7 @@ PACKET_PLAYER_ATTRIBUTE_CHUNK = 58; pre-send, sc, cs, handle-via-packet MEMORY data[ATTRIBUTE_CHUNK_SIZE:chunk_length]; end -PACKET_PLAYER_DIPLSTATE = 59; sc +PACKET_PLAYER_DIPLSTATE = 59; sc, handle-via-packet UINT32 diplstate_id; key PLAYER plr1; PLAYER plr2; @@ -998,7 +998,7 @@ end /************** Research packets **********************/ -PACKET_RESEARCH_INFO = 60; sc, lsend, is-game-info +PACKET_RESEARCH_INFO = 60; sc, lsend, is-game-info, handle-via-packet RESEARCH id; key UINT32 techs_researched; UINT16 future_tech; @@ -1024,7 +1024,7 @@ PACKET_UNIT_REMOVE = 62; sc, dsend, lsend, cancel(PACKET_UNIT_INFO), cancel(PACK UNIT unit_id; end -PACKET_UNIT_INFO = 63; sc, lsend, is-game-info, cancel(PACKET_UNIT_SHORT_INFO) +PACKET_UNIT_INFO = 63; sc, lsend, is-game-info, cancel(PACKET_UNIT_SHORT_INFO), handle-via-packet UNIT id; key PLAYER owner; PLAYER nationality; @@ -1064,7 +1064,7 @@ PACKET_UNIT_INFO = 63; sc, lsend, is-game-info, cancel(PACKET_UNIT_SHORT_INFO) TILE action_decision_tile; end -PACKET_UNIT_SHORT_INFO = 64; sc, lsend, is-game-info, force, cancel(PACKET_UNIT_INFO) +PACKET_UNIT_SHORT_INFO = 64; sc, lsend, is-game-info, force, cancel(PACKET_UNIT_INFO), handle-via-packet UNIT id; key PLAYER owner; TILE tile; @@ -1084,7 +1084,7 @@ PACKET_UNIT_SHORT_INFO = 64; sc, lsend, is-game-info, force, cancel(PACKET_UNIT_ and UNIT_INFO_CITY_PRESENT uses */ end -PACKET_UNIT_COMBAT_INFO = 65; sc, lsend +PACKET_UNIT_COMBAT_INFO = 65; sc, lsend, handle-via-packet UNIT attacker_unit_id; UNIT defender_unit_id; HP attacker_hp; @@ -1100,7 +1100,7 @@ PACKET_UNIT_SSCS_SET = 71; cs, dsend end # used for client orders: currently client-side goto and patrol -PACKET_UNIT_ORDERS = 73; cs +PACKET_UNIT_ORDERS = 73; cs, handle-via-packet UNIT unit_id; TILE src_tile; # Origin tile, included for sanity checking @@ -1153,7 +1153,7 @@ PACKET_UNIT_GET_ACTIONS = 87; cs, handle-per-conn, dsend UINT8 request_kind; end -PACKET_UNIT_ACTIONS = 90; sc, dsend +PACKET_UNIT_ACTIONS = 90; sc, dsend, handle-via-packet UNIT actor_unit_id; UNIT target_unit_id; CITY target_city_id; @@ -1253,7 +1253,7 @@ end # For telling clients information about other connections to server. # Clients may not use all info, but supply now to avoid unnecessary # protocol changes later. -PACKET_CONN_INFO = 115; sc, lsend, is-info +PACKET_CONN_INFO = 115; sc, lsend, is-info, handle-via-packet CONNECTION id; key # 0 means client should forget its @@ -1347,7 +1347,7 @@ PACKET_SPACESHIP_PLACE = 136; cs, dsend UINT8 num; end -PACKET_SPACESHIP_INFO = 137; sc, lsend, is-game-info +PACKET_SPACESHIP_INFO = 137; sc, lsend, is-game-info, handle-via-packet PLAYER player_num; key UINT8 sship_state; UINT8 structurals; @@ -1370,7 +1370,7 @@ end /************** Ruleset packets **********************/ -PACKET_RULESET_UNIT = 140; sc, lsend +PACKET_RULESET_UNIT = 140; sc, lsend, handle-via-packet UNIT_TYPE id; STRING name[MAX_LEN_NAME]; STRING rule_name[MAX_LEN_NAME]; @@ -1430,7 +1430,7 @@ PACKET_RULESET_UNIT = 140; sc, lsend BOOL worker; end -PACKET_RULESET_UNIT_BONUS = 228; sc, lsend +PACKET_RULESET_UNIT_BONUS = 228; sc, lsend, handle-via-packet UNIT_TYPE unit; UTYF flag; CBONUS_TYPE type; @@ -1438,19 +1438,19 @@ PACKET_RULESET_UNIT_BONUS = 228; sc, lsend BOOL quiet; end -PACKET_RULESET_UNIT_FLAG = 229; sc, lsend +PACKET_RULESET_UNIT_FLAG = 229; sc, lsend, handle-via-packet UINT8 id; STRING name[MAX_LEN_NAME]; STRING helptxt[MAX_LEN_PACKET]; end -PACKET_RULESET_UNIT_CLASS_FLAG = 230; sc, lsend +PACKET_RULESET_UNIT_CLASS_FLAG = 230; sc, lsend, handle-via-packet UINT8 id; STRING name[MAX_LEN_NAME]; STRING helptxt[MAX_LEN_PACKET]; end -PACKET_RULESET_GAME = 141; sc, lsend +PACKET_RULESET_GAME = 141; sc, lsend, handle-via-packet UINT8 default_specialist; UINT8 global_init_techs_count; @@ -1470,7 +1470,7 @@ PACKET_RULESET_GAME = 141; sc, lsend UINT8 background_blue; end -PACKET_RULESET_SPECIALIST = 142; sc, lsend +PACKET_RULESET_SPECIALIST = 142; sc, lsend, handle-via-packet SPECIALIST id; STRING plural_name[MAX_LEN_NAME]; @@ -1486,14 +1486,14 @@ PACKET_RULESET_SPECIALIST = 142; sc, lsend STRVEC helptext[MAX_LEN_PACKET]; end -PACKET_RULESET_GOVERNMENT_RULER_TITLE = 143; sc, lsend +PACKET_RULESET_GOVERNMENT_RULER_TITLE = 143; sc, lsend, handle-via-packet GOVERNMENT gov; NATION nation; STRING male_title[MAX_LEN_NAME]; STRING female_title[MAX_LEN_NAME]; end -PACKET_RULESET_TECH = 144; sc, lsend +PACKET_RULESET_TECH = 144; sc, lsend, handle-via-packet TECH id; TECH root_req; UINT8 research_reqs_count; @@ -1510,20 +1510,20 @@ PACKET_RULESET_TECH = 144; sc, lsend STRING graphic_alt[MAX_LEN_NAME]; end -PACKET_RULESET_TECH_CLASS = 9; sc, lsend +PACKET_RULESET_TECH_CLASS = 9; sc, lsend, handle-via-packet UINT16 id; STRING name[MAX_LEN_NAME]; STRING rule_name[MAX_LEN_NAME]; UINT16 cost_pct; end -PACKET_RULESET_TECH_FLAG = 234; sc, lsend +PACKET_RULESET_TECH_FLAG = 234; sc, lsend, handle-via-packet UINT8 id; STRING name[MAX_LEN_NAME]; STRING helptxt[MAX_LEN_PACKET]; end -PACKET_RULESET_GOVERNMENT = 145; sc, lsend +PACKET_RULESET_GOVERNMENT = 145; sc, lsend, handle-via-packet GOVERNMENT id; UINT8 reqs_count; @@ -1536,7 +1536,7 @@ PACKET_RULESET_GOVERNMENT = 145; sc, lsend STRVEC helptext[MAX_LEN_PACKET]; end -PACKET_RULESET_TERRAIN_CONTROL = 146; sc, lsend +PACKET_RULESET_TERRAIN_CONTROL = 146; sc, lsend, handle-via-packet UINT8 ocean_reclaim_requirement_pct; /* # adjacent land tiles for reclaim */ UINT8 land_channel_requirement_pct; /* # adjacent ocean tiles for channel */ UINT8 terrain_thaw_requirement_pct; /* # adjacent unfrozen tiles for thaw */ @@ -1554,7 +1554,7 @@ end PACKET_RULESETS_READY = 225; sc, lsend end -PACKET_RULESET_NATION_SETS = 236; sc, lsend +PACKET_RULESET_NATION_SETS = 236; sc, lsend, handle-via-packet UINT8 nsets; STRING names[MAX_NUM_NATION_SETS:nsets][MAX_LEN_NAME]; STRING rule_names[MAX_NUM_NATION_SETS:nsets][MAX_LEN_NAME]; @@ -1563,13 +1563,13 @@ PACKET_RULESET_NATION_SETS = 236; sc, lsend STRING descriptions[MAX_NUM_NATION_SETS:nsets][MAX_LEN_MSG]; /*untranslated*/ end -PACKET_RULESET_NATION_GROUPS = 147; sc, lsend +PACKET_RULESET_NATION_GROUPS = 147; sc, lsend, handle-via-packet UINT8 ngroups; STRING groups[MAX_NUM_NATION_GROUPS:ngroups][MAX_LEN_NAME]; BOOL hidden[MAX_NUM_NATION_GROUPS:ngroups]; end -PACKET_RULESET_NATION = 148; sc, lsend +PACKET_RULESET_NATION = 148; sc, lsend, handle-via-packet NATION id; key STRING translation_domain[MAX_LEN_NAME]; @@ -1613,13 +1613,13 @@ PACKET_NATION_AVAILABILITY = 237; sc, lsend BOOL nationset_change; end -PACKET_RULESET_STYLE = 239; sc, lsend +PACKET_RULESET_STYLE = 239; sc, lsend, handle-via-packet UINT8 id; STRING name[MAX_LEN_NAME]; STRING rule_name[MAX_LEN_NAME]; end -PACKET_RULESET_CITY = 149; sc, lsend +PACKET_RULESET_CITY = 149; sc, lsend, handle-via-packet UINT8 style_id; STRING name[MAX_LEN_NAME]; STRING rule_name[MAX_LEN_NAME]; @@ -1630,7 +1630,7 @@ PACKET_RULESET_CITY = 149; sc, lsend STRING graphic_alt[MAX_LEN_NAME]; end -PACKET_RULESET_BUILDING = 150; sc, lsend +PACKET_RULESET_BUILDING = 150; sc, lsend, handle-via-packet IMPROVEMENT id; IMPR_GENUS genus; STRING name[MAX_LEN_NAME]; @@ -1649,7 +1649,7 @@ PACKET_RULESET_BUILDING = 150; sc, lsend STRVEC helptext[MAX_LEN_PACKET]; end -PACKET_RULESET_TERRAIN = 151; sc, lsend +PACKET_RULESET_TERRAIN = 151; sc, lsend, handle-via-packet TERRAIN id; UINT8 tclass; @@ -1701,13 +1701,13 @@ PACKET_RULESET_TERRAIN = 151; sc, lsend STRVEC helptext[MAX_LEN_PACKET]; end -PACKET_RULESET_TERRAIN_FLAG = 231; sc, lsend +PACKET_RULESET_TERRAIN_FLAG = 231; sc, lsend, handle-via-packet UINT8 id; STRING name[MAX_LEN_NAME]; STRING helptxt[MAX_LEN_PACKET]; end -PACKET_RULESET_UNIT_CLASS = 152; sc, lsend +PACKET_RULESET_UNIT_CLASS = 152; sc, lsend, handle-via-packet UINT8 id; STRING name[MAX_LEN_NAME]; STRING rule_name[MAX_LEN_NAME]; @@ -1719,7 +1719,7 @@ PACKET_RULESET_UNIT_CLASS = 152; sc, lsend STRVEC helptext[MAX_LEN_PACKET]; end -PACKET_RULESET_EXTRA = 232; sc, lsend +PACKET_RULESET_EXTRA = 232; sc, lsend, handle-via-packet UINT8 id; STRING name[MAX_LEN_NAME]; STRING rule_name[MAX_LEN_NAME]; @@ -1762,13 +1762,13 @@ PACKET_RULESET_EXTRA = 232; sc, lsend STRVEC helptext[MAX_LEN_PACKET]; end -PACKET_RULESET_EXTRA_FLAG = 226; sc, lsend +PACKET_RULESET_EXTRA_FLAG = 226; sc, lsend, handle-via-packet UINT8 id; STRING name[MAX_LEN_NAME]; STRING helptxt[MAX_LEN_PACKET]; end -PACKET_RULESET_BASE = 153; sc, lsend +PACKET_RULESET_BASE = 153; sc, lsend, handle-via-packet UINT8 id; BASE_GUI gui_type; SINT8 border_sq; @@ -1777,7 +1777,7 @@ PACKET_RULESET_BASE = 153; sc, lsend SINT8 vision_subs_sq; end -PACKET_RULESET_ROAD = 220; sc, lsend +PACKET_RULESET_ROAD = 220; sc, lsend, handle-via-packet UINT8 id; ROAD_GUI gui_type; UINT8 first_reqs_count; @@ -1792,7 +1792,7 @@ PACKET_RULESET_ROAD = 220; sc, lsend BV_ROAD_FLAGS flags; end -PACKET_RULESET_GOODS = 248; sc, lsend +PACKET_RULESET_GOODS = 248; sc, lsend, handle-via-packet UINT8 id; STRING name[MAX_LEN_NAME]; STRING rule_name[MAX_LEN_NAME]; @@ -1805,7 +1805,7 @@ PACKET_RULESET_GOODS = 248; sc, lsend STRVEC helptext[MAX_LEN_PACKET]; end -PACKET_RULESET_DISASTER = 224; sc, lsend +PACKET_RULESET_DISASTER = 224; sc, lsend, handle-via-packet UINT8 id; STRING name[MAX_LEN_NAME]; STRING rule_name[MAX_LEN_NAME]; @@ -1815,7 +1815,7 @@ PACKET_RULESET_DISASTER = 224; sc, lsend BV_DISASTER_EFFECTS effects; end -PACKET_RULESET_ACHIEVEMENT = 233; sc, lsend +PACKET_RULESET_ACHIEVEMENT = 233; sc, lsend, handle-via-packet UINT8 id; STRING name[MAX_LEN_NAME]; STRING rule_name[MAX_LEN_NAME]; @@ -1824,14 +1824,14 @@ PACKET_RULESET_ACHIEVEMENT = 233; sc, lsend UINT16 value; end -PACKET_RULESET_TRADE = 227; sc, lsend +PACKET_RULESET_TRADE = 227; sc, lsend, handle-via-packet UINT8 id; UINT16 trade_pct; TRI cancelling; TR_BONUS_TYPE bonus_type; end -PACKET_RULESET_ACTION = 246; sc, lsend +PACKET_RULESET_ACTION = 246; sc, lsend, handle-via-packet ACTION_ID id; STRING ui_name[MAX_LEN_NAME]; @@ -1850,7 +1850,7 @@ PACKET_RULESET_ACTION = 246; sc, lsend BV_ACTIONS blocked_by; end -PACKET_RULESET_ACTION_ENABLER = 235; sc, lsend +PACKET_RULESET_ACTION_ENABLER = 235; sc, lsend, handle-via-packet ACTION_ID enabled_action; UINT8 actor_reqs_count; REQUIREMENT actor_reqs[MAX_NUM_REQS:actor_reqs_count]; @@ -1858,7 +1858,7 @@ PACKET_RULESET_ACTION_ENABLER = 235; sc, lsend REQUIREMENT target_reqs[MAX_NUM_REQS:target_reqs_count]; end -PACKET_RULESET_ACTION_AUTO = 252; sc, lsend +PACKET_RULESET_ACTION_AUTO = 252; sc, lsend, handle-via-packet UINT8 id; ACTION_AUTO_CAUSE cause; @@ -1869,7 +1869,7 @@ PACKET_RULESET_ACTION_AUTO = 252; sc, lsend ACTION_ID alternatives[MAX_NUM_ACTIONS:alternatives_count]; end -PACKET_RULESET_MUSIC = 240; sc, lsend +PACKET_RULESET_MUSIC = 240; sc, lsend, handle-via-packet UINT8 id; STRING music_peaceful[MAX_LEN_NAME]; STRING music_combat[MAX_LEN_NAME]; @@ -1877,7 +1877,7 @@ PACKET_RULESET_MUSIC = 240; sc, lsend REQUIREMENT reqs[MAX_NUM_REQS:reqs_count]; end -PACKET_RULESET_MULTIPLIER = 243; sc, dsend, lsend +PACKET_RULESET_MULTIPLIER = 243; sc, dsend, lsend, handle-via-packet MULTIPLIER id; SINT32 start; SINT32 stop; @@ -1893,7 +1893,7 @@ PACKET_RULESET_MULTIPLIER = 243; sc, dsend, lsend STRVEC helptext[MAX_LEN_PACKET]; end -PACKET_RULESET_CLAUSE = 512; sc, lsend +PACKET_RULESET_CLAUSE = 512; sc, lsend, handle-via-packet CLAUSE type; BOOL enabled; UINT8 giver_reqs_count; @@ -1908,7 +1908,7 @@ end other part of the rulesets. (Terrain ruleset has enough info for its own "control" packet, done separately.) **************************************************************************/ -PACKET_RULESET_CONTROL = 155; sc, lsend +PACKET_RULESET_CONTROL = 155; sc, lsend, handle-via-packet UINT16 num_unit_classes; UINT16 num_unit_types; UINT16 num_impr_types; @@ -1942,11 +1942,11 @@ PACKET_RULESET_CONTROL = 155; sc, lsend UINT16 num_counters; end -PACKET_RULESET_SUMMARY = 251; sc, lsend +PACKET_RULESET_SUMMARY = 251; sc, lsend, handle-via-packet STRING text[MAX_LEN_CONTENT]; end -PACKET_RULESET_DESCRIPTION_PART = 247; sc, lsend +PACKET_RULESET_DESCRIPTION_PART = 247; sc, lsend, handle-via-packet STRING text[MAX_LEN_CONTENT]; end @@ -1961,12 +1961,12 @@ PACKET_SINGLE_WANT_HACK_REPLY = 161; sc, dsend BOOL you_have_hack; end -PACKET_RULESET_CHOICES = 162; sc +PACKET_RULESET_CHOICES = 162; sc, handle-via-packet UINT8 ruleset_count; STRING rulesets[MAX_NUM_RULESETS:ruleset_count][MAX_RULESET_NAME_LENGTH]; end -PACKET_RULESET_SELECT = 171; cs, handle-per-conn +PACKET_RULESET_SELECT = 171; cs, handle-per-conn, handle-via-packet STRING modpack[MAX_RULESET_NAME_LENGTH]; end @@ -2059,7 +2059,7 @@ end /************** Effects hash packets **********************/ -PACKET_RULESET_EFFECT = 175; sc, lsend +PACKET_RULESET_EFFECT = 175; sc, lsend, handle-via-packet EFFECT_TYPE effect_type; SINT32 effect_value; BOOL has_multiplier; @@ -2069,7 +2069,7 @@ PACKET_RULESET_EFFECT = 175; sc, lsend REQUIREMENT reqs[MAX_NUM_REQS:reqs_count]; end -PACKET_RULESET_RESOURCE = 177; sc, lsend +PACKET_RULESET_RESOURCE = 177; sc, lsend, handle-via-packet UINT8 id; UINT8 output[O_LAST]; @@ -2284,7 +2284,7 @@ PACKET_EDIT_PLAYER_REMOVE = 215; cs, handle-per-conn, dsend PLAYER id; end -PACKET_EDIT_PLAYER = 216; cs, handle-per-conn, lsend +PACKET_EDIT_PLAYER = 216; cs, handle-per-conn, lsend, handle-via-packet PLAYER id; key STRING name[MAX_LEN_NAME]; STRING username[MAX_LEN_NAME]; -- 2.34.1