/* Syntax: Comments: ========= Supported are: c-style (/ * * /), c++-style (//) and python style (#). Empty lines will be ignored. Typedef lines: ============== Start with "type" and have the format "type = ". You can now use at every place a type is expected. Nested type defs are possible. Packets: ======== They just start and end with a line only containing "end". Header line is: ";;". If packet-type isn't given the packet type is given as parameter. Flags is a comma seperated list of: Packet flags: ------------- is-info: a second packet with the same content can be discarded pre, post: call pre-send and post-receive hooks no-delta: don't use the delta protocol. This is useful for packets which contain always different data (packet_generic_integer) or are only sent once (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. Each other packet line has the format " ;". Type: ---- is an alias or a basic type. A basic type has the format "()". Exception here is the float type. You can specify with the dataio-type "float" the transmission of a float in a uint32 multiplied by this factor. Fields: ------- Comma seperated list of names. Each name can have zero, one or two array declarations. So "x", "x[10]" and "x[20][10]" is possible. The array size in the "[]" can be specified plain as a term. In this case all elements will be transmitted. If this is not-desired you can specify the amount of elements to be transfered by given the number. So the extenmded format is "[:]". elements-to-transfer is relative to the packet. Field flags: ------------ key: create multiple entries in the cache indexed by the key set (set of all fields which have the key attribute). This allow a better delta compression. */ type UINT8 = uint8(int) type UINT16 = uint16(int) type UINT32 = uint32(int) type SINT8 = sint8(int) type SINT16 = sint16(int) type SINT32 = sint32(int) type BOOL = bool8(bool) type FLOAT = float10000(float) type MEMORY = memory(unsigned char) type STRING = string(char) type BIT_STRING = bit_string(char) type CITY_MAP = city_map(char) type WORKLIST = worklist(struct worklist) type TECH_LIST = tech_list(int) type COORD = UINT8 type PLAYER = UINT8 type CITY = UINT16 type YEAR = SINT16 type UNIT = UINT16 type HP = UINT8 type PERCENT = UINT8 type TECH = UINT8 type UNIT_TYPE = uint8(Unit_Type_id) PACKET_PROCESSING_STARTED; sc end PACKET_PROCESSING_FINISHED; sc end # this packet is the very first packet send by the client. the player # hasn't been accepted yet. 'short_name' is the same as 'name', but # possibly truncated (can only add long name at end, to avoid problems # with connection to/from older versions) PACKET_SERVER_JOIN_REQ; no-delta, cs STRING name[MAX_LEN_NAME]; STRING capability[MAX_LEN_CAPSTR]; STRING version_label[MAX_LEN_NAME]; UINT32 major_version, minor_version, patch_version; end # ... and the server replies. PACKET_SERVER_JOIN_REPLY; no-delta, sc bool32(bool) you_can_join; STRING message[MAX_LEN_MSG]; STRING capability[MAX_LEN_CAPSTR]; # clients conn id as known in server UINT32 conn_id; end PACKET_SERVER_SHUTDOWN;sc end PACKET_NATIONS_SELECTED_INFO;sc UINT8 num_nations_used; uint16(Nation_Type_id) nations_used[MAX_NUM_PLAYERS:num_nations_used]; end PACKET_NATION_SELECT_REQ;cs uint32(Nation_Type_id) nation_no; STRING name[MAX_LEN_NAME]; BOOL is_male; UINT8 city_style; end PACKET_NATION_SELECT_OK;sc end PACKET_GAME_STATE;sc UINT32 value; end # send to each client whenever the turn has ended. PACKET_NEW_YEAR;sc YEAR year; UINT16 turn; end PACKET_TILE_INFO; is-info,sc COORD x,y; key UINT8 type, known; UINT16 special; end PACKET_GAME_INFO; is-info,sc UINT16 gold; UINT32 tech; UINT8 researchcost; UINT32 skill_level; UINT32 seconds_to_turndone; UINT32 turn; UINT32 timeout; YEAR year, end_year; PLAYER min_players, max_players, nplayers, player_idx; UINT32 globalwarming, heating, nuclearwinter, cooling; UINT8 cityfactor; UINT8 diplcost, freecost, conquercost; UINT8 unhappysize; UINT8 angrycitizen; UINT8 techpenalty; UINT8 foodbox; UINT8 civstyle; BOOL spacerace; UINT8 global_advances[A_LAST]; UINT16 global_wonders[B_LAST]; end PACKET_MAP_INFO; is-info,sc COORD xsize; COORD ysize; BOOL is_earth; end PACKET_CHAT_MSG;sc STRING message[MAX_LEN_MSG]; COORD x; COORD y; UINT32 event; end PACKET_CHAT_MSG_REQ;cs STRING message[MAX_LEN_MSG]; end PACKET_CITY_INFO; is-info,sc CITY id; key PLAYER owner; COORD x,y; STRING name[MAX_LEN_NAME]; UINT8 size; UINT8 ppl_happy[5], ppl_content[5], ppl_unhappy[5], ppl_angry[5]; UINT8 ppl_elvis, ppl_scientist, ppl_taxman; UINT16 food_prod, food_surplus, food_stock; UINT16 shield_prod, shield_surplus, shield_stock; UINT16 trade_prod, tile_trade, corruption; UINT16 trade[NUM_TRADEROUTES]; UINT8 trade_value[NUM_TRADEROUTES]; UINT16 luxury_total, tax_total, science_total; UINT16 pollution; UINT8 currently_building; BOOL is_building_unit; YEAR turn_last_built, turn_changed_target; UINT8 changed_from_id; BOOL changed_from_is_unit; UINT16 before_change_shields; UINT16 disbanded_shields; UINT16 caravan_shields; worklist(struct worklist) worklist; BIT_STRING improvements[B_LAST+1]; CITY_MAP city_map[CITY_MAP_SIZE*CITY_MAP_SIZE+1]; BOOL did_buy, did_sell, was_happy, airlift, diplomat_investigate; UINT8 city_options; UINT32 turn_founded; end PACKET_CITY_SHORT_INFO; is-info,sc CITY id;key PLAYER owner; COORD x; COORD y; STRING name[MAX_LEN_NAME]; UINT8 size; BOOL happy; BOOL capital; BOOL walls; UINT16 tile_trade; end PACKET_CITY_SELL;cs CITY city_id; UINT8 build_id; end PACKET_CITY_BUY;cs CITY city_id; end PACKET_CITY_CHANGE;cs CITY city_id; UINT8 build_id; BOOL is_build_id_unit_id; end PACKET_CITY_WORKLIST;cs CITY city_id; worklist(struct worklist) worklist; end PACKET_CITY_MAKE_SPECIALIST;cs CITY city_id; COORD worker_x, worker_y; end PACKET_CITY_MAKE_WORKER;cs CITY city_id; COORD worker_x, worker_y; end PACKET_CITY_CHANGE_SPECIALIST;cs CITY city_id; UINT8 from, to; end PACKET_CITY_RENAME;cs CITY city_id; STRING name[MAX_LEN_NAME]; end PACKET_PLAYER_INFO; is-info,sc PLAYER playerno; key STRING name[MAX_LEN_NAME]; BOOL is_male; UINT8 government; UINT32 embassy; UINT8 city_style; UINT8 nation; BOOL turn_done; UINT16 nturns_idle; BOOL is_alive; UINT32 reputation; diplstate(struct player_diplstate) diplstates[MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS]; UINT32 gold; UINT8 tax; UINT8 science; UINT8 luxury; UINT32 bulbs_researched; UINT32 techs_researched; UINT8 researching; UINT16 future_tech; UINT8 tech_goal; BOOL is_connected; UINT8 revolution; BOOL ai; UINT8 barbarian_type; uint32(unsigned int) gives_shared_vision; BIT_STRING inventions[A_LAST+1]; end PACKET_PLAYER_TURN_DONE;cs end PACKET_PLAYER_RATES;cs PERCENT tax; PERCENT luxury; PERCENT science; end PACKET_PLAYER_REVOLUTION;cs end PACKET_PLAYER_GOVERNMENT;cs UINT8 government; end PACKET_PLAYER_RESEARCH;cs TECH tech; end PACKET_PLAYER_TECH_GOAL;cs TECH tech; end PACKET_PLAYER_ATTRIBUTE_BLOCK;cs end PACKET_PLAYER_ATTRIBUTE_CHUNK; pre,post,sc,cs,handle-via-packet UINT32 offset, total_length, chunk_length; /* to keep memory management simple don't allocate dynamic memory */ MEMORY data[ATTRIBUTE_CHUNK_SIZE:chunk_length]; end PACKET_UNIT_INFO; is-info,sc UNIT id; key PLAYER owner; COORD x,y; CITY homecity; BOOL veteran, ai, paradropped, connecting, carried, select_it; UNIT_TYPE type; UINT8 movesleft, hp, fuel, activity, activity_count; UINT8 unhappiness, upkeep, upkeep_food, upkeep_gold; COORD goto_dest_x,goto_dest_y; uint16(enum tile_special_type) activity_target; UINT8 packet_use; CITY info_city_id; UINT16 serial_num; end PACKET_UNIT_COMBAT_INFO; sc UNIT attacker_unit_id; UNIT defender_unit_id; HP attacker_hp; HP defender_hp; BOOL make_winner_veteran; end PACKET_UNIT_MOVE;cs UNIT unit_id; COORD x; COORD y; end PACKET_UNIT_BUILD_CITY;cs UNIT unit_id; STRING name[MAX_LEN_NAME]; end PACKET_UNIT_DISBAND;cs UNIT unit_id; end PACKET_UNIT_CHANGE_HOMECITY;cs UNIT unit_id; CITY city_id; end PACKET_UNIT_ESTABLISH_TRADE;cs UNIT unit_id; end PACKET_UNIT_HELP_BUILD_WONDER;cs UNIT unit_id; end PACKET_UNIT_GOTO;cs UNIT unit_id; COORD x; COORD y; end PACKET_UNIT_AUTO;cs UNIT unit_id; CITY city_id; COORD x; COORD y; STRING name[MAX_LEN_NAME]; end PACKET_UNIT_UNLOAD;cs UNIT unit_id; CITY city_id; COORD x; COORD y; STRING name[MAX_LEN_NAME]; end PACKET_UNIT_UPGRADE;cs UNIT unit_id; end PACKET_UNIT_NUKE;cs UNIT unit_id; CITY city_id; COORD x; COORD y; STRING name[MAX_LEN_NAME]; end PACKET_UNIT_PARADROP_TO;cs UNIT unit_id; CITY city_id; COORD x; COORD y; STRING name[MAX_LEN_NAME]; end PACKET_UNIT_AIRLIFT;cs UNIT unit_id; CITY city_id; end PACKET_UNIT_CONNECT;cs UNIT unit_id; UINT8 activity_type; COORD dest_x; COORD dest_y; end PACKET_UNIT_BRIBE_INQ;cs,handle-per-conn UNIT unit_id; end PACKET_UNIT_BRIBE_INFO;sc UNIT unit_id; UINT32 value; end PACKET_UNIT_TYPE_UPGRADE;cs UNIT_TYPE type; end PACKET_UNIT_DIPLOMAT_ACTION;cs UNIT diplomat_id; uint8(enum diplomat_actions) action_type; UNIT target_id; # city_id or unit_id target_id; UINT16 value; end PACKET_UNIT_CHANGE_ACTIVITIY; cs UNIT unit_id; UINT8 activity; uint16(enum tile_special_type) activity_target; BOOL select_it; end ############################################################### PACKET_DIPLOMACY_INIT_MEETING_REQ;cs PLAYER other_player_id; end PACKET_DIPLOMACY_INIT_MEETING;sc PLAYER from, other; end PACKET_DIPLOMACY_CREATE_CLAUSE_REQ;cs PLAYER other_player_id; uint32(enum clause_type) clause_type; UINT32 value; end PACKET_DIPLOMACY_CREATE_CLAUSE;sc PLAYER from, other; uint32(enum clause_type) clause_type; UINT32 value; end PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ;cs PLAYER other_player_id; uint32(enum clause_type) clause_type; UINT32 value; end PACKET_DIPLOMACY_REMOVE_CLAUSE;sc PLAYER from, other; uint32(enum clause_type) clause_type; UINT32 value; end PACKET_DIPLOMACY_CANCEL_MEETING_REQ;cs PLAYER other_player_id; end PACKET_DIPLOMACY_CANCEL_MEETING;sc PLAYER from, other; end PACKET_DIPLOMACY_ACCEPT_TREATY_REQ;cs PLAYER other_player_id; end PACKET_DIPLOMACY_ACCEPT_TREATY;sc PLAYER from, other; end ############################################################### PACKET_NUKE_TILE_INFO;sc COORD x,y; end PACKET_PAGE_MSG;sc STRING message[MAX_LEN_MSG]; UINT32 event; end PACKET_REMOVE_UNIT;sc UNIT unit_id; end PACKET_REMOVE_CITY;sc CITY city_id; end PACKET_REMOVE_PLAYER; sc PLAYER player_id; end PACKET_REPORT_REQ;cs,handle-per-conn uint32(enum report_type) type; end PACKET_CITY_REFRESH;cs CITY city_id; end PACKET_CITY_INCITE_INQ;cs CITY id; end PACKET_ADVANCE_FOCUS;sc UINT32 value; end PACKET_PLAYER_CANCEL_PACT;cs UINT32 value; end PACKET_MAP_REMOVE_VISION;cs PLAYER other_player_id; 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; is-info,sc UINT32 id; key # 0 means client should forget its # info about this connection BOOL used; BOOL established; BOOL observer; PLAYER player_num; # range uchar; index in game.players, or 255 uint8(enum cmdlevel_id) access_level; STRING name[MAX_LEN_NAME]; STRING addr[MAX_LEN_ADDR]; STRING capability[MAX_LEN_CAPSTR]; end PACKET_SPACESHIP_ACTION;cs UINT8 action; # SSHIP_ACT_LAUNCH: ignored # _PLACE_STRUCTURAL: index to sship->structure[] # others: new value for sship->fuel etc; should be just # one more than current value of ship->fuel etc # (used to avoid possible problems if we send duplicate # packets when client auto-builds?) UINT8 num; end PACKET_INCITE_COST_INFO;sc UINT16 id; UINT32 value1, value2; end PACKET_CITY_OPTIONS_REQ;cs CITY city_id; UINT8 value; end PACKET_CITY_OPTIONS_INFO;sc CITY city_id; UINT8 value; end PACKET_CITY_NAME_SUGGESTION_REQ;cs UINT32 value; end # For city name suggestions, client sends unit id of unit building the # city. The server does not use the id, but sends it back to the # client so that the client knows what to do with the suggestion when # it arrives back. (This is for the reply; the request is sent as a # generic integer packet with the id value.) (Currently, for city # renaming, default is existing name; if wanted to suggest a new name, # could do the same thing sending the city id as id, and only client # needs to change.) PACKET_CITY_NAME_SUGGESTION_INFO;sc UNIT id; STRING name[MAX_LEN_NAME]; end PACKET_SABOTAGE_LIST;sc UNIT diplomat_id; CITY city_id; BIT_STRING improvements[B_LAST+1]; end PACKET_CONN_PING;sc end PACKET_CONN_PONG;cs end PACKET_BEFORE_NEW_YEAR;sc end PACKET_START_TURN;sc end PACKET_FREEZE_HINT;sc end PACKET_THAW_HINT;sc end PACKET_SPACESHIP_INFO; is-info,sc PLAYER player_num; key UINT8 sship_state; UINT8 structurals; UINT8 components; UINT8 modules; UINT8 fuel; UINT8 propulsion; UINT8 habitation; UINT8 life_support; UINT8 solar_panels; YEAR launch_year; UINT32 population; UINT32 mass; BIT_STRING structure[NUM_SS_STRUCTURALS+1]; FLOAT support_rate; FLOAT energy_rate; FLOAT success_rate; FLOAT travel_time; end PACKET_RULESET_UNIT;sc UNIT_TYPE id; STRING name[MAX_LEN_NAME]; STRING graphic_str[MAX_LEN_NAME]; STRING graphic_alt[MAX_LEN_NAME]; STRING sound_move[MAX_LEN_NAME]; STRING sound_move_alt[MAX_LEN_NAME]; STRING sound_fight[MAX_LEN_NAME]; STRING sound_fight_alt[MAX_LEN_NAME]; UINT8 move_type; UINT16 build_cost; UINT8 pop_cost; UINT8 attack_strength; UINT8 defense_strength; UINT8 move_rate; TECH tech_requirement; UINT8 vision_range; UINT8 transport_capacity; UINT8 hp; UINT8 firepower; SINT8 obsoleted_by; UINT8 fuel; UINT8 happy_cost; # unhappy people in home city UINT8 shield_cost; # normal upkeep cost UINT8 food_cost; # settler food cost UINT8 gold_cost; # gold upkeep (n/a now, maybe later) UINT8 paratroopers_range; # max range of paratroopers, F_PARATROOPERS UINT8 paratroopers_mr_req; UINT8 paratroopers_mr_sub; STRING helptext[MAX_LEN_PACKET]; bitvector(bv_flags) flags; bitvector(bv_roles) roles; end PACKET_RULESET_GAME;sc UINT8 min_city_center_food; UINT8 min_city_center_shield; UINT8 min_city_center_trade; UINT8 min_dist_bw_cities; UINT8 init_vis_radius_sq; UINT8 hut_overflight; BOOL pillage_select; UINT8 nuke_contamination; UINT8 granary_food_ini; UINT8 granary_food_inc; UINT8 tech_cost_style; UINT8 tech_leakage; TECH_LIST global_init_techs[MAX_NUM_TECH_LIST]; end PACKET_RULESET_GOVERNMENT_RULER_TITLE;sc UINT8 gov, id, nation; STRING male_title[MAX_LEN_NAME]; STRING female_title[MAX_LEN_NAME]; end PACKET_RULESET_TECH;sc UINT8 id; UINT8 req[2]; UINT32 flags, preset_cost, num_reqs; STRING name[MAX_LEN_NAME]; STRING helptext[MAX_LEN_PACKET]; end PACKET_RULESET_GOVERNMENT;sc UINT8 id; UINT8 required_tech; UINT8 max_rate; UINT8 civil_war; UINT8 martial_law_max; UINT8 martial_law_per; UINT8 empire_size_mod; UINT8 empire_size_inc; UINT8 rapture_size; UINT8 unit_happy_cost_factor; UINT8 unit_shield_cost_factor; UINT8 unit_food_cost_factor; UINT8 unit_gold_cost_factor; UINT8 free_happy; UINT8 free_shield; UINT8 free_food; UINT8 free_gold; UINT8 trade_before_penalty; UINT8 shields_before_penalty; UINT8 food_before_penalty; UINT8 celeb_trade_before_penalty; UINT8 celeb_shields_before_penalty; UINT8 celeb_food_before_penalty; UINT8 trade_bonus; UINT8 shield_bonus; UINT8 food_bonus; UINT8 celeb_trade_bonus; UINT8 celeb_shield_bonus; UINT8 celeb_food_bonus; UINT8 corruption_level; UINT8 corruption_modifier; UINT8 fixed_corruption_distance; UINT8 corruption_distance_factor; UINT8 extra_corruption_distance; UINT16 flags; UINT8 hints; UINT8 num_ruler_titles; STRING name[MAX_LEN_NAME]; STRING graphic_str[MAX_LEN_NAME]; STRING graphic_alt[MAX_LEN_NAME]; STRING helptext[MAX_LEN_PACKET]; end PACKET_RULESET_TERRAIN_CONTROL;sc uint8(enum terrain_river_type) river_style; BOOL may_road; /* may build roads/railroads */ BOOL may_irrigate; /* may build irrigation/farmland */ BOOL may_mine; /* may build mines */ BOOL may_transform; /* may transform terrain */ /* parameters */ UINT8 ocean_reclaim_requirement; /* # adjacent land tiles for reclaim */ UINT8 land_channel_requirement; /* # adjacent ocean tiles for channel */ uint8(enum special_river_move) river_move_mode; UINT16 river_defense_bonus; /* % added to defense if Civ2 river */ UINT16 river_trade_incr; /* added to trade if Civ2 river */ STRING river_help_text[MAX_LEN_PACKET]; # help for Civ2-style rivers UINT16 fortress_defense_bonus; /* % added to defense if fortress */ UINT16 road_superhighway_trade_bonus; # % added to trade if road/s-highway UINT16 rail_food_bonus; /* % added to food if railroad */ UINT16 rail_shield_bonus; /* % added to shield if railroad */ UINT16 rail_trade_bonus; /* % added to trade if railroad */ UINT16 farmland_supermarket_food_bonus;# % added to food if farm/s-market UINT16 pollution_food_penalty; /* % subtr. from food if polluted */ UINT16 pollution_shield_penalty; /* % subtr. from shield if polluted */ UINT16 pollution_trade_penalty; /* % subtr. from trade if polluted */ UINT16 fallout_food_penalty; /* % subtr. from food if fallout */ UINT16 fallout_shield_penalty; /* % subtr. from shield if fallout */ UINT16 fallout_trade_penalty; /* % subtr. from trade if fallout */ end PACKET_RULESET_NATION;sc UINT8 id; STRING name[MAX_LEN_NAME]; STRING name_plural[MAX_LEN_NAME]; STRING graphic_str[MAX_LEN_NAME]; STRING graphic_alt[MAX_LEN_NAME]; UINT8 city_style; TECH_LIST init_techs[MAX_NUM_TECH_LIST]; UINT8 leader_count; STRING leader_name[MAX_NUM_LEADERS:leader_count][MAX_LEN_NAME]; BOOL leader_sex[MAX_NUM_LEADERS:leader_count]; end PACKET_RULESET_CITY;sc UINT8 style_id; UINT8 techreq; STRING name[MAX_LEN_NAME]; STRING graphic[MAX_LEN_NAME]; STRING graphic_alt[MAX_LEN_NAME]; SINT16 replaced_by; end PACKET_RULESET_TERRAIN;sc UINT8 id; STRING terrain_name[MAX_LEN_NAME]; STRING graphic_str[MAX_LEN_NAME]; STRING graphic_alt[MAX_LEN_NAME]; UINT8 movement_cost; UINT8 defense_bonus; UINT8 food; UINT8 shield; UINT8 trade; STRING special_1_name[MAX_LEN_NAME]; UINT8 food_special_1; UINT8 shield_special_1; UINT8 trade_special_1; STRING graphic_str_special_1[MAX_LEN_NAME]; STRING graphic_alt_special_1[MAX_LEN_NAME]; STRING special_2_name[MAX_LEN_NAME]; UINT8 food_special_2; UINT8 shield_special_2; UINT8 trade_special_2; STRING graphic_str_special_2[MAX_LEN_NAME]; STRING graphic_alt_special_2[MAX_LEN_NAME]; UINT8 road_trade_incr; UINT8 road_time; uint8(enum tile_terrain_type) irrigation_result; UINT8 irrigation_food_incr; UINT8 irrigation_time; uint8(enum tile_terrain_type) mining_result; UINT8 mining_shield_incr; UINT8 mining_time; uint8(enum tile_terrain_type) transform_result; UINT8 transform_time; STRING helptext[MAX_LEN_PACKET]; end /********************************************************* Ruleset control values: single values, some of which are needed before sending other ruleset data (eg, num_unit_types, government_count). This is only sent once at the start of the game, eg unlike game_info which is sent again each turn. (Terrain ruleset has enough info for its own "control" packet, done separately.) *********************************************************/ PACKET_RULESET_CONTROL;sc UINT8 aqueduct_size; UINT8 sewer_size; UINT8 add_to_size_limit; UINT8 notradesize, fulltradesize; UINT8 num_unit_types; UINT8 num_impr_types; UINT8 num_tech_types; UINT8 rtech_cathedral_plus; UINT8 rtech_cathedral_minus; UINT8 rtech_colosseum_plus; UINT8 rtech_temple_plus; TECH_LIST rtech_partisan_req[MAX_NUM_TECH_LIST]; UINT8 government_when_anarchy; UINT8 default_government; UINT8 government_count; UINT8 nation_count; UINT8 playable_nation_count; UINT8 style_count; end