1 
2  /****************************************************************************
3  *                       THIS FILE WAS GENERATED                             *
4  * Script: common/generate_packets.py                                        *
5  * Input:  common/packets.def                                                *
6  *                       DO NOT CHANGE THIS FILE                             *
7  ****************************************************************************/
8 
9 
10 #ifdef HAVE_CONFIG_H
11 #include <fc_config.h>
12 #endif
13 
14 #include <string.h>
15 
16 /* utility */
17 #include "bitvector.h"
18 #include "capability.h"
19 #include "genhash.h"
20 #include "log.h"
21 #include "mem.h"
22 #include "support.h"
23 
24 /* common */
25 #include "capstr.h"
26 #include "connection.h"
27 #include "dataio.h"
28 #include "game.h"
29 
30 #include "packets.h"
31 
32 const char *const packet_functional_capability = "techloss_forgiveness year32";
33 
hash_const(const void * vkey)34 static genhash_val_t hash_const(const void *vkey)
35 {
36   return 0;
37 }
38 
cmp_const(const void * vkey1,const void * vkey2)39 static bool cmp_const(const void *vkey1, const void *vkey2)
40 {
41   return TRUE;
42 }
43 
delta_stats_report(void)44 void delta_stats_report(void) {}
45 
delta_stats_reset(void)46 void delta_stats_reset(void) {}
47 
packet_name(enum packet_type type)48 const char *packet_name(enum packet_type type)
49 {
50   static const char *const names[PACKET_LAST] = {
51     "PACKET_PROCESSING_STARTED",
52     "PACKET_PROCESSING_FINISHED",
53     "unknown",
54     "unknown",
55     "PACKET_SERVER_JOIN_REQ",
56     "PACKET_SERVER_JOIN_REPLY",
57     "PACKET_AUTHENTICATION_REQ",
58     "PACKET_AUTHENTICATION_REPLY",
59     "PACKET_SERVER_SHUTDOWN",
60     "unknown",
61     "PACKET_NATION_SELECT_REQ",
62     "PACKET_PLAYER_READY",
63     "PACKET_ENDGAME_REPORT",
64     "unknown",
65     "unknown",
66     "PACKET_TILE_INFO",
67     "PACKET_GAME_INFO",
68     "PACKET_MAP_INFO",
69     "PACKET_NUKE_TILE_INFO",
70     "PACKET_TEAM_NAME_INFO",
71     "unknown",
72     "unknown",
73     "unknown",
74     "unknown",
75     "unknown",
76     "PACKET_CHAT_MSG",
77     "PACKET_CHAT_MSG_REQ",
78     "PACKET_CONNECT_MSG",
79     "PACKET_EARLY_CHAT_MSG",
80     "unknown",
81     "PACKET_CITY_REMOVE",
82     "PACKET_CITY_INFO",
83     "PACKET_CITY_SHORT_INFO",
84     "PACKET_CITY_SELL",
85     "PACKET_CITY_BUY",
86     "PACKET_CITY_CHANGE",
87     "PACKET_CITY_WORKLIST",
88     "PACKET_CITY_MAKE_SPECIALIST",
89     "PACKET_CITY_MAKE_WORKER",
90     "PACKET_CITY_CHANGE_SPECIALIST",
91     "PACKET_CITY_RENAME",
92     "PACKET_CITY_OPTIONS_REQ",
93     "PACKET_CITY_REFRESH",
94     "PACKET_CITY_NAME_SUGGESTION_REQ",
95     "PACKET_CITY_NAME_SUGGESTION_INFO",
96     "PACKET_CITY_SABOTAGE_LIST",
97     "unknown",
98     "unknown",
99     "unknown",
100     "unknown",
101     "PACKET_PLAYER_REMOVE",
102     "PACKET_PLAYER_INFO",
103     "PACKET_PLAYER_PHASE_DONE",
104     "PACKET_PLAYER_RATES",
105     "PACKET_PLAYER_CHANGE_GOVERNMENT",
106     "PACKET_PLAYER_RESEARCH",
107     "PACKET_PLAYER_TECH_GOAL",
108     "PACKET_PLAYER_ATTRIBUTE_BLOCK",
109     "PACKET_PLAYER_ATTRIBUTE_CHUNK",
110     "PACKET_PLAYER_DIPLSTATE",
111     "PACKET_RESEARCH_INFO",
112     "unknown",
113     "PACKET_UNIT_REMOVE",
114     "PACKET_UNIT_INFO",
115     "PACKET_UNIT_SHORT_INFO",
116     "PACKET_UNIT_COMBAT_INFO",
117     "unknown",
118     "PACKET_UNIT_BUILD_CITY",
119     "PACKET_UNIT_DISBAND",
120     "PACKET_UNIT_CHANGE_HOMECITY",
121     "unknown",
122     "PACKET_UNIT_BATTLEGROUP",
123     "unknown",
124     "PACKET_UNIT_ORDERS",
125     "PACKET_UNIT_AUTOSETTLERS",
126     "PACKET_UNIT_LOAD",
127     "PACKET_UNIT_UNLOAD",
128     "PACKET_UNIT_UPGRADE",
129     "unknown",
130     "PACKET_UNIT_NUKE",
131     "PACKET_UNIT_PARADROP_TO",
132     "PACKET_UNIT_AIRLIFT",
133     "PACKET_UNIT_ACTION_QUERY",
134     "PACKET_UNIT_TYPE_UPGRADE",
135     "PACKET_UNIT_DO_ACTION",
136     "PACKET_UNIT_ACTION_ANSWER",
137     "unknown",
138     "PACKET_UNIT_GET_ACTIONS",
139     "PACKET_CONN_PING",
140     "PACKET_CONN_PONG",
141     "PACKET_UNIT_ACTIONS",
142     "unknown",
143     "unknown",
144     "unknown",
145     "unknown",
146     "PACKET_DIPLOMACY_INIT_MEETING_REQ",
147     "PACKET_DIPLOMACY_INIT_MEETING",
148     "PACKET_DIPLOMACY_CANCEL_MEETING_REQ",
149     "PACKET_DIPLOMACY_CANCEL_MEETING",
150     "PACKET_DIPLOMACY_CREATE_CLAUSE_REQ",
151     "PACKET_DIPLOMACY_CREATE_CLAUSE",
152     "PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ",
153     "PACKET_DIPLOMACY_REMOVE_CLAUSE",
154     "PACKET_DIPLOMACY_ACCEPT_TREATY_REQ",
155     "PACKET_DIPLOMACY_ACCEPT_TREATY",
156     "PACKET_DIPLOMACY_CANCEL_PACT",
157     "unknown",
158     "unknown",
159     "unknown",
160     "unknown",
161     "PACKET_PAGE_MSG",
162     "PACKET_REPORT_REQ",
163     "unknown",
164     "unknown",
165     "unknown",
166     "PACKET_CONN_INFO",
167     "PACKET_CONN_PING_INFO",
168     "unknown",
169     "unknown",
170     "PACKET_CLIENT_INFO",
171     "unknown",
172     "unknown",
173     "unknown",
174     "unknown",
175     "unknown",
176     "PACKET_END_PHASE",
177     "PACKET_START_PHASE",
178     "PACKET_NEW_YEAR",
179     "PACKET_BEGIN_TURN",
180     "PACKET_END_TURN",
181     "PACKET_FREEZE_CLIENT",
182     "PACKET_THAW_CLIENT",
183     "unknown",
184     "unknown",
185     "unknown",
186     "PACKET_SPACESHIP_LAUNCH",
187     "PACKET_SPACESHIP_PLACE",
188     "PACKET_SPACESHIP_INFO",
189     "unknown",
190     "unknown",
191     "PACKET_RULESET_UNIT",
192     "PACKET_RULESET_GAME",
193     "PACKET_RULESET_SPECIALIST",
194     "PACKET_RULESET_GOVERNMENT_RULER_TITLE",
195     "PACKET_RULESET_TECH",
196     "PACKET_RULESET_GOVERNMENT",
197     "PACKET_RULESET_TERRAIN_CONTROL",
198     "PACKET_RULESET_NATION_GROUPS",
199     "PACKET_RULESET_NATION",
200     "PACKET_RULESET_CITY",
201     "PACKET_RULESET_BUILDING",
202     "PACKET_RULESET_TERRAIN",
203     "PACKET_RULESET_UNIT_CLASS",
204     "PACKET_RULESET_BASE",
205     "unknown",
206     "PACKET_RULESET_CONTROL",
207     "unknown",
208     "unknown",
209     "unknown",
210     "unknown",
211     "PACKET_SINGLE_WANT_HACK_REQ",
212     "PACKET_SINGLE_WANT_HACK_REPLY",
213     "PACKET_RULESET_CHOICES",
214     "PACKET_GAME_LOAD",
215     "PACKET_SERVER_SETTING_CONTROL",
216     "PACKET_SERVER_SETTING_CONST",
217     "PACKET_SERVER_SETTING_BOOL",
218     "PACKET_SERVER_SETTING_INT",
219     "PACKET_SERVER_SETTING_STR",
220     "PACKET_SERVER_SETTING_ENUM",
221     "PACKET_SERVER_SETTING_BITWISE",
222     "unknown",
223     "unknown",
224     "unknown",
225     "unknown",
226     "PACKET_RULESET_EFFECT",
227     "unknown",
228     "PACKET_RULESET_RESOURCE",
229     "unknown",
230     "unknown",
231     "PACKET_SCENARIO_INFO",
232     "PACKET_SAVE_SCENARIO",
233     "unknown",
234     "unknown",
235     "unknown",
236     "PACKET_VOTE_NEW",
237     "PACKET_VOTE_UPDATE",
238     "PACKET_VOTE_REMOVE",
239     "PACKET_VOTE_RESOLVE",
240     "PACKET_VOTE_SUBMIT",
241     "PACKET_EDIT_MODE",
242     "unknown",
243     "unknown",
244     "unknown",
245     "unknown",
246     "unknown",
247     "unknown",
248     "PACKET_EDIT_RECALCULATE_BORDERS",
249     "PACKET_EDIT_CHECK_TILES",
250     "PACKET_EDIT_TOGGLE_FOGOFWAR",
251     "PACKET_EDIT_TILE_TERRAIN",
252     "PACKET_EDIT_TILE_RESOURCE",
253     "PACKET_EDIT_TILE_EXTRA",
254     "unknown",
255     "PACKET_EDIT_STARTPOS",
256     "PACKET_EDIT_STARTPOS_FULL",
257     "PACKET_EDIT_TILE",
258     "PACKET_EDIT_UNIT_CREATE",
259     "PACKET_EDIT_UNIT_REMOVE",
260     "PACKET_EDIT_UNIT_REMOVE_BY_ID",
261     "PACKET_EDIT_UNIT",
262     "PACKET_EDIT_CITY_CREATE",
263     "PACKET_EDIT_CITY_REMOVE",
264     "PACKET_EDIT_CITY",
265     "PACKET_EDIT_PLAYER_CREATE",
266     "PACKET_EDIT_PLAYER_REMOVE",
267     "PACKET_EDIT_PLAYER",
268     "PACKET_EDIT_PLAYER_VISION",
269     "PACKET_EDIT_GAME",
270     "PACKET_EDIT_OBJECT_CREATED",
271     "PACKET_RULESET_ROAD",
272     "unknown",
273     "PACKET_UNIT_CHANGE_ACTIVITY",
274     "PACKET_ENDGAME_PLAYER",
275     "PACKET_RULESET_DISASTER",
276     "PACKET_RULESETS_READY",
277     "unknown",
278     "PACKET_RULESET_TRADE",
279     "PACKET_RULESET_UNIT_BONUS",
280     "PACKET_RULESET_UNIT_FLAG",
281     "unknown",
282     "PACKET_RULESET_TERRAIN_FLAG",
283     "PACKET_RULESET_EXTRA",
284     "PACKET_RULESET_ACHIEVEMENT",
285     "PACKET_RULESET_TECH_FLAG",
286     "PACKET_RULESET_ACTION_ENABLER",
287     "PACKET_RULESET_NATION_SETS",
288     "PACKET_NATION_AVAILABILITY",
289     "PACKET_ACHIEVEMENT_INFO",
290     "PACKET_RULESET_STYLE",
291     "PACKET_RULESET_MUSIC",
292     "PACKET_WORKER_TASK",
293     "PACKET_PLAYER_MULTIPLIER",
294     "PACKET_RULESET_MULTIPLIER",
295     "PACKET_TIMEOUT_INFO",
296     "PACKET_PLAY_MUSIC",
297     "PACKET_RULESET_ACTION",
298     "PACKET_RULESET_DESCRIPTION_PART",
299     "PACKET_PAGE_MSG_PART",
300     "PACKET_RULESET_SUMMARY",
301     "PACKET_SET_TOPOLOGY",
302     "PACKET_CLIENT_HEARTBEAT",
303     "PACKET_SCENARIO_DESCRIPTION",
304     "PACKET_EDIT_SCENARIO_DESC",
305   };
306 
307   return (type >= 0 && type < PACKET_LAST ? names[type] : "unknown");
308 }
309 
packet_has_game_info_flag(enum packet_type type)310 bool packet_has_game_info_flag(enum packet_type type)
311 {
312   static const bool flag[PACKET_LAST] = {
313     FALSE, /* PACKET_PROCESSING_STARTED */
314     FALSE, /* PACKET_PROCESSING_FINISHED */
315     FALSE,
316     FALSE,
317     FALSE, /* PACKET_SERVER_JOIN_REQ */
318     FALSE, /* PACKET_SERVER_JOIN_REPLY */
319     FALSE, /* PACKET_AUTHENTICATION_REQ */
320     FALSE, /* PACKET_AUTHENTICATION_REPLY */
321     FALSE, /* PACKET_SERVER_SHUTDOWN */
322     FALSE,
323     FALSE, /* PACKET_NATION_SELECT_REQ */
324     FALSE, /* PACKET_PLAYER_READY */
325     FALSE, /* PACKET_ENDGAME_REPORT */
326     FALSE,
327     FALSE,
328     TRUE, /* PACKET_TILE_INFO */
329     FALSE, /* PACKET_GAME_INFO */
330     FALSE, /* PACKET_MAP_INFO */
331     FALSE, /* PACKET_NUKE_TILE_INFO */
332     FALSE, /* PACKET_TEAM_NAME_INFO */
333     FALSE,
334     FALSE,
335     FALSE,
336     FALSE,
337     FALSE,
338     FALSE, /* PACKET_CHAT_MSG */
339     FALSE, /* PACKET_CHAT_MSG_REQ */
340     FALSE, /* PACKET_CONNECT_MSG */
341     FALSE, /* PACKET_EARLY_CHAT_MSG */
342     FALSE,
343     FALSE, /* PACKET_CITY_REMOVE */
344     TRUE, /* PACKET_CITY_INFO */
345     TRUE, /* PACKET_CITY_SHORT_INFO */
346     FALSE, /* PACKET_CITY_SELL */
347     FALSE, /* PACKET_CITY_BUY */
348     FALSE, /* PACKET_CITY_CHANGE */
349     FALSE, /* PACKET_CITY_WORKLIST */
350     FALSE, /* PACKET_CITY_MAKE_SPECIALIST */
351     FALSE, /* PACKET_CITY_MAKE_WORKER */
352     FALSE, /* PACKET_CITY_CHANGE_SPECIALIST */
353     FALSE, /* PACKET_CITY_RENAME */
354     FALSE, /* PACKET_CITY_OPTIONS_REQ */
355     FALSE, /* PACKET_CITY_REFRESH */
356     FALSE, /* PACKET_CITY_NAME_SUGGESTION_REQ */
357     FALSE, /* PACKET_CITY_NAME_SUGGESTION_INFO */
358     FALSE, /* PACKET_CITY_SABOTAGE_LIST */
359     FALSE,
360     FALSE,
361     FALSE,
362     FALSE,
363     FALSE, /* PACKET_PLAYER_REMOVE */
364     FALSE, /* PACKET_PLAYER_INFO */
365     FALSE, /* PACKET_PLAYER_PHASE_DONE */
366     FALSE, /* PACKET_PLAYER_RATES */
367     FALSE, /* PACKET_PLAYER_CHANGE_GOVERNMENT */
368     FALSE, /* PACKET_PLAYER_RESEARCH */
369     FALSE, /* PACKET_PLAYER_TECH_GOAL */
370     FALSE, /* PACKET_PLAYER_ATTRIBUTE_BLOCK */
371     FALSE, /* PACKET_PLAYER_ATTRIBUTE_CHUNK */
372     FALSE, /* PACKET_PLAYER_DIPLSTATE */
373     TRUE, /* PACKET_RESEARCH_INFO */
374     FALSE,
375     FALSE, /* PACKET_UNIT_REMOVE */
376     TRUE, /* PACKET_UNIT_INFO */
377     TRUE, /* PACKET_UNIT_SHORT_INFO */
378     FALSE, /* PACKET_UNIT_COMBAT_INFO */
379     FALSE,
380     FALSE, /* PACKET_UNIT_BUILD_CITY */
381     FALSE, /* PACKET_UNIT_DISBAND */
382     FALSE, /* PACKET_UNIT_CHANGE_HOMECITY */
383     FALSE,
384     FALSE, /* PACKET_UNIT_BATTLEGROUP */
385     FALSE,
386     FALSE, /* PACKET_UNIT_ORDERS */
387     FALSE, /* PACKET_UNIT_AUTOSETTLERS */
388     FALSE, /* PACKET_UNIT_LOAD */
389     FALSE, /* PACKET_UNIT_UNLOAD */
390     FALSE, /* PACKET_UNIT_UPGRADE */
391     FALSE,
392     FALSE, /* PACKET_UNIT_NUKE */
393     FALSE, /* PACKET_UNIT_PARADROP_TO */
394     FALSE, /* PACKET_UNIT_AIRLIFT */
395     FALSE, /* PACKET_UNIT_ACTION_QUERY */
396     FALSE, /* PACKET_UNIT_TYPE_UPGRADE */
397     FALSE, /* PACKET_UNIT_DO_ACTION */
398     FALSE, /* PACKET_UNIT_ACTION_ANSWER */
399     FALSE,
400     FALSE, /* PACKET_UNIT_GET_ACTIONS */
401     FALSE, /* PACKET_CONN_PING */
402     FALSE, /* PACKET_CONN_PONG */
403     FALSE, /* PACKET_UNIT_ACTIONS */
404     FALSE,
405     FALSE,
406     FALSE,
407     FALSE,
408     FALSE, /* PACKET_DIPLOMACY_INIT_MEETING_REQ */
409     FALSE, /* PACKET_DIPLOMACY_INIT_MEETING */
410     FALSE, /* PACKET_DIPLOMACY_CANCEL_MEETING_REQ */
411     FALSE, /* PACKET_DIPLOMACY_CANCEL_MEETING */
412     FALSE, /* PACKET_DIPLOMACY_CREATE_CLAUSE_REQ */
413     FALSE, /* PACKET_DIPLOMACY_CREATE_CLAUSE */
414     FALSE, /* PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ */
415     FALSE, /* PACKET_DIPLOMACY_REMOVE_CLAUSE */
416     FALSE, /* PACKET_DIPLOMACY_ACCEPT_TREATY_REQ */
417     FALSE, /* PACKET_DIPLOMACY_ACCEPT_TREATY */
418     FALSE, /* PACKET_DIPLOMACY_CANCEL_PACT */
419     FALSE,
420     FALSE,
421     FALSE,
422     FALSE,
423     FALSE, /* PACKET_PAGE_MSG */
424     FALSE, /* PACKET_REPORT_REQ */
425     FALSE,
426     FALSE,
427     FALSE,
428     FALSE, /* PACKET_CONN_INFO */
429     FALSE, /* PACKET_CONN_PING_INFO */
430     FALSE,
431     FALSE,
432     FALSE, /* PACKET_CLIENT_INFO */
433     FALSE,
434     FALSE,
435     FALSE,
436     FALSE,
437     FALSE,
438     FALSE, /* PACKET_END_PHASE */
439     FALSE, /* PACKET_START_PHASE */
440     FALSE, /* PACKET_NEW_YEAR */
441     FALSE, /* PACKET_BEGIN_TURN */
442     FALSE, /* PACKET_END_TURN */
443     FALSE, /* PACKET_FREEZE_CLIENT */
444     FALSE, /* PACKET_THAW_CLIENT */
445     FALSE,
446     FALSE,
447     FALSE,
448     FALSE, /* PACKET_SPACESHIP_LAUNCH */
449     FALSE, /* PACKET_SPACESHIP_PLACE */
450     TRUE, /* PACKET_SPACESHIP_INFO */
451     FALSE,
452     FALSE,
453     FALSE, /* PACKET_RULESET_UNIT */
454     FALSE, /* PACKET_RULESET_GAME */
455     FALSE, /* PACKET_RULESET_SPECIALIST */
456     FALSE, /* PACKET_RULESET_GOVERNMENT_RULER_TITLE */
457     FALSE, /* PACKET_RULESET_TECH */
458     FALSE, /* PACKET_RULESET_GOVERNMENT */
459     FALSE, /* PACKET_RULESET_TERRAIN_CONTROL */
460     FALSE, /* PACKET_RULESET_NATION_GROUPS */
461     FALSE, /* PACKET_RULESET_NATION */
462     FALSE, /* PACKET_RULESET_CITY */
463     FALSE, /* PACKET_RULESET_BUILDING */
464     FALSE, /* PACKET_RULESET_TERRAIN */
465     FALSE, /* PACKET_RULESET_UNIT_CLASS */
466     FALSE, /* PACKET_RULESET_BASE */
467     FALSE,
468     FALSE, /* PACKET_RULESET_CONTROL */
469     FALSE,
470     FALSE,
471     FALSE,
472     FALSE,
473     FALSE, /* PACKET_SINGLE_WANT_HACK_REQ */
474     FALSE, /* PACKET_SINGLE_WANT_HACK_REPLY */
475     FALSE, /* PACKET_RULESET_CHOICES */
476     FALSE, /* PACKET_GAME_LOAD */
477     FALSE, /* PACKET_SERVER_SETTING_CONTROL */
478     FALSE, /* PACKET_SERVER_SETTING_CONST */
479     FALSE, /* PACKET_SERVER_SETTING_BOOL */
480     FALSE, /* PACKET_SERVER_SETTING_INT */
481     FALSE, /* PACKET_SERVER_SETTING_STR */
482     FALSE, /* PACKET_SERVER_SETTING_ENUM */
483     FALSE, /* PACKET_SERVER_SETTING_BITWISE */
484     FALSE,
485     FALSE,
486     FALSE,
487     FALSE,
488     FALSE, /* PACKET_RULESET_EFFECT */
489     FALSE,
490     FALSE, /* PACKET_RULESET_RESOURCE */
491     FALSE,
492     FALSE,
493     FALSE, /* PACKET_SCENARIO_INFO */
494     FALSE, /* PACKET_SAVE_SCENARIO */
495     FALSE,
496     FALSE,
497     FALSE,
498     FALSE, /* PACKET_VOTE_NEW */
499     FALSE, /* PACKET_VOTE_UPDATE */
500     FALSE, /* PACKET_VOTE_REMOVE */
501     FALSE, /* PACKET_VOTE_RESOLVE */
502     FALSE, /* PACKET_VOTE_SUBMIT */
503     FALSE, /* PACKET_EDIT_MODE */
504     FALSE,
505     FALSE,
506     FALSE,
507     FALSE,
508     FALSE,
509     FALSE,
510     FALSE, /* PACKET_EDIT_RECALCULATE_BORDERS */
511     FALSE, /* PACKET_EDIT_CHECK_TILES */
512     FALSE, /* PACKET_EDIT_TOGGLE_FOGOFWAR */
513     FALSE, /* PACKET_EDIT_TILE_TERRAIN */
514     FALSE, /* PACKET_EDIT_TILE_RESOURCE */
515     FALSE, /* PACKET_EDIT_TILE_EXTRA */
516     FALSE,
517     FALSE, /* PACKET_EDIT_STARTPOS */
518     FALSE, /* PACKET_EDIT_STARTPOS_FULL */
519     FALSE, /* PACKET_EDIT_TILE */
520     FALSE, /* PACKET_EDIT_UNIT_CREATE */
521     FALSE, /* PACKET_EDIT_UNIT_REMOVE */
522     FALSE, /* PACKET_EDIT_UNIT_REMOVE_BY_ID */
523     FALSE, /* PACKET_EDIT_UNIT */
524     FALSE, /* PACKET_EDIT_CITY_CREATE */
525     FALSE, /* PACKET_EDIT_CITY_REMOVE */
526     FALSE, /* PACKET_EDIT_CITY */
527     FALSE, /* PACKET_EDIT_PLAYER_CREATE */
528     FALSE, /* PACKET_EDIT_PLAYER_REMOVE */
529     FALSE, /* PACKET_EDIT_PLAYER */
530     FALSE, /* PACKET_EDIT_PLAYER_VISION */
531     FALSE, /* PACKET_EDIT_GAME */
532     FALSE, /* PACKET_EDIT_OBJECT_CREATED */
533     FALSE, /* PACKET_RULESET_ROAD */
534     FALSE,
535     FALSE, /* PACKET_UNIT_CHANGE_ACTIVITY */
536     FALSE, /* PACKET_ENDGAME_PLAYER */
537     FALSE, /* PACKET_RULESET_DISASTER */
538     FALSE, /* PACKET_RULESETS_READY */
539     FALSE,
540     FALSE, /* PACKET_RULESET_TRADE */
541     FALSE, /* PACKET_RULESET_UNIT_BONUS */
542     FALSE, /* PACKET_RULESET_UNIT_FLAG */
543     FALSE,
544     FALSE, /* PACKET_RULESET_TERRAIN_FLAG */
545     FALSE, /* PACKET_RULESET_EXTRA */
546     FALSE, /* PACKET_RULESET_ACHIEVEMENT */
547     FALSE, /* PACKET_RULESET_TECH_FLAG */
548     FALSE, /* PACKET_RULESET_ACTION_ENABLER */
549     FALSE, /* PACKET_RULESET_NATION_SETS */
550     FALSE, /* PACKET_NATION_AVAILABILITY */
551     FALSE, /* PACKET_ACHIEVEMENT_INFO */
552     FALSE, /* PACKET_RULESET_STYLE */
553     FALSE, /* PACKET_RULESET_MUSIC */
554     FALSE, /* PACKET_WORKER_TASK */
555     FALSE, /* PACKET_PLAYER_MULTIPLIER */
556     FALSE, /* PACKET_RULESET_MULTIPLIER */
557     FALSE, /* PACKET_TIMEOUT_INFO */
558     FALSE, /* PACKET_PLAY_MUSIC */
559     FALSE, /* PACKET_RULESET_ACTION */
560     FALSE, /* PACKET_RULESET_DESCRIPTION_PART */
561     FALSE, /* PACKET_PAGE_MSG_PART */
562     FALSE, /* PACKET_RULESET_SUMMARY */
563     FALSE, /* PACKET_SET_TOPOLOGY */
564     FALSE, /* PACKET_CLIENT_HEARTBEAT */
565     FALSE, /* PACKET_SCENARIO_DESCRIPTION */
566     FALSE, /* PACKET_EDIT_SCENARIO_DESC */
567   };
568 
569   return (type >= 0 && type < PACKET_LAST ? flag[type] : FALSE);
570 }
571 
receive_packet_processing_started_100(struct connection * pc)572 static struct packet_processing_started *receive_packet_processing_started_100(struct connection *pc)
573 {
574   RECEIVE_PACKET_START(packet_processing_started, real_packet);
575   real_packet->__dummy = 0xff;
576   log_packet_detailed("packet_processing_started_100: got info about ()");
577   RECEIVE_PACKET_END(real_packet);
578 }
579 
send_packet_processing_started_100(struct connection * pc)580 static int send_packet_processing_started_100(struct connection *pc)
581 {
582   SEND_PACKET_START(PACKET_PROCESSING_STARTED);
583 
584   log_packet_detailed("packet_processing_started_100: sending info about ()");
585   SEND_PACKET_END(PACKET_PROCESSING_STARTED);
586 }
587 
send_packet_processing_started(struct connection * pc)588 int send_packet_processing_started(struct connection *pc)
589 {
590   if (!pc->used) {
591     log_error("WARNING: trying to send data to the closed connection %s",
592               conn_description(pc));
593     return -1;
594   }
595   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PROCESSING_STARTED].no_packet != NULL, -1,
596                         "Handler for PACKET_PROCESSING_STARTED not installed");
597   return pc->phs.handlers->send[PACKET_PROCESSING_STARTED].no_packet(pc);
598 }
599 
receive_packet_processing_finished_100(struct connection * pc)600 static struct packet_processing_finished *receive_packet_processing_finished_100(struct connection *pc)
601 {
602   RECEIVE_PACKET_START(packet_processing_finished, real_packet);
603   real_packet->__dummy = 0xff;
604   log_packet_detailed("packet_processing_finished_100: got info about ()");
605   RECEIVE_PACKET_END(real_packet);
606 }
607 
send_packet_processing_finished_100(struct connection * pc)608 static int send_packet_processing_finished_100(struct connection *pc)
609 {
610   SEND_PACKET_START(PACKET_PROCESSING_FINISHED);
611 
612   log_packet_detailed("packet_processing_finished_100: sending info about ()");
613   SEND_PACKET_END(PACKET_PROCESSING_FINISHED);
614 }
615 
send_packet_processing_finished(struct connection * pc)616 int send_packet_processing_finished(struct connection *pc)
617 {
618   if (!pc->used) {
619     log_error("WARNING: trying to send data to the closed connection %s",
620               conn_description(pc));
621     return -1;
622   }
623   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PROCESSING_FINISHED].no_packet != NULL, -1,
624                         "Handler for PACKET_PROCESSING_FINISHED not installed");
625   return pc->phs.handlers->send[PACKET_PROCESSING_FINISHED].no_packet(pc);
626 }
627 
receive_packet_server_join_req_100(struct connection * pc)628 static struct packet_server_join_req *receive_packet_server_join_req_100(struct connection *pc)
629 {
630   RECEIVE_PACKET_START(packet_server_join_req, real_packet);
631   if (!DIO_GET(string, &din, "username", real_packet->username, sizeof(real_packet->username))) {
632     RECEIVE_PACKET_FIELD_ERROR(username);
633   }
634   if (!DIO_GET(string, &din, "capability", real_packet->capability, sizeof(real_packet->capability))) {
635     RECEIVE_PACKET_FIELD_ERROR(capability);
636   }
637   if (!DIO_GET(string, &din, "version_label", real_packet->version_label, sizeof(real_packet->version_label))) {
638     RECEIVE_PACKET_FIELD_ERROR(version_label);
639   }
640   if (!DIO_GET(uint32, &din, "major_version", &real_packet->major_version)) {
641     RECEIVE_PACKET_FIELD_ERROR(major_version);
642   }
643   if (!DIO_GET(uint32, &din, "minor_version", &real_packet->minor_version)) {
644     RECEIVE_PACKET_FIELD_ERROR(minor_version);
645   }
646   if (!DIO_GET(uint32, &din, "patch_version", &real_packet->patch_version)) {
647     RECEIVE_PACKET_FIELD_ERROR(patch_version);
648   }
649 
650   log_packet_detailed("packet_server_join_req_100: got info about ()");
651   RECEIVE_PACKET_END(real_packet);
652 }
653 
send_packet_server_join_req_100(struct connection * pc,const struct packet_server_join_req * packet)654 static int send_packet_server_join_req_100(struct connection *pc, const struct packet_server_join_req *packet)
655 {
656   const struct packet_server_join_req *real_packet = packet;
657   SEND_PACKET_START(PACKET_SERVER_JOIN_REQ);
658 
659   log_packet_detailed("packet_server_join_req_100: sending info about ()");
660 
661   DIO_PUT(string, &dout, "username", real_packet->username);
662   DIO_PUT(string, &dout, "capability", real_packet->capability);
663   DIO_PUT(string, &dout, "version_label", real_packet->version_label);
664   DIO_PUT(uint32, &dout, "major_version", real_packet->major_version);
665   DIO_PUT(uint32, &dout, "minor_version", real_packet->minor_version);
666   DIO_PUT(uint32, &dout, "patch_version", real_packet->patch_version);
667 
668   SEND_PACKET_END(PACKET_SERVER_JOIN_REQ);
669 }
670 
send_packet_server_join_req(struct connection * pc,const struct packet_server_join_req * packet)671 int send_packet_server_join_req(struct connection *pc, const struct packet_server_join_req *packet)
672 {
673   if (!pc->used) {
674     log_error("WARNING: trying to send data to the closed connection %s",
675               conn_description(pc));
676     return -1;
677   }
678   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SERVER_JOIN_REQ].packet != NULL, -1,
679                         "Handler for PACKET_SERVER_JOIN_REQ not installed");
680   return pc->phs.handlers->send[PACKET_SERVER_JOIN_REQ].packet(pc, packet);
681 }
682 
dsend_packet_server_join_req(struct connection * pc,const char * username,const char * capability,const char * version_label,int major_version,int minor_version,int patch_version)683 int dsend_packet_server_join_req(struct connection *pc, const char *username, const char *capability, const char *version_label, int major_version, int minor_version, int patch_version)
684 {
685   struct packet_server_join_req packet, *real_packet = &packet;
686 
687   sz_strlcpy(real_packet->username, username);
688   sz_strlcpy(real_packet->capability, capability);
689   sz_strlcpy(real_packet->version_label, version_label);
690   real_packet->major_version = major_version;
691   real_packet->minor_version = minor_version;
692   real_packet->patch_version = patch_version;
693 
694   return send_packet_server_join_req(pc, real_packet);
695 }
696 
receive_packet_server_join_reply_100(struct connection * pc)697 static struct packet_server_join_reply *receive_packet_server_join_reply_100(struct connection *pc)
698 {
699   RECEIVE_PACKET_START(packet_server_join_reply, real_packet);
700   if (!DIO_GET(bool8, &din, "you_can_join", &real_packet->you_can_join)) {
701     RECEIVE_PACKET_FIELD_ERROR(you_can_join);
702   }
703   if (!DIO_GET(string, &din, "message", real_packet->message, sizeof(real_packet->message))) {
704     RECEIVE_PACKET_FIELD_ERROR(message);
705   }
706   if (!DIO_GET(string, &din, "capability", real_packet->capability, sizeof(real_packet->capability))) {
707     RECEIVE_PACKET_FIELD_ERROR(capability);
708   }
709   if (!DIO_GET(string, &din, "challenge_file", real_packet->challenge_file, sizeof(real_packet->challenge_file))) {
710     RECEIVE_PACKET_FIELD_ERROR(challenge_file);
711   }
712   if (!DIO_GET(sint16, &din, "conn_id", &real_packet->conn_id)) {
713     RECEIVE_PACKET_FIELD_ERROR(conn_id);
714   }
715 
716   log_packet_detailed("packet_server_join_reply_100: got info about ()");
717   post_receive_packet_server_join_reply(pc, real_packet);
718   RECEIVE_PACKET_END(real_packet);
719 }
720 
send_packet_server_join_reply_100(struct connection * pc,const struct packet_server_join_reply * packet)721 static int send_packet_server_join_reply_100(struct connection *pc, const struct packet_server_join_reply *packet)
722 {
723   const struct packet_server_join_reply *real_packet = packet;
724   SEND_PACKET_START(PACKET_SERVER_JOIN_REPLY);
725 
726   log_packet_detailed("packet_server_join_reply_100: sending info about ()");
727 
728   DIO_PUT(bool8, &dout, "you_can_join", real_packet->you_can_join);
729   DIO_PUT(string, &dout, "message", real_packet->message);
730   DIO_PUT(string, &dout, "capability", real_packet->capability);
731   DIO_PUT(string, &dout, "challenge_file", real_packet->challenge_file);
732   DIO_PUT(sint16, &dout, "conn_id", real_packet->conn_id);
733 
734   post_send_packet_server_join_reply(pc, real_packet);
735   SEND_PACKET_END(PACKET_SERVER_JOIN_REPLY);
736 }
737 
send_packet_server_join_reply(struct connection * pc,const struct packet_server_join_reply * packet)738 int send_packet_server_join_reply(struct connection *pc, const struct packet_server_join_reply *packet)
739 {
740   if (!pc->used) {
741     log_error("WARNING: trying to send data to the closed connection %s",
742               conn_description(pc));
743     return -1;
744   }
745   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SERVER_JOIN_REPLY].packet != NULL, -1,
746                         "Handler for PACKET_SERVER_JOIN_REPLY not installed");
747   return pc->phs.handlers->send[PACKET_SERVER_JOIN_REPLY].packet(pc, packet);
748 }
749 
750 #define hash_packet_authentication_req_100 hash_const
751 
752 #define cmp_packet_authentication_req_100 cmp_const
753 
754 BV_DEFINE(packet_authentication_req_100_fields, 2);
755 
receive_packet_authentication_req_100(struct connection * pc)756 static struct packet_authentication_req *receive_packet_authentication_req_100(struct connection *pc)
757 {
758   packet_authentication_req_100_fields fields;
759   struct packet_authentication_req *old;
760   struct genhash **hash = pc->phs.received + PACKET_AUTHENTICATION_REQ;
761   RECEIVE_PACKET_START(packet_authentication_req, real_packet);
762 
763   DIO_BV_GET(&din, fields);
764 
765   log_packet_detailed("packet_authentication_req_100: got info about ()");
766 
767   if (NULL == *hash) {
768     *hash = genhash_new_full(hash_packet_authentication_req_100, cmp_packet_authentication_req_100,
769                              NULL, NULL, NULL, free);
770   }
771 
772   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
773     *real_packet = *old;
774   } else {
775     log_packet_detailed("  no old info");
776     memset(real_packet, 0, sizeof(*real_packet));
777   }
778 
779   if (BV_ISSET(fields, 0)) {
780     log_packet_detailed("  got field 'type'");
781     {
782       int readin;
783 
784       if (!DIO_GET(uint8, &din, "type", &readin)) {
785         RECEIVE_PACKET_FIELD_ERROR(type);
786       }
787       real_packet->type = readin;
788     }
789   }
790   if (BV_ISSET(fields, 1)) {
791     log_packet_detailed("  got field 'message'");
792     if (!DIO_GET(string, &din, "message", real_packet->message, sizeof(real_packet->message))) {
793       RECEIVE_PACKET_FIELD_ERROR(message);
794     }
795   }
796 
797   if (NULL == old) {
798     old = fc_malloc(sizeof(*old));
799     *old = *real_packet;
800     genhash_insert(*hash, old, old);
801   } else {
802     *old = *real_packet;
803   }
804   RECEIVE_PACKET_END(real_packet);
805 }
806 
send_packet_authentication_req_100(struct connection * pc,const struct packet_authentication_req * packet)807 static int send_packet_authentication_req_100(struct connection *pc, const struct packet_authentication_req *packet)
808 {
809   const struct packet_authentication_req *real_packet = packet;
810   packet_authentication_req_100_fields fields;
811   struct packet_authentication_req *old;
812   bool differ;
813   struct genhash **hash = pc->phs.sent + PACKET_AUTHENTICATION_REQ;
814   int different = 0;
815   SEND_PACKET_START(PACKET_AUTHENTICATION_REQ);
816 
817   log_packet_detailed("packet_authentication_req_100: sending info about ()");
818 
819   if (NULL == *hash) {
820     *hash = genhash_new_full(hash_packet_authentication_req_100, cmp_packet_authentication_req_100,
821                              NULL, NULL, NULL, free);
822   }
823   BV_CLR_ALL(fields);
824 
825   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
826     old = fc_malloc(sizeof(*old));
827     *old = *real_packet;
828     genhash_insert(*hash, old, old);
829     memset(old, 0, sizeof(*old));
830     different = 1;      /* Force to send. */
831   }
832 
833   differ = (old->type != real_packet->type);
834   if (differ) {
835     different++;
836     BV_SET(fields, 0);
837   }
838 
839   differ = (strcmp(old->message, real_packet->message) != 0);
840   if (differ) {
841     different++;
842     BV_SET(fields, 1);
843   }
844 
845 
846   DIO_BV_PUT(&dout, "fields", fields);
847 
848   if (BV_ISSET(fields, 0)) {
849     log_packet_detailed("  field 'type' has changed");
850     DIO_PUT(uint8, &dout, "type", real_packet->type);
851   }
852   if (BV_ISSET(fields, 1)) {
853     log_packet_detailed("  field 'message' has changed");
854     DIO_PUT(string, &dout, "message", real_packet->message);
855   }
856 
857   *old = *real_packet;
858   SEND_PACKET_END(PACKET_AUTHENTICATION_REQ);
859 }
860 
send_packet_authentication_req(struct connection * pc,const struct packet_authentication_req * packet)861 int send_packet_authentication_req(struct connection *pc, const struct packet_authentication_req *packet)
862 {
863   if (!pc->used) {
864     log_error("WARNING: trying to send data to the closed connection %s",
865               conn_description(pc));
866     return -1;
867   }
868   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_AUTHENTICATION_REQ].packet != NULL, -1,
869                         "Handler for PACKET_AUTHENTICATION_REQ not installed");
870   return pc->phs.handlers->send[PACKET_AUTHENTICATION_REQ].packet(pc, packet);
871 }
872 
dsend_packet_authentication_req(struct connection * pc,enum authentication_type type,const char * message)873 int dsend_packet_authentication_req(struct connection *pc, enum authentication_type type, const char *message)
874 {
875   struct packet_authentication_req packet, *real_packet = &packet;
876 
877   real_packet->type = type;
878   sz_strlcpy(real_packet->message, message);
879 
880   return send_packet_authentication_req(pc, real_packet);
881 }
882 
883 #define hash_packet_authentication_reply_100 hash_const
884 
885 #define cmp_packet_authentication_reply_100 cmp_const
886 
887 BV_DEFINE(packet_authentication_reply_100_fields, 1);
888 
receive_packet_authentication_reply_100(struct connection * pc)889 static struct packet_authentication_reply *receive_packet_authentication_reply_100(struct connection *pc)
890 {
891   packet_authentication_reply_100_fields fields;
892   struct packet_authentication_reply *old;
893   struct genhash **hash = pc->phs.received + PACKET_AUTHENTICATION_REPLY;
894   RECEIVE_PACKET_START(packet_authentication_reply, real_packet);
895 
896   DIO_BV_GET(&din, fields);
897 
898   log_packet_detailed("packet_authentication_reply_100: got info about ()");
899 
900   if (NULL == *hash) {
901     *hash = genhash_new_full(hash_packet_authentication_reply_100, cmp_packet_authentication_reply_100,
902                              NULL, NULL, NULL, free);
903   }
904 
905   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
906     *real_packet = *old;
907   } else {
908     log_packet_detailed("  no old info");
909     memset(real_packet, 0, sizeof(*real_packet));
910   }
911 
912   if (BV_ISSET(fields, 0)) {
913     log_packet_detailed("  got field 'password'");
914     if (!DIO_GET(string, &din, "password", real_packet->password, sizeof(real_packet->password))) {
915       RECEIVE_PACKET_FIELD_ERROR(password);
916     }
917   }
918 
919   if (NULL == old) {
920     old = fc_malloc(sizeof(*old));
921     *old = *real_packet;
922     genhash_insert(*hash, old, old);
923   } else {
924     *old = *real_packet;
925   }
926   RECEIVE_PACKET_END(real_packet);
927 }
928 
send_packet_authentication_reply_100(struct connection * pc,const struct packet_authentication_reply * packet)929 static int send_packet_authentication_reply_100(struct connection *pc, const struct packet_authentication_reply *packet)
930 {
931   const struct packet_authentication_reply *real_packet = packet;
932   packet_authentication_reply_100_fields fields;
933   struct packet_authentication_reply *old;
934   bool differ;
935   struct genhash **hash = pc->phs.sent + PACKET_AUTHENTICATION_REPLY;
936   int different = 0;
937   SEND_PACKET_START(PACKET_AUTHENTICATION_REPLY);
938 
939   log_packet_detailed("packet_authentication_reply_100: sending info about ()");
940 
941   if (NULL == *hash) {
942     *hash = genhash_new_full(hash_packet_authentication_reply_100, cmp_packet_authentication_reply_100,
943                              NULL, NULL, NULL, free);
944   }
945   BV_CLR_ALL(fields);
946 
947   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
948     old = fc_malloc(sizeof(*old));
949     *old = *real_packet;
950     genhash_insert(*hash, old, old);
951     memset(old, 0, sizeof(*old));
952     different = 1;      /* Force to send. */
953   }
954 
955   differ = (strcmp(old->password, real_packet->password) != 0);
956   if (differ) {
957     different++;
958     BV_SET(fields, 0);
959   }
960 
961 
962   DIO_BV_PUT(&dout, "fields", fields);
963 
964   if (BV_ISSET(fields, 0)) {
965     log_packet_detailed("  field 'password' has changed");
966     DIO_PUT(string, &dout, "password", real_packet->password);
967   }
968 
969   *old = *real_packet;
970   SEND_PACKET_END(PACKET_AUTHENTICATION_REPLY);
971 }
972 
send_packet_authentication_reply(struct connection * pc,const struct packet_authentication_reply * packet)973 int send_packet_authentication_reply(struct connection *pc, const struct packet_authentication_reply *packet)
974 {
975   if (!pc->used) {
976     log_error("WARNING: trying to send data to the closed connection %s",
977               conn_description(pc));
978     return -1;
979   }
980   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_AUTHENTICATION_REPLY].packet != NULL, -1,
981                         "Handler for PACKET_AUTHENTICATION_REPLY not installed");
982   return pc->phs.handlers->send[PACKET_AUTHENTICATION_REPLY].packet(pc, packet);
983 }
984 
receive_packet_server_shutdown_100(struct connection * pc)985 static struct packet_server_shutdown *receive_packet_server_shutdown_100(struct connection *pc)
986 {
987   RECEIVE_PACKET_START(packet_server_shutdown, real_packet);
988   real_packet->__dummy = 0xff;
989   log_packet_detailed("packet_server_shutdown_100: got info about ()");
990   RECEIVE_PACKET_END(real_packet);
991 }
992 
send_packet_server_shutdown_100(struct connection * pc)993 static int send_packet_server_shutdown_100(struct connection *pc)
994 {
995   SEND_PACKET_START(PACKET_SERVER_SHUTDOWN);
996 
997   log_packet_detailed("packet_server_shutdown_100: sending info about ()");
998   SEND_PACKET_END(PACKET_SERVER_SHUTDOWN);
999 }
1000 
send_packet_server_shutdown(struct connection * pc)1001 int send_packet_server_shutdown(struct connection *pc)
1002 {
1003   if (!pc->used) {
1004     log_error("WARNING: trying to send data to the closed connection %s",
1005               conn_description(pc));
1006     return -1;
1007   }
1008   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SERVER_SHUTDOWN].no_packet != NULL, -1,
1009                         "Handler for PACKET_SERVER_SHUTDOWN not installed");
1010   return pc->phs.handlers->send[PACKET_SERVER_SHUTDOWN].no_packet(pc);
1011 }
1012 
lsend_packet_server_shutdown(struct conn_list * dest)1013 void lsend_packet_server_shutdown(struct conn_list *dest)
1014 {
1015   conn_list_iterate(dest, pconn) {
1016     send_packet_server_shutdown(pconn);
1017   } conn_list_iterate_end;
1018 }
1019 
1020 #define hash_packet_nation_select_req_100 hash_const
1021 
1022 #define cmp_packet_nation_select_req_100 cmp_const
1023 
1024 BV_DEFINE(packet_nation_select_req_100_fields, 5);
1025 
receive_packet_nation_select_req_100(struct connection * pc)1026 static struct packet_nation_select_req *receive_packet_nation_select_req_100(struct connection *pc)
1027 {
1028   packet_nation_select_req_100_fields fields;
1029   struct packet_nation_select_req *old;
1030   struct genhash **hash = pc->phs.received + PACKET_NATION_SELECT_REQ;
1031   RECEIVE_PACKET_START(packet_nation_select_req, real_packet);
1032 
1033   DIO_BV_GET(&din, fields);
1034 
1035   log_packet_detailed("packet_nation_select_req_100: got info about ()");
1036 
1037   if (NULL == *hash) {
1038     *hash = genhash_new_full(hash_packet_nation_select_req_100, cmp_packet_nation_select_req_100,
1039                              NULL, NULL, NULL, free);
1040   }
1041 
1042   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
1043     *real_packet = *old;
1044   } else {
1045     log_packet_detailed("  no old info");
1046     memset(real_packet, 0, sizeof(*real_packet));
1047   }
1048 
1049   if (BV_ISSET(fields, 0)) {
1050     log_packet_detailed("  got field 'player_no'");
1051     if (!DIO_GET(uint8, &din, "player_no", &real_packet->player_no)) {
1052       RECEIVE_PACKET_FIELD_ERROR(player_no);
1053     }
1054   }
1055   if (BV_ISSET(fields, 1)) {
1056     log_packet_detailed("  got field 'nation_no'");
1057     {
1058       int readin;
1059 
1060       if (!DIO_GET(sint16, &din, "nation_no", &readin)) {
1061         RECEIVE_PACKET_FIELD_ERROR(nation_no);
1062       }
1063       real_packet->nation_no = readin;
1064     }
1065   }
1066   real_packet->is_male = BV_ISSET(fields, 2);
1067   if (BV_ISSET(fields, 3)) {
1068     log_packet_detailed("  got field 'name'");
1069     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
1070       RECEIVE_PACKET_FIELD_ERROR(name);
1071     }
1072   }
1073   if (BV_ISSET(fields, 4)) {
1074     log_packet_detailed("  got field 'style'");
1075     if (!DIO_GET(uint8, &din, "style", &real_packet->style)) {
1076       RECEIVE_PACKET_FIELD_ERROR(style);
1077     }
1078   }
1079 
1080   if (NULL == old) {
1081     old = fc_malloc(sizeof(*old));
1082     *old = *real_packet;
1083     genhash_insert(*hash, old, old);
1084   } else {
1085     *old = *real_packet;
1086   }
1087   RECEIVE_PACKET_END(real_packet);
1088 }
1089 
send_packet_nation_select_req_100(struct connection * pc,const struct packet_nation_select_req * packet)1090 static int send_packet_nation_select_req_100(struct connection *pc, const struct packet_nation_select_req *packet)
1091 {
1092   const struct packet_nation_select_req *real_packet = packet;
1093   packet_nation_select_req_100_fields fields;
1094   struct packet_nation_select_req *old;
1095   bool differ;
1096   struct genhash **hash = pc->phs.sent + PACKET_NATION_SELECT_REQ;
1097   int different = 0;
1098   SEND_PACKET_START(PACKET_NATION_SELECT_REQ);
1099 
1100   log_packet_detailed("packet_nation_select_req_100: sending info about ()");
1101 
1102   if (NULL == *hash) {
1103     *hash = genhash_new_full(hash_packet_nation_select_req_100, cmp_packet_nation_select_req_100,
1104                              NULL, NULL, NULL, free);
1105   }
1106   BV_CLR_ALL(fields);
1107 
1108   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
1109     old = fc_malloc(sizeof(*old));
1110     *old = *real_packet;
1111     genhash_insert(*hash, old, old);
1112     memset(old, 0, sizeof(*old));
1113     different = 1;      /* Force to send. */
1114   }
1115 
1116   differ = (old->player_no != real_packet->player_no);
1117   if (differ) {
1118     different++;
1119     BV_SET(fields, 0);
1120   }
1121 
1122   differ = (old->nation_no != real_packet->nation_no);
1123   if (differ) {
1124     different++;
1125     BV_SET(fields, 1);
1126   }
1127 
1128   differ = (old->is_male != real_packet->is_male);
1129   if (differ) {
1130     different++;
1131   }
1132   if (packet->is_male) {
1133     BV_SET(fields, 2);
1134   }
1135 
1136   differ = (strcmp(old->name, real_packet->name) != 0);
1137   if (differ) {
1138     different++;
1139     BV_SET(fields, 3);
1140   }
1141 
1142   differ = (old->style != real_packet->style);
1143   if (differ) {
1144     different++;
1145     BV_SET(fields, 4);
1146   }
1147 
1148 
1149   DIO_BV_PUT(&dout, "fields", fields);
1150 
1151   if (BV_ISSET(fields, 0)) {
1152     log_packet_detailed("  field 'player_no' has changed");
1153     DIO_PUT(uint8, &dout, "player_no", real_packet->player_no);
1154   }
1155   if (BV_ISSET(fields, 1)) {
1156     log_packet_detailed("  field 'nation_no' has changed");
1157     DIO_PUT(sint16, &dout, "nation_no", real_packet->nation_no);
1158   }
1159   /* field 2 is folded into the header */
1160   if (BV_ISSET(fields, 3)) {
1161     log_packet_detailed("  field 'name' has changed");
1162     DIO_PUT(string, &dout, "name", real_packet->name);
1163   }
1164   if (BV_ISSET(fields, 4)) {
1165     log_packet_detailed("  field 'style' has changed");
1166     DIO_PUT(uint8, &dout, "style", real_packet->style);
1167   }
1168 
1169   *old = *real_packet;
1170   SEND_PACKET_END(PACKET_NATION_SELECT_REQ);
1171 }
1172 
send_packet_nation_select_req(struct connection * pc,const struct packet_nation_select_req * packet)1173 int send_packet_nation_select_req(struct connection *pc, const struct packet_nation_select_req *packet)
1174 {
1175   if (!pc->used) {
1176     log_error("WARNING: trying to send data to the closed connection %s",
1177               conn_description(pc));
1178     return -1;
1179   }
1180   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_NATION_SELECT_REQ].packet != NULL, -1,
1181                         "Handler for PACKET_NATION_SELECT_REQ not installed");
1182   return pc->phs.handlers->send[PACKET_NATION_SELECT_REQ].packet(pc, packet);
1183 }
1184 
dsend_packet_nation_select_req(struct connection * pc,int player_no,Nation_type_id nation_no,bool is_male,const char * name,int style)1185 int dsend_packet_nation_select_req(struct connection *pc, int player_no, Nation_type_id nation_no, bool is_male, const char *name, int style)
1186 {
1187   struct packet_nation_select_req packet, *real_packet = &packet;
1188 
1189   real_packet->player_no = player_no;
1190   real_packet->nation_no = nation_no;
1191   real_packet->is_male = is_male;
1192   sz_strlcpy(real_packet->name, name);
1193   real_packet->style = style;
1194 
1195   return send_packet_nation_select_req(pc, real_packet);
1196 }
1197 
1198 #define hash_packet_player_ready_100 hash_const
1199 
1200 #define cmp_packet_player_ready_100 cmp_const
1201 
1202 BV_DEFINE(packet_player_ready_100_fields, 2);
1203 
receive_packet_player_ready_100(struct connection * pc)1204 static struct packet_player_ready *receive_packet_player_ready_100(struct connection *pc)
1205 {
1206   packet_player_ready_100_fields fields;
1207   struct packet_player_ready *old;
1208   struct genhash **hash = pc->phs.received + PACKET_PLAYER_READY;
1209   RECEIVE_PACKET_START(packet_player_ready, real_packet);
1210 
1211   DIO_BV_GET(&din, fields);
1212 
1213   log_packet_detailed("packet_player_ready_100: got info about ()");
1214 
1215   if (NULL == *hash) {
1216     *hash = genhash_new_full(hash_packet_player_ready_100, cmp_packet_player_ready_100,
1217                              NULL, NULL, NULL, free);
1218   }
1219 
1220   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
1221     *real_packet = *old;
1222   } else {
1223     log_packet_detailed("  no old info");
1224     memset(real_packet, 0, sizeof(*real_packet));
1225   }
1226 
1227   if (BV_ISSET(fields, 0)) {
1228     log_packet_detailed("  got field 'player_no'");
1229     if (!DIO_GET(uint8, &din, "player_no", &real_packet->player_no)) {
1230       RECEIVE_PACKET_FIELD_ERROR(player_no);
1231     }
1232   }
1233   real_packet->is_ready = BV_ISSET(fields, 1);
1234 
1235   if (NULL == old) {
1236     old = fc_malloc(sizeof(*old));
1237     *old = *real_packet;
1238     genhash_insert(*hash, old, old);
1239   } else {
1240     *old = *real_packet;
1241   }
1242   RECEIVE_PACKET_END(real_packet);
1243 }
1244 
send_packet_player_ready_100(struct connection * pc,const struct packet_player_ready * packet)1245 static int send_packet_player_ready_100(struct connection *pc, const struct packet_player_ready *packet)
1246 {
1247   const struct packet_player_ready *real_packet = packet;
1248   packet_player_ready_100_fields fields;
1249   struct packet_player_ready *old;
1250   bool differ;
1251   struct genhash **hash = pc->phs.sent + PACKET_PLAYER_READY;
1252   int different = 0;
1253   SEND_PACKET_START(PACKET_PLAYER_READY);
1254 
1255   log_packet_detailed("packet_player_ready_100: sending info about ()");
1256 
1257   if (NULL == *hash) {
1258     *hash = genhash_new_full(hash_packet_player_ready_100, cmp_packet_player_ready_100,
1259                              NULL, NULL, NULL, free);
1260   }
1261   BV_CLR_ALL(fields);
1262 
1263   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
1264     old = fc_malloc(sizeof(*old));
1265     *old = *real_packet;
1266     genhash_insert(*hash, old, old);
1267     memset(old, 0, sizeof(*old));
1268     different = 1;      /* Force to send. */
1269   }
1270 
1271   differ = (old->player_no != real_packet->player_no);
1272   if (differ) {
1273     different++;
1274     BV_SET(fields, 0);
1275   }
1276 
1277   differ = (old->is_ready != real_packet->is_ready);
1278   if (differ) {
1279     different++;
1280   }
1281   if (packet->is_ready) {
1282     BV_SET(fields, 1);
1283   }
1284 
1285 
1286   DIO_BV_PUT(&dout, "fields", fields);
1287 
1288   if (BV_ISSET(fields, 0)) {
1289     log_packet_detailed("  field 'player_no' has changed");
1290     DIO_PUT(uint8, &dout, "player_no", real_packet->player_no);
1291   }
1292   /* field 1 is folded into the header */
1293 
1294   *old = *real_packet;
1295   SEND_PACKET_END(PACKET_PLAYER_READY);
1296 }
1297 
send_packet_player_ready(struct connection * pc,const struct packet_player_ready * packet)1298 int send_packet_player_ready(struct connection *pc, const struct packet_player_ready *packet)
1299 {
1300   if (!pc->used) {
1301     log_error("WARNING: trying to send data to the closed connection %s",
1302               conn_description(pc));
1303     return -1;
1304   }
1305   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_READY].packet != NULL, -1,
1306                         "Handler for PACKET_PLAYER_READY not installed");
1307   return pc->phs.handlers->send[PACKET_PLAYER_READY].packet(pc, packet);
1308 }
1309 
dsend_packet_player_ready(struct connection * pc,int player_no,bool is_ready)1310 int dsend_packet_player_ready(struct connection *pc, int player_no, bool is_ready)
1311 {
1312   struct packet_player_ready packet, *real_packet = &packet;
1313 
1314   real_packet->player_no = player_no;
1315   real_packet->is_ready = is_ready;
1316 
1317   return send_packet_player_ready(pc, real_packet);
1318 }
1319 
receive_packet_endgame_report_100(struct connection * pc)1320 static struct packet_endgame_report *receive_packet_endgame_report_100(struct connection *pc)
1321 {
1322   RECEIVE_PACKET_START(packet_endgame_report, real_packet);
1323   if (!DIO_GET(uint8, &din, "category_num", &real_packet->category_num)) {
1324     RECEIVE_PACKET_FIELD_ERROR(category_num);
1325   }
1326 
1327   {
1328     int i;
1329 
1330     if (real_packet->category_num > 32) {
1331       RECEIVE_PACKET_FIELD_ERROR(category_name, ": truncation array");
1332     }
1333     for (i = 0; i < real_packet->category_num; i++) {
1334       if (!DIO_GET(string, &din, "category_name", real_packet->category_name[i], sizeof(real_packet->category_name[i]))) {
1335         RECEIVE_PACKET_FIELD_ERROR(category_name);
1336       }
1337     }
1338   }
1339   if (!DIO_GET(uint8, &din, "player_num", &real_packet->player_num)) {
1340     RECEIVE_PACKET_FIELD_ERROR(player_num);
1341   }
1342 
1343   log_packet_detailed("packet_endgame_report_100: got info about ()");
1344   RECEIVE_PACKET_END(real_packet);
1345 }
1346 
send_packet_endgame_report_100(struct connection * pc,const struct packet_endgame_report * packet)1347 static int send_packet_endgame_report_100(struct connection *pc, const struct packet_endgame_report *packet)
1348 {
1349   const struct packet_endgame_report *real_packet = packet;
1350   SEND_PACKET_START(PACKET_ENDGAME_REPORT);
1351 
1352   log_packet_detailed("packet_endgame_report_100: sending info about ()");
1353 
1354   DIO_PUT(uint8, &dout, "category_num", real_packet->category_num);
1355 
1356     {
1357       int i;
1358 
1359       for (i = 0; i < real_packet->category_num; i++) {
1360         dio_put_string(&dout, real_packet->category_name[i]);
1361       }
1362     }
1363   DIO_PUT(uint8, &dout, "player_num", real_packet->player_num);
1364 
1365   SEND_PACKET_END(PACKET_ENDGAME_REPORT);
1366 }
1367 
send_packet_endgame_report(struct connection * pc,const struct packet_endgame_report * packet)1368 int send_packet_endgame_report(struct connection *pc, const struct packet_endgame_report *packet)
1369 {
1370   if (!pc->used) {
1371     log_error("WARNING: trying to send data to the closed connection %s",
1372               conn_description(pc));
1373     return -1;
1374   }
1375   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_ENDGAME_REPORT].packet != NULL, -1,
1376                         "Handler for PACKET_ENDGAME_REPORT not installed");
1377   return pc->phs.handlers->send[PACKET_ENDGAME_REPORT].packet(pc, packet);
1378 }
1379 
lsend_packet_endgame_report(struct conn_list * dest,const struct packet_endgame_report * packet)1380 void lsend_packet_endgame_report(struct conn_list *dest, const struct packet_endgame_report *packet)
1381 {
1382   conn_list_iterate(dest, pconn) {
1383     send_packet_endgame_report(pconn, packet);
1384   } conn_list_iterate_end;
1385 }
1386 
receive_packet_endgame_player_100(struct connection * pc)1387 static struct packet_endgame_player *receive_packet_endgame_player_100(struct connection *pc)
1388 {
1389   RECEIVE_PACKET_START(packet_endgame_player, real_packet);
1390   if (!DIO_GET(uint8, &din, "category_num", &real_packet->category_num)) {
1391     RECEIVE_PACKET_FIELD_ERROR(category_num);
1392   }
1393   if (!DIO_GET(uint8, &din, "player_id", &real_packet->player_id)) {
1394     RECEIVE_PACKET_FIELD_ERROR(player_id);
1395   }
1396   if (!DIO_GET(uint16, &din, "score", &real_packet->score)) {
1397     RECEIVE_PACKET_FIELD_ERROR(score);
1398   }
1399 
1400   {
1401     int i;
1402 
1403     if (real_packet->category_num > 32) {
1404       RECEIVE_PACKET_FIELD_ERROR(category_score, ": truncation array");
1405     }
1406     for (i = 0; i < real_packet->category_num; i++) {
1407       if (!DIO_GET(uint32, &din, "category_score", &real_packet->category_score[i])) {
1408         RECEIVE_PACKET_FIELD_ERROR(category_score);
1409       }
1410     }
1411   }
1412   if (!DIO_GET(bool8, &din, "winner", &real_packet->winner)) {
1413     RECEIVE_PACKET_FIELD_ERROR(winner);
1414   }
1415 
1416   log_packet_detailed("packet_endgame_player_100: got info about ()");
1417   RECEIVE_PACKET_END(real_packet);
1418 }
1419 
send_packet_endgame_player_100(struct connection * pc,const struct packet_endgame_player * packet)1420 static int send_packet_endgame_player_100(struct connection *pc, const struct packet_endgame_player *packet)
1421 {
1422   const struct packet_endgame_player *real_packet = packet;
1423   SEND_PACKET_START(PACKET_ENDGAME_PLAYER);
1424 
1425   log_packet_detailed("packet_endgame_player_100: sending info about ()");
1426 
1427   DIO_PUT(uint8, &dout, "category_num", real_packet->category_num);
1428   DIO_PUT(uint8, &dout, "player_id", real_packet->player_id);
1429   DIO_PUT(uint16, &dout, "score", real_packet->score);
1430 
1431     {
1432       int i;
1433 
1434       for (i = 0; i < real_packet->category_num; i++) {
1435         dio_put_uint32(&dout, real_packet->category_score[i]);
1436       }
1437     }
1438   DIO_PUT(bool8, &dout, "winner", real_packet->winner);
1439 
1440   SEND_PACKET_END(PACKET_ENDGAME_PLAYER);
1441 }
1442 
send_packet_endgame_player(struct connection * pc,const struct packet_endgame_player * packet)1443 int send_packet_endgame_player(struct connection *pc, const struct packet_endgame_player *packet)
1444 {
1445   if (!pc->used) {
1446     log_error("WARNING: trying to send data to the closed connection %s",
1447               conn_description(pc));
1448     return -1;
1449   }
1450   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_ENDGAME_PLAYER].packet != NULL, -1,
1451                         "Handler for PACKET_ENDGAME_PLAYER not installed");
1452   return pc->phs.handlers->send[PACKET_ENDGAME_PLAYER].packet(pc, packet);
1453 }
1454 
lsend_packet_endgame_player(struct conn_list * dest,const struct packet_endgame_player * packet)1455 void lsend_packet_endgame_player(struct conn_list *dest, const struct packet_endgame_player *packet)
1456 {
1457   conn_list_iterate(dest, pconn) {
1458     send_packet_endgame_player(pconn, packet);
1459   } conn_list_iterate_end;
1460 }
1461 
hash_packet_tile_info_100(const void * vkey)1462 static genhash_val_t hash_packet_tile_info_100(const void *vkey)
1463 {
1464   const struct packet_tile_info *key = (const struct packet_tile_info *) vkey;
1465 
1466   return key->tile;
1467 }
1468 
cmp_packet_tile_info_100(const void * vkey1,const void * vkey2)1469 static bool cmp_packet_tile_info_100(const void *vkey1, const void *vkey2)
1470 {
1471   const struct packet_tile_info *key1 = (const struct packet_tile_info *) vkey1;
1472   const struct packet_tile_info *key2 = (const struct packet_tile_info *) vkey2;
1473 
1474   return key1->tile == key2->tile;
1475 }
1476 
1477 BV_DEFINE(packet_tile_info_100_fields, 10);
1478 
receive_packet_tile_info_100(struct connection * pc)1479 static struct packet_tile_info *receive_packet_tile_info_100(struct connection *pc)
1480 {
1481   packet_tile_info_100_fields fields;
1482   struct packet_tile_info *old;
1483   struct genhash **hash = pc->phs.received + PACKET_TILE_INFO;
1484   RECEIVE_PACKET_START(packet_tile_info, real_packet);
1485 
1486   DIO_BV_GET(&din, fields);
1487   if (!DIO_GET(sint32, &din, "tile", &real_packet->tile)) {
1488     RECEIVE_PACKET_FIELD_ERROR(tile);
1489   }
1490 
1491   log_packet_detailed("packet_tile_info_100: got info about (%d)",
1492     real_packet->tile);
1493 
1494   if (NULL == *hash) {
1495     *hash = genhash_new_full(hash_packet_tile_info_100, cmp_packet_tile_info_100,
1496                              NULL, NULL, NULL, free);
1497   }
1498 
1499   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
1500     *real_packet = *old;
1501   } else {
1502     int tile = real_packet->tile;
1503 
1504     log_packet_detailed("  no old info");
1505     memset(real_packet, 0, sizeof(*real_packet));
1506 
1507     real_packet->tile = tile;
1508   }
1509 
1510   if (BV_ISSET(fields, 0)) {
1511     log_packet_detailed("  got field 'continent'");
1512     {
1513       int readin;
1514 
1515       if (!DIO_GET(sint16, &din, "continent", &readin)) {
1516         RECEIVE_PACKET_FIELD_ERROR(continent);
1517       }
1518       real_packet->continent = readin;
1519     }
1520   }
1521   if (BV_ISSET(fields, 1)) {
1522     log_packet_detailed("  got field 'known'");
1523     {
1524       int readin;
1525 
1526       if (!DIO_GET(uint8, &din, "known", &readin)) {
1527         RECEIVE_PACKET_FIELD_ERROR(known);
1528       }
1529       real_packet->known = readin;
1530     }
1531   }
1532   if (BV_ISSET(fields, 2)) {
1533     log_packet_detailed("  got field 'owner'");
1534     if (!DIO_GET(uint8, &din, "owner", &real_packet->owner)) {
1535       RECEIVE_PACKET_FIELD_ERROR(owner);
1536     }
1537   }
1538   if (BV_ISSET(fields, 3)) {
1539     log_packet_detailed("  got field 'extras_owner'");
1540     if (!DIO_GET(uint8, &din, "extras_owner", &real_packet->extras_owner)) {
1541       RECEIVE_PACKET_FIELD_ERROR(extras_owner);
1542     }
1543   }
1544   if (BV_ISSET(fields, 4)) {
1545     log_packet_detailed("  got field 'worked'");
1546     if (!DIO_GET(uint16, &din, "worked", &real_packet->worked)) {
1547       RECEIVE_PACKET_FIELD_ERROR(worked);
1548     }
1549   }
1550   if (BV_ISSET(fields, 5)) {
1551     log_packet_detailed("  got field 'terrain'");
1552     {
1553       int readin;
1554 
1555       if (!DIO_GET(uint8, &din, "terrain", &readin)) {
1556         RECEIVE_PACKET_FIELD_ERROR(terrain);
1557       }
1558       real_packet->terrain = readin;
1559     }
1560   }
1561   if (BV_ISSET(fields, 6)) {
1562     log_packet_detailed("  got field 'resource'");
1563     {
1564       int readin;
1565 
1566       if (!DIO_GET(uint8, &din, "resource", &readin)) {
1567         RECEIVE_PACKET_FIELD_ERROR(resource);
1568       }
1569       real_packet->resource = readin;
1570     }
1571   }
1572   if (BV_ISSET(fields, 7)) {
1573     log_packet_detailed("  got field 'extras'");
1574     if (!DIO_BV_GET(&din, real_packet->extras)) {
1575       RECEIVE_PACKET_FIELD_ERROR(extras);
1576     }
1577   }
1578   if (BV_ISSET(fields, 8)) {
1579     log_packet_detailed("  got field 'spec_sprite'");
1580     if (!DIO_GET(string, &din, "spec_sprite", real_packet->spec_sprite, sizeof(real_packet->spec_sprite))) {
1581       RECEIVE_PACKET_FIELD_ERROR(spec_sprite);
1582     }
1583   }
1584   if (BV_ISSET(fields, 9)) {
1585     log_packet_detailed("  got field 'label'");
1586     if (!DIO_GET(string, &din, "label", real_packet->label, sizeof(real_packet->label))) {
1587       RECEIVE_PACKET_FIELD_ERROR(label);
1588     }
1589   }
1590 
1591   if (NULL == old) {
1592     old = fc_malloc(sizeof(*old));
1593     *old = *real_packet;
1594     genhash_insert(*hash, old, old);
1595   } else {
1596     *old = *real_packet;
1597   }
1598   RECEIVE_PACKET_END(real_packet);
1599 }
1600 
send_packet_tile_info_100(struct connection * pc,const struct packet_tile_info * packet)1601 static int send_packet_tile_info_100(struct connection *pc, const struct packet_tile_info *packet)
1602 {
1603   const struct packet_tile_info *real_packet = packet;
1604   packet_tile_info_100_fields fields;
1605   struct packet_tile_info *old;
1606   bool differ;
1607   struct genhash **hash = pc->phs.sent + PACKET_TILE_INFO;
1608   int different = 0;
1609   SEND_PACKET_START(PACKET_TILE_INFO);
1610 
1611   log_packet_detailed("packet_tile_info_100: sending info about (%d)",
1612     real_packet->tile);
1613 
1614   if (NULL == *hash) {
1615     *hash = genhash_new_full(hash_packet_tile_info_100, cmp_packet_tile_info_100,
1616                              NULL, NULL, NULL, free);
1617   }
1618   BV_CLR_ALL(fields);
1619 
1620   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
1621     old = fc_malloc(sizeof(*old));
1622     *old = *real_packet;
1623     genhash_insert(*hash, old, old);
1624     memset(old, 0, sizeof(*old));
1625     different = 1;      /* Force to send. */
1626   }
1627 
1628   differ = (old->continent != real_packet->continent);
1629   if (differ) {
1630     different++;
1631     BV_SET(fields, 0);
1632   }
1633 
1634   differ = (old->known != real_packet->known);
1635   if (differ) {
1636     different++;
1637     BV_SET(fields, 1);
1638   }
1639 
1640   differ = (old->owner != real_packet->owner);
1641   if (differ) {
1642     different++;
1643     BV_SET(fields, 2);
1644   }
1645 
1646   differ = (old->extras_owner != real_packet->extras_owner);
1647   if (differ) {
1648     different++;
1649     BV_SET(fields, 3);
1650   }
1651 
1652   differ = (old->worked != real_packet->worked);
1653   if (differ) {
1654     different++;
1655     BV_SET(fields, 4);
1656   }
1657 
1658   differ = (old->terrain != real_packet->terrain);
1659   if (differ) {
1660     different++;
1661     BV_SET(fields, 5);
1662   }
1663 
1664   differ = (old->resource != real_packet->resource);
1665   if (differ) {
1666     different++;
1667     BV_SET(fields, 6);
1668   }
1669 
1670   differ = !BV_ARE_EQUAL(old->extras, real_packet->extras);
1671   if (differ) {
1672     different++;
1673     BV_SET(fields, 7);
1674   }
1675 
1676   differ = (strcmp(old->spec_sprite, real_packet->spec_sprite) != 0);
1677   if (differ) {
1678     different++;
1679     BV_SET(fields, 8);
1680   }
1681 
1682   differ = (strcmp(old->label, real_packet->label) != 0);
1683   if (differ) {
1684     different++;
1685     BV_SET(fields, 9);
1686   }
1687 
1688 
1689   if (different == 0) {
1690     log_packet_detailed("  no change -> discard");
1691     return 0;
1692   }
1693 
1694   DIO_BV_PUT(&dout, "fields", fields);
1695   DIO_PUT(sint32, &dout, "tile", real_packet->tile);
1696 
1697   if (BV_ISSET(fields, 0)) {
1698     log_packet_detailed("  field 'continent' has changed");
1699     DIO_PUT(sint16, &dout, "continent", real_packet->continent);
1700   }
1701   if (BV_ISSET(fields, 1)) {
1702     log_packet_detailed("  field 'known' has changed");
1703     DIO_PUT(uint8, &dout, "known", real_packet->known);
1704   }
1705   if (BV_ISSET(fields, 2)) {
1706     log_packet_detailed("  field 'owner' has changed");
1707     DIO_PUT(uint8, &dout, "owner", real_packet->owner);
1708   }
1709   if (BV_ISSET(fields, 3)) {
1710     log_packet_detailed("  field 'extras_owner' has changed");
1711     DIO_PUT(uint8, &dout, "extras_owner", real_packet->extras_owner);
1712   }
1713   if (BV_ISSET(fields, 4)) {
1714     log_packet_detailed("  field 'worked' has changed");
1715     DIO_PUT(uint16, &dout, "worked", real_packet->worked);
1716   }
1717   if (BV_ISSET(fields, 5)) {
1718     log_packet_detailed("  field 'terrain' has changed");
1719     DIO_PUT(uint8, &dout, "terrain", real_packet->terrain);
1720   }
1721   if (BV_ISSET(fields, 6)) {
1722     log_packet_detailed("  field 'resource' has changed");
1723     DIO_PUT(uint8, &dout, "resource", real_packet->resource);
1724   }
1725   if (BV_ISSET(fields, 7)) {
1726     log_packet_detailed("  field 'extras' has changed");
1727   DIO_BV_PUT(&dout, "extras", packet->extras);
1728   }
1729   if (BV_ISSET(fields, 8)) {
1730     log_packet_detailed("  field 'spec_sprite' has changed");
1731     DIO_PUT(string, &dout, "spec_sprite", real_packet->spec_sprite);
1732   }
1733   if (BV_ISSET(fields, 9)) {
1734     log_packet_detailed("  field 'label' has changed");
1735     DIO_PUT(string, &dout, "label", real_packet->label);
1736   }
1737 
1738   *old = *real_packet;
1739   SEND_PACKET_END(PACKET_TILE_INFO);
1740 }
1741 
send_packet_tile_info(struct connection * pc,const struct packet_tile_info * packet)1742 int send_packet_tile_info(struct connection *pc, const struct packet_tile_info *packet)
1743 {
1744   if (!pc->used) {
1745     log_error("WARNING: trying to send data to the closed connection %s",
1746               conn_description(pc));
1747     return -1;
1748   }
1749   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_TILE_INFO].packet != NULL, -1,
1750                         "Handler for PACKET_TILE_INFO not installed");
1751   return pc->phs.handlers->send[PACKET_TILE_INFO].packet(pc, packet);
1752 }
1753 
lsend_packet_tile_info(struct conn_list * dest,const struct packet_tile_info * packet)1754 void lsend_packet_tile_info(struct conn_list *dest, const struct packet_tile_info *packet)
1755 {
1756   conn_list_iterate(dest, pconn) {
1757     send_packet_tile_info(pconn, packet);
1758   } conn_list_iterate_end;
1759 }
1760 
1761 #define hash_packet_game_info_100 hash_const
1762 
1763 #define cmp_packet_game_info_100 cmp_const
1764 
1765 BV_DEFINE(packet_game_info_100_fields, 108);
1766 
receive_packet_game_info_100(struct connection * pc)1767 static struct packet_game_info *receive_packet_game_info_100(struct connection *pc)
1768 {
1769   packet_game_info_100_fields fields;
1770   struct packet_game_info *old;
1771   struct genhash **hash = pc->phs.received + PACKET_GAME_INFO;
1772   RECEIVE_PACKET_START(packet_game_info, real_packet);
1773 
1774   DIO_BV_GET(&din, fields);
1775 
1776   log_packet_detailed("packet_game_info_100: got info about ()");
1777 
1778   if (NULL == *hash) {
1779     *hash = genhash_new_full(hash_packet_game_info_100, cmp_packet_game_info_100,
1780                              NULL, NULL, NULL, free);
1781   }
1782 
1783   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
1784     *real_packet = *old;
1785   } else {
1786     log_packet_detailed("  no old info");
1787     memset(real_packet, 0, sizeof(*real_packet));
1788   }
1789 
1790   if (BV_ISSET(fields, 0)) {
1791     log_packet_detailed("  got field 'add_to_size_limit'");
1792     if (!DIO_GET(uint8, &din, "add_to_size_limit", &real_packet->add_to_size_limit)) {
1793       RECEIVE_PACKET_FIELD_ERROR(add_to_size_limit);
1794     }
1795   }
1796   if (BV_ISSET(fields, 1)) {
1797     log_packet_detailed("  got field 'aifill'");
1798     if (!DIO_GET(uint8, &din, "aifill", &real_packet->aifill)) {
1799       RECEIVE_PACKET_FIELD_ERROR(aifill);
1800     }
1801   }
1802   if (BV_ISSET(fields, 2)) {
1803     log_packet_detailed("  got field 'persistent_ready'");
1804     {
1805       int readin;
1806 
1807       if (!DIO_GET(uint8, &din, "persistent_ready", &readin)) {
1808         RECEIVE_PACKET_FIELD_ERROR(persistent_ready);
1809       }
1810       real_packet->persistent_ready = readin;
1811     }
1812   }
1813   if (BV_ISSET(fields, 3)) {
1814     log_packet_detailed("  got field 'airlifting_style'");
1815     {
1816       int readin;
1817 
1818       if (!DIO_GET(uint8, &din, "airlifting_style", &readin)) {
1819         RECEIVE_PACKET_FIELD_ERROR(airlifting_style);
1820       }
1821       real_packet->airlifting_style = readin;
1822     }
1823   }
1824   if (BV_ISSET(fields, 4)) {
1825     log_packet_detailed("  got field 'angrycitizen'");
1826     if (!DIO_GET(uint8, &din, "angrycitizen", &real_packet->angrycitizen)) {
1827       RECEIVE_PACKET_FIELD_ERROR(angrycitizen);
1828     }
1829   }
1830   if (BV_ISSET(fields, 5)) {
1831     log_packet_detailed("  got field 'base_pollution'");
1832     if (!DIO_GET(sint16, &din, "base_pollution", &real_packet->base_pollution)) {
1833       RECEIVE_PACKET_FIELD_ERROR(base_pollution);
1834     }
1835   }
1836   if (BV_ISSET(fields, 6)) {
1837     log_packet_detailed("  got field 'base_tech_cost'");
1838     if (!DIO_GET(uint8, &din, "base_tech_cost", &real_packet->base_tech_cost)) {
1839       RECEIVE_PACKET_FIELD_ERROR(base_tech_cost);
1840     }
1841   }
1842   if (BV_ISSET(fields, 7)) {
1843     log_packet_detailed("  got field 'border_city_radius_sq'");
1844     if (!DIO_GET(uint16, &din, "border_city_radius_sq", &real_packet->border_city_radius_sq)) {
1845       RECEIVE_PACKET_FIELD_ERROR(border_city_radius_sq);
1846     }
1847   }
1848   if (BV_ISSET(fields, 8)) {
1849     log_packet_detailed("  got field 'border_size_effect'");
1850     if (!DIO_GET(uint8, &din, "border_size_effect", &real_packet->border_size_effect)) {
1851       RECEIVE_PACKET_FIELD_ERROR(border_size_effect);
1852     }
1853   }
1854   if (BV_ISSET(fields, 9)) {
1855     log_packet_detailed("  got field 'border_city_permanent_radius_sq'");
1856     if (!DIO_GET(sint16, &din, "border_city_permanent_radius_sq", &real_packet->border_city_permanent_radius_sq)) {
1857       RECEIVE_PACKET_FIELD_ERROR(border_city_permanent_radius_sq);
1858     }
1859   }
1860   if (BV_ISSET(fields, 10)) {
1861     log_packet_detailed("  got field 'borders'");
1862     {
1863       int readin;
1864 
1865       if (!DIO_GET(uint8, &din, "borders", &readin)) {
1866         RECEIVE_PACKET_FIELD_ERROR(borders);
1867       }
1868       real_packet->borders = readin;
1869     }
1870   }
1871   if (BV_ISSET(fields, 11)) {
1872     log_packet_detailed("  got field 'base_bribe_cost'");
1873     if (!DIO_GET(uint32, &din, "base_bribe_cost", &real_packet->base_bribe_cost)) {
1874       RECEIVE_PACKET_FIELD_ERROR(base_bribe_cost);
1875     }
1876   }
1877   if (BV_ISSET(fields, 12)) {
1878     log_packet_detailed("  got field 'culture_vic_points'");
1879     if (!DIO_GET(uint32, &din, "culture_vic_points", &real_packet->culture_vic_points)) {
1880       RECEIVE_PACKET_FIELD_ERROR(culture_vic_points);
1881     }
1882   }
1883   if (BV_ISSET(fields, 13)) {
1884     log_packet_detailed("  got field 'culture_vic_lead'");
1885     if (!DIO_GET(uint16, &din, "culture_vic_lead", &real_packet->culture_vic_lead)) {
1886       RECEIVE_PACKET_FIELD_ERROR(culture_vic_lead);
1887     }
1888   }
1889   if (BV_ISSET(fields, 14)) {
1890     log_packet_detailed("  got field 'culture_migration_pml'");
1891     if (!DIO_GET(uint16, &din, "culture_migration_pml", &real_packet->culture_migration_pml)) {
1892       RECEIVE_PACKET_FIELD_ERROR(culture_migration_pml);
1893     }
1894   }
1895   real_packet->calendar_skip_0 = BV_ISSET(fields, 15);
1896   if (BV_ISSET(fields, 16)) {
1897     log_packet_detailed("  got field 'celebratesize'");
1898     if (!DIO_GET(uint8, &din, "celebratesize", &real_packet->celebratesize)) {
1899       RECEIVE_PACKET_FIELD_ERROR(celebratesize);
1900     }
1901   }
1902   real_packet->changable_tax = BV_ISSET(fields, 17);
1903   if (BV_ISSET(fields, 18)) {
1904     log_packet_detailed("  got field 'pop_report_zeroes'");
1905     if (!DIO_GET(uint8, &din, "pop_report_zeroes", &real_packet->pop_report_zeroes)) {
1906       RECEIVE_PACKET_FIELD_ERROR(pop_report_zeroes);
1907     }
1908   }
1909   real_packet->citizen_nationality = BV_ISSET(fields, 19);
1910   if (BV_ISSET(fields, 20)) {
1911     log_packet_detailed("  got field 'citizen_convert_speed'");
1912     if (!DIO_GET(uint16, &din, "citizen_convert_speed", &real_packet->citizen_convert_speed)) {
1913       RECEIVE_PACKET_FIELD_ERROR(citizen_convert_speed);
1914     }
1915   }
1916   if (BV_ISSET(fields, 21)) {
1917     log_packet_detailed("  got field 'citizen_partisans_pct'");
1918     if (!DIO_GET(uint8, &din, "citizen_partisans_pct", &real_packet->citizen_partisans_pct)) {
1919       RECEIVE_PACKET_FIELD_ERROR(citizen_partisans_pct);
1920     }
1921   }
1922   if (BV_ISSET(fields, 22)) {
1923     log_packet_detailed("  got field 'citymindist'");
1924     if (!DIO_GET(uint8, &din, "citymindist", &real_packet->citymindist)) {
1925       RECEIVE_PACKET_FIELD_ERROR(citymindist);
1926     }
1927   }
1928   if (BV_ISSET(fields, 23)) {
1929     log_packet_detailed("  got field 'cooling'");
1930     if (!DIO_GET(uint32, &din, "cooling", &real_packet->cooling)) {
1931       RECEIVE_PACKET_FIELD_ERROR(cooling);
1932     }
1933   }
1934   if (BV_ISSET(fields, 24)) {
1935     log_packet_detailed("  got field 'coolinglevel'");
1936     if (!DIO_GET(uint32, &din, "coolinglevel", &real_packet->coolinglevel)) {
1937       RECEIVE_PACKET_FIELD_ERROR(coolinglevel);
1938     }
1939   }
1940   if (BV_ISSET(fields, 25)) {
1941     log_packet_detailed("  got field 'diplomacy'");
1942     {
1943       int readin;
1944 
1945       if (!DIO_GET(uint8, &din, "diplomacy", &readin)) {
1946         RECEIVE_PACKET_FIELD_ERROR(diplomacy);
1947       }
1948       real_packet->diplomacy = readin;
1949     }
1950   }
1951   real_packet->fogofwar = BV_ISSET(fields, 26);
1952   if (BV_ISSET(fields, 27)) {
1953     log_packet_detailed("  got field 'food_cost'");
1954     if (!DIO_GET(uint8, &din, "food_cost", &real_packet->food_cost)) {
1955       RECEIVE_PACKET_FIELD_ERROR(food_cost);
1956     }
1957   }
1958   if (BV_ISSET(fields, 28)) {
1959     log_packet_detailed("  got field 'foodbox'");
1960     if (!DIO_GET(uint32, &din, "foodbox", &real_packet->foodbox)) {
1961       RECEIVE_PACKET_FIELD_ERROR(foodbox);
1962     }
1963   }
1964   if (BV_ISSET(fields, 29)) {
1965     log_packet_detailed("  got field 'forced_gold'");
1966     if (!DIO_GET(uint8, &din, "forced_gold", &real_packet->forced_gold)) {
1967       RECEIVE_PACKET_FIELD_ERROR(forced_gold);
1968     }
1969   }
1970   if (BV_ISSET(fields, 30)) {
1971     log_packet_detailed("  got field 'forced_luxury'");
1972     if (!DIO_GET(uint8, &din, "forced_luxury", &real_packet->forced_luxury)) {
1973       RECEIVE_PACKET_FIELD_ERROR(forced_luxury);
1974     }
1975   }
1976   if (BV_ISSET(fields, 31)) {
1977     log_packet_detailed("  got field 'forced_science'");
1978     if (!DIO_GET(uint8, &din, "forced_science", &real_packet->forced_science)) {
1979       RECEIVE_PACKET_FIELD_ERROR(forced_science);
1980     }
1981   }
1982   if (BV_ISSET(fields, 32)) {
1983     log_packet_detailed("  got field 'fulltradesize'");
1984     if (!DIO_GET(uint8, &din, "fulltradesize", &real_packet->fulltradesize)) {
1985       RECEIVE_PACKET_FIELD_ERROR(fulltradesize);
1986     }
1987   }
1988   if (BV_ISSET(fields, 33)) {
1989     log_packet_detailed("  got field 'global_advances'");
1990 
1991     for (;;) {
1992       int i;
1993 
1994       if (!DIO_GET(uint8, &din, "global_advances", &i)) {
1995         RECEIVE_PACKET_FIELD_ERROR(global_advances);
1996       }
1997       if (i == 255) {
1998         break;
1999       }
2000       if (i > A_LAST) {
2001         RECEIVE_PACKET_FIELD_ERROR(global_advances,
2002                                    ": unexpected value %d "
2003                                    "(> A_LAST) in array diff",
2004                                    i);
2005       } else {
2006         if (!DIO_GET(bool8, &din, "global_advances", &real_packet->global_advances[i])) {
2007           RECEIVE_PACKET_FIELD_ERROR(global_advances);
2008         }
2009       }
2010     }
2011   }
2012   real_packet->global_warming = BV_ISSET(fields, 34);
2013   if (BV_ISSET(fields, 35)) {
2014     log_packet_detailed("  got field 'globalwarming'");
2015     if (!DIO_GET(uint32, &din, "globalwarming", &real_packet->globalwarming)) {
2016       RECEIVE_PACKET_FIELD_ERROR(globalwarming);
2017     }
2018   }
2019   if (BV_ISSET(fields, 36)) {
2020     log_packet_detailed("  got field 'gold'");
2021     if (!DIO_GET(uint32, &din, "gold", &real_packet->gold)) {
2022       RECEIVE_PACKET_FIELD_ERROR(gold);
2023     }
2024   }
2025   if (BV_ISSET(fields, 37)) {
2026     log_packet_detailed("  got field 'gold_upkeep_style'");
2027     {
2028       int readin;
2029 
2030       if (!DIO_GET(uint8, &din, "gold_upkeep_style", &readin)) {
2031         RECEIVE_PACKET_FIELD_ERROR(gold_upkeep_style);
2032       }
2033       real_packet->gold_upkeep_style = readin;
2034     }
2035   }
2036   if (BV_ISSET(fields, 38)) {
2037     log_packet_detailed("  got field 'revolentype'");
2038     {
2039       int readin;
2040 
2041       if (!DIO_GET(uint8, &din, "revolentype", &readin)) {
2042         RECEIVE_PACKET_FIELD_ERROR(revolentype);
2043       }
2044       real_packet->revolentype = readin;
2045     }
2046   }
2047   if (BV_ISSET(fields, 39)) {
2048     log_packet_detailed("  got field 'default_government_id'");
2049     {
2050       int readin;
2051 
2052       if (!DIO_GET(sint8, &din, "default_government_id", &readin)) {
2053         RECEIVE_PACKET_FIELD_ERROR(default_government_id);
2054       }
2055       real_packet->default_government_id = readin;
2056     }
2057   }
2058   if (BV_ISSET(fields, 40)) {
2059     log_packet_detailed("  got field 'government_during_revolution_id'");
2060     {
2061       int readin;
2062 
2063       if (!DIO_GET(sint8, &din, "government_during_revolution_id", &readin)) {
2064         RECEIVE_PACKET_FIELD_ERROR(government_during_revolution_id);
2065       }
2066       real_packet->government_during_revolution_id = readin;
2067     }
2068   }
2069   if (BV_ISSET(fields, 41)) {
2070     log_packet_detailed("  got field 'granary_food_inc'");
2071     if (!DIO_GET(uint8, &din, "granary_food_inc", &real_packet->granary_food_inc)) {
2072       RECEIVE_PACKET_FIELD_ERROR(granary_food_inc);
2073     }
2074   }
2075   if (BV_ISSET(fields, 42)) {
2076     log_packet_detailed("  got field 'granary_food_ini'");
2077 
2078     {
2079       int i;
2080 
2081       for (i = 0; i < MAX_GRANARY_INIS; i++) {
2082         if (!DIO_GET(uint8, &din, "granary_food_ini", &real_packet->granary_food_ini[i])) {
2083           RECEIVE_PACKET_FIELD_ERROR(granary_food_ini);
2084         }
2085       }
2086     }
2087   }
2088   if (BV_ISSET(fields, 43)) {
2089     log_packet_detailed("  got field 'granary_num_inis'");
2090     if (!DIO_GET(uint8, &din, "granary_num_inis", &real_packet->granary_num_inis)) {
2091       RECEIVE_PACKET_FIELD_ERROR(granary_num_inis);
2092     }
2093   }
2094   if (BV_ISSET(fields, 44)) {
2095     log_packet_detailed("  got field 'great_wonder_owners'");
2096 
2097     for (;;) {
2098       int i;
2099 
2100       if (!DIO_GET(uint8, &din, "great_wonder_owners", &i)) {
2101         RECEIVE_PACKET_FIELD_ERROR(great_wonder_owners);
2102       }
2103       if (i == 255) {
2104         break;
2105       }
2106       if (i > B_LAST) {
2107         RECEIVE_PACKET_FIELD_ERROR(great_wonder_owners,
2108                                    ": unexpected value %d "
2109                                    "(> B_LAST) in array diff",
2110                                    i);
2111       } else {
2112         if (!DIO_GET(uint8, &din, "great_wonder_owners", &real_packet->great_wonder_owners[i])) {
2113           RECEIVE_PACKET_FIELD_ERROR(great_wonder_owners);
2114         }
2115       }
2116     }
2117   }
2118   if (BV_ISSET(fields, 45)) {
2119     log_packet_detailed("  got field 'happy_cost'");
2120     if (!DIO_GET(uint8, &din, "happy_cost", &real_packet->happy_cost)) {
2121       RECEIVE_PACKET_FIELD_ERROR(happy_cost);
2122     }
2123   }
2124   if (BV_ISSET(fields, 46)) {
2125     log_packet_detailed("  got field 'happyborders'");
2126     {
2127       int readin;
2128 
2129       if (!DIO_GET(uint8, &din, "happyborders", &readin)) {
2130         RECEIVE_PACKET_FIELD_ERROR(happyborders);
2131       }
2132       real_packet->happyborders = readin;
2133     }
2134   }
2135   if (BV_ISSET(fields, 47)) {
2136     log_packet_detailed("  got field 'heating'");
2137     if (!DIO_GET(uint32, &din, "heating", &real_packet->heating)) {
2138       RECEIVE_PACKET_FIELD_ERROR(heating);
2139     }
2140   }
2141   if (BV_ISSET(fields, 48)) {
2142     log_packet_detailed("  got field 'illness_base_factor'");
2143     if (!DIO_GET(uint16, &din, "illness_base_factor", &real_packet->illness_base_factor)) {
2144       RECEIVE_PACKET_FIELD_ERROR(illness_base_factor);
2145     }
2146   }
2147   if (BV_ISSET(fields, 49)) {
2148     log_packet_detailed("  got field 'illness_min_size'");
2149     if (!DIO_GET(uint8, &din, "illness_min_size", &real_packet->illness_min_size)) {
2150       RECEIVE_PACKET_FIELD_ERROR(illness_min_size);
2151     }
2152   }
2153   real_packet->illness_on = BV_ISSET(fields, 50);
2154   if (BV_ISSET(fields, 51)) {
2155     log_packet_detailed("  got field 'illness_pollution_factor'");
2156     if (!DIO_GET(uint16, &din, "illness_pollution_factor", &real_packet->illness_pollution_factor)) {
2157       RECEIVE_PACKET_FIELD_ERROR(illness_pollution_factor);
2158     }
2159   }
2160   if (BV_ISSET(fields, 52)) {
2161     log_packet_detailed("  got field 'illness_trade_infection'");
2162     if (!DIO_GET(uint16, &din, "illness_trade_infection", &real_packet->illness_trade_infection)) {
2163       RECEIVE_PACKET_FIELD_ERROR(illness_trade_infection);
2164     }
2165   }
2166   if (BV_ISSET(fields, 53)) {
2167     log_packet_detailed("  got field 'init_city_radius_sq'");
2168     if (!DIO_GET(uint8, &din, "init_city_radius_sq", &real_packet->init_city_radius_sq)) {
2169       RECEIVE_PACKET_FIELD_ERROR(init_city_radius_sq);
2170     }
2171   }
2172   real_packet->is_edit_mode = BV_ISSET(fields, 54);
2173   real_packet->is_new_game = BV_ISSET(fields, 55);
2174   real_packet->killcitizen = BV_ISSET(fields, 56);
2175   real_packet->killstack = BV_ISSET(fields, 57);
2176   if (BV_ISSET(fields, 58)) {
2177     log_packet_detailed("  got field 'min_city_center_output'");
2178 
2179     {
2180       int i;
2181 
2182       for (i = 0; i < O_LAST; i++) {
2183         if (!DIO_GET(uint8, &din, "min_city_center_output", &real_packet->min_city_center_output[i])) {
2184           RECEIVE_PACKET_FIELD_ERROR(min_city_center_output);
2185         }
2186       }
2187     }
2188   }
2189   if (BV_ISSET(fields, 59)) {
2190     log_packet_detailed("  got field 'negative_year_label'");
2191     if (!DIO_GET(string, &din, "negative_year_label", real_packet->negative_year_label, sizeof(real_packet->negative_year_label))) {
2192       RECEIVE_PACKET_FIELD_ERROR(negative_year_label);
2193     }
2194   }
2195   if (BV_ISSET(fields, 60)) {
2196     log_packet_detailed("  got field 'notradesize'");
2197     if (!DIO_GET(uint8, &din, "notradesize", &real_packet->notradesize)) {
2198       RECEIVE_PACKET_FIELD_ERROR(notradesize);
2199     }
2200   }
2201   real_packet->nuclear_winter = BV_ISSET(fields, 61);
2202   if (BV_ISSET(fields, 62)) {
2203     log_packet_detailed("  got field 'nuclearwinter'");
2204     if (!DIO_GET(uint32, &din, "nuclearwinter", &real_packet->nuclearwinter)) {
2205       RECEIVE_PACKET_FIELD_ERROR(nuclearwinter);
2206     }
2207   }
2208   if (BV_ISSET(fields, 63)) {
2209     log_packet_detailed("  got field 'phase'");
2210     if (!DIO_GET(sint16, &din, "phase", &real_packet->phase)) {
2211       RECEIVE_PACKET_FIELD_ERROR(phase);
2212     }
2213   }
2214   if (BV_ISSET(fields, 64)) {
2215     log_packet_detailed("  got field 'phase_mode'");
2216     {
2217       int readin;
2218 
2219       if (!DIO_GET(uint8, &din, "phase_mode", &readin)) {
2220         RECEIVE_PACKET_FIELD_ERROR(phase_mode);
2221       }
2222       real_packet->phase_mode = readin;
2223     }
2224   }
2225   real_packet->pillage_select = BV_ISSET(fields, 65);
2226   real_packet->tech_steal_allow_holes = BV_ISSET(fields, 66);
2227   real_packet->tech_trade_allow_holes = BV_ISSET(fields, 67);
2228   real_packet->tech_trade_loss_allow_holes = BV_ISSET(fields, 68);
2229   real_packet->tech_parasite_allow_holes = BV_ISSET(fields, 69);
2230   real_packet->tech_loss_allow_holes = BV_ISSET(fields, 70);
2231   if (BV_ISSET(fields, 71)) {
2232     log_packet_detailed("  got field 'positive_year_label'");
2233     if (!DIO_GET(string, &din, "positive_year_label", real_packet->positive_year_label, sizeof(real_packet->positive_year_label))) {
2234       RECEIVE_PACKET_FIELD_ERROR(positive_year_label);
2235     }
2236   }
2237   if (BV_ISSET(fields, 72)) {
2238     log_packet_detailed("  got field 'rapturedelay'");
2239     if (!DIO_GET(uint8, &din, "rapturedelay", &real_packet->rapturedelay)) {
2240       RECEIVE_PACKET_FIELD_ERROR(rapturedelay);
2241     }
2242   }
2243   if (BV_ISSET(fields, 73)) {
2244     log_packet_detailed("  got field 'disasters'");
2245     if (!DIO_GET(uint16, &din, "disasters", &real_packet->disasters)) {
2246       RECEIVE_PACKET_FIELD_ERROR(disasters);
2247     }
2248   }
2249   real_packet->restrictinfra = BV_ISSET(fields, 74);
2250   real_packet->unreachable_protects = BV_ISSET(fields, 75);
2251   if (BV_ISSET(fields, 76)) {
2252     log_packet_detailed("  got field 'sciencebox'");
2253     if (!DIO_GET(uint32, &din, "sciencebox", &real_packet->sciencebox)) {
2254       RECEIVE_PACKET_FIELD_ERROR(sciencebox);
2255     }
2256   }
2257   if (BV_ISSET(fields, 77)) {
2258     log_packet_detailed("  got field 'shieldbox'");
2259     if (!DIO_GET(uint32, &din, "shieldbox", &real_packet->shieldbox)) {
2260       RECEIVE_PACKET_FIELD_ERROR(shieldbox);
2261     }
2262   }
2263   if (BV_ISSET(fields, 78)) {
2264     log_packet_detailed("  got field 'skill_level'");
2265     if (!DIO_GET(uint32, &din, "skill_level", &real_packet->skill_level)) {
2266       RECEIVE_PACKET_FIELD_ERROR(skill_level);
2267     }
2268   }
2269   real_packet->slow_invasions = BV_ISSET(fields, 79);
2270   if (BV_ISSET(fields, 80)) {
2271     log_packet_detailed("  got field 'victory_conditions'");
2272     {
2273       int readin;
2274 
2275       if (!DIO_GET(uint8, &din, "victory_conditions", &readin)) {
2276         RECEIVE_PACKET_FIELD_ERROR(victory_conditions);
2277       }
2278       real_packet->victory_conditions = readin;
2279     }
2280   }
2281   real_packet->team_pooled_research = BV_ISSET(fields, 81);
2282   if (BV_ISSET(fields, 82)) {
2283     log_packet_detailed("  got field 'tech'");
2284     if (!DIO_GET(uint32, &din, "tech", &real_packet->tech)) {
2285       RECEIVE_PACKET_FIELD_ERROR(tech);
2286     }
2287   }
2288   if (BV_ISSET(fields, 83)) {
2289     log_packet_detailed("  got field 'tech_cost_style'");
2290     {
2291       int readin;
2292 
2293       if (!DIO_GET(uint8, &din, "tech_cost_style", &readin)) {
2294         RECEIVE_PACKET_FIELD_ERROR(tech_cost_style);
2295       }
2296       real_packet->tech_cost_style = readin;
2297     }
2298   }
2299   if (BV_ISSET(fields, 84)) {
2300     log_packet_detailed("  got field 'tech_leakage'");
2301     {
2302       int readin;
2303 
2304       if (!DIO_GET(uint8, &din, "tech_leakage", &readin)) {
2305         RECEIVE_PACKET_FIELD_ERROR(tech_leakage);
2306       }
2307       real_packet->tech_leakage = readin;
2308     }
2309   }
2310   if (BV_ISSET(fields, 85)) {
2311     log_packet_detailed("  got field 'tech_upkeep_divider'");
2312     if (!DIO_GET(uint16, &din, "tech_upkeep_divider", &real_packet->tech_upkeep_divider)) {
2313       RECEIVE_PACKET_FIELD_ERROR(tech_upkeep_divider);
2314     }
2315   }
2316   if (BV_ISSET(fields, 86)) {
2317     log_packet_detailed("  got field 'tech_upkeep_style'");
2318     {
2319       int readin;
2320 
2321       if (!DIO_GET(uint8, &din, "tech_upkeep_style", &readin)) {
2322         RECEIVE_PACKET_FIELD_ERROR(tech_upkeep_style);
2323       }
2324       real_packet->tech_upkeep_style = readin;
2325     }
2326   }
2327   if (BV_ISSET(fields, 87)) {
2328     log_packet_detailed("  got field 'techloss_forgiveness'");
2329     if (!DIO_GET(sint16, &din, "techloss_forgiveness", &real_packet->techloss_forgiveness)) {
2330       RECEIVE_PACKET_FIELD_ERROR(techloss_forgiveness);
2331     }
2332   }
2333   if (BV_ISSET(fields, 88)) {
2334     log_packet_detailed("  got field 'free_tech_method'");
2335     {
2336       int readin;
2337 
2338       if (!DIO_GET(uint8, &din, "free_tech_method", &readin)) {
2339         RECEIVE_PACKET_FIELD_ERROR(free_tech_method);
2340       }
2341       real_packet->free_tech_method = readin;
2342     }
2343   }
2344   if (BV_ISSET(fields, 89)) {
2345     log_packet_detailed("  got field 'gameloss_style'");
2346     {
2347       int readin;
2348 
2349       if (!DIO_GET(uint8, &din, "gameloss_style", &readin)) {
2350         RECEIVE_PACKET_FIELD_ERROR(gameloss_style);
2351       }
2352       real_packet->gameloss_style = readin;
2353     }
2354   }
2355   if (BV_ISSET(fields, 90)) {
2356     log_packet_detailed("  got field 'timeout'");
2357     if (!DIO_GET(uint32, &din, "timeout", &real_packet->timeout)) {
2358       RECEIVE_PACKET_FIELD_ERROR(timeout);
2359     }
2360   }
2361   if (BV_ISSET(fields, 91)) {
2362     log_packet_detailed("  got field 'first_timeout'");
2363     if (!DIO_GET(uint32, &din, "first_timeout", &real_packet->first_timeout)) {
2364       RECEIVE_PACKET_FIELD_ERROR(first_timeout);
2365     }
2366   }
2367   real_packet->tired_attack = BV_ISSET(fields, 92);
2368   if (BV_ISSET(fields, 93)) {
2369     log_packet_detailed("  got field 'trademindist'");
2370     if (!DIO_GET(uint16, &din, "trademindist", &real_packet->trademindist)) {
2371       RECEIVE_PACKET_FIELD_ERROR(trademindist);
2372     }
2373   }
2374   real_packet->force_trade_route = BV_ISSET(fields, 94);
2375   real_packet->trading_city = BV_ISSET(fields, 95);
2376   real_packet->trading_gold = BV_ISSET(fields, 96);
2377   real_packet->trading_tech = BV_ISSET(fields, 97);
2378   if (BV_ISSET(fields, 98)) {
2379     log_packet_detailed("  got field 'turn'");
2380     if (!DIO_GET(sint16, &din, "turn", &real_packet->turn)) {
2381       RECEIVE_PACKET_FIELD_ERROR(turn);
2382     }
2383   }
2384   if (BV_ISSET(fields, 99)) {
2385     log_packet_detailed("  got field 'warminglevel'");
2386     if (!DIO_GET(uint32, &din, "warminglevel", &real_packet->warminglevel)) {
2387       RECEIVE_PACKET_FIELD_ERROR(warminglevel);
2388     }
2389   }
2390   if (BV_ISSET(fields, 100)) {
2391     log_packet_detailed("  got field 'year16'");
2392     if (!DIO_GET(sint16, &din, "year16", &real_packet->year16)) {
2393       RECEIVE_PACKET_FIELD_ERROR(year16);
2394     }
2395   }
2396   if (BV_ISSET(fields, 101)) {
2397     log_packet_detailed("  got field 'year32'");
2398     if (!DIO_GET(sint32, &din, "year32", &real_packet->year32)) {
2399       RECEIVE_PACKET_FIELD_ERROR(year32);
2400     }
2401   }
2402   real_packet->year_0_hack = BV_ISSET(fields, 102);
2403   if (BV_ISSET(fields, 103)) {
2404     log_packet_detailed("  got field 'calendar_fragments'");
2405     if (!DIO_GET(uint16, &din, "calendar_fragments", &real_packet->calendar_fragments)) {
2406       RECEIVE_PACKET_FIELD_ERROR(calendar_fragments);
2407     }
2408   }
2409   if (BV_ISSET(fields, 104)) {
2410     log_packet_detailed("  got field 'fragment_count'");
2411     if (!DIO_GET(uint16, &din, "fragment_count", &real_packet->fragment_count)) {
2412       RECEIVE_PACKET_FIELD_ERROR(fragment_count);
2413     }
2414   }
2415   if (BV_ISSET(fields, 105)) {
2416     log_packet_detailed("  got field 'calendar_fragment_name'");
2417 
2418     {
2419       int i;
2420 
2421       for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
2422         if (!DIO_GET(string, &din, "calendar_fragment_name", real_packet->calendar_fragment_name[i], sizeof(real_packet->calendar_fragment_name[i]))) {
2423           RECEIVE_PACKET_FIELD_ERROR(calendar_fragment_name);
2424         }
2425       }
2426     }
2427   }
2428   real_packet->civil_war_enabled = BV_ISSET(fields, 106);
2429   real_packet->paradrop_to_transport = BV_ISSET(fields, 107);
2430 
2431   if (NULL == old) {
2432     old = fc_malloc(sizeof(*old));
2433     *old = *real_packet;
2434     genhash_insert(*hash, old, old);
2435   } else {
2436     *old = *real_packet;
2437   }
2438   RECEIVE_PACKET_END(real_packet);
2439 }
2440 
send_packet_game_info_100(struct connection * pc,const struct packet_game_info * packet)2441 static int send_packet_game_info_100(struct connection *pc, const struct packet_game_info *packet)
2442 {
2443   const struct packet_game_info *real_packet = packet;
2444   packet_game_info_100_fields fields;
2445   struct packet_game_info *old;
2446   bool differ;
2447   struct genhash **hash = pc->phs.sent + PACKET_GAME_INFO;
2448   int different = 0;
2449   SEND_PACKET_START(PACKET_GAME_INFO);
2450 
2451   log_packet_detailed("packet_game_info_100: sending info about ()");
2452 
2453   if (NULL == *hash) {
2454     *hash = genhash_new_full(hash_packet_game_info_100, cmp_packet_game_info_100,
2455                              NULL, NULL, NULL, free);
2456   }
2457   BV_CLR_ALL(fields);
2458 
2459   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
2460     old = fc_malloc(sizeof(*old));
2461     *old = *real_packet;
2462     genhash_insert(*hash, old, old);
2463     memset(old, 0, sizeof(*old));
2464     different = 1;      /* Force to send. */
2465   }
2466 
2467   differ = (old->add_to_size_limit != real_packet->add_to_size_limit);
2468   if (differ) {
2469     different++;
2470     BV_SET(fields, 0);
2471   }
2472 
2473   differ = (old->aifill != real_packet->aifill);
2474   if (differ) {
2475     different++;
2476     BV_SET(fields, 1);
2477   }
2478 
2479   differ = (old->persistent_ready != real_packet->persistent_ready);
2480   if (differ) {
2481     different++;
2482     BV_SET(fields, 2);
2483   }
2484 
2485   differ = (old->airlifting_style != real_packet->airlifting_style);
2486   if (differ) {
2487     different++;
2488     BV_SET(fields, 3);
2489   }
2490 
2491   differ = (old->angrycitizen != real_packet->angrycitizen);
2492   if (differ) {
2493     different++;
2494     BV_SET(fields, 4);
2495   }
2496 
2497   differ = (old->base_pollution != real_packet->base_pollution);
2498   if (differ) {
2499     different++;
2500     BV_SET(fields, 5);
2501   }
2502 
2503   differ = (old->base_tech_cost != real_packet->base_tech_cost);
2504   if (differ) {
2505     different++;
2506     BV_SET(fields, 6);
2507   }
2508 
2509   differ = (old->border_city_radius_sq != real_packet->border_city_radius_sq);
2510   if (differ) {
2511     different++;
2512     BV_SET(fields, 7);
2513   }
2514 
2515   differ = (old->border_size_effect != real_packet->border_size_effect);
2516   if (differ) {
2517     different++;
2518     BV_SET(fields, 8);
2519   }
2520 
2521   differ = (old->border_city_permanent_radius_sq != real_packet->border_city_permanent_radius_sq);
2522   if (differ) {
2523     different++;
2524     BV_SET(fields, 9);
2525   }
2526 
2527   differ = (old->borders != real_packet->borders);
2528   if (differ) {
2529     different++;
2530     BV_SET(fields, 10);
2531   }
2532 
2533   differ = (old->base_bribe_cost != real_packet->base_bribe_cost);
2534   if (differ) {
2535     different++;
2536     BV_SET(fields, 11);
2537   }
2538 
2539   differ = (old->culture_vic_points != real_packet->culture_vic_points);
2540   if (differ) {
2541     different++;
2542     BV_SET(fields, 12);
2543   }
2544 
2545   differ = (old->culture_vic_lead != real_packet->culture_vic_lead);
2546   if (differ) {
2547     different++;
2548     BV_SET(fields, 13);
2549   }
2550 
2551   differ = (old->culture_migration_pml != real_packet->culture_migration_pml);
2552   if (differ) {
2553     different++;
2554     BV_SET(fields, 14);
2555   }
2556 
2557   differ = (old->calendar_skip_0 != real_packet->calendar_skip_0);
2558   if (differ) {
2559     different++;
2560   }
2561   if (packet->calendar_skip_0) {
2562     BV_SET(fields, 15);
2563   }
2564 
2565   differ = (old->celebratesize != real_packet->celebratesize);
2566   if (differ) {
2567     different++;
2568     BV_SET(fields, 16);
2569   }
2570 
2571   differ = (old->changable_tax != real_packet->changable_tax);
2572   if (differ) {
2573     different++;
2574   }
2575   if (packet->changable_tax) {
2576     BV_SET(fields, 17);
2577   }
2578 
2579   differ = (old->pop_report_zeroes != real_packet->pop_report_zeroes);
2580   if (differ) {
2581     different++;
2582     BV_SET(fields, 18);
2583   }
2584 
2585   differ = (old->citizen_nationality != real_packet->citizen_nationality);
2586   if (differ) {
2587     different++;
2588   }
2589   if (packet->citizen_nationality) {
2590     BV_SET(fields, 19);
2591   }
2592 
2593   differ = (old->citizen_convert_speed != real_packet->citizen_convert_speed);
2594   if (differ) {
2595     different++;
2596     BV_SET(fields, 20);
2597   }
2598 
2599   differ = (old->citizen_partisans_pct != real_packet->citizen_partisans_pct);
2600   if (differ) {
2601     different++;
2602     BV_SET(fields, 21);
2603   }
2604 
2605   differ = (old->citymindist != real_packet->citymindist);
2606   if (differ) {
2607     different++;
2608     BV_SET(fields, 22);
2609   }
2610 
2611   differ = (old->cooling != real_packet->cooling);
2612   if (differ) {
2613     different++;
2614     BV_SET(fields, 23);
2615   }
2616 
2617   differ = (old->coolinglevel != real_packet->coolinglevel);
2618   if (differ) {
2619     different++;
2620     BV_SET(fields, 24);
2621   }
2622 
2623   differ = (old->diplomacy != real_packet->diplomacy);
2624   if (differ) {
2625     different++;
2626     BV_SET(fields, 25);
2627   }
2628 
2629   differ = (old->fogofwar != real_packet->fogofwar);
2630   if (differ) {
2631     different++;
2632   }
2633   if (packet->fogofwar) {
2634     BV_SET(fields, 26);
2635   }
2636 
2637   differ = (old->food_cost != real_packet->food_cost);
2638   if (differ) {
2639     different++;
2640     BV_SET(fields, 27);
2641   }
2642 
2643   differ = (old->foodbox != real_packet->foodbox);
2644   if (differ) {
2645     different++;
2646     BV_SET(fields, 28);
2647   }
2648 
2649   differ = (old->forced_gold != real_packet->forced_gold);
2650   if (differ) {
2651     different++;
2652     BV_SET(fields, 29);
2653   }
2654 
2655   differ = (old->forced_luxury != real_packet->forced_luxury);
2656   if (differ) {
2657     different++;
2658     BV_SET(fields, 30);
2659   }
2660 
2661   differ = (old->forced_science != real_packet->forced_science);
2662   if (differ) {
2663     different++;
2664     BV_SET(fields, 31);
2665   }
2666 
2667   differ = (old->fulltradesize != real_packet->fulltradesize);
2668   if (differ) {
2669     different++;
2670     BV_SET(fields, 32);
2671   }
2672 
2673 
2674     {
2675       differ = (A_LAST != A_LAST);
2676       if (!differ) {
2677         int i;
2678 
2679         for (i = 0; i < A_LAST; i++) {
2680           if (old->global_advances[i] != real_packet->global_advances[i]) {
2681             differ = TRUE;
2682             break;
2683           }
2684         }
2685       }
2686     }
2687   if (differ) {
2688     different++;
2689     BV_SET(fields, 33);
2690   }
2691 
2692   differ = (old->global_warming != real_packet->global_warming);
2693   if (differ) {
2694     different++;
2695   }
2696   if (packet->global_warming) {
2697     BV_SET(fields, 34);
2698   }
2699 
2700   differ = (old->globalwarming != real_packet->globalwarming);
2701   if (differ) {
2702     different++;
2703     BV_SET(fields, 35);
2704   }
2705 
2706   differ = (old->gold != real_packet->gold);
2707   if (differ) {
2708     different++;
2709     BV_SET(fields, 36);
2710   }
2711 
2712   differ = (old->gold_upkeep_style != real_packet->gold_upkeep_style);
2713   if (differ) {
2714     different++;
2715     BV_SET(fields, 37);
2716   }
2717 
2718   differ = (old->revolentype != real_packet->revolentype);
2719   if (differ) {
2720     different++;
2721     BV_SET(fields, 38);
2722   }
2723 
2724   differ = (old->default_government_id != real_packet->default_government_id);
2725   if (differ) {
2726     different++;
2727     BV_SET(fields, 39);
2728   }
2729 
2730   differ = (old->government_during_revolution_id != real_packet->government_during_revolution_id);
2731   if (differ) {
2732     different++;
2733     BV_SET(fields, 40);
2734   }
2735 
2736   differ = (old->granary_food_inc != real_packet->granary_food_inc);
2737   if (differ) {
2738     different++;
2739     BV_SET(fields, 41);
2740   }
2741 
2742 
2743     {
2744       differ = (MAX_GRANARY_INIS != MAX_GRANARY_INIS);
2745       if (!differ) {
2746         int i;
2747 
2748         for (i = 0; i < MAX_GRANARY_INIS; i++) {
2749           if (old->granary_food_ini[i] != real_packet->granary_food_ini[i]) {
2750             differ = TRUE;
2751             break;
2752           }
2753         }
2754       }
2755     }
2756   if (differ) {
2757     different++;
2758     BV_SET(fields, 42);
2759   }
2760 
2761   differ = (old->granary_num_inis != real_packet->granary_num_inis);
2762   if (differ) {
2763     different++;
2764     BV_SET(fields, 43);
2765   }
2766 
2767 
2768     {
2769       differ = (B_LAST != B_LAST);
2770       if (!differ) {
2771         int i;
2772 
2773         for (i = 0; i < B_LAST; i++) {
2774           if (old->great_wonder_owners[i] != real_packet->great_wonder_owners[i]) {
2775             differ = TRUE;
2776             break;
2777           }
2778         }
2779       }
2780     }
2781   if (differ) {
2782     different++;
2783     BV_SET(fields, 44);
2784   }
2785 
2786   differ = (old->happy_cost != real_packet->happy_cost);
2787   if (differ) {
2788     different++;
2789     BV_SET(fields, 45);
2790   }
2791 
2792   differ = (old->happyborders != real_packet->happyborders);
2793   if (differ) {
2794     different++;
2795     BV_SET(fields, 46);
2796   }
2797 
2798   differ = (old->heating != real_packet->heating);
2799   if (differ) {
2800     different++;
2801     BV_SET(fields, 47);
2802   }
2803 
2804   differ = (old->illness_base_factor != real_packet->illness_base_factor);
2805   if (differ) {
2806     different++;
2807     BV_SET(fields, 48);
2808   }
2809 
2810   differ = (old->illness_min_size != real_packet->illness_min_size);
2811   if (differ) {
2812     different++;
2813     BV_SET(fields, 49);
2814   }
2815 
2816   differ = (old->illness_on != real_packet->illness_on);
2817   if (differ) {
2818     different++;
2819   }
2820   if (packet->illness_on) {
2821     BV_SET(fields, 50);
2822   }
2823 
2824   differ = (old->illness_pollution_factor != real_packet->illness_pollution_factor);
2825   if (differ) {
2826     different++;
2827     BV_SET(fields, 51);
2828   }
2829 
2830   differ = (old->illness_trade_infection != real_packet->illness_trade_infection);
2831   if (differ) {
2832     different++;
2833     BV_SET(fields, 52);
2834   }
2835 
2836   differ = (old->init_city_radius_sq != real_packet->init_city_radius_sq);
2837   if (differ) {
2838     different++;
2839     BV_SET(fields, 53);
2840   }
2841 
2842   differ = (old->is_edit_mode != real_packet->is_edit_mode);
2843   if (differ) {
2844     different++;
2845   }
2846   if (packet->is_edit_mode) {
2847     BV_SET(fields, 54);
2848   }
2849 
2850   differ = (old->is_new_game != real_packet->is_new_game);
2851   if (differ) {
2852     different++;
2853   }
2854   if (packet->is_new_game) {
2855     BV_SET(fields, 55);
2856   }
2857 
2858   differ = (old->killcitizen != real_packet->killcitizen);
2859   if (differ) {
2860     different++;
2861   }
2862   if (packet->killcitizen) {
2863     BV_SET(fields, 56);
2864   }
2865 
2866   differ = (old->killstack != real_packet->killstack);
2867   if (differ) {
2868     different++;
2869   }
2870   if (packet->killstack) {
2871     BV_SET(fields, 57);
2872   }
2873 
2874 
2875     {
2876       differ = (O_LAST != O_LAST);
2877       if (!differ) {
2878         int i;
2879 
2880         for (i = 0; i < O_LAST; i++) {
2881           if (old->min_city_center_output[i] != real_packet->min_city_center_output[i]) {
2882             differ = TRUE;
2883             break;
2884           }
2885         }
2886       }
2887     }
2888   if (differ) {
2889     different++;
2890     BV_SET(fields, 58);
2891   }
2892 
2893   differ = (strcmp(old->negative_year_label, real_packet->negative_year_label) != 0);
2894   if (differ) {
2895     different++;
2896     BV_SET(fields, 59);
2897   }
2898 
2899   differ = (old->notradesize != real_packet->notradesize);
2900   if (differ) {
2901     different++;
2902     BV_SET(fields, 60);
2903   }
2904 
2905   differ = (old->nuclear_winter != real_packet->nuclear_winter);
2906   if (differ) {
2907     different++;
2908   }
2909   if (packet->nuclear_winter) {
2910     BV_SET(fields, 61);
2911   }
2912 
2913   differ = (old->nuclearwinter != real_packet->nuclearwinter);
2914   if (differ) {
2915     different++;
2916     BV_SET(fields, 62);
2917   }
2918 
2919   differ = (old->phase != real_packet->phase);
2920   if (differ) {
2921     different++;
2922     BV_SET(fields, 63);
2923   }
2924 
2925   differ = (old->phase_mode != real_packet->phase_mode);
2926   if (differ) {
2927     different++;
2928     BV_SET(fields, 64);
2929   }
2930 
2931   differ = (old->pillage_select != real_packet->pillage_select);
2932   if (differ) {
2933     different++;
2934   }
2935   if (packet->pillage_select) {
2936     BV_SET(fields, 65);
2937   }
2938 
2939   differ = (old->tech_steal_allow_holes != real_packet->tech_steal_allow_holes);
2940   if (differ) {
2941     different++;
2942   }
2943   if (packet->tech_steal_allow_holes) {
2944     BV_SET(fields, 66);
2945   }
2946 
2947   differ = (old->tech_trade_allow_holes != real_packet->tech_trade_allow_holes);
2948   if (differ) {
2949     different++;
2950   }
2951   if (packet->tech_trade_allow_holes) {
2952     BV_SET(fields, 67);
2953   }
2954 
2955   differ = (old->tech_trade_loss_allow_holes != real_packet->tech_trade_loss_allow_holes);
2956   if (differ) {
2957     different++;
2958   }
2959   if (packet->tech_trade_loss_allow_holes) {
2960     BV_SET(fields, 68);
2961   }
2962 
2963   differ = (old->tech_parasite_allow_holes != real_packet->tech_parasite_allow_holes);
2964   if (differ) {
2965     different++;
2966   }
2967   if (packet->tech_parasite_allow_holes) {
2968     BV_SET(fields, 69);
2969   }
2970 
2971   differ = (old->tech_loss_allow_holes != real_packet->tech_loss_allow_holes);
2972   if (differ) {
2973     different++;
2974   }
2975   if (packet->tech_loss_allow_holes) {
2976     BV_SET(fields, 70);
2977   }
2978 
2979   differ = (strcmp(old->positive_year_label, real_packet->positive_year_label) != 0);
2980   if (differ) {
2981     different++;
2982     BV_SET(fields, 71);
2983   }
2984 
2985   differ = (old->rapturedelay != real_packet->rapturedelay);
2986   if (differ) {
2987     different++;
2988     BV_SET(fields, 72);
2989   }
2990 
2991   differ = (old->disasters != real_packet->disasters);
2992   if (differ) {
2993     different++;
2994     BV_SET(fields, 73);
2995   }
2996 
2997   differ = (old->restrictinfra != real_packet->restrictinfra);
2998   if (differ) {
2999     different++;
3000   }
3001   if (packet->restrictinfra) {
3002     BV_SET(fields, 74);
3003   }
3004 
3005   differ = (old->unreachable_protects != real_packet->unreachable_protects);
3006   if (differ) {
3007     different++;
3008   }
3009   if (packet->unreachable_protects) {
3010     BV_SET(fields, 75);
3011   }
3012 
3013   differ = (old->sciencebox != real_packet->sciencebox);
3014   if (differ) {
3015     different++;
3016     BV_SET(fields, 76);
3017   }
3018 
3019   differ = (old->shieldbox != real_packet->shieldbox);
3020   if (differ) {
3021     different++;
3022     BV_SET(fields, 77);
3023   }
3024 
3025   differ = (old->skill_level != real_packet->skill_level);
3026   if (differ) {
3027     different++;
3028     BV_SET(fields, 78);
3029   }
3030 
3031   differ = (old->slow_invasions != real_packet->slow_invasions);
3032   if (differ) {
3033     different++;
3034   }
3035   if (packet->slow_invasions) {
3036     BV_SET(fields, 79);
3037   }
3038 
3039   differ = (old->victory_conditions != real_packet->victory_conditions);
3040   if (differ) {
3041     different++;
3042     BV_SET(fields, 80);
3043   }
3044 
3045   differ = (old->team_pooled_research != real_packet->team_pooled_research);
3046   if (differ) {
3047     different++;
3048   }
3049   if (packet->team_pooled_research) {
3050     BV_SET(fields, 81);
3051   }
3052 
3053   differ = (old->tech != real_packet->tech);
3054   if (differ) {
3055     different++;
3056     BV_SET(fields, 82);
3057   }
3058 
3059   differ = (old->tech_cost_style != real_packet->tech_cost_style);
3060   if (differ) {
3061     different++;
3062     BV_SET(fields, 83);
3063   }
3064 
3065   differ = (old->tech_leakage != real_packet->tech_leakage);
3066   if (differ) {
3067     different++;
3068     BV_SET(fields, 84);
3069   }
3070 
3071   differ = (old->tech_upkeep_divider != real_packet->tech_upkeep_divider);
3072   if (differ) {
3073     different++;
3074     BV_SET(fields, 85);
3075   }
3076 
3077   differ = (old->tech_upkeep_style != real_packet->tech_upkeep_style);
3078   if (differ) {
3079     different++;
3080     BV_SET(fields, 86);
3081   }
3082 
3083   differ = (old->techloss_forgiveness != real_packet->techloss_forgiveness);
3084   if (differ) {
3085     different++;
3086     BV_SET(fields, 87);
3087   }
3088 
3089   differ = (old->free_tech_method != real_packet->free_tech_method);
3090   if (differ) {
3091     different++;
3092     BV_SET(fields, 88);
3093   }
3094 
3095   differ = (old->gameloss_style != real_packet->gameloss_style);
3096   if (differ) {
3097     different++;
3098     BV_SET(fields, 89);
3099   }
3100 
3101   differ = (old->timeout != real_packet->timeout);
3102   if (differ) {
3103     different++;
3104     BV_SET(fields, 90);
3105   }
3106 
3107   differ = (old->first_timeout != real_packet->first_timeout);
3108   if (differ) {
3109     different++;
3110     BV_SET(fields, 91);
3111   }
3112 
3113   differ = (old->tired_attack != real_packet->tired_attack);
3114   if (differ) {
3115     different++;
3116   }
3117   if (packet->tired_attack) {
3118     BV_SET(fields, 92);
3119   }
3120 
3121   differ = (old->trademindist != real_packet->trademindist);
3122   if (differ) {
3123     different++;
3124     BV_SET(fields, 93);
3125   }
3126 
3127   differ = (old->force_trade_route != real_packet->force_trade_route);
3128   if (differ) {
3129     different++;
3130   }
3131   if (packet->force_trade_route) {
3132     BV_SET(fields, 94);
3133   }
3134 
3135   differ = (old->trading_city != real_packet->trading_city);
3136   if (differ) {
3137     different++;
3138   }
3139   if (packet->trading_city) {
3140     BV_SET(fields, 95);
3141   }
3142 
3143   differ = (old->trading_gold != real_packet->trading_gold);
3144   if (differ) {
3145     different++;
3146   }
3147   if (packet->trading_gold) {
3148     BV_SET(fields, 96);
3149   }
3150 
3151   differ = (old->trading_tech != real_packet->trading_tech);
3152   if (differ) {
3153     different++;
3154   }
3155   if (packet->trading_tech) {
3156     BV_SET(fields, 97);
3157   }
3158 
3159   differ = (old->turn != real_packet->turn);
3160   if (differ) {
3161     different++;
3162     BV_SET(fields, 98);
3163   }
3164 
3165   differ = (old->warminglevel != real_packet->warminglevel);
3166   if (differ) {
3167     different++;
3168     BV_SET(fields, 99);
3169   }
3170 
3171   differ = (old->year16 != real_packet->year16);
3172   if (differ) {
3173     different++;
3174     BV_SET(fields, 100);
3175   }
3176 
3177   differ = (old->year32 != real_packet->year32);
3178   if (differ) {
3179     different++;
3180     BV_SET(fields, 101);
3181   }
3182 
3183   differ = (old->year_0_hack != real_packet->year_0_hack);
3184   if (differ) {
3185     different++;
3186   }
3187   if (packet->year_0_hack) {
3188     BV_SET(fields, 102);
3189   }
3190 
3191   differ = (old->calendar_fragments != real_packet->calendar_fragments);
3192   if (differ) {
3193     different++;
3194     BV_SET(fields, 103);
3195   }
3196 
3197   differ = (old->fragment_count != real_packet->fragment_count);
3198   if (differ) {
3199     different++;
3200     BV_SET(fields, 104);
3201   }
3202 
3203 
3204     {
3205       differ = (MAX_CALENDAR_FRAGMENTS != MAX_CALENDAR_FRAGMENTS);
3206       if (!differ) {
3207         int i;
3208 
3209         for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
3210           if (strcmp(old->calendar_fragment_name[i], real_packet->calendar_fragment_name[i]) != 0) {
3211             differ = TRUE;
3212             break;
3213           }
3214         }
3215       }
3216     }
3217   if (differ) {
3218     different++;
3219     BV_SET(fields, 105);
3220   }
3221 
3222   differ = (old->civil_war_enabled != real_packet->civil_war_enabled);
3223   if (differ) {
3224     different++;
3225   }
3226   if (packet->civil_war_enabled) {
3227     BV_SET(fields, 106);
3228   }
3229 
3230   differ = (old->paradrop_to_transport != real_packet->paradrop_to_transport);
3231   if (differ) {
3232     different++;
3233   }
3234   if (packet->paradrop_to_transport) {
3235     BV_SET(fields, 107);
3236   }
3237 
3238 
3239   if (different == 0) {
3240     log_packet_detailed("  no change -> discard");
3241     return 0;
3242   }
3243 
3244   DIO_BV_PUT(&dout, "fields", fields);
3245 
3246   if (BV_ISSET(fields, 0)) {
3247     log_packet_detailed("  field 'add_to_size_limit' has changed");
3248     DIO_PUT(uint8, &dout, "add_to_size_limit", real_packet->add_to_size_limit);
3249   }
3250   if (BV_ISSET(fields, 1)) {
3251     log_packet_detailed("  field 'aifill' has changed");
3252     DIO_PUT(uint8, &dout, "aifill", real_packet->aifill);
3253   }
3254   if (BV_ISSET(fields, 2)) {
3255     log_packet_detailed("  field 'persistent_ready' has changed");
3256     DIO_PUT(uint8, &dout, "persistent_ready", real_packet->persistent_ready);
3257   }
3258   if (BV_ISSET(fields, 3)) {
3259     log_packet_detailed("  field 'airlifting_style' has changed");
3260     DIO_PUT(uint8, &dout, "airlifting_style", real_packet->airlifting_style);
3261   }
3262   if (BV_ISSET(fields, 4)) {
3263     log_packet_detailed("  field 'angrycitizen' has changed");
3264     DIO_PUT(uint8, &dout, "angrycitizen", real_packet->angrycitizen);
3265   }
3266   if (BV_ISSET(fields, 5)) {
3267     log_packet_detailed("  field 'base_pollution' has changed");
3268     DIO_PUT(sint16, &dout, "base_pollution", real_packet->base_pollution);
3269   }
3270   if (BV_ISSET(fields, 6)) {
3271     log_packet_detailed("  field 'base_tech_cost' has changed");
3272     DIO_PUT(uint8, &dout, "base_tech_cost", real_packet->base_tech_cost);
3273   }
3274   if (BV_ISSET(fields, 7)) {
3275     log_packet_detailed("  field 'border_city_radius_sq' has changed");
3276     DIO_PUT(uint16, &dout, "border_city_radius_sq", real_packet->border_city_radius_sq);
3277   }
3278   if (BV_ISSET(fields, 8)) {
3279     log_packet_detailed("  field 'border_size_effect' has changed");
3280     DIO_PUT(uint8, &dout, "border_size_effect", real_packet->border_size_effect);
3281   }
3282   if (BV_ISSET(fields, 9)) {
3283     log_packet_detailed("  field 'border_city_permanent_radius_sq' has changed");
3284     DIO_PUT(sint16, &dout, "border_city_permanent_radius_sq", real_packet->border_city_permanent_radius_sq);
3285   }
3286   if (BV_ISSET(fields, 10)) {
3287     log_packet_detailed("  field 'borders' has changed");
3288     DIO_PUT(uint8, &dout, "borders", real_packet->borders);
3289   }
3290   if (BV_ISSET(fields, 11)) {
3291     log_packet_detailed("  field 'base_bribe_cost' has changed");
3292     DIO_PUT(uint32, &dout, "base_bribe_cost", real_packet->base_bribe_cost);
3293   }
3294   if (BV_ISSET(fields, 12)) {
3295     log_packet_detailed("  field 'culture_vic_points' has changed");
3296     DIO_PUT(uint32, &dout, "culture_vic_points", real_packet->culture_vic_points);
3297   }
3298   if (BV_ISSET(fields, 13)) {
3299     log_packet_detailed("  field 'culture_vic_lead' has changed");
3300     DIO_PUT(uint16, &dout, "culture_vic_lead", real_packet->culture_vic_lead);
3301   }
3302   if (BV_ISSET(fields, 14)) {
3303     log_packet_detailed("  field 'culture_migration_pml' has changed");
3304     DIO_PUT(uint16, &dout, "culture_migration_pml", real_packet->culture_migration_pml);
3305   }
3306   /* field 15 is folded into the header */
3307   if (BV_ISSET(fields, 16)) {
3308     log_packet_detailed("  field 'celebratesize' has changed");
3309     DIO_PUT(uint8, &dout, "celebratesize", real_packet->celebratesize);
3310   }
3311   /* field 17 is folded into the header */
3312   if (BV_ISSET(fields, 18)) {
3313     log_packet_detailed("  field 'pop_report_zeroes' has changed");
3314     DIO_PUT(uint8, &dout, "pop_report_zeroes", real_packet->pop_report_zeroes);
3315   }
3316   /* field 19 is folded into the header */
3317   if (BV_ISSET(fields, 20)) {
3318     log_packet_detailed("  field 'citizen_convert_speed' has changed");
3319     DIO_PUT(uint16, &dout, "citizen_convert_speed", real_packet->citizen_convert_speed);
3320   }
3321   if (BV_ISSET(fields, 21)) {
3322     log_packet_detailed("  field 'citizen_partisans_pct' has changed");
3323     DIO_PUT(uint8, &dout, "citizen_partisans_pct", real_packet->citizen_partisans_pct);
3324   }
3325   if (BV_ISSET(fields, 22)) {
3326     log_packet_detailed("  field 'citymindist' has changed");
3327     DIO_PUT(uint8, &dout, "citymindist", real_packet->citymindist);
3328   }
3329   if (BV_ISSET(fields, 23)) {
3330     log_packet_detailed("  field 'cooling' has changed");
3331     DIO_PUT(uint32, &dout, "cooling", real_packet->cooling);
3332   }
3333   if (BV_ISSET(fields, 24)) {
3334     log_packet_detailed("  field 'coolinglevel' has changed");
3335     DIO_PUT(uint32, &dout, "coolinglevel", real_packet->coolinglevel);
3336   }
3337   if (BV_ISSET(fields, 25)) {
3338     log_packet_detailed("  field 'diplomacy' has changed");
3339     DIO_PUT(uint8, &dout, "diplomacy", real_packet->diplomacy);
3340   }
3341   /* field 26 is folded into the header */
3342   if (BV_ISSET(fields, 27)) {
3343     log_packet_detailed("  field 'food_cost' has changed");
3344     DIO_PUT(uint8, &dout, "food_cost", real_packet->food_cost);
3345   }
3346   if (BV_ISSET(fields, 28)) {
3347     log_packet_detailed("  field 'foodbox' has changed");
3348     DIO_PUT(uint32, &dout, "foodbox", real_packet->foodbox);
3349   }
3350   if (BV_ISSET(fields, 29)) {
3351     log_packet_detailed("  field 'forced_gold' has changed");
3352     DIO_PUT(uint8, &dout, "forced_gold", real_packet->forced_gold);
3353   }
3354   if (BV_ISSET(fields, 30)) {
3355     log_packet_detailed("  field 'forced_luxury' has changed");
3356     DIO_PUT(uint8, &dout, "forced_luxury", real_packet->forced_luxury);
3357   }
3358   if (BV_ISSET(fields, 31)) {
3359     log_packet_detailed("  field 'forced_science' has changed");
3360     DIO_PUT(uint8, &dout, "forced_science", real_packet->forced_science);
3361   }
3362   if (BV_ISSET(fields, 32)) {
3363     log_packet_detailed("  field 'fulltradesize' has changed");
3364     DIO_PUT(uint8, &dout, "fulltradesize", real_packet->fulltradesize);
3365   }
3366   if (BV_ISSET(fields, 33)) {
3367     log_packet_detailed("  field 'global_advances' has changed");
3368 
3369     {
3370       int i;
3371 
3372       fc_assert(A_LAST < 255);
3373 
3374       for (i = 0; i < A_LAST; i++) {
3375         if (old->global_advances[i] != real_packet->global_advances[i]) {
3376           dio_put_uint8(&dout, i);
3377           dio_put_bool8(&dout, real_packet->global_advances[i]);
3378         }
3379       }
3380       dio_put_uint8(&dout, 255);
3381     }
3382   }
3383   /* field 34 is folded into the header */
3384   if (BV_ISSET(fields, 35)) {
3385     log_packet_detailed("  field 'globalwarming' has changed");
3386     DIO_PUT(uint32, &dout, "globalwarming", real_packet->globalwarming);
3387   }
3388   if (BV_ISSET(fields, 36)) {
3389     log_packet_detailed("  field 'gold' has changed");
3390     DIO_PUT(uint32, &dout, "gold", real_packet->gold);
3391   }
3392   if (BV_ISSET(fields, 37)) {
3393     log_packet_detailed("  field 'gold_upkeep_style' has changed");
3394     DIO_PUT(uint8, &dout, "gold_upkeep_style", real_packet->gold_upkeep_style);
3395   }
3396   if (BV_ISSET(fields, 38)) {
3397     log_packet_detailed("  field 'revolentype' has changed");
3398     DIO_PUT(uint8, &dout, "revolentype", real_packet->revolentype);
3399   }
3400   if (BV_ISSET(fields, 39)) {
3401     log_packet_detailed("  field 'default_government_id' has changed");
3402     DIO_PUT(sint8, &dout, "default_government_id", real_packet->default_government_id);
3403   }
3404   if (BV_ISSET(fields, 40)) {
3405     log_packet_detailed("  field 'government_during_revolution_id' has changed");
3406     DIO_PUT(sint8, &dout, "government_during_revolution_id", real_packet->government_during_revolution_id);
3407   }
3408   if (BV_ISSET(fields, 41)) {
3409     log_packet_detailed("  field 'granary_food_inc' has changed");
3410     DIO_PUT(uint8, &dout, "granary_food_inc", real_packet->granary_food_inc);
3411   }
3412   if (BV_ISSET(fields, 42)) {
3413     log_packet_detailed("  field 'granary_food_ini' has changed");
3414 
3415     {
3416       int i;
3417 
3418       for (i = 0; i < MAX_GRANARY_INIS; i++) {
3419         dio_put_uint8(&dout, real_packet->granary_food_ini[i]);
3420       }
3421     }
3422   }
3423   if (BV_ISSET(fields, 43)) {
3424     log_packet_detailed("  field 'granary_num_inis' has changed");
3425     DIO_PUT(uint8, &dout, "granary_num_inis", real_packet->granary_num_inis);
3426   }
3427   if (BV_ISSET(fields, 44)) {
3428     log_packet_detailed("  field 'great_wonder_owners' has changed");
3429 
3430     {
3431       int i;
3432 
3433       fc_assert(B_LAST < 255);
3434 
3435       for (i = 0; i < B_LAST; i++) {
3436         if (old->great_wonder_owners[i] != real_packet->great_wonder_owners[i]) {
3437           dio_put_uint8(&dout, i);
3438           dio_put_uint8(&dout, real_packet->great_wonder_owners[i]);
3439         }
3440       }
3441       dio_put_uint8(&dout, 255);
3442     }
3443   }
3444   if (BV_ISSET(fields, 45)) {
3445     log_packet_detailed("  field 'happy_cost' has changed");
3446     DIO_PUT(uint8, &dout, "happy_cost", real_packet->happy_cost);
3447   }
3448   if (BV_ISSET(fields, 46)) {
3449     log_packet_detailed("  field 'happyborders' has changed");
3450     DIO_PUT(uint8, &dout, "happyborders", real_packet->happyborders);
3451   }
3452   if (BV_ISSET(fields, 47)) {
3453     log_packet_detailed("  field 'heating' has changed");
3454     DIO_PUT(uint32, &dout, "heating", real_packet->heating);
3455   }
3456   if (BV_ISSET(fields, 48)) {
3457     log_packet_detailed("  field 'illness_base_factor' has changed");
3458     DIO_PUT(uint16, &dout, "illness_base_factor", real_packet->illness_base_factor);
3459   }
3460   if (BV_ISSET(fields, 49)) {
3461     log_packet_detailed("  field 'illness_min_size' has changed");
3462     DIO_PUT(uint8, &dout, "illness_min_size", real_packet->illness_min_size);
3463   }
3464   /* field 50 is folded into the header */
3465   if (BV_ISSET(fields, 51)) {
3466     log_packet_detailed("  field 'illness_pollution_factor' has changed");
3467     DIO_PUT(uint16, &dout, "illness_pollution_factor", real_packet->illness_pollution_factor);
3468   }
3469   if (BV_ISSET(fields, 52)) {
3470     log_packet_detailed("  field 'illness_trade_infection' has changed");
3471     DIO_PUT(uint16, &dout, "illness_trade_infection", real_packet->illness_trade_infection);
3472   }
3473   if (BV_ISSET(fields, 53)) {
3474     log_packet_detailed("  field 'init_city_radius_sq' has changed");
3475     DIO_PUT(uint8, &dout, "init_city_radius_sq", real_packet->init_city_radius_sq);
3476   }
3477   /* field 54 is folded into the header */
3478   /* field 55 is folded into the header */
3479   /* field 56 is folded into the header */
3480   /* field 57 is folded into the header */
3481   if (BV_ISSET(fields, 58)) {
3482     log_packet_detailed("  field 'min_city_center_output' has changed");
3483 
3484     {
3485       int i;
3486 
3487       for (i = 0; i < O_LAST; i++) {
3488         dio_put_uint8(&dout, real_packet->min_city_center_output[i]);
3489       }
3490     }
3491   }
3492   if (BV_ISSET(fields, 59)) {
3493     log_packet_detailed("  field 'negative_year_label' has changed");
3494     DIO_PUT(string, &dout, "negative_year_label", real_packet->negative_year_label);
3495   }
3496   if (BV_ISSET(fields, 60)) {
3497     log_packet_detailed("  field 'notradesize' has changed");
3498     DIO_PUT(uint8, &dout, "notradesize", real_packet->notradesize);
3499   }
3500   /* field 61 is folded into the header */
3501   if (BV_ISSET(fields, 62)) {
3502     log_packet_detailed("  field 'nuclearwinter' has changed");
3503     DIO_PUT(uint32, &dout, "nuclearwinter", real_packet->nuclearwinter);
3504   }
3505   if (BV_ISSET(fields, 63)) {
3506     log_packet_detailed("  field 'phase' has changed");
3507     DIO_PUT(sint16, &dout, "phase", real_packet->phase);
3508   }
3509   if (BV_ISSET(fields, 64)) {
3510     log_packet_detailed("  field 'phase_mode' has changed");
3511     DIO_PUT(uint8, &dout, "phase_mode", real_packet->phase_mode);
3512   }
3513   /* field 65 is folded into the header */
3514   /* field 66 is folded into the header */
3515   /* field 67 is folded into the header */
3516   /* field 68 is folded into the header */
3517   /* field 69 is folded into the header */
3518   /* field 70 is folded into the header */
3519   if (BV_ISSET(fields, 71)) {
3520     log_packet_detailed("  field 'positive_year_label' has changed");
3521     DIO_PUT(string, &dout, "positive_year_label", real_packet->positive_year_label);
3522   }
3523   if (BV_ISSET(fields, 72)) {
3524     log_packet_detailed("  field 'rapturedelay' has changed");
3525     DIO_PUT(uint8, &dout, "rapturedelay", real_packet->rapturedelay);
3526   }
3527   if (BV_ISSET(fields, 73)) {
3528     log_packet_detailed("  field 'disasters' has changed");
3529     DIO_PUT(uint16, &dout, "disasters", real_packet->disasters);
3530   }
3531   /* field 74 is folded into the header */
3532   /* field 75 is folded into the header */
3533   if (BV_ISSET(fields, 76)) {
3534     log_packet_detailed("  field 'sciencebox' has changed");
3535     DIO_PUT(uint32, &dout, "sciencebox", real_packet->sciencebox);
3536   }
3537   if (BV_ISSET(fields, 77)) {
3538     log_packet_detailed("  field 'shieldbox' has changed");
3539     DIO_PUT(uint32, &dout, "shieldbox", real_packet->shieldbox);
3540   }
3541   if (BV_ISSET(fields, 78)) {
3542     log_packet_detailed("  field 'skill_level' has changed");
3543     DIO_PUT(uint32, &dout, "skill_level", real_packet->skill_level);
3544   }
3545   /* field 79 is folded into the header */
3546   if (BV_ISSET(fields, 80)) {
3547     log_packet_detailed("  field 'victory_conditions' has changed");
3548     DIO_PUT(uint8, &dout, "victory_conditions", real_packet->victory_conditions);
3549   }
3550   /* field 81 is folded into the header */
3551   if (BV_ISSET(fields, 82)) {
3552     log_packet_detailed("  field 'tech' has changed");
3553     DIO_PUT(uint32, &dout, "tech", real_packet->tech);
3554   }
3555   if (BV_ISSET(fields, 83)) {
3556     log_packet_detailed("  field 'tech_cost_style' has changed");
3557     DIO_PUT(uint8, &dout, "tech_cost_style", real_packet->tech_cost_style);
3558   }
3559   if (BV_ISSET(fields, 84)) {
3560     log_packet_detailed("  field 'tech_leakage' has changed");
3561     DIO_PUT(uint8, &dout, "tech_leakage", real_packet->tech_leakage);
3562   }
3563   if (BV_ISSET(fields, 85)) {
3564     log_packet_detailed("  field 'tech_upkeep_divider' has changed");
3565     DIO_PUT(uint16, &dout, "tech_upkeep_divider", real_packet->tech_upkeep_divider);
3566   }
3567   if (BV_ISSET(fields, 86)) {
3568     log_packet_detailed("  field 'tech_upkeep_style' has changed");
3569     DIO_PUT(uint8, &dout, "tech_upkeep_style", real_packet->tech_upkeep_style);
3570   }
3571   if (BV_ISSET(fields, 87)) {
3572     log_packet_detailed("  field 'techloss_forgiveness' has changed");
3573     DIO_PUT(sint16, &dout, "techloss_forgiveness", real_packet->techloss_forgiveness);
3574   }
3575   if (BV_ISSET(fields, 88)) {
3576     log_packet_detailed("  field 'free_tech_method' has changed");
3577     DIO_PUT(uint8, &dout, "free_tech_method", real_packet->free_tech_method);
3578   }
3579   if (BV_ISSET(fields, 89)) {
3580     log_packet_detailed("  field 'gameloss_style' has changed");
3581     DIO_PUT(uint8, &dout, "gameloss_style", real_packet->gameloss_style);
3582   }
3583   if (BV_ISSET(fields, 90)) {
3584     log_packet_detailed("  field 'timeout' has changed");
3585     DIO_PUT(uint32, &dout, "timeout", real_packet->timeout);
3586   }
3587   if (BV_ISSET(fields, 91)) {
3588     log_packet_detailed("  field 'first_timeout' has changed");
3589     DIO_PUT(uint32, &dout, "first_timeout", real_packet->first_timeout);
3590   }
3591   /* field 92 is folded into the header */
3592   if (BV_ISSET(fields, 93)) {
3593     log_packet_detailed("  field 'trademindist' has changed");
3594     DIO_PUT(uint16, &dout, "trademindist", real_packet->trademindist);
3595   }
3596   /* field 94 is folded into the header */
3597   /* field 95 is folded into the header */
3598   /* field 96 is folded into the header */
3599   /* field 97 is folded into the header */
3600   if (BV_ISSET(fields, 98)) {
3601     log_packet_detailed("  field 'turn' has changed");
3602     DIO_PUT(sint16, &dout, "turn", real_packet->turn);
3603   }
3604   if (BV_ISSET(fields, 99)) {
3605     log_packet_detailed("  field 'warminglevel' has changed");
3606     DIO_PUT(uint32, &dout, "warminglevel", real_packet->warminglevel);
3607   }
3608   if (BV_ISSET(fields, 100)) {
3609     log_packet_detailed("  field 'year16' has changed");
3610     DIO_PUT(sint16, &dout, "year16", real_packet->year16);
3611   }
3612   if (BV_ISSET(fields, 101)) {
3613     log_packet_detailed("  field 'year32' has changed");
3614     DIO_PUT(sint32, &dout, "year32", real_packet->year32);
3615   }
3616   /* field 102 is folded into the header */
3617   if (BV_ISSET(fields, 103)) {
3618     log_packet_detailed("  field 'calendar_fragments' has changed");
3619     DIO_PUT(uint16, &dout, "calendar_fragments", real_packet->calendar_fragments);
3620   }
3621   if (BV_ISSET(fields, 104)) {
3622     log_packet_detailed("  field 'fragment_count' has changed");
3623     DIO_PUT(uint16, &dout, "fragment_count", real_packet->fragment_count);
3624   }
3625   if (BV_ISSET(fields, 105)) {
3626     log_packet_detailed("  field 'calendar_fragment_name' has changed");
3627 
3628     {
3629       int i;
3630 
3631       for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
3632         dio_put_string(&dout, real_packet->calendar_fragment_name[i]);
3633       }
3634     }
3635   }
3636   /* field 106 is folded into the header */
3637   /* field 107 is folded into the header */
3638 
3639   *old = *real_packet;
3640   SEND_PACKET_END(PACKET_GAME_INFO);
3641 }
3642 
3643 #define hash_packet_game_info_101 hash_const
3644 
3645 #define cmp_packet_game_info_101 cmp_const
3646 
3647 BV_DEFINE(packet_game_info_101_fields, 107);
3648 
receive_packet_game_info_101(struct connection * pc)3649 static struct packet_game_info *receive_packet_game_info_101(struct connection *pc)
3650 {
3651   packet_game_info_101_fields fields;
3652   struct packet_game_info *old;
3653   struct genhash **hash = pc->phs.received + PACKET_GAME_INFO;
3654   RECEIVE_PACKET_START(packet_game_info, real_packet);
3655 
3656   DIO_BV_GET(&din, fields);
3657 
3658   log_packet_detailed("packet_game_info_101: got info about ()");
3659 
3660   if (NULL == *hash) {
3661     *hash = genhash_new_full(hash_packet_game_info_101, cmp_packet_game_info_101,
3662                              NULL, NULL, NULL, free);
3663   }
3664 
3665   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
3666     *real_packet = *old;
3667   } else {
3668     log_packet_detailed("  no old info");
3669     memset(real_packet, 0, sizeof(*real_packet));
3670   }
3671 
3672   if (BV_ISSET(fields, 0)) {
3673     log_packet_detailed("  got field 'add_to_size_limit'");
3674     if (!DIO_GET(uint8, &din, "add_to_size_limit", &real_packet->add_to_size_limit)) {
3675       RECEIVE_PACKET_FIELD_ERROR(add_to_size_limit);
3676     }
3677   }
3678   if (BV_ISSET(fields, 1)) {
3679     log_packet_detailed("  got field 'aifill'");
3680     if (!DIO_GET(uint8, &din, "aifill", &real_packet->aifill)) {
3681       RECEIVE_PACKET_FIELD_ERROR(aifill);
3682     }
3683   }
3684   if (BV_ISSET(fields, 2)) {
3685     log_packet_detailed("  got field 'persistent_ready'");
3686     {
3687       int readin;
3688 
3689       if (!DIO_GET(uint8, &din, "persistent_ready", &readin)) {
3690         RECEIVE_PACKET_FIELD_ERROR(persistent_ready);
3691       }
3692       real_packet->persistent_ready = readin;
3693     }
3694   }
3695   if (BV_ISSET(fields, 3)) {
3696     log_packet_detailed("  got field 'airlifting_style'");
3697     {
3698       int readin;
3699 
3700       if (!DIO_GET(uint8, &din, "airlifting_style", &readin)) {
3701         RECEIVE_PACKET_FIELD_ERROR(airlifting_style);
3702       }
3703       real_packet->airlifting_style = readin;
3704     }
3705   }
3706   if (BV_ISSET(fields, 4)) {
3707     log_packet_detailed("  got field 'angrycitizen'");
3708     if (!DIO_GET(uint8, &din, "angrycitizen", &real_packet->angrycitizen)) {
3709       RECEIVE_PACKET_FIELD_ERROR(angrycitizen);
3710     }
3711   }
3712   if (BV_ISSET(fields, 5)) {
3713     log_packet_detailed("  got field 'base_pollution'");
3714     if (!DIO_GET(sint16, &din, "base_pollution", &real_packet->base_pollution)) {
3715       RECEIVE_PACKET_FIELD_ERROR(base_pollution);
3716     }
3717   }
3718   if (BV_ISSET(fields, 6)) {
3719     log_packet_detailed("  got field 'base_tech_cost'");
3720     if (!DIO_GET(uint8, &din, "base_tech_cost", &real_packet->base_tech_cost)) {
3721       RECEIVE_PACKET_FIELD_ERROR(base_tech_cost);
3722     }
3723   }
3724   if (BV_ISSET(fields, 7)) {
3725     log_packet_detailed("  got field 'border_city_radius_sq'");
3726     if (!DIO_GET(uint16, &din, "border_city_radius_sq", &real_packet->border_city_radius_sq)) {
3727       RECEIVE_PACKET_FIELD_ERROR(border_city_radius_sq);
3728     }
3729   }
3730   if (BV_ISSET(fields, 8)) {
3731     log_packet_detailed("  got field 'border_size_effect'");
3732     if (!DIO_GET(uint8, &din, "border_size_effect", &real_packet->border_size_effect)) {
3733       RECEIVE_PACKET_FIELD_ERROR(border_size_effect);
3734     }
3735   }
3736   if (BV_ISSET(fields, 9)) {
3737     log_packet_detailed("  got field 'border_city_permanent_radius_sq'");
3738     if (!DIO_GET(sint16, &din, "border_city_permanent_radius_sq", &real_packet->border_city_permanent_radius_sq)) {
3739       RECEIVE_PACKET_FIELD_ERROR(border_city_permanent_radius_sq);
3740     }
3741   }
3742   if (BV_ISSET(fields, 10)) {
3743     log_packet_detailed("  got field 'borders'");
3744     {
3745       int readin;
3746 
3747       if (!DIO_GET(uint8, &din, "borders", &readin)) {
3748         RECEIVE_PACKET_FIELD_ERROR(borders);
3749       }
3750       real_packet->borders = readin;
3751     }
3752   }
3753   if (BV_ISSET(fields, 11)) {
3754     log_packet_detailed("  got field 'base_bribe_cost'");
3755     if (!DIO_GET(uint32, &din, "base_bribe_cost", &real_packet->base_bribe_cost)) {
3756       RECEIVE_PACKET_FIELD_ERROR(base_bribe_cost);
3757     }
3758   }
3759   if (BV_ISSET(fields, 12)) {
3760     log_packet_detailed("  got field 'culture_vic_points'");
3761     if (!DIO_GET(uint32, &din, "culture_vic_points", &real_packet->culture_vic_points)) {
3762       RECEIVE_PACKET_FIELD_ERROR(culture_vic_points);
3763     }
3764   }
3765   if (BV_ISSET(fields, 13)) {
3766     log_packet_detailed("  got field 'culture_vic_lead'");
3767     if (!DIO_GET(uint16, &din, "culture_vic_lead", &real_packet->culture_vic_lead)) {
3768       RECEIVE_PACKET_FIELD_ERROR(culture_vic_lead);
3769     }
3770   }
3771   if (BV_ISSET(fields, 14)) {
3772     log_packet_detailed("  got field 'culture_migration_pml'");
3773     if (!DIO_GET(uint16, &din, "culture_migration_pml", &real_packet->culture_migration_pml)) {
3774       RECEIVE_PACKET_FIELD_ERROR(culture_migration_pml);
3775     }
3776   }
3777   real_packet->calendar_skip_0 = BV_ISSET(fields, 15);
3778   if (BV_ISSET(fields, 16)) {
3779     log_packet_detailed("  got field 'celebratesize'");
3780     if (!DIO_GET(uint8, &din, "celebratesize", &real_packet->celebratesize)) {
3781       RECEIVE_PACKET_FIELD_ERROR(celebratesize);
3782     }
3783   }
3784   real_packet->changable_tax = BV_ISSET(fields, 17);
3785   if (BV_ISSET(fields, 18)) {
3786     log_packet_detailed("  got field 'pop_report_zeroes'");
3787     if (!DIO_GET(uint8, &din, "pop_report_zeroes", &real_packet->pop_report_zeroes)) {
3788       RECEIVE_PACKET_FIELD_ERROR(pop_report_zeroes);
3789     }
3790   }
3791   real_packet->citizen_nationality = BV_ISSET(fields, 19);
3792   if (BV_ISSET(fields, 20)) {
3793     log_packet_detailed("  got field 'citizen_convert_speed'");
3794     if (!DIO_GET(uint16, &din, "citizen_convert_speed", &real_packet->citizen_convert_speed)) {
3795       RECEIVE_PACKET_FIELD_ERROR(citizen_convert_speed);
3796     }
3797   }
3798   if (BV_ISSET(fields, 21)) {
3799     log_packet_detailed("  got field 'citizen_partisans_pct'");
3800     if (!DIO_GET(uint8, &din, "citizen_partisans_pct", &real_packet->citizen_partisans_pct)) {
3801       RECEIVE_PACKET_FIELD_ERROR(citizen_partisans_pct);
3802     }
3803   }
3804   if (BV_ISSET(fields, 22)) {
3805     log_packet_detailed("  got field 'citymindist'");
3806     if (!DIO_GET(uint8, &din, "citymindist", &real_packet->citymindist)) {
3807       RECEIVE_PACKET_FIELD_ERROR(citymindist);
3808     }
3809   }
3810   if (BV_ISSET(fields, 23)) {
3811     log_packet_detailed("  got field 'cooling'");
3812     if (!DIO_GET(uint32, &din, "cooling", &real_packet->cooling)) {
3813       RECEIVE_PACKET_FIELD_ERROR(cooling);
3814     }
3815   }
3816   if (BV_ISSET(fields, 24)) {
3817     log_packet_detailed("  got field 'coolinglevel'");
3818     if (!DIO_GET(uint32, &din, "coolinglevel", &real_packet->coolinglevel)) {
3819       RECEIVE_PACKET_FIELD_ERROR(coolinglevel);
3820     }
3821   }
3822   if (BV_ISSET(fields, 25)) {
3823     log_packet_detailed("  got field 'diplomacy'");
3824     {
3825       int readin;
3826 
3827       if (!DIO_GET(uint8, &din, "diplomacy", &readin)) {
3828         RECEIVE_PACKET_FIELD_ERROR(diplomacy);
3829       }
3830       real_packet->diplomacy = readin;
3831     }
3832   }
3833   real_packet->fogofwar = BV_ISSET(fields, 26);
3834   if (BV_ISSET(fields, 27)) {
3835     log_packet_detailed("  got field 'food_cost'");
3836     if (!DIO_GET(uint8, &din, "food_cost", &real_packet->food_cost)) {
3837       RECEIVE_PACKET_FIELD_ERROR(food_cost);
3838     }
3839   }
3840   if (BV_ISSET(fields, 28)) {
3841     log_packet_detailed("  got field 'foodbox'");
3842     if (!DIO_GET(uint32, &din, "foodbox", &real_packet->foodbox)) {
3843       RECEIVE_PACKET_FIELD_ERROR(foodbox);
3844     }
3845   }
3846   if (BV_ISSET(fields, 29)) {
3847     log_packet_detailed("  got field 'forced_gold'");
3848     if (!DIO_GET(uint8, &din, "forced_gold", &real_packet->forced_gold)) {
3849       RECEIVE_PACKET_FIELD_ERROR(forced_gold);
3850     }
3851   }
3852   if (BV_ISSET(fields, 30)) {
3853     log_packet_detailed("  got field 'forced_luxury'");
3854     if (!DIO_GET(uint8, &din, "forced_luxury", &real_packet->forced_luxury)) {
3855       RECEIVE_PACKET_FIELD_ERROR(forced_luxury);
3856     }
3857   }
3858   if (BV_ISSET(fields, 31)) {
3859     log_packet_detailed("  got field 'forced_science'");
3860     if (!DIO_GET(uint8, &din, "forced_science", &real_packet->forced_science)) {
3861       RECEIVE_PACKET_FIELD_ERROR(forced_science);
3862     }
3863   }
3864   if (BV_ISSET(fields, 32)) {
3865     log_packet_detailed("  got field 'fulltradesize'");
3866     if (!DIO_GET(uint8, &din, "fulltradesize", &real_packet->fulltradesize)) {
3867       RECEIVE_PACKET_FIELD_ERROR(fulltradesize);
3868     }
3869   }
3870   if (BV_ISSET(fields, 33)) {
3871     log_packet_detailed("  got field 'global_advances'");
3872 
3873     for (;;) {
3874       int i;
3875 
3876       if (!DIO_GET(uint8, &din, "global_advances", &i)) {
3877         RECEIVE_PACKET_FIELD_ERROR(global_advances);
3878       }
3879       if (i == 255) {
3880         break;
3881       }
3882       if (i > A_LAST) {
3883         RECEIVE_PACKET_FIELD_ERROR(global_advances,
3884                                    ": unexpected value %d "
3885                                    "(> A_LAST) in array diff",
3886                                    i);
3887       } else {
3888         if (!DIO_GET(bool8, &din, "global_advances", &real_packet->global_advances[i])) {
3889           RECEIVE_PACKET_FIELD_ERROR(global_advances);
3890         }
3891       }
3892     }
3893   }
3894   real_packet->global_warming = BV_ISSET(fields, 34);
3895   if (BV_ISSET(fields, 35)) {
3896     log_packet_detailed("  got field 'globalwarming'");
3897     if (!DIO_GET(uint32, &din, "globalwarming", &real_packet->globalwarming)) {
3898       RECEIVE_PACKET_FIELD_ERROR(globalwarming);
3899     }
3900   }
3901   if (BV_ISSET(fields, 36)) {
3902     log_packet_detailed("  got field 'gold'");
3903     if (!DIO_GET(uint32, &din, "gold", &real_packet->gold)) {
3904       RECEIVE_PACKET_FIELD_ERROR(gold);
3905     }
3906   }
3907   if (BV_ISSET(fields, 37)) {
3908     log_packet_detailed("  got field 'gold_upkeep_style'");
3909     {
3910       int readin;
3911 
3912       if (!DIO_GET(uint8, &din, "gold_upkeep_style", &readin)) {
3913         RECEIVE_PACKET_FIELD_ERROR(gold_upkeep_style);
3914       }
3915       real_packet->gold_upkeep_style = readin;
3916     }
3917   }
3918   if (BV_ISSET(fields, 38)) {
3919     log_packet_detailed("  got field 'revolentype'");
3920     {
3921       int readin;
3922 
3923       if (!DIO_GET(uint8, &din, "revolentype", &readin)) {
3924         RECEIVE_PACKET_FIELD_ERROR(revolentype);
3925       }
3926       real_packet->revolentype = readin;
3927     }
3928   }
3929   if (BV_ISSET(fields, 39)) {
3930     log_packet_detailed("  got field 'default_government_id'");
3931     {
3932       int readin;
3933 
3934       if (!DIO_GET(sint8, &din, "default_government_id", &readin)) {
3935         RECEIVE_PACKET_FIELD_ERROR(default_government_id);
3936       }
3937       real_packet->default_government_id = readin;
3938     }
3939   }
3940   if (BV_ISSET(fields, 40)) {
3941     log_packet_detailed("  got field 'government_during_revolution_id'");
3942     {
3943       int readin;
3944 
3945       if (!DIO_GET(sint8, &din, "government_during_revolution_id", &readin)) {
3946         RECEIVE_PACKET_FIELD_ERROR(government_during_revolution_id);
3947       }
3948       real_packet->government_during_revolution_id = readin;
3949     }
3950   }
3951   if (BV_ISSET(fields, 41)) {
3952     log_packet_detailed("  got field 'granary_food_inc'");
3953     if (!DIO_GET(uint8, &din, "granary_food_inc", &real_packet->granary_food_inc)) {
3954       RECEIVE_PACKET_FIELD_ERROR(granary_food_inc);
3955     }
3956   }
3957   if (BV_ISSET(fields, 42)) {
3958     log_packet_detailed("  got field 'granary_food_ini'");
3959 
3960     {
3961       int i;
3962 
3963       for (i = 0; i < MAX_GRANARY_INIS; i++) {
3964         if (!DIO_GET(uint8, &din, "granary_food_ini", &real_packet->granary_food_ini[i])) {
3965           RECEIVE_PACKET_FIELD_ERROR(granary_food_ini);
3966         }
3967       }
3968     }
3969   }
3970   if (BV_ISSET(fields, 43)) {
3971     log_packet_detailed("  got field 'granary_num_inis'");
3972     if (!DIO_GET(uint8, &din, "granary_num_inis", &real_packet->granary_num_inis)) {
3973       RECEIVE_PACKET_FIELD_ERROR(granary_num_inis);
3974     }
3975   }
3976   if (BV_ISSET(fields, 44)) {
3977     log_packet_detailed("  got field 'great_wonder_owners'");
3978 
3979     for (;;) {
3980       int i;
3981 
3982       if (!DIO_GET(uint8, &din, "great_wonder_owners", &i)) {
3983         RECEIVE_PACKET_FIELD_ERROR(great_wonder_owners);
3984       }
3985       if (i == 255) {
3986         break;
3987       }
3988       if (i > B_LAST) {
3989         RECEIVE_PACKET_FIELD_ERROR(great_wonder_owners,
3990                                    ": unexpected value %d "
3991                                    "(> B_LAST) in array diff",
3992                                    i);
3993       } else {
3994         if (!DIO_GET(uint8, &din, "great_wonder_owners", &real_packet->great_wonder_owners[i])) {
3995           RECEIVE_PACKET_FIELD_ERROR(great_wonder_owners);
3996         }
3997       }
3998     }
3999   }
4000   if (BV_ISSET(fields, 45)) {
4001     log_packet_detailed("  got field 'happy_cost'");
4002     if (!DIO_GET(uint8, &din, "happy_cost", &real_packet->happy_cost)) {
4003       RECEIVE_PACKET_FIELD_ERROR(happy_cost);
4004     }
4005   }
4006   if (BV_ISSET(fields, 46)) {
4007     log_packet_detailed("  got field 'happyborders'");
4008     {
4009       int readin;
4010 
4011       if (!DIO_GET(uint8, &din, "happyborders", &readin)) {
4012         RECEIVE_PACKET_FIELD_ERROR(happyborders);
4013       }
4014       real_packet->happyborders = readin;
4015     }
4016   }
4017   if (BV_ISSET(fields, 47)) {
4018     log_packet_detailed("  got field 'heating'");
4019     if (!DIO_GET(uint32, &din, "heating", &real_packet->heating)) {
4020       RECEIVE_PACKET_FIELD_ERROR(heating);
4021     }
4022   }
4023   if (BV_ISSET(fields, 48)) {
4024     log_packet_detailed("  got field 'illness_base_factor'");
4025     if (!DIO_GET(uint16, &din, "illness_base_factor", &real_packet->illness_base_factor)) {
4026       RECEIVE_PACKET_FIELD_ERROR(illness_base_factor);
4027     }
4028   }
4029   if (BV_ISSET(fields, 49)) {
4030     log_packet_detailed("  got field 'illness_min_size'");
4031     if (!DIO_GET(uint8, &din, "illness_min_size", &real_packet->illness_min_size)) {
4032       RECEIVE_PACKET_FIELD_ERROR(illness_min_size);
4033     }
4034   }
4035   real_packet->illness_on = BV_ISSET(fields, 50);
4036   if (BV_ISSET(fields, 51)) {
4037     log_packet_detailed("  got field 'illness_pollution_factor'");
4038     if (!DIO_GET(uint16, &din, "illness_pollution_factor", &real_packet->illness_pollution_factor)) {
4039       RECEIVE_PACKET_FIELD_ERROR(illness_pollution_factor);
4040     }
4041   }
4042   if (BV_ISSET(fields, 52)) {
4043     log_packet_detailed("  got field 'illness_trade_infection'");
4044     if (!DIO_GET(uint16, &din, "illness_trade_infection", &real_packet->illness_trade_infection)) {
4045       RECEIVE_PACKET_FIELD_ERROR(illness_trade_infection);
4046     }
4047   }
4048   if (BV_ISSET(fields, 53)) {
4049     log_packet_detailed("  got field 'init_city_radius_sq'");
4050     if (!DIO_GET(uint8, &din, "init_city_radius_sq", &real_packet->init_city_radius_sq)) {
4051       RECEIVE_PACKET_FIELD_ERROR(init_city_radius_sq);
4052     }
4053   }
4054   real_packet->is_edit_mode = BV_ISSET(fields, 54);
4055   real_packet->is_new_game = BV_ISSET(fields, 55);
4056   real_packet->killcitizen = BV_ISSET(fields, 56);
4057   real_packet->killstack = BV_ISSET(fields, 57);
4058   if (BV_ISSET(fields, 58)) {
4059     log_packet_detailed("  got field 'min_city_center_output'");
4060 
4061     {
4062       int i;
4063 
4064       for (i = 0; i < O_LAST; i++) {
4065         if (!DIO_GET(uint8, &din, "min_city_center_output", &real_packet->min_city_center_output[i])) {
4066           RECEIVE_PACKET_FIELD_ERROR(min_city_center_output);
4067         }
4068       }
4069     }
4070   }
4071   if (BV_ISSET(fields, 59)) {
4072     log_packet_detailed("  got field 'negative_year_label'");
4073     if (!DIO_GET(string, &din, "negative_year_label", real_packet->negative_year_label, sizeof(real_packet->negative_year_label))) {
4074       RECEIVE_PACKET_FIELD_ERROR(negative_year_label);
4075     }
4076   }
4077   if (BV_ISSET(fields, 60)) {
4078     log_packet_detailed("  got field 'notradesize'");
4079     if (!DIO_GET(uint8, &din, "notradesize", &real_packet->notradesize)) {
4080       RECEIVE_PACKET_FIELD_ERROR(notradesize);
4081     }
4082   }
4083   real_packet->nuclear_winter = BV_ISSET(fields, 61);
4084   if (BV_ISSET(fields, 62)) {
4085     log_packet_detailed("  got field 'nuclearwinter'");
4086     if (!DIO_GET(uint32, &din, "nuclearwinter", &real_packet->nuclearwinter)) {
4087       RECEIVE_PACKET_FIELD_ERROR(nuclearwinter);
4088     }
4089   }
4090   if (BV_ISSET(fields, 63)) {
4091     log_packet_detailed("  got field 'phase'");
4092     if (!DIO_GET(sint16, &din, "phase", &real_packet->phase)) {
4093       RECEIVE_PACKET_FIELD_ERROR(phase);
4094     }
4095   }
4096   if (BV_ISSET(fields, 64)) {
4097     log_packet_detailed("  got field 'phase_mode'");
4098     {
4099       int readin;
4100 
4101       if (!DIO_GET(uint8, &din, "phase_mode", &readin)) {
4102         RECEIVE_PACKET_FIELD_ERROR(phase_mode);
4103       }
4104       real_packet->phase_mode = readin;
4105     }
4106   }
4107   real_packet->pillage_select = BV_ISSET(fields, 65);
4108   real_packet->tech_steal_allow_holes = BV_ISSET(fields, 66);
4109   real_packet->tech_trade_allow_holes = BV_ISSET(fields, 67);
4110   real_packet->tech_trade_loss_allow_holes = BV_ISSET(fields, 68);
4111   real_packet->tech_parasite_allow_holes = BV_ISSET(fields, 69);
4112   real_packet->tech_loss_allow_holes = BV_ISSET(fields, 70);
4113   if (BV_ISSET(fields, 71)) {
4114     log_packet_detailed("  got field 'positive_year_label'");
4115     if (!DIO_GET(string, &din, "positive_year_label", real_packet->positive_year_label, sizeof(real_packet->positive_year_label))) {
4116       RECEIVE_PACKET_FIELD_ERROR(positive_year_label);
4117     }
4118   }
4119   if (BV_ISSET(fields, 72)) {
4120     log_packet_detailed("  got field 'rapturedelay'");
4121     if (!DIO_GET(uint8, &din, "rapturedelay", &real_packet->rapturedelay)) {
4122       RECEIVE_PACKET_FIELD_ERROR(rapturedelay);
4123     }
4124   }
4125   if (BV_ISSET(fields, 73)) {
4126     log_packet_detailed("  got field 'disasters'");
4127     if (!DIO_GET(uint16, &din, "disasters", &real_packet->disasters)) {
4128       RECEIVE_PACKET_FIELD_ERROR(disasters);
4129     }
4130   }
4131   real_packet->restrictinfra = BV_ISSET(fields, 74);
4132   real_packet->unreachable_protects = BV_ISSET(fields, 75);
4133   if (BV_ISSET(fields, 76)) {
4134     log_packet_detailed("  got field 'sciencebox'");
4135     if (!DIO_GET(uint32, &din, "sciencebox", &real_packet->sciencebox)) {
4136       RECEIVE_PACKET_FIELD_ERROR(sciencebox);
4137     }
4138   }
4139   if (BV_ISSET(fields, 77)) {
4140     log_packet_detailed("  got field 'shieldbox'");
4141     if (!DIO_GET(uint32, &din, "shieldbox", &real_packet->shieldbox)) {
4142       RECEIVE_PACKET_FIELD_ERROR(shieldbox);
4143     }
4144   }
4145   if (BV_ISSET(fields, 78)) {
4146     log_packet_detailed("  got field 'skill_level'");
4147     if (!DIO_GET(uint32, &din, "skill_level", &real_packet->skill_level)) {
4148       RECEIVE_PACKET_FIELD_ERROR(skill_level);
4149     }
4150   }
4151   real_packet->slow_invasions = BV_ISSET(fields, 79);
4152   if (BV_ISSET(fields, 80)) {
4153     log_packet_detailed("  got field 'victory_conditions'");
4154     {
4155       int readin;
4156 
4157       if (!DIO_GET(uint8, &din, "victory_conditions", &readin)) {
4158         RECEIVE_PACKET_FIELD_ERROR(victory_conditions);
4159       }
4160       real_packet->victory_conditions = readin;
4161     }
4162   }
4163   real_packet->team_pooled_research = BV_ISSET(fields, 81);
4164   if (BV_ISSET(fields, 82)) {
4165     log_packet_detailed("  got field 'tech'");
4166     if (!DIO_GET(uint32, &din, "tech", &real_packet->tech)) {
4167       RECEIVE_PACKET_FIELD_ERROR(tech);
4168     }
4169   }
4170   if (BV_ISSET(fields, 83)) {
4171     log_packet_detailed("  got field 'tech_cost_style'");
4172     {
4173       int readin;
4174 
4175       if (!DIO_GET(uint8, &din, "tech_cost_style", &readin)) {
4176         RECEIVE_PACKET_FIELD_ERROR(tech_cost_style);
4177       }
4178       real_packet->tech_cost_style = readin;
4179     }
4180   }
4181   if (BV_ISSET(fields, 84)) {
4182     log_packet_detailed("  got field 'tech_leakage'");
4183     {
4184       int readin;
4185 
4186       if (!DIO_GET(uint8, &din, "tech_leakage", &readin)) {
4187         RECEIVE_PACKET_FIELD_ERROR(tech_leakage);
4188       }
4189       real_packet->tech_leakage = readin;
4190     }
4191   }
4192   if (BV_ISSET(fields, 85)) {
4193     log_packet_detailed("  got field 'tech_upkeep_divider'");
4194     if (!DIO_GET(uint16, &din, "tech_upkeep_divider", &real_packet->tech_upkeep_divider)) {
4195       RECEIVE_PACKET_FIELD_ERROR(tech_upkeep_divider);
4196     }
4197   }
4198   if (BV_ISSET(fields, 86)) {
4199     log_packet_detailed("  got field 'tech_upkeep_style'");
4200     {
4201       int readin;
4202 
4203       if (!DIO_GET(uint8, &din, "tech_upkeep_style", &readin)) {
4204         RECEIVE_PACKET_FIELD_ERROR(tech_upkeep_style);
4205       }
4206       real_packet->tech_upkeep_style = readin;
4207     }
4208   }
4209   if (BV_ISSET(fields, 87)) {
4210     log_packet_detailed("  got field 'techloss_forgiveness'");
4211     if (!DIO_GET(sint16, &din, "techloss_forgiveness", &real_packet->techloss_forgiveness)) {
4212       RECEIVE_PACKET_FIELD_ERROR(techloss_forgiveness);
4213     }
4214   }
4215   if (BV_ISSET(fields, 88)) {
4216     log_packet_detailed("  got field 'free_tech_method'");
4217     {
4218       int readin;
4219 
4220       if (!DIO_GET(uint8, &din, "free_tech_method", &readin)) {
4221         RECEIVE_PACKET_FIELD_ERROR(free_tech_method);
4222       }
4223       real_packet->free_tech_method = readin;
4224     }
4225   }
4226   if (BV_ISSET(fields, 89)) {
4227     log_packet_detailed("  got field 'gameloss_style'");
4228     {
4229       int readin;
4230 
4231       if (!DIO_GET(uint8, &din, "gameloss_style", &readin)) {
4232         RECEIVE_PACKET_FIELD_ERROR(gameloss_style);
4233       }
4234       real_packet->gameloss_style = readin;
4235     }
4236   }
4237   if (BV_ISSET(fields, 90)) {
4238     log_packet_detailed("  got field 'timeout'");
4239     if (!DIO_GET(uint32, &din, "timeout", &real_packet->timeout)) {
4240       RECEIVE_PACKET_FIELD_ERROR(timeout);
4241     }
4242   }
4243   if (BV_ISSET(fields, 91)) {
4244     log_packet_detailed("  got field 'first_timeout'");
4245     if (!DIO_GET(uint32, &din, "first_timeout", &real_packet->first_timeout)) {
4246       RECEIVE_PACKET_FIELD_ERROR(first_timeout);
4247     }
4248   }
4249   real_packet->tired_attack = BV_ISSET(fields, 92);
4250   if (BV_ISSET(fields, 93)) {
4251     log_packet_detailed("  got field 'trademindist'");
4252     if (!DIO_GET(uint16, &din, "trademindist", &real_packet->trademindist)) {
4253       RECEIVE_PACKET_FIELD_ERROR(trademindist);
4254     }
4255   }
4256   real_packet->force_trade_route = BV_ISSET(fields, 94);
4257   real_packet->trading_city = BV_ISSET(fields, 95);
4258   real_packet->trading_gold = BV_ISSET(fields, 96);
4259   real_packet->trading_tech = BV_ISSET(fields, 97);
4260   if (BV_ISSET(fields, 98)) {
4261     log_packet_detailed("  got field 'turn'");
4262     if (!DIO_GET(sint16, &din, "turn", &real_packet->turn)) {
4263       RECEIVE_PACKET_FIELD_ERROR(turn);
4264     }
4265   }
4266   if (BV_ISSET(fields, 99)) {
4267     log_packet_detailed("  got field 'warminglevel'");
4268     if (!DIO_GET(uint32, &din, "warminglevel", &real_packet->warminglevel)) {
4269       RECEIVE_PACKET_FIELD_ERROR(warminglevel);
4270     }
4271   }
4272   if (BV_ISSET(fields, 100)) {
4273     log_packet_detailed("  got field 'year16'");
4274     if (!DIO_GET(sint16, &din, "year16", &real_packet->year16)) {
4275       RECEIVE_PACKET_FIELD_ERROR(year16);
4276     }
4277   }
4278   real_packet->year_0_hack = BV_ISSET(fields, 101);
4279   if (BV_ISSET(fields, 102)) {
4280     log_packet_detailed("  got field 'calendar_fragments'");
4281     if (!DIO_GET(uint16, &din, "calendar_fragments", &real_packet->calendar_fragments)) {
4282       RECEIVE_PACKET_FIELD_ERROR(calendar_fragments);
4283     }
4284   }
4285   if (BV_ISSET(fields, 103)) {
4286     log_packet_detailed("  got field 'fragment_count'");
4287     if (!DIO_GET(uint16, &din, "fragment_count", &real_packet->fragment_count)) {
4288       RECEIVE_PACKET_FIELD_ERROR(fragment_count);
4289     }
4290   }
4291   if (BV_ISSET(fields, 104)) {
4292     log_packet_detailed("  got field 'calendar_fragment_name'");
4293 
4294     {
4295       int i;
4296 
4297       for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
4298         if (!DIO_GET(string, &din, "calendar_fragment_name", real_packet->calendar_fragment_name[i], sizeof(real_packet->calendar_fragment_name[i]))) {
4299           RECEIVE_PACKET_FIELD_ERROR(calendar_fragment_name);
4300         }
4301       }
4302     }
4303   }
4304   real_packet->civil_war_enabled = BV_ISSET(fields, 105);
4305   real_packet->paradrop_to_transport = BV_ISSET(fields, 106);
4306 
4307   if (NULL == old) {
4308     old = fc_malloc(sizeof(*old));
4309     *old = *real_packet;
4310     genhash_insert(*hash, old, old);
4311   } else {
4312     *old = *real_packet;
4313   }
4314   RECEIVE_PACKET_END(real_packet);
4315 }
4316 
send_packet_game_info_101(struct connection * pc,const struct packet_game_info * packet)4317 static int send_packet_game_info_101(struct connection *pc, const struct packet_game_info *packet)
4318 {
4319   const struct packet_game_info *real_packet = packet;
4320   packet_game_info_101_fields fields;
4321   struct packet_game_info *old;
4322   bool differ;
4323   struct genhash **hash = pc->phs.sent + PACKET_GAME_INFO;
4324   int different = 0;
4325   SEND_PACKET_START(PACKET_GAME_INFO);
4326 
4327   log_packet_detailed("packet_game_info_101: sending info about ()");
4328 
4329   if (NULL == *hash) {
4330     *hash = genhash_new_full(hash_packet_game_info_101, cmp_packet_game_info_101,
4331                              NULL, NULL, NULL, free);
4332   }
4333   BV_CLR_ALL(fields);
4334 
4335   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
4336     old = fc_malloc(sizeof(*old));
4337     *old = *real_packet;
4338     genhash_insert(*hash, old, old);
4339     memset(old, 0, sizeof(*old));
4340     different = 1;      /* Force to send. */
4341   }
4342 
4343   differ = (old->add_to_size_limit != real_packet->add_to_size_limit);
4344   if (differ) {
4345     different++;
4346     BV_SET(fields, 0);
4347   }
4348 
4349   differ = (old->aifill != real_packet->aifill);
4350   if (differ) {
4351     different++;
4352     BV_SET(fields, 1);
4353   }
4354 
4355   differ = (old->persistent_ready != real_packet->persistent_ready);
4356   if (differ) {
4357     different++;
4358     BV_SET(fields, 2);
4359   }
4360 
4361   differ = (old->airlifting_style != real_packet->airlifting_style);
4362   if (differ) {
4363     different++;
4364     BV_SET(fields, 3);
4365   }
4366 
4367   differ = (old->angrycitizen != real_packet->angrycitizen);
4368   if (differ) {
4369     different++;
4370     BV_SET(fields, 4);
4371   }
4372 
4373   differ = (old->base_pollution != real_packet->base_pollution);
4374   if (differ) {
4375     different++;
4376     BV_SET(fields, 5);
4377   }
4378 
4379   differ = (old->base_tech_cost != real_packet->base_tech_cost);
4380   if (differ) {
4381     different++;
4382     BV_SET(fields, 6);
4383   }
4384 
4385   differ = (old->border_city_radius_sq != real_packet->border_city_radius_sq);
4386   if (differ) {
4387     different++;
4388     BV_SET(fields, 7);
4389   }
4390 
4391   differ = (old->border_size_effect != real_packet->border_size_effect);
4392   if (differ) {
4393     different++;
4394     BV_SET(fields, 8);
4395   }
4396 
4397   differ = (old->border_city_permanent_radius_sq != real_packet->border_city_permanent_radius_sq);
4398   if (differ) {
4399     different++;
4400     BV_SET(fields, 9);
4401   }
4402 
4403   differ = (old->borders != real_packet->borders);
4404   if (differ) {
4405     different++;
4406     BV_SET(fields, 10);
4407   }
4408 
4409   differ = (old->base_bribe_cost != real_packet->base_bribe_cost);
4410   if (differ) {
4411     different++;
4412     BV_SET(fields, 11);
4413   }
4414 
4415   differ = (old->culture_vic_points != real_packet->culture_vic_points);
4416   if (differ) {
4417     different++;
4418     BV_SET(fields, 12);
4419   }
4420 
4421   differ = (old->culture_vic_lead != real_packet->culture_vic_lead);
4422   if (differ) {
4423     different++;
4424     BV_SET(fields, 13);
4425   }
4426 
4427   differ = (old->culture_migration_pml != real_packet->culture_migration_pml);
4428   if (differ) {
4429     different++;
4430     BV_SET(fields, 14);
4431   }
4432 
4433   differ = (old->calendar_skip_0 != real_packet->calendar_skip_0);
4434   if (differ) {
4435     different++;
4436   }
4437   if (packet->calendar_skip_0) {
4438     BV_SET(fields, 15);
4439   }
4440 
4441   differ = (old->celebratesize != real_packet->celebratesize);
4442   if (differ) {
4443     different++;
4444     BV_SET(fields, 16);
4445   }
4446 
4447   differ = (old->changable_tax != real_packet->changable_tax);
4448   if (differ) {
4449     different++;
4450   }
4451   if (packet->changable_tax) {
4452     BV_SET(fields, 17);
4453   }
4454 
4455   differ = (old->pop_report_zeroes != real_packet->pop_report_zeroes);
4456   if (differ) {
4457     different++;
4458     BV_SET(fields, 18);
4459   }
4460 
4461   differ = (old->citizen_nationality != real_packet->citizen_nationality);
4462   if (differ) {
4463     different++;
4464   }
4465   if (packet->citizen_nationality) {
4466     BV_SET(fields, 19);
4467   }
4468 
4469   differ = (old->citizen_convert_speed != real_packet->citizen_convert_speed);
4470   if (differ) {
4471     different++;
4472     BV_SET(fields, 20);
4473   }
4474 
4475   differ = (old->citizen_partisans_pct != real_packet->citizen_partisans_pct);
4476   if (differ) {
4477     different++;
4478     BV_SET(fields, 21);
4479   }
4480 
4481   differ = (old->citymindist != real_packet->citymindist);
4482   if (differ) {
4483     different++;
4484     BV_SET(fields, 22);
4485   }
4486 
4487   differ = (old->cooling != real_packet->cooling);
4488   if (differ) {
4489     different++;
4490     BV_SET(fields, 23);
4491   }
4492 
4493   differ = (old->coolinglevel != real_packet->coolinglevel);
4494   if (differ) {
4495     different++;
4496     BV_SET(fields, 24);
4497   }
4498 
4499   differ = (old->diplomacy != real_packet->diplomacy);
4500   if (differ) {
4501     different++;
4502     BV_SET(fields, 25);
4503   }
4504 
4505   differ = (old->fogofwar != real_packet->fogofwar);
4506   if (differ) {
4507     different++;
4508   }
4509   if (packet->fogofwar) {
4510     BV_SET(fields, 26);
4511   }
4512 
4513   differ = (old->food_cost != real_packet->food_cost);
4514   if (differ) {
4515     different++;
4516     BV_SET(fields, 27);
4517   }
4518 
4519   differ = (old->foodbox != real_packet->foodbox);
4520   if (differ) {
4521     different++;
4522     BV_SET(fields, 28);
4523   }
4524 
4525   differ = (old->forced_gold != real_packet->forced_gold);
4526   if (differ) {
4527     different++;
4528     BV_SET(fields, 29);
4529   }
4530 
4531   differ = (old->forced_luxury != real_packet->forced_luxury);
4532   if (differ) {
4533     different++;
4534     BV_SET(fields, 30);
4535   }
4536 
4537   differ = (old->forced_science != real_packet->forced_science);
4538   if (differ) {
4539     different++;
4540     BV_SET(fields, 31);
4541   }
4542 
4543   differ = (old->fulltradesize != real_packet->fulltradesize);
4544   if (differ) {
4545     different++;
4546     BV_SET(fields, 32);
4547   }
4548 
4549 
4550     {
4551       differ = (A_LAST != A_LAST);
4552       if (!differ) {
4553         int i;
4554 
4555         for (i = 0; i < A_LAST; i++) {
4556           if (old->global_advances[i] != real_packet->global_advances[i]) {
4557             differ = TRUE;
4558             break;
4559           }
4560         }
4561       }
4562     }
4563   if (differ) {
4564     different++;
4565     BV_SET(fields, 33);
4566   }
4567 
4568   differ = (old->global_warming != real_packet->global_warming);
4569   if (differ) {
4570     different++;
4571   }
4572   if (packet->global_warming) {
4573     BV_SET(fields, 34);
4574   }
4575 
4576   differ = (old->globalwarming != real_packet->globalwarming);
4577   if (differ) {
4578     different++;
4579     BV_SET(fields, 35);
4580   }
4581 
4582   differ = (old->gold != real_packet->gold);
4583   if (differ) {
4584     different++;
4585     BV_SET(fields, 36);
4586   }
4587 
4588   differ = (old->gold_upkeep_style != real_packet->gold_upkeep_style);
4589   if (differ) {
4590     different++;
4591     BV_SET(fields, 37);
4592   }
4593 
4594   differ = (old->revolentype != real_packet->revolentype);
4595   if (differ) {
4596     different++;
4597     BV_SET(fields, 38);
4598   }
4599 
4600   differ = (old->default_government_id != real_packet->default_government_id);
4601   if (differ) {
4602     different++;
4603     BV_SET(fields, 39);
4604   }
4605 
4606   differ = (old->government_during_revolution_id != real_packet->government_during_revolution_id);
4607   if (differ) {
4608     different++;
4609     BV_SET(fields, 40);
4610   }
4611 
4612   differ = (old->granary_food_inc != real_packet->granary_food_inc);
4613   if (differ) {
4614     different++;
4615     BV_SET(fields, 41);
4616   }
4617 
4618 
4619     {
4620       differ = (MAX_GRANARY_INIS != MAX_GRANARY_INIS);
4621       if (!differ) {
4622         int i;
4623 
4624         for (i = 0; i < MAX_GRANARY_INIS; i++) {
4625           if (old->granary_food_ini[i] != real_packet->granary_food_ini[i]) {
4626             differ = TRUE;
4627             break;
4628           }
4629         }
4630       }
4631     }
4632   if (differ) {
4633     different++;
4634     BV_SET(fields, 42);
4635   }
4636 
4637   differ = (old->granary_num_inis != real_packet->granary_num_inis);
4638   if (differ) {
4639     different++;
4640     BV_SET(fields, 43);
4641   }
4642 
4643 
4644     {
4645       differ = (B_LAST != B_LAST);
4646       if (!differ) {
4647         int i;
4648 
4649         for (i = 0; i < B_LAST; i++) {
4650           if (old->great_wonder_owners[i] != real_packet->great_wonder_owners[i]) {
4651             differ = TRUE;
4652             break;
4653           }
4654         }
4655       }
4656     }
4657   if (differ) {
4658     different++;
4659     BV_SET(fields, 44);
4660   }
4661 
4662   differ = (old->happy_cost != real_packet->happy_cost);
4663   if (differ) {
4664     different++;
4665     BV_SET(fields, 45);
4666   }
4667 
4668   differ = (old->happyborders != real_packet->happyborders);
4669   if (differ) {
4670     different++;
4671     BV_SET(fields, 46);
4672   }
4673 
4674   differ = (old->heating != real_packet->heating);
4675   if (differ) {
4676     different++;
4677     BV_SET(fields, 47);
4678   }
4679 
4680   differ = (old->illness_base_factor != real_packet->illness_base_factor);
4681   if (differ) {
4682     different++;
4683     BV_SET(fields, 48);
4684   }
4685 
4686   differ = (old->illness_min_size != real_packet->illness_min_size);
4687   if (differ) {
4688     different++;
4689     BV_SET(fields, 49);
4690   }
4691 
4692   differ = (old->illness_on != real_packet->illness_on);
4693   if (differ) {
4694     different++;
4695   }
4696   if (packet->illness_on) {
4697     BV_SET(fields, 50);
4698   }
4699 
4700   differ = (old->illness_pollution_factor != real_packet->illness_pollution_factor);
4701   if (differ) {
4702     different++;
4703     BV_SET(fields, 51);
4704   }
4705 
4706   differ = (old->illness_trade_infection != real_packet->illness_trade_infection);
4707   if (differ) {
4708     different++;
4709     BV_SET(fields, 52);
4710   }
4711 
4712   differ = (old->init_city_radius_sq != real_packet->init_city_radius_sq);
4713   if (differ) {
4714     different++;
4715     BV_SET(fields, 53);
4716   }
4717 
4718   differ = (old->is_edit_mode != real_packet->is_edit_mode);
4719   if (differ) {
4720     different++;
4721   }
4722   if (packet->is_edit_mode) {
4723     BV_SET(fields, 54);
4724   }
4725 
4726   differ = (old->is_new_game != real_packet->is_new_game);
4727   if (differ) {
4728     different++;
4729   }
4730   if (packet->is_new_game) {
4731     BV_SET(fields, 55);
4732   }
4733 
4734   differ = (old->killcitizen != real_packet->killcitizen);
4735   if (differ) {
4736     different++;
4737   }
4738   if (packet->killcitizen) {
4739     BV_SET(fields, 56);
4740   }
4741 
4742   differ = (old->killstack != real_packet->killstack);
4743   if (differ) {
4744     different++;
4745   }
4746   if (packet->killstack) {
4747     BV_SET(fields, 57);
4748   }
4749 
4750 
4751     {
4752       differ = (O_LAST != O_LAST);
4753       if (!differ) {
4754         int i;
4755 
4756         for (i = 0; i < O_LAST; i++) {
4757           if (old->min_city_center_output[i] != real_packet->min_city_center_output[i]) {
4758             differ = TRUE;
4759             break;
4760           }
4761         }
4762       }
4763     }
4764   if (differ) {
4765     different++;
4766     BV_SET(fields, 58);
4767   }
4768 
4769   differ = (strcmp(old->negative_year_label, real_packet->negative_year_label) != 0);
4770   if (differ) {
4771     different++;
4772     BV_SET(fields, 59);
4773   }
4774 
4775   differ = (old->notradesize != real_packet->notradesize);
4776   if (differ) {
4777     different++;
4778     BV_SET(fields, 60);
4779   }
4780 
4781   differ = (old->nuclear_winter != real_packet->nuclear_winter);
4782   if (differ) {
4783     different++;
4784   }
4785   if (packet->nuclear_winter) {
4786     BV_SET(fields, 61);
4787   }
4788 
4789   differ = (old->nuclearwinter != real_packet->nuclearwinter);
4790   if (differ) {
4791     different++;
4792     BV_SET(fields, 62);
4793   }
4794 
4795   differ = (old->phase != real_packet->phase);
4796   if (differ) {
4797     different++;
4798     BV_SET(fields, 63);
4799   }
4800 
4801   differ = (old->phase_mode != real_packet->phase_mode);
4802   if (differ) {
4803     different++;
4804     BV_SET(fields, 64);
4805   }
4806 
4807   differ = (old->pillage_select != real_packet->pillage_select);
4808   if (differ) {
4809     different++;
4810   }
4811   if (packet->pillage_select) {
4812     BV_SET(fields, 65);
4813   }
4814 
4815   differ = (old->tech_steal_allow_holes != real_packet->tech_steal_allow_holes);
4816   if (differ) {
4817     different++;
4818   }
4819   if (packet->tech_steal_allow_holes) {
4820     BV_SET(fields, 66);
4821   }
4822 
4823   differ = (old->tech_trade_allow_holes != real_packet->tech_trade_allow_holes);
4824   if (differ) {
4825     different++;
4826   }
4827   if (packet->tech_trade_allow_holes) {
4828     BV_SET(fields, 67);
4829   }
4830 
4831   differ = (old->tech_trade_loss_allow_holes != real_packet->tech_trade_loss_allow_holes);
4832   if (differ) {
4833     different++;
4834   }
4835   if (packet->tech_trade_loss_allow_holes) {
4836     BV_SET(fields, 68);
4837   }
4838 
4839   differ = (old->tech_parasite_allow_holes != real_packet->tech_parasite_allow_holes);
4840   if (differ) {
4841     different++;
4842   }
4843   if (packet->tech_parasite_allow_holes) {
4844     BV_SET(fields, 69);
4845   }
4846 
4847   differ = (old->tech_loss_allow_holes != real_packet->tech_loss_allow_holes);
4848   if (differ) {
4849     different++;
4850   }
4851   if (packet->tech_loss_allow_holes) {
4852     BV_SET(fields, 70);
4853   }
4854 
4855   differ = (strcmp(old->positive_year_label, real_packet->positive_year_label) != 0);
4856   if (differ) {
4857     different++;
4858     BV_SET(fields, 71);
4859   }
4860 
4861   differ = (old->rapturedelay != real_packet->rapturedelay);
4862   if (differ) {
4863     different++;
4864     BV_SET(fields, 72);
4865   }
4866 
4867   differ = (old->disasters != real_packet->disasters);
4868   if (differ) {
4869     different++;
4870     BV_SET(fields, 73);
4871   }
4872 
4873   differ = (old->restrictinfra != real_packet->restrictinfra);
4874   if (differ) {
4875     different++;
4876   }
4877   if (packet->restrictinfra) {
4878     BV_SET(fields, 74);
4879   }
4880 
4881   differ = (old->unreachable_protects != real_packet->unreachable_protects);
4882   if (differ) {
4883     different++;
4884   }
4885   if (packet->unreachable_protects) {
4886     BV_SET(fields, 75);
4887   }
4888 
4889   differ = (old->sciencebox != real_packet->sciencebox);
4890   if (differ) {
4891     different++;
4892     BV_SET(fields, 76);
4893   }
4894 
4895   differ = (old->shieldbox != real_packet->shieldbox);
4896   if (differ) {
4897     different++;
4898     BV_SET(fields, 77);
4899   }
4900 
4901   differ = (old->skill_level != real_packet->skill_level);
4902   if (differ) {
4903     different++;
4904     BV_SET(fields, 78);
4905   }
4906 
4907   differ = (old->slow_invasions != real_packet->slow_invasions);
4908   if (differ) {
4909     different++;
4910   }
4911   if (packet->slow_invasions) {
4912     BV_SET(fields, 79);
4913   }
4914 
4915   differ = (old->victory_conditions != real_packet->victory_conditions);
4916   if (differ) {
4917     different++;
4918     BV_SET(fields, 80);
4919   }
4920 
4921   differ = (old->team_pooled_research != real_packet->team_pooled_research);
4922   if (differ) {
4923     different++;
4924   }
4925   if (packet->team_pooled_research) {
4926     BV_SET(fields, 81);
4927   }
4928 
4929   differ = (old->tech != real_packet->tech);
4930   if (differ) {
4931     different++;
4932     BV_SET(fields, 82);
4933   }
4934 
4935   differ = (old->tech_cost_style != real_packet->tech_cost_style);
4936   if (differ) {
4937     different++;
4938     BV_SET(fields, 83);
4939   }
4940 
4941   differ = (old->tech_leakage != real_packet->tech_leakage);
4942   if (differ) {
4943     different++;
4944     BV_SET(fields, 84);
4945   }
4946 
4947   differ = (old->tech_upkeep_divider != real_packet->tech_upkeep_divider);
4948   if (differ) {
4949     different++;
4950     BV_SET(fields, 85);
4951   }
4952 
4953   differ = (old->tech_upkeep_style != real_packet->tech_upkeep_style);
4954   if (differ) {
4955     different++;
4956     BV_SET(fields, 86);
4957   }
4958 
4959   differ = (old->techloss_forgiveness != real_packet->techloss_forgiveness);
4960   if (differ) {
4961     different++;
4962     BV_SET(fields, 87);
4963   }
4964 
4965   differ = (old->free_tech_method != real_packet->free_tech_method);
4966   if (differ) {
4967     different++;
4968     BV_SET(fields, 88);
4969   }
4970 
4971   differ = (old->gameloss_style != real_packet->gameloss_style);
4972   if (differ) {
4973     different++;
4974     BV_SET(fields, 89);
4975   }
4976 
4977   differ = (old->timeout != real_packet->timeout);
4978   if (differ) {
4979     different++;
4980     BV_SET(fields, 90);
4981   }
4982 
4983   differ = (old->first_timeout != real_packet->first_timeout);
4984   if (differ) {
4985     different++;
4986     BV_SET(fields, 91);
4987   }
4988 
4989   differ = (old->tired_attack != real_packet->tired_attack);
4990   if (differ) {
4991     different++;
4992   }
4993   if (packet->tired_attack) {
4994     BV_SET(fields, 92);
4995   }
4996 
4997   differ = (old->trademindist != real_packet->trademindist);
4998   if (differ) {
4999     different++;
5000     BV_SET(fields, 93);
5001   }
5002 
5003   differ = (old->force_trade_route != real_packet->force_trade_route);
5004   if (differ) {
5005     different++;
5006   }
5007   if (packet->force_trade_route) {
5008     BV_SET(fields, 94);
5009   }
5010 
5011   differ = (old->trading_city != real_packet->trading_city);
5012   if (differ) {
5013     different++;
5014   }
5015   if (packet->trading_city) {
5016     BV_SET(fields, 95);
5017   }
5018 
5019   differ = (old->trading_gold != real_packet->trading_gold);
5020   if (differ) {
5021     different++;
5022   }
5023   if (packet->trading_gold) {
5024     BV_SET(fields, 96);
5025   }
5026 
5027   differ = (old->trading_tech != real_packet->trading_tech);
5028   if (differ) {
5029     different++;
5030   }
5031   if (packet->trading_tech) {
5032     BV_SET(fields, 97);
5033   }
5034 
5035   differ = (old->turn != real_packet->turn);
5036   if (differ) {
5037     different++;
5038     BV_SET(fields, 98);
5039   }
5040 
5041   differ = (old->warminglevel != real_packet->warminglevel);
5042   if (differ) {
5043     different++;
5044     BV_SET(fields, 99);
5045   }
5046 
5047   differ = (old->year16 != real_packet->year16);
5048   if (differ) {
5049     different++;
5050     BV_SET(fields, 100);
5051   }
5052 
5053   differ = (old->year_0_hack != real_packet->year_0_hack);
5054   if (differ) {
5055     different++;
5056   }
5057   if (packet->year_0_hack) {
5058     BV_SET(fields, 101);
5059   }
5060 
5061   differ = (old->calendar_fragments != real_packet->calendar_fragments);
5062   if (differ) {
5063     different++;
5064     BV_SET(fields, 102);
5065   }
5066 
5067   differ = (old->fragment_count != real_packet->fragment_count);
5068   if (differ) {
5069     different++;
5070     BV_SET(fields, 103);
5071   }
5072 
5073 
5074     {
5075       differ = (MAX_CALENDAR_FRAGMENTS != MAX_CALENDAR_FRAGMENTS);
5076       if (!differ) {
5077         int i;
5078 
5079         for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
5080           if (strcmp(old->calendar_fragment_name[i], real_packet->calendar_fragment_name[i]) != 0) {
5081             differ = TRUE;
5082             break;
5083           }
5084         }
5085       }
5086     }
5087   if (differ) {
5088     different++;
5089     BV_SET(fields, 104);
5090   }
5091 
5092   differ = (old->civil_war_enabled != real_packet->civil_war_enabled);
5093   if (differ) {
5094     different++;
5095   }
5096   if (packet->civil_war_enabled) {
5097     BV_SET(fields, 105);
5098   }
5099 
5100   differ = (old->paradrop_to_transport != real_packet->paradrop_to_transport);
5101   if (differ) {
5102     different++;
5103   }
5104   if (packet->paradrop_to_transport) {
5105     BV_SET(fields, 106);
5106   }
5107 
5108 
5109   if (different == 0) {
5110     log_packet_detailed("  no change -> discard");
5111     return 0;
5112   }
5113 
5114   DIO_BV_PUT(&dout, "fields", fields);
5115 
5116   if (BV_ISSET(fields, 0)) {
5117     log_packet_detailed("  field 'add_to_size_limit' has changed");
5118     DIO_PUT(uint8, &dout, "add_to_size_limit", real_packet->add_to_size_limit);
5119   }
5120   if (BV_ISSET(fields, 1)) {
5121     log_packet_detailed("  field 'aifill' has changed");
5122     DIO_PUT(uint8, &dout, "aifill", real_packet->aifill);
5123   }
5124   if (BV_ISSET(fields, 2)) {
5125     log_packet_detailed("  field 'persistent_ready' has changed");
5126     DIO_PUT(uint8, &dout, "persistent_ready", real_packet->persistent_ready);
5127   }
5128   if (BV_ISSET(fields, 3)) {
5129     log_packet_detailed("  field 'airlifting_style' has changed");
5130     DIO_PUT(uint8, &dout, "airlifting_style", real_packet->airlifting_style);
5131   }
5132   if (BV_ISSET(fields, 4)) {
5133     log_packet_detailed("  field 'angrycitizen' has changed");
5134     DIO_PUT(uint8, &dout, "angrycitizen", real_packet->angrycitizen);
5135   }
5136   if (BV_ISSET(fields, 5)) {
5137     log_packet_detailed("  field 'base_pollution' has changed");
5138     DIO_PUT(sint16, &dout, "base_pollution", real_packet->base_pollution);
5139   }
5140   if (BV_ISSET(fields, 6)) {
5141     log_packet_detailed("  field 'base_tech_cost' has changed");
5142     DIO_PUT(uint8, &dout, "base_tech_cost", real_packet->base_tech_cost);
5143   }
5144   if (BV_ISSET(fields, 7)) {
5145     log_packet_detailed("  field 'border_city_radius_sq' has changed");
5146     DIO_PUT(uint16, &dout, "border_city_radius_sq", real_packet->border_city_radius_sq);
5147   }
5148   if (BV_ISSET(fields, 8)) {
5149     log_packet_detailed("  field 'border_size_effect' has changed");
5150     DIO_PUT(uint8, &dout, "border_size_effect", real_packet->border_size_effect);
5151   }
5152   if (BV_ISSET(fields, 9)) {
5153     log_packet_detailed("  field 'border_city_permanent_radius_sq' has changed");
5154     DIO_PUT(sint16, &dout, "border_city_permanent_radius_sq", real_packet->border_city_permanent_radius_sq);
5155   }
5156   if (BV_ISSET(fields, 10)) {
5157     log_packet_detailed("  field 'borders' has changed");
5158     DIO_PUT(uint8, &dout, "borders", real_packet->borders);
5159   }
5160   if (BV_ISSET(fields, 11)) {
5161     log_packet_detailed("  field 'base_bribe_cost' has changed");
5162     DIO_PUT(uint32, &dout, "base_bribe_cost", real_packet->base_bribe_cost);
5163   }
5164   if (BV_ISSET(fields, 12)) {
5165     log_packet_detailed("  field 'culture_vic_points' has changed");
5166     DIO_PUT(uint32, &dout, "culture_vic_points", real_packet->culture_vic_points);
5167   }
5168   if (BV_ISSET(fields, 13)) {
5169     log_packet_detailed("  field 'culture_vic_lead' has changed");
5170     DIO_PUT(uint16, &dout, "culture_vic_lead", real_packet->culture_vic_lead);
5171   }
5172   if (BV_ISSET(fields, 14)) {
5173     log_packet_detailed("  field 'culture_migration_pml' has changed");
5174     DIO_PUT(uint16, &dout, "culture_migration_pml", real_packet->culture_migration_pml);
5175   }
5176   /* field 15 is folded into the header */
5177   if (BV_ISSET(fields, 16)) {
5178     log_packet_detailed("  field 'celebratesize' has changed");
5179     DIO_PUT(uint8, &dout, "celebratesize", real_packet->celebratesize);
5180   }
5181   /* field 17 is folded into the header */
5182   if (BV_ISSET(fields, 18)) {
5183     log_packet_detailed("  field 'pop_report_zeroes' has changed");
5184     DIO_PUT(uint8, &dout, "pop_report_zeroes", real_packet->pop_report_zeroes);
5185   }
5186   /* field 19 is folded into the header */
5187   if (BV_ISSET(fields, 20)) {
5188     log_packet_detailed("  field 'citizen_convert_speed' has changed");
5189     DIO_PUT(uint16, &dout, "citizen_convert_speed", real_packet->citizen_convert_speed);
5190   }
5191   if (BV_ISSET(fields, 21)) {
5192     log_packet_detailed("  field 'citizen_partisans_pct' has changed");
5193     DIO_PUT(uint8, &dout, "citizen_partisans_pct", real_packet->citizen_partisans_pct);
5194   }
5195   if (BV_ISSET(fields, 22)) {
5196     log_packet_detailed("  field 'citymindist' has changed");
5197     DIO_PUT(uint8, &dout, "citymindist", real_packet->citymindist);
5198   }
5199   if (BV_ISSET(fields, 23)) {
5200     log_packet_detailed("  field 'cooling' has changed");
5201     DIO_PUT(uint32, &dout, "cooling", real_packet->cooling);
5202   }
5203   if (BV_ISSET(fields, 24)) {
5204     log_packet_detailed("  field 'coolinglevel' has changed");
5205     DIO_PUT(uint32, &dout, "coolinglevel", real_packet->coolinglevel);
5206   }
5207   if (BV_ISSET(fields, 25)) {
5208     log_packet_detailed("  field 'diplomacy' has changed");
5209     DIO_PUT(uint8, &dout, "diplomacy", real_packet->diplomacy);
5210   }
5211   /* field 26 is folded into the header */
5212   if (BV_ISSET(fields, 27)) {
5213     log_packet_detailed("  field 'food_cost' has changed");
5214     DIO_PUT(uint8, &dout, "food_cost", real_packet->food_cost);
5215   }
5216   if (BV_ISSET(fields, 28)) {
5217     log_packet_detailed("  field 'foodbox' has changed");
5218     DIO_PUT(uint32, &dout, "foodbox", real_packet->foodbox);
5219   }
5220   if (BV_ISSET(fields, 29)) {
5221     log_packet_detailed("  field 'forced_gold' has changed");
5222     DIO_PUT(uint8, &dout, "forced_gold", real_packet->forced_gold);
5223   }
5224   if (BV_ISSET(fields, 30)) {
5225     log_packet_detailed("  field 'forced_luxury' has changed");
5226     DIO_PUT(uint8, &dout, "forced_luxury", real_packet->forced_luxury);
5227   }
5228   if (BV_ISSET(fields, 31)) {
5229     log_packet_detailed("  field 'forced_science' has changed");
5230     DIO_PUT(uint8, &dout, "forced_science", real_packet->forced_science);
5231   }
5232   if (BV_ISSET(fields, 32)) {
5233     log_packet_detailed("  field 'fulltradesize' has changed");
5234     DIO_PUT(uint8, &dout, "fulltradesize", real_packet->fulltradesize);
5235   }
5236   if (BV_ISSET(fields, 33)) {
5237     log_packet_detailed("  field 'global_advances' has changed");
5238 
5239     {
5240       int i;
5241 
5242       fc_assert(A_LAST < 255);
5243 
5244       for (i = 0; i < A_LAST; i++) {
5245         if (old->global_advances[i] != real_packet->global_advances[i]) {
5246           dio_put_uint8(&dout, i);
5247           dio_put_bool8(&dout, real_packet->global_advances[i]);
5248         }
5249       }
5250       dio_put_uint8(&dout, 255);
5251     }
5252   }
5253   /* field 34 is folded into the header */
5254   if (BV_ISSET(fields, 35)) {
5255     log_packet_detailed("  field 'globalwarming' has changed");
5256     DIO_PUT(uint32, &dout, "globalwarming", real_packet->globalwarming);
5257   }
5258   if (BV_ISSET(fields, 36)) {
5259     log_packet_detailed("  field 'gold' has changed");
5260     DIO_PUT(uint32, &dout, "gold", real_packet->gold);
5261   }
5262   if (BV_ISSET(fields, 37)) {
5263     log_packet_detailed("  field 'gold_upkeep_style' has changed");
5264     DIO_PUT(uint8, &dout, "gold_upkeep_style", real_packet->gold_upkeep_style);
5265   }
5266   if (BV_ISSET(fields, 38)) {
5267     log_packet_detailed("  field 'revolentype' has changed");
5268     DIO_PUT(uint8, &dout, "revolentype", real_packet->revolentype);
5269   }
5270   if (BV_ISSET(fields, 39)) {
5271     log_packet_detailed("  field 'default_government_id' has changed");
5272     DIO_PUT(sint8, &dout, "default_government_id", real_packet->default_government_id);
5273   }
5274   if (BV_ISSET(fields, 40)) {
5275     log_packet_detailed("  field 'government_during_revolution_id' has changed");
5276     DIO_PUT(sint8, &dout, "government_during_revolution_id", real_packet->government_during_revolution_id);
5277   }
5278   if (BV_ISSET(fields, 41)) {
5279     log_packet_detailed("  field 'granary_food_inc' has changed");
5280     DIO_PUT(uint8, &dout, "granary_food_inc", real_packet->granary_food_inc);
5281   }
5282   if (BV_ISSET(fields, 42)) {
5283     log_packet_detailed("  field 'granary_food_ini' has changed");
5284 
5285     {
5286       int i;
5287 
5288       for (i = 0; i < MAX_GRANARY_INIS; i++) {
5289         dio_put_uint8(&dout, real_packet->granary_food_ini[i]);
5290       }
5291     }
5292   }
5293   if (BV_ISSET(fields, 43)) {
5294     log_packet_detailed("  field 'granary_num_inis' has changed");
5295     DIO_PUT(uint8, &dout, "granary_num_inis", real_packet->granary_num_inis);
5296   }
5297   if (BV_ISSET(fields, 44)) {
5298     log_packet_detailed("  field 'great_wonder_owners' has changed");
5299 
5300     {
5301       int i;
5302 
5303       fc_assert(B_LAST < 255);
5304 
5305       for (i = 0; i < B_LAST; i++) {
5306         if (old->great_wonder_owners[i] != real_packet->great_wonder_owners[i]) {
5307           dio_put_uint8(&dout, i);
5308           dio_put_uint8(&dout, real_packet->great_wonder_owners[i]);
5309         }
5310       }
5311       dio_put_uint8(&dout, 255);
5312     }
5313   }
5314   if (BV_ISSET(fields, 45)) {
5315     log_packet_detailed("  field 'happy_cost' has changed");
5316     DIO_PUT(uint8, &dout, "happy_cost", real_packet->happy_cost);
5317   }
5318   if (BV_ISSET(fields, 46)) {
5319     log_packet_detailed("  field 'happyborders' has changed");
5320     DIO_PUT(uint8, &dout, "happyborders", real_packet->happyborders);
5321   }
5322   if (BV_ISSET(fields, 47)) {
5323     log_packet_detailed("  field 'heating' has changed");
5324     DIO_PUT(uint32, &dout, "heating", real_packet->heating);
5325   }
5326   if (BV_ISSET(fields, 48)) {
5327     log_packet_detailed("  field 'illness_base_factor' has changed");
5328     DIO_PUT(uint16, &dout, "illness_base_factor", real_packet->illness_base_factor);
5329   }
5330   if (BV_ISSET(fields, 49)) {
5331     log_packet_detailed("  field 'illness_min_size' has changed");
5332     DIO_PUT(uint8, &dout, "illness_min_size", real_packet->illness_min_size);
5333   }
5334   /* field 50 is folded into the header */
5335   if (BV_ISSET(fields, 51)) {
5336     log_packet_detailed("  field 'illness_pollution_factor' has changed");
5337     DIO_PUT(uint16, &dout, "illness_pollution_factor", real_packet->illness_pollution_factor);
5338   }
5339   if (BV_ISSET(fields, 52)) {
5340     log_packet_detailed("  field 'illness_trade_infection' has changed");
5341     DIO_PUT(uint16, &dout, "illness_trade_infection", real_packet->illness_trade_infection);
5342   }
5343   if (BV_ISSET(fields, 53)) {
5344     log_packet_detailed("  field 'init_city_radius_sq' has changed");
5345     DIO_PUT(uint8, &dout, "init_city_radius_sq", real_packet->init_city_radius_sq);
5346   }
5347   /* field 54 is folded into the header */
5348   /* field 55 is folded into the header */
5349   /* field 56 is folded into the header */
5350   /* field 57 is folded into the header */
5351   if (BV_ISSET(fields, 58)) {
5352     log_packet_detailed("  field 'min_city_center_output' has changed");
5353 
5354     {
5355       int i;
5356 
5357       for (i = 0; i < O_LAST; i++) {
5358         dio_put_uint8(&dout, real_packet->min_city_center_output[i]);
5359       }
5360     }
5361   }
5362   if (BV_ISSET(fields, 59)) {
5363     log_packet_detailed("  field 'negative_year_label' has changed");
5364     DIO_PUT(string, &dout, "negative_year_label", real_packet->negative_year_label);
5365   }
5366   if (BV_ISSET(fields, 60)) {
5367     log_packet_detailed("  field 'notradesize' has changed");
5368     DIO_PUT(uint8, &dout, "notradesize", real_packet->notradesize);
5369   }
5370   /* field 61 is folded into the header */
5371   if (BV_ISSET(fields, 62)) {
5372     log_packet_detailed("  field 'nuclearwinter' has changed");
5373     DIO_PUT(uint32, &dout, "nuclearwinter", real_packet->nuclearwinter);
5374   }
5375   if (BV_ISSET(fields, 63)) {
5376     log_packet_detailed("  field 'phase' has changed");
5377     DIO_PUT(sint16, &dout, "phase", real_packet->phase);
5378   }
5379   if (BV_ISSET(fields, 64)) {
5380     log_packet_detailed("  field 'phase_mode' has changed");
5381     DIO_PUT(uint8, &dout, "phase_mode", real_packet->phase_mode);
5382   }
5383   /* field 65 is folded into the header */
5384   /* field 66 is folded into the header */
5385   /* field 67 is folded into the header */
5386   /* field 68 is folded into the header */
5387   /* field 69 is folded into the header */
5388   /* field 70 is folded into the header */
5389   if (BV_ISSET(fields, 71)) {
5390     log_packet_detailed("  field 'positive_year_label' has changed");
5391     DIO_PUT(string, &dout, "positive_year_label", real_packet->positive_year_label);
5392   }
5393   if (BV_ISSET(fields, 72)) {
5394     log_packet_detailed("  field 'rapturedelay' has changed");
5395     DIO_PUT(uint8, &dout, "rapturedelay", real_packet->rapturedelay);
5396   }
5397   if (BV_ISSET(fields, 73)) {
5398     log_packet_detailed("  field 'disasters' has changed");
5399     DIO_PUT(uint16, &dout, "disasters", real_packet->disasters);
5400   }
5401   /* field 74 is folded into the header */
5402   /* field 75 is folded into the header */
5403   if (BV_ISSET(fields, 76)) {
5404     log_packet_detailed("  field 'sciencebox' has changed");
5405     DIO_PUT(uint32, &dout, "sciencebox", real_packet->sciencebox);
5406   }
5407   if (BV_ISSET(fields, 77)) {
5408     log_packet_detailed("  field 'shieldbox' has changed");
5409     DIO_PUT(uint32, &dout, "shieldbox", real_packet->shieldbox);
5410   }
5411   if (BV_ISSET(fields, 78)) {
5412     log_packet_detailed("  field 'skill_level' has changed");
5413     DIO_PUT(uint32, &dout, "skill_level", real_packet->skill_level);
5414   }
5415   /* field 79 is folded into the header */
5416   if (BV_ISSET(fields, 80)) {
5417     log_packet_detailed("  field 'victory_conditions' has changed");
5418     DIO_PUT(uint8, &dout, "victory_conditions", real_packet->victory_conditions);
5419   }
5420   /* field 81 is folded into the header */
5421   if (BV_ISSET(fields, 82)) {
5422     log_packet_detailed("  field 'tech' has changed");
5423     DIO_PUT(uint32, &dout, "tech", real_packet->tech);
5424   }
5425   if (BV_ISSET(fields, 83)) {
5426     log_packet_detailed("  field 'tech_cost_style' has changed");
5427     DIO_PUT(uint8, &dout, "tech_cost_style", real_packet->tech_cost_style);
5428   }
5429   if (BV_ISSET(fields, 84)) {
5430     log_packet_detailed("  field 'tech_leakage' has changed");
5431     DIO_PUT(uint8, &dout, "tech_leakage", real_packet->tech_leakage);
5432   }
5433   if (BV_ISSET(fields, 85)) {
5434     log_packet_detailed("  field 'tech_upkeep_divider' has changed");
5435     DIO_PUT(uint16, &dout, "tech_upkeep_divider", real_packet->tech_upkeep_divider);
5436   }
5437   if (BV_ISSET(fields, 86)) {
5438     log_packet_detailed("  field 'tech_upkeep_style' has changed");
5439     DIO_PUT(uint8, &dout, "tech_upkeep_style", real_packet->tech_upkeep_style);
5440   }
5441   if (BV_ISSET(fields, 87)) {
5442     log_packet_detailed("  field 'techloss_forgiveness' has changed");
5443     DIO_PUT(sint16, &dout, "techloss_forgiveness", real_packet->techloss_forgiveness);
5444   }
5445   if (BV_ISSET(fields, 88)) {
5446     log_packet_detailed("  field 'free_tech_method' has changed");
5447     DIO_PUT(uint8, &dout, "free_tech_method", real_packet->free_tech_method);
5448   }
5449   if (BV_ISSET(fields, 89)) {
5450     log_packet_detailed("  field 'gameloss_style' has changed");
5451     DIO_PUT(uint8, &dout, "gameloss_style", real_packet->gameloss_style);
5452   }
5453   if (BV_ISSET(fields, 90)) {
5454     log_packet_detailed("  field 'timeout' has changed");
5455     DIO_PUT(uint32, &dout, "timeout", real_packet->timeout);
5456   }
5457   if (BV_ISSET(fields, 91)) {
5458     log_packet_detailed("  field 'first_timeout' has changed");
5459     DIO_PUT(uint32, &dout, "first_timeout", real_packet->first_timeout);
5460   }
5461   /* field 92 is folded into the header */
5462   if (BV_ISSET(fields, 93)) {
5463     log_packet_detailed("  field 'trademindist' has changed");
5464     DIO_PUT(uint16, &dout, "trademindist", real_packet->trademindist);
5465   }
5466   /* field 94 is folded into the header */
5467   /* field 95 is folded into the header */
5468   /* field 96 is folded into the header */
5469   /* field 97 is folded into the header */
5470   if (BV_ISSET(fields, 98)) {
5471     log_packet_detailed("  field 'turn' has changed");
5472     DIO_PUT(sint16, &dout, "turn", real_packet->turn);
5473   }
5474   if (BV_ISSET(fields, 99)) {
5475     log_packet_detailed("  field 'warminglevel' has changed");
5476     DIO_PUT(uint32, &dout, "warminglevel", real_packet->warminglevel);
5477   }
5478   if (BV_ISSET(fields, 100)) {
5479     log_packet_detailed("  field 'year16' has changed");
5480     DIO_PUT(sint16, &dout, "year16", real_packet->year16);
5481   }
5482   /* field 101 is folded into the header */
5483   if (BV_ISSET(fields, 102)) {
5484     log_packet_detailed("  field 'calendar_fragments' has changed");
5485     DIO_PUT(uint16, &dout, "calendar_fragments", real_packet->calendar_fragments);
5486   }
5487   if (BV_ISSET(fields, 103)) {
5488     log_packet_detailed("  field 'fragment_count' has changed");
5489     DIO_PUT(uint16, &dout, "fragment_count", real_packet->fragment_count);
5490   }
5491   if (BV_ISSET(fields, 104)) {
5492     log_packet_detailed("  field 'calendar_fragment_name' has changed");
5493 
5494     {
5495       int i;
5496 
5497       for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
5498         dio_put_string(&dout, real_packet->calendar_fragment_name[i]);
5499       }
5500     }
5501   }
5502   /* field 105 is folded into the header */
5503   /* field 106 is folded into the header */
5504 
5505   *old = *real_packet;
5506   SEND_PACKET_END(PACKET_GAME_INFO);
5507 }
5508 
5509 #define hash_packet_game_info_102 hash_const
5510 
5511 #define cmp_packet_game_info_102 cmp_const
5512 
5513 BV_DEFINE(packet_game_info_102_fields, 107);
5514 
receive_packet_game_info_102(struct connection * pc)5515 static struct packet_game_info *receive_packet_game_info_102(struct connection *pc)
5516 {
5517   packet_game_info_102_fields fields;
5518   struct packet_game_info *old;
5519   struct genhash **hash = pc->phs.received + PACKET_GAME_INFO;
5520   RECEIVE_PACKET_START(packet_game_info, real_packet);
5521 
5522   DIO_BV_GET(&din, fields);
5523 
5524   log_packet_detailed("packet_game_info_102: got info about ()");
5525 
5526   if (NULL == *hash) {
5527     *hash = genhash_new_full(hash_packet_game_info_102, cmp_packet_game_info_102,
5528                              NULL, NULL, NULL, free);
5529   }
5530 
5531   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
5532     *real_packet = *old;
5533   } else {
5534     log_packet_detailed("  no old info");
5535     memset(real_packet, 0, sizeof(*real_packet));
5536   }
5537 
5538   if (BV_ISSET(fields, 0)) {
5539     log_packet_detailed("  got field 'add_to_size_limit'");
5540     if (!DIO_GET(uint8, &din, "add_to_size_limit", &real_packet->add_to_size_limit)) {
5541       RECEIVE_PACKET_FIELD_ERROR(add_to_size_limit);
5542     }
5543   }
5544   if (BV_ISSET(fields, 1)) {
5545     log_packet_detailed("  got field 'aifill'");
5546     if (!DIO_GET(uint8, &din, "aifill", &real_packet->aifill)) {
5547       RECEIVE_PACKET_FIELD_ERROR(aifill);
5548     }
5549   }
5550   if (BV_ISSET(fields, 2)) {
5551     log_packet_detailed("  got field 'persistent_ready'");
5552     {
5553       int readin;
5554 
5555       if (!DIO_GET(uint8, &din, "persistent_ready", &readin)) {
5556         RECEIVE_PACKET_FIELD_ERROR(persistent_ready);
5557       }
5558       real_packet->persistent_ready = readin;
5559     }
5560   }
5561   if (BV_ISSET(fields, 3)) {
5562     log_packet_detailed("  got field 'airlifting_style'");
5563     {
5564       int readin;
5565 
5566       if (!DIO_GET(uint8, &din, "airlifting_style", &readin)) {
5567         RECEIVE_PACKET_FIELD_ERROR(airlifting_style);
5568       }
5569       real_packet->airlifting_style = readin;
5570     }
5571   }
5572   if (BV_ISSET(fields, 4)) {
5573     log_packet_detailed("  got field 'angrycitizen'");
5574     if (!DIO_GET(uint8, &din, "angrycitizen", &real_packet->angrycitizen)) {
5575       RECEIVE_PACKET_FIELD_ERROR(angrycitizen);
5576     }
5577   }
5578   if (BV_ISSET(fields, 5)) {
5579     log_packet_detailed("  got field 'base_pollution'");
5580     if (!DIO_GET(sint16, &din, "base_pollution", &real_packet->base_pollution)) {
5581       RECEIVE_PACKET_FIELD_ERROR(base_pollution);
5582     }
5583   }
5584   if (BV_ISSET(fields, 6)) {
5585     log_packet_detailed("  got field 'base_tech_cost'");
5586     if (!DIO_GET(uint8, &din, "base_tech_cost", &real_packet->base_tech_cost)) {
5587       RECEIVE_PACKET_FIELD_ERROR(base_tech_cost);
5588     }
5589   }
5590   if (BV_ISSET(fields, 7)) {
5591     log_packet_detailed("  got field 'border_city_radius_sq'");
5592     if (!DIO_GET(uint16, &din, "border_city_radius_sq", &real_packet->border_city_radius_sq)) {
5593       RECEIVE_PACKET_FIELD_ERROR(border_city_radius_sq);
5594     }
5595   }
5596   if (BV_ISSET(fields, 8)) {
5597     log_packet_detailed("  got field 'border_size_effect'");
5598     if (!DIO_GET(uint8, &din, "border_size_effect", &real_packet->border_size_effect)) {
5599       RECEIVE_PACKET_FIELD_ERROR(border_size_effect);
5600     }
5601   }
5602   if (BV_ISSET(fields, 9)) {
5603     log_packet_detailed("  got field 'border_city_permanent_radius_sq'");
5604     if (!DIO_GET(sint16, &din, "border_city_permanent_radius_sq", &real_packet->border_city_permanent_radius_sq)) {
5605       RECEIVE_PACKET_FIELD_ERROR(border_city_permanent_radius_sq);
5606     }
5607   }
5608   if (BV_ISSET(fields, 10)) {
5609     log_packet_detailed("  got field 'borders'");
5610     {
5611       int readin;
5612 
5613       if (!DIO_GET(uint8, &din, "borders", &readin)) {
5614         RECEIVE_PACKET_FIELD_ERROR(borders);
5615       }
5616       real_packet->borders = readin;
5617     }
5618   }
5619   if (BV_ISSET(fields, 11)) {
5620     log_packet_detailed("  got field 'base_bribe_cost'");
5621     if (!DIO_GET(uint32, &din, "base_bribe_cost", &real_packet->base_bribe_cost)) {
5622       RECEIVE_PACKET_FIELD_ERROR(base_bribe_cost);
5623     }
5624   }
5625   if (BV_ISSET(fields, 12)) {
5626     log_packet_detailed("  got field 'culture_vic_points'");
5627     if (!DIO_GET(uint32, &din, "culture_vic_points", &real_packet->culture_vic_points)) {
5628       RECEIVE_PACKET_FIELD_ERROR(culture_vic_points);
5629     }
5630   }
5631   if (BV_ISSET(fields, 13)) {
5632     log_packet_detailed("  got field 'culture_vic_lead'");
5633     if (!DIO_GET(uint16, &din, "culture_vic_lead", &real_packet->culture_vic_lead)) {
5634       RECEIVE_PACKET_FIELD_ERROR(culture_vic_lead);
5635     }
5636   }
5637   if (BV_ISSET(fields, 14)) {
5638     log_packet_detailed("  got field 'culture_migration_pml'");
5639     if (!DIO_GET(uint16, &din, "culture_migration_pml", &real_packet->culture_migration_pml)) {
5640       RECEIVE_PACKET_FIELD_ERROR(culture_migration_pml);
5641     }
5642   }
5643   real_packet->calendar_skip_0 = BV_ISSET(fields, 15);
5644   if (BV_ISSET(fields, 16)) {
5645     log_packet_detailed("  got field 'celebratesize'");
5646     if (!DIO_GET(uint8, &din, "celebratesize", &real_packet->celebratesize)) {
5647       RECEIVE_PACKET_FIELD_ERROR(celebratesize);
5648     }
5649   }
5650   real_packet->changable_tax = BV_ISSET(fields, 17);
5651   if (BV_ISSET(fields, 18)) {
5652     log_packet_detailed("  got field 'pop_report_zeroes'");
5653     if (!DIO_GET(uint8, &din, "pop_report_zeroes", &real_packet->pop_report_zeroes)) {
5654       RECEIVE_PACKET_FIELD_ERROR(pop_report_zeroes);
5655     }
5656   }
5657   real_packet->citizen_nationality = BV_ISSET(fields, 19);
5658   if (BV_ISSET(fields, 20)) {
5659     log_packet_detailed("  got field 'citizen_convert_speed'");
5660     if (!DIO_GET(uint16, &din, "citizen_convert_speed", &real_packet->citizen_convert_speed)) {
5661       RECEIVE_PACKET_FIELD_ERROR(citizen_convert_speed);
5662     }
5663   }
5664   if (BV_ISSET(fields, 21)) {
5665     log_packet_detailed("  got field 'citizen_partisans_pct'");
5666     if (!DIO_GET(uint8, &din, "citizen_partisans_pct", &real_packet->citizen_partisans_pct)) {
5667       RECEIVE_PACKET_FIELD_ERROR(citizen_partisans_pct);
5668     }
5669   }
5670   if (BV_ISSET(fields, 22)) {
5671     log_packet_detailed("  got field 'citymindist'");
5672     if (!DIO_GET(uint8, &din, "citymindist", &real_packet->citymindist)) {
5673       RECEIVE_PACKET_FIELD_ERROR(citymindist);
5674     }
5675   }
5676   if (BV_ISSET(fields, 23)) {
5677     log_packet_detailed("  got field 'cooling'");
5678     if (!DIO_GET(uint32, &din, "cooling", &real_packet->cooling)) {
5679       RECEIVE_PACKET_FIELD_ERROR(cooling);
5680     }
5681   }
5682   if (BV_ISSET(fields, 24)) {
5683     log_packet_detailed("  got field 'coolinglevel'");
5684     if (!DIO_GET(uint32, &din, "coolinglevel", &real_packet->coolinglevel)) {
5685       RECEIVE_PACKET_FIELD_ERROR(coolinglevel);
5686     }
5687   }
5688   if (BV_ISSET(fields, 25)) {
5689     log_packet_detailed("  got field 'diplomacy'");
5690     {
5691       int readin;
5692 
5693       if (!DIO_GET(uint8, &din, "diplomacy", &readin)) {
5694         RECEIVE_PACKET_FIELD_ERROR(diplomacy);
5695       }
5696       real_packet->diplomacy = readin;
5697     }
5698   }
5699   real_packet->fogofwar = BV_ISSET(fields, 26);
5700   if (BV_ISSET(fields, 27)) {
5701     log_packet_detailed("  got field 'food_cost'");
5702     if (!DIO_GET(uint8, &din, "food_cost", &real_packet->food_cost)) {
5703       RECEIVE_PACKET_FIELD_ERROR(food_cost);
5704     }
5705   }
5706   if (BV_ISSET(fields, 28)) {
5707     log_packet_detailed("  got field 'foodbox'");
5708     if (!DIO_GET(uint32, &din, "foodbox", &real_packet->foodbox)) {
5709       RECEIVE_PACKET_FIELD_ERROR(foodbox);
5710     }
5711   }
5712   if (BV_ISSET(fields, 29)) {
5713     log_packet_detailed("  got field 'forced_gold'");
5714     if (!DIO_GET(uint8, &din, "forced_gold", &real_packet->forced_gold)) {
5715       RECEIVE_PACKET_FIELD_ERROR(forced_gold);
5716     }
5717   }
5718   if (BV_ISSET(fields, 30)) {
5719     log_packet_detailed("  got field 'forced_luxury'");
5720     if (!DIO_GET(uint8, &din, "forced_luxury", &real_packet->forced_luxury)) {
5721       RECEIVE_PACKET_FIELD_ERROR(forced_luxury);
5722     }
5723   }
5724   if (BV_ISSET(fields, 31)) {
5725     log_packet_detailed("  got field 'forced_science'");
5726     if (!DIO_GET(uint8, &din, "forced_science", &real_packet->forced_science)) {
5727       RECEIVE_PACKET_FIELD_ERROR(forced_science);
5728     }
5729   }
5730   if (BV_ISSET(fields, 32)) {
5731     log_packet_detailed("  got field 'fulltradesize'");
5732     if (!DIO_GET(uint8, &din, "fulltradesize", &real_packet->fulltradesize)) {
5733       RECEIVE_PACKET_FIELD_ERROR(fulltradesize);
5734     }
5735   }
5736   if (BV_ISSET(fields, 33)) {
5737     log_packet_detailed("  got field 'global_advances'");
5738 
5739     for (;;) {
5740       int i;
5741 
5742       if (!DIO_GET(uint8, &din, "global_advances", &i)) {
5743         RECEIVE_PACKET_FIELD_ERROR(global_advances);
5744       }
5745       if (i == 255) {
5746         break;
5747       }
5748       if (i > A_LAST) {
5749         RECEIVE_PACKET_FIELD_ERROR(global_advances,
5750                                    ": unexpected value %d "
5751                                    "(> A_LAST) in array diff",
5752                                    i);
5753       } else {
5754         if (!DIO_GET(bool8, &din, "global_advances", &real_packet->global_advances[i])) {
5755           RECEIVE_PACKET_FIELD_ERROR(global_advances);
5756         }
5757       }
5758     }
5759   }
5760   real_packet->global_warming = BV_ISSET(fields, 34);
5761   if (BV_ISSET(fields, 35)) {
5762     log_packet_detailed("  got field 'globalwarming'");
5763     if (!DIO_GET(uint32, &din, "globalwarming", &real_packet->globalwarming)) {
5764       RECEIVE_PACKET_FIELD_ERROR(globalwarming);
5765     }
5766   }
5767   if (BV_ISSET(fields, 36)) {
5768     log_packet_detailed("  got field 'gold'");
5769     if (!DIO_GET(uint32, &din, "gold", &real_packet->gold)) {
5770       RECEIVE_PACKET_FIELD_ERROR(gold);
5771     }
5772   }
5773   if (BV_ISSET(fields, 37)) {
5774     log_packet_detailed("  got field 'gold_upkeep_style'");
5775     {
5776       int readin;
5777 
5778       if (!DIO_GET(uint8, &din, "gold_upkeep_style", &readin)) {
5779         RECEIVE_PACKET_FIELD_ERROR(gold_upkeep_style);
5780       }
5781       real_packet->gold_upkeep_style = readin;
5782     }
5783   }
5784   if (BV_ISSET(fields, 38)) {
5785     log_packet_detailed("  got field 'revolentype'");
5786     {
5787       int readin;
5788 
5789       if (!DIO_GET(uint8, &din, "revolentype", &readin)) {
5790         RECEIVE_PACKET_FIELD_ERROR(revolentype);
5791       }
5792       real_packet->revolentype = readin;
5793     }
5794   }
5795   if (BV_ISSET(fields, 39)) {
5796     log_packet_detailed("  got field 'default_government_id'");
5797     {
5798       int readin;
5799 
5800       if (!DIO_GET(sint8, &din, "default_government_id", &readin)) {
5801         RECEIVE_PACKET_FIELD_ERROR(default_government_id);
5802       }
5803       real_packet->default_government_id = readin;
5804     }
5805   }
5806   if (BV_ISSET(fields, 40)) {
5807     log_packet_detailed("  got field 'government_during_revolution_id'");
5808     {
5809       int readin;
5810 
5811       if (!DIO_GET(sint8, &din, "government_during_revolution_id", &readin)) {
5812         RECEIVE_PACKET_FIELD_ERROR(government_during_revolution_id);
5813       }
5814       real_packet->government_during_revolution_id = readin;
5815     }
5816   }
5817   if (BV_ISSET(fields, 41)) {
5818     log_packet_detailed("  got field 'granary_food_inc'");
5819     if (!DIO_GET(uint8, &din, "granary_food_inc", &real_packet->granary_food_inc)) {
5820       RECEIVE_PACKET_FIELD_ERROR(granary_food_inc);
5821     }
5822   }
5823   if (BV_ISSET(fields, 42)) {
5824     log_packet_detailed("  got field 'granary_food_ini'");
5825 
5826     {
5827       int i;
5828 
5829       for (i = 0; i < MAX_GRANARY_INIS; i++) {
5830         if (!DIO_GET(uint8, &din, "granary_food_ini", &real_packet->granary_food_ini[i])) {
5831           RECEIVE_PACKET_FIELD_ERROR(granary_food_ini);
5832         }
5833       }
5834     }
5835   }
5836   if (BV_ISSET(fields, 43)) {
5837     log_packet_detailed("  got field 'granary_num_inis'");
5838     if (!DIO_GET(uint8, &din, "granary_num_inis", &real_packet->granary_num_inis)) {
5839       RECEIVE_PACKET_FIELD_ERROR(granary_num_inis);
5840     }
5841   }
5842   if (BV_ISSET(fields, 44)) {
5843     log_packet_detailed("  got field 'great_wonder_owners'");
5844 
5845     for (;;) {
5846       int i;
5847 
5848       if (!DIO_GET(uint8, &din, "great_wonder_owners", &i)) {
5849         RECEIVE_PACKET_FIELD_ERROR(great_wonder_owners);
5850       }
5851       if (i == 255) {
5852         break;
5853       }
5854       if (i > B_LAST) {
5855         RECEIVE_PACKET_FIELD_ERROR(great_wonder_owners,
5856                                    ": unexpected value %d "
5857                                    "(> B_LAST) in array diff",
5858                                    i);
5859       } else {
5860         if (!DIO_GET(uint8, &din, "great_wonder_owners", &real_packet->great_wonder_owners[i])) {
5861           RECEIVE_PACKET_FIELD_ERROR(great_wonder_owners);
5862         }
5863       }
5864     }
5865   }
5866   if (BV_ISSET(fields, 45)) {
5867     log_packet_detailed("  got field 'happy_cost'");
5868     if (!DIO_GET(uint8, &din, "happy_cost", &real_packet->happy_cost)) {
5869       RECEIVE_PACKET_FIELD_ERROR(happy_cost);
5870     }
5871   }
5872   if (BV_ISSET(fields, 46)) {
5873     log_packet_detailed("  got field 'happyborders'");
5874     {
5875       int readin;
5876 
5877       if (!DIO_GET(uint8, &din, "happyborders", &readin)) {
5878         RECEIVE_PACKET_FIELD_ERROR(happyborders);
5879       }
5880       real_packet->happyborders = readin;
5881     }
5882   }
5883   if (BV_ISSET(fields, 47)) {
5884     log_packet_detailed("  got field 'heating'");
5885     if (!DIO_GET(uint32, &din, "heating", &real_packet->heating)) {
5886       RECEIVE_PACKET_FIELD_ERROR(heating);
5887     }
5888   }
5889   if (BV_ISSET(fields, 48)) {
5890     log_packet_detailed("  got field 'illness_base_factor'");
5891     if (!DIO_GET(uint16, &din, "illness_base_factor", &real_packet->illness_base_factor)) {
5892       RECEIVE_PACKET_FIELD_ERROR(illness_base_factor);
5893     }
5894   }
5895   if (BV_ISSET(fields, 49)) {
5896     log_packet_detailed("  got field 'illness_min_size'");
5897     if (!DIO_GET(uint8, &din, "illness_min_size", &real_packet->illness_min_size)) {
5898       RECEIVE_PACKET_FIELD_ERROR(illness_min_size);
5899     }
5900   }
5901   real_packet->illness_on = BV_ISSET(fields, 50);
5902   if (BV_ISSET(fields, 51)) {
5903     log_packet_detailed("  got field 'illness_pollution_factor'");
5904     if (!DIO_GET(uint16, &din, "illness_pollution_factor", &real_packet->illness_pollution_factor)) {
5905       RECEIVE_PACKET_FIELD_ERROR(illness_pollution_factor);
5906     }
5907   }
5908   if (BV_ISSET(fields, 52)) {
5909     log_packet_detailed("  got field 'illness_trade_infection'");
5910     if (!DIO_GET(uint16, &din, "illness_trade_infection", &real_packet->illness_trade_infection)) {
5911       RECEIVE_PACKET_FIELD_ERROR(illness_trade_infection);
5912     }
5913   }
5914   if (BV_ISSET(fields, 53)) {
5915     log_packet_detailed("  got field 'init_city_radius_sq'");
5916     if (!DIO_GET(uint8, &din, "init_city_radius_sq", &real_packet->init_city_radius_sq)) {
5917       RECEIVE_PACKET_FIELD_ERROR(init_city_radius_sq);
5918     }
5919   }
5920   real_packet->is_edit_mode = BV_ISSET(fields, 54);
5921   real_packet->is_new_game = BV_ISSET(fields, 55);
5922   real_packet->killcitizen = BV_ISSET(fields, 56);
5923   real_packet->killstack = BV_ISSET(fields, 57);
5924   if (BV_ISSET(fields, 58)) {
5925     log_packet_detailed("  got field 'min_city_center_output'");
5926 
5927     {
5928       int i;
5929 
5930       for (i = 0; i < O_LAST; i++) {
5931         if (!DIO_GET(uint8, &din, "min_city_center_output", &real_packet->min_city_center_output[i])) {
5932           RECEIVE_PACKET_FIELD_ERROR(min_city_center_output);
5933         }
5934       }
5935     }
5936   }
5937   if (BV_ISSET(fields, 59)) {
5938     log_packet_detailed("  got field 'negative_year_label'");
5939     if (!DIO_GET(string, &din, "negative_year_label", real_packet->negative_year_label, sizeof(real_packet->negative_year_label))) {
5940       RECEIVE_PACKET_FIELD_ERROR(negative_year_label);
5941     }
5942   }
5943   if (BV_ISSET(fields, 60)) {
5944     log_packet_detailed("  got field 'notradesize'");
5945     if (!DIO_GET(uint8, &din, "notradesize", &real_packet->notradesize)) {
5946       RECEIVE_PACKET_FIELD_ERROR(notradesize);
5947     }
5948   }
5949   real_packet->nuclear_winter = BV_ISSET(fields, 61);
5950   if (BV_ISSET(fields, 62)) {
5951     log_packet_detailed("  got field 'nuclearwinter'");
5952     if (!DIO_GET(uint32, &din, "nuclearwinter", &real_packet->nuclearwinter)) {
5953       RECEIVE_PACKET_FIELD_ERROR(nuclearwinter);
5954     }
5955   }
5956   if (BV_ISSET(fields, 63)) {
5957     log_packet_detailed("  got field 'phase'");
5958     if (!DIO_GET(sint16, &din, "phase", &real_packet->phase)) {
5959       RECEIVE_PACKET_FIELD_ERROR(phase);
5960     }
5961   }
5962   if (BV_ISSET(fields, 64)) {
5963     log_packet_detailed("  got field 'phase_mode'");
5964     {
5965       int readin;
5966 
5967       if (!DIO_GET(uint8, &din, "phase_mode", &readin)) {
5968         RECEIVE_PACKET_FIELD_ERROR(phase_mode);
5969       }
5970       real_packet->phase_mode = readin;
5971     }
5972   }
5973   real_packet->pillage_select = BV_ISSET(fields, 65);
5974   real_packet->tech_steal_allow_holes = BV_ISSET(fields, 66);
5975   real_packet->tech_trade_allow_holes = BV_ISSET(fields, 67);
5976   real_packet->tech_trade_loss_allow_holes = BV_ISSET(fields, 68);
5977   real_packet->tech_parasite_allow_holes = BV_ISSET(fields, 69);
5978   real_packet->tech_loss_allow_holes = BV_ISSET(fields, 70);
5979   if (BV_ISSET(fields, 71)) {
5980     log_packet_detailed("  got field 'positive_year_label'");
5981     if (!DIO_GET(string, &din, "positive_year_label", real_packet->positive_year_label, sizeof(real_packet->positive_year_label))) {
5982       RECEIVE_PACKET_FIELD_ERROR(positive_year_label);
5983     }
5984   }
5985   if (BV_ISSET(fields, 72)) {
5986     log_packet_detailed("  got field 'rapturedelay'");
5987     if (!DIO_GET(uint8, &din, "rapturedelay", &real_packet->rapturedelay)) {
5988       RECEIVE_PACKET_FIELD_ERROR(rapturedelay);
5989     }
5990   }
5991   if (BV_ISSET(fields, 73)) {
5992     log_packet_detailed("  got field 'disasters'");
5993     if (!DIO_GET(uint16, &din, "disasters", &real_packet->disasters)) {
5994       RECEIVE_PACKET_FIELD_ERROR(disasters);
5995     }
5996   }
5997   real_packet->restrictinfra = BV_ISSET(fields, 74);
5998   real_packet->unreachable_protects = BV_ISSET(fields, 75);
5999   if (BV_ISSET(fields, 76)) {
6000     log_packet_detailed("  got field 'sciencebox'");
6001     if (!DIO_GET(uint32, &din, "sciencebox", &real_packet->sciencebox)) {
6002       RECEIVE_PACKET_FIELD_ERROR(sciencebox);
6003     }
6004   }
6005   if (BV_ISSET(fields, 77)) {
6006     log_packet_detailed("  got field 'shieldbox'");
6007     if (!DIO_GET(uint32, &din, "shieldbox", &real_packet->shieldbox)) {
6008       RECEIVE_PACKET_FIELD_ERROR(shieldbox);
6009     }
6010   }
6011   if (BV_ISSET(fields, 78)) {
6012     log_packet_detailed("  got field 'skill_level'");
6013     if (!DIO_GET(uint32, &din, "skill_level", &real_packet->skill_level)) {
6014       RECEIVE_PACKET_FIELD_ERROR(skill_level);
6015     }
6016   }
6017   real_packet->slow_invasions = BV_ISSET(fields, 79);
6018   if (BV_ISSET(fields, 80)) {
6019     log_packet_detailed("  got field 'victory_conditions'");
6020     {
6021       int readin;
6022 
6023       if (!DIO_GET(uint8, &din, "victory_conditions", &readin)) {
6024         RECEIVE_PACKET_FIELD_ERROR(victory_conditions);
6025       }
6026       real_packet->victory_conditions = readin;
6027     }
6028   }
6029   real_packet->team_pooled_research = BV_ISSET(fields, 81);
6030   if (BV_ISSET(fields, 82)) {
6031     log_packet_detailed("  got field 'tech'");
6032     if (!DIO_GET(uint32, &din, "tech", &real_packet->tech)) {
6033       RECEIVE_PACKET_FIELD_ERROR(tech);
6034     }
6035   }
6036   if (BV_ISSET(fields, 83)) {
6037     log_packet_detailed("  got field 'tech_cost_style'");
6038     {
6039       int readin;
6040 
6041       if (!DIO_GET(uint8, &din, "tech_cost_style", &readin)) {
6042         RECEIVE_PACKET_FIELD_ERROR(tech_cost_style);
6043       }
6044       real_packet->tech_cost_style = readin;
6045     }
6046   }
6047   if (BV_ISSET(fields, 84)) {
6048     log_packet_detailed("  got field 'tech_leakage'");
6049     {
6050       int readin;
6051 
6052       if (!DIO_GET(uint8, &din, "tech_leakage", &readin)) {
6053         RECEIVE_PACKET_FIELD_ERROR(tech_leakage);
6054       }
6055       real_packet->tech_leakage = readin;
6056     }
6057   }
6058   if (BV_ISSET(fields, 85)) {
6059     log_packet_detailed("  got field 'tech_upkeep_divider'");
6060     if (!DIO_GET(uint16, &din, "tech_upkeep_divider", &real_packet->tech_upkeep_divider)) {
6061       RECEIVE_PACKET_FIELD_ERROR(tech_upkeep_divider);
6062     }
6063   }
6064   if (BV_ISSET(fields, 86)) {
6065     log_packet_detailed("  got field 'tech_upkeep_style'");
6066     {
6067       int readin;
6068 
6069       if (!DIO_GET(uint8, &din, "tech_upkeep_style", &readin)) {
6070         RECEIVE_PACKET_FIELD_ERROR(tech_upkeep_style);
6071       }
6072       real_packet->tech_upkeep_style = readin;
6073     }
6074   }
6075   if (BV_ISSET(fields, 87)) {
6076     log_packet_detailed("  got field 'free_tech_method'");
6077     {
6078       int readin;
6079 
6080       if (!DIO_GET(uint8, &din, "free_tech_method", &readin)) {
6081         RECEIVE_PACKET_FIELD_ERROR(free_tech_method);
6082       }
6083       real_packet->free_tech_method = readin;
6084     }
6085   }
6086   if (BV_ISSET(fields, 88)) {
6087     log_packet_detailed("  got field 'gameloss_style'");
6088     {
6089       int readin;
6090 
6091       if (!DIO_GET(uint8, &din, "gameloss_style", &readin)) {
6092         RECEIVE_PACKET_FIELD_ERROR(gameloss_style);
6093       }
6094       real_packet->gameloss_style = readin;
6095     }
6096   }
6097   if (BV_ISSET(fields, 89)) {
6098     log_packet_detailed("  got field 'timeout'");
6099     if (!DIO_GET(uint32, &din, "timeout", &real_packet->timeout)) {
6100       RECEIVE_PACKET_FIELD_ERROR(timeout);
6101     }
6102   }
6103   if (BV_ISSET(fields, 90)) {
6104     log_packet_detailed("  got field 'first_timeout'");
6105     if (!DIO_GET(uint32, &din, "first_timeout", &real_packet->first_timeout)) {
6106       RECEIVE_PACKET_FIELD_ERROR(first_timeout);
6107     }
6108   }
6109   real_packet->tired_attack = BV_ISSET(fields, 91);
6110   if (BV_ISSET(fields, 92)) {
6111     log_packet_detailed("  got field 'trademindist'");
6112     if (!DIO_GET(uint16, &din, "trademindist", &real_packet->trademindist)) {
6113       RECEIVE_PACKET_FIELD_ERROR(trademindist);
6114     }
6115   }
6116   real_packet->force_trade_route = BV_ISSET(fields, 93);
6117   real_packet->trading_city = BV_ISSET(fields, 94);
6118   real_packet->trading_gold = BV_ISSET(fields, 95);
6119   real_packet->trading_tech = BV_ISSET(fields, 96);
6120   if (BV_ISSET(fields, 97)) {
6121     log_packet_detailed("  got field 'turn'");
6122     if (!DIO_GET(sint16, &din, "turn", &real_packet->turn)) {
6123       RECEIVE_PACKET_FIELD_ERROR(turn);
6124     }
6125   }
6126   if (BV_ISSET(fields, 98)) {
6127     log_packet_detailed("  got field 'warminglevel'");
6128     if (!DIO_GET(uint32, &din, "warminglevel", &real_packet->warminglevel)) {
6129       RECEIVE_PACKET_FIELD_ERROR(warminglevel);
6130     }
6131   }
6132   if (BV_ISSET(fields, 99)) {
6133     log_packet_detailed("  got field 'year16'");
6134     if (!DIO_GET(sint16, &din, "year16", &real_packet->year16)) {
6135       RECEIVE_PACKET_FIELD_ERROR(year16);
6136     }
6137   }
6138   if (BV_ISSET(fields, 100)) {
6139     log_packet_detailed("  got field 'year32'");
6140     if (!DIO_GET(sint32, &din, "year32", &real_packet->year32)) {
6141       RECEIVE_PACKET_FIELD_ERROR(year32);
6142     }
6143   }
6144   real_packet->year_0_hack = BV_ISSET(fields, 101);
6145   if (BV_ISSET(fields, 102)) {
6146     log_packet_detailed("  got field 'calendar_fragments'");
6147     if (!DIO_GET(uint16, &din, "calendar_fragments", &real_packet->calendar_fragments)) {
6148       RECEIVE_PACKET_FIELD_ERROR(calendar_fragments);
6149     }
6150   }
6151   if (BV_ISSET(fields, 103)) {
6152     log_packet_detailed("  got field 'fragment_count'");
6153     if (!DIO_GET(uint16, &din, "fragment_count", &real_packet->fragment_count)) {
6154       RECEIVE_PACKET_FIELD_ERROR(fragment_count);
6155     }
6156   }
6157   if (BV_ISSET(fields, 104)) {
6158     log_packet_detailed("  got field 'calendar_fragment_name'");
6159 
6160     {
6161       int i;
6162 
6163       for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
6164         if (!DIO_GET(string, &din, "calendar_fragment_name", real_packet->calendar_fragment_name[i], sizeof(real_packet->calendar_fragment_name[i]))) {
6165           RECEIVE_PACKET_FIELD_ERROR(calendar_fragment_name);
6166         }
6167       }
6168     }
6169   }
6170   real_packet->civil_war_enabled = BV_ISSET(fields, 105);
6171   real_packet->paradrop_to_transport = BV_ISSET(fields, 106);
6172 
6173   if (NULL == old) {
6174     old = fc_malloc(sizeof(*old));
6175     *old = *real_packet;
6176     genhash_insert(*hash, old, old);
6177   } else {
6178     *old = *real_packet;
6179   }
6180   RECEIVE_PACKET_END(real_packet);
6181 }
6182 
send_packet_game_info_102(struct connection * pc,const struct packet_game_info * packet)6183 static int send_packet_game_info_102(struct connection *pc, const struct packet_game_info *packet)
6184 {
6185   const struct packet_game_info *real_packet = packet;
6186   packet_game_info_102_fields fields;
6187   struct packet_game_info *old;
6188   bool differ;
6189   struct genhash **hash = pc->phs.sent + PACKET_GAME_INFO;
6190   int different = 0;
6191   SEND_PACKET_START(PACKET_GAME_INFO);
6192 
6193   log_packet_detailed("packet_game_info_102: sending info about ()");
6194 
6195   if (NULL == *hash) {
6196     *hash = genhash_new_full(hash_packet_game_info_102, cmp_packet_game_info_102,
6197                              NULL, NULL, NULL, free);
6198   }
6199   BV_CLR_ALL(fields);
6200 
6201   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
6202     old = fc_malloc(sizeof(*old));
6203     *old = *real_packet;
6204     genhash_insert(*hash, old, old);
6205     memset(old, 0, sizeof(*old));
6206     different = 1;      /* Force to send. */
6207   }
6208 
6209   differ = (old->add_to_size_limit != real_packet->add_to_size_limit);
6210   if (differ) {
6211     different++;
6212     BV_SET(fields, 0);
6213   }
6214 
6215   differ = (old->aifill != real_packet->aifill);
6216   if (differ) {
6217     different++;
6218     BV_SET(fields, 1);
6219   }
6220 
6221   differ = (old->persistent_ready != real_packet->persistent_ready);
6222   if (differ) {
6223     different++;
6224     BV_SET(fields, 2);
6225   }
6226 
6227   differ = (old->airlifting_style != real_packet->airlifting_style);
6228   if (differ) {
6229     different++;
6230     BV_SET(fields, 3);
6231   }
6232 
6233   differ = (old->angrycitizen != real_packet->angrycitizen);
6234   if (differ) {
6235     different++;
6236     BV_SET(fields, 4);
6237   }
6238 
6239   differ = (old->base_pollution != real_packet->base_pollution);
6240   if (differ) {
6241     different++;
6242     BV_SET(fields, 5);
6243   }
6244 
6245   differ = (old->base_tech_cost != real_packet->base_tech_cost);
6246   if (differ) {
6247     different++;
6248     BV_SET(fields, 6);
6249   }
6250 
6251   differ = (old->border_city_radius_sq != real_packet->border_city_radius_sq);
6252   if (differ) {
6253     different++;
6254     BV_SET(fields, 7);
6255   }
6256 
6257   differ = (old->border_size_effect != real_packet->border_size_effect);
6258   if (differ) {
6259     different++;
6260     BV_SET(fields, 8);
6261   }
6262 
6263   differ = (old->border_city_permanent_radius_sq != real_packet->border_city_permanent_radius_sq);
6264   if (differ) {
6265     different++;
6266     BV_SET(fields, 9);
6267   }
6268 
6269   differ = (old->borders != real_packet->borders);
6270   if (differ) {
6271     different++;
6272     BV_SET(fields, 10);
6273   }
6274 
6275   differ = (old->base_bribe_cost != real_packet->base_bribe_cost);
6276   if (differ) {
6277     different++;
6278     BV_SET(fields, 11);
6279   }
6280 
6281   differ = (old->culture_vic_points != real_packet->culture_vic_points);
6282   if (differ) {
6283     different++;
6284     BV_SET(fields, 12);
6285   }
6286 
6287   differ = (old->culture_vic_lead != real_packet->culture_vic_lead);
6288   if (differ) {
6289     different++;
6290     BV_SET(fields, 13);
6291   }
6292 
6293   differ = (old->culture_migration_pml != real_packet->culture_migration_pml);
6294   if (differ) {
6295     different++;
6296     BV_SET(fields, 14);
6297   }
6298 
6299   differ = (old->calendar_skip_0 != real_packet->calendar_skip_0);
6300   if (differ) {
6301     different++;
6302   }
6303   if (packet->calendar_skip_0) {
6304     BV_SET(fields, 15);
6305   }
6306 
6307   differ = (old->celebratesize != real_packet->celebratesize);
6308   if (differ) {
6309     different++;
6310     BV_SET(fields, 16);
6311   }
6312 
6313   differ = (old->changable_tax != real_packet->changable_tax);
6314   if (differ) {
6315     different++;
6316   }
6317   if (packet->changable_tax) {
6318     BV_SET(fields, 17);
6319   }
6320 
6321   differ = (old->pop_report_zeroes != real_packet->pop_report_zeroes);
6322   if (differ) {
6323     different++;
6324     BV_SET(fields, 18);
6325   }
6326 
6327   differ = (old->citizen_nationality != real_packet->citizen_nationality);
6328   if (differ) {
6329     different++;
6330   }
6331   if (packet->citizen_nationality) {
6332     BV_SET(fields, 19);
6333   }
6334 
6335   differ = (old->citizen_convert_speed != real_packet->citizen_convert_speed);
6336   if (differ) {
6337     different++;
6338     BV_SET(fields, 20);
6339   }
6340 
6341   differ = (old->citizen_partisans_pct != real_packet->citizen_partisans_pct);
6342   if (differ) {
6343     different++;
6344     BV_SET(fields, 21);
6345   }
6346 
6347   differ = (old->citymindist != real_packet->citymindist);
6348   if (differ) {
6349     different++;
6350     BV_SET(fields, 22);
6351   }
6352 
6353   differ = (old->cooling != real_packet->cooling);
6354   if (differ) {
6355     different++;
6356     BV_SET(fields, 23);
6357   }
6358 
6359   differ = (old->coolinglevel != real_packet->coolinglevel);
6360   if (differ) {
6361     different++;
6362     BV_SET(fields, 24);
6363   }
6364 
6365   differ = (old->diplomacy != real_packet->diplomacy);
6366   if (differ) {
6367     different++;
6368     BV_SET(fields, 25);
6369   }
6370 
6371   differ = (old->fogofwar != real_packet->fogofwar);
6372   if (differ) {
6373     different++;
6374   }
6375   if (packet->fogofwar) {
6376     BV_SET(fields, 26);
6377   }
6378 
6379   differ = (old->food_cost != real_packet->food_cost);
6380   if (differ) {
6381     different++;
6382     BV_SET(fields, 27);
6383   }
6384 
6385   differ = (old->foodbox != real_packet->foodbox);
6386   if (differ) {
6387     different++;
6388     BV_SET(fields, 28);
6389   }
6390 
6391   differ = (old->forced_gold != real_packet->forced_gold);
6392   if (differ) {
6393     different++;
6394     BV_SET(fields, 29);
6395   }
6396 
6397   differ = (old->forced_luxury != real_packet->forced_luxury);
6398   if (differ) {
6399     different++;
6400     BV_SET(fields, 30);
6401   }
6402 
6403   differ = (old->forced_science != real_packet->forced_science);
6404   if (differ) {
6405     different++;
6406     BV_SET(fields, 31);
6407   }
6408 
6409   differ = (old->fulltradesize != real_packet->fulltradesize);
6410   if (differ) {
6411     different++;
6412     BV_SET(fields, 32);
6413   }
6414 
6415 
6416     {
6417       differ = (A_LAST != A_LAST);
6418       if (!differ) {
6419         int i;
6420 
6421         for (i = 0; i < A_LAST; i++) {
6422           if (old->global_advances[i] != real_packet->global_advances[i]) {
6423             differ = TRUE;
6424             break;
6425           }
6426         }
6427       }
6428     }
6429   if (differ) {
6430     different++;
6431     BV_SET(fields, 33);
6432   }
6433 
6434   differ = (old->global_warming != real_packet->global_warming);
6435   if (differ) {
6436     different++;
6437   }
6438   if (packet->global_warming) {
6439     BV_SET(fields, 34);
6440   }
6441 
6442   differ = (old->globalwarming != real_packet->globalwarming);
6443   if (differ) {
6444     different++;
6445     BV_SET(fields, 35);
6446   }
6447 
6448   differ = (old->gold != real_packet->gold);
6449   if (differ) {
6450     different++;
6451     BV_SET(fields, 36);
6452   }
6453 
6454   differ = (old->gold_upkeep_style != real_packet->gold_upkeep_style);
6455   if (differ) {
6456     different++;
6457     BV_SET(fields, 37);
6458   }
6459 
6460   differ = (old->revolentype != real_packet->revolentype);
6461   if (differ) {
6462     different++;
6463     BV_SET(fields, 38);
6464   }
6465 
6466   differ = (old->default_government_id != real_packet->default_government_id);
6467   if (differ) {
6468     different++;
6469     BV_SET(fields, 39);
6470   }
6471 
6472   differ = (old->government_during_revolution_id != real_packet->government_during_revolution_id);
6473   if (differ) {
6474     different++;
6475     BV_SET(fields, 40);
6476   }
6477 
6478   differ = (old->granary_food_inc != real_packet->granary_food_inc);
6479   if (differ) {
6480     different++;
6481     BV_SET(fields, 41);
6482   }
6483 
6484 
6485     {
6486       differ = (MAX_GRANARY_INIS != MAX_GRANARY_INIS);
6487       if (!differ) {
6488         int i;
6489 
6490         for (i = 0; i < MAX_GRANARY_INIS; i++) {
6491           if (old->granary_food_ini[i] != real_packet->granary_food_ini[i]) {
6492             differ = TRUE;
6493             break;
6494           }
6495         }
6496       }
6497     }
6498   if (differ) {
6499     different++;
6500     BV_SET(fields, 42);
6501   }
6502 
6503   differ = (old->granary_num_inis != real_packet->granary_num_inis);
6504   if (differ) {
6505     different++;
6506     BV_SET(fields, 43);
6507   }
6508 
6509 
6510     {
6511       differ = (B_LAST != B_LAST);
6512       if (!differ) {
6513         int i;
6514 
6515         for (i = 0; i < B_LAST; i++) {
6516           if (old->great_wonder_owners[i] != real_packet->great_wonder_owners[i]) {
6517             differ = TRUE;
6518             break;
6519           }
6520         }
6521       }
6522     }
6523   if (differ) {
6524     different++;
6525     BV_SET(fields, 44);
6526   }
6527 
6528   differ = (old->happy_cost != real_packet->happy_cost);
6529   if (differ) {
6530     different++;
6531     BV_SET(fields, 45);
6532   }
6533 
6534   differ = (old->happyborders != real_packet->happyborders);
6535   if (differ) {
6536     different++;
6537     BV_SET(fields, 46);
6538   }
6539 
6540   differ = (old->heating != real_packet->heating);
6541   if (differ) {
6542     different++;
6543     BV_SET(fields, 47);
6544   }
6545 
6546   differ = (old->illness_base_factor != real_packet->illness_base_factor);
6547   if (differ) {
6548     different++;
6549     BV_SET(fields, 48);
6550   }
6551 
6552   differ = (old->illness_min_size != real_packet->illness_min_size);
6553   if (differ) {
6554     different++;
6555     BV_SET(fields, 49);
6556   }
6557 
6558   differ = (old->illness_on != real_packet->illness_on);
6559   if (differ) {
6560     different++;
6561   }
6562   if (packet->illness_on) {
6563     BV_SET(fields, 50);
6564   }
6565 
6566   differ = (old->illness_pollution_factor != real_packet->illness_pollution_factor);
6567   if (differ) {
6568     different++;
6569     BV_SET(fields, 51);
6570   }
6571 
6572   differ = (old->illness_trade_infection != real_packet->illness_trade_infection);
6573   if (differ) {
6574     different++;
6575     BV_SET(fields, 52);
6576   }
6577 
6578   differ = (old->init_city_radius_sq != real_packet->init_city_radius_sq);
6579   if (differ) {
6580     different++;
6581     BV_SET(fields, 53);
6582   }
6583 
6584   differ = (old->is_edit_mode != real_packet->is_edit_mode);
6585   if (differ) {
6586     different++;
6587   }
6588   if (packet->is_edit_mode) {
6589     BV_SET(fields, 54);
6590   }
6591 
6592   differ = (old->is_new_game != real_packet->is_new_game);
6593   if (differ) {
6594     different++;
6595   }
6596   if (packet->is_new_game) {
6597     BV_SET(fields, 55);
6598   }
6599 
6600   differ = (old->killcitizen != real_packet->killcitizen);
6601   if (differ) {
6602     different++;
6603   }
6604   if (packet->killcitizen) {
6605     BV_SET(fields, 56);
6606   }
6607 
6608   differ = (old->killstack != real_packet->killstack);
6609   if (differ) {
6610     different++;
6611   }
6612   if (packet->killstack) {
6613     BV_SET(fields, 57);
6614   }
6615 
6616 
6617     {
6618       differ = (O_LAST != O_LAST);
6619       if (!differ) {
6620         int i;
6621 
6622         for (i = 0; i < O_LAST; i++) {
6623           if (old->min_city_center_output[i] != real_packet->min_city_center_output[i]) {
6624             differ = TRUE;
6625             break;
6626           }
6627         }
6628       }
6629     }
6630   if (differ) {
6631     different++;
6632     BV_SET(fields, 58);
6633   }
6634 
6635   differ = (strcmp(old->negative_year_label, real_packet->negative_year_label) != 0);
6636   if (differ) {
6637     different++;
6638     BV_SET(fields, 59);
6639   }
6640 
6641   differ = (old->notradesize != real_packet->notradesize);
6642   if (differ) {
6643     different++;
6644     BV_SET(fields, 60);
6645   }
6646 
6647   differ = (old->nuclear_winter != real_packet->nuclear_winter);
6648   if (differ) {
6649     different++;
6650   }
6651   if (packet->nuclear_winter) {
6652     BV_SET(fields, 61);
6653   }
6654 
6655   differ = (old->nuclearwinter != real_packet->nuclearwinter);
6656   if (differ) {
6657     different++;
6658     BV_SET(fields, 62);
6659   }
6660 
6661   differ = (old->phase != real_packet->phase);
6662   if (differ) {
6663     different++;
6664     BV_SET(fields, 63);
6665   }
6666 
6667   differ = (old->phase_mode != real_packet->phase_mode);
6668   if (differ) {
6669     different++;
6670     BV_SET(fields, 64);
6671   }
6672 
6673   differ = (old->pillage_select != real_packet->pillage_select);
6674   if (differ) {
6675     different++;
6676   }
6677   if (packet->pillage_select) {
6678     BV_SET(fields, 65);
6679   }
6680 
6681   differ = (old->tech_steal_allow_holes != real_packet->tech_steal_allow_holes);
6682   if (differ) {
6683     different++;
6684   }
6685   if (packet->tech_steal_allow_holes) {
6686     BV_SET(fields, 66);
6687   }
6688 
6689   differ = (old->tech_trade_allow_holes != real_packet->tech_trade_allow_holes);
6690   if (differ) {
6691     different++;
6692   }
6693   if (packet->tech_trade_allow_holes) {
6694     BV_SET(fields, 67);
6695   }
6696 
6697   differ = (old->tech_trade_loss_allow_holes != real_packet->tech_trade_loss_allow_holes);
6698   if (differ) {
6699     different++;
6700   }
6701   if (packet->tech_trade_loss_allow_holes) {
6702     BV_SET(fields, 68);
6703   }
6704 
6705   differ = (old->tech_parasite_allow_holes != real_packet->tech_parasite_allow_holes);
6706   if (differ) {
6707     different++;
6708   }
6709   if (packet->tech_parasite_allow_holes) {
6710     BV_SET(fields, 69);
6711   }
6712 
6713   differ = (old->tech_loss_allow_holes != real_packet->tech_loss_allow_holes);
6714   if (differ) {
6715     different++;
6716   }
6717   if (packet->tech_loss_allow_holes) {
6718     BV_SET(fields, 70);
6719   }
6720 
6721   differ = (strcmp(old->positive_year_label, real_packet->positive_year_label) != 0);
6722   if (differ) {
6723     different++;
6724     BV_SET(fields, 71);
6725   }
6726 
6727   differ = (old->rapturedelay != real_packet->rapturedelay);
6728   if (differ) {
6729     different++;
6730     BV_SET(fields, 72);
6731   }
6732 
6733   differ = (old->disasters != real_packet->disasters);
6734   if (differ) {
6735     different++;
6736     BV_SET(fields, 73);
6737   }
6738 
6739   differ = (old->restrictinfra != real_packet->restrictinfra);
6740   if (differ) {
6741     different++;
6742   }
6743   if (packet->restrictinfra) {
6744     BV_SET(fields, 74);
6745   }
6746 
6747   differ = (old->unreachable_protects != real_packet->unreachable_protects);
6748   if (differ) {
6749     different++;
6750   }
6751   if (packet->unreachable_protects) {
6752     BV_SET(fields, 75);
6753   }
6754 
6755   differ = (old->sciencebox != real_packet->sciencebox);
6756   if (differ) {
6757     different++;
6758     BV_SET(fields, 76);
6759   }
6760 
6761   differ = (old->shieldbox != real_packet->shieldbox);
6762   if (differ) {
6763     different++;
6764     BV_SET(fields, 77);
6765   }
6766 
6767   differ = (old->skill_level != real_packet->skill_level);
6768   if (differ) {
6769     different++;
6770     BV_SET(fields, 78);
6771   }
6772 
6773   differ = (old->slow_invasions != real_packet->slow_invasions);
6774   if (differ) {
6775     different++;
6776   }
6777   if (packet->slow_invasions) {
6778     BV_SET(fields, 79);
6779   }
6780 
6781   differ = (old->victory_conditions != real_packet->victory_conditions);
6782   if (differ) {
6783     different++;
6784     BV_SET(fields, 80);
6785   }
6786 
6787   differ = (old->team_pooled_research != real_packet->team_pooled_research);
6788   if (differ) {
6789     different++;
6790   }
6791   if (packet->team_pooled_research) {
6792     BV_SET(fields, 81);
6793   }
6794 
6795   differ = (old->tech != real_packet->tech);
6796   if (differ) {
6797     different++;
6798     BV_SET(fields, 82);
6799   }
6800 
6801   differ = (old->tech_cost_style != real_packet->tech_cost_style);
6802   if (differ) {
6803     different++;
6804     BV_SET(fields, 83);
6805   }
6806 
6807   differ = (old->tech_leakage != real_packet->tech_leakage);
6808   if (differ) {
6809     different++;
6810     BV_SET(fields, 84);
6811   }
6812 
6813   differ = (old->tech_upkeep_divider != real_packet->tech_upkeep_divider);
6814   if (differ) {
6815     different++;
6816     BV_SET(fields, 85);
6817   }
6818 
6819   differ = (old->tech_upkeep_style != real_packet->tech_upkeep_style);
6820   if (differ) {
6821     different++;
6822     BV_SET(fields, 86);
6823   }
6824 
6825   differ = (old->free_tech_method != real_packet->free_tech_method);
6826   if (differ) {
6827     different++;
6828     BV_SET(fields, 87);
6829   }
6830 
6831   differ = (old->gameloss_style != real_packet->gameloss_style);
6832   if (differ) {
6833     different++;
6834     BV_SET(fields, 88);
6835   }
6836 
6837   differ = (old->timeout != real_packet->timeout);
6838   if (differ) {
6839     different++;
6840     BV_SET(fields, 89);
6841   }
6842 
6843   differ = (old->first_timeout != real_packet->first_timeout);
6844   if (differ) {
6845     different++;
6846     BV_SET(fields, 90);
6847   }
6848 
6849   differ = (old->tired_attack != real_packet->tired_attack);
6850   if (differ) {
6851     different++;
6852   }
6853   if (packet->tired_attack) {
6854     BV_SET(fields, 91);
6855   }
6856 
6857   differ = (old->trademindist != real_packet->trademindist);
6858   if (differ) {
6859     different++;
6860     BV_SET(fields, 92);
6861   }
6862 
6863   differ = (old->force_trade_route != real_packet->force_trade_route);
6864   if (differ) {
6865     different++;
6866   }
6867   if (packet->force_trade_route) {
6868     BV_SET(fields, 93);
6869   }
6870 
6871   differ = (old->trading_city != real_packet->trading_city);
6872   if (differ) {
6873     different++;
6874   }
6875   if (packet->trading_city) {
6876     BV_SET(fields, 94);
6877   }
6878 
6879   differ = (old->trading_gold != real_packet->trading_gold);
6880   if (differ) {
6881     different++;
6882   }
6883   if (packet->trading_gold) {
6884     BV_SET(fields, 95);
6885   }
6886 
6887   differ = (old->trading_tech != real_packet->trading_tech);
6888   if (differ) {
6889     different++;
6890   }
6891   if (packet->trading_tech) {
6892     BV_SET(fields, 96);
6893   }
6894 
6895   differ = (old->turn != real_packet->turn);
6896   if (differ) {
6897     different++;
6898     BV_SET(fields, 97);
6899   }
6900 
6901   differ = (old->warminglevel != real_packet->warminglevel);
6902   if (differ) {
6903     different++;
6904     BV_SET(fields, 98);
6905   }
6906 
6907   differ = (old->year16 != real_packet->year16);
6908   if (differ) {
6909     different++;
6910     BV_SET(fields, 99);
6911   }
6912 
6913   differ = (old->year32 != real_packet->year32);
6914   if (differ) {
6915     different++;
6916     BV_SET(fields, 100);
6917   }
6918 
6919   differ = (old->year_0_hack != real_packet->year_0_hack);
6920   if (differ) {
6921     different++;
6922   }
6923   if (packet->year_0_hack) {
6924     BV_SET(fields, 101);
6925   }
6926 
6927   differ = (old->calendar_fragments != real_packet->calendar_fragments);
6928   if (differ) {
6929     different++;
6930     BV_SET(fields, 102);
6931   }
6932 
6933   differ = (old->fragment_count != real_packet->fragment_count);
6934   if (differ) {
6935     different++;
6936     BV_SET(fields, 103);
6937   }
6938 
6939 
6940     {
6941       differ = (MAX_CALENDAR_FRAGMENTS != MAX_CALENDAR_FRAGMENTS);
6942       if (!differ) {
6943         int i;
6944 
6945         for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
6946           if (strcmp(old->calendar_fragment_name[i], real_packet->calendar_fragment_name[i]) != 0) {
6947             differ = TRUE;
6948             break;
6949           }
6950         }
6951       }
6952     }
6953   if (differ) {
6954     different++;
6955     BV_SET(fields, 104);
6956   }
6957 
6958   differ = (old->civil_war_enabled != real_packet->civil_war_enabled);
6959   if (differ) {
6960     different++;
6961   }
6962   if (packet->civil_war_enabled) {
6963     BV_SET(fields, 105);
6964   }
6965 
6966   differ = (old->paradrop_to_transport != real_packet->paradrop_to_transport);
6967   if (differ) {
6968     different++;
6969   }
6970   if (packet->paradrop_to_transport) {
6971     BV_SET(fields, 106);
6972   }
6973 
6974 
6975   if (different == 0) {
6976     log_packet_detailed("  no change -> discard");
6977     return 0;
6978   }
6979 
6980   DIO_BV_PUT(&dout, "fields", fields);
6981 
6982   if (BV_ISSET(fields, 0)) {
6983     log_packet_detailed("  field 'add_to_size_limit' has changed");
6984     DIO_PUT(uint8, &dout, "add_to_size_limit", real_packet->add_to_size_limit);
6985   }
6986   if (BV_ISSET(fields, 1)) {
6987     log_packet_detailed("  field 'aifill' has changed");
6988     DIO_PUT(uint8, &dout, "aifill", real_packet->aifill);
6989   }
6990   if (BV_ISSET(fields, 2)) {
6991     log_packet_detailed("  field 'persistent_ready' has changed");
6992     DIO_PUT(uint8, &dout, "persistent_ready", real_packet->persistent_ready);
6993   }
6994   if (BV_ISSET(fields, 3)) {
6995     log_packet_detailed("  field 'airlifting_style' has changed");
6996     DIO_PUT(uint8, &dout, "airlifting_style", real_packet->airlifting_style);
6997   }
6998   if (BV_ISSET(fields, 4)) {
6999     log_packet_detailed("  field 'angrycitizen' has changed");
7000     DIO_PUT(uint8, &dout, "angrycitizen", real_packet->angrycitizen);
7001   }
7002   if (BV_ISSET(fields, 5)) {
7003     log_packet_detailed("  field 'base_pollution' has changed");
7004     DIO_PUT(sint16, &dout, "base_pollution", real_packet->base_pollution);
7005   }
7006   if (BV_ISSET(fields, 6)) {
7007     log_packet_detailed("  field 'base_tech_cost' has changed");
7008     DIO_PUT(uint8, &dout, "base_tech_cost", real_packet->base_tech_cost);
7009   }
7010   if (BV_ISSET(fields, 7)) {
7011     log_packet_detailed("  field 'border_city_radius_sq' has changed");
7012     DIO_PUT(uint16, &dout, "border_city_radius_sq", real_packet->border_city_radius_sq);
7013   }
7014   if (BV_ISSET(fields, 8)) {
7015     log_packet_detailed("  field 'border_size_effect' has changed");
7016     DIO_PUT(uint8, &dout, "border_size_effect", real_packet->border_size_effect);
7017   }
7018   if (BV_ISSET(fields, 9)) {
7019     log_packet_detailed("  field 'border_city_permanent_radius_sq' has changed");
7020     DIO_PUT(sint16, &dout, "border_city_permanent_radius_sq", real_packet->border_city_permanent_radius_sq);
7021   }
7022   if (BV_ISSET(fields, 10)) {
7023     log_packet_detailed("  field 'borders' has changed");
7024     DIO_PUT(uint8, &dout, "borders", real_packet->borders);
7025   }
7026   if (BV_ISSET(fields, 11)) {
7027     log_packet_detailed("  field 'base_bribe_cost' has changed");
7028     DIO_PUT(uint32, &dout, "base_bribe_cost", real_packet->base_bribe_cost);
7029   }
7030   if (BV_ISSET(fields, 12)) {
7031     log_packet_detailed("  field 'culture_vic_points' has changed");
7032     DIO_PUT(uint32, &dout, "culture_vic_points", real_packet->culture_vic_points);
7033   }
7034   if (BV_ISSET(fields, 13)) {
7035     log_packet_detailed("  field 'culture_vic_lead' has changed");
7036     DIO_PUT(uint16, &dout, "culture_vic_lead", real_packet->culture_vic_lead);
7037   }
7038   if (BV_ISSET(fields, 14)) {
7039     log_packet_detailed("  field 'culture_migration_pml' has changed");
7040     DIO_PUT(uint16, &dout, "culture_migration_pml", real_packet->culture_migration_pml);
7041   }
7042   /* field 15 is folded into the header */
7043   if (BV_ISSET(fields, 16)) {
7044     log_packet_detailed("  field 'celebratesize' has changed");
7045     DIO_PUT(uint8, &dout, "celebratesize", real_packet->celebratesize);
7046   }
7047   /* field 17 is folded into the header */
7048   if (BV_ISSET(fields, 18)) {
7049     log_packet_detailed("  field 'pop_report_zeroes' has changed");
7050     DIO_PUT(uint8, &dout, "pop_report_zeroes", real_packet->pop_report_zeroes);
7051   }
7052   /* field 19 is folded into the header */
7053   if (BV_ISSET(fields, 20)) {
7054     log_packet_detailed("  field 'citizen_convert_speed' has changed");
7055     DIO_PUT(uint16, &dout, "citizen_convert_speed", real_packet->citizen_convert_speed);
7056   }
7057   if (BV_ISSET(fields, 21)) {
7058     log_packet_detailed("  field 'citizen_partisans_pct' has changed");
7059     DIO_PUT(uint8, &dout, "citizen_partisans_pct", real_packet->citizen_partisans_pct);
7060   }
7061   if (BV_ISSET(fields, 22)) {
7062     log_packet_detailed("  field 'citymindist' has changed");
7063     DIO_PUT(uint8, &dout, "citymindist", real_packet->citymindist);
7064   }
7065   if (BV_ISSET(fields, 23)) {
7066     log_packet_detailed("  field 'cooling' has changed");
7067     DIO_PUT(uint32, &dout, "cooling", real_packet->cooling);
7068   }
7069   if (BV_ISSET(fields, 24)) {
7070     log_packet_detailed("  field 'coolinglevel' has changed");
7071     DIO_PUT(uint32, &dout, "coolinglevel", real_packet->coolinglevel);
7072   }
7073   if (BV_ISSET(fields, 25)) {
7074     log_packet_detailed("  field 'diplomacy' has changed");
7075     DIO_PUT(uint8, &dout, "diplomacy", real_packet->diplomacy);
7076   }
7077   /* field 26 is folded into the header */
7078   if (BV_ISSET(fields, 27)) {
7079     log_packet_detailed("  field 'food_cost' has changed");
7080     DIO_PUT(uint8, &dout, "food_cost", real_packet->food_cost);
7081   }
7082   if (BV_ISSET(fields, 28)) {
7083     log_packet_detailed("  field 'foodbox' has changed");
7084     DIO_PUT(uint32, &dout, "foodbox", real_packet->foodbox);
7085   }
7086   if (BV_ISSET(fields, 29)) {
7087     log_packet_detailed("  field 'forced_gold' has changed");
7088     DIO_PUT(uint8, &dout, "forced_gold", real_packet->forced_gold);
7089   }
7090   if (BV_ISSET(fields, 30)) {
7091     log_packet_detailed("  field 'forced_luxury' has changed");
7092     DIO_PUT(uint8, &dout, "forced_luxury", real_packet->forced_luxury);
7093   }
7094   if (BV_ISSET(fields, 31)) {
7095     log_packet_detailed("  field 'forced_science' has changed");
7096     DIO_PUT(uint8, &dout, "forced_science", real_packet->forced_science);
7097   }
7098   if (BV_ISSET(fields, 32)) {
7099     log_packet_detailed("  field 'fulltradesize' has changed");
7100     DIO_PUT(uint8, &dout, "fulltradesize", real_packet->fulltradesize);
7101   }
7102   if (BV_ISSET(fields, 33)) {
7103     log_packet_detailed("  field 'global_advances' has changed");
7104 
7105     {
7106       int i;
7107 
7108       fc_assert(A_LAST < 255);
7109 
7110       for (i = 0; i < A_LAST; i++) {
7111         if (old->global_advances[i] != real_packet->global_advances[i]) {
7112           dio_put_uint8(&dout, i);
7113           dio_put_bool8(&dout, real_packet->global_advances[i]);
7114         }
7115       }
7116       dio_put_uint8(&dout, 255);
7117     }
7118   }
7119   /* field 34 is folded into the header */
7120   if (BV_ISSET(fields, 35)) {
7121     log_packet_detailed("  field 'globalwarming' has changed");
7122     DIO_PUT(uint32, &dout, "globalwarming", real_packet->globalwarming);
7123   }
7124   if (BV_ISSET(fields, 36)) {
7125     log_packet_detailed("  field 'gold' has changed");
7126     DIO_PUT(uint32, &dout, "gold", real_packet->gold);
7127   }
7128   if (BV_ISSET(fields, 37)) {
7129     log_packet_detailed("  field 'gold_upkeep_style' has changed");
7130     DIO_PUT(uint8, &dout, "gold_upkeep_style", real_packet->gold_upkeep_style);
7131   }
7132   if (BV_ISSET(fields, 38)) {
7133     log_packet_detailed("  field 'revolentype' has changed");
7134     DIO_PUT(uint8, &dout, "revolentype", real_packet->revolentype);
7135   }
7136   if (BV_ISSET(fields, 39)) {
7137     log_packet_detailed("  field 'default_government_id' has changed");
7138     DIO_PUT(sint8, &dout, "default_government_id", real_packet->default_government_id);
7139   }
7140   if (BV_ISSET(fields, 40)) {
7141     log_packet_detailed("  field 'government_during_revolution_id' has changed");
7142     DIO_PUT(sint8, &dout, "government_during_revolution_id", real_packet->government_during_revolution_id);
7143   }
7144   if (BV_ISSET(fields, 41)) {
7145     log_packet_detailed("  field 'granary_food_inc' has changed");
7146     DIO_PUT(uint8, &dout, "granary_food_inc", real_packet->granary_food_inc);
7147   }
7148   if (BV_ISSET(fields, 42)) {
7149     log_packet_detailed("  field 'granary_food_ini' has changed");
7150 
7151     {
7152       int i;
7153 
7154       for (i = 0; i < MAX_GRANARY_INIS; i++) {
7155         dio_put_uint8(&dout, real_packet->granary_food_ini[i]);
7156       }
7157     }
7158   }
7159   if (BV_ISSET(fields, 43)) {
7160     log_packet_detailed("  field 'granary_num_inis' has changed");
7161     DIO_PUT(uint8, &dout, "granary_num_inis", real_packet->granary_num_inis);
7162   }
7163   if (BV_ISSET(fields, 44)) {
7164     log_packet_detailed("  field 'great_wonder_owners' has changed");
7165 
7166     {
7167       int i;
7168 
7169       fc_assert(B_LAST < 255);
7170 
7171       for (i = 0; i < B_LAST; i++) {
7172         if (old->great_wonder_owners[i] != real_packet->great_wonder_owners[i]) {
7173           dio_put_uint8(&dout, i);
7174           dio_put_uint8(&dout, real_packet->great_wonder_owners[i]);
7175         }
7176       }
7177       dio_put_uint8(&dout, 255);
7178     }
7179   }
7180   if (BV_ISSET(fields, 45)) {
7181     log_packet_detailed("  field 'happy_cost' has changed");
7182     DIO_PUT(uint8, &dout, "happy_cost", real_packet->happy_cost);
7183   }
7184   if (BV_ISSET(fields, 46)) {
7185     log_packet_detailed("  field 'happyborders' has changed");
7186     DIO_PUT(uint8, &dout, "happyborders", real_packet->happyborders);
7187   }
7188   if (BV_ISSET(fields, 47)) {
7189     log_packet_detailed("  field 'heating' has changed");
7190     DIO_PUT(uint32, &dout, "heating", real_packet->heating);
7191   }
7192   if (BV_ISSET(fields, 48)) {
7193     log_packet_detailed("  field 'illness_base_factor' has changed");
7194     DIO_PUT(uint16, &dout, "illness_base_factor", real_packet->illness_base_factor);
7195   }
7196   if (BV_ISSET(fields, 49)) {
7197     log_packet_detailed("  field 'illness_min_size' has changed");
7198     DIO_PUT(uint8, &dout, "illness_min_size", real_packet->illness_min_size);
7199   }
7200   /* field 50 is folded into the header */
7201   if (BV_ISSET(fields, 51)) {
7202     log_packet_detailed("  field 'illness_pollution_factor' has changed");
7203     DIO_PUT(uint16, &dout, "illness_pollution_factor", real_packet->illness_pollution_factor);
7204   }
7205   if (BV_ISSET(fields, 52)) {
7206     log_packet_detailed("  field 'illness_trade_infection' has changed");
7207     DIO_PUT(uint16, &dout, "illness_trade_infection", real_packet->illness_trade_infection);
7208   }
7209   if (BV_ISSET(fields, 53)) {
7210     log_packet_detailed("  field 'init_city_radius_sq' has changed");
7211     DIO_PUT(uint8, &dout, "init_city_radius_sq", real_packet->init_city_radius_sq);
7212   }
7213   /* field 54 is folded into the header */
7214   /* field 55 is folded into the header */
7215   /* field 56 is folded into the header */
7216   /* field 57 is folded into the header */
7217   if (BV_ISSET(fields, 58)) {
7218     log_packet_detailed("  field 'min_city_center_output' has changed");
7219 
7220     {
7221       int i;
7222 
7223       for (i = 0; i < O_LAST; i++) {
7224         dio_put_uint8(&dout, real_packet->min_city_center_output[i]);
7225       }
7226     }
7227   }
7228   if (BV_ISSET(fields, 59)) {
7229     log_packet_detailed("  field 'negative_year_label' has changed");
7230     DIO_PUT(string, &dout, "negative_year_label", real_packet->negative_year_label);
7231   }
7232   if (BV_ISSET(fields, 60)) {
7233     log_packet_detailed("  field 'notradesize' has changed");
7234     DIO_PUT(uint8, &dout, "notradesize", real_packet->notradesize);
7235   }
7236   /* field 61 is folded into the header */
7237   if (BV_ISSET(fields, 62)) {
7238     log_packet_detailed("  field 'nuclearwinter' has changed");
7239     DIO_PUT(uint32, &dout, "nuclearwinter", real_packet->nuclearwinter);
7240   }
7241   if (BV_ISSET(fields, 63)) {
7242     log_packet_detailed("  field 'phase' has changed");
7243     DIO_PUT(sint16, &dout, "phase", real_packet->phase);
7244   }
7245   if (BV_ISSET(fields, 64)) {
7246     log_packet_detailed("  field 'phase_mode' has changed");
7247     DIO_PUT(uint8, &dout, "phase_mode", real_packet->phase_mode);
7248   }
7249   /* field 65 is folded into the header */
7250   /* field 66 is folded into the header */
7251   /* field 67 is folded into the header */
7252   /* field 68 is folded into the header */
7253   /* field 69 is folded into the header */
7254   /* field 70 is folded into the header */
7255   if (BV_ISSET(fields, 71)) {
7256     log_packet_detailed("  field 'positive_year_label' has changed");
7257     DIO_PUT(string, &dout, "positive_year_label", real_packet->positive_year_label);
7258   }
7259   if (BV_ISSET(fields, 72)) {
7260     log_packet_detailed("  field 'rapturedelay' has changed");
7261     DIO_PUT(uint8, &dout, "rapturedelay", real_packet->rapturedelay);
7262   }
7263   if (BV_ISSET(fields, 73)) {
7264     log_packet_detailed("  field 'disasters' has changed");
7265     DIO_PUT(uint16, &dout, "disasters", real_packet->disasters);
7266   }
7267   /* field 74 is folded into the header */
7268   /* field 75 is folded into the header */
7269   if (BV_ISSET(fields, 76)) {
7270     log_packet_detailed("  field 'sciencebox' has changed");
7271     DIO_PUT(uint32, &dout, "sciencebox", real_packet->sciencebox);
7272   }
7273   if (BV_ISSET(fields, 77)) {
7274     log_packet_detailed("  field 'shieldbox' has changed");
7275     DIO_PUT(uint32, &dout, "shieldbox", real_packet->shieldbox);
7276   }
7277   if (BV_ISSET(fields, 78)) {
7278     log_packet_detailed("  field 'skill_level' has changed");
7279     DIO_PUT(uint32, &dout, "skill_level", real_packet->skill_level);
7280   }
7281   /* field 79 is folded into the header */
7282   if (BV_ISSET(fields, 80)) {
7283     log_packet_detailed("  field 'victory_conditions' has changed");
7284     DIO_PUT(uint8, &dout, "victory_conditions", real_packet->victory_conditions);
7285   }
7286   /* field 81 is folded into the header */
7287   if (BV_ISSET(fields, 82)) {
7288     log_packet_detailed("  field 'tech' has changed");
7289     DIO_PUT(uint32, &dout, "tech", real_packet->tech);
7290   }
7291   if (BV_ISSET(fields, 83)) {
7292     log_packet_detailed("  field 'tech_cost_style' has changed");
7293     DIO_PUT(uint8, &dout, "tech_cost_style", real_packet->tech_cost_style);
7294   }
7295   if (BV_ISSET(fields, 84)) {
7296     log_packet_detailed("  field 'tech_leakage' has changed");
7297     DIO_PUT(uint8, &dout, "tech_leakage", real_packet->tech_leakage);
7298   }
7299   if (BV_ISSET(fields, 85)) {
7300     log_packet_detailed("  field 'tech_upkeep_divider' has changed");
7301     DIO_PUT(uint16, &dout, "tech_upkeep_divider", real_packet->tech_upkeep_divider);
7302   }
7303   if (BV_ISSET(fields, 86)) {
7304     log_packet_detailed("  field 'tech_upkeep_style' has changed");
7305     DIO_PUT(uint8, &dout, "tech_upkeep_style", real_packet->tech_upkeep_style);
7306   }
7307   if (BV_ISSET(fields, 87)) {
7308     log_packet_detailed("  field 'free_tech_method' has changed");
7309     DIO_PUT(uint8, &dout, "free_tech_method", real_packet->free_tech_method);
7310   }
7311   if (BV_ISSET(fields, 88)) {
7312     log_packet_detailed("  field 'gameloss_style' has changed");
7313     DIO_PUT(uint8, &dout, "gameloss_style", real_packet->gameloss_style);
7314   }
7315   if (BV_ISSET(fields, 89)) {
7316     log_packet_detailed("  field 'timeout' has changed");
7317     DIO_PUT(uint32, &dout, "timeout", real_packet->timeout);
7318   }
7319   if (BV_ISSET(fields, 90)) {
7320     log_packet_detailed("  field 'first_timeout' has changed");
7321     DIO_PUT(uint32, &dout, "first_timeout", real_packet->first_timeout);
7322   }
7323   /* field 91 is folded into the header */
7324   if (BV_ISSET(fields, 92)) {
7325     log_packet_detailed("  field 'trademindist' has changed");
7326     DIO_PUT(uint16, &dout, "trademindist", real_packet->trademindist);
7327   }
7328   /* field 93 is folded into the header */
7329   /* field 94 is folded into the header */
7330   /* field 95 is folded into the header */
7331   /* field 96 is folded into the header */
7332   if (BV_ISSET(fields, 97)) {
7333     log_packet_detailed("  field 'turn' has changed");
7334     DIO_PUT(sint16, &dout, "turn", real_packet->turn);
7335   }
7336   if (BV_ISSET(fields, 98)) {
7337     log_packet_detailed("  field 'warminglevel' has changed");
7338     DIO_PUT(uint32, &dout, "warminglevel", real_packet->warminglevel);
7339   }
7340   if (BV_ISSET(fields, 99)) {
7341     log_packet_detailed("  field 'year16' has changed");
7342     DIO_PUT(sint16, &dout, "year16", real_packet->year16);
7343   }
7344   if (BV_ISSET(fields, 100)) {
7345     log_packet_detailed("  field 'year32' has changed");
7346     DIO_PUT(sint32, &dout, "year32", real_packet->year32);
7347   }
7348   /* field 101 is folded into the header */
7349   if (BV_ISSET(fields, 102)) {
7350     log_packet_detailed("  field 'calendar_fragments' has changed");
7351     DIO_PUT(uint16, &dout, "calendar_fragments", real_packet->calendar_fragments);
7352   }
7353   if (BV_ISSET(fields, 103)) {
7354     log_packet_detailed("  field 'fragment_count' has changed");
7355     DIO_PUT(uint16, &dout, "fragment_count", real_packet->fragment_count);
7356   }
7357   if (BV_ISSET(fields, 104)) {
7358     log_packet_detailed("  field 'calendar_fragment_name' has changed");
7359 
7360     {
7361       int i;
7362 
7363       for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
7364         dio_put_string(&dout, real_packet->calendar_fragment_name[i]);
7365       }
7366     }
7367   }
7368   /* field 105 is folded into the header */
7369   /* field 106 is folded into the header */
7370 
7371   *old = *real_packet;
7372   SEND_PACKET_END(PACKET_GAME_INFO);
7373 }
7374 
7375 #define hash_packet_game_info_103 hash_const
7376 
7377 #define cmp_packet_game_info_103 cmp_const
7378 
7379 BV_DEFINE(packet_game_info_103_fields, 106);
7380 
receive_packet_game_info_103(struct connection * pc)7381 static struct packet_game_info *receive_packet_game_info_103(struct connection *pc)
7382 {
7383   packet_game_info_103_fields fields;
7384   struct packet_game_info *old;
7385   struct genhash **hash = pc->phs.received + PACKET_GAME_INFO;
7386   RECEIVE_PACKET_START(packet_game_info, real_packet);
7387 
7388   DIO_BV_GET(&din, fields);
7389 
7390   log_packet_detailed("packet_game_info_103: got info about ()");
7391 
7392   if (NULL == *hash) {
7393     *hash = genhash_new_full(hash_packet_game_info_103, cmp_packet_game_info_103,
7394                              NULL, NULL, NULL, free);
7395   }
7396 
7397   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
7398     *real_packet = *old;
7399   } else {
7400     log_packet_detailed("  no old info");
7401     memset(real_packet, 0, sizeof(*real_packet));
7402   }
7403 
7404   if (BV_ISSET(fields, 0)) {
7405     log_packet_detailed("  got field 'add_to_size_limit'");
7406     if (!DIO_GET(uint8, &din, "add_to_size_limit", &real_packet->add_to_size_limit)) {
7407       RECEIVE_PACKET_FIELD_ERROR(add_to_size_limit);
7408     }
7409   }
7410   if (BV_ISSET(fields, 1)) {
7411     log_packet_detailed("  got field 'aifill'");
7412     if (!DIO_GET(uint8, &din, "aifill", &real_packet->aifill)) {
7413       RECEIVE_PACKET_FIELD_ERROR(aifill);
7414     }
7415   }
7416   if (BV_ISSET(fields, 2)) {
7417     log_packet_detailed("  got field 'persistent_ready'");
7418     {
7419       int readin;
7420 
7421       if (!DIO_GET(uint8, &din, "persistent_ready", &readin)) {
7422         RECEIVE_PACKET_FIELD_ERROR(persistent_ready);
7423       }
7424       real_packet->persistent_ready = readin;
7425     }
7426   }
7427   if (BV_ISSET(fields, 3)) {
7428     log_packet_detailed("  got field 'airlifting_style'");
7429     {
7430       int readin;
7431 
7432       if (!DIO_GET(uint8, &din, "airlifting_style", &readin)) {
7433         RECEIVE_PACKET_FIELD_ERROR(airlifting_style);
7434       }
7435       real_packet->airlifting_style = readin;
7436     }
7437   }
7438   if (BV_ISSET(fields, 4)) {
7439     log_packet_detailed("  got field 'angrycitizen'");
7440     if (!DIO_GET(uint8, &din, "angrycitizen", &real_packet->angrycitizen)) {
7441       RECEIVE_PACKET_FIELD_ERROR(angrycitizen);
7442     }
7443   }
7444   if (BV_ISSET(fields, 5)) {
7445     log_packet_detailed("  got field 'base_pollution'");
7446     if (!DIO_GET(sint16, &din, "base_pollution", &real_packet->base_pollution)) {
7447       RECEIVE_PACKET_FIELD_ERROR(base_pollution);
7448     }
7449   }
7450   if (BV_ISSET(fields, 6)) {
7451     log_packet_detailed("  got field 'base_tech_cost'");
7452     if (!DIO_GET(uint8, &din, "base_tech_cost", &real_packet->base_tech_cost)) {
7453       RECEIVE_PACKET_FIELD_ERROR(base_tech_cost);
7454     }
7455   }
7456   if (BV_ISSET(fields, 7)) {
7457     log_packet_detailed("  got field 'border_city_radius_sq'");
7458     if (!DIO_GET(uint16, &din, "border_city_radius_sq", &real_packet->border_city_radius_sq)) {
7459       RECEIVE_PACKET_FIELD_ERROR(border_city_radius_sq);
7460     }
7461   }
7462   if (BV_ISSET(fields, 8)) {
7463     log_packet_detailed("  got field 'border_size_effect'");
7464     if (!DIO_GET(uint8, &din, "border_size_effect", &real_packet->border_size_effect)) {
7465       RECEIVE_PACKET_FIELD_ERROR(border_size_effect);
7466     }
7467   }
7468   if (BV_ISSET(fields, 9)) {
7469     log_packet_detailed("  got field 'border_city_permanent_radius_sq'");
7470     if (!DIO_GET(sint16, &din, "border_city_permanent_radius_sq", &real_packet->border_city_permanent_radius_sq)) {
7471       RECEIVE_PACKET_FIELD_ERROR(border_city_permanent_radius_sq);
7472     }
7473   }
7474   if (BV_ISSET(fields, 10)) {
7475     log_packet_detailed("  got field 'borders'");
7476     {
7477       int readin;
7478 
7479       if (!DIO_GET(uint8, &din, "borders", &readin)) {
7480         RECEIVE_PACKET_FIELD_ERROR(borders);
7481       }
7482       real_packet->borders = readin;
7483     }
7484   }
7485   if (BV_ISSET(fields, 11)) {
7486     log_packet_detailed("  got field 'base_bribe_cost'");
7487     if (!DIO_GET(uint32, &din, "base_bribe_cost", &real_packet->base_bribe_cost)) {
7488       RECEIVE_PACKET_FIELD_ERROR(base_bribe_cost);
7489     }
7490   }
7491   if (BV_ISSET(fields, 12)) {
7492     log_packet_detailed("  got field 'culture_vic_points'");
7493     if (!DIO_GET(uint32, &din, "culture_vic_points", &real_packet->culture_vic_points)) {
7494       RECEIVE_PACKET_FIELD_ERROR(culture_vic_points);
7495     }
7496   }
7497   if (BV_ISSET(fields, 13)) {
7498     log_packet_detailed("  got field 'culture_vic_lead'");
7499     if (!DIO_GET(uint16, &din, "culture_vic_lead", &real_packet->culture_vic_lead)) {
7500       RECEIVE_PACKET_FIELD_ERROR(culture_vic_lead);
7501     }
7502   }
7503   if (BV_ISSET(fields, 14)) {
7504     log_packet_detailed("  got field 'culture_migration_pml'");
7505     if (!DIO_GET(uint16, &din, "culture_migration_pml", &real_packet->culture_migration_pml)) {
7506       RECEIVE_PACKET_FIELD_ERROR(culture_migration_pml);
7507     }
7508   }
7509   real_packet->calendar_skip_0 = BV_ISSET(fields, 15);
7510   if (BV_ISSET(fields, 16)) {
7511     log_packet_detailed("  got field 'celebratesize'");
7512     if (!DIO_GET(uint8, &din, "celebratesize", &real_packet->celebratesize)) {
7513       RECEIVE_PACKET_FIELD_ERROR(celebratesize);
7514     }
7515   }
7516   real_packet->changable_tax = BV_ISSET(fields, 17);
7517   if (BV_ISSET(fields, 18)) {
7518     log_packet_detailed("  got field 'pop_report_zeroes'");
7519     if (!DIO_GET(uint8, &din, "pop_report_zeroes", &real_packet->pop_report_zeroes)) {
7520       RECEIVE_PACKET_FIELD_ERROR(pop_report_zeroes);
7521     }
7522   }
7523   real_packet->citizen_nationality = BV_ISSET(fields, 19);
7524   if (BV_ISSET(fields, 20)) {
7525     log_packet_detailed("  got field 'citizen_convert_speed'");
7526     if (!DIO_GET(uint16, &din, "citizen_convert_speed", &real_packet->citizen_convert_speed)) {
7527       RECEIVE_PACKET_FIELD_ERROR(citizen_convert_speed);
7528     }
7529   }
7530   if (BV_ISSET(fields, 21)) {
7531     log_packet_detailed("  got field 'citizen_partisans_pct'");
7532     if (!DIO_GET(uint8, &din, "citizen_partisans_pct", &real_packet->citizen_partisans_pct)) {
7533       RECEIVE_PACKET_FIELD_ERROR(citizen_partisans_pct);
7534     }
7535   }
7536   if (BV_ISSET(fields, 22)) {
7537     log_packet_detailed("  got field 'citymindist'");
7538     if (!DIO_GET(uint8, &din, "citymindist", &real_packet->citymindist)) {
7539       RECEIVE_PACKET_FIELD_ERROR(citymindist);
7540     }
7541   }
7542   if (BV_ISSET(fields, 23)) {
7543     log_packet_detailed("  got field 'cooling'");
7544     if (!DIO_GET(uint32, &din, "cooling", &real_packet->cooling)) {
7545       RECEIVE_PACKET_FIELD_ERROR(cooling);
7546     }
7547   }
7548   if (BV_ISSET(fields, 24)) {
7549     log_packet_detailed("  got field 'coolinglevel'");
7550     if (!DIO_GET(uint32, &din, "coolinglevel", &real_packet->coolinglevel)) {
7551       RECEIVE_PACKET_FIELD_ERROR(coolinglevel);
7552     }
7553   }
7554   if (BV_ISSET(fields, 25)) {
7555     log_packet_detailed("  got field 'diplomacy'");
7556     {
7557       int readin;
7558 
7559       if (!DIO_GET(uint8, &din, "diplomacy", &readin)) {
7560         RECEIVE_PACKET_FIELD_ERROR(diplomacy);
7561       }
7562       real_packet->diplomacy = readin;
7563     }
7564   }
7565   real_packet->fogofwar = BV_ISSET(fields, 26);
7566   if (BV_ISSET(fields, 27)) {
7567     log_packet_detailed("  got field 'food_cost'");
7568     if (!DIO_GET(uint8, &din, "food_cost", &real_packet->food_cost)) {
7569       RECEIVE_PACKET_FIELD_ERROR(food_cost);
7570     }
7571   }
7572   if (BV_ISSET(fields, 28)) {
7573     log_packet_detailed("  got field 'foodbox'");
7574     if (!DIO_GET(uint32, &din, "foodbox", &real_packet->foodbox)) {
7575       RECEIVE_PACKET_FIELD_ERROR(foodbox);
7576     }
7577   }
7578   if (BV_ISSET(fields, 29)) {
7579     log_packet_detailed("  got field 'forced_gold'");
7580     if (!DIO_GET(uint8, &din, "forced_gold", &real_packet->forced_gold)) {
7581       RECEIVE_PACKET_FIELD_ERROR(forced_gold);
7582     }
7583   }
7584   if (BV_ISSET(fields, 30)) {
7585     log_packet_detailed("  got field 'forced_luxury'");
7586     if (!DIO_GET(uint8, &din, "forced_luxury", &real_packet->forced_luxury)) {
7587       RECEIVE_PACKET_FIELD_ERROR(forced_luxury);
7588     }
7589   }
7590   if (BV_ISSET(fields, 31)) {
7591     log_packet_detailed("  got field 'forced_science'");
7592     if (!DIO_GET(uint8, &din, "forced_science", &real_packet->forced_science)) {
7593       RECEIVE_PACKET_FIELD_ERROR(forced_science);
7594     }
7595   }
7596   if (BV_ISSET(fields, 32)) {
7597     log_packet_detailed("  got field 'fulltradesize'");
7598     if (!DIO_GET(uint8, &din, "fulltradesize", &real_packet->fulltradesize)) {
7599       RECEIVE_PACKET_FIELD_ERROR(fulltradesize);
7600     }
7601   }
7602   if (BV_ISSET(fields, 33)) {
7603     log_packet_detailed("  got field 'global_advances'");
7604 
7605     for (;;) {
7606       int i;
7607 
7608       if (!DIO_GET(uint8, &din, "global_advances", &i)) {
7609         RECEIVE_PACKET_FIELD_ERROR(global_advances);
7610       }
7611       if (i == 255) {
7612         break;
7613       }
7614       if (i > A_LAST) {
7615         RECEIVE_PACKET_FIELD_ERROR(global_advances,
7616                                    ": unexpected value %d "
7617                                    "(> A_LAST) in array diff",
7618                                    i);
7619       } else {
7620         if (!DIO_GET(bool8, &din, "global_advances", &real_packet->global_advances[i])) {
7621           RECEIVE_PACKET_FIELD_ERROR(global_advances);
7622         }
7623       }
7624     }
7625   }
7626   real_packet->global_warming = BV_ISSET(fields, 34);
7627   if (BV_ISSET(fields, 35)) {
7628     log_packet_detailed("  got field 'globalwarming'");
7629     if (!DIO_GET(uint32, &din, "globalwarming", &real_packet->globalwarming)) {
7630       RECEIVE_PACKET_FIELD_ERROR(globalwarming);
7631     }
7632   }
7633   if (BV_ISSET(fields, 36)) {
7634     log_packet_detailed("  got field 'gold'");
7635     if (!DIO_GET(uint32, &din, "gold", &real_packet->gold)) {
7636       RECEIVE_PACKET_FIELD_ERROR(gold);
7637     }
7638   }
7639   if (BV_ISSET(fields, 37)) {
7640     log_packet_detailed("  got field 'gold_upkeep_style'");
7641     {
7642       int readin;
7643 
7644       if (!DIO_GET(uint8, &din, "gold_upkeep_style", &readin)) {
7645         RECEIVE_PACKET_FIELD_ERROR(gold_upkeep_style);
7646       }
7647       real_packet->gold_upkeep_style = readin;
7648     }
7649   }
7650   if (BV_ISSET(fields, 38)) {
7651     log_packet_detailed("  got field 'revolentype'");
7652     {
7653       int readin;
7654 
7655       if (!DIO_GET(uint8, &din, "revolentype", &readin)) {
7656         RECEIVE_PACKET_FIELD_ERROR(revolentype);
7657       }
7658       real_packet->revolentype = readin;
7659     }
7660   }
7661   if (BV_ISSET(fields, 39)) {
7662     log_packet_detailed("  got field 'default_government_id'");
7663     {
7664       int readin;
7665 
7666       if (!DIO_GET(sint8, &din, "default_government_id", &readin)) {
7667         RECEIVE_PACKET_FIELD_ERROR(default_government_id);
7668       }
7669       real_packet->default_government_id = readin;
7670     }
7671   }
7672   if (BV_ISSET(fields, 40)) {
7673     log_packet_detailed("  got field 'government_during_revolution_id'");
7674     {
7675       int readin;
7676 
7677       if (!DIO_GET(sint8, &din, "government_during_revolution_id", &readin)) {
7678         RECEIVE_PACKET_FIELD_ERROR(government_during_revolution_id);
7679       }
7680       real_packet->government_during_revolution_id = readin;
7681     }
7682   }
7683   if (BV_ISSET(fields, 41)) {
7684     log_packet_detailed("  got field 'granary_food_inc'");
7685     if (!DIO_GET(uint8, &din, "granary_food_inc", &real_packet->granary_food_inc)) {
7686       RECEIVE_PACKET_FIELD_ERROR(granary_food_inc);
7687     }
7688   }
7689   if (BV_ISSET(fields, 42)) {
7690     log_packet_detailed("  got field 'granary_food_ini'");
7691 
7692     {
7693       int i;
7694 
7695       for (i = 0; i < MAX_GRANARY_INIS; i++) {
7696         if (!DIO_GET(uint8, &din, "granary_food_ini", &real_packet->granary_food_ini[i])) {
7697           RECEIVE_PACKET_FIELD_ERROR(granary_food_ini);
7698         }
7699       }
7700     }
7701   }
7702   if (BV_ISSET(fields, 43)) {
7703     log_packet_detailed("  got field 'granary_num_inis'");
7704     if (!DIO_GET(uint8, &din, "granary_num_inis", &real_packet->granary_num_inis)) {
7705       RECEIVE_PACKET_FIELD_ERROR(granary_num_inis);
7706     }
7707   }
7708   if (BV_ISSET(fields, 44)) {
7709     log_packet_detailed("  got field 'great_wonder_owners'");
7710 
7711     for (;;) {
7712       int i;
7713 
7714       if (!DIO_GET(uint8, &din, "great_wonder_owners", &i)) {
7715         RECEIVE_PACKET_FIELD_ERROR(great_wonder_owners);
7716       }
7717       if (i == 255) {
7718         break;
7719       }
7720       if (i > B_LAST) {
7721         RECEIVE_PACKET_FIELD_ERROR(great_wonder_owners,
7722                                    ": unexpected value %d "
7723                                    "(> B_LAST) in array diff",
7724                                    i);
7725       } else {
7726         if (!DIO_GET(uint8, &din, "great_wonder_owners", &real_packet->great_wonder_owners[i])) {
7727           RECEIVE_PACKET_FIELD_ERROR(great_wonder_owners);
7728         }
7729       }
7730     }
7731   }
7732   if (BV_ISSET(fields, 45)) {
7733     log_packet_detailed("  got field 'happy_cost'");
7734     if (!DIO_GET(uint8, &din, "happy_cost", &real_packet->happy_cost)) {
7735       RECEIVE_PACKET_FIELD_ERROR(happy_cost);
7736     }
7737   }
7738   if (BV_ISSET(fields, 46)) {
7739     log_packet_detailed("  got field 'happyborders'");
7740     {
7741       int readin;
7742 
7743       if (!DIO_GET(uint8, &din, "happyborders", &readin)) {
7744         RECEIVE_PACKET_FIELD_ERROR(happyborders);
7745       }
7746       real_packet->happyborders = readin;
7747     }
7748   }
7749   if (BV_ISSET(fields, 47)) {
7750     log_packet_detailed("  got field 'heating'");
7751     if (!DIO_GET(uint32, &din, "heating", &real_packet->heating)) {
7752       RECEIVE_PACKET_FIELD_ERROR(heating);
7753     }
7754   }
7755   if (BV_ISSET(fields, 48)) {
7756     log_packet_detailed("  got field 'illness_base_factor'");
7757     if (!DIO_GET(uint16, &din, "illness_base_factor", &real_packet->illness_base_factor)) {
7758       RECEIVE_PACKET_FIELD_ERROR(illness_base_factor);
7759     }
7760   }
7761   if (BV_ISSET(fields, 49)) {
7762     log_packet_detailed("  got field 'illness_min_size'");
7763     if (!DIO_GET(uint8, &din, "illness_min_size", &real_packet->illness_min_size)) {
7764       RECEIVE_PACKET_FIELD_ERROR(illness_min_size);
7765     }
7766   }
7767   real_packet->illness_on = BV_ISSET(fields, 50);
7768   if (BV_ISSET(fields, 51)) {
7769     log_packet_detailed("  got field 'illness_pollution_factor'");
7770     if (!DIO_GET(uint16, &din, "illness_pollution_factor", &real_packet->illness_pollution_factor)) {
7771       RECEIVE_PACKET_FIELD_ERROR(illness_pollution_factor);
7772     }
7773   }
7774   if (BV_ISSET(fields, 52)) {
7775     log_packet_detailed("  got field 'illness_trade_infection'");
7776     if (!DIO_GET(uint16, &din, "illness_trade_infection", &real_packet->illness_trade_infection)) {
7777       RECEIVE_PACKET_FIELD_ERROR(illness_trade_infection);
7778     }
7779   }
7780   if (BV_ISSET(fields, 53)) {
7781     log_packet_detailed("  got field 'init_city_radius_sq'");
7782     if (!DIO_GET(uint8, &din, "init_city_radius_sq", &real_packet->init_city_radius_sq)) {
7783       RECEIVE_PACKET_FIELD_ERROR(init_city_radius_sq);
7784     }
7785   }
7786   real_packet->is_edit_mode = BV_ISSET(fields, 54);
7787   real_packet->is_new_game = BV_ISSET(fields, 55);
7788   real_packet->killcitizen = BV_ISSET(fields, 56);
7789   real_packet->killstack = BV_ISSET(fields, 57);
7790   if (BV_ISSET(fields, 58)) {
7791     log_packet_detailed("  got field 'min_city_center_output'");
7792 
7793     {
7794       int i;
7795 
7796       for (i = 0; i < O_LAST; i++) {
7797         if (!DIO_GET(uint8, &din, "min_city_center_output", &real_packet->min_city_center_output[i])) {
7798           RECEIVE_PACKET_FIELD_ERROR(min_city_center_output);
7799         }
7800       }
7801     }
7802   }
7803   if (BV_ISSET(fields, 59)) {
7804     log_packet_detailed("  got field 'negative_year_label'");
7805     if (!DIO_GET(string, &din, "negative_year_label", real_packet->negative_year_label, sizeof(real_packet->negative_year_label))) {
7806       RECEIVE_PACKET_FIELD_ERROR(negative_year_label);
7807     }
7808   }
7809   if (BV_ISSET(fields, 60)) {
7810     log_packet_detailed("  got field 'notradesize'");
7811     if (!DIO_GET(uint8, &din, "notradesize", &real_packet->notradesize)) {
7812       RECEIVE_PACKET_FIELD_ERROR(notradesize);
7813     }
7814   }
7815   real_packet->nuclear_winter = BV_ISSET(fields, 61);
7816   if (BV_ISSET(fields, 62)) {
7817     log_packet_detailed("  got field 'nuclearwinter'");
7818     if (!DIO_GET(uint32, &din, "nuclearwinter", &real_packet->nuclearwinter)) {
7819       RECEIVE_PACKET_FIELD_ERROR(nuclearwinter);
7820     }
7821   }
7822   if (BV_ISSET(fields, 63)) {
7823     log_packet_detailed("  got field 'phase'");
7824     if (!DIO_GET(sint16, &din, "phase", &real_packet->phase)) {
7825       RECEIVE_PACKET_FIELD_ERROR(phase);
7826     }
7827   }
7828   if (BV_ISSET(fields, 64)) {
7829     log_packet_detailed("  got field 'phase_mode'");
7830     {
7831       int readin;
7832 
7833       if (!DIO_GET(uint8, &din, "phase_mode", &readin)) {
7834         RECEIVE_PACKET_FIELD_ERROR(phase_mode);
7835       }
7836       real_packet->phase_mode = readin;
7837     }
7838   }
7839   real_packet->pillage_select = BV_ISSET(fields, 65);
7840   real_packet->tech_steal_allow_holes = BV_ISSET(fields, 66);
7841   real_packet->tech_trade_allow_holes = BV_ISSET(fields, 67);
7842   real_packet->tech_trade_loss_allow_holes = BV_ISSET(fields, 68);
7843   real_packet->tech_parasite_allow_holes = BV_ISSET(fields, 69);
7844   real_packet->tech_loss_allow_holes = BV_ISSET(fields, 70);
7845   if (BV_ISSET(fields, 71)) {
7846     log_packet_detailed("  got field 'positive_year_label'");
7847     if (!DIO_GET(string, &din, "positive_year_label", real_packet->positive_year_label, sizeof(real_packet->positive_year_label))) {
7848       RECEIVE_PACKET_FIELD_ERROR(positive_year_label);
7849     }
7850   }
7851   if (BV_ISSET(fields, 72)) {
7852     log_packet_detailed("  got field 'rapturedelay'");
7853     if (!DIO_GET(uint8, &din, "rapturedelay", &real_packet->rapturedelay)) {
7854       RECEIVE_PACKET_FIELD_ERROR(rapturedelay);
7855     }
7856   }
7857   if (BV_ISSET(fields, 73)) {
7858     log_packet_detailed("  got field 'disasters'");
7859     if (!DIO_GET(uint16, &din, "disasters", &real_packet->disasters)) {
7860       RECEIVE_PACKET_FIELD_ERROR(disasters);
7861     }
7862   }
7863   real_packet->restrictinfra = BV_ISSET(fields, 74);
7864   real_packet->unreachable_protects = BV_ISSET(fields, 75);
7865   if (BV_ISSET(fields, 76)) {
7866     log_packet_detailed("  got field 'sciencebox'");
7867     if (!DIO_GET(uint32, &din, "sciencebox", &real_packet->sciencebox)) {
7868       RECEIVE_PACKET_FIELD_ERROR(sciencebox);
7869     }
7870   }
7871   if (BV_ISSET(fields, 77)) {
7872     log_packet_detailed("  got field 'shieldbox'");
7873     if (!DIO_GET(uint32, &din, "shieldbox", &real_packet->shieldbox)) {
7874       RECEIVE_PACKET_FIELD_ERROR(shieldbox);
7875     }
7876   }
7877   if (BV_ISSET(fields, 78)) {
7878     log_packet_detailed("  got field 'skill_level'");
7879     if (!DIO_GET(uint32, &din, "skill_level", &real_packet->skill_level)) {
7880       RECEIVE_PACKET_FIELD_ERROR(skill_level);
7881     }
7882   }
7883   real_packet->slow_invasions = BV_ISSET(fields, 79);
7884   if (BV_ISSET(fields, 80)) {
7885     log_packet_detailed("  got field 'victory_conditions'");
7886     {
7887       int readin;
7888 
7889       if (!DIO_GET(uint8, &din, "victory_conditions", &readin)) {
7890         RECEIVE_PACKET_FIELD_ERROR(victory_conditions);
7891       }
7892       real_packet->victory_conditions = readin;
7893     }
7894   }
7895   real_packet->team_pooled_research = BV_ISSET(fields, 81);
7896   if (BV_ISSET(fields, 82)) {
7897     log_packet_detailed("  got field 'tech'");
7898     if (!DIO_GET(uint32, &din, "tech", &real_packet->tech)) {
7899       RECEIVE_PACKET_FIELD_ERROR(tech);
7900     }
7901   }
7902   if (BV_ISSET(fields, 83)) {
7903     log_packet_detailed("  got field 'tech_cost_style'");
7904     {
7905       int readin;
7906 
7907       if (!DIO_GET(uint8, &din, "tech_cost_style", &readin)) {
7908         RECEIVE_PACKET_FIELD_ERROR(tech_cost_style);
7909       }
7910       real_packet->tech_cost_style = readin;
7911     }
7912   }
7913   if (BV_ISSET(fields, 84)) {
7914     log_packet_detailed("  got field 'tech_leakage'");
7915     {
7916       int readin;
7917 
7918       if (!DIO_GET(uint8, &din, "tech_leakage", &readin)) {
7919         RECEIVE_PACKET_FIELD_ERROR(tech_leakage);
7920       }
7921       real_packet->tech_leakage = readin;
7922     }
7923   }
7924   if (BV_ISSET(fields, 85)) {
7925     log_packet_detailed("  got field 'tech_upkeep_divider'");
7926     if (!DIO_GET(uint16, &din, "tech_upkeep_divider", &real_packet->tech_upkeep_divider)) {
7927       RECEIVE_PACKET_FIELD_ERROR(tech_upkeep_divider);
7928     }
7929   }
7930   if (BV_ISSET(fields, 86)) {
7931     log_packet_detailed("  got field 'tech_upkeep_style'");
7932     {
7933       int readin;
7934 
7935       if (!DIO_GET(uint8, &din, "tech_upkeep_style", &readin)) {
7936         RECEIVE_PACKET_FIELD_ERROR(tech_upkeep_style);
7937       }
7938       real_packet->tech_upkeep_style = readin;
7939     }
7940   }
7941   if (BV_ISSET(fields, 87)) {
7942     log_packet_detailed("  got field 'free_tech_method'");
7943     {
7944       int readin;
7945 
7946       if (!DIO_GET(uint8, &din, "free_tech_method", &readin)) {
7947         RECEIVE_PACKET_FIELD_ERROR(free_tech_method);
7948       }
7949       real_packet->free_tech_method = readin;
7950     }
7951   }
7952   if (BV_ISSET(fields, 88)) {
7953     log_packet_detailed("  got field 'gameloss_style'");
7954     {
7955       int readin;
7956 
7957       if (!DIO_GET(uint8, &din, "gameloss_style", &readin)) {
7958         RECEIVE_PACKET_FIELD_ERROR(gameloss_style);
7959       }
7960       real_packet->gameloss_style = readin;
7961     }
7962   }
7963   if (BV_ISSET(fields, 89)) {
7964     log_packet_detailed("  got field 'timeout'");
7965     if (!DIO_GET(uint32, &din, "timeout", &real_packet->timeout)) {
7966       RECEIVE_PACKET_FIELD_ERROR(timeout);
7967     }
7968   }
7969   if (BV_ISSET(fields, 90)) {
7970     log_packet_detailed("  got field 'first_timeout'");
7971     if (!DIO_GET(uint32, &din, "first_timeout", &real_packet->first_timeout)) {
7972       RECEIVE_PACKET_FIELD_ERROR(first_timeout);
7973     }
7974   }
7975   real_packet->tired_attack = BV_ISSET(fields, 91);
7976   if (BV_ISSET(fields, 92)) {
7977     log_packet_detailed("  got field 'trademindist'");
7978     if (!DIO_GET(uint16, &din, "trademindist", &real_packet->trademindist)) {
7979       RECEIVE_PACKET_FIELD_ERROR(trademindist);
7980     }
7981   }
7982   real_packet->force_trade_route = BV_ISSET(fields, 93);
7983   real_packet->trading_city = BV_ISSET(fields, 94);
7984   real_packet->trading_gold = BV_ISSET(fields, 95);
7985   real_packet->trading_tech = BV_ISSET(fields, 96);
7986   if (BV_ISSET(fields, 97)) {
7987     log_packet_detailed("  got field 'turn'");
7988     if (!DIO_GET(sint16, &din, "turn", &real_packet->turn)) {
7989       RECEIVE_PACKET_FIELD_ERROR(turn);
7990     }
7991   }
7992   if (BV_ISSET(fields, 98)) {
7993     log_packet_detailed("  got field 'warminglevel'");
7994     if (!DIO_GET(uint32, &din, "warminglevel", &real_packet->warminglevel)) {
7995       RECEIVE_PACKET_FIELD_ERROR(warminglevel);
7996     }
7997   }
7998   if (BV_ISSET(fields, 99)) {
7999     log_packet_detailed("  got field 'year16'");
8000     if (!DIO_GET(sint16, &din, "year16", &real_packet->year16)) {
8001       RECEIVE_PACKET_FIELD_ERROR(year16);
8002     }
8003   }
8004   real_packet->year_0_hack = BV_ISSET(fields, 100);
8005   if (BV_ISSET(fields, 101)) {
8006     log_packet_detailed("  got field 'calendar_fragments'");
8007     if (!DIO_GET(uint16, &din, "calendar_fragments", &real_packet->calendar_fragments)) {
8008       RECEIVE_PACKET_FIELD_ERROR(calendar_fragments);
8009     }
8010   }
8011   if (BV_ISSET(fields, 102)) {
8012     log_packet_detailed("  got field 'fragment_count'");
8013     if (!DIO_GET(uint16, &din, "fragment_count", &real_packet->fragment_count)) {
8014       RECEIVE_PACKET_FIELD_ERROR(fragment_count);
8015     }
8016   }
8017   if (BV_ISSET(fields, 103)) {
8018     log_packet_detailed("  got field 'calendar_fragment_name'");
8019 
8020     {
8021       int i;
8022 
8023       for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
8024         if (!DIO_GET(string, &din, "calendar_fragment_name", real_packet->calendar_fragment_name[i], sizeof(real_packet->calendar_fragment_name[i]))) {
8025           RECEIVE_PACKET_FIELD_ERROR(calendar_fragment_name);
8026         }
8027       }
8028     }
8029   }
8030   real_packet->civil_war_enabled = BV_ISSET(fields, 104);
8031   real_packet->paradrop_to_transport = BV_ISSET(fields, 105);
8032 
8033   if (NULL == old) {
8034     old = fc_malloc(sizeof(*old));
8035     *old = *real_packet;
8036     genhash_insert(*hash, old, old);
8037   } else {
8038     *old = *real_packet;
8039   }
8040   RECEIVE_PACKET_END(real_packet);
8041 }
8042 
send_packet_game_info_103(struct connection * pc,const struct packet_game_info * packet)8043 static int send_packet_game_info_103(struct connection *pc, const struct packet_game_info *packet)
8044 {
8045   const struct packet_game_info *real_packet = packet;
8046   packet_game_info_103_fields fields;
8047   struct packet_game_info *old;
8048   bool differ;
8049   struct genhash **hash = pc->phs.sent + PACKET_GAME_INFO;
8050   int different = 0;
8051   SEND_PACKET_START(PACKET_GAME_INFO);
8052 
8053   log_packet_detailed("packet_game_info_103: sending info about ()");
8054 
8055   if (NULL == *hash) {
8056     *hash = genhash_new_full(hash_packet_game_info_103, cmp_packet_game_info_103,
8057                              NULL, NULL, NULL, free);
8058   }
8059   BV_CLR_ALL(fields);
8060 
8061   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
8062     old = fc_malloc(sizeof(*old));
8063     *old = *real_packet;
8064     genhash_insert(*hash, old, old);
8065     memset(old, 0, sizeof(*old));
8066     different = 1;      /* Force to send. */
8067   }
8068 
8069   differ = (old->add_to_size_limit != real_packet->add_to_size_limit);
8070   if (differ) {
8071     different++;
8072     BV_SET(fields, 0);
8073   }
8074 
8075   differ = (old->aifill != real_packet->aifill);
8076   if (differ) {
8077     different++;
8078     BV_SET(fields, 1);
8079   }
8080 
8081   differ = (old->persistent_ready != real_packet->persistent_ready);
8082   if (differ) {
8083     different++;
8084     BV_SET(fields, 2);
8085   }
8086 
8087   differ = (old->airlifting_style != real_packet->airlifting_style);
8088   if (differ) {
8089     different++;
8090     BV_SET(fields, 3);
8091   }
8092 
8093   differ = (old->angrycitizen != real_packet->angrycitizen);
8094   if (differ) {
8095     different++;
8096     BV_SET(fields, 4);
8097   }
8098 
8099   differ = (old->base_pollution != real_packet->base_pollution);
8100   if (differ) {
8101     different++;
8102     BV_SET(fields, 5);
8103   }
8104 
8105   differ = (old->base_tech_cost != real_packet->base_tech_cost);
8106   if (differ) {
8107     different++;
8108     BV_SET(fields, 6);
8109   }
8110 
8111   differ = (old->border_city_radius_sq != real_packet->border_city_radius_sq);
8112   if (differ) {
8113     different++;
8114     BV_SET(fields, 7);
8115   }
8116 
8117   differ = (old->border_size_effect != real_packet->border_size_effect);
8118   if (differ) {
8119     different++;
8120     BV_SET(fields, 8);
8121   }
8122 
8123   differ = (old->border_city_permanent_radius_sq != real_packet->border_city_permanent_radius_sq);
8124   if (differ) {
8125     different++;
8126     BV_SET(fields, 9);
8127   }
8128 
8129   differ = (old->borders != real_packet->borders);
8130   if (differ) {
8131     different++;
8132     BV_SET(fields, 10);
8133   }
8134 
8135   differ = (old->base_bribe_cost != real_packet->base_bribe_cost);
8136   if (differ) {
8137     different++;
8138     BV_SET(fields, 11);
8139   }
8140 
8141   differ = (old->culture_vic_points != real_packet->culture_vic_points);
8142   if (differ) {
8143     different++;
8144     BV_SET(fields, 12);
8145   }
8146 
8147   differ = (old->culture_vic_lead != real_packet->culture_vic_lead);
8148   if (differ) {
8149     different++;
8150     BV_SET(fields, 13);
8151   }
8152 
8153   differ = (old->culture_migration_pml != real_packet->culture_migration_pml);
8154   if (differ) {
8155     different++;
8156     BV_SET(fields, 14);
8157   }
8158 
8159   differ = (old->calendar_skip_0 != real_packet->calendar_skip_0);
8160   if (differ) {
8161     different++;
8162   }
8163   if (packet->calendar_skip_0) {
8164     BV_SET(fields, 15);
8165   }
8166 
8167   differ = (old->celebratesize != real_packet->celebratesize);
8168   if (differ) {
8169     different++;
8170     BV_SET(fields, 16);
8171   }
8172 
8173   differ = (old->changable_tax != real_packet->changable_tax);
8174   if (differ) {
8175     different++;
8176   }
8177   if (packet->changable_tax) {
8178     BV_SET(fields, 17);
8179   }
8180 
8181   differ = (old->pop_report_zeroes != real_packet->pop_report_zeroes);
8182   if (differ) {
8183     different++;
8184     BV_SET(fields, 18);
8185   }
8186 
8187   differ = (old->citizen_nationality != real_packet->citizen_nationality);
8188   if (differ) {
8189     different++;
8190   }
8191   if (packet->citizen_nationality) {
8192     BV_SET(fields, 19);
8193   }
8194 
8195   differ = (old->citizen_convert_speed != real_packet->citizen_convert_speed);
8196   if (differ) {
8197     different++;
8198     BV_SET(fields, 20);
8199   }
8200 
8201   differ = (old->citizen_partisans_pct != real_packet->citizen_partisans_pct);
8202   if (differ) {
8203     different++;
8204     BV_SET(fields, 21);
8205   }
8206 
8207   differ = (old->citymindist != real_packet->citymindist);
8208   if (differ) {
8209     different++;
8210     BV_SET(fields, 22);
8211   }
8212 
8213   differ = (old->cooling != real_packet->cooling);
8214   if (differ) {
8215     different++;
8216     BV_SET(fields, 23);
8217   }
8218 
8219   differ = (old->coolinglevel != real_packet->coolinglevel);
8220   if (differ) {
8221     different++;
8222     BV_SET(fields, 24);
8223   }
8224 
8225   differ = (old->diplomacy != real_packet->diplomacy);
8226   if (differ) {
8227     different++;
8228     BV_SET(fields, 25);
8229   }
8230 
8231   differ = (old->fogofwar != real_packet->fogofwar);
8232   if (differ) {
8233     different++;
8234   }
8235   if (packet->fogofwar) {
8236     BV_SET(fields, 26);
8237   }
8238 
8239   differ = (old->food_cost != real_packet->food_cost);
8240   if (differ) {
8241     different++;
8242     BV_SET(fields, 27);
8243   }
8244 
8245   differ = (old->foodbox != real_packet->foodbox);
8246   if (differ) {
8247     different++;
8248     BV_SET(fields, 28);
8249   }
8250 
8251   differ = (old->forced_gold != real_packet->forced_gold);
8252   if (differ) {
8253     different++;
8254     BV_SET(fields, 29);
8255   }
8256 
8257   differ = (old->forced_luxury != real_packet->forced_luxury);
8258   if (differ) {
8259     different++;
8260     BV_SET(fields, 30);
8261   }
8262 
8263   differ = (old->forced_science != real_packet->forced_science);
8264   if (differ) {
8265     different++;
8266     BV_SET(fields, 31);
8267   }
8268 
8269   differ = (old->fulltradesize != real_packet->fulltradesize);
8270   if (differ) {
8271     different++;
8272     BV_SET(fields, 32);
8273   }
8274 
8275 
8276     {
8277       differ = (A_LAST != A_LAST);
8278       if (!differ) {
8279         int i;
8280 
8281         for (i = 0; i < A_LAST; i++) {
8282           if (old->global_advances[i] != real_packet->global_advances[i]) {
8283             differ = TRUE;
8284             break;
8285           }
8286         }
8287       }
8288     }
8289   if (differ) {
8290     different++;
8291     BV_SET(fields, 33);
8292   }
8293 
8294   differ = (old->global_warming != real_packet->global_warming);
8295   if (differ) {
8296     different++;
8297   }
8298   if (packet->global_warming) {
8299     BV_SET(fields, 34);
8300   }
8301 
8302   differ = (old->globalwarming != real_packet->globalwarming);
8303   if (differ) {
8304     different++;
8305     BV_SET(fields, 35);
8306   }
8307 
8308   differ = (old->gold != real_packet->gold);
8309   if (differ) {
8310     different++;
8311     BV_SET(fields, 36);
8312   }
8313 
8314   differ = (old->gold_upkeep_style != real_packet->gold_upkeep_style);
8315   if (differ) {
8316     different++;
8317     BV_SET(fields, 37);
8318   }
8319 
8320   differ = (old->revolentype != real_packet->revolentype);
8321   if (differ) {
8322     different++;
8323     BV_SET(fields, 38);
8324   }
8325 
8326   differ = (old->default_government_id != real_packet->default_government_id);
8327   if (differ) {
8328     different++;
8329     BV_SET(fields, 39);
8330   }
8331 
8332   differ = (old->government_during_revolution_id != real_packet->government_during_revolution_id);
8333   if (differ) {
8334     different++;
8335     BV_SET(fields, 40);
8336   }
8337 
8338   differ = (old->granary_food_inc != real_packet->granary_food_inc);
8339   if (differ) {
8340     different++;
8341     BV_SET(fields, 41);
8342   }
8343 
8344 
8345     {
8346       differ = (MAX_GRANARY_INIS != MAX_GRANARY_INIS);
8347       if (!differ) {
8348         int i;
8349 
8350         for (i = 0; i < MAX_GRANARY_INIS; i++) {
8351           if (old->granary_food_ini[i] != real_packet->granary_food_ini[i]) {
8352             differ = TRUE;
8353             break;
8354           }
8355         }
8356       }
8357     }
8358   if (differ) {
8359     different++;
8360     BV_SET(fields, 42);
8361   }
8362 
8363   differ = (old->granary_num_inis != real_packet->granary_num_inis);
8364   if (differ) {
8365     different++;
8366     BV_SET(fields, 43);
8367   }
8368 
8369 
8370     {
8371       differ = (B_LAST != B_LAST);
8372       if (!differ) {
8373         int i;
8374 
8375         for (i = 0; i < B_LAST; i++) {
8376           if (old->great_wonder_owners[i] != real_packet->great_wonder_owners[i]) {
8377             differ = TRUE;
8378             break;
8379           }
8380         }
8381       }
8382     }
8383   if (differ) {
8384     different++;
8385     BV_SET(fields, 44);
8386   }
8387 
8388   differ = (old->happy_cost != real_packet->happy_cost);
8389   if (differ) {
8390     different++;
8391     BV_SET(fields, 45);
8392   }
8393 
8394   differ = (old->happyborders != real_packet->happyborders);
8395   if (differ) {
8396     different++;
8397     BV_SET(fields, 46);
8398   }
8399 
8400   differ = (old->heating != real_packet->heating);
8401   if (differ) {
8402     different++;
8403     BV_SET(fields, 47);
8404   }
8405 
8406   differ = (old->illness_base_factor != real_packet->illness_base_factor);
8407   if (differ) {
8408     different++;
8409     BV_SET(fields, 48);
8410   }
8411 
8412   differ = (old->illness_min_size != real_packet->illness_min_size);
8413   if (differ) {
8414     different++;
8415     BV_SET(fields, 49);
8416   }
8417 
8418   differ = (old->illness_on != real_packet->illness_on);
8419   if (differ) {
8420     different++;
8421   }
8422   if (packet->illness_on) {
8423     BV_SET(fields, 50);
8424   }
8425 
8426   differ = (old->illness_pollution_factor != real_packet->illness_pollution_factor);
8427   if (differ) {
8428     different++;
8429     BV_SET(fields, 51);
8430   }
8431 
8432   differ = (old->illness_trade_infection != real_packet->illness_trade_infection);
8433   if (differ) {
8434     different++;
8435     BV_SET(fields, 52);
8436   }
8437 
8438   differ = (old->init_city_radius_sq != real_packet->init_city_radius_sq);
8439   if (differ) {
8440     different++;
8441     BV_SET(fields, 53);
8442   }
8443 
8444   differ = (old->is_edit_mode != real_packet->is_edit_mode);
8445   if (differ) {
8446     different++;
8447   }
8448   if (packet->is_edit_mode) {
8449     BV_SET(fields, 54);
8450   }
8451 
8452   differ = (old->is_new_game != real_packet->is_new_game);
8453   if (differ) {
8454     different++;
8455   }
8456   if (packet->is_new_game) {
8457     BV_SET(fields, 55);
8458   }
8459 
8460   differ = (old->killcitizen != real_packet->killcitizen);
8461   if (differ) {
8462     different++;
8463   }
8464   if (packet->killcitizen) {
8465     BV_SET(fields, 56);
8466   }
8467 
8468   differ = (old->killstack != real_packet->killstack);
8469   if (differ) {
8470     different++;
8471   }
8472   if (packet->killstack) {
8473     BV_SET(fields, 57);
8474   }
8475 
8476 
8477     {
8478       differ = (O_LAST != O_LAST);
8479       if (!differ) {
8480         int i;
8481 
8482         for (i = 0; i < O_LAST; i++) {
8483           if (old->min_city_center_output[i] != real_packet->min_city_center_output[i]) {
8484             differ = TRUE;
8485             break;
8486           }
8487         }
8488       }
8489     }
8490   if (differ) {
8491     different++;
8492     BV_SET(fields, 58);
8493   }
8494 
8495   differ = (strcmp(old->negative_year_label, real_packet->negative_year_label) != 0);
8496   if (differ) {
8497     different++;
8498     BV_SET(fields, 59);
8499   }
8500 
8501   differ = (old->notradesize != real_packet->notradesize);
8502   if (differ) {
8503     different++;
8504     BV_SET(fields, 60);
8505   }
8506 
8507   differ = (old->nuclear_winter != real_packet->nuclear_winter);
8508   if (differ) {
8509     different++;
8510   }
8511   if (packet->nuclear_winter) {
8512     BV_SET(fields, 61);
8513   }
8514 
8515   differ = (old->nuclearwinter != real_packet->nuclearwinter);
8516   if (differ) {
8517     different++;
8518     BV_SET(fields, 62);
8519   }
8520 
8521   differ = (old->phase != real_packet->phase);
8522   if (differ) {
8523     different++;
8524     BV_SET(fields, 63);
8525   }
8526 
8527   differ = (old->phase_mode != real_packet->phase_mode);
8528   if (differ) {
8529     different++;
8530     BV_SET(fields, 64);
8531   }
8532 
8533   differ = (old->pillage_select != real_packet->pillage_select);
8534   if (differ) {
8535     different++;
8536   }
8537   if (packet->pillage_select) {
8538     BV_SET(fields, 65);
8539   }
8540 
8541   differ = (old->tech_steal_allow_holes != real_packet->tech_steal_allow_holes);
8542   if (differ) {
8543     different++;
8544   }
8545   if (packet->tech_steal_allow_holes) {
8546     BV_SET(fields, 66);
8547   }
8548 
8549   differ = (old->tech_trade_allow_holes != real_packet->tech_trade_allow_holes);
8550   if (differ) {
8551     different++;
8552   }
8553   if (packet->tech_trade_allow_holes) {
8554     BV_SET(fields, 67);
8555   }
8556 
8557   differ = (old->tech_trade_loss_allow_holes != real_packet->tech_trade_loss_allow_holes);
8558   if (differ) {
8559     different++;
8560   }
8561   if (packet->tech_trade_loss_allow_holes) {
8562     BV_SET(fields, 68);
8563   }
8564 
8565   differ = (old->tech_parasite_allow_holes != real_packet->tech_parasite_allow_holes);
8566   if (differ) {
8567     different++;
8568   }
8569   if (packet->tech_parasite_allow_holes) {
8570     BV_SET(fields, 69);
8571   }
8572 
8573   differ = (old->tech_loss_allow_holes != real_packet->tech_loss_allow_holes);
8574   if (differ) {
8575     different++;
8576   }
8577   if (packet->tech_loss_allow_holes) {
8578     BV_SET(fields, 70);
8579   }
8580 
8581   differ = (strcmp(old->positive_year_label, real_packet->positive_year_label) != 0);
8582   if (differ) {
8583     different++;
8584     BV_SET(fields, 71);
8585   }
8586 
8587   differ = (old->rapturedelay != real_packet->rapturedelay);
8588   if (differ) {
8589     different++;
8590     BV_SET(fields, 72);
8591   }
8592 
8593   differ = (old->disasters != real_packet->disasters);
8594   if (differ) {
8595     different++;
8596     BV_SET(fields, 73);
8597   }
8598 
8599   differ = (old->restrictinfra != real_packet->restrictinfra);
8600   if (differ) {
8601     different++;
8602   }
8603   if (packet->restrictinfra) {
8604     BV_SET(fields, 74);
8605   }
8606 
8607   differ = (old->unreachable_protects != real_packet->unreachable_protects);
8608   if (differ) {
8609     different++;
8610   }
8611   if (packet->unreachable_protects) {
8612     BV_SET(fields, 75);
8613   }
8614 
8615   differ = (old->sciencebox != real_packet->sciencebox);
8616   if (differ) {
8617     different++;
8618     BV_SET(fields, 76);
8619   }
8620 
8621   differ = (old->shieldbox != real_packet->shieldbox);
8622   if (differ) {
8623     different++;
8624     BV_SET(fields, 77);
8625   }
8626 
8627   differ = (old->skill_level != real_packet->skill_level);
8628   if (differ) {
8629     different++;
8630     BV_SET(fields, 78);
8631   }
8632 
8633   differ = (old->slow_invasions != real_packet->slow_invasions);
8634   if (differ) {
8635     different++;
8636   }
8637   if (packet->slow_invasions) {
8638     BV_SET(fields, 79);
8639   }
8640 
8641   differ = (old->victory_conditions != real_packet->victory_conditions);
8642   if (differ) {
8643     different++;
8644     BV_SET(fields, 80);
8645   }
8646 
8647   differ = (old->team_pooled_research != real_packet->team_pooled_research);
8648   if (differ) {
8649     different++;
8650   }
8651   if (packet->team_pooled_research) {
8652     BV_SET(fields, 81);
8653   }
8654 
8655   differ = (old->tech != real_packet->tech);
8656   if (differ) {
8657     different++;
8658     BV_SET(fields, 82);
8659   }
8660 
8661   differ = (old->tech_cost_style != real_packet->tech_cost_style);
8662   if (differ) {
8663     different++;
8664     BV_SET(fields, 83);
8665   }
8666 
8667   differ = (old->tech_leakage != real_packet->tech_leakage);
8668   if (differ) {
8669     different++;
8670     BV_SET(fields, 84);
8671   }
8672 
8673   differ = (old->tech_upkeep_divider != real_packet->tech_upkeep_divider);
8674   if (differ) {
8675     different++;
8676     BV_SET(fields, 85);
8677   }
8678 
8679   differ = (old->tech_upkeep_style != real_packet->tech_upkeep_style);
8680   if (differ) {
8681     different++;
8682     BV_SET(fields, 86);
8683   }
8684 
8685   differ = (old->free_tech_method != real_packet->free_tech_method);
8686   if (differ) {
8687     different++;
8688     BV_SET(fields, 87);
8689   }
8690 
8691   differ = (old->gameloss_style != real_packet->gameloss_style);
8692   if (differ) {
8693     different++;
8694     BV_SET(fields, 88);
8695   }
8696 
8697   differ = (old->timeout != real_packet->timeout);
8698   if (differ) {
8699     different++;
8700     BV_SET(fields, 89);
8701   }
8702 
8703   differ = (old->first_timeout != real_packet->first_timeout);
8704   if (differ) {
8705     different++;
8706     BV_SET(fields, 90);
8707   }
8708 
8709   differ = (old->tired_attack != real_packet->tired_attack);
8710   if (differ) {
8711     different++;
8712   }
8713   if (packet->tired_attack) {
8714     BV_SET(fields, 91);
8715   }
8716 
8717   differ = (old->trademindist != real_packet->trademindist);
8718   if (differ) {
8719     different++;
8720     BV_SET(fields, 92);
8721   }
8722 
8723   differ = (old->force_trade_route != real_packet->force_trade_route);
8724   if (differ) {
8725     different++;
8726   }
8727   if (packet->force_trade_route) {
8728     BV_SET(fields, 93);
8729   }
8730 
8731   differ = (old->trading_city != real_packet->trading_city);
8732   if (differ) {
8733     different++;
8734   }
8735   if (packet->trading_city) {
8736     BV_SET(fields, 94);
8737   }
8738 
8739   differ = (old->trading_gold != real_packet->trading_gold);
8740   if (differ) {
8741     different++;
8742   }
8743   if (packet->trading_gold) {
8744     BV_SET(fields, 95);
8745   }
8746 
8747   differ = (old->trading_tech != real_packet->trading_tech);
8748   if (differ) {
8749     different++;
8750   }
8751   if (packet->trading_tech) {
8752     BV_SET(fields, 96);
8753   }
8754 
8755   differ = (old->turn != real_packet->turn);
8756   if (differ) {
8757     different++;
8758     BV_SET(fields, 97);
8759   }
8760 
8761   differ = (old->warminglevel != real_packet->warminglevel);
8762   if (differ) {
8763     different++;
8764     BV_SET(fields, 98);
8765   }
8766 
8767   differ = (old->year16 != real_packet->year16);
8768   if (differ) {
8769     different++;
8770     BV_SET(fields, 99);
8771   }
8772 
8773   differ = (old->year_0_hack != real_packet->year_0_hack);
8774   if (differ) {
8775     different++;
8776   }
8777   if (packet->year_0_hack) {
8778     BV_SET(fields, 100);
8779   }
8780 
8781   differ = (old->calendar_fragments != real_packet->calendar_fragments);
8782   if (differ) {
8783     different++;
8784     BV_SET(fields, 101);
8785   }
8786 
8787   differ = (old->fragment_count != real_packet->fragment_count);
8788   if (differ) {
8789     different++;
8790     BV_SET(fields, 102);
8791   }
8792 
8793 
8794     {
8795       differ = (MAX_CALENDAR_FRAGMENTS != MAX_CALENDAR_FRAGMENTS);
8796       if (!differ) {
8797         int i;
8798 
8799         for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
8800           if (strcmp(old->calendar_fragment_name[i], real_packet->calendar_fragment_name[i]) != 0) {
8801             differ = TRUE;
8802             break;
8803           }
8804         }
8805       }
8806     }
8807   if (differ) {
8808     different++;
8809     BV_SET(fields, 103);
8810   }
8811 
8812   differ = (old->civil_war_enabled != real_packet->civil_war_enabled);
8813   if (differ) {
8814     different++;
8815   }
8816   if (packet->civil_war_enabled) {
8817     BV_SET(fields, 104);
8818   }
8819 
8820   differ = (old->paradrop_to_transport != real_packet->paradrop_to_transport);
8821   if (differ) {
8822     different++;
8823   }
8824   if (packet->paradrop_to_transport) {
8825     BV_SET(fields, 105);
8826   }
8827 
8828 
8829   if (different == 0) {
8830     log_packet_detailed("  no change -> discard");
8831     return 0;
8832   }
8833 
8834   DIO_BV_PUT(&dout, "fields", fields);
8835 
8836   if (BV_ISSET(fields, 0)) {
8837     log_packet_detailed("  field 'add_to_size_limit' has changed");
8838     DIO_PUT(uint8, &dout, "add_to_size_limit", real_packet->add_to_size_limit);
8839   }
8840   if (BV_ISSET(fields, 1)) {
8841     log_packet_detailed("  field 'aifill' has changed");
8842     DIO_PUT(uint8, &dout, "aifill", real_packet->aifill);
8843   }
8844   if (BV_ISSET(fields, 2)) {
8845     log_packet_detailed("  field 'persistent_ready' has changed");
8846     DIO_PUT(uint8, &dout, "persistent_ready", real_packet->persistent_ready);
8847   }
8848   if (BV_ISSET(fields, 3)) {
8849     log_packet_detailed("  field 'airlifting_style' has changed");
8850     DIO_PUT(uint8, &dout, "airlifting_style", real_packet->airlifting_style);
8851   }
8852   if (BV_ISSET(fields, 4)) {
8853     log_packet_detailed("  field 'angrycitizen' has changed");
8854     DIO_PUT(uint8, &dout, "angrycitizen", real_packet->angrycitizen);
8855   }
8856   if (BV_ISSET(fields, 5)) {
8857     log_packet_detailed("  field 'base_pollution' has changed");
8858     DIO_PUT(sint16, &dout, "base_pollution", real_packet->base_pollution);
8859   }
8860   if (BV_ISSET(fields, 6)) {
8861     log_packet_detailed("  field 'base_tech_cost' has changed");
8862     DIO_PUT(uint8, &dout, "base_tech_cost", real_packet->base_tech_cost);
8863   }
8864   if (BV_ISSET(fields, 7)) {
8865     log_packet_detailed("  field 'border_city_radius_sq' has changed");
8866     DIO_PUT(uint16, &dout, "border_city_radius_sq", real_packet->border_city_radius_sq);
8867   }
8868   if (BV_ISSET(fields, 8)) {
8869     log_packet_detailed("  field 'border_size_effect' has changed");
8870     DIO_PUT(uint8, &dout, "border_size_effect", real_packet->border_size_effect);
8871   }
8872   if (BV_ISSET(fields, 9)) {
8873     log_packet_detailed("  field 'border_city_permanent_radius_sq' has changed");
8874     DIO_PUT(sint16, &dout, "border_city_permanent_radius_sq", real_packet->border_city_permanent_radius_sq);
8875   }
8876   if (BV_ISSET(fields, 10)) {
8877     log_packet_detailed("  field 'borders' has changed");
8878     DIO_PUT(uint8, &dout, "borders", real_packet->borders);
8879   }
8880   if (BV_ISSET(fields, 11)) {
8881     log_packet_detailed("  field 'base_bribe_cost' has changed");
8882     DIO_PUT(uint32, &dout, "base_bribe_cost", real_packet->base_bribe_cost);
8883   }
8884   if (BV_ISSET(fields, 12)) {
8885     log_packet_detailed("  field 'culture_vic_points' has changed");
8886     DIO_PUT(uint32, &dout, "culture_vic_points", real_packet->culture_vic_points);
8887   }
8888   if (BV_ISSET(fields, 13)) {
8889     log_packet_detailed("  field 'culture_vic_lead' has changed");
8890     DIO_PUT(uint16, &dout, "culture_vic_lead", real_packet->culture_vic_lead);
8891   }
8892   if (BV_ISSET(fields, 14)) {
8893     log_packet_detailed("  field 'culture_migration_pml' has changed");
8894     DIO_PUT(uint16, &dout, "culture_migration_pml", real_packet->culture_migration_pml);
8895   }
8896   /* field 15 is folded into the header */
8897   if (BV_ISSET(fields, 16)) {
8898     log_packet_detailed("  field 'celebratesize' has changed");
8899     DIO_PUT(uint8, &dout, "celebratesize", real_packet->celebratesize);
8900   }
8901   /* field 17 is folded into the header */
8902   if (BV_ISSET(fields, 18)) {
8903     log_packet_detailed("  field 'pop_report_zeroes' has changed");
8904     DIO_PUT(uint8, &dout, "pop_report_zeroes", real_packet->pop_report_zeroes);
8905   }
8906   /* field 19 is folded into the header */
8907   if (BV_ISSET(fields, 20)) {
8908     log_packet_detailed("  field 'citizen_convert_speed' has changed");
8909     DIO_PUT(uint16, &dout, "citizen_convert_speed", real_packet->citizen_convert_speed);
8910   }
8911   if (BV_ISSET(fields, 21)) {
8912     log_packet_detailed("  field 'citizen_partisans_pct' has changed");
8913     DIO_PUT(uint8, &dout, "citizen_partisans_pct", real_packet->citizen_partisans_pct);
8914   }
8915   if (BV_ISSET(fields, 22)) {
8916     log_packet_detailed("  field 'citymindist' has changed");
8917     DIO_PUT(uint8, &dout, "citymindist", real_packet->citymindist);
8918   }
8919   if (BV_ISSET(fields, 23)) {
8920     log_packet_detailed("  field 'cooling' has changed");
8921     DIO_PUT(uint32, &dout, "cooling", real_packet->cooling);
8922   }
8923   if (BV_ISSET(fields, 24)) {
8924     log_packet_detailed("  field 'coolinglevel' has changed");
8925     DIO_PUT(uint32, &dout, "coolinglevel", real_packet->coolinglevel);
8926   }
8927   if (BV_ISSET(fields, 25)) {
8928     log_packet_detailed("  field 'diplomacy' has changed");
8929     DIO_PUT(uint8, &dout, "diplomacy", real_packet->diplomacy);
8930   }
8931   /* field 26 is folded into the header */
8932   if (BV_ISSET(fields, 27)) {
8933     log_packet_detailed("  field 'food_cost' has changed");
8934     DIO_PUT(uint8, &dout, "food_cost", real_packet->food_cost);
8935   }
8936   if (BV_ISSET(fields, 28)) {
8937     log_packet_detailed("  field 'foodbox' has changed");
8938     DIO_PUT(uint32, &dout, "foodbox", real_packet->foodbox);
8939   }
8940   if (BV_ISSET(fields, 29)) {
8941     log_packet_detailed("  field 'forced_gold' has changed");
8942     DIO_PUT(uint8, &dout, "forced_gold", real_packet->forced_gold);
8943   }
8944   if (BV_ISSET(fields, 30)) {
8945     log_packet_detailed("  field 'forced_luxury' has changed");
8946     DIO_PUT(uint8, &dout, "forced_luxury", real_packet->forced_luxury);
8947   }
8948   if (BV_ISSET(fields, 31)) {
8949     log_packet_detailed("  field 'forced_science' has changed");
8950     DIO_PUT(uint8, &dout, "forced_science", real_packet->forced_science);
8951   }
8952   if (BV_ISSET(fields, 32)) {
8953     log_packet_detailed("  field 'fulltradesize' has changed");
8954     DIO_PUT(uint8, &dout, "fulltradesize", real_packet->fulltradesize);
8955   }
8956   if (BV_ISSET(fields, 33)) {
8957     log_packet_detailed("  field 'global_advances' has changed");
8958 
8959     {
8960       int i;
8961 
8962       fc_assert(A_LAST < 255);
8963 
8964       for (i = 0; i < A_LAST; i++) {
8965         if (old->global_advances[i] != real_packet->global_advances[i]) {
8966           dio_put_uint8(&dout, i);
8967           dio_put_bool8(&dout, real_packet->global_advances[i]);
8968         }
8969       }
8970       dio_put_uint8(&dout, 255);
8971     }
8972   }
8973   /* field 34 is folded into the header */
8974   if (BV_ISSET(fields, 35)) {
8975     log_packet_detailed("  field 'globalwarming' has changed");
8976     DIO_PUT(uint32, &dout, "globalwarming", real_packet->globalwarming);
8977   }
8978   if (BV_ISSET(fields, 36)) {
8979     log_packet_detailed("  field 'gold' has changed");
8980     DIO_PUT(uint32, &dout, "gold", real_packet->gold);
8981   }
8982   if (BV_ISSET(fields, 37)) {
8983     log_packet_detailed("  field 'gold_upkeep_style' has changed");
8984     DIO_PUT(uint8, &dout, "gold_upkeep_style", real_packet->gold_upkeep_style);
8985   }
8986   if (BV_ISSET(fields, 38)) {
8987     log_packet_detailed("  field 'revolentype' has changed");
8988     DIO_PUT(uint8, &dout, "revolentype", real_packet->revolentype);
8989   }
8990   if (BV_ISSET(fields, 39)) {
8991     log_packet_detailed("  field 'default_government_id' has changed");
8992     DIO_PUT(sint8, &dout, "default_government_id", real_packet->default_government_id);
8993   }
8994   if (BV_ISSET(fields, 40)) {
8995     log_packet_detailed("  field 'government_during_revolution_id' has changed");
8996     DIO_PUT(sint8, &dout, "government_during_revolution_id", real_packet->government_during_revolution_id);
8997   }
8998   if (BV_ISSET(fields, 41)) {
8999     log_packet_detailed("  field 'granary_food_inc' has changed");
9000     DIO_PUT(uint8, &dout, "granary_food_inc", real_packet->granary_food_inc);
9001   }
9002   if (BV_ISSET(fields, 42)) {
9003     log_packet_detailed("  field 'granary_food_ini' has changed");
9004 
9005     {
9006       int i;
9007 
9008       for (i = 0; i < MAX_GRANARY_INIS; i++) {
9009         dio_put_uint8(&dout, real_packet->granary_food_ini[i]);
9010       }
9011     }
9012   }
9013   if (BV_ISSET(fields, 43)) {
9014     log_packet_detailed("  field 'granary_num_inis' has changed");
9015     DIO_PUT(uint8, &dout, "granary_num_inis", real_packet->granary_num_inis);
9016   }
9017   if (BV_ISSET(fields, 44)) {
9018     log_packet_detailed("  field 'great_wonder_owners' has changed");
9019 
9020     {
9021       int i;
9022 
9023       fc_assert(B_LAST < 255);
9024 
9025       for (i = 0; i < B_LAST; i++) {
9026         if (old->great_wonder_owners[i] != real_packet->great_wonder_owners[i]) {
9027           dio_put_uint8(&dout, i);
9028           dio_put_uint8(&dout, real_packet->great_wonder_owners[i]);
9029         }
9030       }
9031       dio_put_uint8(&dout, 255);
9032     }
9033   }
9034   if (BV_ISSET(fields, 45)) {
9035     log_packet_detailed("  field 'happy_cost' has changed");
9036     DIO_PUT(uint8, &dout, "happy_cost", real_packet->happy_cost);
9037   }
9038   if (BV_ISSET(fields, 46)) {
9039     log_packet_detailed("  field 'happyborders' has changed");
9040     DIO_PUT(uint8, &dout, "happyborders", real_packet->happyborders);
9041   }
9042   if (BV_ISSET(fields, 47)) {
9043     log_packet_detailed("  field 'heating' has changed");
9044     DIO_PUT(uint32, &dout, "heating", real_packet->heating);
9045   }
9046   if (BV_ISSET(fields, 48)) {
9047     log_packet_detailed("  field 'illness_base_factor' has changed");
9048     DIO_PUT(uint16, &dout, "illness_base_factor", real_packet->illness_base_factor);
9049   }
9050   if (BV_ISSET(fields, 49)) {
9051     log_packet_detailed("  field 'illness_min_size' has changed");
9052     DIO_PUT(uint8, &dout, "illness_min_size", real_packet->illness_min_size);
9053   }
9054   /* field 50 is folded into the header */
9055   if (BV_ISSET(fields, 51)) {
9056     log_packet_detailed("  field 'illness_pollution_factor' has changed");
9057     DIO_PUT(uint16, &dout, "illness_pollution_factor", real_packet->illness_pollution_factor);
9058   }
9059   if (BV_ISSET(fields, 52)) {
9060     log_packet_detailed("  field 'illness_trade_infection' has changed");
9061     DIO_PUT(uint16, &dout, "illness_trade_infection", real_packet->illness_trade_infection);
9062   }
9063   if (BV_ISSET(fields, 53)) {
9064     log_packet_detailed("  field 'init_city_radius_sq' has changed");
9065     DIO_PUT(uint8, &dout, "init_city_radius_sq", real_packet->init_city_radius_sq);
9066   }
9067   /* field 54 is folded into the header */
9068   /* field 55 is folded into the header */
9069   /* field 56 is folded into the header */
9070   /* field 57 is folded into the header */
9071   if (BV_ISSET(fields, 58)) {
9072     log_packet_detailed("  field 'min_city_center_output' has changed");
9073 
9074     {
9075       int i;
9076 
9077       for (i = 0; i < O_LAST; i++) {
9078         dio_put_uint8(&dout, real_packet->min_city_center_output[i]);
9079       }
9080     }
9081   }
9082   if (BV_ISSET(fields, 59)) {
9083     log_packet_detailed("  field 'negative_year_label' has changed");
9084     DIO_PUT(string, &dout, "negative_year_label", real_packet->negative_year_label);
9085   }
9086   if (BV_ISSET(fields, 60)) {
9087     log_packet_detailed("  field 'notradesize' has changed");
9088     DIO_PUT(uint8, &dout, "notradesize", real_packet->notradesize);
9089   }
9090   /* field 61 is folded into the header */
9091   if (BV_ISSET(fields, 62)) {
9092     log_packet_detailed("  field 'nuclearwinter' has changed");
9093     DIO_PUT(uint32, &dout, "nuclearwinter", real_packet->nuclearwinter);
9094   }
9095   if (BV_ISSET(fields, 63)) {
9096     log_packet_detailed("  field 'phase' has changed");
9097     DIO_PUT(sint16, &dout, "phase", real_packet->phase);
9098   }
9099   if (BV_ISSET(fields, 64)) {
9100     log_packet_detailed("  field 'phase_mode' has changed");
9101     DIO_PUT(uint8, &dout, "phase_mode", real_packet->phase_mode);
9102   }
9103   /* field 65 is folded into the header */
9104   /* field 66 is folded into the header */
9105   /* field 67 is folded into the header */
9106   /* field 68 is folded into the header */
9107   /* field 69 is folded into the header */
9108   /* field 70 is folded into the header */
9109   if (BV_ISSET(fields, 71)) {
9110     log_packet_detailed("  field 'positive_year_label' has changed");
9111     DIO_PUT(string, &dout, "positive_year_label", real_packet->positive_year_label);
9112   }
9113   if (BV_ISSET(fields, 72)) {
9114     log_packet_detailed("  field 'rapturedelay' has changed");
9115     DIO_PUT(uint8, &dout, "rapturedelay", real_packet->rapturedelay);
9116   }
9117   if (BV_ISSET(fields, 73)) {
9118     log_packet_detailed("  field 'disasters' has changed");
9119     DIO_PUT(uint16, &dout, "disasters", real_packet->disasters);
9120   }
9121   /* field 74 is folded into the header */
9122   /* field 75 is folded into the header */
9123   if (BV_ISSET(fields, 76)) {
9124     log_packet_detailed("  field 'sciencebox' has changed");
9125     DIO_PUT(uint32, &dout, "sciencebox", real_packet->sciencebox);
9126   }
9127   if (BV_ISSET(fields, 77)) {
9128     log_packet_detailed("  field 'shieldbox' has changed");
9129     DIO_PUT(uint32, &dout, "shieldbox", real_packet->shieldbox);
9130   }
9131   if (BV_ISSET(fields, 78)) {
9132     log_packet_detailed("  field 'skill_level' has changed");
9133     DIO_PUT(uint32, &dout, "skill_level", real_packet->skill_level);
9134   }
9135   /* field 79 is folded into the header */
9136   if (BV_ISSET(fields, 80)) {
9137     log_packet_detailed("  field 'victory_conditions' has changed");
9138     DIO_PUT(uint8, &dout, "victory_conditions", real_packet->victory_conditions);
9139   }
9140   /* field 81 is folded into the header */
9141   if (BV_ISSET(fields, 82)) {
9142     log_packet_detailed("  field 'tech' has changed");
9143     DIO_PUT(uint32, &dout, "tech", real_packet->tech);
9144   }
9145   if (BV_ISSET(fields, 83)) {
9146     log_packet_detailed("  field 'tech_cost_style' has changed");
9147     DIO_PUT(uint8, &dout, "tech_cost_style", real_packet->tech_cost_style);
9148   }
9149   if (BV_ISSET(fields, 84)) {
9150     log_packet_detailed("  field 'tech_leakage' has changed");
9151     DIO_PUT(uint8, &dout, "tech_leakage", real_packet->tech_leakage);
9152   }
9153   if (BV_ISSET(fields, 85)) {
9154     log_packet_detailed("  field 'tech_upkeep_divider' has changed");
9155     DIO_PUT(uint16, &dout, "tech_upkeep_divider", real_packet->tech_upkeep_divider);
9156   }
9157   if (BV_ISSET(fields, 86)) {
9158     log_packet_detailed("  field 'tech_upkeep_style' has changed");
9159     DIO_PUT(uint8, &dout, "tech_upkeep_style", real_packet->tech_upkeep_style);
9160   }
9161   if (BV_ISSET(fields, 87)) {
9162     log_packet_detailed("  field 'free_tech_method' has changed");
9163     DIO_PUT(uint8, &dout, "free_tech_method", real_packet->free_tech_method);
9164   }
9165   if (BV_ISSET(fields, 88)) {
9166     log_packet_detailed("  field 'gameloss_style' has changed");
9167     DIO_PUT(uint8, &dout, "gameloss_style", real_packet->gameloss_style);
9168   }
9169   if (BV_ISSET(fields, 89)) {
9170     log_packet_detailed("  field 'timeout' has changed");
9171     DIO_PUT(uint32, &dout, "timeout", real_packet->timeout);
9172   }
9173   if (BV_ISSET(fields, 90)) {
9174     log_packet_detailed("  field 'first_timeout' has changed");
9175     DIO_PUT(uint32, &dout, "first_timeout", real_packet->first_timeout);
9176   }
9177   /* field 91 is folded into the header */
9178   if (BV_ISSET(fields, 92)) {
9179     log_packet_detailed("  field 'trademindist' has changed");
9180     DIO_PUT(uint16, &dout, "trademindist", real_packet->trademindist);
9181   }
9182   /* field 93 is folded into the header */
9183   /* field 94 is folded into the header */
9184   /* field 95 is folded into the header */
9185   /* field 96 is folded into the header */
9186   if (BV_ISSET(fields, 97)) {
9187     log_packet_detailed("  field 'turn' has changed");
9188     DIO_PUT(sint16, &dout, "turn", real_packet->turn);
9189   }
9190   if (BV_ISSET(fields, 98)) {
9191     log_packet_detailed("  field 'warminglevel' has changed");
9192     DIO_PUT(uint32, &dout, "warminglevel", real_packet->warminglevel);
9193   }
9194   if (BV_ISSET(fields, 99)) {
9195     log_packet_detailed("  field 'year16' has changed");
9196     DIO_PUT(sint16, &dout, "year16", real_packet->year16);
9197   }
9198   /* field 100 is folded into the header */
9199   if (BV_ISSET(fields, 101)) {
9200     log_packet_detailed("  field 'calendar_fragments' has changed");
9201     DIO_PUT(uint16, &dout, "calendar_fragments", real_packet->calendar_fragments);
9202   }
9203   if (BV_ISSET(fields, 102)) {
9204     log_packet_detailed("  field 'fragment_count' has changed");
9205     DIO_PUT(uint16, &dout, "fragment_count", real_packet->fragment_count);
9206   }
9207   if (BV_ISSET(fields, 103)) {
9208     log_packet_detailed("  field 'calendar_fragment_name' has changed");
9209 
9210     {
9211       int i;
9212 
9213       for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
9214         dio_put_string(&dout, real_packet->calendar_fragment_name[i]);
9215       }
9216     }
9217   }
9218   /* field 104 is folded into the header */
9219   /* field 105 is folded into the header */
9220 
9221   *old = *real_packet;
9222   SEND_PACKET_END(PACKET_GAME_INFO);
9223 }
9224 
send_packet_game_info(struct connection * pc,const struct packet_game_info * packet)9225 int send_packet_game_info(struct connection *pc, const struct packet_game_info *packet)
9226 {
9227   if (!pc->used) {
9228     log_error("WARNING: trying to send data to the closed connection %s",
9229               conn_description(pc));
9230     return -1;
9231   }
9232   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_GAME_INFO].packet != NULL, -1,
9233                         "Handler for PACKET_GAME_INFO not installed");
9234   return pc->phs.handlers->send[PACKET_GAME_INFO].packet(pc, packet);
9235 }
9236 
9237 #define hash_packet_timeout_info_100 hash_const
9238 
9239 #define cmp_packet_timeout_info_100 cmp_const
9240 
9241 BV_DEFINE(packet_timeout_info_100_fields, 2);
9242 
receive_packet_timeout_info_100(struct connection * pc)9243 static struct packet_timeout_info *receive_packet_timeout_info_100(struct connection *pc)
9244 {
9245   packet_timeout_info_100_fields fields;
9246   struct packet_timeout_info *old;
9247   struct genhash **hash = pc->phs.received + PACKET_TIMEOUT_INFO;
9248   RECEIVE_PACKET_START(packet_timeout_info, real_packet);
9249 
9250   DIO_BV_GET(&din, fields);
9251 
9252   log_packet_detailed("packet_timeout_info_100: got info about ()");
9253 
9254   if (NULL == *hash) {
9255     *hash = genhash_new_full(hash_packet_timeout_info_100, cmp_packet_timeout_info_100,
9256                              NULL, NULL, NULL, free);
9257   }
9258 
9259   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
9260     *real_packet = *old;
9261   } else {
9262     log_packet_detailed("  no old info");
9263     memset(real_packet, 0, sizeof(*real_packet));
9264   }
9265 
9266   if (BV_ISSET(fields, 0)) {
9267     log_packet_detailed("  got field 'seconds_to_phasedone'");
9268     if (!DIO_GET(sfloat, &din, "seconds_to_phasedone", &real_packet->seconds_to_phasedone, 100)) {
9269       RECEIVE_PACKET_FIELD_ERROR(seconds_to_phasedone);
9270     }
9271   }
9272   if (BV_ISSET(fields, 1)) {
9273     log_packet_detailed("  got field 'last_turn_change_time'");
9274     if (!DIO_GET(sfloat, &din, "last_turn_change_time", &real_packet->last_turn_change_time, 100)) {
9275       RECEIVE_PACKET_FIELD_ERROR(last_turn_change_time);
9276     }
9277   }
9278 
9279   if (NULL == old) {
9280     old = fc_malloc(sizeof(*old));
9281     *old = *real_packet;
9282     genhash_insert(*hash, old, old);
9283   } else {
9284     *old = *real_packet;
9285   }
9286   RECEIVE_PACKET_END(real_packet);
9287 }
9288 
send_packet_timeout_info_100(struct connection * pc,const struct packet_timeout_info * packet)9289 static int send_packet_timeout_info_100(struct connection *pc, const struct packet_timeout_info *packet)
9290 {
9291   const struct packet_timeout_info *real_packet = packet;
9292   packet_timeout_info_100_fields fields;
9293   struct packet_timeout_info *old;
9294   bool differ;
9295   struct genhash **hash = pc->phs.sent + PACKET_TIMEOUT_INFO;
9296   int different = 0;
9297   SEND_PACKET_START(PACKET_TIMEOUT_INFO);
9298 
9299   log_packet_detailed("packet_timeout_info_100: sending info about ()");
9300 
9301   if (NULL == *hash) {
9302     *hash = genhash_new_full(hash_packet_timeout_info_100, cmp_packet_timeout_info_100,
9303                              NULL, NULL, NULL, free);
9304   }
9305   BV_CLR_ALL(fields);
9306 
9307   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
9308     old = fc_malloc(sizeof(*old));
9309     *old = *real_packet;
9310     genhash_insert(*hash, old, old);
9311     memset(old, 0, sizeof(*old));
9312     different = 1;      /* Force to send. */
9313   }
9314 
9315   differ = (old->seconds_to_phasedone != real_packet->seconds_to_phasedone);
9316   if (differ) {
9317     different++;
9318     BV_SET(fields, 0);
9319   }
9320 
9321   differ = (old->last_turn_change_time != real_packet->last_turn_change_time);
9322   if (differ) {
9323     different++;
9324     BV_SET(fields, 1);
9325   }
9326 
9327 
9328   DIO_BV_PUT(&dout, "fields", fields);
9329 
9330   if (BV_ISSET(fields, 0)) {
9331     log_packet_detailed("  field 'seconds_to_phasedone' has changed");
9332     DIO_PUT(sfloat, &dout, "seconds_to_phasedone", real_packet->seconds_to_phasedone, 100);
9333   }
9334   if (BV_ISSET(fields, 1)) {
9335     log_packet_detailed("  field 'last_turn_change_time' has changed");
9336     DIO_PUT(sfloat, &dout, "last_turn_change_time", real_packet->last_turn_change_time, 100);
9337   }
9338 
9339   *old = *real_packet;
9340   SEND_PACKET_END(PACKET_TIMEOUT_INFO);
9341 }
9342 
send_packet_timeout_info(struct connection * pc,const struct packet_timeout_info * packet)9343 int send_packet_timeout_info(struct connection *pc, const struct packet_timeout_info *packet)
9344 {
9345   if (!pc->used) {
9346     log_error("WARNING: trying to send data to the closed connection %s",
9347               conn_description(pc));
9348     return -1;
9349   }
9350   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_TIMEOUT_INFO].packet != NULL, -1,
9351                         "Handler for PACKET_TIMEOUT_INFO not installed");
9352   return pc->phs.handlers->send[PACKET_TIMEOUT_INFO].packet(pc, packet);
9353 }
9354 
9355 #define hash_packet_map_info_100 hash_const
9356 
9357 #define cmp_packet_map_info_100 cmp_const
9358 
9359 BV_DEFINE(packet_map_info_100_fields, 3);
9360 
receive_packet_map_info_100(struct connection * pc)9361 static struct packet_map_info *receive_packet_map_info_100(struct connection *pc)
9362 {
9363   packet_map_info_100_fields fields;
9364   struct packet_map_info *old;
9365   struct genhash **hash = pc->phs.received + PACKET_MAP_INFO;
9366   RECEIVE_PACKET_START(packet_map_info, real_packet);
9367 
9368   DIO_BV_GET(&din, fields);
9369 
9370   log_packet_detailed("packet_map_info_100: got info about ()");
9371 
9372   if (NULL == *hash) {
9373     *hash = genhash_new_full(hash_packet_map_info_100, cmp_packet_map_info_100,
9374                              NULL, NULL, NULL, free);
9375   }
9376 
9377   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
9378     *real_packet = *old;
9379   } else {
9380     log_packet_detailed("  no old info");
9381     memset(real_packet, 0, sizeof(*real_packet));
9382   }
9383 
9384   if (BV_ISSET(fields, 0)) {
9385     log_packet_detailed("  got field 'xsize'");
9386     if (!DIO_GET(uint16, &din, "xsize", &real_packet->xsize)) {
9387       RECEIVE_PACKET_FIELD_ERROR(xsize);
9388     }
9389   }
9390   if (BV_ISSET(fields, 1)) {
9391     log_packet_detailed("  got field 'ysize'");
9392     if (!DIO_GET(uint16, &din, "ysize", &real_packet->ysize)) {
9393       RECEIVE_PACKET_FIELD_ERROR(ysize);
9394     }
9395   }
9396   if (BV_ISSET(fields, 2)) {
9397     log_packet_detailed("  got field 'topology_id'");
9398     if (!DIO_GET(uint8, &din, "topology_id", &real_packet->topology_id)) {
9399       RECEIVE_PACKET_FIELD_ERROR(topology_id);
9400     }
9401   }
9402 
9403   if (NULL == old) {
9404     old = fc_malloc(sizeof(*old));
9405     *old = *real_packet;
9406     genhash_insert(*hash, old, old);
9407   } else {
9408     *old = *real_packet;
9409   }
9410   RECEIVE_PACKET_END(real_packet);
9411 }
9412 
send_packet_map_info_100(struct connection * pc,const struct packet_map_info * packet)9413 static int send_packet_map_info_100(struct connection *pc, const struct packet_map_info *packet)
9414 {
9415   const struct packet_map_info *real_packet = packet;
9416   packet_map_info_100_fields fields;
9417   struct packet_map_info *old;
9418   bool differ;
9419   struct genhash **hash = pc->phs.sent + PACKET_MAP_INFO;
9420   int different = 0;
9421   SEND_PACKET_START(PACKET_MAP_INFO);
9422 
9423   log_packet_detailed("packet_map_info_100: sending info about ()");
9424 
9425   if (NULL == *hash) {
9426     *hash = genhash_new_full(hash_packet_map_info_100, cmp_packet_map_info_100,
9427                              NULL, NULL, NULL, free);
9428   }
9429   BV_CLR_ALL(fields);
9430 
9431   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
9432     old = fc_malloc(sizeof(*old));
9433     *old = *real_packet;
9434     genhash_insert(*hash, old, old);
9435     memset(old, 0, sizeof(*old));
9436     different = 1;      /* Force to send. */
9437   }
9438 
9439   differ = (old->xsize != real_packet->xsize);
9440   if (differ) {
9441     different++;
9442     BV_SET(fields, 0);
9443   }
9444 
9445   differ = (old->ysize != real_packet->ysize);
9446   if (differ) {
9447     different++;
9448     BV_SET(fields, 1);
9449   }
9450 
9451   differ = (old->topology_id != real_packet->topology_id);
9452   if (differ) {
9453     different++;
9454     BV_SET(fields, 2);
9455   }
9456 
9457 
9458   DIO_BV_PUT(&dout, "fields", fields);
9459 
9460   if (BV_ISSET(fields, 0)) {
9461     log_packet_detailed("  field 'xsize' has changed");
9462     DIO_PUT(uint16, &dout, "xsize", real_packet->xsize);
9463   }
9464   if (BV_ISSET(fields, 1)) {
9465     log_packet_detailed("  field 'ysize' has changed");
9466     DIO_PUT(uint16, &dout, "ysize", real_packet->ysize);
9467   }
9468   if (BV_ISSET(fields, 2)) {
9469     log_packet_detailed("  field 'topology_id' has changed");
9470     DIO_PUT(uint8, &dout, "topology_id", real_packet->topology_id);
9471   }
9472 
9473   *old = *real_packet;
9474   SEND_PACKET_END(PACKET_MAP_INFO);
9475 }
9476 
send_packet_map_info(struct connection * pc,const struct packet_map_info * packet)9477 int send_packet_map_info(struct connection *pc, const struct packet_map_info *packet)
9478 {
9479   if (!pc->used) {
9480     log_error("WARNING: trying to send data to the closed connection %s",
9481               conn_description(pc));
9482     return -1;
9483   }
9484   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_MAP_INFO].packet != NULL, -1,
9485                         "Handler for PACKET_MAP_INFO not installed");
9486   return pc->phs.handlers->send[PACKET_MAP_INFO].packet(pc, packet);
9487 }
9488 
lsend_packet_map_info(struct conn_list * dest,const struct packet_map_info * packet)9489 void lsend_packet_map_info(struct conn_list *dest, const struct packet_map_info *packet)
9490 {
9491   conn_list_iterate(dest, pconn) {
9492     send_packet_map_info(pconn, packet);
9493   } conn_list_iterate_end;
9494 }
9495 
9496 #define hash_packet_nuke_tile_info_100 hash_const
9497 
9498 #define cmp_packet_nuke_tile_info_100 cmp_const
9499 
9500 BV_DEFINE(packet_nuke_tile_info_100_fields, 1);
9501 
receive_packet_nuke_tile_info_100(struct connection * pc)9502 static struct packet_nuke_tile_info *receive_packet_nuke_tile_info_100(struct connection *pc)
9503 {
9504   packet_nuke_tile_info_100_fields fields;
9505   struct packet_nuke_tile_info *old;
9506   struct genhash **hash = pc->phs.received + PACKET_NUKE_TILE_INFO;
9507   RECEIVE_PACKET_START(packet_nuke_tile_info, real_packet);
9508 
9509   DIO_BV_GET(&din, fields);
9510 
9511   log_packet_detailed("packet_nuke_tile_info_100: got info about ()");
9512 
9513   if (NULL == *hash) {
9514     *hash = genhash_new_full(hash_packet_nuke_tile_info_100, cmp_packet_nuke_tile_info_100,
9515                              NULL, NULL, NULL, free);
9516   }
9517 
9518   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
9519     *real_packet = *old;
9520   } else {
9521     log_packet_detailed("  no old info");
9522     memset(real_packet, 0, sizeof(*real_packet));
9523   }
9524 
9525   if (BV_ISSET(fields, 0)) {
9526     log_packet_detailed("  got field 'tile'");
9527     if (!DIO_GET(sint32, &din, "tile", &real_packet->tile)) {
9528       RECEIVE_PACKET_FIELD_ERROR(tile);
9529     }
9530   }
9531 
9532   if (NULL == old) {
9533     old = fc_malloc(sizeof(*old));
9534     *old = *real_packet;
9535     genhash_insert(*hash, old, old);
9536   } else {
9537     *old = *real_packet;
9538   }
9539   RECEIVE_PACKET_END(real_packet);
9540 }
9541 
send_packet_nuke_tile_info_100(struct connection * pc,const struct packet_nuke_tile_info * packet)9542 static int send_packet_nuke_tile_info_100(struct connection *pc, const struct packet_nuke_tile_info *packet)
9543 {
9544   const struct packet_nuke_tile_info *real_packet = packet;
9545   packet_nuke_tile_info_100_fields fields;
9546   struct packet_nuke_tile_info *old;
9547   bool differ;
9548   struct genhash **hash = pc->phs.sent + PACKET_NUKE_TILE_INFO;
9549   int different = 0;
9550   SEND_PACKET_START(PACKET_NUKE_TILE_INFO);
9551 
9552   log_packet_detailed("packet_nuke_tile_info_100: sending info about ()");
9553 
9554   if (NULL == *hash) {
9555     *hash = genhash_new_full(hash_packet_nuke_tile_info_100, cmp_packet_nuke_tile_info_100,
9556                              NULL, NULL, NULL, free);
9557   }
9558   BV_CLR_ALL(fields);
9559 
9560   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
9561     old = fc_malloc(sizeof(*old));
9562     *old = *real_packet;
9563     genhash_insert(*hash, old, old);
9564     memset(old, 0, sizeof(*old));
9565     different = 1;      /* Force to send. */
9566   }
9567 
9568   differ = (old->tile != real_packet->tile);
9569   if (differ) {
9570     different++;
9571     BV_SET(fields, 0);
9572   }
9573 
9574 
9575   DIO_BV_PUT(&dout, "fields", fields);
9576 
9577   if (BV_ISSET(fields, 0)) {
9578     log_packet_detailed("  field 'tile' has changed");
9579     DIO_PUT(sint32, &dout, "tile", real_packet->tile);
9580   }
9581 
9582   *old = *real_packet;
9583   SEND_PACKET_END(PACKET_NUKE_TILE_INFO);
9584 }
9585 
send_packet_nuke_tile_info(struct connection * pc,const struct packet_nuke_tile_info * packet)9586 int send_packet_nuke_tile_info(struct connection *pc, const struct packet_nuke_tile_info *packet)
9587 {
9588   if (!pc->used) {
9589     log_error("WARNING: trying to send data to the closed connection %s",
9590               conn_description(pc));
9591     return -1;
9592   }
9593   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_NUKE_TILE_INFO].packet != NULL, -1,
9594                         "Handler for PACKET_NUKE_TILE_INFO not installed");
9595   return pc->phs.handlers->send[PACKET_NUKE_TILE_INFO].packet(pc, packet);
9596 }
9597 
lsend_packet_nuke_tile_info(struct conn_list * dest,const struct packet_nuke_tile_info * packet)9598 void lsend_packet_nuke_tile_info(struct conn_list *dest, const struct packet_nuke_tile_info *packet)
9599 {
9600   conn_list_iterate(dest, pconn) {
9601     send_packet_nuke_tile_info(pconn, packet);
9602   } conn_list_iterate_end;
9603 }
9604 
dsend_packet_nuke_tile_info(struct connection * pc,int tile)9605 int dsend_packet_nuke_tile_info(struct connection *pc, int tile)
9606 {
9607   struct packet_nuke_tile_info packet, *real_packet = &packet;
9608 
9609   real_packet->tile = tile;
9610 
9611   return send_packet_nuke_tile_info(pc, real_packet);
9612 }
9613 
dlsend_packet_nuke_tile_info(struct conn_list * dest,int tile)9614 void dlsend_packet_nuke_tile_info(struct conn_list *dest, int tile)
9615 {
9616   struct packet_nuke_tile_info packet, *real_packet = &packet;
9617 
9618   real_packet->tile = tile;
9619 
9620   lsend_packet_nuke_tile_info(dest, real_packet);
9621 }
9622 
hash_packet_team_name_info_100(const void * vkey)9623 static genhash_val_t hash_packet_team_name_info_100(const void *vkey)
9624 {
9625   const struct packet_team_name_info *key = (const struct packet_team_name_info *) vkey;
9626 
9627   return key->team_id;
9628 }
9629 
cmp_packet_team_name_info_100(const void * vkey1,const void * vkey2)9630 static bool cmp_packet_team_name_info_100(const void *vkey1, const void *vkey2)
9631 {
9632   const struct packet_team_name_info *key1 = (const struct packet_team_name_info *) vkey1;
9633   const struct packet_team_name_info *key2 = (const struct packet_team_name_info *) vkey2;
9634 
9635   return key1->team_id == key2->team_id;
9636 }
9637 
9638 BV_DEFINE(packet_team_name_info_100_fields, 1);
9639 
receive_packet_team_name_info_100(struct connection * pc)9640 static struct packet_team_name_info *receive_packet_team_name_info_100(struct connection *pc)
9641 {
9642   packet_team_name_info_100_fields fields;
9643   struct packet_team_name_info *old;
9644   struct genhash **hash = pc->phs.received + PACKET_TEAM_NAME_INFO;
9645   RECEIVE_PACKET_START(packet_team_name_info, real_packet);
9646 
9647   DIO_BV_GET(&din, fields);
9648   if (!DIO_GET(uint8, &din, "team_id", &real_packet->team_id)) {
9649     RECEIVE_PACKET_FIELD_ERROR(team_id);
9650   }
9651 
9652   log_packet_detailed("packet_team_name_info_100: got info about (%d)",
9653     real_packet->team_id);
9654 
9655   if (NULL == *hash) {
9656     *hash = genhash_new_full(hash_packet_team_name_info_100, cmp_packet_team_name_info_100,
9657                              NULL, NULL, NULL, free);
9658   }
9659 
9660   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
9661     *real_packet = *old;
9662   } else {
9663     int team_id = real_packet->team_id;
9664 
9665     log_packet_detailed("  no old info");
9666     memset(real_packet, 0, sizeof(*real_packet));
9667 
9668     real_packet->team_id = team_id;
9669   }
9670 
9671   if (BV_ISSET(fields, 0)) {
9672     log_packet_detailed("  got field 'team_name'");
9673     if (!DIO_GET(string, &din, "team_name", real_packet->team_name, sizeof(real_packet->team_name))) {
9674       RECEIVE_PACKET_FIELD_ERROR(team_name);
9675     }
9676   }
9677 
9678   if (NULL == old) {
9679     old = fc_malloc(sizeof(*old));
9680     *old = *real_packet;
9681     genhash_insert(*hash, old, old);
9682   } else {
9683     *old = *real_packet;
9684   }
9685   RECEIVE_PACKET_END(real_packet);
9686 }
9687 
send_packet_team_name_info_100(struct connection * pc,const struct packet_team_name_info * packet)9688 static int send_packet_team_name_info_100(struct connection *pc, const struct packet_team_name_info *packet)
9689 {
9690   const struct packet_team_name_info *real_packet = packet;
9691   packet_team_name_info_100_fields fields;
9692   struct packet_team_name_info *old;
9693   bool differ;
9694   struct genhash **hash = pc->phs.sent + PACKET_TEAM_NAME_INFO;
9695   int different = 0;
9696   SEND_PACKET_START(PACKET_TEAM_NAME_INFO);
9697 
9698   log_packet_detailed("packet_team_name_info_100: sending info about (%d)",
9699     real_packet->team_id);
9700 
9701   if (NULL == *hash) {
9702     *hash = genhash_new_full(hash_packet_team_name_info_100, cmp_packet_team_name_info_100,
9703                              NULL, NULL, NULL, free);
9704   }
9705   BV_CLR_ALL(fields);
9706 
9707   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
9708     old = fc_malloc(sizeof(*old));
9709     *old = *real_packet;
9710     genhash_insert(*hash, old, old);
9711     memset(old, 0, sizeof(*old));
9712     different = 1;      /* Force to send. */
9713   }
9714 
9715   differ = (strcmp(old->team_name, real_packet->team_name) != 0);
9716   if (differ) {
9717     different++;
9718     BV_SET(fields, 0);
9719   }
9720 
9721 
9722   DIO_BV_PUT(&dout, "fields", fields);
9723   DIO_PUT(uint8, &dout, "team_id", real_packet->team_id);
9724 
9725   if (BV_ISSET(fields, 0)) {
9726     log_packet_detailed("  field 'team_name' has changed");
9727     DIO_PUT(string, &dout, "team_name", real_packet->team_name);
9728   }
9729 
9730   *old = *real_packet;
9731   SEND_PACKET_END(PACKET_TEAM_NAME_INFO);
9732 }
9733 
send_packet_team_name_info(struct connection * pc,const struct packet_team_name_info * packet)9734 int send_packet_team_name_info(struct connection *pc, const struct packet_team_name_info *packet)
9735 {
9736   if (!pc->used) {
9737     log_error("WARNING: trying to send data to the closed connection %s",
9738               conn_description(pc));
9739     return -1;
9740   }
9741   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_TEAM_NAME_INFO].packet != NULL, -1,
9742                         "Handler for PACKET_TEAM_NAME_INFO not installed");
9743   return pc->phs.handlers->send[PACKET_TEAM_NAME_INFO].packet(pc, packet);
9744 }
9745 
lsend_packet_team_name_info(struct conn_list * dest,const struct packet_team_name_info * packet)9746 void lsend_packet_team_name_info(struct conn_list *dest, const struct packet_team_name_info *packet)
9747 {
9748   conn_list_iterate(dest, pconn) {
9749     send_packet_team_name_info(pconn, packet);
9750   } conn_list_iterate_end;
9751 }
9752 
9753 #define hash_packet_achievement_info_100 hash_const
9754 
9755 #define cmp_packet_achievement_info_100 cmp_const
9756 
9757 BV_DEFINE(packet_achievement_info_100_fields, 3);
9758 
receive_packet_achievement_info_100(struct connection * pc)9759 static struct packet_achievement_info *receive_packet_achievement_info_100(struct connection *pc)
9760 {
9761   packet_achievement_info_100_fields fields;
9762   struct packet_achievement_info *old;
9763   struct genhash **hash = pc->phs.received + PACKET_ACHIEVEMENT_INFO;
9764   RECEIVE_PACKET_START(packet_achievement_info, real_packet);
9765 
9766   DIO_BV_GET(&din, fields);
9767 
9768   log_packet_detailed("packet_achievement_info_100: got info about ()");
9769 
9770   if (NULL == *hash) {
9771     *hash = genhash_new_full(hash_packet_achievement_info_100, cmp_packet_achievement_info_100,
9772                              NULL, NULL, NULL, free);
9773   }
9774 
9775   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
9776     *real_packet = *old;
9777   } else {
9778     log_packet_detailed("  no old info");
9779     memset(real_packet, 0, sizeof(*real_packet));
9780   }
9781 
9782   if (BV_ISSET(fields, 0)) {
9783     log_packet_detailed("  got field 'id'");
9784     if (!DIO_GET(uint8, &din, "id", &real_packet->id)) {
9785       RECEIVE_PACKET_FIELD_ERROR(id);
9786     }
9787   }
9788   real_packet->gained = BV_ISSET(fields, 1);
9789   real_packet->first = BV_ISSET(fields, 2);
9790 
9791   if (NULL == old) {
9792     old = fc_malloc(sizeof(*old));
9793     *old = *real_packet;
9794     genhash_insert(*hash, old, old);
9795   } else {
9796     *old = *real_packet;
9797   }
9798   RECEIVE_PACKET_END(real_packet);
9799 }
9800 
send_packet_achievement_info_100(struct connection * pc,const struct packet_achievement_info * packet)9801 static int send_packet_achievement_info_100(struct connection *pc, const struct packet_achievement_info *packet)
9802 {
9803   const struct packet_achievement_info *real_packet = packet;
9804   packet_achievement_info_100_fields fields;
9805   struct packet_achievement_info *old;
9806   bool differ;
9807   struct genhash **hash = pc->phs.sent + PACKET_ACHIEVEMENT_INFO;
9808   int different = 0;
9809   SEND_PACKET_START(PACKET_ACHIEVEMENT_INFO);
9810 
9811   log_packet_detailed("packet_achievement_info_100: sending info about ()");
9812 
9813   if (NULL == *hash) {
9814     *hash = genhash_new_full(hash_packet_achievement_info_100, cmp_packet_achievement_info_100,
9815                              NULL, NULL, NULL, free);
9816   }
9817   BV_CLR_ALL(fields);
9818 
9819   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
9820     old = fc_malloc(sizeof(*old));
9821     *old = *real_packet;
9822     genhash_insert(*hash, old, old);
9823     memset(old, 0, sizeof(*old));
9824     different = 1;      /* Force to send. */
9825   }
9826 
9827   differ = (old->id != real_packet->id);
9828   if (differ) {
9829     different++;
9830     BV_SET(fields, 0);
9831   }
9832 
9833   differ = (old->gained != real_packet->gained);
9834   if (differ) {
9835     different++;
9836   }
9837   if (packet->gained) {
9838     BV_SET(fields, 1);
9839   }
9840 
9841   differ = (old->first != real_packet->first);
9842   if (differ) {
9843     different++;
9844   }
9845   if (packet->first) {
9846     BV_SET(fields, 2);
9847   }
9848 
9849 
9850   DIO_BV_PUT(&dout, "fields", fields);
9851 
9852   if (BV_ISSET(fields, 0)) {
9853     log_packet_detailed("  field 'id' has changed");
9854     DIO_PUT(uint8, &dout, "id", real_packet->id);
9855   }
9856   /* field 1 is folded into the header */
9857   /* field 2 is folded into the header */
9858 
9859   *old = *real_packet;
9860   SEND_PACKET_END(PACKET_ACHIEVEMENT_INFO);
9861 }
9862 
send_packet_achievement_info(struct connection * pc,const struct packet_achievement_info * packet)9863 int send_packet_achievement_info(struct connection *pc, const struct packet_achievement_info *packet)
9864 {
9865   if (!pc->used) {
9866     log_error("WARNING: trying to send data to the closed connection %s",
9867               conn_description(pc));
9868     return -1;
9869   }
9870   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_ACHIEVEMENT_INFO].packet != NULL, -1,
9871                         "Handler for PACKET_ACHIEVEMENT_INFO not installed");
9872   return pc->phs.handlers->send[PACKET_ACHIEVEMENT_INFO].packet(pc, packet);
9873 }
9874 
lsend_packet_achievement_info(struct conn_list * dest,const struct packet_achievement_info * packet)9875 void lsend_packet_achievement_info(struct conn_list *dest, const struct packet_achievement_info *packet)
9876 {
9877   conn_list_iterate(dest, pconn) {
9878     send_packet_achievement_info(pconn, packet);
9879   } conn_list_iterate_end;
9880 }
9881 
9882 #define hash_packet_chat_msg_100 hash_const
9883 
9884 #define cmp_packet_chat_msg_100 cmp_const
9885 
9886 BV_DEFINE(packet_chat_msg_100_fields, 6);
9887 
receive_packet_chat_msg_100(struct connection * pc)9888 static struct packet_chat_msg *receive_packet_chat_msg_100(struct connection *pc)
9889 {
9890   packet_chat_msg_100_fields fields;
9891   struct packet_chat_msg *old;
9892   struct genhash **hash = pc->phs.received + PACKET_CHAT_MSG;
9893   RECEIVE_PACKET_START(packet_chat_msg, real_packet);
9894 
9895   DIO_BV_GET(&din, fields);
9896 
9897   log_packet_detailed("packet_chat_msg_100: got info about ()");
9898 
9899   if (NULL == *hash) {
9900     *hash = genhash_new_full(hash_packet_chat_msg_100, cmp_packet_chat_msg_100,
9901                              NULL, NULL, NULL, free);
9902   }
9903 
9904   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
9905     *real_packet = *old;
9906   } else {
9907     log_packet_detailed("  no old info");
9908     memset(real_packet, 0, sizeof(*real_packet));
9909   }
9910 
9911   if (BV_ISSET(fields, 0)) {
9912     log_packet_detailed("  got field 'message'");
9913     if (!DIO_GET(string, &din, "message", real_packet->message, sizeof(real_packet->message))) {
9914       RECEIVE_PACKET_FIELD_ERROR(message);
9915     }
9916   }
9917   if (BV_ISSET(fields, 1)) {
9918     log_packet_detailed("  got field 'tile'");
9919     if (!DIO_GET(sint32, &din, "tile", &real_packet->tile)) {
9920       RECEIVE_PACKET_FIELD_ERROR(tile);
9921     }
9922   }
9923   if (BV_ISSET(fields, 2)) {
9924     log_packet_detailed("  got field 'event'");
9925     {
9926       int readin;
9927 
9928       if (!DIO_GET(sint16, &din, "event", &readin)) {
9929         RECEIVE_PACKET_FIELD_ERROR(event);
9930       }
9931       real_packet->event = readin;
9932     }
9933   }
9934   if (BV_ISSET(fields, 3)) {
9935     log_packet_detailed("  got field 'turn'");
9936     if (!DIO_GET(sint16, &din, "turn", &real_packet->turn)) {
9937       RECEIVE_PACKET_FIELD_ERROR(turn);
9938     }
9939   }
9940   if (BV_ISSET(fields, 4)) {
9941     log_packet_detailed("  got field 'phase'");
9942     if (!DIO_GET(sint16, &din, "phase", &real_packet->phase)) {
9943       RECEIVE_PACKET_FIELD_ERROR(phase);
9944     }
9945   }
9946   if (BV_ISSET(fields, 5)) {
9947     log_packet_detailed("  got field 'conn_id'");
9948     if (!DIO_GET(sint16, &din, "conn_id", &real_packet->conn_id)) {
9949       RECEIVE_PACKET_FIELD_ERROR(conn_id);
9950     }
9951   }
9952 
9953   if (NULL == old) {
9954     old = fc_malloc(sizeof(*old));
9955     *old = *real_packet;
9956     genhash_insert(*hash, old, old);
9957   } else {
9958     *old = *real_packet;
9959   }
9960   RECEIVE_PACKET_END(real_packet);
9961 }
9962 
send_packet_chat_msg_100(struct connection * pc,const struct packet_chat_msg * packet)9963 static int send_packet_chat_msg_100(struct connection *pc, const struct packet_chat_msg *packet)
9964 {
9965   const struct packet_chat_msg *real_packet = packet;
9966   packet_chat_msg_100_fields fields;
9967   struct packet_chat_msg *old;
9968   bool differ;
9969   struct genhash **hash = pc->phs.sent + PACKET_CHAT_MSG;
9970   int different = 0;
9971   SEND_PACKET_START(PACKET_CHAT_MSG);
9972 
9973   log_packet_detailed("packet_chat_msg_100: sending info about ()");
9974 
9975   if (NULL == *hash) {
9976     *hash = genhash_new_full(hash_packet_chat_msg_100, cmp_packet_chat_msg_100,
9977                              NULL, NULL, NULL, free);
9978   }
9979   BV_CLR_ALL(fields);
9980 
9981   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
9982     old = fc_malloc(sizeof(*old));
9983     *old = *real_packet;
9984     genhash_insert(*hash, old, old);
9985     memset(old, 0, sizeof(*old));
9986     different = 1;      /* Force to send. */
9987   }
9988 
9989   differ = (strcmp(old->message, real_packet->message) != 0);
9990   if (differ) {
9991     different++;
9992     BV_SET(fields, 0);
9993   }
9994 
9995   differ = (old->tile != real_packet->tile);
9996   if (differ) {
9997     different++;
9998     BV_SET(fields, 1);
9999   }
10000 
10001   differ = (old->event != real_packet->event);
10002   if (differ) {
10003     different++;
10004     BV_SET(fields, 2);
10005   }
10006 
10007   differ = (old->turn != real_packet->turn);
10008   if (differ) {
10009     different++;
10010     BV_SET(fields, 3);
10011   }
10012 
10013   differ = (old->phase != real_packet->phase);
10014   if (differ) {
10015     different++;
10016     BV_SET(fields, 4);
10017   }
10018 
10019   differ = (old->conn_id != real_packet->conn_id);
10020   if (differ) {
10021     different++;
10022     BV_SET(fields, 5);
10023   }
10024 
10025 
10026   DIO_BV_PUT(&dout, "fields", fields);
10027 
10028   if (BV_ISSET(fields, 0)) {
10029     log_packet_detailed("  field 'message' has changed");
10030     DIO_PUT(string, &dout, "message", real_packet->message);
10031   }
10032   if (BV_ISSET(fields, 1)) {
10033     log_packet_detailed("  field 'tile' has changed");
10034     DIO_PUT(sint32, &dout, "tile", real_packet->tile);
10035   }
10036   if (BV_ISSET(fields, 2)) {
10037     log_packet_detailed("  field 'event' has changed");
10038     DIO_PUT(sint16, &dout, "event", real_packet->event);
10039   }
10040   if (BV_ISSET(fields, 3)) {
10041     log_packet_detailed("  field 'turn' has changed");
10042     DIO_PUT(sint16, &dout, "turn", real_packet->turn);
10043   }
10044   if (BV_ISSET(fields, 4)) {
10045     log_packet_detailed("  field 'phase' has changed");
10046     DIO_PUT(sint16, &dout, "phase", real_packet->phase);
10047   }
10048   if (BV_ISSET(fields, 5)) {
10049     log_packet_detailed("  field 'conn_id' has changed");
10050     DIO_PUT(sint16, &dout, "conn_id", real_packet->conn_id);
10051   }
10052 
10053   *old = *real_packet;
10054   SEND_PACKET_END(PACKET_CHAT_MSG);
10055 }
10056 
send_packet_chat_msg(struct connection * pc,const struct packet_chat_msg * packet)10057 int send_packet_chat_msg(struct connection *pc, const struct packet_chat_msg *packet)
10058 {
10059   if (!pc->used) {
10060     log_error("WARNING: trying to send data to the closed connection %s",
10061               conn_description(pc));
10062     return -1;
10063   }
10064   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CHAT_MSG].packet != NULL, -1,
10065                         "Handler for PACKET_CHAT_MSG not installed");
10066   return pc->phs.handlers->send[PACKET_CHAT_MSG].packet(pc, packet);
10067 }
10068 
lsend_packet_chat_msg(struct conn_list * dest,const struct packet_chat_msg * packet)10069 void lsend_packet_chat_msg(struct conn_list *dest, const struct packet_chat_msg *packet)
10070 {
10071   conn_list_iterate(dest, pconn) {
10072     send_packet_chat_msg(pconn, packet);
10073   } conn_list_iterate_end;
10074 }
10075 
10076 #define hash_packet_early_chat_msg_100 hash_const
10077 
10078 #define cmp_packet_early_chat_msg_100 cmp_const
10079 
10080 BV_DEFINE(packet_early_chat_msg_100_fields, 6);
10081 
receive_packet_early_chat_msg_100(struct connection * pc)10082 static struct packet_early_chat_msg *receive_packet_early_chat_msg_100(struct connection *pc)
10083 {
10084   packet_early_chat_msg_100_fields fields;
10085   struct packet_early_chat_msg *old;
10086   struct genhash **hash = pc->phs.received + PACKET_EARLY_CHAT_MSG;
10087   RECEIVE_PACKET_START(packet_early_chat_msg, real_packet);
10088 
10089   DIO_BV_GET(&din, fields);
10090 
10091   log_packet_detailed("packet_early_chat_msg_100: got info about ()");
10092 
10093   if (NULL == *hash) {
10094     *hash = genhash_new_full(hash_packet_early_chat_msg_100, cmp_packet_early_chat_msg_100,
10095                              NULL, NULL, NULL, free);
10096   }
10097 
10098   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
10099     *real_packet = *old;
10100   } else {
10101     log_packet_detailed("  no old info");
10102     memset(real_packet, 0, sizeof(*real_packet));
10103   }
10104 
10105   if (BV_ISSET(fields, 0)) {
10106     log_packet_detailed("  got field 'message'");
10107     if (!DIO_GET(string, &din, "message", real_packet->message, sizeof(real_packet->message))) {
10108       RECEIVE_PACKET_FIELD_ERROR(message);
10109     }
10110   }
10111   if (BV_ISSET(fields, 1)) {
10112     log_packet_detailed("  got field 'tile'");
10113     if (!DIO_GET(sint32, &din, "tile", &real_packet->tile)) {
10114       RECEIVE_PACKET_FIELD_ERROR(tile);
10115     }
10116   }
10117   if (BV_ISSET(fields, 2)) {
10118     log_packet_detailed("  got field 'event'");
10119     {
10120       int readin;
10121 
10122       if (!DIO_GET(sint16, &din, "event", &readin)) {
10123         RECEIVE_PACKET_FIELD_ERROR(event);
10124       }
10125       real_packet->event = readin;
10126     }
10127   }
10128   if (BV_ISSET(fields, 3)) {
10129     log_packet_detailed("  got field 'turn'");
10130     if (!DIO_GET(sint16, &din, "turn", &real_packet->turn)) {
10131       RECEIVE_PACKET_FIELD_ERROR(turn);
10132     }
10133   }
10134   if (BV_ISSET(fields, 4)) {
10135     log_packet_detailed("  got field 'phase'");
10136     if (!DIO_GET(sint16, &din, "phase", &real_packet->phase)) {
10137       RECEIVE_PACKET_FIELD_ERROR(phase);
10138     }
10139   }
10140   if (BV_ISSET(fields, 5)) {
10141     log_packet_detailed("  got field 'conn_id'");
10142     if (!DIO_GET(sint16, &din, "conn_id", &real_packet->conn_id)) {
10143       RECEIVE_PACKET_FIELD_ERROR(conn_id);
10144     }
10145   }
10146 
10147   if (NULL == old) {
10148     old = fc_malloc(sizeof(*old));
10149     *old = *real_packet;
10150     genhash_insert(*hash, old, old);
10151   } else {
10152     *old = *real_packet;
10153   }
10154   RECEIVE_PACKET_END(real_packet);
10155 }
10156 
send_packet_early_chat_msg_100(struct connection * pc,const struct packet_early_chat_msg * packet)10157 static int send_packet_early_chat_msg_100(struct connection *pc, const struct packet_early_chat_msg *packet)
10158 {
10159   const struct packet_early_chat_msg *real_packet = packet;
10160   packet_early_chat_msg_100_fields fields;
10161   struct packet_early_chat_msg *old;
10162   bool differ;
10163   struct genhash **hash = pc->phs.sent + PACKET_EARLY_CHAT_MSG;
10164   int different = 0;
10165   SEND_PACKET_START(PACKET_EARLY_CHAT_MSG);
10166 
10167   log_packet_detailed("packet_early_chat_msg_100: sending info about ()");
10168 
10169   if (NULL == *hash) {
10170     *hash = genhash_new_full(hash_packet_early_chat_msg_100, cmp_packet_early_chat_msg_100,
10171                              NULL, NULL, NULL, free);
10172   }
10173   BV_CLR_ALL(fields);
10174 
10175   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
10176     old = fc_malloc(sizeof(*old));
10177     *old = *real_packet;
10178     genhash_insert(*hash, old, old);
10179     memset(old, 0, sizeof(*old));
10180     different = 1;      /* Force to send. */
10181   }
10182 
10183   differ = (strcmp(old->message, real_packet->message) != 0);
10184   if (differ) {
10185     different++;
10186     BV_SET(fields, 0);
10187   }
10188 
10189   differ = (old->tile != real_packet->tile);
10190   if (differ) {
10191     different++;
10192     BV_SET(fields, 1);
10193   }
10194 
10195   differ = (old->event != real_packet->event);
10196   if (differ) {
10197     different++;
10198     BV_SET(fields, 2);
10199   }
10200 
10201   differ = (old->turn != real_packet->turn);
10202   if (differ) {
10203     different++;
10204     BV_SET(fields, 3);
10205   }
10206 
10207   differ = (old->phase != real_packet->phase);
10208   if (differ) {
10209     different++;
10210     BV_SET(fields, 4);
10211   }
10212 
10213   differ = (old->conn_id != real_packet->conn_id);
10214   if (differ) {
10215     different++;
10216     BV_SET(fields, 5);
10217   }
10218 
10219 
10220   DIO_BV_PUT(&dout, "fields", fields);
10221 
10222   if (BV_ISSET(fields, 0)) {
10223     log_packet_detailed("  field 'message' has changed");
10224     DIO_PUT(string, &dout, "message", real_packet->message);
10225   }
10226   if (BV_ISSET(fields, 1)) {
10227     log_packet_detailed("  field 'tile' has changed");
10228     DIO_PUT(sint32, &dout, "tile", real_packet->tile);
10229   }
10230   if (BV_ISSET(fields, 2)) {
10231     log_packet_detailed("  field 'event' has changed");
10232     DIO_PUT(sint16, &dout, "event", real_packet->event);
10233   }
10234   if (BV_ISSET(fields, 3)) {
10235     log_packet_detailed("  field 'turn' has changed");
10236     DIO_PUT(sint16, &dout, "turn", real_packet->turn);
10237   }
10238   if (BV_ISSET(fields, 4)) {
10239     log_packet_detailed("  field 'phase' has changed");
10240     DIO_PUT(sint16, &dout, "phase", real_packet->phase);
10241   }
10242   if (BV_ISSET(fields, 5)) {
10243     log_packet_detailed("  field 'conn_id' has changed");
10244     DIO_PUT(sint16, &dout, "conn_id", real_packet->conn_id);
10245   }
10246 
10247   *old = *real_packet;
10248   SEND_PACKET_END(PACKET_EARLY_CHAT_MSG);
10249 }
10250 
send_packet_early_chat_msg(struct connection * pc,const struct packet_early_chat_msg * packet)10251 int send_packet_early_chat_msg(struct connection *pc, const struct packet_early_chat_msg *packet)
10252 {
10253   if (!pc->used) {
10254     log_error("WARNING: trying to send data to the closed connection %s",
10255               conn_description(pc));
10256     return -1;
10257   }
10258   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EARLY_CHAT_MSG].packet != NULL, -1,
10259                         "Handler for PACKET_EARLY_CHAT_MSG not installed");
10260   return pc->phs.handlers->send[PACKET_EARLY_CHAT_MSG].packet(pc, packet);
10261 }
10262 
lsend_packet_early_chat_msg(struct conn_list * dest,const struct packet_early_chat_msg * packet)10263 void lsend_packet_early_chat_msg(struct conn_list *dest, const struct packet_early_chat_msg *packet)
10264 {
10265   conn_list_iterate(dest, pconn) {
10266     send_packet_early_chat_msg(pconn, packet);
10267   } conn_list_iterate_end;
10268 }
10269 
10270 #define hash_packet_chat_msg_req_100 hash_const
10271 
10272 #define cmp_packet_chat_msg_req_100 cmp_const
10273 
10274 BV_DEFINE(packet_chat_msg_req_100_fields, 1);
10275 
receive_packet_chat_msg_req_100(struct connection * pc)10276 static struct packet_chat_msg_req *receive_packet_chat_msg_req_100(struct connection *pc)
10277 {
10278   packet_chat_msg_req_100_fields fields;
10279   struct packet_chat_msg_req *old;
10280   struct genhash **hash = pc->phs.received + PACKET_CHAT_MSG_REQ;
10281   RECEIVE_PACKET_START(packet_chat_msg_req, real_packet);
10282 
10283   DIO_BV_GET(&din, fields);
10284 
10285   log_packet_detailed("packet_chat_msg_req_100: got info about ()");
10286 
10287   if (NULL == *hash) {
10288     *hash = genhash_new_full(hash_packet_chat_msg_req_100, cmp_packet_chat_msg_req_100,
10289                              NULL, NULL, NULL, free);
10290   }
10291 
10292   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
10293     *real_packet = *old;
10294   } else {
10295     log_packet_detailed("  no old info");
10296     memset(real_packet, 0, sizeof(*real_packet));
10297   }
10298 
10299   if (BV_ISSET(fields, 0)) {
10300     log_packet_detailed("  got field 'message'");
10301     if (!DIO_GET(string, &din, "message", real_packet->message, sizeof(real_packet->message))) {
10302       RECEIVE_PACKET_FIELD_ERROR(message);
10303     }
10304   }
10305 
10306   if (NULL == old) {
10307     old = fc_malloc(sizeof(*old));
10308     *old = *real_packet;
10309     genhash_insert(*hash, old, old);
10310   } else {
10311     *old = *real_packet;
10312   }
10313   RECEIVE_PACKET_END(real_packet);
10314 }
10315 
send_packet_chat_msg_req_100(struct connection * pc,const struct packet_chat_msg_req * packet)10316 static int send_packet_chat_msg_req_100(struct connection *pc, const struct packet_chat_msg_req *packet)
10317 {
10318   const struct packet_chat_msg_req *real_packet = packet;
10319   packet_chat_msg_req_100_fields fields;
10320   struct packet_chat_msg_req *old;
10321   bool differ;
10322   struct genhash **hash = pc->phs.sent + PACKET_CHAT_MSG_REQ;
10323   int different = 0;
10324   SEND_PACKET_START(PACKET_CHAT_MSG_REQ);
10325 
10326   log_packet_detailed("packet_chat_msg_req_100: sending info about ()");
10327 
10328   if (NULL == *hash) {
10329     *hash = genhash_new_full(hash_packet_chat_msg_req_100, cmp_packet_chat_msg_req_100,
10330                              NULL, NULL, NULL, free);
10331   }
10332   BV_CLR_ALL(fields);
10333 
10334   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
10335     old = fc_malloc(sizeof(*old));
10336     *old = *real_packet;
10337     genhash_insert(*hash, old, old);
10338     memset(old, 0, sizeof(*old));
10339     different = 1;      /* Force to send. */
10340   }
10341 
10342   differ = (strcmp(old->message, real_packet->message) != 0);
10343   if (differ) {
10344     different++;
10345     BV_SET(fields, 0);
10346   }
10347 
10348 
10349   DIO_BV_PUT(&dout, "fields", fields);
10350 
10351   if (BV_ISSET(fields, 0)) {
10352     log_packet_detailed("  field 'message' has changed");
10353     DIO_PUT(string, &dout, "message", real_packet->message);
10354   }
10355 
10356   *old = *real_packet;
10357   SEND_PACKET_END(PACKET_CHAT_MSG_REQ);
10358 }
10359 
send_packet_chat_msg_req(struct connection * pc,const struct packet_chat_msg_req * packet)10360 int send_packet_chat_msg_req(struct connection *pc, const struct packet_chat_msg_req *packet)
10361 {
10362   if (!pc->used) {
10363     log_error("WARNING: trying to send data to the closed connection %s",
10364               conn_description(pc));
10365     return -1;
10366   }
10367   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CHAT_MSG_REQ].packet != NULL, -1,
10368                         "Handler for PACKET_CHAT_MSG_REQ not installed");
10369   return pc->phs.handlers->send[PACKET_CHAT_MSG_REQ].packet(pc, packet);
10370 }
10371 
dsend_packet_chat_msg_req(struct connection * pc,const char * message)10372 int dsend_packet_chat_msg_req(struct connection *pc, const char *message)
10373 {
10374   struct packet_chat_msg_req packet, *real_packet = &packet;
10375 
10376   sz_strlcpy(real_packet->message, message);
10377 
10378   return send_packet_chat_msg_req(pc, real_packet);
10379 }
10380 
10381 #define hash_packet_connect_msg_100 hash_const
10382 
10383 #define cmp_packet_connect_msg_100 cmp_const
10384 
10385 BV_DEFINE(packet_connect_msg_100_fields, 1);
10386 
receive_packet_connect_msg_100(struct connection * pc)10387 static struct packet_connect_msg *receive_packet_connect_msg_100(struct connection *pc)
10388 {
10389   packet_connect_msg_100_fields fields;
10390   struct packet_connect_msg *old;
10391   struct genhash **hash = pc->phs.received + PACKET_CONNECT_MSG;
10392   RECEIVE_PACKET_START(packet_connect_msg, real_packet);
10393 
10394   DIO_BV_GET(&din, fields);
10395 
10396   log_packet_detailed("packet_connect_msg_100: got info about ()");
10397 
10398   if (NULL == *hash) {
10399     *hash = genhash_new_full(hash_packet_connect_msg_100, cmp_packet_connect_msg_100,
10400                              NULL, NULL, NULL, free);
10401   }
10402 
10403   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
10404     *real_packet = *old;
10405   } else {
10406     log_packet_detailed("  no old info");
10407     memset(real_packet, 0, sizeof(*real_packet));
10408   }
10409 
10410   if (BV_ISSET(fields, 0)) {
10411     log_packet_detailed("  got field 'message'");
10412     if (!DIO_GET(string, &din, "message", real_packet->message, sizeof(real_packet->message))) {
10413       RECEIVE_PACKET_FIELD_ERROR(message);
10414     }
10415   }
10416 
10417   if (NULL == old) {
10418     old = fc_malloc(sizeof(*old));
10419     *old = *real_packet;
10420     genhash_insert(*hash, old, old);
10421   } else {
10422     *old = *real_packet;
10423   }
10424   RECEIVE_PACKET_END(real_packet);
10425 }
10426 
send_packet_connect_msg_100(struct connection * pc,const struct packet_connect_msg * packet)10427 static int send_packet_connect_msg_100(struct connection *pc, const struct packet_connect_msg *packet)
10428 {
10429   const struct packet_connect_msg *real_packet = packet;
10430   packet_connect_msg_100_fields fields;
10431   struct packet_connect_msg *old;
10432   bool differ;
10433   struct genhash **hash = pc->phs.sent + PACKET_CONNECT_MSG;
10434   int different = 0;
10435   SEND_PACKET_START(PACKET_CONNECT_MSG);
10436 
10437   log_packet_detailed("packet_connect_msg_100: sending info about ()");
10438 
10439   if (NULL == *hash) {
10440     *hash = genhash_new_full(hash_packet_connect_msg_100, cmp_packet_connect_msg_100,
10441                              NULL, NULL, NULL, free);
10442   }
10443   BV_CLR_ALL(fields);
10444 
10445   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
10446     old = fc_malloc(sizeof(*old));
10447     *old = *real_packet;
10448     genhash_insert(*hash, old, old);
10449     memset(old, 0, sizeof(*old));
10450     different = 1;      /* Force to send. */
10451   }
10452 
10453   differ = (strcmp(old->message, real_packet->message) != 0);
10454   if (differ) {
10455     different++;
10456     BV_SET(fields, 0);
10457   }
10458 
10459 
10460   DIO_BV_PUT(&dout, "fields", fields);
10461 
10462   if (BV_ISSET(fields, 0)) {
10463     log_packet_detailed("  field 'message' has changed");
10464     DIO_PUT(string, &dout, "message", real_packet->message);
10465   }
10466 
10467   *old = *real_packet;
10468   SEND_PACKET_END(PACKET_CONNECT_MSG);
10469 }
10470 
send_packet_connect_msg(struct connection * pc,const struct packet_connect_msg * packet)10471 int send_packet_connect_msg(struct connection *pc, const struct packet_connect_msg *packet)
10472 {
10473   if (!pc->used) {
10474     log_error("WARNING: trying to send data to the closed connection %s",
10475               conn_description(pc));
10476     return -1;
10477   }
10478   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CONNECT_MSG].packet != NULL, -1,
10479                         "Handler for PACKET_CONNECT_MSG not installed");
10480   return pc->phs.handlers->send[PACKET_CONNECT_MSG].packet(pc, packet);
10481 }
10482 
dsend_packet_connect_msg(struct connection * pc,const char * message)10483 int dsend_packet_connect_msg(struct connection *pc, const char *message)
10484 {
10485   struct packet_connect_msg packet, *real_packet = &packet;
10486 
10487   sz_strlcpy(real_packet->message, message);
10488 
10489   return send_packet_connect_msg(pc, real_packet);
10490 }
10491 
10492 #define hash_packet_city_remove_100 hash_const
10493 
10494 #define cmp_packet_city_remove_100 cmp_const
10495 
10496 BV_DEFINE(packet_city_remove_100_fields, 1);
10497 
receive_packet_city_remove_100(struct connection * pc)10498 static struct packet_city_remove *receive_packet_city_remove_100(struct connection *pc)
10499 {
10500   packet_city_remove_100_fields fields;
10501   struct packet_city_remove *old;
10502   struct genhash **hash = pc->phs.received + PACKET_CITY_REMOVE;
10503   RECEIVE_PACKET_START(packet_city_remove, real_packet);
10504 
10505   DIO_BV_GET(&din, fields);
10506 
10507   log_packet_detailed("packet_city_remove_100: got info about ()");
10508 
10509   if (NULL == *hash) {
10510     *hash = genhash_new_full(hash_packet_city_remove_100, cmp_packet_city_remove_100,
10511                              NULL, NULL, NULL, free);
10512   }
10513 
10514   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
10515     *real_packet = *old;
10516   } else {
10517     log_packet_detailed("  no old info");
10518     memset(real_packet, 0, sizeof(*real_packet));
10519   }
10520 
10521   if (BV_ISSET(fields, 0)) {
10522     log_packet_detailed("  got field 'city_id'");
10523     if (!DIO_GET(uint16, &din, "city_id", &real_packet->city_id)) {
10524       RECEIVE_PACKET_FIELD_ERROR(city_id);
10525     }
10526   }
10527 
10528   if (NULL == old) {
10529     old = fc_malloc(sizeof(*old));
10530     *old = *real_packet;
10531     genhash_insert(*hash, old, old);
10532   } else {
10533     *old = *real_packet;
10534   }
10535 
10536   hash = pc->phs.received + PACKET_CITY_INFO;
10537   if (NULL != *hash) {
10538     genhash_remove(*hash, real_packet);
10539   }
10540 
10541   hash = pc->phs.received + PACKET_CITY_SHORT_INFO;
10542   if (NULL != *hash) {
10543     genhash_remove(*hash, real_packet);
10544   }
10545   RECEIVE_PACKET_END(real_packet);
10546 }
10547 
send_packet_city_remove_100(struct connection * pc,const struct packet_city_remove * packet)10548 static int send_packet_city_remove_100(struct connection *pc, const struct packet_city_remove *packet)
10549 {
10550   const struct packet_city_remove *real_packet = packet;
10551   packet_city_remove_100_fields fields;
10552   struct packet_city_remove *old;
10553   bool differ;
10554   struct genhash **hash = pc->phs.sent + PACKET_CITY_REMOVE;
10555   int different = 0;
10556   SEND_PACKET_START(PACKET_CITY_REMOVE);
10557 
10558   log_packet_detailed("packet_city_remove_100: sending info about ()");
10559 
10560   if (NULL == *hash) {
10561     *hash = genhash_new_full(hash_packet_city_remove_100, cmp_packet_city_remove_100,
10562                              NULL, NULL, NULL, free);
10563   }
10564   BV_CLR_ALL(fields);
10565 
10566   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
10567     old = fc_malloc(sizeof(*old));
10568     *old = *real_packet;
10569     genhash_insert(*hash, old, old);
10570     memset(old, 0, sizeof(*old));
10571     different = 1;      /* Force to send. */
10572   }
10573 
10574   differ = (old->city_id != real_packet->city_id);
10575   if (differ) {
10576     different++;
10577     BV_SET(fields, 0);
10578   }
10579 
10580 
10581   DIO_BV_PUT(&dout, "fields", fields);
10582 
10583   if (BV_ISSET(fields, 0)) {
10584     log_packet_detailed("  field 'city_id' has changed");
10585     DIO_PUT(uint16, &dout, "city_id", real_packet->city_id);
10586   }
10587 
10588   *old = *real_packet;
10589 
10590   hash = pc->phs.sent + PACKET_CITY_INFO;
10591   if (NULL != *hash) {
10592     genhash_remove(*hash, real_packet);
10593   }
10594 
10595   hash = pc->phs.sent + PACKET_CITY_SHORT_INFO;
10596   if (NULL != *hash) {
10597     genhash_remove(*hash, real_packet);
10598   }
10599   SEND_PACKET_END(PACKET_CITY_REMOVE);
10600 }
10601 
send_packet_city_remove(struct connection * pc,const struct packet_city_remove * packet)10602 int send_packet_city_remove(struct connection *pc, const struct packet_city_remove *packet)
10603 {
10604   if (!pc->used) {
10605     log_error("WARNING: trying to send data to the closed connection %s",
10606               conn_description(pc));
10607     return -1;
10608   }
10609   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_REMOVE].packet != NULL, -1,
10610                         "Handler for PACKET_CITY_REMOVE not installed");
10611   return pc->phs.handlers->send[PACKET_CITY_REMOVE].packet(pc, packet);
10612 }
10613 
lsend_packet_city_remove(struct conn_list * dest,const struct packet_city_remove * packet)10614 void lsend_packet_city_remove(struct conn_list *dest, const struct packet_city_remove *packet)
10615 {
10616   conn_list_iterate(dest, pconn) {
10617     send_packet_city_remove(pconn, packet);
10618   } conn_list_iterate_end;
10619 }
10620 
dsend_packet_city_remove(struct connection * pc,int city_id)10621 int dsend_packet_city_remove(struct connection *pc, int city_id)
10622 {
10623   struct packet_city_remove packet, *real_packet = &packet;
10624 
10625   real_packet->city_id = city_id;
10626 
10627   return send_packet_city_remove(pc, real_packet);
10628 }
10629 
dlsend_packet_city_remove(struct conn_list * dest,int city_id)10630 void dlsend_packet_city_remove(struct conn_list *dest, int city_id)
10631 {
10632   struct packet_city_remove packet, *real_packet = &packet;
10633 
10634   real_packet->city_id = city_id;
10635 
10636   lsend_packet_city_remove(dest, real_packet);
10637 }
10638 
hash_packet_city_info_100(const void * vkey)10639 static genhash_val_t hash_packet_city_info_100(const void *vkey)
10640 {
10641   const struct packet_city_info *key = (const struct packet_city_info *) vkey;
10642 
10643   return key->id;
10644 }
10645 
cmp_packet_city_info_100(const void * vkey1,const void * vkey2)10646 static bool cmp_packet_city_info_100(const void *vkey1, const void *vkey2)
10647 {
10648   const struct packet_city_info *key1 = (const struct packet_city_info *) vkey1;
10649   const struct packet_city_info *key2 = (const struct packet_city_info *) vkey2;
10650 
10651   return key1->id == key2->id;
10652 }
10653 
10654 BV_DEFINE(packet_city_info_100_fields, 49);
10655 
receive_packet_city_info_100(struct connection * pc)10656 static struct packet_city_info *receive_packet_city_info_100(struct connection *pc)
10657 {
10658   packet_city_info_100_fields fields;
10659   struct packet_city_info *old;
10660   struct genhash **hash = pc->phs.received + PACKET_CITY_INFO;
10661   RECEIVE_PACKET_START(packet_city_info, real_packet);
10662 
10663   DIO_BV_GET(&din, fields);
10664   if (!DIO_GET(uint16, &din, "id", &real_packet->id)) {
10665     RECEIVE_PACKET_FIELD_ERROR(id);
10666   }
10667 
10668   log_packet_detailed("packet_city_info_100: got info about (%d)",
10669     real_packet->id);
10670 
10671   if (NULL == *hash) {
10672     *hash = genhash_new_full(hash_packet_city_info_100, cmp_packet_city_info_100,
10673                              NULL, NULL, NULL, free);
10674   }
10675 
10676   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
10677     *real_packet = *old;
10678   } else {
10679     int id = real_packet->id;
10680 
10681     log_packet_detailed("  no old info");
10682     memset(real_packet, 0, sizeof(*real_packet));
10683 
10684     real_packet->id = id;
10685   }
10686 
10687   if (BV_ISSET(fields, 0)) {
10688     log_packet_detailed("  got field 'tile'");
10689     if (!DIO_GET(sint32, &din, "tile", &real_packet->tile)) {
10690       RECEIVE_PACKET_FIELD_ERROR(tile);
10691     }
10692   }
10693   if (BV_ISSET(fields, 1)) {
10694     log_packet_detailed("  got field 'owner'");
10695     if (!DIO_GET(uint8, &din, "owner", &real_packet->owner)) {
10696       RECEIVE_PACKET_FIELD_ERROR(owner);
10697     }
10698   }
10699   if (BV_ISSET(fields, 2)) {
10700     log_packet_detailed("  got field 'size'");
10701     if (!DIO_GET(uint8, &din, "size", &real_packet->size)) {
10702       RECEIVE_PACKET_FIELD_ERROR(size);
10703     }
10704   }
10705   if (BV_ISSET(fields, 3)) {
10706     log_packet_detailed("  got field 'city_radius_sq'");
10707     if (!DIO_GET(uint8, &din, "city_radius_sq", &real_packet->city_radius_sq)) {
10708       RECEIVE_PACKET_FIELD_ERROR(city_radius_sq);
10709     }
10710   }
10711   if (BV_ISSET(fields, 4)) {
10712     log_packet_detailed("  got field 'style'");
10713     if (!DIO_GET(uint8, &din, "style", &real_packet->style)) {
10714       RECEIVE_PACKET_FIELD_ERROR(style);
10715     }
10716   }
10717   if (BV_ISSET(fields, 5)) {
10718     log_packet_detailed("  got field 'ppl_happy'");
10719 
10720     {
10721       int i;
10722 
10723       for (i = 0; i < FEELING_LAST; i++) {
10724         if (!DIO_GET(uint8, &din, "ppl_happy", &real_packet->ppl_happy[i])) {
10725           RECEIVE_PACKET_FIELD_ERROR(ppl_happy);
10726         }
10727       }
10728     }
10729   }
10730   if (BV_ISSET(fields, 6)) {
10731     log_packet_detailed("  got field 'ppl_content'");
10732 
10733     {
10734       int i;
10735 
10736       for (i = 0; i < FEELING_LAST; i++) {
10737         if (!DIO_GET(uint8, &din, "ppl_content", &real_packet->ppl_content[i])) {
10738           RECEIVE_PACKET_FIELD_ERROR(ppl_content);
10739         }
10740       }
10741     }
10742   }
10743   if (BV_ISSET(fields, 7)) {
10744     log_packet_detailed("  got field 'ppl_unhappy'");
10745 
10746     {
10747       int i;
10748 
10749       for (i = 0; i < FEELING_LAST; i++) {
10750         if (!DIO_GET(uint8, &din, "ppl_unhappy", &real_packet->ppl_unhappy[i])) {
10751           RECEIVE_PACKET_FIELD_ERROR(ppl_unhappy);
10752         }
10753       }
10754     }
10755   }
10756   if (BV_ISSET(fields, 8)) {
10757     log_packet_detailed("  got field 'ppl_angry'");
10758 
10759     {
10760       int i;
10761 
10762       for (i = 0; i < FEELING_LAST; i++) {
10763         if (!DIO_GET(uint8, &din, "ppl_angry", &real_packet->ppl_angry[i])) {
10764           RECEIVE_PACKET_FIELD_ERROR(ppl_angry);
10765         }
10766       }
10767     }
10768   }
10769   if (BV_ISSET(fields, 9)) {
10770     log_packet_detailed("  got field 'specialists_size'");
10771     if (!DIO_GET(uint8, &din, "specialists_size", &real_packet->specialists_size)) {
10772       RECEIVE_PACKET_FIELD_ERROR(specialists_size);
10773     }
10774   }
10775   if (BV_ISSET(fields, 10)) {
10776     log_packet_detailed("  got field 'specialists'");
10777 
10778     {
10779       int i;
10780 
10781       if (real_packet->specialists_size > SP_MAX) {
10782         RECEIVE_PACKET_FIELD_ERROR(specialists, ": truncation array");
10783       }
10784       for (i = 0; i < real_packet->specialists_size; i++) {
10785         if (!DIO_GET(uint8, &din, "specialists", &real_packet->specialists[i])) {
10786           RECEIVE_PACKET_FIELD_ERROR(specialists);
10787         }
10788       }
10789     }
10790   }
10791   if (BV_ISSET(fields, 11)) {
10792     log_packet_detailed("  got field 'nationalities_count'");
10793     if (!DIO_GET(uint8, &din, "nationalities_count", &real_packet->nationalities_count)) {
10794       RECEIVE_PACKET_FIELD_ERROR(nationalities_count);
10795     }
10796   }
10797   if (BV_ISSET(fields, 12)) {
10798     log_packet_detailed("  got field 'nation_id'");
10799 
10800     {
10801       int i;
10802 
10803       if (real_packet->nationalities_count > MAX_NUM_PLAYER_SLOTS) {
10804         RECEIVE_PACKET_FIELD_ERROR(nation_id, ": truncation array");
10805       }
10806       for (i = 0; i < real_packet->nationalities_count; i++) {
10807         if (!DIO_GET(uint8, &din, "nation_id", &real_packet->nation_id[i])) {
10808           RECEIVE_PACKET_FIELD_ERROR(nation_id);
10809         }
10810       }
10811     }
10812   }
10813   if (BV_ISSET(fields, 13)) {
10814     log_packet_detailed("  got field 'nation_citizens'");
10815 
10816     {
10817       int i;
10818 
10819       if (real_packet->nationalities_count > MAX_NUM_PLAYER_SLOTS) {
10820         RECEIVE_PACKET_FIELD_ERROR(nation_citizens, ": truncation array");
10821       }
10822       for (i = 0; i < real_packet->nationalities_count; i++) {
10823         if (!DIO_GET(uint8, &din, "nation_citizens", &real_packet->nation_citizens[i])) {
10824           RECEIVE_PACKET_FIELD_ERROR(nation_citizens);
10825         }
10826       }
10827     }
10828   }
10829   if (BV_ISSET(fields, 14)) {
10830     log_packet_detailed("  got field 'history'");
10831     if (!DIO_GET(uint16, &din, "history", &real_packet->history)) {
10832       RECEIVE_PACKET_FIELD_ERROR(history);
10833     }
10834   }
10835   if (BV_ISSET(fields, 15)) {
10836     log_packet_detailed("  got field 'culture'");
10837     if (!DIO_GET(uint16, &din, "culture", &real_packet->culture)) {
10838       RECEIVE_PACKET_FIELD_ERROR(culture);
10839     }
10840   }
10841   if (BV_ISSET(fields, 16)) {
10842     log_packet_detailed("  got field 'surplus'");
10843 
10844     {
10845       int i;
10846 
10847       for (i = 0; i < O_LAST; i++) {
10848         if (!DIO_GET(sint16, &din, "surplus", &real_packet->surplus[i])) {
10849           RECEIVE_PACKET_FIELD_ERROR(surplus);
10850         }
10851       }
10852     }
10853   }
10854   if (BV_ISSET(fields, 17)) {
10855     log_packet_detailed("  got field 'waste'");
10856 
10857     {
10858       int i;
10859 
10860       for (i = 0; i < O_LAST; i++) {
10861         if (!DIO_GET(uint16, &din, "waste", &real_packet->waste[i])) {
10862           RECEIVE_PACKET_FIELD_ERROR(waste);
10863         }
10864       }
10865     }
10866   }
10867   if (BV_ISSET(fields, 18)) {
10868     log_packet_detailed("  got field 'unhappy_penalty'");
10869 
10870     {
10871       int i;
10872 
10873       for (i = 0; i < O_LAST; i++) {
10874         if (!DIO_GET(sint16, &din, "unhappy_penalty", &real_packet->unhappy_penalty[i])) {
10875           RECEIVE_PACKET_FIELD_ERROR(unhappy_penalty);
10876         }
10877       }
10878     }
10879   }
10880   if (BV_ISSET(fields, 19)) {
10881     log_packet_detailed("  got field 'prod'");
10882 
10883     {
10884       int i;
10885 
10886       for (i = 0; i < O_LAST; i++) {
10887         if (!DIO_GET(uint16, &din, "prod", &real_packet->prod[i])) {
10888           RECEIVE_PACKET_FIELD_ERROR(prod);
10889         }
10890       }
10891     }
10892   }
10893   if (BV_ISSET(fields, 20)) {
10894     log_packet_detailed("  got field 'citizen_base'");
10895 
10896     {
10897       int i;
10898 
10899       for (i = 0; i < O_LAST; i++) {
10900         if (!DIO_GET(sint16, &din, "citizen_base", &real_packet->citizen_base[i])) {
10901           RECEIVE_PACKET_FIELD_ERROR(citizen_base);
10902         }
10903       }
10904     }
10905   }
10906   if (BV_ISSET(fields, 21)) {
10907     log_packet_detailed("  got field 'usage'");
10908 
10909     {
10910       int i;
10911 
10912       for (i = 0; i < O_LAST; i++) {
10913         if (!DIO_GET(sint16, &din, "usage", &real_packet->usage[i])) {
10914           RECEIVE_PACKET_FIELD_ERROR(usage);
10915         }
10916       }
10917     }
10918   }
10919   if (BV_ISSET(fields, 22)) {
10920     log_packet_detailed("  got field 'food_stock'");
10921     if (!DIO_GET(sint16, &din, "food_stock", &real_packet->food_stock)) {
10922       RECEIVE_PACKET_FIELD_ERROR(food_stock);
10923     }
10924   }
10925   if (BV_ISSET(fields, 23)) {
10926     log_packet_detailed("  got field 'shield_stock'");
10927     if (!DIO_GET(uint16, &din, "shield_stock", &real_packet->shield_stock)) {
10928       RECEIVE_PACKET_FIELD_ERROR(shield_stock);
10929     }
10930   }
10931   if (BV_ISSET(fields, 24)) {
10932     log_packet_detailed("  got field 'trade'");
10933 
10934     {
10935       int i;
10936 
10937       for (i = 0; i < MAX_TRADE_ROUTES; i++) {
10938         if (!DIO_GET(uint16, &din, "trade", &real_packet->trade[i])) {
10939           RECEIVE_PACKET_FIELD_ERROR(trade);
10940         }
10941       }
10942     }
10943   }
10944   if (BV_ISSET(fields, 25)) {
10945     log_packet_detailed("  got field 'trade_value'");
10946 
10947     {
10948       int i;
10949 
10950       for (i = 0; i < MAX_TRADE_ROUTES; i++) {
10951         if (!DIO_GET(uint8, &din, "trade_value", &real_packet->trade_value[i])) {
10952           RECEIVE_PACKET_FIELD_ERROR(trade_value);
10953         }
10954       }
10955     }
10956   }
10957   if (BV_ISSET(fields, 26)) {
10958     log_packet_detailed("  got field 'pollution'");
10959     if (!DIO_GET(uint16, &din, "pollution", &real_packet->pollution)) {
10960       RECEIVE_PACKET_FIELD_ERROR(pollution);
10961     }
10962   }
10963   if (BV_ISSET(fields, 27)) {
10964     log_packet_detailed("  got field 'illness_trade'");
10965     if (!DIO_GET(uint16, &din, "illness_trade", &real_packet->illness_trade)) {
10966       RECEIVE_PACKET_FIELD_ERROR(illness_trade);
10967     }
10968   }
10969   if (BV_ISSET(fields, 28)) {
10970     log_packet_detailed("  got field 'production_kind'");
10971     if (!DIO_GET(uint8, &din, "production_kind", &real_packet->production_kind)) {
10972       RECEIVE_PACKET_FIELD_ERROR(production_kind);
10973     }
10974   }
10975   if (BV_ISSET(fields, 29)) {
10976     log_packet_detailed("  got field 'production_value'");
10977     if (!DIO_GET(uint8, &din, "production_value", &real_packet->production_value)) {
10978       RECEIVE_PACKET_FIELD_ERROR(production_value);
10979     }
10980   }
10981   if (BV_ISSET(fields, 30)) {
10982     log_packet_detailed("  got field 'turn_founded'");
10983     if (!DIO_GET(sint16, &din, "turn_founded", &real_packet->turn_founded)) {
10984       RECEIVE_PACKET_FIELD_ERROR(turn_founded);
10985     }
10986   }
10987   if (BV_ISSET(fields, 31)) {
10988     log_packet_detailed("  got field 'turn_last_built'");
10989     if (!DIO_GET(sint16, &din, "turn_last_built", &real_packet->turn_last_built)) {
10990       RECEIVE_PACKET_FIELD_ERROR(turn_last_built);
10991     }
10992   }
10993   if (BV_ISSET(fields, 32)) {
10994     log_packet_detailed("  got field 'changed_from_kind'");
10995     if (!DIO_GET(uint8, &din, "changed_from_kind", &real_packet->changed_from_kind)) {
10996       RECEIVE_PACKET_FIELD_ERROR(changed_from_kind);
10997     }
10998   }
10999   if (BV_ISSET(fields, 33)) {
11000     log_packet_detailed("  got field 'changed_from_value'");
11001     if (!DIO_GET(uint8, &din, "changed_from_value", &real_packet->changed_from_value)) {
11002       RECEIVE_PACKET_FIELD_ERROR(changed_from_value);
11003     }
11004   }
11005   if (BV_ISSET(fields, 34)) {
11006     log_packet_detailed("  got field 'before_change_shields'");
11007     if (!DIO_GET(uint16, &din, "before_change_shields", &real_packet->before_change_shields)) {
11008       RECEIVE_PACKET_FIELD_ERROR(before_change_shields);
11009     }
11010   }
11011   if (BV_ISSET(fields, 35)) {
11012     log_packet_detailed("  got field 'disbanded_shields'");
11013     if (!DIO_GET(uint16, &din, "disbanded_shields", &real_packet->disbanded_shields)) {
11014       RECEIVE_PACKET_FIELD_ERROR(disbanded_shields);
11015     }
11016   }
11017   if (BV_ISSET(fields, 36)) {
11018     log_packet_detailed("  got field 'caravan_shields'");
11019     if (!DIO_GET(uint16, &din, "caravan_shields", &real_packet->caravan_shields)) {
11020       RECEIVE_PACKET_FIELD_ERROR(caravan_shields);
11021     }
11022   }
11023   if (BV_ISSET(fields, 37)) {
11024     log_packet_detailed("  got field 'last_turns_shield_surplus'");
11025     if (!DIO_GET(uint16, &din, "last_turns_shield_surplus", &real_packet->last_turns_shield_surplus)) {
11026       RECEIVE_PACKET_FIELD_ERROR(last_turns_shield_surplus);
11027     }
11028   }
11029   if (BV_ISSET(fields, 38)) {
11030     log_packet_detailed("  got field 'airlift'");
11031     if (!DIO_GET(uint8, &din, "airlift", &real_packet->airlift)) {
11032       RECEIVE_PACKET_FIELD_ERROR(airlift);
11033     }
11034   }
11035   real_packet->did_buy = BV_ISSET(fields, 39);
11036   real_packet->did_sell = BV_ISSET(fields, 40);
11037   real_packet->was_happy = BV_ISSET(fields, 41);
11038   real_packet->diplomat_investigate = BV_ISSET(fields, 42);
11039   if (BV_ISSET(fields, 43)) {
11040     log_packet_detailed("  got field 'walls'");
11041     if (!DIO_GET(uint8, &din, "walls", &real_packet->walls)) {
11042       RECEIVE_PACKET_FIELD_ERROR(walls);
11043     }
11044   }
11045   if (BV_ISSET(fields, 44)) {
11046     log_packet_detailed("  got field 'city_image'");
11047     if (!DIO_GET(sint8, &din, "city_image", &real_packet->city_image)) {
11048       RECEIVE_PACKET_FIELD_ERROR(city_image);
11049     }
11050   }
11051   if (BV_ISSET(fields, 45)) {
11052     log_packet_detailed("  got field 'worklist'");
11053     if (!DIO_GET(worklist, &din, "worklist", &real_packet->worklist)) {
11054       RECEIVE_PACKET_FIELD_ERROR(worklist);
11055     }
11056   }
11057   if (BV_ISSET(fields, 46)) {
11058     log_packet_detailed("  got field 'improvements'");
11059     if (!DIO_BV_GET(&din, real_packet->improvements)) {
11060       RECEIVE_PACKET_FIELD_ERROR(improvements);
11061     }
11062   }
11063   if (BV_ISSET(fields, 47)) {
11064     log_packet_detailed("  got field 'city_options'");
11065     if (!DIO_BV_GET(&din, real_packet->city_options)) {
11066       RECEIVE_PACKET_FIELD_ERROR(city_options);
11067     }
11068   }
11069   if (BV_ISSET(fields, 48)) {
11070     log_packet_detailed("  got field 'name'");
11071     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
11072       RECEIVE_PACKET_FIELD_ERROR(name);
11073     }
11074   }
11075 
11076   if (NULL == old) {
11077     old = fc_malloc(sizeof(*old));
11078     *old = *real_packet;
11079     genhash_insert(*hash, old, old);
11080   } else {
11081     *old = *real_packet;
11082   }
11083 
11084   hash = pc->phs.received + PACKET_CITY_SHORT_INFO;
11085   if (NULL != *hash) {
11086     genhash_remove(*hash, real_packet);
11087   }
11088   RECEIVE_PACKET_END(real_packet);
11089 }
11090 
send_packet_city_info_100(struct connection * pc,const struct packet_city_info * packet,bool force_to_send)11091 static int send_packet_city_info_100(struct connection *pc, const struct packet_city_info *packet, bool force_to_send)
11092 {
11093   const struct packet_city_info *real_packet = packet;
11094   packet_city_info_100_fields fields;
11095   struct packet_city_info *old;
11096   bool differ;
11097   struct genhash **hash = pc->phs.sent + PACKET_CITY_INFO;
11098   int different = force_to_send;
11099   SEND_PACKET_START(PACKET_CITY_INFO);
11100 
11101   log_packet_detailed("packet_city_info_100: sending info about (%d)",
11102     real_packet->id);
11103 
11104   if (NULL == *hash) {
11105     *hash = genhash_new_full(hash_packet_city_info_100, cmp_packet_city_info_100,
11106                              NULL, NULL, NULL, free);
11107   }
11108   BV_CLR_ALL(fields);
11109 
11110   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
11111     old = fc_malloc(sizeof(*old));
11112     *old = *real_packet;
11113     genhash_insert(*hash, old, old);
11114     memset(old, 0, sizeof(*old));
11115     different = 1;      /* Force to send. */
11116   }
11117 
11118   differ = (old->tile != real_packet->tile);
11119   if (differ) {
11120     different++;
11121     BV_SET(fields, 0);
11122   }
11123 
11124   differ = (old->owner != real_packet->owner);
11125   if (differ) {
11126     different++;
11127     BV_SET(fields, 1);
11128   }
11129 
11130   differ = (old->size != real_packet->size);
11131   if (differ) {
11132     different++;
11133     BV_SET(fields, 2);
11134   }
11135 
11136   differ = (old->city_radius_sq != real_packet->city_radius_sq);
11137   if (differ) {
11138     different++;
11139     BV_SET(fields, 3);
11140   }
11141 
11142   differ = (old->style != real_packet->style);
11143   if (differ) {
11144     different++;
11145     BV_SET(fields, 4);
11146   }
11147 
11148 
11149     {
11150       differ = (FEELING_LAST != FEELING_LAST);
11151       if (!differ) {
11152         int i;
11153 
11154         for (i = 0; i < FEELING_LAST; i++) {
11155           if (old->ppl_happy[i] != real_packet->ppl_happy[i]) {
11156             differ = TRUE;
11157             break;
11158           }
11159         }
11160       }
11161     }
11162   if (differ) {
11163     different++;
11164     BV_SET(fields, 5);
11165   }
11166 
11167 
11168     {
11169       differ = (FEELING_LAST != FEELING_LAST);
11170       if (!differ) {
11171         int i;
11172 
11173         for (i = 0; i < FEELING_LAST; i++) {
11174           if (old->ppl_content[i] != real_packet->ppl_content[i]) {
11175             differ = TRUE;
11176             break;
11177           }
11178         }
11179       }
11180     }
11181   if (differ) {
11182     different++;
11183     BV_SET(fields, 6);
11184   }
11185 
11186 
11187     {
11188       differ = (FEELING_LAST != FEELING_LAST);
11189       if (!differ) {
11190         int i;
11191 
11192         for (i = 0; i < FEELING_LAST; i++) {
11193           if (old->ppl_unhappy[i] != real_packet->ppl_unhappy[i]) {
11194             differ = TRUE;
11195             break;
11196           }
11197         }
11198       }
11199     }
11200   if (differ) {
11201     different++;
11202     BV_SET(fields, 7);
11203   }
11204 
11205 
11206     {
11207       differ = (FEELING_LAST != FEELING_LAST);
11208       if (!differ) {
11209         int i;
11210 
11211         for (i = 0; i < FEELING_LAST; i++) {
11212           if (old->ppl_angry[i] != real_packet->ppl_angry[i]) {
11213             differ = TRUE;
11214             break;
11215           }
11216         }
11217       }
11218     }
11219   if (differ) {
11220     different++;
11221     BV_SET(fields, 8);
11222   }
11223 
11224   differ = (old->specialists_size != real_packet->specialists_size);
11225   if (differ) {
11226     different++;
11227     BV_SET(fields, 9);
11228   }
11229 
11230 
11231     {
11232       differ = (old->specialists_size != real_packet->specialists_size);
11233       if (!differ) {
11234         int i;
11235 
11236         for (i = 0; i < real_packet->specialists_size; i++) {
11237           if (old->specialists[i] != real_packet->specialists[i]) {
11238             differ = TRUE;
11239             break;
11240           }
11241         }
11242       }
11243     }
11244   if (differ) {
11245     different++;
11246     BV_SET(fields, 10);
11247   }
11248 
11249   differ = (old->nationalities_count != real_packet->nationalities_count);
11250   if (differ) {
11251     different++;
11252     BV_SET(fields, 11);
11253   }
11254 
11255 
11256     {
11257       differ = (old->nationalities_count != real_packet->nationalities_count);
11258       if (!differ) {
11259         int i;
11260 
11261         for (i = 0; i < real_packet->nationalities_count; i++) {
11262           if (old->nation_id[i] != real_packet->nation_id[i]) {
11263             differ = TRUE;
11264             break;
11265           }
11266         }
11267       }
11268     }
11269   if (differ) {
11270     different++;
11271     BV_SET(fields, 12);
11272   }
11273 
11274 
11275     {
11276       differ = (old->nationalities_count != real_packet->nationalities_count);
11277       if (!differ) {
11278         int i;
11279 
11280         for (i = 0; i < real_packet->nationalities_count; i++) {
11281           if (old->nation_citizens[i] != real_packet->nation_citizens[i]) {
11282             differ = TRUE;
11283             break;
11284           }
11285         }
11286       }
11287     }
11288   if (differ) {
11289     different++;
11290     BV_SET(fields, 13);
11291   }
11292 
11293   differ = (old->history != real_packet->history);
11294   if (differ) {
11295     different++;
11296     BV_SET(fields, 14);
11297   }
11298 
11299   differ = (old->culture != real_packet->culture);
11300   if (differ) {
11301     different++;
11302     BV_SET(fields, 15);
11303   }
11304 
11305 
11306     {
11307       differ = (O_LAST != O_LAST);
11308       if (!differ) {
11309         int i;
11310 
11311         for (i = 0; i < O_LAST; i++) {
11312           if (old->surplus[i] != real_packet->surplus[i]) {
11313             differ = TRUE;
11314             break;
11315           }
11316         }
11317       }
11318     }
11319   if (differ) {
11320     different++;
11321     BV_SET(fields, 16);
11322   }
11323 
11324 
11325     {
11326       differ = (O_LAST != O_LAST);
11327       if (!differ) {
11328         int i;
11329 
11330         for (i = 0; i < O_LAST; i++) {
11331           if (old->waste[i] != real_packet->waste[i]) {
11332             differ = TRUE;
11333             break;
11334           }
11335         }
11336       }
11337     }
11338   if (differ) {
11339     different++;
11340     BV_SET(fields, 17);
11341   }
11342 
11343 
11344     {
11345       differ = (O_LAST != O_LAST);
11346       if (!differ) {
11347         int i;
11348 
11349         for (i = 0; i < O_LAST; i++) {
11350           if (old->unhappy_penalty[i] != real_packet->unhappy_penalty[i]) {
11351             differ = TRUE;
11352             break;
11353           }
11354         }
11355       }
11356     }
11357   if (differ) {
11358     different++;
11359     BV_SET(fields, 18);
11360   }
11361 
11362 
11363     {
11364       differ = (O_LAST != O_LAST);
11365       if (!differ) {
11366         int i;
11367 
11368         for (i = 0; i < O_LAST; i++) {
11369           if (old->prod[i] != real_packet->prod[i]) {
11370             differ = TRUE;
11371             break;
11372           }
11373         }
11374       }
11375     }
11376   if (differ) {
11377     different++;
11378     BV_SET(fields, 19);
11379   }
11380 
11381 
11382     {
11383       differ = (O_LAST != O_LAST);
11384       if (!differ) {
11385         int i;
11386 
11387         for (i = 0; i < O_LAST; i++) {
11388           if (old->citizen_base[i] != real_packet->citizen_base[i]) {
11389             differ = TRUE;
11390             break;
11391           }
11392         }
11393       }
11394     }
11395   if (differ) {
11396     different++;
11397     BV_SET(fields, 20);
11398   }
11399 
11400 
11401     {
11402       differ = (O_LAST != O_LAST);
11403       if (!differ) {
11404         int i;
11405 
11406         for (i = 0; i < O_LAST; i++) {
11407           if (old->usage[i] != real_packet->usage[i]) {
11408             differ = TRUE;
11409             break;
11410           }
11411         }
11412       }
11413     }
11414   if (differ) {
11415     different++;
11416     BV_SET(fields, 21);
11417   }
11418 
11419   differ = (old->food_stock != real_packet->food_stock);
11420   if (differ) {
11421     different++;
11422     BV_SET(fields, 22);
11423   }
11424 
11425   differ = (old->shield_stock != real_packet->shield_stock);
11426   if (differ) {
11427     different++;
11428     BV_SET(fields, 23);
11429   }
11430 
11431 
11432     {
11433       differ = (MAX_TRADE_ROUTES != MAX_TRADE_ROUTES);
11434       if (!differ) {
11435         int i;
11436 
11437         for (i = 0; i < MAX_TRADE_ROUTES; i++) {
11438           if (old->trade[i] != real_packet->trade[i]) {
11439             differ = TRUE;
11440             break;
11441           }
11442         }
11443       }
11444     }
11445   if (differ) {
11446     different++;
11447     BV_SET(fields, 24);
11448   }
11449 
11450 
11451     {
11452       differ = (MAX_TRADE_ROUTES != MAX_TRADE_ROUTES);
11453       if (!differ) {
11454         int i;
11455 
11456         for (i = 0; i < MAX_TRADE_ROUTES; i++) {
11457           if (old->trade_value[i] != real_packet->trade_value[i]) {
11458             differ = TRUE;
11459             break;
11460           }
11461         }
11462       }
11463     }
11464   if (differ) {
11465     different++;
11466     BV_SET(fields, 25);
11467   }
11468 
11469   differ = (old->pollution != real_packet->pollution);
11470   if (differ) {
11471     different++;
11472     BV_SET(fields, 26);
11473   }
11474 
11475   differ = (old->illness_trade != real_packet->illness_trade);
11476   if (differ) {
11477     different++;
11478     BV_SET(fields, 27);
11479   }
11480 
11481   differ = (old->production_kind != real_packet->production_kind);
11482   if (differ) {
11483     different++;
11484     BV_SET(fields, 28);
11485   }
11486 
11487   differ = (old->production_value != real_packet->production_value);
11488   if (differ) {
11489     different++;
11490     BV_SET(fields, 29);
11491   }
11492 
11493   differ = (old->turn_founded != real_packet->turn_founded);
11494   if (differ) {
11495     different++;
11496     BV_SET(fields, 30);
11497   }
11498 
11499   differ = (old->turn_last_built != real_packet->turn_last_built);
11500   if (differ) {
11501     different++;
11502     BV_SET(fields, 31);
11503   }
11504 
11505   differ = (old->changed_from_kind != real_packet->changed_from_kind);
11506   if (differ) {
11507     different++;
11508     BV_SET(fields, 32);
11509   }
11510 
11511   differ = (old->changed_from_value != real_packet->changed_from_value);
11512   if (differ) {
11513     different++;
11514     BV_SET(fields, 33);
11515   }
11516 
11517   differ = (old->before_change_shields != real_packet->before_change_shields);
11518   if (differ) {
11519     different++;
11520     BV_SET(fields, 34);
11521   }
11522 
11523   differ = (old->disbanded_shields != real_packet->disbanded_shields);
11524   if (differ) {
11525     different++;
11526     BV_SET(fields, 35);
11527   }
11528 
11529   differ = (old->caravan_shields != real_packet->caravan_shields);
11530   if (differ) {
11531     different++;
11532     BV_SET(fields, 36);
11533   }
11534 
11535   differ = (old->last_turns_shield_surplus != real_packet->last_turns_shield_surplus);
11536   if (differ) {
11537     different++;
11538     BV_SET(fields, 37);
11539   }
11540 
11541   differ = (old->airlift != real_packet->airlift);
11542   if (differ) {
11543     different++;
11544     BV_SET(fields, 38);
11545   }
11546 
11547   differ = (old->did_buy != real_packet->did_buy);
11548   if (differ) {
11549     different++;
11550   }
11551   if (packet->did_buy) {
11552     BV_SET(fields, 39);
11553   }
11554 
11555   differ = (old->did_sell != real_packet->did_sell);
11556   if (differ) {
11557     different++;
11558   }
11559   if (packet->did_sell) {
11560     BV_SET(fields, 40);
11561   }
11562 
11563   differ = (old->was_happy != real_packet->was_happy);
11564   if (differ) {
11565     different++;
11566   }
11567   if (packet->was_happy) {
11568     BV_SET(fields, 41);
11569   }
11570 
11571   differ = (old->diplomat_investigate != real_packet->diplomat_investigate);
11572   if (differ) {
11573     different++;
11574   }
11575   if (packet->diplomat_investigate) {
11576     BV_SET(fields, 42);
11577   }
11578 
11579   differ = (old->walls != real_packet->walls);
11580   if (differ) {
11581     different++;
11582     BV_SET(fields, 43);
11583   }
11584 
11585   differ = (old->city_image != real_packet->city_image);
11586   if (differ) {
11587     different++;
11588     BV_SET(fields, 44);
11589   }
11590 
11591   differ = !are_worklists_equal(&old->worklist, &real_packet->worklist);
11592   if (differ) {
11593     different++;
11594     BV_SET(fields, 45);
11595   }
11596 
11597   differ = !BV_ARE_EQUAL(old->improvements, real_packet->improvements);
11598   if (differ) {
11599     different++;
11600     BV_SET(fields, 46);
11601   }
11602 
11603   differ = !BV_ARE_EQUAL(old->city_options, real_packet->city_options);
11604   if (differ) {
11605     different++;
11606     BV_SET(fields, 47);
11607   }
11608 
11609   differ = (strcmp(old->name, real_packet->name) != 0);
11610   if (differ) {
11611     different++;
11612     BV_SET(fields, 48);
11613   }
11614 
11615 
11616   if (different == 0) {
11617     log_packet_detailed("  no change -> discard");
11618     return 0;
11619   }
11620 
11621   DIO_BV_PUT(&dout, "fields", fields);
11622   DIO_PUT(uint16, &dout, "id", real_packet->id);
11623 
11624   if (BV_ISSET(fields, 0)) {
11625     log_packet_detailed("  field 'tile' has changed");
11626     DIO_PUT(sint32, &dout, "tile", real_packet->tile);
11627   }
11628   if (BV_ISSET(fields, 1)) {
11629     log_packet_detailed("  field 'owner' has changed");
11630     DIO_PUT(uint8, &dout, "owner", real_packet->owner);
11631   }
11632   if (BV_ISSET(fields, 2)) {
11633     log_packet_detailed("  field 'size' has changed");
11634     DIO_PUT(uint8, &dout, "size", real_packet->size);
11635   }
11636   if (BV_ISSET(fields, 3)) {
11637     log_packet_detailed("  field 'city_radius_sq' has changed");
11638     DIO_PUT(uint8, &dout, "city_radius_sq", real_packet->city_radius_sq);
11639   }
11640   if (BV_ISSET(fields, 4)) {
11641     log_packet_detailed("  field 'style' has changed");
11642     DIO_PUT(uint8, &dout, "style", real_packet->style);
11643   }
11644   if (BV_ISSET(fields, 5)) {
11645     log_packet_detailed("  field 'ppl_happy' has changed");
11646 
11647     {
11648       int i;
11649 
11650       for (i = 0; i < FEELING_LAST; i++) {
11651         dio_put_uint8(&dout, real_packet->ppl_happy[i]);
11652       }
11653     }
11654   }
11655   if (BV_ISSET(fields, 6)) {
11656     log_packet_detailed("  field 'ppl_content' has changed");
11657 
11658     {
11659       int i;
11660 
11661       for (i = 0; i < FEELING_LAST; i++) {
11662         dio_put_uint8(&dout, real_packet->ppl_content[i]);
11663       }
11664     }
11665   }
11666   if (BV_ISSET(fields, 7)) {
11667     log_packet_detailed("  field 'ppl_unhappy' has changed");
11668 
11669     {
11670       int i;
11671 
11672       for (i = 0; i < FEELING_LAST; i++) {
11673         dio_put_uint8(&dout, real_packet->ppl_unhappy[i]);
11674       }
11675     }
11676   }
11677   if (BV_ISSET(fields, 8)) {
11678     log_packet_detailed("  field 'ppl_angry' has changed");
11679 
11680     {
11681       int i;
11682 
11683       for (i = 0; i < FEELING_LAST; i++) {
11684         dio_put_uint8(&dout, real_packet->ppl_angry[i]);
11685       }
11686     }
11687   }
11688   if (BV_ISSET(fields, 9)) {
11689     log_packet_detailed("  field 'specialists_size' has changed");
11690     DIO_PUT(uint8, &dout, "specialists_size", real_packet->specialists_size);
11691   }
11692   if (BV_ISSET(fields, 10)) {
11693     log_packet_detailed("  field 'specialists' has changed");
11694 
11695     {
11696       int i;
11697 
11698       for (i = 0; i < real_packet->specialists_size; i++) {
11699         dio_put_uint8(&dout, real_packet->specialists[i]);
11700       }
11701     }
11702   }
11703   if (BV_ISSET(fields, 11)) {
11704     log_packet_detailed("  field 'nationalities_count' has changed");
11705     DIO_PUT(uint8, &dout, "nationalities_count", real_packet->nationalities_count);
11706   }
11707   if (BV_ISSET(fields, 12)) {
11708     log_packet_detailed("  field 'nation_id' has changed");
11709 
11710     {
11711       int i;
11712 
11713       for (i = 0; i < real_packet->nationalities_count; i++) {
11714         dio_put_uint8(&dout, real_packet->nation_id[i]);
11715       }
11716     }
11717   }
11718   if (BV_ISSET(fields, 13)) {
11719     log_packet_detailed("  field 'nation_citizens' has changed");
11720 
11721     {
11722       int i;
11723 
11724       for (i = 0; i < real_packet->nationalities_count; i++) {
11725         dio_put_uint8(&dout, real_packet->nation_citizens[i]);
11726       }
11727     }
11728   }
11729   if (BV_ISSET(fields, 14)) {
11730     log_packet_detailed("  field 'history' has changed");
11731     DIO_PUT(uint16, &dout, "history", real_packet->history);
11732   }
11733   if (BV_ISSET(fields, 15)) {
11734     log_packet_detailed("  field 'culture' has changed");
11735     DIO_PUT(uint16, &dout, "culture", real_packet->culture);
11736   }
11737   if (BV_ISSET(fields, 16)) {
11738     log_packet_detailed("  field 'surplus' has changed");
11739 
11740     {
11741       int i;
11742 
11743       for (i = 0; i < O_LAST; i++) {
11744         dio_put_sint16(&dout, real_packet->surplus[i]);
11745       }
11746     }
11747   }
11748   if (BV_ISSET(fields, 17)) {
11749     log_packet_detailed("  field 'waste' has changed");
11750 
11751     {
11752       int i;
11753 
11754       for (i = 0; i < O_LAST; i++) {
11755         dio_put_uint16(&dout, real_packet->waste[i]);
11756       }
11757     }
11758   }
11759   if (BV_ISSET(fields, 18)) {
11760     log_packet_detailed("  field 'unhappy_penalty' has changed");
11761 
11762     {
11763       int i;
11764 
11765       for (i = 0; i < O_LAST; i++) {
11766         dio_put_sint16(&dout, real_packet->unhappy_penalty[i]);
11767       }
11768     }
11769   }
11770   if (BV_ISSET(fields, 19)) {
11771     log_packet_detailed("  field 'prod' has changed");
11772 
11773     {
11774       int i;
11775 
11776       for (i = 0; i < O_LAST; i++) {
11777         dio_put_uint16(&dout, real_packet->prod[i]);
11778       }
11779     }
11780   }
11781   if (BV_ISSET(fields, 20)) {
11782     log_packet_detailed("  field 'citizen_base' has changed");
11783 
11784     {
11785       int i;
11786 
11787       for (i = 0; i < O_LAST; i++) {
11788         dio_put_sint16(&dout, real_packet->citizen_base[i]);
11789       }
11790     }
11791   }
11792   if (BV_ISSET(fields, 21)) {
11793     log_packet_detailed("  field 'usage' has changed");
11794 
11795     {
11796       int i;
11797 
11798       for (i = 0; i < O_LAST; i++) {
11799         dio_put_sint16(&dout, real_packet->usage[i]);
11800       }
11801     }
11802   }
11803   if (BV_ISSET(fields, 22)) {
11804     log_packet_detailed("  field 'food_stock' has changed");
11805     DIO_PUT(sint16, &dout, "food_stock", real_packet->food_stock);
11806   }
11807   if (BV_ISSET(fields, 23)) {
11808     log_packet_detailed("  field 'shield_stock' has changed");
11809     DIO_PUT(uint16, &dout, "shield_stock", real_packet->shield_stock);
11810   }
11811   if (BV_ISSET(fields, 24)) {
11812     log_packet_detailed("  field 'trade' has changed");
11813 
11814     {
11815       int i;
11816 
11817       for (i = 0; i < MAX_TRADE_ROUTES; i++) {
11818         dio_put_uint16(&dout, real_packet->trade[i]);
11819       }
11820     }
11821   }
11822   if (BV_ISSET(fields, 25)) {
11823     log_packet_detailed("  field 'trade_value' has changed");
11824 
11825     {
11826       int i;
11827 
11828       for (i = 0; i < MAX_TRADE_ROUTES; i++) {
11829         dio_put_uint8(&dout, real_packet->trade_value[i]);
11830       }
11831     }
11832   }
11833   if (BV_ISSET(fields, 26)) {
11834     log_packet_detailed("  field 'pollution' has changed");
11835     DIO_PUT(uint16, &dout, "pollution", real_packet->pollution);
11836   }
11837   if (BV_ISSET(fields, 27)) {
11838     log_packet_detailed("  field 'illness_trade' has changed");
11839     DIO_PUT(uint16, &dout, "illness_trade", real_packet->illness_trade);
11840   }
11841   if (BV_ISSET(fields, 28)) {
11842     log_packet_detailed("  field 'production_kind' has changed");
11843     DIO_PUT(uint8, &dout, "production_kind", real_packet->production_kind);
11844   }
11845   if (BV_ISSET(fields, 29)) {
11846     log_packet_detailed("  field 'production_value' has changed");
11847     DIO_PUT(uint8, &dout, "production_value", real_packet->production_value);
11848   }
11849   if (BV_ISSET(fields, 30)) {
11850     log_packet_detailed("  field 'turn_founded' has changed");
11851     DIO_PUT(sint16, &dout, "turn_founded", real_packet->turn_founded);
11852   }
11853   if (BV_ISSET(fields, 31)) {
11854     log_packet_detailed("  field 'turn_last_built' has changed");
11855     DIO_PUT(sint16, &dout, "turn_last_built", real_packet->turn_last_built);
11856   }
11857   if (BV_ISSET(fields, 32)) {
11858     log_packet_detailed("  field 'changed_from_kind' has changed");
11859     DIO_PUT(uint8, &dout, "changed_from_kind", real_packet->changed_from_kind);
11860   }
11861   if (BV_ISSET(fields, 33)) {
11862     log_packet_detailed("  field 'changed_from_value' has changed");
11863     DIO_PUT(uint8, &dout, "changed_from_value", real_packet->changed_from_value);
11864   }
11865   if (BV_ISSET(fields, 34)) {
11866     log_packet_detailed("  field 'before_change_shields' has changed");
11867     DIO_PUT(uint16, &dout, "before_change_shields", real_packet->before_change_shields);
11868   }
11869   if (BV_ISSET(fields, 35)) {
11870     log_packet_detailed("  field 'disbanded_shields' has changed");
11871     DIO_PUT(uint16, &dout, "disbanded_shields", real_packet->disbanded_shields);
11872   }
11873   if (BV_ISSET(fields, 36)) {
11874     log_packet_detailed("  field 'caravan_shields' has changed");
11875     DIO_PUT(uint16, &dout, "caravan_shields", real_packet->caravan_shields);
11876   }
11877   if (BV_ISSET(fields, 37)) {
11878     log_packet_detailed("  field 'last_turns_shield_surplus' has changed");
11879     DIO_PUT(uint16, &dout, "last_turns_shield_surplus", real_packet->last_turns_shield_surplus);
11880   }
11881   if (BV_ISSET(fields, 38)) {
11882     log_packet_detailed("  field 'airlift' has changed");
11883     DIO_PUT(uint8, &dout, "airlift", real_packet->airlift);
11884   }
11885   /* field 39 is folded into the header */
11886   /* field 40 is folded into the header */
11887   /* field 41 is folded into the header */
11888   /* field 42 is folded into the header */
11889   if (BV_ISSET(fields, 43)) {
11890     log_packet_detailed("  field 'walls' has changed");
11891     DIO_PUT(uint8, &dout, "walls", real_packet->walls);
11892   }
11893   if (BV_ISSET(fields, 44)) {
11894     log_packet_detailed("  field 'city_image' has changed");
11895     DIO_PUT(sint8, &dout, "city_image", real_packet->city_image);
11896   }
11897   if (BV_ISSET(fields, 45)) {
11898     log_packet_detailed("  field 'worklist' has changed");
11899     DIO_PUT(worklist, &dout, "worklist", &real_packet->worklist);
11900   }
11901   if (BV_ISSET(fields, 46)) {
11902     log_packet_detailed("  field 'improvements' has changed");
11903   DIO_BV_PUT(&dout, "improvements", packet->improvements);
11904   }
11905   if (BV_ISSET(fields, 47)) {
11906     log_packet_detailed("  field 'city_options' has changed");
11907   DIO_BV_PUT(&dout, "city_options", packet->city_options);
11908   }
11909   if (BV_ISSET(fields, 48)) {
11910     log_packet_detailed("  field 'name' has changed");
11911     DIO_PUT(string, &dout, "name", real_packet->name);
11912   }
11913 
11914   *old = *real_packet;
11915 
11916   hash = pc->phs.sent + PACKET_CITY_SHORT_INFO;
11917   if (NULL != *hash) {
11918     genhash_remove(*hash, real_packet);
11919   }
11920   SEND_PACKET_END(PACKET_CITY_INFO);
11921 }
11922 
send_packet_city_info(struct connection * pc,const struct packet_city_info * packet,bool force_to_send)11923 int send_packet_city_info(struct connection *pc, const struct packet_city_info *packet, bool force_to_send)
11924 {
11925   if (!pc->used) {
11926     log_error("WARNING: trying to send data to the closed connection %s",
11927               conn_description(pc));
11928     return -1;
11929   }
11930   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_INFO].force_to_send != NULL, -1,
11931                         "Handler for PACKET_CITY_INFO not installed");
11932   return pc->phs.handlers->send[PACKET_CITY_INFO].force_to_send(pc, packet, force_to_send);
11933 }
11934 
lsend_packet_city_info(struct conn_list * dest,const struct packet_city_info * packet,bool force_to_send)11935 void lsend_packet_city_info(struct conn_list *dest, const struct packet_city_info *packet, bool force_to_send)
11936 {
11937   conn_list_iterate(dest, pconn) {
11938     send_packet_city_info(pconn, packet, force_to_send);
11939   } conn_list_iterate_end;
11940 }
11941 
hash_packet_city_short_info_100(const void * vkey)11942 static genhash_val_t hash_packet_city_short_info_100(const void *vkey)
11943 {
11944   const struct packet_city_short_info *key = (const struct packet_city_short_info *) vkey;
11945 
11946   return key->id;
11947 }
11948 
cmp_packet_city_short_info_100(const void * vkey1,const void * vkey2)11949 static bool cmp_packet_city_short_info_100(const void *vkey1, const void *vkey2)
11950 {
11951   const struct packet_city_short_info *key1 = (const struct packet_city_short_info *) vkey1;
11952   const struct packet_city_short_info *key2 = (const struct packet_city_short_info *) vkey2;
11953 
11954   return key1->id == key2->id;
11955 }
11956 
11957 BV_DEFINE(packet_city_short_info_100_fields, 11);
11958 
receive_packet_city_short_info_100(struct connection * pc)11959 static struct packet_city_short_info *receive_packet_city_short_info_100(struct connection *pc)
11960 {
11961   packet_city_short_info_100_fields fields;
11962   struct packet_city_short_info *old;
11963   struct genhash **hash = pc->phs.received + PACKET_CITY_SHORT_INFO;
11964   RECEIVE_PACKET_START(packet_city_short_info, real_packet);
11965 
11966   DIO_BV_GET(&din, fields);
11967   if (!DIO_GET(uint16, &din, "id", &real_packet->id)) {
11968     RECEIVE_PACKET_FIELD_ERROR(id);
11969   }
11970 
11971   log_packet_detailed("packet_city_short_info_100: got info about (%d)",
11972     real_packet->id);
11973 
11974   if (NULL == *hash) {
11975     *hash = genhash_new_full(hash_packet_city_short_info_100, cmp_packet_city_short_info_100,
11976                              NULL, NULL, NULL, free);
11977   }
11978 
11979   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
11980     *real_packet = *old;
11981   } else {
11982     int id = real_packet->id;
11983 
11984     log_packet_detailed("  no old info");
11985     memset(real_packet, 0, sizeof(*real_packet));
11986 
11987     real_packet->id = id;
11988   }
11989 
11990   if (BV_ISSET(fields, 0)) {
11991     log_packet_detailed("  got field 'tile'");
11992     if (!DIO_GET(sint32, &din, "tile", &real_packet->tile)) {
11993       RECEIVE_PACKET_FIELD_ERROR(tile);
11994     }
11995   }
11996   if (BV_ISSET(fields, 1)) {
11997     log_packet_detailed("  got field 'owner'");
11998     if (!DIO_GET(uint8, &din, "owner", &real_packet->owner)) {
11999       RECEIVE_PACKET_FIELD_ERROR(owner);
12000     }
12001   }
12002   if (BV_ISSET(fields, 2)) {
12003     log_packet_detailed("  got field 'size'");
12004     if (!DIO_GET(uint8, &din, "size", &real_packet->size)) {
12005       RECEIVE_PACKET_FIELD_ERROR(size);
12006     }
12007   }
12008   if (BV_ISSET(fields, 3)) {
12009     log_packet_detailed("  got field 'style'");
12010     if (!DIO_GET(uint8, &din, "style", &real_packet->style)) {
12011       RECEIVE_PACKET_FIELD_ERROR(style);
12012     }
12013   }
12014   real_packet->occupied = BV_ISSET(fields, 4);
12015   if (BV_ISSET(fields, 5)) {
12016     log_packet_detailed("  got field 'walls'");
12017     if (!DIO_GET(uint8, &din, "walls", &real_packet->walls)) {
12018       RECEIVE_PACKET_FIELD_ERROR(walls);
12019     }
12020   }
12021   real_packet->happy = BV_ISSET(fields, 6);
12022   real_packet->unhappy = BV_ISSET(fields, 7);
12023   if (BV_ISSET(fields, 8)) {
12024     log_packet_detailed("  got field 'city_image'");
12025     if (!DIO_GET(sint8, &din, "city_image", &real_packet->city_image)) {
12026       RECEIVE_PACKET_FIELD_ERROR(city_image);
12027     }
12028   }
12029   if (BV_ISSET(fields, 9)) {
12030     log_packet_detailed("  got field 'improvements'");
12031     if (!DIO_BV_GET(&din, real_packet->improvements)) {
12032       RECEIVE_PACKET_FIELD_ERROR(improvements);
12033     }
12034   }
12035   if (BV_ISSET(fields, 10)) {
12036     log_packet_detailed("  got field 'name'");
12037     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
12038       RECEIVE_PACKET_FIELD_ERROR(name);
12039     }
12040   }
12041 
12042   if (NULL == old) {
12043     old = fc_malloc(sizeof(*old));
12044     *old = *real_packet;
12045     genhash_insert(*hash, old, old);
12046   } else {
12047     *old = *real_packet;
12048   }
12049 
12050   hash = pc->phs.received + PACKET_CITY_INFO;
12051   if (NULL != *hash) {
12052     genhash_remove(*hash, real_packet);
12053   }
12054   RECEIVE_PACKET_END(real_packet);
12055 }
12056 
send_packet_city_short_info_100(struct connection * pc,const struct packet_city_short_info * packet)12057 static int send_packet_city_short_info_100(struct connection *pc, const struct packet_city_short_info *packet)
12058 {
12059   const struct packet_city_short_info *real_packet = packet;
12060   packet_city_short_info_100_fields fields;
12061   struct packet_city_short_info *old;
12062   bool differ;
12063   struct genhash **hash = pc->phs.sent + PACKET_CITY_SHORT_INFO;
12064   int different = 0;
12065   SEND_PACKET_START(PACKET_CITY_SHORT_INFO);
12066 
12067   log_packet_detailed("packet_city_short_info_100: sending info about (%d)",
12068     real_packet->id);
12069 
12070   if (NULL == *hash) {
12071     *hash = genhash_new_full(hash_packet_city_short_info_100, cmp_packet_city_short_info_100,
12072                              NULL, NULL, NULL, free);
12073   }
12074   BV_CLR_ALL(fields);
12075 
12076   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
12077     old = fc_malloc(sizeof(*old));
12078     *old = *real_packet;
12079     genhash_insert(*hash, old, old);
12080     memset(old, 0, sizeof(*old));
12081     different = 1;      /* Force to send. */
12082   }
12083 
12084   differ = (old->tile != real_packet->tile);
12085   if (differ) {
12086     different++;
12087     BV_SET(fields, 0);
12088   }
12089 
12090   differ = (old->owner != real_packet->owner);
12091   if (differ) {
12092     different++;
12093     BV_SET(fields, 1);
12094   }
12095 
12096   differ = (old->size != real_packet->size);
12097   if (differ) {
12098     different++;
12099     BV_SET(fields, 2);
12100   }
12101 
12102   differ = (old->style != real_packet->style);
12103   if (differ) {
12104     different++;
12105     BV_SET(fields, 3);
12106   }
12107 
12108   differ = (old->occupied != real_packet->occupied);
12109   if (differ) {
12110     different++;
12111   }
12112   if (packet->occupied) {
12113     BV_SET(fields, 4);
12114   }
12115 
12116   differ = (old->walls != real_packet->walls);
12117   if (differ) {
12118     different++;
12119     BV_SET(fields, 5);
12120   }
12121 
12122   differ = (old->happy != real_packet->happy);
12123   if (differ) {
12124     different++;
12125   }
12126   if (packet->happy) {
12127     BV_SET(fields, 6);
12128   }
12129 
12130   differ = (old->unhappy != real_packet->unhappy);
12131   if (differ) {
12132     different++;
12133   }
12134   if (packet->unhappy) {
12135     BV_SET(fields, 7);
12136   }
12137 
12138   differ = (old->city_image != real_packet->city_image);
12139   if (differ) {
12140     different++;
12141     BV_SET(fields, 8);
12142   }
12143 
12144   differ = !BV_ARE_EQUAL(old->improvements, real_packet->improvements);
12145   if (differ) {
12146     different++;
12147     BV_SET(fields, 9);
12148   }
12149 
12150   differ = (strcmp(old->name, real_packet->name) != 0);
12151   if (differ) {
12152     different++;
12153     BV_SET(fields, 10);
12154   }
12155 
12156 
12157   if (different == 0) {
12158     log_packet_detailed("  no change -> discard");
12159     return 0;
12160   }
12161 
12162   DIO_BV_PUT(&dout, "fields", fields);
12163   DIO_PUT(uint16, &dout, "id", real_packet->id);
12164 
12165   if (BV_ISSET(fields, 0)) {
12166     log_packet_detailed("  field 'tile' has changed");
12167     DIO_PUT(sint32, &dout, "tile", real_packet->tile);
12168   }
12169   if (BV_ISSET(fields, 1)) {
12170     log_packet_detailed("  field 'owner' has changed");
12171     DIO_PUT(uint8, &dout, "owner", real_packet->owner);
12172   }
12173   if (BV_ISSET(fields, 2)) {
12174     log_packet_detailed("  field 'size' has changed");
12175     DIO_PUT(uint8, &dout, "size", real_packet->size);
12176   }
12177   if (BV_ISSET(fields, 3)) {
12178     log_packet_detailed("  field 'style' has changed");
12179     DIO_PUT(uint8, &dout, "style", real_packet->style);
12180   }
12181   /* field 4 is folded into the header */
12182   if (BV_ISSET(fields, 5)) {
12183     log_packet_detailed("  field 'walls' has changed");
12184     DIO_PUT(uint8, &dout, "walls", real_packet->walls);
12185   }
12186   /* field 6 is folded into the header */
12187   /* field 7 is folded into the header */
12188   if (BV_ISSET(fields, 8)) {
12189     log_packet_detailed("  field 'city_image' has changed");
12190     DIO_PUT(sint8, &dout, "city_image", real_packet->city_image);
12191   }
12192   if (BV_ISSET(fields, 9)) {
12193     log_packet_detailed("  field 'improvements' has changed");
12194   DIO_BV_PUT(&dout, "improvements", packet->improvements);
12195   }
12196   if (BV_ISSET(fields, 10)) {
12197     log_packet_detailed("  field 'name' has changed");
12198     DIO_PUT(string, &dout, "name", real_packet->name);
12199   }
12200 
12201   *old = *real_packet;
12202 
12203   hash = pc->phs.sent + PACKET_CITY_INFO;
12204   if (NULL != *hash) {
12205     genhash_remove(*hash, real_packet);
12206   }
12207   SEND_PACKET_END(PACKET_CITY_SHORT_INFO);
12208 }
12209 
send_packet_city_short_info(struct connection * pc,const struct packet_city_short_info * packet)12210 int send_packet_city_short_info(struct connection *pc, const struct packet_city_short_info *packet)
12211 {
12212   if (!pc->used) {
12213     log_error("WARNING: trying to send data to the closed connection %s",
12214               conn_description(pc));
12215     return -1;
12216   }
12217   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_SHORT_INFO].packet != NULL, -1,
12218                         "Handler for PACKET_CITY_SHORT_INFO not installed");
12219   return pc->phs.handlers->send[PACKET_CITY_SHORT_INFO].packet(pc, packet);
12220 }
12221 
lsend_packet_city_short_info(struct conn_list * dest,const struct packet_city_short_info * packet)12222 void lsend_packet_city_short_info(struct conn_list *dest, const struct packet_city_short_info *packet)
12223 {
12224   conn_list_iterate(dest, pconn) {
12225     send_packet_city_short_info(pconn, packet);
12226   } conn_list_iterate_end;
12227 }
12228 
12229 #define hash_packet_city_sell_100 hash_const
12230 
12231 #define cmp_packet_city_sell_100 cmp_const
12232 
12233 BV_DEFINE(packet_city_sell_100_fields, 2);
12234 
receive_packet_city_sell_100(struct connection * pc)12235 static struct packet_city_sell *receive_packet_city_sell_100(struct connection *pc)
12236 {
12237   packet_city_sell_100_fields fields;
12238   struct packet_city_sell *old;
12239   struct genhash **hash = pc->phs.received + PACKET_CITY_SELL;
12240   RECEIVE_PACKET_START(packet_city_sell, real_packet);
12241 
12242   DIO_BV_GET(&din, fields);
12243 
12244   log_packet_detailed("packet_city_sell_100: got info about ()");
12245 
12246   if (NULL == *hash) {
12247     *hash = genhash_new_full(hash_packet_city_sell_100, cmp_packet_city_sell_100,
12248                              NULL, NULL, NULL, free);
12249   }
12250 
12251   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
12252     *real_packet = *old;
12253   } else {
12254     log_packet_detailed("  no old info");
12255     memset(real_packet, 0, sizeof(*real_packet));
12256   }
12257 
12258   if (BV_ISSET(fields, 0)) {
12259     log_packet_detailed("  got field 'city_id'");
12260     if (!DIO_GET(uint16, &din, "city_id", &real_packet->city_id)) {
12261       RECEIVE_PACKET_FIELD_ERROR(city_id);
12262     }
12263   }
12264   if (BV_ISSET(fields, 1)) {
12265     log_packet_detailed("  got field 'build_id'");
12266     if (!DIO_GET(uint8, &din, "build_id", &real_packet->build_id)) {
12267       RECEIVE_PACKET_FIELD_ERROR(build_id);
12268     }
12269   }
12270 
12271   if (NULL == old) {
12272     old = fc_malloc(sizeof(*old));
12273     *old = *real_packet;
12274     genhash_insert(*hash, old, old);
12275   } else {
12276     *old = *real_packet;
12277   }
12278   RECEIVE_PACKET_END(real_packet);
12279 }
12280 
send_packet_city_sell_100(struct connection * pc,const struct packet_city_sell * packet)12281 static int send_packet_city_sell_100(struct connection *pc, const struct packet_city_sell *packet)
12282 {
12283   const struct packet_city_sell *real_packet = packet;
12284   packet_city_sell_100_fields fields;
12285   struct packet_city_sell *old;
12286   bool differ;
12287   struct genhash **hash = pc->phs.sent + PACKET_CITY_SELL;
12288   int different = 0;
12289   SEND_PACKET_START(PACKET_CITY_SELL);
12290 
12291   log_packet_detailed("packet_city_sell_100: sending info about ()");
12292 
12293   if (NULL == *hash) {
12294     *hash = genhash_new_full(hash_packet_city_sell_100, cmp_packet_city_sell_100,
12295                              NULL, NULL, NULL, free);
12296   }
12297   BV_CLR_ALL(fields);
12298 
12299   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
12300     old = fc_malloc(sizeof(*old));
12301     *old = *real_packet;
12302     genhash_insert(*hash, old, old);
12303     memset(old, 0, sizeof(*old));
12304     different = 1;      /* Force to send. */
12305   }
12306 
12307   differ = (old->city_id != real_packet->city_id);
12308   if (differ) {
12309     different++;
12310     BV_SET(fields, 0);
12311   }
12312 
12313   differ = (old->build_id != real_packet->build_id);
12314   if (differ) {
12315     different++;
12316     BV_SET(fields, 1);
12317   }
12318 
12319 
12320   DIO_BV_PUT(&dout, "fields", fields);
12321 
12322   if (BV_ISSET(fields, 0)) {
12323     log_packet_detailed("  field 'city_id' has changed");
12324     DIO_PUT(uint16, &dout, "city_id", real_packet->city_id);
12325   }
12326   if (BV_ISSET(fields, 1)) {
12327     log_packet_detailed("  field 'build_id' has changed");
12328     DIO_PUT(uint8, &dout, "build_id", real_packet->build_id);
12329   }
12330 
12331   *old = *real_packet;
12332   SEND_PACKET_END(PACKET_CITY_SELL);
12333 }
12334 
send_packet_city_sell(struct connection * pc,const struct packet_city_sell * packet)12335 int send_packet_city_sell(struct connection *pc, const struct packet_city_sell *packet)
12336 {
12337   if (!pc->used) {
12338     log_error("WARNING: trying to send data to the closed connection %s",
12339               conn_description(pc));
12340     return -1;
12341   }
12342   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_SELL].packet != NULL, -1,
12343                         "Handler for PACKET_CITY_SELL not installed");
12344   return pc->phs.handlers->send[PACKET_CITY_SELL].packet(pc, packet);
12345 }
12346 
dsend_packet_city_sell(struct connection * pc,int city_id,int build_id)12347 int dsend_packet_city_sell(struct connection *pc, int city_id, int build_id)
12348 {
12349   struct packet_city_sell packet, *real_packet = &packet;
12350 
12351   real_packet->city_id = city_id;
12352   real_packet->build_id = build_id;
12353 
12354   return send_packet_city_sell(pc, real_packet);
12355 }
12356 
12357 #define hash_packet_city_buy_100 hash_const
12358 
12359 #define cmp_packet_city_buy_100 cmp_const
12360 
12361 BV_DEFINE(packet_city_buy_100_fields, 1);
12362 
receive_packet_city_buy_100(struct connection * pc)12363 static struct packet_city_buy *receive_packet_city_buy_100(struct connection *pc)
12364 {
12365   packet_city_buy_100_fields fields;
12366   struct packet_city_buy *old;
12367   struct genhash **hash = pc->phs.received + PACKET_CITY_BUY;
12368   RECEIVE_PACKET_START(packet_city_buy, real_packet);
12369 
12370   DIO_BV_GET(&din, fields);
12371 
12372   log_packet_detailed("packet_city_buy_100: got info about ()");
12373 
12374   if (NULL == *hash) {
12375     *hash = genhash_new_full(hash_packet_city_buy_100, cmp_packet_city_buy_100,
12376                              NULL, NULL, NULL, free);
12377   }
12378 
12379   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
12380     *real_packet = *old;
12381   } else {
12382     log_packet_detailed("  no old info");
12383     memset(real_packet, 0, sizeof(*real_packet));
12384   }
12385 
12386   if (BV_ISSET(fields, 0)) {
12387     log_packet_detailed("  got field 'city_id'");
12388     if (!DIO_GET(uint16, &din, "city_id", &real_packet->city_id)) {
12389       RECEIVE_PACKET_FIELD_ERROR(city_id);
12390     }
12391   }
12392 
12393   if (NULL == old) {
12394     old = fc_malloc(sizeof(*old));
12395     *old = *real_packet;
12396     genhash_insert(*hash, old, old);
12397   } else {
12398     *old = *real_packet;
12399   }
12400   RECEIVE_PACKET_END(real_packet);
12401 }
12402 
send_packet_city_buy_100(struct connection * pc,const struct packet_city_buy * packet)12403 static int send_packet_city_buy_100(struct connection *pc, const struct packet_city_buy *packet)
12404 {
12405   const struct packet_city_buy *real_packet = packet;
12406   packet_city_buy_100_fields fields;
12407   struct packet_city_buy *old;
12408   bool differ;
12409   struct genhash **hash = pc->phs.sent + PACKET_CITY_BUY;
12410   int different = 0;
12411   SEND_PACKET_START(PACKET_CITY_BUY);
12412 
12413   log_packet_detailed("packet_city_buy_100: sending info about ()");
12414 
12415   if (NULL == *hash) {
12416     *hash = genhash_new_full(hash_packet_city_buy_100, cmp_packet_city_buy_100,
12417                              NULL, NULL, NULL, free);
12418   }
12419   BV_CLR_ALL(fields);
12420 
12421   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
12422     old = fc_malloc(sizeof(*old));
12423     *old = *real_packet;
12424     genhash_insert(*hash, old, old);
12425     memset(old, 0, sizeof(*old));
12426     different = 1;      /* Force to send. */
12427   }
12428 
12429   differ = (old->city_id != real_packet->city_id);
12430   if (differ) {
12431     different++;
12432     BV_SET(fields, 0);
12433   }
12434 
12435 
12436   DIO_BV_PUT(&dout, "fields", fields);
12437 
12438   if (BV_ISSET(fields, 0)) {
12439     log_packet_detailed("  field 'city_id' has changed");
12440     DIO_PUT(uint16, &dout, "city_id", real_packet->city_id);
12441   }
12442 
12443   *old = *real_packet;
12444   SEND_PACKET_END(PACKET_CITY_BUY);
12445 }
12446 
send_packet_city_buy(struct connection * pc,const struct packet_city_buy * packet)12447 int send_packet_city_buy(struct connection *pc, const struct packet_city_buy *packet)
12448 {
12449   if (!pc->used) {
12450     log_error("WARNING: trying to send data to the closed connection %s",
12451               conn_description(pc));
12452     return -1;
12453   }
12454   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_BUY].packet != NULL, -1,
12455                         "Handler for PACKET_CITY_BUY not installed");
12456   return pc->phs.handlers->send[PACKET_CITY_BUY].packet(pc, packet);
12457 }
12458 
dsend_packet_city_buy(struct connection * pc,int city_id)12459 int dsend_packet_city_buy(struct connection *pc, int city_id)
12460 {
12461   struct packet_city_buy packet, *real_packet = &packet;
12462 
12463   real_packet->city_id = city_id;
12464 
12465   return send_packet_city_buy(pc, real_packet);
12466 }
12467 
12468 #define hash_packet_city_change_100 hash_const
12469 
12470 #define cmp_packet_city_change_100 cmp_const
12471 
12472 BV_DEFINE(packet_city_change_100_fields, 3);
12473 
receive_packet_city_change_100(struct connection * pc)12474 static struct packet_city_change *receive_packet_city_change_100(struct connection *pc)
12475 {
12476   packet_city_change_100_fields fields;
12477   struct packet_city_change *old;
12478   struct genhash **hash = pc->phs.received + PACKET_CITY_CHANGE;
12479   RECEIVE_PACKET_START(packet_city_change, real_packet);
12480 
12481   DIO_BV_GET(&din, fields);
12482 
12483   log_packet_detailed("packet_city_change_100: got info about ()");
12484 
12485   if (NULL == *hash) {
12486     *hash = genhash_new_full(hash_packet_city_change_100, cmp_packet_city_change_100,
12487                              NULL, NULL, NULL, free);
12488   }
12489 
12490   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
12491     *real_packet = *old;
12492   } else {
12493     log_packet_detailed("  no old info");
12494     memset(real_packet, 0, sizeof(*real_packet));
12495   }
12496 
12497   if (BV_ISSET(fields, 0)) {
12498     log_packet_detailed("  got field 'city_id'");
12499     if (!DIO_GET(uint16, &din, "city_id", &real_packet->city_id)) {
12500       RECEIVE_PACKET_FIELD_ERROR(city_id);
12501     }
12502   }
12503   if (BV_ISSET(fields, 1)) {
12504     log_packet_detailed("  got field 'production_kind'");
12505     if (!DIO_GET(uint8, &din, "production_kind", &real_packet->production_kind)) {
12506       RECEIVE_PACKET_FIELD_ERROR(production_kind);
12507     }
12508   }
12509   if (BV_ISSET(fields, 2)) {
12510     log_packet_detailed("  got field 'production_value'");
12511     if (!DIO_GET(uint8, &din, "production_value", &real_packet->production_value)) {
12512       RECEIVE_PACKET_FIELD_ERROR(production_value);
12513     }
12514   }
12515 
12516   if (NULL == old) {
12517     old = fc_malloc(sizeof(*old));
12518     *old = *real_packet;
12519     genhash_insert(*hash, old, old);
12520   } else {
12521     *old = *real_packet;
12522   }
12523   RECEIVE_PACKET_END(real_packet);
12524 }
12525 
send_packet_city_change_100(struct connection * pc,const struct packet_city_change * packet)12526 static int send_packet_city_change_100(struct connection *pc, const struct packet_city_change *packet)
12527 {
12528   const struct packet_city_change *real_packet = packet;
12529   packet_city_change_100_fields fields;
12530   struct packet_city_change *old;
12531   bool differ;
12532   struct genhash **hash = pc->phs.sent + PACKET_CITY_CHANGE;
12533   int different = 0;
12534   SEND_PACKET_START(PACKET_CITY_CHANGE);
12535 
12536   log_packet_detailed("packet_city_change_100: sending info about ()");
12537 
12538   if (NULL == *hash) {
12539     *hash = genhash_new_full(hash_packet_city_change_100, cmp_packet_city_change_100,
12540                              NULL, NULL, NULL, free);
12541   }
12542   BV_CLR_ALL(fields);
12543 
12544   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
12545     old = fc_malloc(sizeof(*old));
12546     *old = *real_packet;
12547     genhash_insert(*hash, old, old);
12548     memset(old, 0, sizeof(*old));
12549     different = 1;      /* Force to send. */
12550   }
12551 
12552   differ = (old->city_id != real_packet->city_id);
12553   if (differ) {
12554     different++;
12555     BV_SET(fields, 0);
12556   }
12557 
12558   differ = (old->production_kind != real_packet->production_kind);
12559   if (differ) {
12560     different++;
12561     BV_SET(fields, 1);
12562   }
12563 
12564   differ = (old->production_value != real_packet->production_value);
12565   if (differ) {
12566     different++;
12567     BV_SET(fields, 2);
12568   }
12569 
12570 
12571   DIO_BV_PUT(&dout, "fields", fields);
12572 
12573   if (BV_ISSET(fields, 0)) {
12574     log_packet_detailed("  field 'city_id' has changed");
12575     DIO_PUT(uint16, &dout, "city_id", real_packet->city_id);
12576   }
12577   if (BV_ISSET(fields, 1)) {
12578     log_packet_detailed("  field 'production_kind' has changed");
12579     DIO_PUT(uint8, &dout, "production_kind", real_packet->production_kind);
12580   }
12581   if (BV_ISSET(fields, 2)) {
12582     log_packet_detailed("  field 'production_value' has changed");
12583     DIO_PUT(uint8, &dout, "production_value", real_packet->production_value);
12584   }
12585 
12586   *old = *real_packet;
12587   SEND_PACKET_END(PACKET_CITY_CHANGE);
12588 }
12589 
send_packet_city_change(struct connection * pc,const struct packet_city_change * packet)12590 int send_packet_city_change(struct connection *pc, const struct packet_city_change *packet)
12591 {
12592   if (!pc->used) {
12593     log_error("WARNING: trying to send data to the closed connection %s",
12594               conn_description(pc));
12595     return -1;
12596   }
12597   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_CHANGE].packet != NULL, -1,
12598                         "Handler for PACKET_CITY_CHANGE not installed");
12599   return pc->phs.handlers->send[PACKET_CITY_CHANGE].packet(pc, packet);
12600 }
12601 
dsend_packet_city_change(struct connection * pc,int city_id,int production_kind,int production_value)12602 int dsend_packet_city_change(struct connection *pc, int city_id, int production_kind, int production_value)
12603 {
12604   struct packet_city_change packet, *real_packet = &packet;
12605 
12606   real_packet->city_id = city_id;
12607   real_packet->production_kind = production_kind;
12608   real_packet->production_value = production_value;
12609 
12610   return send_packet_city_change(pc, real_packet);
12611 }
12612 
12613 #define hash_packet_city_worklist_100 hash_const
12614 
12615 #define cmp_packet_city_worklist_100 cmp_const
12616 
12617 BV_DEFINE(packet_city_worklist_100_fields, 2);
12618 
receive_packet_city_worklist_100(struct connection * pc)12619 static struct packet_city_worklist *receive_packet_city_worklist_100(struct connection *pc)
12620 {
12621   packet_city_worklist_100_fields fields;
12622   struct packet_city_worklist *old;
12623   struct genhash **hash = pc->phs.received + PACKET_CITY_WORKLIST;
12624   RECEIVE_PACKET_START(packet_city_worklist, real_packet);
12625 
12626   DIO_BV_GET(&din, fields);
12627 
12628   log_packet_detailed("packet_city_worklist_100: got info about ()");
12629 
12630   if (NULL == *hash) {
12631     *hash = genhash_new_full(hash_packet_city_worklist_100, cmp_packet_city_worklist_100,
12632                              NULL, NULL, NULL, free);
12633   }
12634 
12635   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
12636     *real_packet = *old;
12637   } else {
12638     log_packet_detailed("  no old info");
12639     memset(real_packet, 0, sizeof(*real_packet));
12640   }
12641 
12642   if (BV_ISSET(fields, 0)) {
12643     log_packet_detailed("  got field 'city_id'");
12644     if (!DIO_GET(uint16, &din, "city_id", &real_packet->city_id)) {
12645       RECEIVE_PACKET_FIELD_ERROR(city_id);
12646     }
12647   }
12648   if (BV_ISSET(fields, 1)) {
12649     log_packet_detailed("  got field 'worklist'");
12650     if (!DIO_GET(worklist, &din, "worklist", &real_packet->worklist)) {
12651       RECEIVE_PACKET_FIELD_ERROR(worklist);
12652     }
12653   }
12654 
12655   if (NULL == old) {
12656     old = fc_malloc(sizeof(*old));
12657     *old = *real_packet;
12658     genhash_insert(*hash, old, old);
12659   } else {
12660     *old = *real_packet;
12661   }
12662   RECEIVE_PACKET_END(real_packet);
12663 }
12664 
send_packet_city_worklist_100(struct connection * pc,const struct packet_city_worklist * packet)12665 static int send_packet_city_worklist_100(struct connection *pc, const struct packet_city_worklist *packet)
12666 {
12667   const struct packet_city_worklist *real_packet = packet;
12668   packet_city_worklist_100_fields fields;
12669   struct packet_city_worklist *old;
12670   bool differ;
12671   struct genhash **hash = pc->phs.sent + PACKET_CITY_WORKLIST;
12672   int different = 0;
12673   SEND_PACKET_START(PACKET_CITY_WORKLIST);
12674 
12675   log_packet_detailed("packet_city_worklist_100: sending info about ()");
12676 
12677   if (NULL == *hash) {
12678     *hash = genhash_new_full(hash_packet_city_worklist_100, cmp_packet_city_worklist_100,
12679                              NULL, NULL, NULL, free);
12680   }
12681   BV_CLR_ALL(fields);
12682 
12683   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
12684     old = fc_malloc(sizeof(*old));
12685     *old = *real_packet;
12686     genhash_insert(*hash, old, old);
12687     memset(old, 0, sizeof(*old));
12688     different = 1;      /* Force to send. */
12689   }
12690 
12691   differ = (old->city_id != real_packet->city_id);
12692   if (differ) {
12693     different++;
12694     BV_SET(fields, 0);
12695   }
12696 
12697   differ = !are_worklists_equal(&old->worklist, &real_packet->worklist);
12698   if (differ) {
12699     different++;
12700     BV_SET(fields, 1);
12701   }
12702 
12703 
12704   DIO_BV_PUT(&dout, "fields", fields);
12705 
12706   if (BV_ISSET(fields, 0)) {
12707     log_packet_detailed("  field 'city_id' has changed");
12708     DIO_PUT(uint16, &dout, "city_id", real_packet->city_id);
12709   }
12710   if (BV_ISSET(fields, 1)) {
12711     log_packet_detailed("  field 'worklist' has changed");
12712     DIO_PUT(worklist, &dout, "worklist", &real_packet->worklist);
12713   }
12714 
12715   *old = *real_packet;
12716   SEND_PACKET_END(PACKET_CITY_WORKLIST);
12717 }
12718 
send_packet_city_worklist(struct connection * pc,const struct packet_city_worklist * packet)12719 int send_packet_city_worklist(struct connection *pc, const struct packet_city_worklist *packet)
12720 {
12721   if (!pc->used) {
12722     log_error("WARNING: trying to send data to the closed connection %s",
12723               conn_description(pc));
12724     return -1;
12725   }
12726   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_WORKLIST].packet != NULL, -1,
12727                         "Handler for PACKET_CITY_WORKLIST not installed");
12728   return pc->phs.handlers->send[PACKET_CITY_WORKLIST].packet(pc, packet);
12729 }
12730 
dsend_packet_city_worklist(struct connection * pc,int city_id,const struct worklist * worklist)12731 int dsend_packet_city_worklist(struct connection *pc, int city_id, const struct worklist *worklist)
12732 {
12733   struct packet_city_worklist packet, *real_packet = &packet;
12734 
12735   real_packet->city_id = city_id;
12736   worklist_copy(&real_packet->worklist, worklist);
12737 
12738   return send_packet_city_worklist(pc, real_packet);
12739 }
12740 
12741 #define hash_packet_city_make_specialist_100 hash_const
12742 
12743 #define cmp_packet_city_make_specialist_100 cmp_const
12744 
12745 BV_DEFINE(packet_city_make_specialist_100_fields, 3);
12746 
receive_packet_city_make_specialist_100(struct connection * pc)12747 static struct packet_city_make_specialist *receive_packet_city_make_specialist_100(struct connection *pc)
12748 {
12749   packet_city_make_specialist_100_fields fields;
12750   struct packet_city_make_specialist *old;
12751   struct genhash **hash = pc->phs.received + PACKET_CITY_MAKE_SPECIALIST;
12752   RECEIVE_PACKET_START(packet_city_make_specialist, real_packet);
12753 
12754   DIO_BV_GET(&din, fields);
12755 
12756   log_packet_detailed("packet_city_make_specialist_100: got info about ()");
12757 
12758   if (NULL == *hash) {
12759     *hash = genhash_new_full(hash_packet_city_make_specialist_100, cmp_packet_city_make_specialist_100,
12760                              NULL, NULL, NULL, free);
12761   }
12762 
12763   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
12764     *real_packet = *old;
12765   } else {
12766     log_packet_detailed("  no old info");
12767     memset(real_packet, 0, sizeof(*real_packet));
12768   }
12769 
12770   if (BV_ISSET(fields, 0)) {
12771     log_packet_detailed("  got field 'city_id'");
12772     if (!DIO_GET(uint16, &din, "city_id", &real_packet->city_id)) {
12773       RECEIVE_PACKET_FIELD_ERROR(city_id);
12774     }
12775   }
12776   if (BV_ISSET(fields, 1)) {
12777     log_packet_detailed("  got field 'worker_x'");
12778     if (!DIO_GET(uint8, &din, "worker_x", &real_packet->worker_x)) {
12779       RECEIVE_PACKET_FIELD_ERROR(worker_x);
12780     }
12781   }
12782   if (BV_ISSET(fields, 2)) {
12783     log_packet_detailed("  got field 'worker_y'");
12784     if (!DIO_GET(uint8, &din, "worker_y", &real_packet->worker_y)) {
12785       RECEIVE_PACKET_FIELD_ERROR(worker_y);
12786     }
12787   }
12788 
12789   if (NULL == old) {
12790     old = fc_malloc(sizeof(*old));
12791     *old = *real_packet;
12792     genhash_insert(*hash, old, old);
12793   } else {
12794     *old = *real_packet;
12795   }
12796   RECEIVE_PACKET_END(real_packet);
12797 }
12798 
send_packet_city_make_specialist_100(struct connection * pc,const struct packet_city_make_specialist * packet)12799 static int send_packet_city_make_specialist_100(struct connection *pc, const struct packet_city_make_specialist *packet)
12800 {
12801   const struct packet_city_make_specialist *real_packet = packet;
12802   packet_city_make_specialist_100_fields fields;
12803   struct packet_city_make_specialist *old;
12804   bool differ;
12805   struct genhash **hash = pc->phs.sent + PACKET_CITY_MAKE_SPECIALIST;
12806   int different = 0;
12807   SEND_PACKET_START(PACKET_CITY_MAKE_SPECIALIST);
12808 
12809   log_packet_detailed("packet_city_make_specialist_100: sending info about ()");
12810 
12811   if (NULL == *hash) {
12812     *hash = genhash_new_full(hash_packet_city_make_specialist_100, cmp_packet_city_make_specialist_100,
12813                              NULL, NULL, NULL, free);
12814   }
12815   BV_CLR_ALL(fields);
12816 
12817   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
12818     old = fc_malloc(sizeof(*old));
12819     *old = *real_packet;
12820     genhash_insert(*hash, old, old);
12821     memset(old, 0, sizeof(*old));
12822     different = 1;      /* Force to send. */
12823   }
12824 
12825   differ = (old->city_id != real_packet->city_id);
12826   if (differ) {
12827     different++;
12828     BV_SET(fields, 0);
12829   }
12830 
12831   differ = (old->worker_x != real_packet->worker_x);
12832   if (differ) {
12833     different++;
12834     BV_SET(fields, 1);
12835   }
12836 
12837   differ = (old->worker_y != real_packet->worker_y);
12838   if (differ) {
12839     different++;
12840     BV_SET(fields, 2);
12841   }
12842 
12843 
12844   DIO_BV_PUT(&dout, "fields", fields);
12845 
12846   if (BV_ISSET(fields, 0)) {
12847     log_packet_detailed("  field 'city_id' has changed");
12848     DIO_PUT(uint16, &dout, "city_id", real_packet->city_id);
12849   }
12850   if (BV_ISSET(fields, 1)) {
12851     log_packet_detailed("  field 'worker_x' has changed");
12852     DIO_PUT(uint8, &dout, "worker_x", real_packet->worker_x);
12853   }
12854   if (BV_ISSET(fields, 2)) {
12855     log_packet_detailed("  field 'worker_y' has changed");
12856     DIO_PUT(uint8, &dout, "worker_y", real_packet->worker_y);
12857   }
12858 
12859   *old = *real_packet;
12860   SEND_PACKET_END(PACKET_CITY_MAKE_SPECIALIST);
12861 }
12862 
send_packet_city_make_specialist(struct connection * pc,const struct packet_city_make_specialist * packet)12863 int send_packet_city_make_specialist(struct connection *pc, const struct packet_city_make_specialist *packet)
12864 {
12865   if (!pc->used) {
12866     log_error("WARNING: trying to send data to the closed connection %s",
12867               conn_description(pc));
12868     return -1;
12869   }
12870   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_MAKE_SPECIALIST].packet != NULL, -1,
12871                         "Handler for PACKET_CITY_MAKE_SPECIALIST not installed");
12872   return pc->phs.handlers->send[PACKET_CITY_MAKE_SPECIALIST].packet(pc, packet);
12873 }
12874 
dsend_packet_city_make_specialist(struct connection * pc,int city_id,int worker_x,int worker_y)12875 int dsend_packet_city_make_specialist(struct connection *pc, int city_id, int worker_x, int worker_y)
12876 {
12877   struct packet_city_make_specialist packet, *real_packet = &packet;
12878 
12879   real_packet->city_id = city_id;
12880   real_packet->worker_x = worker_x;
12881   real_packet->worker_y = worker_y;
12882 
12883   return send_packet_city_make_specialist(pc, real_packet);
12884 }
12885 
12886 #define hash_packet_city_make_worker_100 hash_const
12887 
12888 #define cmp_packet_city_make_worker_100 cmp_const
12889 
12890 BV_DEFINE(packet_city_make_worker_100_fields, 3);
12891 
receive_packet_city_make_worker_100(struct connection * pc)12892 static struct packet_city_make_worker *receive_packet_city_make_worker_100(struct connection *pc)
12893 {
12894   packet_city_make_worker_100_fields fields;
12895   struct packet_city_make_worker *old;
12896   struct genhash **hash = pc->phs.received + PACKET_CITY_MAKE_WORKER;
12897   RECEIVE_PACKET_START(packet_city_make_worker, real_packet);
12898 
12899   DIO_BV_GET(&din, fields);
12900 
12901   log_packet_detailed("packet_city_make_worker_100: got info about ()");
12902 
12903   if (NULL == *hash) {
12904     *hash = genhash_new_full(hash_packet_city_make_worker_100, cmp_packet_city_make_worker_100,
12905                              NULL, NULL, NULL, free);
12906   }
12907 
12908   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
12909     *real_packet = *old;
12910   } else {
12911     log_packet_detailed("  no old info");
12912     memset(real_packet, 0, sizeof(*real_packet));
12913   }
12914 
12915   if (BV_ISSET(fields, 0)) {
12916     log_packet_detailed("  got field 'city_id'");
12917     if (!DIO_GET(uint16, &din, "city_id", &real_packet->city_id)) {
12918       RECEIVE_PACKET_FIELD_ERROR(city_id);
12919     }
12920   }
12921   if (BV_ISSET(fields, 1)) {
12922     log_packet_detailed("  got field 'worker_x'");
12923     if (!DIO_GET(uint8, &din, "worker_x", &real_packet->worker_x)) {
12924       RECEIVE_PACKET_FIELD_ERROR(worker_x);
12925     }
12926   }
12927   if (BV_ISSET(fields, 2)) {
12928     log_packet_detailed("  got field 'worker_y'");
12929     if (!DIO_GET(uint8, &din, "worker_y", &real_packet->worker_y)) {
12930       RECEIVE_PACKET_FIELD_ERROR(worker_y);
12931     }
12932   }
12933 
12934   if (NULL == old) {
12935     old = fc_malloc(sizeof(*old));
12936     *old = *real_packet;
12937     genhash_insert(*hash, old, old);
12938   } else {
12939     *old = *real_packet;
12940   }
12941   RECEIVE_PACKET_END(real_packet);
12942 }
12943 
send_packet_city_make_worker_100(struct connection * pc,const struct packet_city_make_worker * packet)12944 static int send_packet_city_make_worker_100(struct connection *pc, const struct packet_city_make_worker *packet)
12945 {
12946   const struct packet_city_make_worker *real_packet = packet;
12947   packet_city_make_worker_100_fields fields;
12948   struct packet_city_make_worker *old;
12949   bool differ;
12950   struct genhash **hash = pc->phs.sent + PACKET_CITY_MAKE_WORKER;
12951   int different = 0;
12952   SEND_PACKET_START(PACKET_CITY_MAKE_WORKER);
12953 
12954   log_packet_detailed("packet_city_make_worker_100: sending info about ()");
12955 
12956   if (NULL == *hash) {
12957     *hash = genhash_new_full(hash_packet_city_make_worker_100, cmp_packet_city_make_worker_100,
12958                              NULL, NULL, NULL, free);
12959   }
12960   BV_CLR_ALL(fields);
12961 
12962   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
12963     old = fc_malloc(sizeof(*old));
12964     *old = *real_packet;
12965     genhash_insert(*hash, old, old);
12966     memset(old, 0, sizeof(*old));
12967     different = 1;      /* Force to send. */
12968   }
12969 
12970   differ = (old->city_id != real_packet->city_id);
12971   if (differ) {
12972     different++;
12973     BV_SET(fields, 0);
12974   }
12975 
12976   differ = (old->worker_x != real_packet->worker_x);
12977   if (differ) {
12978     different++;
12979     BV_SET(fields, 1);
12980   }
12981 
12982   differ = (old->worker_y != real_packet->worker_y);
12983   if (differ) {
12984     different++;
12985     BV_SET(fields, 2);
12986   }
12987 
12988 
12989   DIO_BV_PUT(&dout, "fields", fields);
12990 
12991   if (BV_ISSET(fields, 0)) {
12992     log_packet_detailed("  field 'city_id' has changed");
12993     DIO_PUT(uint16, &dout, "city_id", real_packet->city_id);
12994   }
12995   if (BV_ISSET(fields, 1)) {
12996     log_packet_detailed("  field 'worker_x' has changed");
12997     DIO_PUT(uint8, &dout, "worker_x", real_packet->worker_x);
12998   }
12999   if (BV_ISSET(fields, 2)) {
13000     log_packet_detailed("  field 'worker_y' has changed");
13001     DIO_PUT(uint8, &dout, "worker_y", real_packet->worker_y);
13002   }
13003 
13004   *old = *real_packet;
13005   SEND_PACKET_END(PACKET_CITY_MAKE_WORKER);
13006 }
13007 
send_packet_city_make_worker(struct connection * pc,const struct packet_city_make_worker * packet)13008 int send_packet_city_make_worker(struct connection *pc, const struct packet_city_make_worker *packet)
13009 {
13010   if (!pc->used) {
13011     log_error("WARNING: trying to send data to the closed connection %s",
13012               conn_description(pc));
13013     return -1;
13014   }
13015   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_MAKE_WORKER].packet != NULL, -1,
13016                         "Handler for PACKET_CITY_MAKE_WORKER not installed");
13017   return pc->phs.handlers->send[PACKET_CITY_MAKE_WORKER].packet(pc, packet);
13018 }
13019 
dsend_packet_city_make_worker(struct connection * pc,int city_id,int worker_x,int worker_y)13020 int dsend_packet_city_make_worker(struct connection *pc, int city_id, int worker_x, int worker_y)
13021 {
13022   struct packet_city_make_worker packet, *real_packet = &packet;
13023 
13024   real_packet->city_id = city_id;
13025   real_packet->worker_x = worker_x;
13026   real_packet->worker_y = worker_y;
13027 
13028   return send_packet_city_make_worker(pc, real_packet);
13029 }
13030 
13031 #define hash_packet_city_change_specialist_100 hash_const
13032 
13033 #define cmp_packet_city_change_specialist_100 cmp_const
13034 
13035 BV_DEFINE(packet_city_change_specialist_100_fields, 3);
13036 
receive_packet_city_change_specialist_100(struct connection * pc)13037 static struct packet_city_change_specialist *receive_packet_city_change_specialist_100(struct connection *pc)
13038 {
13039   packet_city_change_specialist_100_fields fields;
13040   struct packet_city_change_specialist *old;
13041   struct genhash **hash = pc->phs.received + PACKET_CITY_CHANGE_SPECIALIST;
13042   RECEIVE_PACKET_START(packet_city_change_specialist, real_packet);
13043 
13044   DIO_BV_GET(&din, fields);
13045 
13046   log_packet_detailed("packet_city_change_specialist_100: got info about ()");
13047 
13048   if (NULL == *hash) {
13049     *hash = genhash_new_full(hash_packet_city_change_specialist_100, cmp_packet_city_change_specialist_100,
13050                              NULL, NULL, NULL, free);
13051   }
13052 
13053   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
13054     *real_packet = *old;
13055   } else {
13056     log_packet_detailed("  no old info");
13057     memset(real_packet, 0, sizeof(*real_packet));
13058   }
13059 
13060   if (BV_ISSET(fields, 0)) {
13061     log_packet_detailed("  got field 'city_id'");
13062     if (!DIO_GET(uint16, &din, "city_id", &real_packet->city_id)) {
13063       RECEIVE_PACKET_FIELD_ERROR(city_id);
13064     }
13065   }
13066   if (BV_ISSET(fields, 1)) {
13067     log_packet_detailed("  got field 'from'");
13068     {
13069       int readin;
13070 
13071       if (!DIO_GET(uint8, &din, "from", &readin)) {
13072         RECEIVE_PACKET_FIELD_ERROR(from);
13073       }
13074       real_packet->from = readin;
13075     }
13076   }
13077   if (BV_ISSET(fields, 2)) {
13078     log_packet_detailed("  got field 'to'");
13079     {
13080       int readin;
13081 
13082       if (!DIO_GET(uint8, &din, "to", &readin)) {
13083         RECEIVE_PACKET_FIELD_ERROR(to);
13084       }
13085       real_packet->to = readin;
13086     }
13087   }
13088 
13089   if (NULL == old) {
13090     old = fc_malloc(sizeof(*old));
13091     *old = *real_packet;
13092     genhash_insert(*hash, old, old);
13093   } else {
13094     *old = *real_packet;
13095   }
13096   RECEIVE_PACKET_END(real_packet);
13097 }
13098 
send_packet_city_change_specialist_100(struct connection * pc,const struct packet_city_change_specialist * packet)13099 static int send_packet_city_change_specialist_100(struct connection *pc, const struct packet_city_change_specialist *packet)
13100 {
13101   const struct packet_city_change_specialist *real_packet = packet;
13102   packet_city_change_specialist_100_fields fields;
13103   struct packet_city_change_specialist *old;
13104   bool differ;
13105   struct genhash **hash = pc->phs.sent + PACKET_CITY_CHANGE_SPECIALIST;
13106   int different = 0;
13107   SEND_PACKET_START(PACKET_CITY_CHANGE_SPECIALIST);
13108 
13109   log_packet_detailed("packet_city_change_specialist_100: sending info about ()");
13110 
13111   if (NULL == *hash) {
13112     *hash = genhash_new_full(hash_packet_city_change_specialist_100, cmp_packet_city_change_specialist_100,
13113                              NULL, NULL, NULL, free);
13114   }
13115   BV_CLR_ALL(fields);
13116 
13117   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
13118     old = fc_malloc(sizeof(*old));
13119     *old = *real_packet;
13120     genhash_insert(*hash, old, old);
13121     memset(old, 0, sizeof(*old));
13122     different = 1;      /* Force to send. */
13123   }
13124 
13125   differ = (old->city_id != real_packet->city_id);
13126   if (differ) {
13127     different++;
13128     BV_SET(fields, 0);
13129   }
13130 
13131   differ = (old->from != real_packet->from);
13132   if (differ) {
13133     different++;
13134     BV_SET(fields, 1);
13135   }
13136 
13137   differ = (old->to != real_packet->to);
13138   if (differ) {
13139     different++;
13140     BV_SET(fields, 2);
13141   }
13142 
13143 
13144   DIO_BV_PUT(&dout, "fields", fields);
13145 
13146   if (BV_ISSET(fields, 0)) {
13147     log_packet_detailed("  field 'city_id' has changed");
13148     DIO_PUT(uint16, &dout, "city_id", real_packet->city_id);
13149   }
13150   if (BV_ISSET(fields, 1)) {
13151     log_packet_detailed("  field 'from' has changed");
13152     DIO_PUT(uint8, &dout, "from", real_packet->from);
13153   }
13154   if (BV_ISSET(fields, 2)) {
13155     log_packet_detailed("  field 'to' has changed");
13156     DIO_PUT(uint8, &dout, "to", real_packet->to);
13157   }
13158 
13159   *old = *real_packet;
13160   SEND_PACKET_END(PACKET_CITY_CHANGE_SPECIALIST);
13161 }
13162 
send_packet_city_change_specialist(struct connection * pc,const struct packet_city_change_specialist * packet)13163 int send_packet_city_change_specialist(struct connection *pc, const struct packet_city_change_specialist *packet)
13164 {
13165   if (!pc->used) {
13166     log_error("WARNING: trying to send data to the closed connection %s",
13167               conn_description(pc));
13168     return -1;
13169   }
13170   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_CHANGE_SPECIALIST].packet != NULL, -1,
13171                         "Handler for PACKET_CITY_CHANGE_SPECIALIST not installed");
13172   return pc->phs.handlers->send[PACKET_CITY_CHANGE_SPECIALIST].packet(pc, packet);
13173 }
13174 
dsend_packet_city_change_specialist(struct connection * pc,int city_id,Specialist_type_id from,Specialist_type_id to)13175 int dsend_packet_city_change_specialist(struct connection *pc, int city_id, Specialist_type_id from, Specialist_type_id to)
13176 {
13177   struct packet_city_change_specialist packet, *real_packet = &packet;
13178 
13179   real_packet->city_id = city_id;
13180   real_packet->from = from;
13181   real_packet->to = to;
13182 
13183   return send_packet_city_change_specialist(pc, real_packet);
13184 }
13185 
13186 #define hash_packet_city_rename_100 hash_const
13187 
13188 #define cmp_packet_city_rename_100 cmp_const
13189 
13190 BV_DEFINE(packet_city_rename_100_fields, 2);
13191 
receive_packet_city_rename_100(struct connection * pc)13192 static struct packet_city_rename *receive_packet_city_rename_100(struct connection *pc)
13193 {
13194   packet_city_rename_100_fields fields;
13195   struct packet_city_rename *old;
13196   struct genhash **hash = pc->phs.received + PACKET_CITY_RENAME;
13197   RECEIVE_PACKET_START(packet_city_rename, real_packet);
13198 
13199   DIO_BV_GET(&din, fields);
13200 
13201   log_packet_detailed("packet_city_rename_100: got info about ()");
13202 
13203   if (NULL == *hash) {
13204     *hash = genhash_new_full(hash_packet_city_rename_100, cmp_packet_city_rename_100,
13205                              NULL, NULL, NULL, free);
13206   }
13207 
13208   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
13209     *real_packet = *old;
13210   } else {
13211     log_packet_detailed("  no old info");
13212     memset(real_packet, 0, sizeof(*real_packet));
13213   }
13214 
13215   if (BV_ISSET(fields, 0)) {
13216     log_packet_detailed("  got field 'city_id'");
13217     if (!DIO_GET(uint16, &din, "city_id", &real_packet->city_id)) {
13218       RECEIVE_PACKET_FIELD_ERROR(city_id);
13219     }
13220   }
13221   if (BV_ISSET(fields, 1)) {
13222     log_packet_detailed("  got field 'name'");
13223     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
13224       RECEIVE_PACKET_FIELD_ERROR(name);
13225     }
13226   }
13227 
13228   if (NULL == old) {
13229     old = fc_malloc(sizeof(*old));
13230     *old = *real_packet;
13231     genhash_insert(*hash, old, old);
13232   } else {
13233     *old = *real_packet;
13234   }
13235   RECEIVE_PACKET_END(real_packet);
13236 }
13237 
send_packet_city_rename_100(struct connection * pc,const struct packet_city_rename * packet)13238 static int send_packet_city_rename_100(struct connection *pc, const struct packet_city_rename *packet)
13239 {
13240   const struct packet_city_rename *real_packet = packet;
13241   packet_city_rename_100_fields fields;
13242   struct packet_city_rename *old;
13243   bool differ;
13244   struct genhash **hash = pc->phs.sent + PACKET_CITY_RENAME;
13245   int different = 0;
13246   SEND_PACKET_START(PACKET_CITY_RENAME);
13247 
13248   log_packet_detailed("packet_city_rename_100: sending info about ()");
13249 
13250   if (NULL == *hash) {
13251     *hash = genhash_new_full(hash_packet_city_rename_100, cmp_packet_city_rename_100,
13252                              NULL, NULL, NULL, free);
13253   }
13254   BV_CLR_ALL(fields);
13255 
13256   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
13257     old = fc_malloc(sizeof(*old));
13258     *old = *real_packet;
13259     genhash_insert(*hash, old, old);
13260     memset(old, 0, sizeof(*old));
13261     different = 1;      /* Force to send. */
13262   }
13263 
13264   differ = (old->city_id != real_packet->city_id);
13265   if (differ) {
13266     different++;
13267     BV_SET(fields, 0);
13268   }
13269 
13270   differ = (strcmp(old->name, real_packet->name) != 0);
13271   if (differ) {
13272     different++;
13273     BV_SET(fields, 1);
13274   }
13275 
13276 
13277   DIO_BV_PUT(&dout, "fields", fields);
13278 
13279   if (BV_ISSET(fields, 0)) {
13280     log_packet_detailed("  field 'city_id' has changed");
13281     DIO_PUT(uint16, &dout, "city_id", real_packet->city_id);
13282   }
13283   if (BV_ISSET(fields, 1)) {
13284     log_packet_detailed("  field 'name' has changed");
13285     DIO_PUT(string, &dout, "name", real_packet->name);
13286   }
13287 
13288   *old = *real_packet;
13289   SEND_PACKET_END(PACKET_CITY_RENAME);
13290 }
13291 
send_packet_city_rename(struct connection * pc,const struct packet_city_rename * packet)13292 int send_packet_city_rename(struct connection *pc, const struct packet_city_rename *packet)
13293 {
13294   if (!pc->used) {
13295     log_error("WARNING: trying to send data to the closed connection %s",
13296               conn_description(pc));
13297     return -1;
13298   }
13299   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_RENAME].packet != NULL, -1,
13300                         "Handler for PACKET_CITY_RENAME not installed");
13301   return pc->phs.handlers->send[PACKET_CITY_RENAME].packet(pc, packet);
13302 }
13303 
dsend_packet_city_rename(struct connection * pc,int city_id,const char * name)13304 int dsend_packet_city_rename(struct connection *pc, int city_id, const char *name)
13305 {
13306   struct packet_city_rename packet, *real_packet = &packet;
13307 
13308   real_packet->city_id = city_id;
13309   sz_strlcpy(real_packet->name, name);
13310 
13311   return send_packet_city_rename(pc, real_packet);
13312 }
13313 
13314 #define hash_packet_city_options_req_100 hash_const
13315 
13316 #define cmp_packet_city_options_req_100 cmp_const
13317 
13318 BV_DEFINE(packet_city_options_req_100_fields, 2);
13319 
receive_packet_city_options_req_100(struct connection * pc)13320 static struct packet_city_options_req *receive_packet_city_options_req_100(struct connection *pc)
13321 {
13322   packet_city_options_req_100_fields fields;
13323   struct packet_city_options_req *old;
13324   struct genhash **hash = pc->phs.received + PACKET_CITY_OPTIONS_REQ;
13325   RECEIVE_PACKET_START(packet_city_options_req, real_packet);
13326 
13327   DIO_BV_GET(&din, fields);
13328 
13329   log_packet_detailed("packet_city_options_req_100: got info about ()");
13330 
13331   if (NULL == *hash) {
13332     *hash = genhash_new_full(hash_packet_city_options_req_100, cmp_packet_city_options_req_100,
13333                              NULL, NULL, NULL, free);
13334   }
13335 
13336   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
13337     *real_packet = *old;
13338   } else {
13339     log_packet_detailed("  no old info");
13340     memset(real_packet, 0, sizeof(*real_packet));
13341   }
13342 
13343   if (BV_ISSET(fields, 0)) {
13344     log_packet_detailed("  got field 'city_id'");
13345     if (!DIO_GET(uint16, &din, "city_id", &real_packet->city_id)) {
13346       RECEIVE_PACKET_FIELD_ERROR(city_id);
13347     }
13348   }
13349   if (BV_ISSET(fields, 1)) {
13350     log_packet_detailed("  got field 'options'");
13351     if (!DIO_BV_GET(&din, real_packet->options)) {
13352       RECEIVE_PACKET_FIELD_ERROR(options);
13353     }
13354   }
13355 
13356   if (NULL == old) {
13357     old = fc_malloc(sizeof(*old));
13358     *old = *real_packet;
13359     genhash_insert(*hash, old, old);
13360   } else {
13361     *old = *real_packet;
13362   }
13363   RECEIVE_PACKET_END(real_packet);
13364 }
13365 
send_packet_city_options_req_100(struct connection * pc,const struct packet_city_options_req * packet)13366 static int send_packet_city_options_req_100(struct connection *pc, const struct packet_city_options_req *packet)
13367 {
13368   const struct packet_city_options_req *real_packet = packet;
13369   packet_city_options_req_100_fields fields;
13370   struct packet_city_options_req *old;
13371   bool differ;
13372   struct genhash **hash = pc->phs.sent + PACKET_CITY_OPTIONS_REQ;
13373   int different = 0;
13374   SEND_PACKET_START(PACKET_CITY_OPTIONS_REQ);
13375 
13376   log_packet_detailed("packet_city_options_req_100: sending info about ()");
13377 
13378   if (NULL == *hash) {
13379     *hash = genhash_new_full(hash_packet_city_options_req_100, cmp_packet_city_options_req_100,
13380                              NULL, NULL, NULL, free);
13381   }
13382   BV_CLR_ALL(fields);
13383 
13384   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
13385     old = fc_malloc(sizeof(*old));
13386     *old = *real_packet;
13387     genhash_insert(*hash, old, old);
13388     memset(old, 0, sizeof(*old));
13389     different = 1;      /* Force to send. */
13390   }
13391 
13392   differ = (old->city_id != real_packet->city_id);
13393   if (differ) {
13394     different++;
13395     BV_SET(fields, 0);
13396   }
13397 
13398   differ = !BV_ARE_EQUAL(old->options, real_packet->options);
13399   if (differ) {
13400     different++;
13401     BV_SET(fields, 1);
13402   }
13403 
13404 
13405   DIO_BV_PUT(&dout, "fields", fields);
13406 
13407   if (BV_ISSET(fields, 0)) {
13408     log_packet_detailed("  field 'city_id' has changed");
13409     DIO_PUT(uint16, &dout, "city_id", real_packet->city_id);
13410   }
13411   if (BV_ISSET(fields, 1)) {
13412     log_packet_detailed("  field 'options' has changed");
13413   DIO_BV_PUT(&dout, "options", packet->options);
13414   }
13415 
13416   *old = *real_packet;
13417   SEND_PACKET_END(PACKET_CITY_OPTIONS_REQ);
13418 }
13419 
send_packet_city_options_req(struct connection * pc,const struct packet_city_options_req * packet)13420 int send_packet_city_options_req(struct connection *pc, const struct packet_city_options_req *packet)
13421 {
13422   if (!pc->used) {
13423     log_error("WARNING: trying to send data to the closed connection %s",
13424               conn_description(pc));
13425     return -1;
13426   }
13427   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_OPTIONS_REQ].packet != NULL, -1,
13428                         "Handler for PACKET_CITY_OPTIONS_REQ not installed");
13429   return pc->phs.handlers->send[PACKET_CITY_OPTIONS_REQ].packet(pc, packet);
13430 }
13431 
dsend_packet_city_options_req(struct connection * pc,int city_id,bv_city_options options)13432 int dsend_packet_city_options_req(struct connection *pc, int city_id, bv_city_options options)
13433 {
13434   struct packet_city_options_req packet, *real_packet = &packet;
13435 
13436   real_packet->city_id = city_id;
13437   real_packet->options = options;
13438 
13439   return send_packet_city_options_req(pc, real_packet);
13440 }
13441 
13442 #define hash_packet_city_refresh_100 hash_const
13443 
13444 #define cmp_packet_city_refresh_100 cmp_const
13445 
13446 BV_DEFINE(packet_city_refresh_100_fields, 1);
13447 
receive_packet_city_refresh_100(struct connection * pc)13448 static struct packet_city_refresh *receive_packet_city_refresh_100(struct connection *pc)
13449 {
13450   packet_city_refresh_100_fields fields;
13451   struct packet_city_refresh *old;
13452   struct genhash **hash = pc->phs.received + PACKET_CITY_REFRESH;
13453   RECEIVE_PACKET_START(packet_city_refresh, real_packet);
13454 
13455   DIO_BV_GET(&din, fields);
13456 
13457   log_packet_detailed("packet_city_refresh_100: got info about ()");
13458 
13459   if (NULL == *hash) {
13460     *hash = genhash_new_full(hash_packet_city_refresh_100, cmp_packet_city_refresh_100,
13461                              NULL, NULL, NULL, free);
13462   }
13463 
13464   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
13465     *real_packet = *old;
13466   } else {
13467     log_packet_detailed("  no old info");
13468     memset(real_packet, 0, sizeof(*real_packet));
13469   }
13470 
13471   if (BV_ISSET(fields, 0)) {
13472     log_packet_detailed("  got field 'city_id'");
13473     if (!DIO_GET(uint16, &din, "city_id", &real_packet->city_id)) {
13474       RECEIVE_PACKET_FIELD_ERROR(city_id);
13475     }
13476   }
13477 
13478   if (NULL == old) {
13479     old = fc_malloc(sizeof(*old));
13480     *old = *real_packet;
13481     genhash_insert(*hash, old, old);
13482   } else {
13483     *old = *real_packet;
13484   }
13485   RECEIVE_PACKET_END(real_packet);
13486 }
13487 
send_packet_city_refresh_100(struct connection * pc,const struct packet_city_refresh * packet)13488 static int send_packet_city_refresh_100(struct connection *pc, const struct packet_city_refresh *packet)
13489 {
13490   const struct packet_city_refresh *real_packet = packet;
13491   packet_city_refresh_100_fields fields;
13492   struct packet_city_refresh *old;
13493   bool differ;
13494   struct genhash **hash = pc->phs.sent + PACKET_CITY_REFRESH;
13495   int different = 0;
13496   SEND_PACKET_START(PACKET_CITY_REFRESH);
13497 
13498   log_packet_detailed("packet_city_refresh_100: sending info about ()");
13499 
13500   if (NULL == *hash) {
13501     *hash = genhash_new_full(hash_packet_city_refresh_100, cmp_packet_city_refresh_100,
13502                              NULL, NULL, NULL, free);
13503   }
13504   BV_CLR_ALL(fields);
13505 
13506   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
13507     old = fc_malloc(sizeof(*old));
13508     *old = *real_packet;
13509     genhash_insert(*hash, old, old);
13510     memset(old, 0, sizeof(*old));
13511     different = 1;      /* Force to send. */
13512   }
13513 
13514   differ = (old->city_id != real_packet->city_id);
13515   if (differ) {
13516     different++;
13517     BV_SET(fields, 0);
13518   }
13519 
13520 
13521   DIO_BV_PUT(&dout, "fields", fields);
13522 
13523   if (BV_ISSET(fields, 0)) {
13524     log_packet_detailed("  field 'city_id' has changed");
13525     DIO_PUT(uint16, &dout, "city_id", real_packet->city_id);
13526   }
13527 
13528   *old = *real_packet;
13529   SEND_PACKET_END(PACKET_CITY_REFRESH);
13530 }
13531 
send_packet_city_refresh(struct connection * pc,const struct packet_city_refresh * packet)13532 int send_packet_city_refresh(struct connection *pc, const struct packet_city_refresh *packet)
13533 {
13534   if (!pc->used) {
13535     log_error("WARNING: trying to send data to the closed connection %s",
13536               conn_description(pc));
13537     return -1;
13538   }
13539   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_REFRESH].packet != NULL, -1,
13540                         "Handler for PACKET_CITY_REFRESH not installed");
13541   return pc->phs.handlers->send[PACKET_CITY_REFRESH].packet(pc, packet);
13542 }
13543 
dsend_packet_city_refresh(struct connection * pc,int city_id)13544 int dsend_packet_city_refresh(struct connection *pc, int city_id)
13545 {
13546   struct packet_city_refresh packet, *real_packet = &packet;
13547 
13548   real_packet->city_id = city_id;
13549 
13550   return send_packet_city_refresh(pc, real_packet);
13551 }
13552 
13553 #define hash_packet_city_name_suggestion_req_100 hash_const
13554 
13555 #define cmp_packet_city_name_suggestion_req_100 cmp_const
13556 
13557 BV_DEFINE(packet_city_name_suggestion_req_100_fields, 1);
13558 
receive_packet_city_name_suggestion_req_100(struct connection * pc)13559 static struct packet_city_name_suggestion_req *receive_packet_city_name_suggestion_req_100(struct connection *pc)
13560 {
13561   packet_city_name_suggestion_req_100_fields fields;
13562   struct packet_city_name_suggestion_req *old;
13563   struct genhash **hash = pc->phs.received + PACKET_CITY_NAME_SUGGESTION_REQ;
13564   RECEIVE_PACKET_START(packet_city_name_suggestion_req, real_packet);
13565 
13566   DIO_BV_GET(&din, fields);
13567 
13568   log_packet_detailed("packet_city_name_suggestion_req_100: got info about ()");
13569 
13570   if (NULL == *hash) {
13571     *hash = genhash_new_full(hash_packet_city_name_suggestion_req_100, cmp_packet_city_name_suggestion_req_100,
13572                              NULL, NULL, NULL, free);
13573   }
13574 
13575   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
13576     *real_packet = *old;
13577   } else {
13578     log_packet_detailed("  no old info");
13579     memset(real_packet, 0, sizeof(*real_packet));
13580   }
13581 
13582   if (BV_ISSET(fields, 0)) {
13583     log_packet_detailed("  got field 'unit_id'");
13584     if (!DIO_GET(uint16, &din, "unit_id", &real_packet->unit_id)) {
13585       RECEIVE_PACKET_FIELD_ERROR(unit_id);
13586     }
13587   }
13588 
13589   if (NULL == old) {
13590     old = fc_malloc(sizeof(*old));
13591     *old = *real_packet;
13592     genhash_insert(*hash, old, old);
13593   } else {
13594     *old = *real_packet;
13595   }
13596   RECEIVE_PACKET_END(real_packet);
13597 }
13598 
send_packet_city_name_suggestion_req_100(struct connection * pc,const struct packet_city_name_suggestion_req * packet)13599 static int send_packet_city_name_suggestion_req_100(struct connection *pc, const struct packet_city_name_suggestion_req *packet)
13600 {
13601   const struct packet_city_name_suggestion_req *real_packet = packet;
13602   packet_city_name_suggestion_req_100_fields fields;
13603   struct packet_city_name_suggestion_req *old;
13604   bool differ;
13605   struct genhash **hash = pc->phs.sent + PACKET_CITY_NAME_SUGGESTION_REQ;
13606   int different = 0;
13607   SEND_PACKET_START(PACKET_CITY_NAME_SUGGESTION_REQ);
13608 
13609   log_packet_detailed("packet_city_name_suggestion_req_100: sending info about ()");
13610 
13611   if (NULL == *hash) {
13612     *hash = genhash_new_full(hash_packet_city_name_suggestion_req_100, cmp_packet_city_name_suggestion_req_100,
13613                              NULL, NULL, NULL, free);
13614   }
13615   BV_CLR_ALL(fields);
13616 
13617   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
13618     old = fc_malloc(sizeof(*old));
13619     *old = *real_packet;
13620     genhash_insert(*hash, old, old);
13621     memset(old, 0, sizeof(*old));
13622     different = 1;      /* Force to send. */
13623   }
13624 
13625   differ = (old->unit_id != real_packet->unit_id);
13626   if (differ) {
13627     different++;
13628     BV_SET(fields, 0);
13629   }
13630 
13631 
13632   DIO_BV_PUT(&dout, "fields", fields);
13633 
13634   if (BV_ISSET(fields, 0)) {
13635     log_packet_detailed("  field 'unit_id' has changed");
13636     DIO_PUT(uint16, &dout, "unit_id", real_packet->unit_id);
13637   }
13638 
13639   *old = *real_packet;
13640   SEND_PACKET_END(PACKET_CITY_NAME_SUGGESTION_REQ);
13641 }
13642 
send_packet_city_name_suggestion_req(struct connection * pc,const struct packet_city_name_suggestion_req * packet)13643 int send_packet_city_name_suggestion_req(struct connection *pc, const struct packet_city_name_suggestion_req *packet)
13644 {
13645   if (!pc->used) {
13646     log_error("WARNING: trying to send data to the closed connection %s",
13647               conn_description(pc));
13648     return -1;
13649   }
13650   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_NAME_SUGGESTION_REQ].packet != NULL, -1,
13651                         "Handler for PACKET_CITY_NAME_SUGGESTION_REQ not installed");
13652   return pc->phs.handlers->send[PACKET_CITY_NAME_SUGGESTION_REQ].packet(pc, packet);
13653 }
13654 
dsend_packet_city_name_suggestion_req(struct connection * pc,int unit_id)13655 int dsend_packet_city_name_suggestion_req(struct connection *pc, int unit_id)
13656 {
13657   struct packet_city_name_suggestion_req packet, *real_packet = &packet;
13658 
13659   real_packet->unit_id = unit_id;
13660 
13661   return send_packet_city_name_suggestion_req(pc, real_packet);
13662 }
13663 
13664 #define hash_packet_city_name_suggestion_info_100 hash_const
13665 
13666 #define cmp_packet_city_name_suggestion_info_100 cmp_const
13667 
13668 BV_DEFINE(packet_city_name_suggestion_info_100_fields, 2);
13669 
receive_packet_city_name_suggestion_info_100(struct connection * pc)13670 static struct packet_city_name_suggestion_info *receive_packet_city_name_suggestion_info_100(struct connection *pc)
13671 {
13672   packet_city_name_suggestion_info_100_fields fields;
13673   struct packet_city_name_suggestion_info *old;
13674   struct genhash **hash = pc->phs.received + PACKET_CITY_NAME_SUGGESTION_INFO;
13675   RECEIVE_PACKET_START(packet_city_name_suggestion_info, real_packet);
13676 
13677   DIO_BV_GET(&din, fields);
13678 
13679   log_packet_detailed("packet_city_name_suggestion_info_100: got info about ()");
13680 
13681   if (NULL == *hash) {
13682     *hash = genhash_new_full(hash_packet_city_name_suggestion_info_100, cmp_packet_city_name_suggestion_info_100,
13683                              NULL, NULL, NULL, free);
13684   }
13685 
13686   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
13687     *real_packet = *old;
13688   } else {
13689     log_packet_detailed("  no old info");
13690     memset(real_packet, 0, sizeof(*real_packet));
13691   }
13692 
13693   if (BV_ISSET(fields, 0)) {
13694     log_packet_detailed("  got field 'unit_id'");
13695     if (!DIO_GET(uint16, &din, "unit_id", &real_packet->unit_id)) {
13696       RECEIVE_PACKET_FIELD_ERROR(unit_id);
13697     }
13698   }
13699   if (BV_ISSET(fields, 1)) {
13700     log_packet_detailed("  got field 'name'");
13701     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
13702       RECEIVE_PACKET_FIELD_ERROR(name);
13703     }
13704   }
13705 
13706   if (NULL == old) {
13707     old = fc_malloc(sizeof(*old));
13708     *old = *real_packet;
13709     genhash_insert(*hash, old, old);
13710   } else {
13711     *old = *real_packet;
13712   }
13713   RECEIVE_PACKET_END(real_packet);
13714 }
13715 
send_packet_city_name_suggestion_info_100(struct connection * pc,const struct packet_city_name_suggestion_info * packet)13716 static int send_packet_city_name_suggestion_info_100(struct connection *pc, const struct packet_city_name_suggestion_info *packet)
13717 {
13718   const struct packet_city_name_suggestion_info *real_packet = packet;
13719   packet_city_name_suggestion_info_100_fields fields;
13720   struct packet_city_name_suggestion_info *old;
13721   bool differ;
13722   struct genhash **hash = pc->phs.sent + PACKET_CITY_NAME_SUGGESTION_INFO;
13723   int different = 0;
13724   SEND_PACKET_START(PACKET_CITY_NAME_SUGGESTION_INFO);
13725 
13726   log_packet_detailed("packet_city_name_suggestion_info_100: sending info about ()");
13727 
13728   if (NULL == *hash) {
13729     *hash = genhash_new_full(hash_packet_city_name_suggestion_info_100, cmp_packet_city_name_suggestion_info_100,
13730                              NULL, NULL, NULL, free);
13731   }
13732   BV_CLR_ALL(fields);
13733 
13734   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
13735     old = fc_malloc(sizeof(*old));
13736     *old = *real_packet;
13737     genhash_insert(*hash, old, old);
13738     memset(old, 0, sizeof(*old));
13739     different = 1;      /* Force to send. */
13740   }
13741 
13742   differ = (old->unit_id != real_packet->unit_id);
13743   if (differ) {
13744     different++;
13745     BV_SET(fields, 0);
13746   }
13747 
13748   differ = (strcmp(old->name, real_packet->name) != 0);
13749   if (differ) {
13750     different++;
13751     BV_SET(fields, 1);
13752   }
13753 
13754 
13755   DIO_BV_PUT(&dout, "fields", fields);
13756 
13757   if (BV_ISSET(fields, 0)) {
13758     log_packet_detailed("  field 'unit_id' has changed");
13759     DIO_PUT(uint16, &dout, "unit_id", real_packet->unit_id);
13760   }
13761   if (BV_ISSET(fields, 1)) {
13762     log_packet_detailed("  field 'name' has changed");
13763     DIO_PUT(string, &dout, "name", real_packet->name);
13764   }
13765 
13766   *old = *real_packet;
13767   SEND_PACKET_END(PACKET_CITY_NAME_SUGGESTION_INFO);
13768 }
13769 
send_packet_city_name_suggestion_info(struct connection * pc,const struct packet_city_name_suggestion_info * packet)13770 int send_packet_city_name_suggestion_info(struct connection *pc, const struct packet_city_name_suggestion_info *packet)
13771 {
13772   if (!pc->used) {
13773     log_error("WARNING: trying to send data to the closed connection %s",
13774               conn_description(pc));
13775     return -1;
13776   }
13777   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_NAME_SUGGESTION_INFO].packet != NULL, -1,
13778                         "Handler for PACKET_CITY_NAME_SUGGESTION_INFO not installed");
13779   return pc->phs.handlers->send[PACKET_CITY_NAME_SUGGESTION_INFO].packet(pc, packet);
13780 }
13781 
lsend_packet_city_name_suggestion_info(struct conn_list * dest,const struct packet_city_name_suggestion_info * packet)13782 void lsend_packet_city_name_suggestion_info(struct conn_list *dest, const struct packet_city_name_suggestion_info *packet)
13783 {
13784   conn_list_iterate(dest, pconn) {
13785     send_packet_city_name_suggestion_info(pconn, packet);
13786   } conn_list_iterate_end;
13787 }
13788 
dsend_packet_city_name_suggestion_info(struct connection * pc,int unit_id,const char * name)13789 int dsend_packet_city_name_suggestion_info(struct connection *pc, int unit_id, const char *name)
13790 {
13791   struct packet_city_name_suggestion_info packet, *real_packet = &packet;
13792 
13793   real_packet->unit_id = unit_id;
13794   sz_strlcpy(real_packet->name, name);
13795 
13796   return send_packet_city_name_suggestion_info(pc, real_packet);
13797 }
13798 
dlsend_packet_city_name_suggestion_info(struct conn_list * dest,int unit_id,const char * name)13799 void dlsend_packet_city_name_suggestion_info(struct conn_list *dest, int unit_id, const char *name)
13800 {
13801   struct packet_city_name_suggestion_info packet, *real_packet = &packet;
13802 
13803   real_packet->unit_id = unit_id;
13804   sz_strlcpy(real_packet->name, name);
13805 
13806   lsend_packet_city_name_suggestion_info(dest, real_packet);
13807 }
13808 
13809 #define hash_packet_city_sabotage_list_100 hash_const
13810 
13811 #define cmp_packet_city_sabotage_list_100 cmp_const
13812 
13813 BV_DEFINE(packet_city_sabotage_list_100_fields, 3);
13814 
receive_packet_city_sabotage_list_100(struct connection * pc)13815 static struct packet_city_sabotage_list *receive_packet_city_sabotage_list_100(struct connection *pc)
13816 {
13817   packet_city_sabotage_list_100_fields fields;
13818   struct packet_city_sabotage_list *old;
13819   struct genhash **hash = pc->phs.received + PACKET_CITY_SABOTAGE_LIST;
13820   RECEIVE_PACKET_START(packet_city_sabotage_list, real_packet);
13821 
13822   DIO_BV_GET(&din, fields);
13823 
13824   log_packet_detailed("packet_city_sabotage_list_100: got info about ()");
13825 
13826   if (NULL == *hash) {
13827     *hash = genhash_new_full(hash_packet_city_sabotage_list_100, cmp_packet_city_sabotage_list_100,
13828                              NULL, NULL, NULL, free);
13829   }
13830 
13831   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
13832     *real_packet = *old;
13833   } else {
13834     log_packet_detailed("  no old info");
13835     memset(real_packet, 0, sizeof(*real_packet));
13836   }
13837 
13838   if (BV_ISSET(fields, 0)) {
13839     log_packet_detailed("  got field 'diplomat_id'");
13840     if (!DIO_GET(uint16, &din, "diplomat_id", &real_packet->diplomat_id)) {
13841       RECEIVE_PACKET_FIELD_ERROR(diplomat_id);
13842     }
13843   }
13844   if (BV_ISSET(fields, 1)) {
13845     log_packet_detailed("  got field 'city_id'");
13846     if (!DIO_GET(uint16, &din, "city_id", &real_packet->city_id)) {
13847       RECEIVE_PACKET_FIELD_ERROR(city_id);
13848     }
13849   }
13850   if (BV_ISSET(fields, 2)) {
13851     log_packet_detailed("  got field 'improvements'");
13852     if (!DIO_BV_GET(&din, real_packet->improvements)) {
13853       RECEIVE_PACKET_FIELD_ERROR(improvements);
13854     }
13855   }
13856 
13857   if (NULL == old) {
13858     old = fc_malloc(sizeof(*old));
13859     *old = *real_packet;
13860     genhash_insert(*hash, old, old);
13861   } else {
13862     *old = *real_packet;
13863   }
13864   RECEIVE_PACKET_END(real_packet);
13865 }
13866 
send_packet_city_sabotage_list_100(struct connection * pc,const struct packet_city_sabotage_list * packet)13867 static int send_packet_city_sabotage_list_100(struct connection *pc, const struct packet_city_sabotage_list *packet)
13868 {
13869   const struct packet_city_sabotage_list *real_packet = packet;
13870   packet_city_sabotage_list_100_fields fields;
13871   struct packet_city_sabotage_list *old;
13872   bool differ;
13873   struct genhash **hash = pc->phs.sent + PACKET_CITY_SABOTAGE_LIST;
13874   int different = 0;
13875   SEND_PACKET_START(PACKET_CITY_SABOTAGE_LIST);
13876 
13877   log_packet_detailed("packet_city_sabotage_list_100: sending info about ()");
13878 
13879   if (NULL == *hash) {
13880     *hash = genhash_new_full(hash_packet_city_sabotage_list_100, cmp_packet_city_sabotage_list_100,
13881                              NULL, NULL, NULL, free);
13882   }
13883   BV_CLR_ALL(fields);
13884 
13885   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
13886     old = fc_malloc(sizeof(*old));
13887     *old = *real_packet;
13888     genhash_insert(*hash, old, old);
13889     memset(old, 0, sizeof(*old));
13890     different = 1;      /* Force to send. */
13891   }
13892 
13893   differ = (old->diplomat_id != real_packet->diplomat_id);
13894   if (differ) {
13895     different++;
13896     BV_SET(fields, 0);
13897   }
13898 
13899   differ = (old->city_id != real_packet->city_id);
13900   if (differ) {
13901     different++;
13902     BV_SET(fields, 1);
13903   }
13904 
13905   differ = !BV_ARE_EQUAL(old->improvements, real_packet->improvements);
13906   if (differ) {
13907     different++;
13908     BV_SET(fields, 2);
13909   }
13910 
13911 
13912   DIO_BV_PUT(&dout, "fields", fields);
13913 
13914   if (BV_ISSET(fields, 0)) {
13915     log_packet_detailed("  field 'diplomat_id' has changed");
13916     DIO_PUT(uint16, &dout, "diplomat_id", real_packet->diplomat_id);
13917   }
13918   if (BV_ISSET(fields, 1)) {
13919     log_packet_detailed("  field 'city_id' has changed");
13920     DIO_PUT(uint16, &dout, "city_id", real_packet->city_id);
13921   }
13922   if (BV_ISSET(fields, 2)) {
13923     log_packet_detailed("  field 'improvements' has changed");
13924   DIO_BV_PUT(&dout, "improvements", packet->improvements);
13925   }
13926 
13927   *old = *real_packet;
13928   SEND_PACKET_END(PACKET_CITY_SABOTAGE_LIST);
13929 }
13930 
send_packet_city_sabotage_list(struct connection * pc,const struct packet_city_sabotage_list * packet)13931 int send_packet_city_sabotage_list(struct connection *pc, const struct packet_city_sabotage_list *packet)
13932 {
13933   if (!pc->used) {
13934     log_error("WARNING: trying to send data to the closed connection %s",
13935               conn_description(pc));
13936     return -1;
13937   }
13938   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_SABOTAGE_LIST].packet != NULL, -1,
13939                         "Handler for PACKET_CITY_SABOTAGE_LIST not installed");
13940   return pc->phs.handlers->send[PACKET_CITY_SABOTAGE_LIST].packet(pc, packet);
13941 }
13942 
lsend_packet_city_sabotage_list(struct conn_list * dest,const struct packet_city_sabotage_list * packet)13943 void lsend_packet_city_sabotage_list(struct conn_list *dest, const struct packet_city_sabotage_list *packet)
13944 {
13945   conn_list_iterate(dest, pconn) {
13946     send_packet_city_sabotage_list(pconn, packet);
13947   } conn_list_iterate_end;
13948 }
13949 
13950 #define hash_packet_worker_task_100 hash_const
13951 
13952 #define cmp_packet_worker_task_100 cmp_const
13953 
13954 BV_DEFINE(packet_worker_task_100_fields, 5);
13955 
receive_packet_worker_task_100(struct connection * pc)13956 static struct packet_worker_task *receive_packet_worker_task_100(struct connection *pc)
13957 {
13958   packet_worker_task_100_fields fields;
13959   struct packet_worker_task *old;
13960   struct genhash **hash = pc->phs.received + PACKET_WORKER_TASK;
13961   RECEIVE_PACKET_START(packet_worker_task, real_packet);
13962 
13963   DIO_BV_GET(&din, fields);
13964 
13965   log_packet_detailed("packet_worker_task_100: got info about ()");
13966 
13967   if (NULL == *hash) {
13968     *hash = genhash_new_full(hash_packet_worker_task_100, cmp_packet_worker_task_100,
13969                              NULL, NULL, NULL, free);
13970   }
13971 
13972   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
13973     *real_packet = *old;
13974   } else {
13975     log_packet_detailed("  no old info");
13976     memset(real_packet, 0, sizeof(*real_packet));
13977   }
13978 
13979   if (BV_ISSET(fields, 0)) {
13980     log_packet_detailed("  got field 'city_id'");
13981     if (!DIO_GET(uint16, &din, "city_id", &real_packet->city_id)) {
13982       RECEIVE_PACKET_FIELD_ERROR(city_id);
13983     }
13984   }
13985   if (BV_ISSET(fields, 1)) {
13986     log_packet_detailed("  got field 'tile_id'");
13987     if (!DIO_GET(sint32, &din, "tile_id", &real_packet->tile_id)) {
13988       RECEIVE_PACKET_FIELD_ERROR(tile_id);
13989     }
13990   }
13991   if (BV_ISSET(fields, 2)) {
13992     log_packet_detailed("  got field 'activity'");
13993     {
13994       int readin;
13995 
13996       if (!DIO_GET(uint8, &din, "activity", &readin)) {
13997         RECEIVE_PACKET_FIELD_ERROR(activity);
13998       }
13999       real_packet->activity = readin;
14000     }
14001   }
14002   if (BV_ISSET(fields, 3)) {
14003     log_packet_detailed("  got field 'tgt'");
14004     if (!DIO_GET(sint8, &din, "tgt", &real_packet->tgt)) {
14005       RECEIVE_PACKET_FIELD_ERROR(tgt);
14006     }
14007   }
14008   if (BV_ISSET(fields, 4)) {
14009     log_packet_detailed("  got field 'want'");
14010     if (!DIO_GET(uint16, &din, "want", &real_packet->want)) {
14011       RECEIVE_PACKET_FIELD_ERROR(want);
14012     }
14013   }
14014 
14015   if (NULL == old) {
14016     old = fc_malloc(sizeof(*old));
14017     *old = *real_packet;
14018     genhash_insert(*hash, old, old);
14019   } else {
14020     *old = *real_packet;
14021   }
14022   RECEIVE_PACKET_END(real_packet);
14023 }
14024 
send_packet_worker_task_100(struct connection * pc,const struct packet_worker_task * packet)14025 static int send_packet_worker_task_100(struct connection *pc, const struct packet_worker_task *packet)
14026 {
14027   const struct packet_worker_task *real_packet = packet;
14028   packet_worker_task_100_fields fields;
14029   struct packet_worker_task *old;
14030   bool differ;
14031   struct genhash **hash = pc->phs.sent + PACKET_WORKER_TASK;
14032   int different = 0;
14033   SEND_PACKET_START(PACKET_WORKER_TASK);
14034 
14035   log_packet_detailed("packet_worker_task_100: sending info about ()");
14036 
14037   if (NULL == *hash) {
14038     *hash = genhash_new_full(hash_packet_worker_task_100, cmp_packet_worker_task_100,
14039                              NULL, NULL, NULL, free);
14040   }
14041   BV_CLR_ALL(fields);
14042 
14043   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
14044     old = fc_malloc(sizeof(*old));
14045     *old = *real_packet;
14046     genhash_insert(*hash, old, old);
14047     memset(old, 0, sizeof(*old));
14048     different = 1;      /* Force to send. */
14049   }
14050 
14051   differ = (old->city_id != real_packet->city_id);
14052   if (differ) {
14053     different++;
14054     BV_SET(fields, 0);
14055   }
14056 
14057   differ = (old->tile_id != real_packet->tile_id);
14058   if (differ) {
14059     different++;
14060     BV_SET(fields, 1);
14061   }
14062 
14063   differ = (old->activity != real_packet->activity);
14064   if (differ) {
14065     different++;
14066     BV_SET(fields, 2);
14067   }
14068 
14069   differ = (old->tgt != real_packet->tgt);
14070   if (differ) {
14071     different++;
14072     BV_SET(fields, 3);
14073   }
14074 
14075   differ = (old->want != real_packet->want);
14076   if (differ) {
14077     different++;
14078     BV_SET(fields, 4);
14079   }
14080 
14081 
14082   DIO_BV_PUT(&dout, "fields", fields);
14083 
14084   if (BV_ISSET(fields, 0)) {
14085     log_packet_detailed("  field 'city_id' has changed");
14086     DIO_PUT(uint16, &dout, "city_id", real_packet->city_id);
14087   }
14088   if (BV_ISSET(fields, 1)) {
14089     log_packet_detailed("  field 'tile_id' has changed");
14090     DIO_PUT(sint32, &dout, "tile_id", real_packet->tile_id);
14091   }
14092   if (BV_ISSET(fields, 2)) {
14093     log_packet_detailed("  field 'activity' has changed");
14094     DIO_PUT(uint8, &dout, "activity", real_packet->activity);
14095   }
14096   if (BV_ISSET(fields, 3)) {
14097     log_packet_detailed("  field 'tgt' has changed");
14098     DIO_PUT(sint8, &dout, "tgt", real_packet->tgt);
14099   }
14100   if (BV_ISSET(fields, 4)) {
14101     log_packet_detailed("  field 'want' has changed");
14102     DIO_PUT(uint16, &dout, "want", real_packet->want);
14103   }
14104 
14105   *old = *real_packet;
14106   SEND_PACKET_END(PACKET_WORKER_TASK);
14107 }
14108 
send_packet_worker_task(struct connection * pc,const struct packet_worker_task * packet)14109 int send_packet_worker_task(struct connection *pc, const struct packet_worker_task *packet)
14110 {
14111   if (!pc->used) {
14112     log_error("WARNING: trying to send data to the closed connection %s",
14113               conn_description(pc));
14114     return -1;
14115   }
14116   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_WORKER_TASK].packet != NULL, -1,
14117                         "Handler for PACKET_WORKER_TASK not installed");
14118   return pc->phs.handlers->send[PACKET_WORKER_TASK].packet(pc, packet);
14119 }
14120 
lsend_packet_worker_task(struct conn_list * dest,const struct packet_worker_task * packet)14121 void lsend_packet_worker_task(struct conn_list *dest, const struct packet_worker_task *packet)
14122 {
14123   conn_list_iterate(dest, pconn) {
14124     send_packet_worker_task(pconn, packet);
14125   } conn_list_iterate_end;
14126 }
14127 
14128 #define hash_packet_player_remove_100 hash_const
14129 
14130 #define cmp_packet_player_remove_100 cmp_const
14131 
14132 BV_DEFINE(packet_player_remove_100_fields, 1);
14133 
receive_packet_player_remove_100(struct connection * pc)14134 static struct packet_player_remove *receive_packet_player_remove_100(struct connection *pc)
14135 {
14136   packet_player_remove_100_fields fields;
14137   struct packet_player_remove *old;
14138   struct genhash **hash = pc->phs.received + PACKET_PLAYER_REMOVE;
14139   RECEIVE_PACKET_START(packet_player_remove, real_packet);
14140 
14141   DIO_BV_GET(&din, fields);
14142 
14143   log_packet_detailed("packet_player_remove_100: got info about ()");
14144 
14145   if (NULL == *hash) {
14146     *hash = genhash_new_full(hash_packet_player_remove_100, cmp_packet_player_remove_100,
14147                              NULL, NULL, NULL, free);
14148   }
14149 
14150   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
14151     *real_packet = *old;
14152   } else {
14153     log_packet_detailed("  no old info");
14154     memset(real_packet, 0, sizeof(*real_packet));
14155   }
14156 
14157   if (BV_ISSET(fields, 0)) {
14158     log_packet_detailed("  got field 'playerno'");
14159     if (!DIO_GET(uint8, &din, "playerno", &real_packet->playerno)) {
14160       RECEIVE_PACKET_FIELD_ERROR(playerno);
14161     }
14162   }
14163 
14164   if (NULL == old) {
14165     old = fc_malloc(sizeof(*old));
14166     *old = *real_packet;
14167     genhash_insert(*hash, old, old);
14168   } else {
14169     *old = *real_packet;
14170   }
14171 
14172   hash = pc->phs.received + PACKET_PLAYER_INFO;
14173   if (NULL != *hash) {
14174     genhash_remove(*hash, real_packet);
14175   }
14176   RECEIVE_PACKET_END(real_packet);
14177 }
14178 
send_packet_player_remove_100(struct connection * pc,const struct packet_player_remove * packet)14179 static int send_packet_player_remove_100(struct connection *pc, const struct packet_player_remove *packet)
14180 {
14181   const struct packet_player_remove *real_packet = packet;
14182   packet_player_remove_100_fields fields;
14183   struct packet_player_remove *old;
14184   bool differ;
14185   struct genhash **hash = pc->phs.sent + PACKET_PLAYER_REMOVE;
14186   int different = 0;
14187   SEND_PACKET_START(PACKET_PLAYER_REMOVE);
14188 
14189   log_packet_detailed("packet_player_remove_100: sending info about ()");
14190 
14191   if (NULL == *hash) {
14192     *hash = genhash_new_full(hash_packet_player_remove_100, cmp_packet_player_remove_100,
14193                              NULL, NULL, NULL, free);
14194   }
14195   BV_CLR_ALL(fields);
14196 
14197   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
14198     old = fc_malloc(sizeof(*old));
14199     *old = *real_packet;
14200     genhash_insert(*hash, old, old);
14201     memset(old, 0, sizeof(*old));
14202     different = 1;      /* Force to send. */
14203   }
14204 
14205   differ = (old->playerno != real_packet->playerno);
14206   if (differ) {
14207     different++;
14208     BV_SET(fields, 0);
14209   }
14210 
14211 
14212   DIO_BV_PUT(&dout, "fields", fields);
14213 
14214   if (BV_ISSET(fields, 0)) {
14215     log_packet_detailed("  field 'playerno' has changed");
14216     DIO_PUT(uint8, &dout, "playerno", real_packet->playerno);
14217   }
14218 
14219   *old = *real_packet;
14220 
14221   hash = pc->phs.sent + PACKET_PLAYER_INFO;
14222   if (NULL != *hash) {
14223     genhash_remove(*hash, real_packet);
14224   }
14225   SEND_PACKET_END(PACKET_PLAYER_REMOVE);
14226 }
14227 
send_packet_player_remove(struct connection * pc,const struct packet_player_remove * packet)14228 int send_packet_player_remove(struct connection *pc, const struct packet_player_remove *packet)
14229 {
14230   if (!pc->used) {
14231     log_error("WARNING: trying to send data to the closed connection %s",
14232               conn_description(pc));
14233     return -1;
14234   }
14235   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_REMOVE].packet != NULL, -1,
14236                         "Handler for PACKET_PLAYER_REMOVE not installed");
14237   return pc->phs.handlers->send[PACKET_PLAYER_REMOVE].packet(pc, packet);
14238 }
14239 
dsend_packet_player_remove(struct connection * pc,int playerno)14240 int dsend_packet_player_remove(struct connection *pc, int playerno)
14241 {
14242   struct packet_player_remove packet, *real_packet = &packet;
14243 
14244   real_packet->playerno = playerno;
14245 
14246   return send_packet_player_remove(pc, real_packet);
14247 }
14248 
hash_packet_player_info_100(const void * vkey)14249 static genhash_val_t hash_packet_player_info_100(const void *vkey)
14250 {
14251   const struct packet_player_info *key = (const struct packet_player_info *) vkey;
14252 
14253   return key->playerno;
14254 }
14255 
cmp_packet_player_info_100(const void * vkey1,const void * vkey2)14256 static bool cmp_packet_player_info_100(const void *vkey1, const void *vkey2)
14257 {
14258   const struct packet_player_info *key1 = (const struct packet_player_info *) vkey1;
14259   const struct packet_player_info *key2 = (const struct packet_player_info *) vkey2;
14260 
14261   return key1->playerno == key2->playerno;
14262 }
14263 
14264 BV_DEFINE(packet_player_info_100_fields, 42);
14265 
receive_packet_player_info_100(struct connection * pc)14266 static struct packet_player_info *receive_packet_player_info_100(struct connection *pc)
14267 {
14268   packet_player_info_100_fields fields;
14269   struct packet_player_info *old;
14270   struct genhash **hash = pc->phs.received + PACKET_PLAYER_INFO;
14271   RECEIVE_PACKET_START(packet_player_info, real_packet);
14272 
14273   DIO_BV_GET(&din, fields);
14274   if (!DIO_GET(uint8, &din, "playerno", &real_packet->playerno)) {
14275     RECEIVE_PACKET_FIELD_ERROR(playerno);
14276   }
14277 
14278   log_packet_detailed("packet_player_info_100: got info about (%d)",
14279     real_packet->playerno);
14280 
14281   if (NULL == *hash) {
14282     *hash = genhash_new_full(hash_packet_player_info_100, cmp_packet_player_info_100,
14283                              NULL, NULL, NULL, free);
14284   }
14285 
14286   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
14287     *real_packet = *old;
14288   } else {
14289     int playerno = real_packet->playerno;
14290 
14291     log_packet_detailed("  no old info");
14292     memset(real_packet, 0, sizeof(*real_packet));
14293 
14294     real_packet->playerno = playerno;
14295   }
14296 
14297   if (BV_ISSET(fields, 0)) {
14298     log_packet_detailed("  got field 'name'");
14299     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
14300       RECEIVE_PACKET_FIELD_ERROR(name);
14301     }
14302   }
14303   if (BV_ISSET(fields, 1)) {
14304     log_packet_detailed("  got field 'username'");
14305     if (!DIO_GET(string, &din, "username", real_packet->username, sizeof(real_packet->username))) {
14306       RECEIVE_PACKET_FIELD_ERROR(username);
14307     }
14308   }
14309   real_packet->unassigned_user = BV_ISSET(fields, 2);
14310   if (BV_ISSET(fields, 3)) {
14311     log_packet_detailed("  got field 'score'");
14312     if (!DIO_GET(uint32, &din, "score", &real_packet->score)) {
14313       RECEIVE_PACKET_FIELD_ERROR(score);
14314     }
14315   }
14316   real_packet->is_male = BV_ISSET(fields, 4);
14317   real_packet->was_created = BV_ISSET(fields, 5);
14318   if (BV_ISSET(fields, 6)) {
14319     log_packet_detailed("  got field 'government'");
14320     {
14321       int readin;
14322 
14323       if (!DIO_GET(sint8, &din, "government", &readin)) {
14324         RECEIVE_PACKET_FIELD_ERROR(government);
14325       }
14326       real_packet->government = readin;
14327     }
14328   }
14329   if (BV_ISSET(fields, 7)) {
14330     log_packet_detailed("  got field 'target_government'");
14331     {
14332       int readin;
14333 
14334       if (!DIO_GET(sint8, &din, "target_government", &readin)) {
14335         RECEIVE_PACKET_FIELD_ERROR(target_government);
14336       }
14337       real_packet->target_government = readin;
14338     }
14339   }
14340   if (BV_ISSET(fields, 8)) {
14341     log_packet_detailed("  got field 'real_embassy'");
14342 
14343     {
14344       int i;
14345 
14346       for (i = 0; i < MAX_NUM_PLAYER_SLOTS; i++) {
14347         if (!DIO_GET(bool8, &din, "real_embassy", &real_packet->real_embassy[i])) {
14348           RECEIVE_PACKET_FIELD_ERROR(real_embassy);
14349         }
14350       }
14351     }
14352   }
14353   if (BV_ISSET(fields, 9)) {
14354     log_packet_detailed("  got field 'mood'");
14355     {
14356       int readin;
14357 
14358       if (!DIO_GET(uint8, &din, "mood", &readin)) {
14359         RECEIVE_PACKET_FIELD_ERROR(mood);
14360       }
14361       real_packet->mood = readin;
14362     }
14363   }
14364   if (BV_ISSET(fields, 10)) {
14365     log_packet_detailed("  got field 'style'");
14366     if (!DIO_GET(uint8, &din, "style", &real_packet->style)) {
14367       RECEIVE_PACKET_FIELD_ERROR(style);
14368     }
14369   }
14370   if (BV_ISSET(fields, 11)) {
14371     log_packet_detailed("  got field 'music_style'");
14372     if (!DIO_GET(sint8, &din, "music_style", &real_packet->music_style)) {
14373       RECEIVE_PACKET_FIELD_ERROR(music_style);
14374     }
14375   }
14376   if (BV_ISSET(fields, 12)) {
14377     log_packet_detailed("  got field 'nation'");
14378     {
14379       int readin;
14380 
14381       if (!DIO_GET(sint16, &din, "nation", &readin)) {
14382         RECEIVE_PACKET_FIELD_ERROR(nation);
14383       }
14384       real_packet->nation = readin;
14385     }
14386   }
14387   if (BV_ISSET(fields, 13)) {
14388     log_packet_detailed("  got field 'team'");
14389     if (!DIO_GET(uint8, &din, "team", &real_packet->team)) {
14390       RECEIVE_PACKET_FIELD_ERROR(team);
14391     }
14392   }
14393   real_packet->is_ready = BV_ISSET(fields, 14);
14394   real_packet->phase_done = BV_ISSET(fields, 15);
14395   if (BV_ISSET(fields, 16)) {
14396     log_packet_detailed("  got field 'nturns_idle'");
14397     if (!DIO_GET(sint16, &din, "nturns_idle", &real_packet->nturns_idle)) {
14398       RECEIVE_PACKET_FIELD_ERROR(nturns_idle);
14399     }
14400   }
14401   if (BV_ISSET(fields, 17)) {
14402     log_packet_detailed("  got field 'turns_alive'");
14403     if (!DIO_GET(sint16, &din, "turns_alive", &real_packet->turns_alive)) {
14404       RECEIVE_PACKET_FIELD_ERROR(turns_alive);
14405     }
14406   }
14407   real_packet->is_alive = BV_ISSET(fields, 18);
14408   if (BV_ISSET(fields, 19)) {
14409     log_packet_detailed("  got field 'gold'");
14410     if (!DIO_GET(uint32, &din, "gold", &real_packet->gold)) {
14411       RECEIVE_PACKET_FIELD_ERROR(gold);
14412     }
14413   }
14414   if (BV_ISSET(fields, 20)) {
14415     log_packet_detailed("  got field 'tax'");
14416     if (!DIO_GET(uint8, &din, "tax", &real_packet->tax)) {
14417       RECEIVE_PACKET_FIELD_ERROR(tax);
14418     }
14419   }
14420   if (BV_ISSET(fields, 21)) {
14421     log_packet_detailed("  got field 'science'");
14422     if (!DIO_GET(uint8, &din, "science", &real_packet->science)) {
14423       RECEIVE_PACKET_FIELD_ERROR(science);
14424     }
14425   }
14426   if (BV_ISSET(fields, 22)) {
14427     log_packet_detailed("  got field 'luxury'");
14428     if (!DIO_GET(uint8, &din, "luxury", &real_packet->luxury)) {
14429       RECEIVE_PACKET_FIELD_ERROR(luxury);
14430     }
14431   }
14432   if (BV_ISSET(fields, 23)) {
14433     log_packet_detailed("  got field 'tech_upkeep'");
14434     if (!DIO_GET(uint16, &din, "tech_upkeep", &real_packet->tech_upkeep)) {
14435       RECEIVE_PACKET_FIELD_ERROR(tech_upkeep);
14436     }
14437   }
14438   if (BV_ISSET(fields, 24)) {
14439     log_packet_detailed("  got field 'science_cost'");
14440     if (!DIO_GET(uint16, &din, "science_cost", &real_packet->science_cost)) {
14441       RECEIVE_PACKET_FIELD_ERROR(science_cost);
14442     }
14443   }
14444   real_packet->is_connected = BV_ISSET(fields, 25);
14445   if (BV_ISSET(fields, 26)) {
14446     log_packet_detailed("  got field 'revolution_finishes'");
14447     if (!DIO_GET(sint16, &din, "revolution_finishes", &real_packet->revolution_finishes)) {
14448       RECEIVE_PACKET_FIELD_ERROR(revolution_finishes);
14449     }
14450   }
14451   real_packet->ai = BV_ISSET(fields, 27);
14452   if (BV_ISSET(fields, 28)) {
14453     log_packet_detailed("  got field 'ai_skill_level'");
14454     if (!DIO_GET(uint8, &din, "ai_skill_level", &real_packet->ai_skill_level)) {
14455       RECEIVE_PACKET_FIELD_ERROR(ai_skill_level);
14456     }
14457   }
14458   if (BV_ISSET(fields, 29)) {
14459     log_packet_detailed("  got field 'barbarian_type'");
14460     {
14461       int readin;
14462 
14463       if (!DIO_GET(uint8, &din, "barbarian_type", &readin)) {
14464         RECEIVE_PACKET_FIELD_ERROR(barbarian_type);
14465       }
14466       real_packet->barbarian_type = readin;
14467     }
14468   }
14469   if (BV_ISSET(fields, 30)) {
14470     log_packet_detailed("  got field 'gives_shared_vision'");
14471     if (!DIO_BV_GET(&din, real_packet->gives_shared_vision)) {
14472       RECEIVE_PACKET_FIELD_ERROR(gives_shared_vision);
14473     }
14474   }
14475   if (BV_ISSET(fields, 31)) {
14476     log_packet_detailed("  got field 'history'");
14477     if (!DIO_GET(uint16, &din, "history", &real_packet->history)) {
14478       RECEIVE_PACKET_FIELD_ERROR(history);
14479     }
14480   }
14481   if (BV_ISSET(fields, 32)) {
14482     log_packet_detailed("  got field 'love'");
14483 
14484     {
14485       int i;
14486 
14487       for (i = 0; i < MAX_NUM_PLAYER_SLOTS; i++) {
14488         if (!DIO_GET(sint16, &din, "love", &real_packet->love[i])) {
14489           RECEIVE_PACKET_FIELD_ERROR(love);
14490         }
14491       }
14492     }
14493   }
14494   real_packet->color_valid = BV_ISSET(fields, 33);
14495   real_packet->color_changeable = BV_ISSET(fields, 34);
14496   if (BV_ISSET(fields, 35)) {
14497     log_packet_detailed("  got field 'color_red'");
14498     if (!DIO_GET(uint8, &din, "color_red", &real_packet->color_red)) {
14499       RECEIVE_PACKET_FIELD_ERROR(color_red);
14500     }
14501   }
14502   if (BV_ISSET(fields, 36)) {
14503     log_packet_detailed("  got field 'color_green'");
14504     if (!DIO_GET(uint8, &din, "color_green", &real_packet->color_green)) {
14505       RECEIVE_PACKET_FIELD_ERROR(color_green);
14506     }
14507   }
14508   if (BV_ISSET(fields, 37)) {
14509     log_packet_detailed("  got field 'color_blue'");
14510     if (!DIO_GET(uint8, &din, "color_blue", &real_packet->color_blue)) {
14511       RECEIVE_PACKET_FIELD_ERROR(color_blue);
14512     }
14513   }
14514   if (BV_ISSET(fields, 38)) {
14515     log_packet_detailed("  got field 'wonders'");
14516 
14517     for (;;) {
14518       int i;
14519 
14520       if (!DIO_GET(uint8, &din, "wonders", &i)) {
14521         RECEIVE_PACKET_FIELD_ERROR(wonders);
14522       }
14523       if (i == 255) {
14524         break;
14525       }
14526       if (i > B_LAST) {
14527         RECEIVE_PACKET_FIELD_ERROR(wonders,
14528                                    ": unexpected value %d "
14529                                    "(> B_LAST) in array diff",
14530                                    i);
14531       } else {
14532         if (!DIO_GET(sint32, &din, "wonders", &real_packet->wonders[i])) {
14533           RECEIVE_PACKET_FIELD_ERROR(wonders);
14534         }
14535       }
14536     }
14537   }
14538   if (BV_ISSET(fields, 39)) {
14539     log_packet_detailed("  got field 'multip_count'");
14540     if (!DIO_GET(uint8, &din, "multip_count", &real_packet->multip_count)) {
14541       RECEIVE_PACKET_FIELD_ERROR(multip_count);
14542     }
14543   }
14544   if (BV_ISSET(fields, 40)) {
14545     log_packet_detailed("  got field 'multiplier'");
14546 
14547     {
14548       int i;
14549 
14550       if (real_packet->multip_count > MAX_NUM_MULTIPLIERS) {
14551         RECEIVE_PACKET_FIELD_ERROR(multiplier, ": truncation array");
14552       }
14553       for (i = 0; i < real_packet->multip_count; i++) {
14554         if (!DIO_GET(sint32, &din, "multiplier", &real_packet->multiplier[i])) {
14555           RECEIVE_PACKET_FIELD_ERROR(multiplier);
14556         }
14557       }
14558     }
14559   }
14560   if (BV_ISSET(fields, 41)) {
14561     log_packet_detailed("  got field 'multiplier_target'");
14562 
14563     {
14564       int i;
14565 
14566       if (real_packet->multip_count > MAX_NUM_MULTIPLIERS) {
14567         RECEIVE_PACKET_FIELD_ERROR(multiplier_target, ": truncation array");
14568       }
14569       for (i = 0; i < real_packet->multip_count; i++) {
14570         if (!DIO_GET(sint32, &din, "multiplier_target", &real_packet->multiplier_target[i])) {
14571           RECEIVE_PACKET_FIELD_ERROR(multiplier_target);
14572         }
14573       }
14574     }
14575   }
14576 
14577   if (NULL == old) {
14578     old = fc_malloc(sizeof(*old));
14579     *old = *real_packet;
14580     genhash_insert(*hash, old, old);
14581   } else {
14582     *old = *real_packet;
14583   }
14584   RECEIVE_PACKET_END(real_packet);
14585 }
14586 
send_packet_player_info_100(struct connection * pc,const struct packet_player_info * packet)14587 static int send_packet_player_info_100(struct connection *pc, const struct packet_player_info *packet)
14588 {
14589   const struct packet_player_info *real_packet = packet;
14590   packet_player_info_100_fields fields;
14591   struct packet_player_info *old;
14592   bool differ;
14593   struct genhash **hash = pc->phs.sent + PACKET_PLAYER_INFO;
14594   int different = 0;
14595   SEND_PACKET_START(PACKET_PLAYER_INFO);
14596 
14597   log_packet_detailed("packet_player_info_100: sending info about (%d)",
14598     real_packet->playerno);
14599 
14600   if (NULL == *hash) {
14601     *hash = genhash_new_full(hash_packet_player_info_100, cmp_packet_player_info_100,
14602                              NULL, NULL, NULL, free);
14603   }
14604   BV_CLR_ALL(fields);
14605 
14606   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
14607     old = fc_malloc(sizeof(*old));
14608     *old = *real_packet;
14609     genhash_insert(*hash, old, old);
14610     memset(old, 0, sizeof(*old));
14611     different = 1;      /* Force to send. */
14612   }
14613 
14614   differ = (strcmp(old->name, real_packet->name) != 0);
14615   if (differ) {
14616     different++;
14617     BV_SET(fields, 0);
14618   }
14619 
14620   differ = (strcmp(old->username, real_packet->username) != 0);
14621   if (differ) {
14622     different++;
14623     BV_SET(fields, 1);
14624   }
14625 
14626   differ = (old->unassigned_user != real_packet->unassigned_user);
14627   if (differ) {
14628     different++;
14629   }
14630   if (packet->unassigned_user) {
14631     BV_SET(fields, 2);
14632   }
14633 
14634   differ = (old->score != real_packet->score);
14635   if (differ) {
14636     different++;
14637     BV_SET(fields, 3);
14638   }
14639 
14640   differ = (old->is_male != real_packet->is_male);
14641   if (differ) {
14642     different++;
14643   }
14644   if (packet->is_male) {
14645     BV_SET(fields, 4);
14646   }
14647 
14648   differ = (old->was_created != real_packet->was_created);
14649   if (differ) {
14650     different++;
14651   }
14652   if (packet->was_created) {
14653     BV_SET(fields, 5);
14654   }
14655 
14656   differ = (old->government != real_packet->government);
14657   if (differ) {
14658     different++;
14659     BV_SET(fields, 6);
14660   }
14661 
14662   differ = (old->target_government != real_packet->target_government);
14663   if (differ) {
14664     different++;
14665     BV_SET(fields, 7);
14666   }
14667 
14668 
14669     {
14670       differ = (MAX_NUM_PLAYER_SLOTS != MAX_NUM_PLAYER_SLOTS);
14671       if (!differ) {
14672         int i;
14673 
14674         for (i = 0; i < MAX_NUM_PLAYER_SLOTS; i++) {
14675           if (old->real_embassy[i] != real_packet->real_embassy[i]) {
14676             differ = TRUE;
14677             break;
14678           }
14679         }
14680       }
14681     }
14682   if (differ) {
14683     different++;
14684     BV_SET(fields, 8);
14685   }
14686 
14687   differ = (old->mood != real_packet->mood);
14688   if (differ) {
14689     different++;
14690     BV_SET(fields, 9);
14691   }
14692 
14693   differ = (old->style != real_packet->style);
14694   if (differ) {
14695     different++;
14696     BV_SET(fields, 10);
14697   }
14698 
14699   differ = (old->music_style != real_packet->music_style);
14700   if (differ) {
14701     different++;
14702     BV_SET(fields, 11);
14703   }
14704 
14705   differ = (old->nation != real_packet->nation);
14706   if (differ) {
14707     different++;
14708     BV_SET(fields, 12);
14709   }
14710 
14711   differ = (old->team != real_packet->team);
14712   if (differ) {
14713     different++;
14714     BV_SET(fields, 13);
14715   }
14716 
14717   differ = (old->is_ready != real_packet->is_ready);
14718   if (differ) {
14719     different++;
14720   }
14721   if (packet->is_ready) {
14722     BV_SET(fields, 14);
14723   }
14724 
14725   differ = (old->phase_done != real_packet->phase_done);
14726   if (differ) {
14727     different++;
14728   }
14729   if (packet->phase_done) {
14730     BV_SET(fields, 15);
14731   }
14732 
14733   differ = (old->nturns_idle != real_packet->nturns_idle);
14734   if (differ) {
14735     different++;
14736     BV_SET(fields, 16);
14737   }
14738 
14739   differ = (old->turns_alive != real_packet->turns_alive);
14740   if (differ) {
14741     different++;
14742     BV_SET(fields, 17);
14743   }
14744 
14745   differ = (old->is_alive != real_packet->is_alive);
14746   if (differ) {
14747     different++;
14748   }
14749   if (packet->is_alive) {
14750     BV_SET(fields, 18);
14751   }
14752 
14753   differ = (old->gold != real_packet->gold);
14754   if (differ) {
14755     different++;
14756     BV_SET(fields, 19);
14757   }
14758 
14759   differ = (old->tax != real_packet->tax);
14760   if (differ) {
14761     different++;
14762     BV_SET(fields, 20);
14763   }
14764 
14765   differ = (old->science != real_packet->science);
14766   if (differ) {
14767     different++;
14768     BV_SET(fields, 21);
14769   }
14770 
14771   differ = (old->luxury != real_packet->luxury);
14772   if (differ) {
14773     different++;
14774     BV_SET(fields, 22);
14775   }
14776 
14777   differ = (old->tech_upkeep != real_packet->tech_upkeep);
14778   if (differ) {
14779     different++;
14780     BV_SET(fields, 23);
14781   }
14782 
14783   differ = (old->science_cost != real_packet->science_cost);
14784   if (differ) {
14785     different++;
14786     BV_SET(fields, 24);
14787   }
14788 
14789   differ = (old->is_connected != real_packet->is_connected);
14790   if (differ) {
14791     different++;
14792   }
14793   if (packet->is_connected) {
14794     BV_SET(fields, 25);
14795   }
14796 
14797   differ = (old->revolution_finishes != real_packet->revolution_finishes);
14798   if (differ) {
14799     different++;
14800     BV_SET(fields, 26);
14801   }
14802 
14803   differ = (old->ai != real_packet->ai);
14804   if (differ) {
14805     different++;
14806   }
14807   if (packet->ai) {
14808     BV_SET(fields, 27);
14809   }
14810 
14811   differ = (old->ai_skill_level != real_packet->ai_skill_level);
14812   if (differ) {
14813     different++;
14814     BV_SET(fields, 28);
14815   }
14816 
14817   differ = (old->barbarian_type != real_packet->barbarian_type);
14818   if (differ) {
14819     different++;
14820     BV_SET(fields, 29);
14821   }
14822 
14823   differ = !BV_ARE_EQUAL(old->gives_shared_vision, real_packet->gives_shared_vision);
14824   if (differ) {
14825     different++;
14826     BV_SET(fields, 30);
14827   }
14828 
14829   differ = (old->history != real_packet->history);
14830   if (differ) {
14831     different++;
14832     BV_SET(fields, 31);
14833   }
14834 
14835 
14836     {
14837       differ = (MAX_NUM_PLAYER_SLOTS != MAX_NUM_PLAYER_SLOTS);
14838       if (!differ) {
14839         int i;
14840 
14841         for (i = 0; i < MAX_NUM_PLAYER_SLOTS; i++) {
14842           if (old->love[i] != real_packet->love[i]) {
14843             differ = TRUE;
14844             break;
14845           }
14846         }
14847       }
14848     }
14849   if (differ) {
14850     different++;
14851     BV_SET(fields, 32);
14852   }
14853 
14854   differ = (old->color_valid != real_packet->color_valid);
14855   if (differ) {
14856     different++;
14857   }
14858   if (packet->color_valid) {
14859     BV_SET(fields, 33);
14860   }
14861 
14862   differ = (old->color_changeable != real_packet->color_changeable);
14863   if (differ) {
14864     different++;
14865   }
14866   if (packet->color_changeable) {
14867     BV_SET(fields, 34);
14868   }
14869 
14870   differ = (old->color_red != real_packet->color_red);
14871   if (differ) {
14872     different++;
14873     BV_SET(fields, 35);
14874   }
14875 
14876   differ = (old->color_green != real_packet->color_green);
14877   if (differ) {
14878     different++;
14879     BV_SET(fields, 36);
14880   }
14881 
14882   differ = (old->color_blue != real_packet->color_blue);
14883   if (differ) {
14884     different++;
14885     BV_SET(fields, 37);
14886   }
14887 
14888 
14889     {
14890       differ = (B_LAST != B_LAST);
14891       if (!differ) {
14892         int i;
14893 
14894         for (i = 0; i < B_LAST; i++) {
14895           if (old->wonders[i] != real_packet->wonders[i]) {
14896             differ = TRUE;
14897             break;
14898           }
14899         }
14900       }
14901     }
14902   if (differ) {
14903     different++;
14904     BV_SET(fields, 38);
14905   }
14906 
14907   differ = (old->multip_count != real_packet->multip_count);
14908   if (differ) {
14909     different++;
14910     BV_SET(fields, 39);
14911   }
14912 
14913 
14914     {
14915       differ = (old->multip_count != real_packet->multip_count);
14916       if (!differ) {
14917         int i;
14918 
14919         for (i = 0; i < real_packet->multip_count; i++) {
14920           if (old->multiplier[i] != real_packet->multiplier[i]) {
14921             differ = TRUE;
14922             break;
14923           }
14924         }
14925       }
14926     }
14927   if (differ) {
14928     different++;
14929     BV_SET(fields, 40);
14930   }
14931 
14932 
14933     {
14934       differ = (old->multip_count != real_packet->multip_count);
14935       if (!differ) {
14936         int i;
14937 
14938         for (i = 0; i < real_packet->multip_count; i++) {
14939           if (old->multiplier_target[i] != real_packet->multiplier_target[i]) {
14940             differ = TRUE;
14941             break;
14942           }
14943         }
14944       }
14945     }
14946   if (differ) {
14947     different++;
14948     BV_SET(fields, 41);
14949   }
14950 
14951 
14952   if (different == 0) {
14953     log_packet_detailed("  no change -> discard");
14954     return 0;
14955   }
14956 
14957   DIO_BV_PUT(&dout, "fields", fields);
14958   DIO_PUT(uint8, &dout, "playerno", real_packet->playerno);
14959 
14960   if (BV_ISSET(fields, 0)) {
14961     log_packet_detailed("  field 'name' has changed");
14962     DIO_PUT(string, &dout, "name", real_packet->name);
14963   }
14964   if (BV_ISSET(fields, 1)) {
14965     log_packet_detailed("  field 'username' has changed");
14966     DIO_PUT(string, &dout, "username", real_packet->username);
14967   }
14968   /* field 2 is folded into the header */
14969   if (BV_ISSET(fields, 3)) {
14970     log_packet_detailed("  field 'score' has changed");
14971     DIO_PUT(uint32, &dout, "score", real_packet->score);
14972   }
14973   /* field 4 is folded into the header */
14974   /* field 5 is folded into the header */
14975   if (BV_ISSET(fields, 6)) {
14976     log_packet_detailed("  field 'government' has changed");
14977     DIO_PUT(sint8, &dout, "government", real_packet->government);
14978   }
14979   if (BV_ISSET(fields, 7)) {
14980     log_packet_detailed("  field 'target_government' has changed");
14981     DIO_PUT(sint8, &dout, "target_government", real_packet->target_government);
14982   }
14983   if (BV_ISSET(fields, 8)) {
14984     log_packet_detailed("  field 'real_embassy' has changed");
14985 
14986     {
14987       int i;
14988 
14989       for (i = 0; i < MAX_NUM_PLAYER_SLOTS; i++) {
14990         dio_put_bool8(&dout, real_packet->real_embassy[i]);
14991       }
14992     }
14993   }
14994   if (BV_ISSET(fields, 9)) {
14995     log_packet_detailed("  field 'mood' has changed");
14996     DIO_PUT(uint8, &dout, "mood", real_packet->mood);
14997   }
14998   if (BV_ISSET(fields, 10)) {
14999     log_packet_detailed("  field 'style' has changed");
15000     DIO_PUT(uint8, &dout, "style", real_packet->style);
15001   }
15002   if (BV_ISSET(fields, 11)) {
15003     log_packet_detailed("  field 'music_style' has changed");
15004     DIO_PUT(sint8, &dout, "music_style", real_packet->music_style);
15005   }
15006   if (BV_ISSET(fields, 12)) {
15007     log_packet_detailed("  field 'nation' has changed");
15008     DIO_PUT(sint16, &dout, "nation", real_packet->nation);
15009   }
15010   if (BV_ISSET(fields, 13)) {
15011     log_packet_detailed("  field 'team' has changed");
15012     DIO_PUT(uint8, &dout, "team", real_packet->team);
15013   }
15014   /* field 14 is folded into the header */
15015   /* field 15 is folded into the header */
15016   if (BV_ISSET(fields, 16)) {
15017     log_packet_detailed("  field 'nturns_idle' has changed");
15018     DIO_PUT(sint16, &dout, "nturns_idle", real_packet->nturns_idle);
15019   }
15020   if (BV_ISSET(fields, 17)) {
15021     log_packet_detailed("  field 'turns_alive' has changed");
15022     DIO_PUT(sint16, &dout, "turns_alive", real_packet->turns_alive);
15023   }
15024   /* field 18 is folded into the header */
15025   if (BV_ISSET(fields, 19)) {
15026     log_packet_detailed("  field 'gold' has changed");
15027     DIO_PUT(uint32, &dout, "gold", real_packet->gold);
15028   }
15029   if (BV_ISSET(fields, 20)) {
15030     log_packet_detailed("  field 'tax' has changed");
15031     DIO_PUT(uint8, &dout, "tax", real_packet->tax);
15032   }
15033   if (BV_ISSET(fields, 21)) {
15034     log_packet_detailed("  field 'science' has changed");
15035     DIO_PUT(uint8, &dout, "science", real_packet->science);
15036   }
15037   if (BV_ISSET(fields, 22)) {
15038     log_packet_detailed("  field 'luxury' has changed");
15039     DIO_PUT(uint8, &dout, "luxury", real_packet->luxury);
15040   }
15041   if (BV_ISSET(fields, 23)) {
15042     log_packet_detailed("  field 'tech_upkeep' has changed");
15043     DIO_PUT(uint16, &dout, "tech_upkeep", real_packet->tech_upkeep);
15044   }
15045   if (BV_ISSET(fields, 24)) {
15046     log_packet_detailed("  field 'science_cost' has changed");
15047     DIO_PUT(uint16, &dout, "science_cost", real_packet->science_cost);
15048   }
15049   /* field 25 is folded into the header */
15050   if (BV_ISSET(fields, 26)) {
15051     log_packet_detailed("  field 'revolution_finishes' has changed");
15052     DIO_PUT(sint16, &dout, "revolution_finishes", real_packet->revolution_finishes);
15053   }
15054   /* field 27 is folded into the header */
15055   if (BV_ISSET(fields, 28)) {
15056     log_packet_detailed("  field 'ai_skill_level' has changed");
15057     DIO_PUT(uint8, &dout, "ai_skill_level", real_packet->ai_skill_level);
15058   }
15059   if (BV_ISSET(fields, 29)) {
15060     log_packet_detailed("  field 'barbarian_type' has changed");
15061     DIO_PUT(uint8, &dout, "barbarian_type", real_packet->barbarian_type);
15062   }
15063   if (BV_ISSET(fields, 30)) {
15064     log_packet_detailed("  field 'gives_shared_vision' has changed");
15065   DIO_BV_PUT(&dout, "gives_shared_vision", packet->gives_shared_vision);
15066   }
15067   if (BV_ISSET(fields, 31)) {
15068     log_packet_detailed("  field 'history' has changed");
15069     DIO_PUT(uint16, &dout, "history", real_packet->history);
15070   }
15071   if (BV_ISSET(fields, 32)) {
15072     log_packet_detailed("  field 'love' has changed");
15073 
15074     {
15075       int i;
15076 
15077       for (i = 0; i < MAX_NUM_PLAYER_SLOTS; i++) {
15078         dio_put_sint16(&dout, real_packet->love[i]);
15079       }
15080     }
15081   }
15082   /* field 33 is folded into the header */
15083   /* field 34 is folded into the header */
15084   if (BV_ISSET(fields, 35)) {
15085     log_packet_detailed("  field 'color_red' has changed");
15086     DIO_PUT(uint8, &dout, "color_red", real_packet->color_red);
15087   }
15088   if (BV_ISSET(fields, 36)) {
15089     log_packet_detailed("  field 'color_green' has changed");
15090     DIO_PUT(uint8, &dout, "color_green", real_packet->color_green);
15091   }
15092   if (BV_ISSET(fields, 37)) {
15093     log_packet_detailed("  field 'color_blue' has changed");
15094     DIO_PUT(uint8, &dout, "color_blue", real_packet->color_blue);
15095   }
15096   if (BV_ISSET(fields, 38)) {
15097     log_packet_detailed("  field 'wonders' has changed");
15098 
15099     {
15100       int i;
15101 
15102       fc_assert(B_LAST < 255);
15103 
15104       for (i = 0; i < B_LAST; i++) {
15105         if (old->wonders[i] != real_packet->wonders[i]) {
15106           dio_put_uint8(&dout, i);
15107           dio_put_sint32(&dout, real_packet->wonders[i]);
15108         }
15109       }
15110       dio_put_uint8(&dout, 255);
15111     }
15112   }
15113   if (BV_ISSET(fields, 39)) {
15114     log_packet_detailed("  field 'multip_count' has changed");
15115     DIO_PUT(uint8, &dout, "multip_count", real_packet->multip_count);
15116   }
15117   if (BV_ISSET(fields, 40)) {
15118     log_packet_detailed("  field 'multiplier' has changed");
15119 
15120     {
15121       int i;
15122 
15123       for (i = 0; i < real_packet->multip_count; i++) {
15124         dio_put_sint32(&dout, real_packet->multiplier[i]);
15125       }
15126     }
15127   }
15128   if (BV_ISSET(fields, 41)) {
15129     log_packet_detailed("  field 'multiplier_target' has changed");
15130 
15131     {
15132       int i;
15133 
15134       for (i = 0; i < real_packet->multip_count; i++) {
15135         dio_put_sint32(&dout, real_packet->multiplier_target[i]);
15136       }
15137     }
15138   }
15139 
15140   *old = *real_packet;
15141   SEND_PACKET_END(PACKET_PLAYER_INFO);
15142 }
15143 
send_packet_player_info(struct connection * pc,const struct packet_player_info * packet)15144 int send_packet_player_info(struct connection *pc, const struct packet_player_info *packet)
15145 {
15146   if (!pc->used) {
15147     log_error("WARNING: trying to send data to the closed connection %s",
15148               conn_description(pc));
15149     return -1;
15150   }
15151   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_INFO].packet != NULL, -1,
15152                         "Handler for PACKET_PLAYER_INFO not installed");
15153   return pc->phs.handlers->send[PACKET_PLAYER_INFO].packet(pc, packet);
15154 }
15155 
15156 #define hash_packet_player_phase_done_100 hash_const
15157 
15158 #define cmp_packet_player_phase_done_100 cmp_const
15159 
15160 BV_DEFINE(packet_player_phase_done_100_fields, 1);
15161 
receive_packet_player_phase_done_100(struct connection * pc)15162 static struct packet_player_phase_done *receive_packet_player_phase_done_100(struct connection *pc)
15163 {
15164   packet_player_phase_done_100_fields fields;
15165   struct packet_player_phase_done *old;
15166   struct genhash **hash = pc->phs.received + PACKET_PLAYER_PHASE_DONE;
15167   RECEIVE_PACKET_START(packet_player_phase_done, real_packet);
15168 
15169   DIO_BV_GET(&din, fields);
15170 
15171   log_packet_detailed("packet_player_phase_done_100: got info about ()");
15172 
15173   if (NULL == *hash) {
15174     *hash = genhash_new_full(hash_packet_player_phase_done_100, cmp_packet_player_phase_done_100,
15175                              NULL, NULL, NULL, free);
15176   }
15177 
15178   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
15179     *real_packet = *old;
15180   } else {
15181     log_packet_detailed("  no old info");
15182     memset(real_packet, 0, sizeof(*real_packet));
15183   }
15184 
15185   if (BV_ISSET(fields, 0)) {
15186     log_packet_detailed("  got field 'turn'");
15187     if (!DIO_GET(sint16, &din, "turn", &real_packet->turn)) {
15188       RECEIVE_PACKET_FIELD_ERROR(turn);
15189     }
15190   }
15191 
15192   if (NULL == old) {
15193     old = fc_malloc(sizeof(*old));
15194     *old = *real_packet;
15195     genhash_insert(*hash, old, old);
15196   } else {
15197     *old = *real_packet;
15198   }
15199   RECEIVE_PACKET_END(real_packet);
15200 }
15201 
send_packet_player_phase_done_100(struct connection * pc,const struct packet_player_phase_done * packet)15202 static int send_packet_player_phase_done_100(struct connection *pc, const struct packet_player_phase_done *packet)
15203 {
15204   const struct packet_player_phase_done *real_packet = packet;
15205   packet_player_phase_done_100_fields fields;
15206   struct packet_player_phase_done *old;
15207   bool differ;
15208   struct genhash **hash = pc->phs.sent + PACKET_PLAYER_PHASE_DONE;
15209   int different = 0;
15210   SEND_PACKET_START(PACKET_PLAYER_PHASE_DONE);
15211 
15212   log_packet_detailed("packet_player_phase_done_100: sending info about ()");
15213 
15214   if (NULL == *hash) {
15215     *hash = genhash_new_full(hash_packet_player_phase_done_100, cmp_packet_player_phase_done_100,
15216                              NULL, NULL, NULL, free);
15217   }
15218   BV_CLR_ALL(fields);
15219 
15220   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
15221     old = fc_malloc(sizeof(*old));
15222     *old = *real_packet;
15223     genhash_insert(*hash, old, old);
15224     memset(old, 0, sizeof(*old));
15225     different = 1;      /* Force to send. */
15226   }
15227 
15228   differ = (old->turn != real_packet->turn);
15229   if (differ) {
15230     different++;
15231     BV_SET(fields, 0);
15232   }
15233 
15234 
15235   DIO_BV_PUT(&dout, "fields", fields);
15236 
15237   if (BV_ISSET(fields, 0)) {
15238     log_packet_detailed("  field 'turn' has changed");
15239     DIO_PUT(sint16, &dout, "turn", real_packet->turn);
15240   }
15241 
15242   *old = *real_packet;
15243   SEND_PACKET_END(PACKET_PLAYER_PHASE_DONE);
15244 }
15245 
send_packet_player_phase_done(struct connection * pc,const struct packet_player_phase_done * packet)15246 int send_packet_player_phase_done(struct connection *pc, const struct packet_player_phase_done *packet)
15247 {
15248   if (!pc->used) {
15249     log_error("WARNING: trying to send data to the closed connection %s",
15250               conn_description(pc));
15251     return -1;
15252   }
15253   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_PHASE_DONE].packet != NULL, -1,
15254                         "Handler for PACKET_PLAYER_PHASE_DONE not installed");
15255   return pc->phs.handlers->send[PACKET_PLAYER_PHASE_DONE].packet(pc, packet);
15256 }
15257 
dsend_packet_player_phase_done(struct connection * pc,int turn)15258 int dsend_packet_player_phase_done(struct connection *pc, int turn)
15259 {
15260   struct packet_player_phase_done packet, *real_packet = &packet;
15261 
15262   real_packet->turn = turn;
15263 
15264   return send_packet_player_phase_done(pc, real_packet);
15265 }
15266 
15267 #define hash_packet_player_rates_100 hash_const
15268 
15269 #define cmp_packet_player_rates_100 cmp_const
15270 
15271 BV_DEFINE(packet_player_rates_100_fields, 3);
15272 
receive_packet_player_rates_100(struct connection * pc)15273 static struct packet_player_rates *receive_packet_player_rates_100(struct connection *pc)
15274 {
15275   packet_player_rates_100_fields fields;
15276   struct packet_player_rates *old;
15277   struct genhash **hash = pc->phs.received + PACKET_PLAYER_RATES;
15278   RECEIVE_PACKET_START(packet_player_rates, real_packet);
15279 
15280   DIO_BV_GET(&din, fields);
15281 
15282   log_packet_detailed("packet_player_rates_100: got info about ()");
15283 
15284   if (NULL == *hash) {
15285     *hash = genhash_new_full(hash_packet_player_rates_100, cmp_packet_player_rates_100,
15286                              NULL, NULL, NULL, free);
15287   }
15288 
15289   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
15290     *real_packet = *old;
15291   } else {
15292     log_packet_detailed("  no old info");
15293     memset(real_packet, 0, sizeof(*real_packet));
15294   }
15295 
15296   if (BV_ISSET(fields, 0)) {
15297     log_packet_detailed("  got field 'tax'");
15298     if (!DIO_GET(uint8, &din, "tax", &real_packet->tax)) {
15299       RECEIVE_PACKET_FIELD_ERROR(tax);
15300     }
15301   }
15302   if (BV_ISSET(fields, 1)) {
15303     log_packet_detailed("  got field 'luxury'");
15304     if (!DIO_GET(uint8, &din, "luxury", &real_packet->luxury)) {
15305       RECEIVE_PACKET_FIELD_ERROR(luxury);
15306     }
15307   }
15308   if (BV_ISSET(fields, 2)) {
15309     log_packet_detailed("  got field 'science'");
15310     if (!DIO_GET(uint8, &din, "science", &real_packet->science)) {
15311       RECEIVE_PACKET_FIELD_ERROR(science);
15312     }
15313   }
15314 
15315   if (NULL == old) {
15316     old = fc_malloc(sizeof(*old));
15317     *old = *real_packet;
15318     genhash_insert(*hash, old, old);
15319   } else {
15320     *old = *real_packet;
15321   }
15322   RECEIVE_PACKET_END(real_packet);
15323 }
15324 
send_packet_player_rates_100(struct connection * pc,const struct packet_player_rates * packet)15325 static int send_packet_player_rates_100(struct connection *pc, const struct packet_player_rates *packet)
15326 {
15327   const struct packet_player_rates *real_packet = packet;
15328   packet_player_rates_100_fields fields;
15329   struct packet_player_rates *old;
15330   bool differ;
15331   struct genhash **hash = pc->phs.sent + PACKET_PLAYER_RATES;
15332   int different = 0;
15333   SEND_PACKET_START(PACKET_PLAYER_RATES);
15334 
15335   log_packet_detailed("packet_player_rates_100: sending info about ()");
15336 
15337   if (NULL == *hash) {
15338     *hash = genhash_new_full(hash_packet_player_rates_100, cmp_packet_player_rates_100,
15339                              NULL, NULL, NULL, free);
15340   }
15341   BV_CLR_ALL(fields);
15342 
15343   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
15344     old = fc_malloc(sizeof(*old));
15345     *old = *real_packet;
15346     genhash_insert(*hash, old, old);
15347     memset(old, 0, sizeof(*old));
15348     different = 1;      /* Force to send. */
15349   }
15350 
15351   differ = (old->tax != real_packet->tax);
15352   if (differ) {
15353     different++;
15354     BV_SET(fields, 0);
15355   }
15356 
15357   differ = (old->luxury != real_packet->luxury);
15358   if (differ) {
15359     different++;
15360     BV_SET(fields, 1);
15361   }
15362 
15363   differ = (old->science != real_packet->science);
15364   if (differ) {
15365     different++;
15366     BV_SET(fields, 2);
15367   }
15368 
15369 
15370   DIO_BV_PUT(&dout, "fields", fields);
15371 
15372   if (BV_ISSET(fields, 0)) {
15373     log_packet_detailed("  field 'tax' has changed");
15374     DIO_PUT(uint8, &dout, "tax", real_packet->tax);
15375   }
15376   if (BV_ISSET(fields, 1)) {
15377     log_packet_detailed("  field 'luxury' has changed");
15378     DIO_PUT(uint8, &dout, "luxury", real_packet->luxury);
15379   }
15380   if (BV_ISSET(fields, 2)) {
15381     log_packet_detailed("  field 'science' has changed");
15382     DIO_PUT(uint8, &dout, "science", real_packet->science);
15383   }
15384 
15385   *old = *real_packet;
15386   SEND_PACKET_END(PACKET_PLAYER_RATES);
15387 }
15388 
send_packet_player_rates(struct connection * pc,const struct packet_player_rates * packet)15389 int send_packet_player_rates(struct connection *pc, const struct packet_player_rates *packet)
15390 {
15391   if (!pc->used) {
15392     log_error("WARNING: trying to send data to the closed connection %s",
15393               conn_description(pc));
15394     return -1;
15395   }
15396   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_RATES].packet != NULL, -1,
15397                         "Handler for PACKET_PLAYER_RATES not installed");
15398   return pc->phs.handlers->send[PACKET_PLAYER_RATES].packet(pc, packet);
15399 }
15400 
dsend_packet_player_rates(struct connection * pc,int tax,int luxury,int science)15401 int dsend_packet_player_rates(struct connection *pc, int tax, int luxury, int science)
15402 {
15403   struct packet_player_rates packet, *real_packet = &packet;
15404 
15405   real_packet->tax = tax;
15406   real_packet->luxury = luxury;
15407   real_packet->science = science;
15408 
15409   return send_packet_player_rates(pc, real_packet);
15410 }
15411 
15412 #define hash_packet_player_change_government_100 hash_const
15413 
15414 #define cmp_packet_player_change_government_100 cmp_const
15415 
15416 BV_DEFINE(packet_player_change_government_100_fields, 1);
15417 
receive_packet_player_change_government_100(struct connection * pc)15418 static struct packet_player_change_government *receive_packet_player_change_government_100(struct connection *pc)
15419 {
15420   packet_player_change_government_100_fields fields;
15421   struct packet_player_change_government *old;
15422   struct genhash **hash = pc->phs.received + PACKET_PLAYER_CHANGE_GOVERNMENT;
15423   RECEIVE_PACKET_START(packet_player_change_government, real_packet);
15424 
15425   DIO_BV_GET(&din, fields);
15426 
15427   log_packet_detailed("packet_player_change_government_100: got info about ()");
15428 
15429   if (NULL == *hash) {
15430     *hash = genhash_new_full(hash_packet_player_change_government_100, cmp_packet_player_change_government_100,
15431                              NULL, NULL, NULL, free);
15432   }
15433 
15434   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
15435     *real_packet = *old;
15436   } else {
15437     log_packet_detailed("  no old info");
15438     memset(real_packet, 0, sizeof(*real_packet));
15439   }
15440 
15441   if (BV_ISSET(fields, 0)) {
15442     log_packet_detailed("  got field 'government'");
15443     {
15444       int readin;
15445 
15446       if (!DIO_GET(sint8, &din, "government", &readin)) {
15447         RECEIVE_PACKET_FIELD_ERROR(government);
15448       }
15449       real_packet->government = readin;
15450     }
15451   }
15452 
15453   if (NULL == old) {
15454     old = fc_malloc(sizeof(*old));
15455     *old = *real_packet;
15456     genhash_insert(*hash, old, old);
15457   } else {
15458     *old = *real_packet;
15459   }
15460   RECEIVE_PACKET_END(real_packet);
15461 }
15462 
send_packet_player_change_government_100(struct connection * pc,const struct packet_player_change_government * packet)15463 static int send_packet_player_change_government_100(struct connection *pc, const struct packet_player_change_government *packet)
15464 {
15465   const struct packet_player_change_government *real_packet = packet;
15466   packet_player_change_government_100_fields fields;
15467   struct packet_player_change_government *old;
15468   bool differ;
15469   struct genhash **hash = pc->phs.sent + PACKET_PLAYER_CHANGE_GOVERNMENT;
15470   int different = 0;
15471   SEND_PACKET_START(PACKET_PLAYER_CHANGE_GOVERNMENT);
15472 
15473   log_packet_detailed("packet_player_change_government_100: sending info about ()");
15474 
15475   if (NULL == *hash) {
15476     *hash = genhash_new_full(hash_packet_player_change_government_100, cmp_packet_player_change_government_100,
15477                              NULL, NULL, NULL, free);
15478   }
15479   BV_CLR_ALL(fields);
15480 
15481   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
15482     old = fc_malloc(sizeof(*old));
15483     *old = *real_packet;
15484     genhash_insert(*hash, old, old);
15485     memset(old, 0, sizeof(*old));
15486     different = 1;      /* Force to send. */
15487   }
15488 
15489   differ = (old->government != real_packet->government);
15490   if (differ) {
15491     different++;
15492     BV_SET(fields, 0);
15493   }
15494 
15495 
15496   DIO_BV_PUT(&dout, "fields", fields);
15497 
15498   if (BV_ISSET(fields, 0)) {
15499     log_packet_detailed("  field 'government' has changed");
15500     DIO_PUT(sint8, &dout, "government", real_packet->government);
15501   }
15502 
15503   *old = *real_packet;
15504   SEND_PACKET_END(PACKET_PLAYER_CHANGE_GOVERNMENT);
15505 }
15506 
send_packet_player_change_government(struct connection * pc,const struct packet_player_change_government * packet)15507 int send_packet_player_change_government(struct connection *pc, const struct packet_player_change_government *packet)
15508 {
15509   if (!pc->used) {
15510     log_error("WARNING: trying to send data to the closed connection %s",
15511               conn_description(pc));
15512     return -1;
15513   }
15514   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_CHANGE_GOVERNMENT].packet != NULL, -1,
15515                         "Handler for PACKET_PLAYER_CHANGE_GOVERNMENT not installed");
15516   return pc->phs.handlers->send[PACKET_PLAYER_CHANGE_GOVERNMENT].packet(pc, packet);
15517 }
15518 
dsend_packet_player_change_government(struct connection * pc,Government_type_id government)15519 int dsend_packet_player_change_government(struct connection *pc, Government_type_id government)
15520 {
15521   struct packet_player_change_government packet, *real_packet = &packet;
15522 
15523   real_packet->government = government;
15524 
15525   return send_packet_player_change_government(pc, real_packet);
15526 }
15527 
receive_packet_player_attribute_block_100(struct connection * pc)15528 static struct packet_player_attribute_block *receive_packet_player_attribute_block_100(struct connection *pc)
15529 {
15530   RECEIVE_PACKET_START(packet_player_attribute_block, real_packet);
15531   real_packet->__dummy = 0xff;
15532   log_packet_detailed("packet_player_attribute_block_100: got info about ()");
15533   RECEIVE_PACKET_END(real_packet);
15534 }
15535 
send_packet_player_attribute_block_100(struct connection * pc)15536 static int send_packet_player_attribute_block_100(struct connection *pc)
15537 {
15538   SEND_PACKET_START(PACKET_PLAYER_ATTRIBUTE_BLOCK);
15539 
15540   log_packet_detailed("packet_player_attribute_block_100: sending info about ()");
15541   SEND_PACKET_END(PACKET_PLAYER_ATTRIBUTE_BLOCK);
15542 }
15543 
send_packet_player_attribute_block(struct connection * pc)15544 int send_packet_player_attribute_block(struct connection *pc)
15545 {
15546   if (!pc->used) {
15547     log_error("WARNING: trying to send data to the closed connection %s",
15548               conn_description(pc));
15549     return -1;
15550   }
15551   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_ATTRIBUTE_BLOCK].no_packet != NULL, -1,
15552                         "Handler for PACKET_PLAYER_ATTRIBUTE_BLOCK not installed");
15553   return pc->phs.handlers->send[PACKET_PLAYER_ATTRIBUTE_BLOCK].no_packet(pc);
15554 }
15555 
hash_packet_player_attribute_chunk_100(const void * vkey)15556 static genhash_val_t hash_packet_player_attribute_chunk_100(const void *vkey)
15557 {
15558   const struct packet_player_attribute_chunk *key = (const struct packet_player_attribute_chunk *) vkey;
15559 
15560   return key->offset;
15561 }
15562 
cmp_packet_player_attribute_chunk_100(const void * vkey1,const void * vkey2)15563 static bool cmp_packet_player_attribute_chunk_100(const void *vkey1, const void *vkey2)
15564 {
15565   const struct packet_player_attribute_chunk *key1 = (const struct packet_player_attribute_chunk *) vkey1;
15566   const struct packet_player_attribute_chunk *key2 = (const struct packet_player_attribute_chunk *) vkey2;
15567 
15568   return key1->offset == key2->offset;
15569 }
15570 
15571 BV_DEFINE(packet_player_attribute_chunk_100_fields, 3);
15572 
receive_packet_player_attribute_chunk_100(struct connection * pc)15573 static struct packet_player_attribute_chunk *receive_packet_player_attribute_chunk_100(struct connection *pc)
15574 {
15575   packet_player_attribute_chunk_100_fields fields;
15576   struct packet_player_attribute_chunk *old;
15577   struct genhash **hash = pc->phs.received + PACKET_PLAYER_ATTRIBUTE_CHUNK;
15578   RECEIVE_PACKET_START(packet_player_attribute_chunk, real_packet);
15579 
15580   DIO_BV_GET(&din, fields);
15581   if (!DIO_GET(uint32, &din, "offset", &real_packet->offset)) {
15582     RECEIVE_PACKET_FIELD_ERROR(offset);
15583   }
15584 
15585   log_packet_detailed("packet_player_attribute_chunk_100: got info about (%d)",
15586     real_packet->offset);
15587 
15588   if (NULL == *hash) {
15589     *hash = genhash_new_full(hash_packet_player_attribute_chunk_100, cmp_packet_player_attribute_chunk_100,
15590                              NULL, NULL, NULL, free);
15591   }
15592 
15593   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
15594     *real_packet = *old;
15595   } else {
15596     int offset = real_packet->offset;
15597 
15598     log_packet_detailed("  no old info");
15599     memset(real_packet, 0, sizeof(*real_packet));
15600 
15601     real_packet->offset = offset;
15602   }
15603 
15604   if (BV_ISSET(fields, 0)) {
15605     log_packet_detailed("  got field 'total_length'");
15606     if (!DIO_GET(uint32, &din, "total_length", &real_packet->total_length)) {
15607       RECEIVE_PACKET_FIELD_ERROR(total_length);
15608     }
15609   }
15610   if (BV_ISSET(fields, 1)) {
15611     log_packet_detailed("  got field 'chunk_length'");
15612     if (!DIO_GET(uint16, &din, "chunk_length", &real_packet->chunk_length)) {
15613       RECEIVE_PACKET_FIELD_ERROR(chunk_length);
15614     }
15615   }
15616   if (BV_ISSET(fields, 2)) {
15617     log_packet_detailed("  got field 'data'");
15618 
15619       if (real_packet->chunk_length > ATTRIBUTE_CHUNK_SIZE) {
15620         RECEIVE_PACKET_FIELD_ERROR(data, ": truncation array");
15621       }
15622       if (!dio_get_memory(&din, real_packet->data, real_packet->chunk_length)){
15623         RECEIVE_PACKET_FIELD_ERROR(data);
15624       }
15625   }
15626 
15627   if (NULL == old) {
15628     old = fc_malloc(sizeof(*old));
15629     *old = *real_packet;
15630     genhash_insert(*hash, old, old);
15631   } else {
15632     *old = *real_packet;
15633   }
15634   RECEIVE_PACKET_END(real_packet);
15635 }
15636 
send_packet_player_attribute_chunk_100(struct connection * pc,const struct packet_player_attribute_chunk * packet)15637 static int send_packet_player_attribute_chunk_100(struct connection *pc, const struct packet_player_attribute_chunk *packet)
15638 {
15639   const struct packet_player_attribute_chunk *real_packet = packet;
15640   packet_player_attribute_chunk_100_fields fields;
15641   struct packet_player_attribute_chunk *old;
15642   bool differ;
15643   struct genhash **hash = pc->phs.sent + PACKET_PLAYER_ATTRIBUTE_CHUNK;
15644   int different = 0;
15645   SEND_PACKET_START(PACKET_PLAYER_ATTRIBUTE_CHUNK);
15646 
15647   log_packet_detailed("packet_player_attribute_chunk_100: sending info about (%d)",
15648     real_packet->offset);
15649 
15650   {
15651     struct packet_player_attribute_chunk *tmp = fc_malloc(sizeof(*tmp));
15652 
15653     *tmp = *packet;
15654     pre_send_packet_player_attribute_chunk(pc, tmp);
15655     real_packet = tmp;
15656   }
15657 
15658   if (NULL == *hash) {
15659     *hash = genhash_new_full(hash_packet_player_attribute_chunk_100, cmp_packet_player_attribute_chunk_100,
15660                              NULL, NULL, NULL, free);
15661   }
15662   BV_CLR_ALL(fields);
15663 
15664   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
15665     old = fc_malloc(sizeof(*old));
15666     *old = *real_packet;
15667     genhash_insert(*hash, old, old);
15668     memset(old, 0, sizeof(*old));
15669     different = 1;      /* Force to send. */
15670   }
15671 
15672   differ = (old->total_length != real_packet->total_length);
15673   if (differ) {
15674     different++;
15675     BV_SET(fields, 0);
15676   }
15677 
15678   differ = (old->chunk_length != real_packet->chunk_length);
15679   if (differ) {
15680     different++;
15681     BV_SET(fields, 1);
15682   }
15683 
15684   differ = (memcmp(old->data, real_packet->data, ATTRIBUTE_CHUNK_SIZE) != 0);
15685   if (differ) {
15686     different++;
15687     BV_SET(fields, 2);
15688   }
15689 
15690 
15691   DIO_BV_PUT(&dout, "fields", fields);
15692   DIO_PUT(uint32, &dout, "offset", real_packet->offset);
15693 
15694   if (BV_ISSET(fields, 0)) {
15695     log_packet_detailed("  field 'total_length' has changed");
15696     DIO_PUT(uint32, &dout, "total_length", real_packet->total_length);
15697   }
15698   if (BV_ISSET(fields, 1)) {
15699     log_packet_detailed("  field 'chunk_length' has changed");
15700     DIO_PUT(uint16, &dout, "chunk_length", real_packet->chunk_length);
15701   }
15702   if (BV_ISSET(fields, 2)) {
15703     log_packet_detailed("  field 'data' has changed");
15704     DIO_PUT(memory, &dout, "data", &real_packet->data, real_packet->chunk_length);
15705   }
15706 
15707   *old = *real_packet;
15708 
15709   if (real_packet != packet) {
15710     free((void *) real_packet);
15711   }
15712   SEND_PACKET_END(PACKET_PLAYER_ATTRIBUTE_CHUNK);
15713 }
15714 
send_packet_player_attribute_chunk(struct connection * pc,const struct packet_player_attribute_chunk * packet)15715 int send_packet_player_attribute_chunk(struct connection *pc, const struct packet_player_attribute_chunk *packet)
15716 {
15717   if (!pc->used) {
15718     log_error("WARNING: trying to send data to the closed connection %s",
15719               conn_description(pc));
15720     return -1;
15721   }
15722   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_ATTRIBUTE_CHUNK].packet != NULL, -1,
15723                         "Handler for PACKET_PLAYER_ATTRIBUTE_CHUNK not installed");
15724   return pc->phs.handlers->send[PACKET_PLAYER_ATTRIBUTE_CHUNK].packet(pc, packet);
15725 }
15726 
hash_packet_player_diplstate_100(const void * vkey)15727 static genhash_val_t hash_packet_player_diplstate_100(const void *vkey)
15728 {
15729   const struct packet_player_diplstate *key = (const struct packet_player_diplstate *) vkey;
15730 
15731   return key->diplstate_id;
15732 }
15733 
cmp_packet_player_diplstate_100(const void * vkey1,const void * vkey2)15734 static bool cmp_packet_player_diplstate_100(const void *vkey1, const void *vkey2)
15735 {
15736   const struct packet_player_diplstate *key1 = (const struct packet_player_diplstate *) vkey1;
15737   const struct packet_player_diplstate *key2 = (const struct packet_player_diplstate *) vkey2;
15738 
15739   return key1->diplstate_id == key2->diplstate_id;
15740 }
15741 
15742 BV_DEFINE(packet_player_diplstate_100_fields, 6);
15743 
receive_packet_player_diplstate_100(struct connection * pc)15744 static struct packet_player_diplstate *receive_packet_player_diplstate_100(struct connection *pc)
15745 {
15746   packet_player_diplstate_100_fields fields;
15747   struct packet_player_diplstate *old;
15748   struct genhash **hash = pc->phs.received + PACKET_PLAYER_DIPLSTATE;
15749   RECEIVE_PACKET_START(packet_player_diplstate, real_packet);
15750 
15751   DIO_BV_GET(&din, fields);
15752   if (!DIO_GET(uint32, &din, "diplstate_id", &real_packet->diplstate_id)) {
15753     RECEIVE_PACKET_FIELD_ERROR(diplstate_id);
15754   }
15755 
15756   log_packet_detailed("packet_player_diplstate_100: got info about (%d)",
15757     real_packet->diplstate_id);
15758 
15759   if (NULL == *hash) {
15760     *hash = genhash_new_full(hash_packet_player_diplstate_100, cmp_packet_player_diplstate_100,
15761                              NULL, NULL, NULL, free);
15762   }
15763 
15764   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
15765     *real_packet = *old;
15766   } else {
15767     int diplstate_id = real_packet->diplstate_id;
15768 
15769     log_packet_detailed("  no old info");
15770     memset(real_packet, 0, sizeof(*real_packet));
15771 
15772     real_packet->diplstate_id = diplstate_id;
15773   }
15774 
15775   if (BV_ISSET(fields, 0)) {
15776     log_packet_detailed("  got field 'plr1'");
15777     if (!DIO_GET(uint8, &din, "plr1", &real_packet->plr1)) {
15778       RECEIVE_PACKET_FIELD_ERROR(plr1);
15779     }
15780   }
15781   if (BV_ISSET(fields, 1)) {
15782     log_packet_detailed("  got field 'plr2'");
15783     if (!DIO_GET(uint8, &din, "plr2", &real_packet->plr2)) {
15784       RECEIVE_PACKET_FIELD_ERROR(plr2);
15785     }
15786   }
15787   if (BV_ISSET(fields, 2)) {
15788     log_packet_detailed("  got field 'type'");
15789     {
15790       int readin;
15791 
15792       if (!DIO_GET(uint8, &din, "type", &readin)) {
15793         RECEIVE_PACKET_FIELD_ERROR(type);
15794       }
15795       real_packet->type = readin;
15796     }
15797   }
15798   if (BV_ISSET(fields, 3)) {
15799     log_packet_detailed("  got field 'turns_left'");
15800     if (!DIO_GET(uint16, &din, "turns_left", &real_packet->turns_left)) {
15801       RECEIVE_PACKET_FIELD_ERROR(turns_left);
15802     }
15803   }
15804   if (BV_ISSET(fields, 4)) {
15805     log_packet_detailed("  got field 'has_reason_to_cancel'");
15806     if (!DIO_GET(uint8, &din, "has_reason_to_cancel", &real_packet->has_reason_to_cancel)) {
15807       RECEIVE_PACKET_FIELD_ERROR(has_reason_to_cancel);
15808     }
15809   }
15810   if (BV_ISSET(fields, 5)) {
15811     log_packet_detailed("  got field 'contact_turns_left'");
15812     if (!DIO_GET(uint16, &din, "contact_turns_left", &real_packet->contact_turns_left)) {
15813       RECEIVE_PACKET_FIELD_ERROR(contact_turns_left);
15814     }
15815   }
15816 
15817   if (NULL == old) {
15818     old = fc_malloc(sizeof(*old));
15819     *old = *real_packet;
15820     genhash_insert(*hash, old, old);
15821   } else {
15822     *old = *real_packet;
15823   }
15824   RECEIVE_PACKET_END(real_packet);
15825 }
15826 
send_packet_player_diplstate_100(struct connection * pc,const struct packet_player_diplstate * packet)15827 static int send_packet_player_diplstate_100(struct connection *pc, const struct packet_player_diplstate *packet)
15828 {
15829   const struct packet_player_diplstate *real_packet = packet;
15830   packet_player_diplstate_100_fields fields;
15831   struct packet_player_diplstate *old;
15832   bool differ;
15833   struct genhash **hash = pc->phs.sent + PACKET_PLAYER_DIPLSTATE;
15834   int different = 0;
15835   SEND_PACKET_START(PACKET_PLAYER_DIPLSTATE);
15836 
15837   log_packet_detailed("packet_player_diplstate_100: sending info about (%d)",
15838     real_packet->diplstate_id);
15839 
15840   if (NULL == *hash) {
15841     *hash = genhash_new_full(hash_packet_player_diplstate_100, cmp_packet_player_diplstate_100,
15842                              NULL, NULL, NULL, free);
15843   }
15844   BV_CLR_ALL(fields);
15845 
15846   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
15847     old = fc_malloc(sizeof(*old));
15848     *old = *real_packet;
15849     genhash_insert(*hash, old, old);
15850     memset(old, 0, sizeof(*old));
15851     different = 1;      /* Force to send. */
15852   }
15853 
15854   differ = (old->plr1 != real_packet->plr1);
15855   if (differ) {
15856     different++;
15857     BV_SET(fields, 0);
15858   }
15859 
15860   differ = (old->plr2 != real_packet->plr2);
15861   if (differ) {
15862     different++;
15863     BV_SET(fields, 1);
15864   }
15865 
15866   differ = (old->type != real_packet->type);
15867   if (differ) {
15868     different++;
15869     BV_SET(fields, 2);
15870   }
15871 
15872   differ = (old->turns_left != real_packet->turns_left);
15873   if (differ) {
15874     different++;
15875     BV_SET(fields, 3);
15876   }
15877 
15878   differ = (old->has_reason_to_cancel != real_packet->has_reason_to_cancel);
15879   if (differ) {
15880     different++;
15881     BV_SET(fields, 4);
15882   }
15883 
15884   differ = (old->contact_turns_left != real_packet->contact_turns_left);
15885   if (differ) {
15886     different++;
15887     BV_SET(fields, 5);
15888   }
15889 
15890 
15891   DIO_BV_PUT(&dout, "fields", fields);
15892   DIO_PUT(uint32, &dout, "diplstate_id", real_packet->diplstate_id);
15893 
15894   if (BV_ISSET(fields, 0)) {
15895     log_packet_detailed("  field 'plr1' has changed");
15896     DIO_PUT(uint8, &dout, "plr1", real_packet->plr1);
15897   }
15898   if (BV_ISSET(fields, 1)) {
15899     log_packet_detailed("  field 'plr2' has changed");
15900     DIO_PUT(uint8, &dout, "plr2", real_packet->plr2);
15901   }
15902   if (BV_ISSET(fields, 2)) {
15903     log_packet_detailed("  field 'type' has changed");
15904     DIO_PUT(uint8, &dout, "type", real_packet->type);
15905   }
15906   if (BV_ISSET(fields, 3)) {
15907     log_packet_detailed("  field 'turns_left' has changed");
15908     DIO_PUT(uint16, &dout, "turns_left", real_packet->turns_left);
15909   }
15910   if (BV_ISSET(fields, 4)) {
15911     log_packet_detailed("  field 'has_reason_to_cancel' has changed");
15912     DIO_PUT(uint8, &dout, "has_reason_to_cancel", real_packet->has_reason_to_cancel);
15913   }
15914   if (BV_ISSET(fields, 5)) {
15915     log_packet_detailed("  field 'contact_turns_left' has changed");
15916     DIO_PUT(uint16, &dout, "contact_turns_left", real_packet->contact_turns_left);
15917   }
15918 
15919   *old = *real_packet;
15920   SEND_PACKET_END(PACKET_PLAYER_DIPLSTATE);
15921 }
15922 
send_packet_player_diplstate(struct connection * pc,const struct packet_player_diplstate * packet)15923 int send_packet_player_diplstate(struct connection *pc, const struct packet_player_diplstate *packet)
15924 {
15925   if (!pc->used) {
15926     log_error("WARNING: trying to send data to the closed connection %s",
15927               conn_description(pc));
15928     return -1;
15929   }
15930   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_DIPLSTATE].packet != NULL, -1,
15931                         "Handler for PACKET_PLAYER_DIPLSTATE not installed");
15932   return pc->phs.handlers->send[PACKET_PLAYER_DIPLSTATE].packet(pc, packet);
15933 }
15934 
15935 #define hash_packet_player_multiplier_100 hash_const
15936 
15937 #define cmp_packet_player_multiplier_100 cmp_const
15938 
15939 BV_DEFINE(packet_player_multiplier_100_fields, 2);
15940 
receive_packet_player_multiplier_100(struct connection * pc)15941 static struct packet_player_multiplier *receive_packet_player_multiplier_100(struct connection *pc)
15942 {
15943   packet_player_multiplier_100_fields fields;
15944   struct packet_player_multiplier *old;
15945   struct genhash **hash = pc->phs.received + PACKET_PLAYER_MULTIPLIER;
15946   RECEIVE_PACKET_START(packet_player_multiplier, real_packet);
15947 
15948   DIO_BV_GET(&din, fields);
15949 
15950   log_packet_detailed("packet_player_multiplier_100: got info about ()");
15951 
15952   if (NULL == *hash) {
15953     *hash = genhash_new_full(hash_packet_player_multiplier_100, cmp_packet_player_multiplier_100,
15954                              NULL, NULL, NULL, free);
15955   }
15956 
15957   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
15958     *real_packet = *old;
15959   } else {
15960     log_packet_detailed("  no old info");
15961     memset(real_packet, 0, sizeof(*real_packet));
15962   }
15963 
15964   if (BV_ISSET(fields, 0)) {
15965     log_packet_detailed("  got field 'count'");
15966     if (!DIO_GET(uint16, &din, "count", &real_packet->count)) {
15967       RECEIVE_PACKET_FIELD_ERROR(count);
15968     }
15969   }
15970   if (BV_ISSET(fields, 1)) {
15971     log_packet_detailed("  got field 'multipliers'");
15972 
15973     {
15974       int i;
15975 
15976       if (real_packet->count > MAX_NUM_MULTIPLIERS) {
15977         RECEIVE_PACKET_FIELD_ERROR(multipliers, ": truncation array");
15978       }
15979       for (i = 0; i < real_packet->count; i++) {
15980         if (!DIO_GET(sint32, &din, "multipliers", &real_packet->multipliers[i])) {
15981           RECEIVE_PACKET_FIELD_ERROR(multipliers);
15982         }
15983       }
15984     }
15985   }
15986 
15987   if (NULL == old) {
15988     old = fc_malloc(sizeof(*old));
15989     *old = *real_packet;
15990     genhash_insert(*hash, old, old);
15991   } else {
15992     *old = *real_packet;
15993   }
15994   RECEIVE_PACKET_END(real_packet);
15995 }
15996 
send_packet_player_multiplier_100(struct connection * pc,const struct packet_player_multiplier * packet)15997 static int send_packet_player_multiplier_100(struct connection *pc, const struct packet_player_multiplier *packet)
15998 {
15999   const struct packet_player_multiplier *real_packet = packet;
16000   packet_player_multiplier_100_fields fields;
16001   struct packet_player_multiplier *old;
16002   bool differ;
16003   struct genhash **hash = pc->phs.sent + PACKET_PLAYER_MULTIPLIER;
16004   int different = 0;
16005   SEND_PACKET_START(PACKET_PLAYER_MULTIPLIER);
16006 
16007   log_packet_detailed("packet_player_multiplier_100: sending info about ()");
16008 
16009   if (NULL == *hash) {
16010     *hash = genhash_new_full(hash_packet_player_multiplier_100, cmp_packet_player_multiplier_100,
16011                              NULL, NULL, NULL, free);
16012   }
16013   BV_CLR_ALL(fields);
16014 
16015   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
16016     old = fc_malloc(sizeof(*old));
16017     *old = *real_packet;
16018     genhash_insert(*hash, old, old);
16019     memset(old, 0, sizeof(*old));
16020     different = 1;      /* Force to send. */
16021   }
16022 
16023   differ = (old->count != real_packet->count);
16024   if (differ) {
16025     different++;
16026     BV_SET(fields, 0);
16027   }
16028 
16029 
16030     {
16031       differ = (old->count != real_packet->count);
16032       if (!differ) {
16033         int i;
16034 
16035         for (i = 0; i < real_packet->count; i++) {
16036           if (old->multipliers[i] != real_packet->multipliers[i]) {
16037             differ = TRUE;
16038             break;
16039           }
16040         }
16041       }
16042     }
16043   if (differ) {
16044     different++;
16045     BV_SET(fields, 1);
16046   }
16047 
16048 
16049   DIO_BV_PUT(&dout, "fields", fields);
16050 
16051   if (BV_ISSET(fields, 0)) {
16052     log_packet_detailed("  field 'count' has changed");
16053     DIO_PUT(uint16, &dout, "count", real_packet->count);
16054   }
16055   if (BV_ISSET(fields, 1)) {
16056     log_packet_detailed("  field 'multipliers' has changed");
16057 
16058     {
16059       int i;
16060 
16061       for (i = 0; i < real_packet->count; i++) {
16062         dio_put_sint32(&dout, real_packet->multipliers[i]);
16063       }
16064     }
16065   }
16066 
16067   *old = *real_packet;
16068   SEND_PACKET_END(PACKET_PLAYER_MULTIPLIER);
16069 }
16070 
send_packet_player_multiplier(struct connection * pc,const struct packet_player_multiplier * packet)16071 int send_packet_player_multiplier(struct connection *pc, const struct packet_player_multiplier *packet)
16072 {
16073   if (!pc->used) {
16074     log_error("WARNING: trying to send data to the closed connection %s",
16075               conn_description(pc));
16076     return -1;
16077   }
16078   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_MULTIPLIER].packet != NULL, -1,
16079                         "Handler for PACKET_PLAYER_MULTIPLIER not installed");
16080   return pc->phs.handlers->send[PACKET_PLAYER_MULTIPLIER].packet(pc, packet);
16081 }
16082 
hash_packet_research_info_100(const void * vkey)16083 static genhash_val_t hash_packet_research_info_100(const void *vkey)
16084 {
16085   const struct packet_research_info *key = (const struct packet_research_info *) vkey;
16086 
16087   return key->id;
16088 }
16089 
cmp_packet_research_info_100(const void * vkey1,const void * vkey2)16090 static bool cmp_packet_research_info_100(const void *vkey1, const void *vkey2)
16091 {
16092   const struct packet_research_info *key1 = (const struct packet_research_info *) vkey1;
16093   const struct packet_research_info *key2 = (const struct packet_research_info *) vkey2;
16094 
16095   return key1->id == key2->id;
16096 }
16097 
16098 BV_DEFINE(packet_research_info_100_fields, 8);
16099 
receive_packet_research_info_100(struct connection * pc)16100 static struct packet_research_info *receive_packet_research_info_100(struct connection *pc)
16101 {
16102   packet_research_info_100_fields fields;
16103   struct packet_research_info *old;
16104   struct genhash **hash = pc->phs.received + PACKET_RESEARCH_INFO;
16105   RECEIVE_PACKET_START(packet_research_info, real_packet);
16106 
16107   DIO_BV_GET(&din, fields);
16108   if (!DIO_GET(uint8, &din, "id", &real_packet->id)) {
16109     RECEIVE_PACKET_FIELD_ERROR(id);
16110   }
16111 
16112   log_packet_detailed("packet_research_info_100: got info about (%d)",
16113     real_packet->id);
16114 
16115   if (NULL == *hash) {
16116     *hash = genhash_new_full(hash_packet_research_info_100, cmp_packet_research_info_100,
16117                              NULL, NULL, NULL, free);
16118   }
16119 
16120   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
16121     *real_packet = *old;
16122   } else {
16123     int id = real_packet->id;
16124 
16125     log_packet_detailed("  no old info");
16126     memset(real_packet, 0, sizeof(*real_packet));
16127 
16128     real_packet->id = id;
16129   }
16130 
16131   if (BV_ISSET(fields, 0)) {
16132     log_packet_detailed("  got field 'techs_researched'");
16133     if (!DIO_GET(uint32, &din, "techs_researched", &real_packet->techs_researched)) {
16134       RECEIVE_PACKET_FIELD_ERROR(techs_researched);
16135     }
16136   }
16137   if (BV_ISSET(fields, 1)) {
16138     log_packet_detailed("  got field 'future_tech'");
16139     if (!DIO_GET(uint16, &din, "future_tech", &real_packet->future_tech)) {
16140       RECEIVE_PACKET_FIELD_ERROR(future_tech);
16141     }
16142   }
16143   if (BV_ISSET(fields, 2)) {
16144     log_packet_detailed("  got field 'researching'");
16145     if (!DIO_GET(uint8, &din, "researching", &real_packet->researching)) {
16146       RECEIVE_PACKET_FIELD_ERROR(researching);
16147     }
16148   }
16149   if (BV_ISSET(fields, 3)) {
16150     log_packet_detailed("  got field 'researching_cost'");
16151     if (!DIO_GET(uint32, &din, "researching_cost", &real_packet->researching_cost)) {
16152       RECEIVE_PACKET_FIELD_ERROR(researching_cost);
16153     }
16154   }
16155   if (BV_ISSET(fields, 4)) {
16156     log_packet_detailed("  got field 'bulbs_researched'");
16157     if (!DIO_GET(uint32, &din, "bulbs_researched", &real_packet->bulbs_researched)) {
16158       RECEIVE_PACKET_FIELD_ERROR(bulbs_researched);
16159     }
16160   }
16161   if (BV_ISSET(fields, 5)) {
16162     log_packet_detailed("  got field 'tech_goal'");
16163     if (!DIO_GET(uint8, &din, "tech_goal", &real_packet->tech_goal)) {
16164       RECEIVE_PACKET_FIELD_ERROR(tech_goal);
16165     }
16166   }
16167   if (BV_ISSET(fields, 6)) {
16168     log_packet_detailed("  got field 'total_bulbs_prod'");
16169     if (!DIO_GET(sint32, &din, "total_bulbs_prod", &real_packet->total_bulbs_prod)) {
16170       RECEIVE_PACKET_FIELD_ERROR(total_bulbs_prod);
16171     }
16172   }
16173   if (BV_ISSET(fields, 7)) {
16174     log_packet_detailed("  got field 'inventions'");
16175     if (!DIO_GET(string, &din, "inventions", real_packet->inventions, sizeof(real_packet->inventions))) {
16176       RECEIVE_PACKET_FIELD_ERROR(inventions);
16177     }
16178   }
16179 
16180   if (NULL == old) {
16181     old = fc_malloc(sizeof(*old));
16182     *old = *real_packet;
16183     genhash_insert(*hash, old, old);
16184   } else {
16185     *old = *real_packet;
16186   }
16187   RECEIVE_PACKET_END(real_packet);
16188 }
16189 
send_packet_research_info_100(struct connection * pc,const struct packet_research_info * packet)16190 static int send_packet_research_info_100(struct connection *pc, const struct packet_research_info *packet)
16191 {
16192   const struct packet_research_info *real_packet = packet;
16193   packet_research_info_100_fields fields;
16194   struct packet_research_info *old;
16195   bool differ;
16196   struct genhash **hash = pc->phs.sent + PACKET_RESEARCH_INFO;
16197   int different = 0;
16198   SEND_PACKET_START(PACKET_RESEARCH_INFO);
16199 
16200   log_packet_detailed("packet_research_info_100: sending info about (%d)",
16201     real_packet->id);
16202 
16203   if (NULL == *hash) {
16204     *hash = genhash_new_full(hash_packet_research_info_100, cmp_packet_research_info_100,
16205                              NULL, NULL, NULL, free);
16206   }
16207   BV_CLR_ALL(fields);
16208 
16209   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
16210     old = fc_malloc(sizeof(*old));
16211     *old = *real_packet;
16212     genhash_insert(*hash, old, old);
16213     memset(old, 0, sizeof(*old));
16214     different = 1;      /* Force to send. */
16215   }
16216 
16217   differ = (old->techs_researched != real_packet->techs_researched);
16218   if (differ) {
16219     different++;
16220     BV_SET(fields, 0);
16221   }
16222 
16223   differ = (old->future_tech != real_packet->future_tech);
16224   if (differ) {
16225     different++;
16226     BV_SET(fields, 1);
16227   }
16228 
16229   differ = (old->researching != real_packet->researching);
16230   if (differ) {
16231     different++;
16232     BV_SET(fields, 2);
16233   }
16234 
16235   differ = (old->researching_cost != real_packet->researching_cost);
16236   if (differ) {
16237     different++;
16238     BV_SET(fields, 3);
16239   }
16240 
16241   differ = (old->bulbs_researched != real_packet->bulbs_researched);
16242   if (differ) {
16243     different++;
16244     BV_SET(fields, 4);
16245   }
16246 
16247   differ = (old->tech_goal != real_packet->tech_goal);
16248   if (differ) {
16249     different++;
16250     BV_SET(fields, 5);
16251   }
16252 
16253   differ = (old->total_bulbs_prod != real_packet->total_bulbs_prod);
16254   if (differ) {
16255     different++;
16256     BV_SET(fields, 6);
16257   }
16258 
16259   differ = (strcmp(old->inventions, real_packet->inventions) != 0);
16260   if (differ) {
16261     different++;
16262     BV_SET(fields, 7);
16263   }
16264 
16265 
16266   if (different == 0) {
16267     log_packet_detailed("  no change -> discard");
16268     return 0;
16269   }
16270 
16271   DIO_BV_PUT(&dout, "fields", fields);
16272   DIO_PUT(uint8, &dout, "id", real_packet->id);
16273 
16274   if (BV_ISSET(fields, 0)) {
16275     log_packet_detailed("  field 'techs_researched' has changed");
16276     DIO_PUT(uint32, &dout, "techs_researched", real_packet->techs_researched);
16277   }
16278   if (BV_ISSET(fields, 1)) {
16279     log_packet_detailed("  field 'future_tech' has changed");
16280     DIO_PUT(uint16, &dout, "future_tech", real_packet->future_tech);
16281   }
16282   if (BV_ISSET(fields, 2)) {
16283     log_packet_detailed("  field 'researching' has changed");
16284     DIO_PUT(uint8, &dout, "researching", real_packet->researching);
16285   }
16286   if (BV_ISSET(fields, 3)) {
16287     log_packet_detailed("  field 'researching_cost' has changed");
16288     DIO_PUT(uint32, &dout, "researching_cost", real_packet->researching_cost);
16289   }
16290   if (BV_ISSET(fields, 4)) {
16291     log_packet_detailed("  field 'bulbs_researched' has changed");
16292     DIO_PUT(uint32, &dout, "bulbs_researched", real_packet->bulbs_researched);
16293   }
16294   if (BV_ISSET(fields, 5)) {
16295     log_packet_detailed("  field 'tech_goal' has changed");
16296     DIO_PUT(uint8, &dout, "tech_goal", real_packet->tech_goal);
16297   }
16298   if (BV_ISSET(fields, 6)) {
16299     log_packet_detailed("  field 'total_bulbs_prod' has changed");
16300     DIO_PUT(sint32, &dout, "total_bulbs_prod", real_packet->total_bulbs_prod);
16301   }
16302   if (BV_ISSET(fields, 7)) {
16303     log_packet_detailed("  field 'inventions' has changed");
16304     DIO_PUT(string, &dout, "inventions", real_packet->inventions);
16305   }
16306 
16307   *old = *real_packet;
16308   SEND_PACKET_END(PACKET_RESEARCH_INFO);
16309 }
16310 
send_packet_research_info(struct connection * pc,const struct packet_research_info * packet)16311 int send_packet_research_info(struct connection *pc, const struct packet_research_info *packet)
16312 {
16313   if (!pc->used) {
16314     log_error("WARNING: trying to send data to the closed connection %s",
16315               conn_description(pc));
16316     return -1;
16317   }
16318   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RESEARCH_INFO].packet != NULL, -1,
16319                         "Handler for PACKET_RESEARCH_INFO not installed");
16320   return pc->phs.handlers->send[PACKET_RESEARCH_INFO].packet(pc, packet);
16321 }
16322 
lsend_packet_research_info(struct conn_list * dest,const struct packet_research_info * packet)16323 void lsend_packet_research_info(struct conn_list *dest, const struct packet_research_info *packet)
16324 {
16325   conn_list_iterate(dest, pconn) {
16326     send_packet_research_info(pconn, packet);
16327   } conn_list_iterate_end;
16328 }
16329 
16330 #define hash_packet_player_research_100 hash_const
16331 
16332 #define cmp_packet_player_research_100 cmp_const
16333 
16334 BV_DEFINE(packet_player_research_100_fields, 1);
16335 
receive_packet_player_research_100(struct connection * pc)16336 static struct packet_player_research *receive_packet_player_research_100(struct connection *pc)
16337 {
16338   packet_player_research_100_fields fields;
16339   struct packet_player_research *old;
16340   struct genhash **hash = pc->phs.received + PACKET_PLAYER_RESEARCH;
16341   RECEIVE_PACKET_START(packet_player_research, real_packet);
16342 
16343   DIO_BV_GET(&din, fields);
16344 
16345   log_packet_detailed("packet_player_research_100: got info about ()");
16346 
16347   if (NULL == *hash) {
16348     *hash = genhash_new_full(hash_packet_player_research_100, cmp_packet_player_research_100,
16349                              NULL, NULL, NULL, free);
16350   }
16351 
16352   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
16353     *real_packet = *old;
16354   } else {
16355     log_packet_detailed("  no old info");
16356     memset(real_packet, 0, sizeof(*real_packet));
16357   }
16358 
16359   if (BV_ISSET(fields, 0)) {
16360     log_packet_detailed("  got field 'tech'");
16361     if (!DIO_GET(uint8, &din, "tech", &real_packet->tech)) {
16362       RECEIVE_PACKET_FIELD_ERROR(tech);
16363     }
16364   }
16365 
16366   if (NULL == old) {
16367     old = fc_malloc(sizeof(*old));
16368     *old = *real_packet;
16369     genhash_insert(*hash, old, old);
16370   } else {
16371     *old = *real_packet;
16372   }
16373   RECEIVE_PACKET_END(real_packet);
16374 }
16375 
send_packet_player_research_100(struct connection * pc,const struct packet_player_research * packet)16376 static int send_packet_player_research_100(struct connection *pc, const struct packet_player_research *packet)
16377 {
16378   const struct packet_player_research *real_packet = packet;
16379   packet_player_research_100_fields fields;
16380   struct packet_player_research *old;
16381   bool differ;
16382   struct genhash **hash = pc->phs.sent + PACKET_PLAYER_RESEARCH;
16383   int different = 0;
16384   SEND_PACKET_START(PACKET_PLAYER_RESEARCH);
16385 
16386   log_packet_detailed("packet_player_research_100: sending info about ()");
16387 
16388   if (NULL == *hash) {
16389     *hash = genhash_new_full(hash_packet_player_research_100, cmp_packet_player_research_100,
16390                              NULL, NULL, NULL, free);
16391   }
16392   BV_CLR_ALL(fields);
16393 
16394   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
16395     old = fc_malloc(sizeof(*old));
16396     *old = *real_packet;
16397     genhash_insert(*hash, old, old);
16398     memset(old, 0, sizeof(*old));
16399     different = 1;      /* Force to send. */
16400   }
16401 
16402   differ = (old->tech != real_packet->tech);
16403   if (differ) {
16404     different++;
16405     BV_SET(fields, 0);
16406   }
16407 
16408 
16409   DIO_BV_PUT(&dout, "fields", fields);
16410 
16411   if (BV_ISSET(fields, 0)) {
16412     log_packet_detailed("  field 'tech' has changed");
16413     DIO_PUT(uint8, &dout, "tech", real_packet->tech);
16414   }
16415 
16416   *old = *real_packet;
16417   SEND_PACKET_END(PACKET_PLAYER_RESEARCH);
16418 }
16419 
send_packet_player_research(struct connection * pc,const struct packet_player_research * packet)16420 int send_packet_player_research(struct connection *pc, const struct packet_player_research *packet)
16421 {
16422   if (!pc->used) {
16423     log_error("WARNING: trying to send data to the closed connection %s",
16424               conn_description(pc));
16425     return -1;
16426   }
16427   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_RESEARCH].packet != NULL, -1,
16428                         "Handler for PACKET_PLAYER_RESEARCH not installed");
16429   return pc->phs.handlers->send[PACKET_PLAYER_RESEARCH].packet(pc, packet);
16430 }
16431 
dsend_packet_player_research(struct connection * pc,int tech)16432 int dsend_packet_player_research(struct connection *pc, int tech)
16433 {
16434   struct packet_player_research packet, *real_packet = &packet;
16435 
16436   real_packet->tech = tech;
16437 
16438   return send_packet_player_research(pc, real_packet);
16439 }
16440 
16441 #define hash_packet_player_tech_goal_100 hash_const
16442 
16443 #define cmp_packet_player_tech_goal_100 cmp_const
16444 
16445 BV_DEFINE(packet_player_tech_goal_100_fields, 1);
16446 
receive_packet_player_tech_goal_100(struct connection * pc)16447 static struct packet_player_tech_goal *receive_packet_player_tech_goal_100(struct connection *pc)
16448 {
16449   packet_player_tech_goal_100_fields fields;
16450   struct packet_player_tech_goal *old;
16451   struct genhash **hash = pc->phs.received + PACKET_PLAYER_TECH_GOAL;
16452   RECEIVE_PACKET_START(packet_player_tech_goal, real_packet);
16453 
16454   DIO_BV_GET(&din, fields);
16455 
16456   log_packet_detailed("packet_player_tech_goal_100: got info about ()");
16457 
16458   if (NULL == *hash) {
16459     *hash = genhash_new_full(hash_packet_player_tech_goal_100, cmp_packet_player_tech_goal_100,
16460                              NULL, NULL, NULL, free);
16461   }
16462 
16463   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
16464     *real_packet = *old;
16465   } else {
16466     log_packet_detailed("  no old info");
16467     memset(real_packet, 0, sizeof(*real_packet));
16468   }
16469 
16470   if (BV_ISSET(fields, 0)) {
16471     log_packet_detailed("  got field 'tech'");
16472     if (!DIO_GET(uint8, &din, "tech", &real_packet->tech)) {
16473       RECEIVE_PACKET_FIELD_ERROR(tech);
16474     }
16475   }
16476 
16477   if (NULL == old) {
16478     old = fc_malloc(sizeof(*old));
16479     *old = *real_packet;
16480     genhash_insert(*hash, old, old);
16481   } else {
16482     *old = *real_packet;
16483   }
16484   RECEIVE_PACKET_END(real_packet);
16485 }
16486 
send_packet_player_tech_goal_100(struct connection * pc,const struct packet_player_tech_goal * packet)16487 static int send_packet_player_tech_goal_100(struct connection *pc, const struct packet_player_tech_goal *packet)
16488 {
16489   const struct packet_player_tech_goal *real_packet = packet;
16490   packet_player_tech_goal_100_fields fields;
16491   struct packet_player_tech_goal *old;
16492   bool differ;
16493   struct genhash **hash = pc->phs.sent + PACKET_PLAYER_TECH_GOAL;
16494   int different = 0;
16495   SEND_PACKET_START(PACKET_PLAYER_TECH_GOAL);
16496 
16497   log_packet_detailed("packet_player_tech_goal_100: sending info about ()");
16498 
16499   if (NULL == *hash) {
16500     *hash = genhash_new_full(hash_packet_player_tech_goal_100, cmp_packet_player_tech_goal_100,
16501                              NULL, NULL, NULL, free);
16502   }
16503   BV_CLR_ALL(fields);
16504 
16505   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
16506     old = fc_malloc(sizeof(*old));
16507     *old = *real_packet;
16508     genhash_insert(*hash, old, old);
16509     memset(old, 0, sizeof(*old));
16510     different = 1;      /* Force to send. */
16511   }
16512 
16513   differ = (old->tech != real_packet->tech);
16514   if (differ) {
16515     different++;
16516     BV_SET(fields, 0);
16517   }
16518 
16519 
16520   DIO_BV_PUT(&dout, "fields", fields);
16521 
16522   if (BV_ISSET(fields, 0)) {
16523     log_packet_detailed("  field 'tech' has changed");
16524     DIO_PUT(uint8, &dout, "tech", real_packet->tech);
16525   }
16526 
16527   *old = *real_packet;
16528   SEND_PACKET_END(PACKET_PLAYER_TECH_GOAL);
16529 }
16530 
send_packet_player_tech_goal(struct connection * pc,const struct packet_player_tech_goal * packet)16531 int send_packet_player_tech_goal(struct connection *pc, const struct packet_player_tech_goal *packet)
16532 {
16533   if (!pc->used) {
16534     log_error("WARNING: trying to send data to the closed connection %s",
16535               conn_description(pc));
16536     return -1;
16537   }
16538   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_TECH_GOAL].packet != NULL, -1,
16539                         "Handler for PACKET_PLAYER_TECH_GOAL not installed");
16540   return pc->phs.handlers->send[PACKET_PLAYER_TECH_GOAL].packet(pc, packet);
16541 }
16542 
dsend_packet_player_tech_goal(struct connection * pc,int tech)16543 int dsend_packet_player_tech_goal(struct connection *pc, int tech)
16544 {
16545   struct packet_player_tech_goal packet, *real_packet = &packet;
16546 
16547   real_packet->tech = tech;
16548 
16549   return send_packet_player_tech_goal(pc, real_packet);
16550 }
16551 
16552 #define hash_packet_unit_remove_100 hash_const
16553 
16554 #define cmp_packet_unit_remove_100 cmp_const
16555 
16556 BV_DEFINE(packet_unit_remove_100_fields, 1);
16557 
receive_packet_unit_remove_100(struct connection * pc)16558 static struct packet_unit_remove *receive_packet_unit_remove_100(struct connection *pc)
16559 {
16560   packet_unit_remove_100_fields fields;
16561   struct packet_unit_remove *old;
16562   struct genhash **hash = pc->phs.received + PACKET_UNIT_REMOVE;
16563   RECEIVE_PACKET_START(packet_unit_remove, real_packet);
16564 
16565   DIO_BV_GET(&din, fields);
16566 
16567   log_packet_detailed("packet_unit_remove_100: got info about ()");
16568 
16569   if (NULL == *hash) {
16570     *hash = genhash_new_full(hash_packet_unit_remove_100, cmp_packet_unit_remove_100,
16571                              NULL, NULL, NULL, free);
16572   }
16573 
16574   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
16575     *real_packet = *old;
16576   } else {
16577     log_packet_detailed("  no old info");
16578     memset(real_packet, 0, sizeof(*real_packet));
16579   }
16580 
16581   if (BV_ISSET(fields, 0)) {
16582     log_packet_detailed("  got field 'unit_id'");
16583     if (!DIO_GET(uint16, &din, "unit_id", &real_packet->unit_id)) {
16584       RECEIVE_PACKET_FIELD_ERROR(unit_id);
16585     }
16586   }
16587 
16588   if (NULL == old) {
16589     old = fc_malloc(sizeof(*old));
16590     *old = *real_packet;
16591     genhash_insert(*hash, old, old);
16592   } else {
16593     *old = *real_packet;
16594   }
16595 
16596   hash = pc->phs.received + PACKET_UNIT_INFO;
16597   if (NULL != *hash) {
16598     genhash_remove(*hash, real_packet);
16599   }
16600 
16601   hash = pc->phs.received + PACKET_UNIT_SHORT_INFO;
16602   if (NULL != *hash) {
16603     genhash_remove(*hash, real_packet);
16604   }
16605   RECEIVE_PACKET_END(real_packet);
16606 }
16607 
send_packet_unit_remove_100(struct connection * pc,const struct packet_unit_remove * packet)16608 static int send_packet_unit_remove_100(struct connection *pc, const struct packet_unit_remove *packet)
16609 {
16610   const struct packet_unit_remove *real_packet = packet;
16611   packet_unit_remove_100_fields fields;
16612   struct packet_unit_remove *old;
16613   bool differ;
16614   struct genhash **hash = pc->phs.sent + PACKET_UNIT_REMOVE;
16615   int different = 0;
16616   SEND_PACKET_START(PACKET_UNIT_REMOVE);
16617 
16618   log_packet_detailed("packet_unit_remove_100: sending info about ()");
16619 
16620   if (NULL == *hash) {
16621     *hash = genhash_new_full(hash_packet_unit_remove_100, cmp_packet_unit_remove_100,
16622                              NULL, NULL, NULL, free);
16623   }
16624   BV_CLR_ALL(fields);
16625 
16626   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
16627     old = fc_malloc(sizeof(*old));
16628     *old = *real_packet;
16629     genhash_insert(*hash, old, old);
16630     memset(old, 0, sizeof(*old));
16631     different = 1;      /* Force to send. */
16632   }
16633 
16634   differ = (old->unit_id != real_packet->unit_id);
16635   if (differ) {
16636     different++;
16637     BV_SET(fields, 0);
16638   }
16639 
16640 
16641   DIO_BV_PUT(&dout, "fields", fields);
16642 
16643   if (BV_ISSET(fields, 0)) {
16644     log_packet_detailed("  field 'unit_id' has changed");
16645     DIO_PUT(uint16, &dout, "unit_id", real_packet->unit_id);
16646   }
16647 
16648   *old = *real_packet;
16649 
16650   hash = pc->phs.sent + PACKET_UNIT_INFO;
16651   if (NULL != *hash) {
16652     genhash_remove(*hash, real_packet);
16653   }
16654 
16655   hash = pc->phs.sent + PACKET_UNIT_SHORT_INFO;
16656   if (NULL != *hash) {
16657     genhash_remove(*hash, real_packet);
16658   }
16659   SEND_PACKET_END(PACKET_UNIT_REMOVE);
16660 }
16661 
send_packet_unit_remove(struct connection * pc,const struct packet_unit_remove * packet)16662 int send_packet_unit_remove(struct connection *pc, const struct packet_unit_remove *packet)
16663 {
16664   if (!pc->used) {
16665     log_error("WARNING: trying to send data to the closed connection %s",
16666               conn_description(pc));
16667     return -1;
16668   }
16669   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_REMOVE].packet != NULL, -1,
16670                         "Handler for PACKET_UNIT_REMOVE not installed");
16671   return pc->phs.handlers->send[PACKET_UNIT_REMOVE].packet(pc, packet);
16672 }
16673 
lsend_packet_unit_remove(struct conn_list * dest,const struct packet_unit_remove * packet)16674 void lsend_packet_unit_remove(struct conn_list *dest, const struct packet_unit_remove *packet)
16675 {
16676   conn_list_iterate(dest, pconn) {
16677     send_packet_unit_remove(pconn, packet);
16678   } conn_list_iterate_end;
16679 }
16680 
dsend_packet_unit_remove(struct connection * pc,int unit_id)16681 int dsend_packet_unit_remove(struct connection *pc, int unit_id)
16682 {
16683   struct packet_unit_remove packet, *real_packet = &packet;
16684 
16685   real_packet->unit_id = unit_id;
16686 
16687   return send_packet_unit_remove(pc, real_packet);
16688 }
16689 
dlsend_packet_unit_remove(struct conn_list * dest,int unit_id)16690 void dlsend_packet_unit_remove(struct conn_list *dest, int unit_id)
16691 {
16692   struct packet_unit_remove packet, *real_packet = &packet;
16693 
16694   real_packet->unit_id = unit_id;
16695 
16696   lsend_packet_unit_remove(dest, real_packet);
16697 }
16698 
hash_packet_unit_info_100(const void * vkey)16699 static genhash_val_t hash_packet_unit_info_100(const void *vkey)
16700 {
16701   const struct packet_unit_info *key = (const struct packet_unit_info *) vkey;
16702 
16703   return key->id;
16704 }
16705 
cmp_packet_unit_info_100(const void * vkey1,const void * vkey2)16706 static bool cmp_packet_unit_info_100(const void *vkey1, const void *vkey2)
16707 {
16708   const struct packet_unit_info *key1 = (const struct packet_unit_info *) vkey1;
16709   const struct packet_unit_info *key2 = (const struct packet_unit_info *) vkey2;
16710 
16711   return key1->id == key2->id;
16712 }
16713 
16714 BV_DEFINE(packet_unit_info_100_fields, 36);
16715 
receive_packet_unit_info_100(struct connection * pc)16716 static struct packet_unit_info *receive_packet_unit_info_100(struct connection *pc)
16717 {
16718   packet_unit_info_100_fields fields;
16719   struct packet_unit_info *old;
16720   struct genhash **hash = pc->phs.received + PACKET_UNIT_INFO;
16721   RECEIVE_PACKET_START(packet_unit_info, real_packet);
16722 
16723   DIO_BV_GET(&din, fields);
16724   if (!DIO_GET(uint16, &din, "id", &real_packet->id)) {
16725     RECEIVE_PACKET_FIELD_ERROR(id);
16726   }
16727 
16728   log_packet_detailed("packet_unit_info_100: got info about (%d)",
16729     real_packet->id);
16730 
16731   if (NULL == *hash) {
16732     *hash = genhash_new_full(hash_packet_unit_info_100, cmp_packet_unit_info_100,
16733                              NULL, NULL, NULL, free);
16734   }
16735 
16736   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
16737     *real_packet = *old;
16738   } else {
16739     int id = real_packet->id;
16740 
16741     log_packet_detailed("  no old info");
16742     memset(real_packet, 0, sizeof(*real_packet));
16743 
16744     real_packet->id = id;
16745   }
16746 
16747   if (BV_ISSET(fields, 0)) {
16748     log_packet_detailed("  got field 'owner'");
16749     if (!DIO_GET(uint8, &din, "owner", &real_packet->owner)) {
16750       RECEIVE_PACKET_FIELD_ERROR(owner);
16751     }
16752   }
16753   if (BV_ISSET(fields, 1)) {
16754     log_packet_detailed("  got field 'nationality'");
16755     if (!DIO_GET(uint8, &din, "nationality", &real_packet->nationality)) {
16756       RECEIVE_PACKET_FIELD_ERROR(nationality);
16757     }
16758   }
16759   if (BV_ISSET(fields, 2)) {
16760     log_packet_detailed("  got field 'tile'");
16761     if (!DIO_GET(sint32, &din, "tile", &real_packet->tile)) {
16762       RECEIVE_PACKET_FIELD_ERROR(tile);
16763     }
16764   }
16765   if (BV_ISSET(fields, 3)) {
16766     log_packet_detailed("  got field 'facing'");
16767     {
16768       int readin;
16769 
16770       if (!DIO_GET(sint8, &din, "facing", &readin)) {
16771         RECEIVE_PACKET_FIELD_ERROR(facing);
16772       }
16773       real_packet->facing = readin;
16774     }
16775   }
16776   if (BV_ISSET(fields, 4)) {
16777     log_packet_detailed("  got field 'homecity'");
16778     if (!DIO_GET(uint16, &din, "homecity", &real_packet->homecity)) {
16779       RECEIVE_PACKET_FIELD_ERROR(homecity);
16780     }
16781   }
16782   if (BV_ISSET(fields, 5)) {
16783     log_packet_detailed("  got field 'upkeep'");
16784 
16785     {
16786       int i;
16787 
16788       for (i = 0; i < O_LAST; i++) {
16789         if (!DIO_GET(uint8, &din, "upkeep", &real_packet->upkeep[i])) {
16790           RECEIVE_PACKET_FIELD_ERROR(upkeep);
16791         }
16792       }
16793     }
16794   }
16795   if (BV_ISSET(fields, 6)) {
16796     log_packet_detailed("  got field 'veteran'");
16797     if (!DIO_GET(uint8, &din, "veteran", &real_packet->veteran)) {
16798       RECEIVE_PACKET_FIELD_ERROR(veteran);
16799     }
16800   }
16801   real_packet->ai = BV_ISSET(fields, 7);
16802   real_packet->paradropped = BV_ISSET(fields, 8);
16803   real_packet->occupied = BV_ISSET(fields, 9);
16804   real_packet->transported = BV_ISSET(fields, 10);
16805   real_packet->done_moving = BV_ISSET(fields, 11);
16806   if (BV_ISSET(fields, 12)) {
16807     log_packet_detailed("  got field 'type'");
16808     {
16809       int readin;
16810 
16811       if (!DIO_GET(uint8, &din, "type", &readin)) {
16812         RECEIVE_PACKET_FIELD_ERROR(type);
16813       }
16814       real_packet->type = readin;
16815     }
16816   }
16817   if (BV_ISSET(fields, 13)) {
16818     log_packet_detailed("  got field 'transported_by'");
16819     if (!DIO_GET(uint16, &din, "transported_by", &real_packet->transported_by)) {
16820       RECEIVE_PACKET_FIELD_ERROR(transported_by);
16821     }
16822   }
16823   if (BV_ISSET(fields, 14)) {
16824     log_packet_detailed("  got field 'movesleft'");
16825     if (!DIO_GET(uint16, &din, "movesleft", &real_packet->movesleft)) {
16826       RECEIVE_PACKET_FIELD_ERROR(movesleft);
16827     }
16828   }
16829   if (BV_ISSET(fields, 15)) {
16830     log_packet_detailed("  got field 'hp'");
16831     if (!DIO_GET(uint8, &din, "hp", &real_packet->hp)) {
16832       RECEIVE_PACKET_FIELD_ERROR(hp);
16833     }
16834   }
16835   if (BV_ISSET(fields, 16)) {
16836     log_packet_detailed("  got field 'fuel'");
16837     if (!DIO_GET(uint8, &din, "fuel", &real_packet->fuel)) {
16838       RECEIVE_PACKET_FIELD_ERROR(fuel);
16839     }
16840   }
16841   if (BV_ISSET(fields, 17)) {
16842     log_packet_detailed("  got field 'activity_count'");
16843     if (!DIO_GET(uint16, &din, "activity_count", &real_packet->activity_count)) {
16844       RECEIVE_PACKET_FIELD_ERROR(activity_count);
16845     }
16846   }
16847   if (BV_ISSET(fields, 18)) {
16848     log_packet_detailed("  got field 'changed_from_count'");
16849     if (!DIO_GET(uint16, &din, "changed_from_count", &real_packet->changed_from_count)) {
16850       RECEIVE_PACKET_FIELD_ERROR(changed_from_count);
16851     }
16852   }
16853   if (BV_ISSET(fields, 19)) {
16854     log_packet_detailed("  got field 'goto_tile'");
16855     if (!DIO_GET(sint32, &din, "goto_tile", &real_packet->goto_tile)) {
16856       RECEIVE_PACKET_FIELD_ERROR(goto_tile);
16857     }
16858   }
16859   if (BV_ISSET(fields, 20)) {
16860     log_packet_detailed("  got field 'activity'");
16861     {
16862       int readin;
16863 
16864       if (!DIO_GET(uint8, &din, "activity", &readin)) {
16865         RECEIVE_PACKET_FIELD_ERROR(activity);
16866       }
16867       real_packet->activity = readin;
16868     }
16869   }
16870   if (BV_ISSET(fields, 21)) {
16871     log_packet_detailed("  got field 'activity_tgt'");
16872     if (!DIO_GET(sint8, &din, "activity_tgt", &real_packet->activity_tgt)) {
16873       RECEIVE_PACKET_FIELD_ERROR(activity_tgt);
16874     }
16875   }
16876   if (BV_ISSET(fields, 22)) {
16877     log_packet_detailed("  got field 'changed_from'");
16878     {
16879       int readin;
16880 
16881       if (!DIO_GET(uint8, &din, "changed_from", &readin)) {
16882         RECEIVE_PACKET_FIELD_ERROR(changed_from);
16883       }
16884       real_packet->changed_from = readin;
16885     }
16886   }
16887   if (BV_ISSET(fields, 23)) {
16888     log_packet_detailed("  got field 'changed_from_tgt'");
16889     if (!DIO_GET(sint8, &din, "changed_from_tgt", &real_packet->changed_from_tgt)) {
16890       RECEIVE_PACKET_FIELD_ERROR(changed_from_tgt);
16891     }
16892   }
16893   if (BV_ISSET(fields, 24)) {
16894     log_packet_detailed("  got field 'battlegroup'");
16895     if (!DIO_GET(sint8, &din, "battlegroup", &real_packet->battlegroup)) {
16896       RECEIVE_PACKET_FIELD_ERROR(battlegroup);
16897     }
16898   }
16899   real_packet->has_orders = BV_ISSET(fields, 25);
16900   if (BV_ISSET(fields, 26)) {
16901     log_packet_detailed("  got field 'orders_length'");
16902     if (!DIO_GET(uint16, &din, "orders_length", &real_packet->orders_length)) {
16903       RECEIVE_PACKET_FIELD_ERROR(orders_length);
16904     }
16905   }
16906   if (BV_ISSET(fields, 27)) {
16907     log_packet_detailed("  got field 'orders_index'");
16908     if (!DIO_GET(uint16, &din, "orders_index", &real_packet->orders_index)) {
16909       RECEIVE_PACKET_FIELD_ERROR(orders_index);
16910     }
16911   }
16912   real_packet->orders_repeat = BV_ISSET(fields, 28);
16913   real_packet->orders_vigilant = BV_ISSET(fields, 29);
16914   if (BV_ISSET(fields, 30)) {
16915     log_packet_detailed("  got field 'orders'");
16916 
16917     {
16918       int i;
16919 
16920       if (real_packet->orders_length > MAX_LEN_ROUTE) {
16921         RECEIVE_PACKET_FIELD_ERROR(orders, ": truncation array");
16922       }
16923       for (i = 0; i < real_packet->orders_length; i++) {
16924         {
16925           int readin;
16926 
16927           if (!DIO_GET(uint8, &din, "orders", &readin)) {
16928             RECEIVE_PACKET_FIELD_ERROR(orders);
16929           }
16930           real_packet->orders[i] = readin;
16931         }
16932       }
16933     }
16934   }
16935   if (BV_ISSET(fields, 31)) {
16936     log_packet_detailed("  got field 'orders_dirs'");
16937 
16938     {
16939       int i;
16940 
16941       if (real_packet->orders_length > MAX_LEN_ROUTE) {
16942         RECEIVE_PACKET_FIELD_ERROR(orders_dirs, ": truncation array");
16943       }
16944       for (i = 0; i < real_packet->orders_length; i++) {
16945         {
16946           int readin;
16947 
16948           if (!DIO_GET(sint8, &din, "orders_dirs", &readin)) {
16949             RECEIVE_PACKET_FIELD_ERROR(orders_dirs);
16950           }
16951           real_packet->orders_dirs[i] = readin;
16952         }
16953       }
16954     }
16955   }
16956   if (BV_ISSET(fields, 32)) {
16957     log_packet_detailed("  got field 'orders_activities'");
16958 
16959     {
16960       int i;
16961 
16962       if (real_packet->orders_length > MAX_LEN_ROUTE) {
16963         RECEIVE_PACKET_FIELD_ERROR(orders_activities, ": truncation array");
16964       }
16965       for (i = 0; i < real_packet->orders_length; i++) {
16966         {
16967           int readin;
16968 
16969           if (!DIO_GET(uint8, &din, "orders_activities", &readin)) {
16970             RECEIVE_PACKET_FIELD_ERROR(orders_activities);
16971           }
16972           real_packet->orders_activities[i] = readin;
16973         }
16974       }
16975     }
16976   }
16977   if (BV_ISSET(fields, 33)) {
16978     log_packet_detailed("  got field 'orders_targets'");
16979 
16980     {
16981       int i;
16982 
16983       if (real_packet->orders_length > MAX_LEN_ROUTE) {
16984         RECEIVE_PACKET_FIELD_ERROR(orders_targets, ": truncation array");
16985       }
16986       for (i = 0; i < real_packet->orders_length; i++) {
16987         if (!DIO_GET(sint8, &din, "orders_targets", &real_packet->orders_targets[i])) {
16988           RECEIVE_PACKET_FIELD_ERROR(orders_targets);
16989         }
16990       }
16991     }
16992   }
16993   if (BV_ISSET(fields, 34)) {
16994     log_packet_detailed("  got field 'action_decision_want'");
16995     {
16996       int readin;
16997 
16998       if (!DIO_GET(uint8, &din, "action_decision_want", &readin)) {
16999         RECEIVE_PACKET_FIELD_ERROR(action_decision_want);
17000       }
17001       real_packet->action_decision_want = readin;
17002     }
17003   }
17004   if (BV_ISSET(fields, 35)) {
17005     log_packet_detailed("  got field 'action_decision_tile'");
17006     if (!DIO_GET(sint32, &din, "action_decision_tile", &real_packet->action_decision_tile)) {
17007       RECEIVE_PACKET_FIELD_ERROR(action_decision_tile);
17008     }
17009   }
17010 
17011   if (NULL == old) {
17012     old = fc_malloc(sizeof(*old));
17013     *old = *real_packet;
17014     genhash_insert(*hash, old, old);
17015   } else {
17016     *old = *real_packet;
17017   }
17018 
17019   hash = pc->phs.received + PACKET_UNIT_SHORT_INFO;
17020   if (NULL != *hash) {
17021     genhash_remove(*hash, real_packet);
17022   }
17023   RECEIVE_PACKET_END(real_packet);
17024 }
17025 
send_packet_unit_info_100(struct connection * pc,const struct packet_unit_info * packet)17026 static int send_packet_unit_info_100(struct connection *pc, const struct packet_unit_info *packet)
17027 {
17028   const struct packet_unit_info *real_packet = packet;
17029   packet_unit_info_100_fields fields;
17030   struct packet_unit_info *old;
17031   bool differ;
17032   struct genhash **hash = pc->phs.sent + PACKET_UNIT_INFO;
17033   int different = 0;
17034   SEND_PACKET_START(PACKET_UNIT_INFO);
17035 
17036   log_packet_detailed("packet_unit_info_100: sending info about (%d)",
17037     real_packet->id);
17038 
17039   if (NULL == *hash) {
17040     *hash = genhash_new_full(hash_packet_unit_info_100, cmp_packet_unit_info_100,
17041                              NULL, NULL, NULL, free);
17042   }
17043   BV_CLR_ALL(fields);
17044 
17045   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
17046     old = fc_malloc(sizeof(*old));
17047     *old = *real_packet;
17048     genhash_insert(*hash, old, old);
17049     memset(old, 0, sizeof(*old));
17050     different = 1;      /* Force to send. */
17051   }
17052 
17053   differ = (old->owner != real_packet->owner);
17054   if (differ) {
17055     different++;
17056     BV_SET(fields, 0);
17057   }
17058 
17059   differ = (old->nationality != real_packet->nationality);
17060   if (differ) {
17061     different++;
17062     BV_SET(fields, 1);
17063   }
17064 
17065   differ = (old->tile != real_packet->tile);
17066   if (differ) {
17067     different++;
17068     BV_SET(fields, 2);
17069   }
17070 
17071   differ = (old->facing != real_packet->facing);
17072   if (differ) {
17073     different++;
17074     BV_SET(fields, 3);
17075   }
17076 
17077   differ = (old->homecity != real_packet->homecity);
17078   if (differ) {
17079     different++;
17080     BV_SET(fields, 4);
17081   }
17082 
17083 
17084     {
17085       differ = (O_LAST != O_LAST);
17086       if (!differ) {
17087         int i;
17088 
17089         for (i = 0; i < O_LAST; i++) {
17090           if (old->upkeep[i] != real_packet->upkeep[i]) {
17091             differ = TRUE;
17092             break;
17093           }
17094         }
17095       }
17096     }
17097   if (differ) {
17098     different++;
17099     BV_SET(fields, 5);
17100   }
17101 
17102   differ = (old->veteran != real_packet->veteran);
17103   if (differ) {
17104     different++;
17105     BV_SET(fields, 6);
17106   }
17107 
17108   differ = (old->ai != real_packet->ai);
17109   if (differ) {
17110     different++;
17111   }
17112   if (packet->ai) {
17113     BV_SET(fields, 7);
17114   }
17115 
17116   differ = (old->paradropped != real_packet->paradropped);
17117   if (differ) {
17118     different++;
17119   }
17120   if (packet->paradropped) {
17121     BV_SET(fields, 8);
17122   }
17123 
17124   differ = (old->occupied != real_packet->occupied);
17125   if (differ) {
17126     different++;
17127   }
17128   if (packet->occupied) {
17129     BV_SET(fields, 9);
17130   }
17131 
17132   differ = (old->transported != real_packet->transported);
17133   if (differ) {
17134     different++;
17135   }
17136   if (packet->transported) {
17137     BV_SET(fields, 10);
17138   }
17139 
17140   differ = (old->done_moving != real_packet->done_moving);
17141   if (differ) {
17142     different++;
17143   }
17144   if (packet->done_moving) {
17145     BV_SET(fields, 11);
17146   }
17147 
17148   differ = (old->type != real_packet->type);
17149   if (differ) {
17150     different++;
17151     BV_SET(fields, 12);
17152   }
17153 
17154   differ = (old->transported_by != real_packet->transported_by);
17155   if (differ) {
17156     different++;
17157     BV_SET(fields, 13);
17158   }
17159 
17160   differ = (old->movesleft != real_packet->movesleft);
17161   if (differ) {
17162     different++;
17163     BV_SET(fields, 14);
17164   }
17165 
17166   differ = (old->hp != real_packet->hp);
17167   if (differ) {
17168     different++;
17169     BV_SET(fields, 15);
17170   }
17171 
17172   differ = (old->fuel != real_packet->fuel);
17173   if (differ) {
17174     different++;
17175     BV_SET(fields, 16);
17176   }
17177 
17178   differ = (old->activity_count != real_packet->activity_count);
17179   if (differ) {
17180     different++;
17181     BV_SET(fields, 17);
17182   }
17183 
17184   differ = (old->changed_from_count != real_packet->changed_from_count);
17185   if (differ) {
17186     different++;
17187     BV_SET(fields, 18);
17188   }
17189 
17190   differ = (old->goto_tile != real_packet->goto_tile);
17191   if (differ) {
17192     different++;
17193     BV_SET(fields, 19);
17194   }
17195 
17196   differ = (old->activity != real_packet->activity);
17197   if (differ) {
17198     different++;
17199     BV_SET(fields, 20);
17200   }
17201 
17202   differ = (old->activity_tgt != real_packet->activity_tgt);
17203   if (differ) {
17204     different++;
17205     BV_SET(fields, 21);
17206   }
17207 
17208   differ = (old->changed_from != real_packet->changed_from);
17209   if (differ) {
17210     different++;
17211     BV_SET(fields, 22);
17212   }
17213 
17214   differ = (old->changed_from_tgt != real_packet->changed_from_tgt);
17215   if (differ) {
17216     different++;
17217     BV_SET(fields, 23);
17218   }
17219 
17220   differ = (old->battlegroup != real_packet->battlegroup);
17221   if (differ) {
17222     different++;
17223     BV_SET(fields, 24);
17224   }
17225 
17226   differ = (old->has_orders != real_packet->has_orders);
17227   if (differ) {
17228     different++;
17229   }
17230   if (packet->has_orders) {
17231     BV_SET(fields, 25);
17232   }
17233 
17234   differ = (old->orders_length != real_packet->orders_length);
17235   if (differ) {
17236     different++;
17237     BV_SET(fields, 26);
17238   }
17239 
17240   differ = (old->orders_index != real_packet->orders_index);
17241   if (differ) {
17242     different++;
17243     BV_SET(fields, 27);
17244   }
17245 
17246   differ = (old->orders_repeat != real_packet->orders_repeat);
17247   if (differ) {
17248     different++;
17249   }
17250   if (packet->orders_repeat) {
17251     BV_SET(fields, 28);
17252   }
17253 
17254   differ = (old->orders_vigilant != real_packet->orders_vigilant);
17255   if (differ) {
17256     different++;
17257   }
17258   if (packet->orders_vigilant) {
17259     BV_SET(fields, 29);
17260   }
17261 
17262 
17263     {
17264       differ = (old->orders_length != real_packet->orders_length);
17265       if (!differ) {
17266         int i;
17267 
17268         for (i = 0; i < real_packet->orders_length; i++) {
17269           if (old->orders[i] != real_packet->orders[i]) {
17270             differ = TRUE;
17271             break;
17272           }
17273         }
17274       }
17275     }
17276   if (differ) {
17277     different++;
17278     BV_SET(fields, 30);
17279   }
17280 
17281 
17282     {
17283       differ = (old->orders_length != real_packet->orders_length);
17284       if (!differ) {
17285         int i;
17286 
17287         for (i = 0; i < real_packet->orders_length; i++) {
17288           if (old->orders_dirs[i] != real_packet->orders_dirs[i]) {
17289             differ = TRUE;
17290             break;
17291           }
17292         }
17293       }
17294     }
17295   if (differ) {
17296     different++;
17297     BV_SET(fields, 31);
17298   }
17299 
17300 
17301     {
17302       differ = (old->orders_length != real_packet->orders_length);
17303       if (!differ) {
17304         int i;
17305 
17306         for (i = 0; i < real_packet->orders_length; i++) {
17307           if (old->orders_activities[i] != real_packet->orders_activities[i]) {
17308             differ = TRUE;
17309             break;
17310           }
17311         }
17312       }
17313     }
17314   if (differ) {
17315     different++;
17316     BV_SET(fields, 32);
17317   }
17318 
17319 
17320     {
17321       differ = (old->orders_length != real_packet->orders_length);
17322       if (!differ) {
17323         int i;
17324 
17325         for (i = 0; i < real_packet->orders_length; i++) {
17326           if (old->orders_targets[i] != real_packet->orders_targets[i]) {
17327             differ = TRUE;
17328             break;
17329           }
17330         }
17331       }
17332     }
17333   if (differ) {
17334     different++;
17335     BV_SET(fields, 33);
17336   }
17337 
17338   differ = (old->action_decision_want != real_packet->action_decision_want);
17339   if (differ) {
17340     different++;
17341     BV_SET(fields, 34);
17342   }
17343 
17344   differ = (old->action_decision_tile != real_packet->action_decision_tile);
17345   if (differ) {
17346     different++;
17347     BV_SET(fields, 35);
17348   }
17349 
17350 
17351   if (different == 0) {
17352     log_packet_detailed("  no change -> discard");
17353     return 0;
17354   }
17355 
17356   DIO_BV_PUT(&dout, "fields", fields);
17357   DIO_PUT(uint16, &dout, "id", real_packet->id);
17358 
17359   if (BV_ISSET(fields, 0)) {
17360     log_packet_detailed("  field 'owner' has changed");
17361     DIO_PUT(uint8, &dout, "owner", real_packet->owner);
17362   }
17363   if (BV_ISSET(fields, 1)) {
17364     log_packet_detailed("  field 'nationality' has changed");
17365     DIO_PUT(uint8, &dout, "nationality", real_packet->nationality);
17366   }
17367   if (BV_ISSET(fields, 2)) {
17368     log_packet_detailed("  field 'tile' has changed");
17369     DIO_PUT(sint32, &dout, "tile", real_packet->tile);
17370   }
17371   if (BV_ISSET(fields, 3)) {
17372     log_packet_detailed("  field 'facing' has changed");
17373     DIO_PUT(sint8, &dout, "facing", real_packet->facing);
17374   }
17375   if (BV_ISSET(fields, 4)) {
17376     log_packet_detailed("  field 'homecity' has changed");
17377     DIO_PUT(uint16, &dout, "homecity", real_packet->homecity);
17378   }
17379   if (BV_ISSET(fields, 5)) {
17380     log_packet_detailed("  field 'upkeep' has changed");
17381 
17382     {
17383       int i;
17384 
17385       for (i = 0; i < O_LAST; i++) {
17386         dio_put_uint8(&dout, real_packet->upkeep[i]);
17387       }
17388     }
17389   }
17390   if (BV_ISSET(fields, 6)) {
17391     log_packet_detailed("  field 'veteran' has changed");
17392     DIO_PUT(uint8, &dout, "veteran", real_packet->veteran);
17393   }
17394   /* field 7 is folded into the header */
17395   /* field 8 is folded into the header */
17396   /* field 9 is folded into the header */
17397   /* field 10 is folded into the header */
17398   /* field 11 is folded into the header */
17399   if (BV_ISSET(fields, 12)) {
17400     log_packet_detailed("  field 'type' has changed");
17401     DIO_PUT(uint8, &dout, "type", real_packet->type);
17402   }
17403   if (BV_ISSET(fields, 13)) {
17404     log_packet_detailed("  field 'transported_by' has changed");
17405     DIO_PUT(uint16, &dout, "transported_by", real_packet->transported_by);
17406   }
17407   if (BV_ISSET(fields, 14)) {
17408     log_packet_detailed("  field 'movesleft' has changed");
17409     DIO_PUT(uint16, &dout, "movesleft", real_packet->movesleft);
17410   }
17411   if (BV_ISSET(fields, 15)) {
17412     log_packet_detailed("  field 'hp' has changed");
17413     DIO_PUT(uint8, &dout, "hp", real_packet->hp);
17414   }
17415   if (BV_ISSET(fields, 16)) {
17416     log_packet_detailed("  field 'fuel' has changed");
17417     DIO_PUT(uint8, &dout, "fuel", real_packet->fuel);
17418   }
17419   if (BV_ISSET(fields, 17)) {
17420     log_packet_detailed("  field 'activity_count' has changed");
17421     DIO_PUT(uint16, &dout, "activity_count", real_packet->activity_count);
17422   }
17423   if (BV_ISSET(fields, 18)) {
17424     log_packet_detailed("  field 'changed_from_count' has changed");
17425     DIO_PUT(uint16, &dout, "changed_from_count", real_packet->changed_from_count);
17426   }
17427   if (BV_ISSET(fields, 19)) {
17428     log_packet_detailed("  field 'goto_tile' has changed");
17429     DIO_PUT(sint32, &dout, "goto_tile", real_packet->goto_tile);
17430   }
17431   if (BV_ISSET(fields, 20)) {
17432     log_packet_detailed("  field 'activity' has changed");
17433     DIO_PUT(uint8, &dout, "activity", real_packet->activity);
17434   }
17435   if (BV_ISSET(fields, 21)) {
17436     log_packet_detailed("  field 'activity_tgt' has changed");
17437     DIO_PUT(sint8, &dout, "activity_tgt", real_packet->activity_tgt);
17438   }
17439   if (BV_ISSET(fields, 22)) {
17440     log_packet_detailed("  field 'changed_from' has changed");
17441     DIO_PUT(uint8, &dout, "changed_from", real_packet->changed_from);
17442   }
17443   if (BV_ISSET(fields, 23)) {
17444     log_packet_detailed("  field 'changed_from_tgt' has changed");
17445     DIO_PUT(sint8, &dout, "changed_from_tgt", real_packet->changed_from_tgt);
17446   }
17447   if (BV_ISSET(fields, 24)) {
17448     log_packet_detailed("  field 'battlegroup' has changed");
17449     DIO_PUT(sint8, &dout, "battlegroup", real_packet->battlegroup);
17450   }
17451   /* field 25 is folded into the header */
17452   if (BV_ISSET(fields, 26)) {
17453     log_packet_detailed("  field 'orders_length' has changed");
17454     DIO_PUT(uint16, &dout, "orders_length", real_packet->orders_length);
17455   }
17456   if (BV_ISSET(fields, 27)) {
17457     log_packet_detailed("  field 'orders_index' has changed");
17458     DIO_PUT(uint16, &dout, "orders_index", real_packet->orders_index);
17459   }
17460   /* field 28 is folded into the header */
17461   /* field 29 is folded into the header */
17462   if (BV_ISSET(fields, 30)) {
17463     log_packet_detailed("  field 'orders' has changed");
17464 
17465     {
17466       int i;
17467 
17468       for (i = 0; i < real_packet->orders_length; i++) {
17469         dio_put_uint8(&dout, real_packet->orders[i]);
17470       }
17471     }
17472   }
17473   if (BV_ISSET(fields, 31)) {
17474     log_packet_detailed("  field 'orders_dirs' has changed");
17475 
17476     {
17477       int i;
17478 
17479       for (i = 0; i < real_packet->orders_length; i++) {
17480         dio_put_sint8(&dout, real_packet->orders_dirs[i]);
17481       }
17482     }
17483   }
17484   if (BV_ISSET(fields, 32)) {
17485     log_packet_detailed("  field 'orders_activities' has changed");
17486 
17487     {
17488       int i;
17489 
17490       for (i = 0; i < real_packet->orders_length; i++) {
17491         dio_put_uint8(&dout, real_packet->orders_activities[i]);
17492       }
17493     }
17494   }
17495   if (BV_ISSET(fields, 33)) {
17496     log_packet_detailed("  field 'orders_targets' has changed");
17497 
17498     {
17499       int i;
17500 
17501       for (i = 0; i < real_packet->orders_length; i++) {
17502         dio_put_sint8(&dout, real_packet->orders_targets[i]);
17503       }
17504     }
17505   }
17506   if (BV_ISSET(fields, 34)) {
17507     log_packet_detailed("  field 'action_decision_want' has changed");
17508     DIO_PUT(uint8, &dout, "action_decision_want", real_packet->action_decision_want);
17509   }
17510   if (BV_ISSET(fields, 35)) {
17511     log_packet_detailed("  field 'action_decision_tile' has changed");
17512     DIO_PUT(sint32, &dout, "action_decision_tile", real_packet->action_decision_tile);
17513   }
17514 
17515   *old = *real_packet;
17516 
17517   hash = pc->phs.sent + PACKET_UNIT_SHORT_INFO;
17518   if (NULL != *hash) {
17519     genhash_remove(*hash, real_packet);
17520   }
17521   SEND_PACKET_END(PACKET_UNIT_INFO);
17522 }
17523 
send_packet_unit_info(struct connection * pc,const struct packet_unit_info * packet)17524 int send_packet_unit_info(struct connection *pc, const struct packet_unit_info *packet)
17525 {
17526   if (!pc->used) {
17527     log_error("WARNING: trying to send data to the closed connection %s",
17528               conn_description(pc));
17529     return -1;
17530   }
17531   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_INFO].packet != NULL, -1,
17532                         "Handler for PACKET_UNIT_INFO not installed");
17533   return pc->phs.handlers->send[PACKET_UNIT_INFO].packet(pc, packet);
17534 }
17535 
lsend_packet_unit_info(struct conn_list * dest,const struct packet_unit_info * packet)17536 void lsend_packet_unit_info(struct conn_list *dest, const struct packet_unit_info *packet)
17537 {
17538   conn_list_iterate(dest, pconn) {
17539     send_packet_unit_info(pconn, packet);
17540   } conn_list_iterate_end;
17541 }
17542 
hash_packet_unit_short_info_100(const void * vkey)17543 static genhash_val_t hash_packet_unit_short_info_100(const void *vkey)
17544 {
17545   const struct packet_unit_short_info *key = (const struct packet_unit_short_info *) vkey;
17546 
17547   return key->id;
17548 }
17549 
cmp_packet_unit_short_info_100(const void * vkey1,const void * vkey2)17550 static bool cmp_packet_unit_short_info_100(const void *vkey1, const void *vkey2)
17551 {
17552   const struct packet_unit_short_info *key1 = (const struct packet_unit_short_info *) vkey1;
17553   const struct packet_unit_short_info *key2 = (const struct packet_unit_short_info *) vkey2;
17554 
17555   return key1->id == key2->id;
17556 }
17557 
17558 BV_DEFINE(packet_unit_short_info_100_fields, 13);
17559 
receive_packet_unit_short_info_100(struct connection * pc)17560 static struct packet_unit_short_info *receive_packet_unit_short_info_100(struct connection *pc)
17561 {
17562   packet_unit_short_info_100_fields fields;
17563   struct packet_unit_short_info *old;
17564   struct genhash **hash = pc->phs.received + PACKET_UNIT_SHORT_INFO;
17565   RECEIVE_PACKET_START(packet_unit_short_info, real_packet);
17566 
17567   DIO_BV_GET(&din, fields);
17568   if (!DIO_GET(uint16, &din, "id", &real_packet->id)) {
17569     RECEIVE_PACKET_FIELD_ERROR(id);
17570   }
17571 
17572   log_packet_detailed("packet_unit_short_info_100: got info about (%d)",
17573     real_packet->id);
17574 
17575   if (NULL == *hash) {
17576     *hash = genhash_new_full(hash_packet_unit_short_info_100, cmp_packet_unit_short_info_100,
17577                              NULL, NULL, NULL, free);
17578   }
17579 
17580   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
17581     *real_packet = *old;
17582   } else {
17583     int id = real_packet->id;
17584 
17585     log_packet_detailed("  no old info");
17586     memset(real_packet, 0, sizeof(*real_packet));
17587 
17588     real_packet->id = id;
17589   }
17590 
17591   if (BV_ISSET(fields, 0)) {
17592     log_packet_detailed("  got field 'owner'");
17593     if (!DIO_GET(uint8, &din, "owner", &real_packet->owner)) {
17594       RECEIVE_PACKET_FIELD_ERROR(owner);
17595     }
17596   }
17597   if (BV_ISSET(fields, 1)) {
17598     log_packet_detailed("  got field 'tile'");
17599     if (!DIO_GET(sint32, &din, "tile", &real_packet->tile)) {
17600       RECEIVE_PACKET_FIELD_ERROR(tile);
17601     }
17602   }
17603   if (BV_ISSET(fields, 2)) {
17604     log_packet_detailed("  got field 'facing'");
17605     {
17606       int readin;
17607 
17608       if (!DIO_GET(sint8, &din, "facing", &readin)) {
17609         RECEIVE_PACKET_FIELD_ERROR(facing);
17610       }
17611       real_packet->facing = readin;
17612     }
17613   }
17614   if (BV_ISSET(fields, 3)) {
17615     log_packet_detailed("  got field 'type'");
17616     {
17617       int readin;
17618 
17619       if (!DIO_GET(uint8, &din, "type", &readin)) {
17620         RECEIVE_PACKET_FIELD_ERROR(type);
17621       }
17622       real_packet->type = readin;
17623     }
17624   }
17625   if (BV_ISSET(fields, 4)) {
17626     log_packet_detailed("  got field 'veteran'");
17627     if (!DIO_GET(uint8, &din, "veteran", &real_packet->veteran)) {
17628       RECEIVE_PACKET_FIELD_ERROR(veteran);
17629     }
17630   }
17631   real_packet->occupied = BV_ISSET(fields, 5);
17632   real_packet->transported = BV_ISSET(fields, 6);
17633   if (BV_ISSET(fields, 7)) {
17634     log_packet_detailed("  got field 'hp'");
17635     if (!DIO_GET(uint8, &din, "hp", &real_packet->hp)) {
17636       RECEIVE_PACKET_FIELD_ERROR(hp);
17637     }
17638   }
17639   if (BV_ISSET(fields, 8)) {
17640     log_packet_detailed("  got field 'activity'");
17641     if (!DIO_GET(uint8, &din, "activity", &real_packet->activity)) {
17642       RECEIVE_PACKET_FIELD_ERROR(activity);
17643     }
17644   }
17645   if (BV_ISSET(fields, 9)) {
17646     log_packet_detailed("  got field 'activity_tgt'");
17647     if (!DIO_GET(sint8, &din, "activity_tgt", &real_packet->activity_tgt)) {
17648       RECEIVE_PACKET_FIELD_ERROR(activity_tgt);
17649     }
17650   }
17651   if (BV_ISSET(fields, 10)) {
17652     log_packet_detailed("  got field 'transported_by'");
17653     if (!DIO_GET(uint16, &din, "transported_by", &real_packet->transported_by)) {
17654       RECEIVE_PACKET_FIELD_ERROR(transported_by);
17655     }
17656   }
17657   if (BV_ISSET(fields, 11)) {
17658     log_packet_detailed("  got field 'packet_use'");
17659     if (!DIO_GET(uint8, &din, "packet_use", &real_packet->packet_use)) {
17660       RECEIVE_PACKET_FIELD_ERROR(packet_use);
17661     }
17662   }
17663   if (BV_ISSET(fields, 12)) {
17664     log_packet_detailed("  got field 'info_city_id'");
17665     if (!DIO_GET(uint16, &din, "info_city_id", &real_packet->info_city_id)) {
17666       RECEIVE_PACKET_FIELD_ERROR(info_city_id);
17667     }
17668   }
17669 
17670   if (NULL == old) {
17671     old = fc_malloc(sizeof(*old));
17672     *old = *real_packet;
17673     genhash_insert(*hash, old, old);
17674   } else {
17675     *old = *real_packet;
17676   }
17677 
17678   hash = pc->phs.received + PACKET_UNIT_INFO;
17679   if (NULL != *hash) {
17680     genhash_remove(*hash, real_packet);
17681   }
17682   RECEIVE_PACKET_END(real_packet);
17683 }
17684 
send_packet_unit_short_info_100(struct connection * pc,const struct packet_unit_short_info * packet,bool force_to_send)17685 static int send_packet_unit_short_info_100(struct connection *pc, const struct packet_unit_short_info *packet, bool force_to_send)
17686 {
17687   const struct packet_unit_short_info *real_packet = packet;
17688   packet_unit_short_info_100_fields fields;
17689   struct packet_unit_short_info *old;
17690   bool differ;
17691   struct genhash **hash = pc->phs.sent + PACKET_UNIT_SHORT_INFO;
17692   int different = force_to_send;
17693   SEND_PACKET_START(PACKET_UNIT_SHORT_INFO);
17694 
17695   log_packet_detailed("packet_unit_short_info_100: sending info about (%d)",
17696     real_packet->id);
17697 
17698   if (NULL == *hash) {
17699     *hash = genhash_new_full(hash_packet_unit_short_info_100, cmp_packet_unit_short_info_100,
17700                              NULL, NULL, NULL, free);
17701   }
17702   BV_CLR_ALL(fields);
17703 
17704   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
17705     old = fc_malloc(sizeof(*old));
17706     *old = *real_packet;
17707     genhash_insert(*hash, old, old);
17708     memset(old, 0, sizeof(*old));
17709     different = 1;      /* Force to send. */
17710   }
17711 
17712   differ = (old->owner != real_packet->owner);
17713   if (differ) {
17714     different++;
17715     BV_SET(fields, 0);
17716   }
17717 
17718   differ = (old->tile != real_packet->tile);
17719   if (differ) {
17720     different++;
17721     BV_SET(fields, 1);
17722   }
17723 
17724   differ = (old->facing != real_packet->facing);
17725   if (differ) {
17726     different++;
17727     BV_SET(fields, 2);
17728   }
17729 
17730   differ = (old->type != real_packet->type);
17731   if (differ) {
17732     different++;
17733     BV_SET(fields, 3);
17734   }
17735 
17736   differ = (old->veteran != real_packet->veteran);
17737   if (differ) {
17738     different++;
17739     BV_SET(fields, 4);
17740   }
17741 
17742   differ = (old->occupied != real_packet->occupied);
17743   if (differ) {
17744     different++;
17745   }
17746   if (packet->occupied) {
17747     BV_SET(fields, 5);
17748   }
17749 
17750   differ = (old->transported != real_packet->transported);
17751   if (differ) {
17752     different++;
17753   }
17754   if (packet->transported) {
17755     BV_SET(fields, 6);
17756   }
17757 
17758   differ = (old->hp != real_packet->hp);
17759   if (differ) {
17760     different++;
17761     BV_SET(fields, 7);
17762   }
17763 
17764   differ = (old->activity != real_packet->activity);
17765   if (differ) {
17766     different++;
17767     BV_SET(fields, 8);
17768   }
17769 
17770   differ = (old->activity_tgt != real_packet->activity_tgt);
17771   if (differ) {
17772     different++;
17773     BV_SET(fields, 9);
17774   }
17775 
17776   differ = (old->transported_by != real_packet->transported_by);
17777   if (differ) {
17778     different++;
17779     BV_SET(fields, 10);
17780   }
17781 
17782   differ = (old->packet_use != real_packet->packet_use);
17783   if (differ) {
17784     different++;
17785     BV_SET(fields, 11);
17786   }
17787 
17788   differ = (old->info_city_id != real_packet->info_city_id);
17789   if (differ) {
17790     different++;
17791     BV_SET(fields, 12);
17792   }
17793 
17794 
17795   if (different == 0) {
17796     log_packet_detailed("  no change -> discard");
17797     return 0;
17798   }
17799 
17800   DIO_BV_PUT(&dout, "fields", fields);
17801   DIO_PUT(uint16, &dout, "id", real_packet->id);
17802 
17803   if (BV_ISSET(fields, 0)) {
17804     log_packet_detailed("  field 'owner' has changed");
17805     DIO_PUT(uint8, &dout, "owner", real_packet->owner);
17806   }
17807   if (BV_ISSET(fields, 1)) {
17808     log_packet_detailed("  field 'tile' has changed");
17809     DIO_PUT(sint32, &dout, "tile", real_packet->tile);
17810   }
17811   if (BV_ISSET(fields, 2)) {
17812     log_packet_detailed("  field 'facing' has changed");
17813     DIO_PUT(sint8, &dout, "facing", real_packet->facing);
17814   }
17815   if (BV_ISSET(fields, 3)) {
17816     log_packet_detailed("  field 'type' has changed");
17817     DIO_PUT(uint8, &dout, "type", real_packet->type);
17818   }
17819   if (BV_ISSET(fields, 4)) {
17820     log_packet_detailed("  field 'veteran' has changed");
17821     DIO_PUT(uint8, &dout, "veteran", real_packet->veteran);
17822   }
17823   /* field 5 is folded into the header */
17824   /* field 6 is folded into the header */
17825   if (BV_ISSET(fields, 7)) {
17826     log_packet_detailed("  field 'hp' has changed");
17827     DIO_PUT(uint8, &dout, "hp", real_packet->hp);
17828   }
17829   if (BV_ISSET(fields, 8)) {
17830     log_packet_detailed("  field 'activity' has changed");
17831     DIO_PUT(uint8, &dout, "activity", real_packet->activity);
17832   }
17833   if (BV_ISSET(fields, 9)) {
17834     log_packet_detailed("  field 'activity_tgt' has changed");
17835     DIO_PUT(sint8, &dout, "activity_tgt", real_packet->activity_tgt);
17836   }
17837   if (BV_ISSET(fields, 10)) {
17838     log_packet_detailed("  field 'transported_by' has changed");
17839     DIO_PUT(uint16, &dout, "transported_by", real_packet->transported_by);
17840   }
17841   if (BV_ISSET(fields, 11)) {
17842     log_packet_detailed("  field 'packet_use' has changed");
17843     DIO_PUT(uint8, &dout, "packet_use", real_packet->packet_use);
17844   }
17845   if (BV_ISSET(fields, 12)) {
17846     log_packet_detailed("  field 'info_city_id' has changed");
17847     DIO_PUT(uint16, &dout, "info_city_id", real_packet->info_city_id);
17848   }
17849 
17850   *old = *real_packet;
17851 
17852   hash = pc->phs.sent + PACKET_UNIT_INFO;
17853   if (NULL != *hash) {
17854     genhash_remove(*hash, real_packet);
17855   }
17856   SEND_PACKET_END(PACKET_UNIT_SHORT_INFO);
17857 }
17858 
send_packet_unit_short_info(struct connection * pc,const struct packet_unit_short_info * packet,bool force_to_send)17859 int send_packet_unit_short_info(struct connection *pc, const struct packet_unit_short_info *packet, bool force_to_send)
17860 {
17861   if (!pc->used) {
17862     log_error("WARNING: trying to send data to the closed connection %s",
17863               conn_description(pc));
17864     return -1;
17865   }
17866   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_SHORT_INFO].force_to_send != NULL, -1,
17867                         "Handler for PACKET_UNIT_SHORT_INFO not installed");
17868   return pc->phs.handlers->send[PACKET_UNIT_SHORT_INFO].force_to_send(pc, packet, force_to_send);
17869 }
17870 
lsend_packet_unit_short_info(struct conn_list * dest,const struct packet_unit_short_info * packet,bool force_to_send)17871 void lsend_packet_unit_short_info(struct conn_list *dest, const struct packet_unit_short_info *packet, bool force_to_send)
17872 {
17873   conn_list_iterate(dest, pconn) {
17874     send_packet_unit_short_info(pconn, packet, force_to_send);
17875   } conn_list_iterate_end;
17876 }
17877 
17878 #define hash_packet_unit_combat_info_100 hash_const
17879 
17880 #define cmp_packet_unit_combat_info_100 cmp_const
17881 
17882 BV_DEFINE(packet_unit_combat_info_100_fields, 5);
17883 
receive_packet_unit_combat_info_100(struct connection * pc)17884 static struct packet_unit_combat_info *receive_packet_unit_combat_info_100(struct connection *pc)
17885 {
17886   packet_unit_combat_info_100_fields fields;
17887   struct packet_unit_combat_info *old;
17888   struct genhash **hash = pc->phs.received + PACKET_UNIT_COMBAT_INFO;
17889   RECEIVE_PACKET_START(packet_unit_combat_info, real_packet);
17890 
17891   DIO_BV_GET(&din, fields);
17892 
17893   log_packet_detailed("packet_unit_combat_info_100: got info about ()");
17894 
17895   if (NULL == *hash) {
17896     *hash = genhash_new_full(hash_packet_unit_combat_info_100, cmp_packet_unit_combat_info_100,
17897                              NULL, NULL, NULL, free);
17898   }
17899 
17900   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
17901     *real_packet = *old;
17902   } else {
17903     log_packet_detailed("  no old info");
17904     memset(real_packet, 0, sizeof(*real_packet));
17905   }
17906 
17907   if (BV_ISSET(fields, 0)) {
17908     log_packet_detailed("  got field 'attacker_unit_id'");
17909     if (!DIO_GET(uint16, &din, "attacker_unit_id", &real_packet->attacker_unit_id)) {
17910       RECEIVE_PACKET_FIELD_ERROR(attacker_unit_id);
17911     }
17912   }
17913   if (BV_ISSET(fields, 1)) {
17914     log_packet_detailed("  got field 'defender_unit_id'");
17915     if (!DIO_GET(uint16, &din, "defender_unit_id", &real_packet->defender_unit_id)) {
17916       RECEIVE_PACKET_FIELD_ERROR(defender_unit_id);
17917     }
17918   }
17919   if (BV_ISSET(fields, 2)) {
17920     log_packet_detailed("  got field 'attacker_hp'");
17921     if (!DIO_GET(uint8, &din, "attacker_hp", &real_packet->attacker_hp)) {
17922       RECEIVE_PACKET_FIELD_ERROR(attacker_hp);
17923     }
17924   }
17925   if (BV_ISSET(fields, 3)) {
17926     log_packet_detailed("  got field 'defender_hp'");
17927     if (!DIO_GET(uint8, &din, "defender_hp", &real_packet->defender_hp)) {
17928       RECEIVE_PACKET_FIELD_ERROR(defender_hp);
17929     }
17930   }
17931   real_packet->make_winner_veteran = BV_ISSET(fields, 4);
17932 
17933   if (NULL == old) {
17934     old = fc_malloc(sizeof(*old));
17935     *old = *real_packet;
17936     genhash_insert(*hash, old, old);
17937   } else {
17938     *old = *real_packet;
17939   }
17940   RECEIVE_PACKET_END(real_packet);
17941 }
17942 
send_packet_unit_combat_info_100(struct connection * pc,const struct packet_unit_combat_info * packet)17943 static int send_packet_unit_combat_info_100(struct connection *pc, const struct packet_unit_combat_info *packet)
17944 {
17945   const struct packet_unit_combat_info *real_packet = packet;
17946   packet_unit_combat_info_100_fields fields;
17947   struct packet_unit_combat_info *old;
17948   bool differ;
17949   struct genhash **hash = pc->phs.sent + PACKET_UNIT_COMBAT_INFO;
17950   int different = 0;
17951   SEND_PACKET_START(PACKET_UNIT_COMBAT_INFO);
17952 
17953   log_packet_detailed("packet_unit_combat_info_100: sending info about ()");
17954 
17955   if (NULL == *hash) {
17956     *hash = genhash_new_full(hash_packet_unit_combat_info_100, cmp_packet_unit_combat_info_100,
17957                              NULL, NULL, NULL, free);
17958   }
17959   BV_CLR_ALL(fields);
17960 
17961   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
17962     old = fc_malloc(sizeof(*old));
17963     *old = *real_packet;
17964     genhash_insert(*hash, old, old);
17965     memset(old, 0, sizeof(*old));
17966     different = 1;      /* Force to send. */
17967   }
17968 
17969   differ = (old->attacker_unit_id != real_packet->attacker_unit_id);
17970   if (differ) {
17971     different++;
17972     BV_SET(fields, 0);
17973   }
17974 
17975   differ = (old->defender_unit_id != real_packet->defender_unit_id);
17976   if (differ) {
17977     different++;
17978     BV_SET(fields, 1);
17979   }
17980 
17981   differ = (old->attacker_hp != real_packet->attacker_hp);
17982   if (differ) {
17983     different++;
17984     BV_SET(fields, 2);
17985   }
17986 
17987   differ = (old->defender_hp != real_packet->defender_hp);
17988   if (differ) {
17989     different++;
17990     BV_SET(fields, 3);
17991   }
17992 
17993   differ = (old->make_winner_veteran != real_packet->make_winner_veteran);
17994   if (differ) {
17995     different++;
17996   }
17997   if (packet->make_winner_veteran) {
17998     BV_SET(fields, 4);
17999   }
18000 
18001 
18002   DIO_BV_PUT(&dout, "fields", fields);
18003 
18004   if (BV_ISSET(fields, 0)) {
18005     log_packet_detailed("  field 'attacker_unit_id' has changed");
18006     DIO_PUT(uint16, &dout, "attacker_unit_id", real_packet->attacker_unit_id);
18007   }
18008   if (BV_ISSET(fields, 1)) {
18009     log_packet_detailed("  field 'defender_unit_id' has changed");
18010     DIO_PUT(uint16, &dout, "defender_unit_id", real_packet->defender_unit_id);
18011   }
18012   if (BV_ISSET(fields, 2)) {
18013     log_packet_detailed("  field 'attacker_hp' has changed");
18014     DIO_PUT(uint8, &dout, "attacker_hp", real_packet->attacker_hp);
18015   }
18016   if (BV_ISSET(fields, 3)) {
18017     log_packet_detailed("  field 'defender_hp' has changed");
18018     DIO_PUT(uint8, &dout, "defender_hp", real_packet->defender_hp);
18019   }
18020   /* field 4 is folded into the header */
18021 
18022   *old = *real_packet;
18023   SEND_PACKET_END(PACKET_UNIT_COMBAT_INFO);
18024 }
18025 
send_packet_unit_combat_info(struct connection * pc,const struct packet_unit_combat_info * packet)18026 int send_packet_unit_combat_info(struct connection *pc, const struct packet_unit_combat_info *packet)
18027 {
18028   if (!pc->used) {
18029     log_error("WARNING: trying to send data to the closed connection %s",
18030               conn_description(pc));
18031     return -1;
18032   }
18033   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_COMBAT_INFO].packet != NULL, -1,
18034                         "Handler for PACKET_UNIT_COMBAT_INFO not installed");
18035   return pc->phs.handlers->send[PACKET_UNIT_COMBAT_INFO].packet(pc, packet);
18036 }
18037 
lsend_packet_unit_combat_info(struct conn_list * dest,const struct packet_unit_combat_info * packet)18038 void lsend_packet_unit_combat_info(struct conn_list *dest, const struct packet_unit_combat_info *packet)
18039 {
18040   conn_list_iterate(dest, pconn) {
18041     send_packet_unit_combat_info(pconn, packet);
18042   } conn_list_iterate_end;
18043 }
18044 
18045 #define hash_packet_unit_build_city_100 hash_const
18046 
18047 #define cmp_packet_unit_build_city_100 cmp_const
18048 
18049 BV_DEFINE(packet_unit_build_city_100_fields, 2);
18050 
receive_packet_unit_build_city_100(struct connection * pc)18051 static struct packet_unit_build_city *receive_packet_unit_build_city_100(struct connection *pc)
18052 {
18053   packet_unit_build_city_100_fields fields;
18054   struct packet_unit_build_city *old;
18055   struct genhash **hash = pc->phs.received + PACKET_UNIT_BUILD_CITY;
18056   RECEIVE_PACKET_START(packet_unit_build_city, real_packet);
18057 
18058   DIO_BV_GET(&din, fields);
18059 
18060   log_packet_detailed("packet_unit_build_city_100: got info about ()");
18061 
18062   if (NULL == *hash) {
18063     *hash = genhash_new_full(hash_packet_unit_build_city_100, cmp_packet_unit_build_city_100,
18064                              NULL, NULL, NULL, free);
18065   }
18066 
18067   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
18068     *real_packet = *old;
18069   } else {
18070     log_packet_detailed("  no old info");
18071     memset(real_packet, 0, sizeof(*real_packet));
18072   }
18073 
18074   if (BV_ISSET(fields, 0)) {
18075     log_packet_detailed("  got field 'unit_id'");
18076     if (!DIO_GET(uint16, &din, "unit_id", &real_packet->unit_id)) {
18077       RECEIVE_PACKET_FIELD_ERROR(unit_id);
18078     }
18079   }
18080   if (BV_ISSET(fields, 1)) {
18081     log_packet_detailed("  got field 'name'");
18082     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
18083       RECEIVE_PACKET_FIELD_ERROR(name);
18084     }
18085   }
18086 
18087   if (NULL == old) {
18088     old = fc_malloc(sizeof(*old));
18089     *old = *real_packet;
18090     genhash_insert(*hash, old, old);
18091   } else {
18092     *old = *real_packet;
18093   }
18094   RECEIVE_PACKET_END(real_packet);
18095 }
18096 
send_packet_unit_build_city_100(struct connection * pc,const struct packet_unit_build_city * packet)18097 static int send_packet_unit_build_city_100(struct connection *pc, const struct packet_unit_build_city *packet)
18098 {
18099   const struct packet_unit_build_city *real_packet = packet;
18100   packet_unit_build_city_100_fields fields;
18101   struct packet_unit_build_city *old;
18102   bool differ;
18103   struct genhash **hash = pc->phs.sent + PACKET_UNIT_BUILD_CITY;
18104   int different = 0;
18105   SEND_PACKET_START(PACKET_UNIT_BUILD_CITY);
18106 
18107   log_packet_detailed("packet_unit_build_city_100: sending info about ()");
18108 
18109   if (NULL == *hash) {
18110     *hash = genhash_new_full(hash_packet_unit_build_city_100, cmp_packet_unit_build_city_100,
18111                              NULL, NULL, NULL, free);
18112   }
18113   BV_CLR_ALL(fields);
18114 
18115   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
18116     old = fc_malloc(sizeof(*old));
18117     *old = *real_packet;
18118     genhash_insert(*hash, old, old);
18119     memset(old, 0, sizeof(*old));
18120     different = 1;      /* Force to send. */
18121   }
18122 
18123   differ = (old->unit_id != real_packet->unit_id);
18124   if (differ) {
18125     different++;
18126     BV_SET(fields, 0);
18127   }
18128 
18129   differ = (strcmp(old->name, real_packet->name) != 0);
18130   if (differ) {
18131     different++;
18132     BV_SET(fields, 1);
18133   }
18134 
18135 
18136   DIO_BV_PUT(&dout, "fields", fields);
18137 
18138   if (BV_ISSET(fields, 0)) {
18139     log_packet_detailed("  field 'unit_id' has changed");
18140     DIO_PUT(uint16, &dout, "unit_id", real_packet->unit_id);
18141   }
18142   if (BV_ISSET(fields, 1)) {
18143     log_packet_detailed("  field 'name' has changed");
18144     DIO_PUT(string, &dout, "name", real_packet->name);
18145   }
18146 
18147   *old = *real_packet;
18148   SEND_PACKET_END(PACKET_UNIT_BUILD_CITY);
18149 }
18150 
send_packet_unit_build_city(struct connection * pc,const struct packet_unit_build_city * packet)18151 int send_packet_unit_build_city(struct connection *pc, const struct packet_unit_build_city *packet)
18152 {
18153   if (!pc->used) {
18154     log_error("WARNING: trying to send data to the closed connection %s",
18155               conn_description(pc));
18156     return -1;
18157   }
18158   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_BUILD_CITY].packet != NULL, -1,
18159                         "Handler for PACKET_UNIT_BUILD_CITY not installed");
18160   return pc->phs.handlers->send[PACKET_UNIT_BUILD_CITY].packet(pc, packet);
18161 }
18162 
dsend_packet_unit_build_city(struct connection * pc,int unit_id,const char * name)18163 int dsend_packet_unit_build_city(struct connection *pc, int unit_id, const char *name)
18164 {
18165   struct packet_unit_build_city packet, *real_packet = &packet;
18166 
18167   real_packet->unit_id = unit_id;
18168   sz_strlcpy(real_packet->name, name);
18169 
18170   return send_packet_unit_build_city(pc, real_packet);
18171 }
18172 
18173 #define hash_packet_unit_disband_100 hash_const
18174 
18175 #define cmp_packet_unit_disband_100 cmp_const
18176 
18177 BV_DEFINE(packet_unit_disband_100_fields, 1);
18178 
receive_packet_unit_disband_100(struct connection * pc)18179 static struct packet_unit_disband *receive_packet_unit_disband_100(struct connection *pc)
18180 {
18181   packet_unit_disband_100_fields fields;
18182   struct packet_unit_disband *old;
18183   struct genhash **hash = pc->phs.received + PACKET_UNIT_DISBAND;
18184   RECEIVE_PACKET_START(packet_unit_disband, real_packet);
18185 
18186   DIO_BV_GET(&din, fields);
18187 
18188   log_packet_detailed("packet_unit_disband_100: got info about ()");
18189 
18190   if (NULL == *hash) {
18191     *hash = genhash_new_full(hash_packet_unit_disband_100, cmp_packet_unit_disband_100,
18192                              NULL, NULL, NULL, free);
18193   }
18194 
18195   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
18196     *real_packet = *old;
18197   } else {
18198     log_packet_detailed("  no old info");
18199     memset(real_packet, 0, sizeof(*real_packet));
18200   }
18201 
18202   if (BV_ISSET(fields, 0)) {
18203     log_packet_detailed("  got field 'unit_id'");
18204     if (!DIO_GET(uint16, &din, "unit_id", &real_packet->unit_id)) {
18205       RECEIVE_PACKET_FIELD_ERROR(unit_id);
18206     }
18207   }
18208 
18209   if (NULL == old) {
18210     old = fc_malloc(sizeof(*old));
18211     *old = *real_packet;
18212     genhash_insert(*hash, old, old);
18213   } else {
18214     *old = *real_packet;
18215   }
18216   RECEIVE_PACKET_END(real_packet);
18217 }
18218 
send_packet_unit_disband_100(struct connection * pc,const struct packet_unit_disband * packet)18219 static int send_packet_unit_disband_100(struct connection *pc, const struct packet_unit_disband *packet)
18220 {
18221   const struct packet_unit_disband *real_packet = packet;
18222   packet_unit_disband_100_fields fields;
18223   struct packet_unit_disband *old;
18224   bool differ;
18225   struct genhash **hash = pc->phs.sent + PACKET_UNIT_DISBAND;
18226   int different = 0;
18227   SEND_PACKET_START(PACKET_UNIT_DISBAND);
18228 
18229   log_packet_detailed("packet_unit_disband_100: sending info about ()");
18230 
18231   if (NULL == *hash) {
18232     *hash = genhash_new_full(hash_packet_unit_disband_100, cmp_packet_unit_disband_100,
18233                              NULL, NULL, NULL, free);
18234   }
18235   BV_CLR_ALL(fields);
18236 
18237   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
18238     old = fc_malloc(sizeof(*old));
18239     *old = *real_packet;
18240     genhash_insert(*hash, old, old);
18241     memset(old, 0, sizeof(*old));
18242     different = 1;      /* Force to send. */
18243   }
18244 
18245   differ = (old->unit_id != real_packet->unit_id);
18246   if (differ) {
18247     different++;
18248     BV_SET(fields, 0);
18249   }
18250 
18251 
18252   DIO_BV_PUT(&dout, "fields", fields);
18253 
18254   if (BV_ISSET(fields, 0)) {
18255     log_packet_detailed("  field 'unit_id' has changed");
18256     DIO_PUT(uint16, &dout, "unit_id", real_packet->unit_id);
18257   }
18258 
18259   *old = *real_packet;
18260   SEND_PACKET_END(PACKET_UNIT_DISBAND);
18261 }
18262 
send_packet_unit_disband(struct connection * pc,const struct packet_unit_disband * packet)18263 int send_packet_unit_disband(struct connection *pc, const struct packet_unit_disband *packet)
18264 {
18265   if (!pc->used) {
18266     log_error("WARNING: trying to send data to the closed connection %s",
18267               conn_description(pc));
18268     return -1;
18269   }
18270   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_DISBAND].packet != NULL, -1,
18271                         "Handler for PACKET_UNIT_DISBAND not installed");
18272   return pc->phs.handlers->send[PACKET_UNIT_DISBAND].packet(pc, packet);
18273 }
18274 
dsend_packet_unit_disband(struct connection * pc,int unit_id)18275 int dsend_packet_unit_disband(struct connection *pc, int unit_id)
18276 {
18277   struct packet_unit_disband packet, *real_packet = &packet;
18278 
18279   real_packet->unit_id = unit_id;
18280 
18281   return send_packet_unit_disband(pc, real_packet);
18282 }
18283 
18284 #define hash_packet_unit_change_homecity_100 hash_const
18285 
18286 #define cmp_packet_unit_change_homecity_100 cmp_const
18287 
18288 BV_DEFINE(packet_unit_change_homecity_100_fields, 2);
18289 
receive_packet_unit_change_homecity_100(struct connection * pc)18290 static struct packet_unit_change_homecity *receive_packet_unit_change_homecity_100(struct connection *pc)
18291 {
18292   packet_unit_change_homecity_100_fields fields;
18293   struct packet_unit_change_homecity *old;
18294   struct genhash **hash = pc->phs.received + PACKET_UNIT_CHANGE_HOMECITY;
18295   RECEIVE_PACKET_START(packet_unit_change_homecity, real_packet);
18296 
18297   DIO_BV_GET(&din, fields);
18298 
18299   log_packet_detailed("packet_unit_change_homecity_100: got info about ()");
18300 
18301   if (NULL == *hash) {
18302     *hash = genhash_new_full(hash_packet_unit_change_homecity_100, cmp_packet_unit_change_homecity_100,
18303                              NULL, NULL, NULL, free);
18304   }
18305 
18306   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
18307     *real_packet = *old;
18308   } else {
18309     log_packet_detailed("  no old info");
18310     memset(real_packet, 0, sizeof(*real_packet));
18311   }
18312 
18313   if (BV_ISSET(fields, 0)) {
18314     log_packet_detailed("  got field 'unit_id'");
18315     if (!DIO_GET(uint16, &din, "unit_id", &real_packet->unit_id)) {
18316       RECEIVE_PACKET_FIELD_ERROR(unit_id);
18317     }
18318   }
18319   if (BV_ISSET(fields, 1)) {
18320     log_packet_detailed("  got field 'city_id'");
18321     if (!DIO_GET(uint16, &din, "city_id", &real_packet->city_id)) {
18322       RECEIVE_PACKET_FIELD_ERROR(city_id);
18323     }
18324   }
18325 
18326   if (NULL == old) {
18327     old = fc_malloc(sizeof(*old));
18328     *old = *real_packet;
18329     genhash_insert(*hash, old, old);
18330   } else {
18331     *old = *real_packet;
18332   }
18333   RECEIVE_PACKET_END(real_packet);
18334 }
18335 
send_packet_unit_change_homecity_100(struct connection * pc,const struct packet_unit_change_homecity * packet)18336 static int send_packet_unit_change_homecity_100(struct connection *pc, const struct packet_unit_change_homecity *packet)
18337 {
18338   const struct packet_unit_change_homecity *real_packet = packet;
18339   packet_unit_change_homecity_100_fields fields;
18340   struct packet_unit_change_homecity *old;
18341   bool differ;
18342   struct genhash **hash = pc->phs.sent + PACKET_UNIT_CHANGE_HOMECITY;
18343   int different = 0;
18344   SEND_PACKET_START(PACKET_UNIT_CHANGE_HOMECITY);
18345 
18346   log_packet_detailed("packet_unit_change_homecity_100: sending info about ()");
18347 
18348   if (NULL == *hash) {
18349     *hash = genhash_new_full(hash_packet_unit_change_homecity_100, cmp_packet_unit_change_homecity_100,
18350                              NULL, NULL, NULL, free);
18351   }
18352   BV_CLR_ALL(fields);
18353 
18354   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
18355     old = fc_malloc(sizeof(*old));
18356     *old = *real_packet;
18357     genhash_insert(*hash, old, old);
18358     memset(old, 0, sizeof(*old));
18359     different = 1;      /* Force to send. */
18360   }
18361 
18362   differ = (old->unit_id != real_packet->unit_id);
18363   if (differ) {
18364     different++;
18365     BV_SET(fields, 0);
18366   }
18367 
18368   differ = (old->city_id != real_packet->city_id);
18369   if (differ) {
18370     different++;
18371     BV_SET(fields, 1);
18372   }
18373 
18374 
18375   DIO_BV_PUT(&dout, "fields", fields);
18376 
18377   if (BV_ISSET(fields, 0)) {
18378     log_packet_detailed("  field 'unit_id' has changed");
18379     DIO_PUT(uint16, &dout, "unit_id", real_packet->unit_id);
18380   }
18381   if (BV_ISSET(fields, 1)) {
18382     log_packet_detailed("  field 'city_id' has changed");
18383     DIO_PUT(uint16, &dout, "city_id", real_packet->city_id);
18384   }
18385 
18386   *old = *real_packet;
18387   SEND_PACKET_END(PACKET_UNIT_CHANGE_HOMECITY);
18388 }
18389 
send_packet_unit_change_homecity(struct connection * pc,const struct packet_unit_change_homecity * packet)18390 int send_packet_unit_change_homecity(struct connection *pc, const struct packet_unit_change_homecity *packet)
18391 {
18392   if (!pc->used) {
18393     log_error("WARNING: trying to send data to the closed connection %s",
18394               conn_description(pc));
18395     return -1;
18396   }
18397   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_CHANGE_HOMECITY].packet != NULL, -1,
18398                         "Handler for PACKET_UNIT_CHANGE_HOMECITY not installed");
18399   return pc->phs.handlers->send[PACKET_UNIT_CHANGE_HOMECITY].packet(pc, packet);
18400 }
18401 
dsend_packet_unit_change_homecity(struct connection * pc,int unit_id,int city_id)18402 int dsend_packet_unit_change_homecity(struct connection *pc, int unit_id, int city_id)
18403 {
18404   struct packet_unit_change_homecity packet, *real_packet = &packet;
18405 
18406   real_packet->unit_id = unit_id;
18407   real_packet->city_id = city_id;
18408 
18409   return send_packet_unit_change_homecity(pc, real_packet);
18410 }
18411 
18412 #define hash_packet_unit_battlegroup_100 hash_const
18413 
18414 #define cmp_packet_unit_battlegroup_100 cmp_const
18415 
18416 BV_DEFINE(packet_unit_battlegroup_100_fields, 2);
18417 
receive_packet_unit_battlegroup_100(struct connection * pc)18418 static struct packet_unit_battlegroup *receive_packet_unit_battlegroup_100(struct connection *pc)
18419 {
18420   packet_unit_battlegroup_100_fields fields;
18421   struct packet_unit_battlegroup *old;
18422   struct genhash **hash = pc->phs.received + PACKET_UNIT_BATTLEGROUP;
18423   RECEIVE_PACKET_START(packet_unit_battlegroup, real_packet);
18424 
18425   DIO_BV_GET(&din, fields);
18426 
18427   log_packet_detailed("packet_unit_battlegroup_100: got info about ()");
18428 
18429   if (NULL == *hash) {
18430     *hash = genhash_new_full(hash_packet_unit_battlegroup_100, cmp_packet_unit_battlegroup_100,
18431                              NULL, NULL, NULL, free);
18432   }
18433 
18434   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
18435     *real_packet = *old;
18436   } else {
18437     log_packet_detailed("  no old info");
18438     memset(real_packet, 0, sizeof(*real_packet));
18439   }
18440 
18441   if (BV_ISSET(fields, 0)) {
18442     log_packet_detailed("  got field 'unit_id'");
18443     if (!DIO_GET(uint16, &din, "unit_id", &real_packet->unit_id)) {
18444       RECEIVE_PACKET_FIELD_ERROR(unit_id);
18445     }
18446   }
18447   if (BV_ISSET(fields, 1)) {
18448     log_packet_detailed("  got field 'battlegroup'");
18449     if (!DIO_GET(sint8, &din, "battlegroup", &real_packet->battlegroup)) {
18450       RECEIVE_PACKET_FIELD_ERROR(battlegroup);
18451     }
18452   }
18453 
18454   if (NULL == old) {
18455     old = fc_malloc(sizeof(*old));
18456     *old = *real_packet;
18457     genhash_insert(*hash, old, old);
18458   } else {
18459     *old = *real_packet;
18460   }
18461   RECEIVE_PACKET_END(real_packet);
18462 }
18463 
send_packet_unit_battlegroup_100(struct connection * pc,const struct packet_unit_battlegroup * packet)18464 static int send_packet_unit_battlegroup_100(struct connection *pc, const struct packet_unit_battlegroup *packet)
18465 {
18466   const struct packet_unit_battlegroup *real_packet = packet;
18467   packet_unit_battlegroup_100_fields fields;
18468   struct packet_unit_battlegroup *old;
18469   bool differ;
18470   struct genhash **hash = pc->phs.sent + PACKET_UNIT_BATTLEGROUP;
18471   int different = 0;
18472   SEND_PACKET_START(PACKET_UNIT_BATTLEGROUP);
18473 
18474   log_packet_detailed("packet_unit_battlegroup_100: sending info about ()");
18475 
18476   if (NULL == *hash) {
18477     *hash = genhash_new_full(hash_packet_unit_battlegroup_100, cmp_packet_unit_battlegroup_100,
18478                              NULL, NULL, NULL, free);
18479   }
18480   BV_CLR_ALL(fields);
18481 
18482   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
18483     old = fc_malloc(sizeof(*old));
18484     *old = *real_packet;
18485     genhash_insert(*hash, old, old);
18486     memset(old, 0, sizeof(*old));
18487     different = 1;      /* Force to send. */
18488   }
18489 
18490   differ = (old->unit_id != real_packet->unit_id);
18491   if (differ) {
18492     different++;
18493     BV_SET(fields, 0);
18494   }
18495 
18496   differ = (old->battlegroup != real_packet->battlegroup);
18497   if (differ) {
18498     different++;
18499     BV_SET(fields, 1);
18500   }
18501 
18502 
18503   DIO_BV_PUT(&dout, "fields", fields);
18504 
18505   if (BV_ISSET(fields, 0)) {
18506     log_packet_detailed("  field 'unit_id' has changed");
18507     DIO_PUT(uint16, &dout, "unit_id", real_packet->unit_id);
18508   }
18509   if (BV_ISSET(fields, 1)) {
18510     log_packet_detailed("  field 'battlegroup' has changed");
18511     DIO_PUT(sint8, &dout, "battlegroup", real_packet->battlegroup);
18512   }
18513 
18514   *old = *real_packet;
18515   SEND_PACKET_END(PACKET_UNIT_BATTLEGROUP);
18516 }
18517 
send_packet_unit_battlegroup(struct connection * pc,const struct packet_unit_battlegroup * packet)18518 int send_packet_unit_battlegroup(struct connection *pc, const struct packet_unit_battlegroup *packet)
18519 {
18520   if (!pc->used) {
18521     log_error("WARNING: trying to send data to the closed connection %s",
18522               conn_description(pc));
18523     return -1;
18524   }
18525   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_BATTLEGROUP].packet != NULL, -1,
18526                         "Handler for PACKET_UNIT_BATTLEGROUP not installed");
18527   return pc->phs.handlers->send[PACKET_UNIT_BATTLEGROUP].packet(pc, packet);
18528 }
18529 
dsend_packet_unit_battlegroup(struct connection * pc,int unit_id,int battlegroup)18530 int dsend_packet_unit_battlegroup(struct connection *pc, int unit_id, int battlegroup)
18531 {
18532   struct packet_unit_battlegroup packet, *real_packet = &packet;
18533 
18534   real_packet->unit_id = unit_id;
18535   real_packet->battlegroup = battlegroup;
18536 
18537   return send_packet_unit_battlegroup(pc, real_packet);
18538 }
18539 
18540 #define hash_packet_unit_orders_100 hash_const
18541 
18542 #define cmp_packet_unit_orders_100 cmp_const
18543 
18544 BV_DEFINE(packet_unit_orders_100_fields, 10);
18545 
receive_packet_unit_orders_100(struct connection * pc)18546 static struct packet_unit_orders *receive_packet_unit_orders_100(struct connection *pc)
18547 {
18548   packet_unit_orders_100_fields fields;
18549   struct packet_unit_orders *old;
18550   struct genhash **hash = pc->phs.received + PACKET_UNIT_ORDERS;
18551   RECEIVE_PACKET_START(packet_unit_orders, real_packet);
18552 
18553   DIO_BV_GET(&din, fields);
18554 
18555   log_packet_detailed("packet_unit_orders_100: got info about ()");
18556 
18557   if (NULL == *hash) {
18558     *hash = genhash_new_full(hash_packet_unit_orders_100, cmp_packet_unit_orders_100,
18559                              NULL, NULL, NULL, free);
18560   }
18561 
18562   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
18563     *real_packet = *old;
18564   } else {
18565     log_packet_detailed("  no old info");
18566     memset(real_packet, 0, sizeof(*real_packet));
18567   }
18568 
18569   if (BV_ISSET(fields, 0)) {
18570     log_packet_detailed("  got field 'unit_id'");
18571     if (!DIO_GET(uint16, &din, "unit_id", &real_packet->unit_id)) {
18572       RECEIVE_PACKET_FIELD_ERROR(unit_id);
18573     }
18574   }
18575   if (BV_ISSET(fields, 1)) {
18576     log_packet_detailed("  got field 'src_tile'");
18577     if (!DIO_GET(sint32, &din, "src_tile", &real_packet->src_tile)) {
18578       RECEIVE_PACKET_FIELD_ERROR(src_tile);
18579     }
18580   }
18581   if (BV_ISSET(fields, 2)) {
18582     log_packet_detailed("  got field 'length'");
18583     if (!DIO_GET(uint16, &din, "length", &real_packet->length)) {
18584       RECEIVE_PACKET_FIELD_ERROR(length);
18585     }
18586   }
18587   real_packet->repeat = BV_ISSET(fields, 3);
18588   real_packet->vigilant = BV_ISSET(fields, 4);
18589   if (BV_ISSET(fields, 5)) {
18590     log_packet_detailed("  got field 'orders'");
18591 
18592     {
18593       int i;
18594 
18595       if (real_packet->length > MAX_LEN_ROUTE) {
18596         RECEIVE_PACKET_FIELD_ERROR(orders, ": truncation array");
18597       }
18598       for (i = 0; i < real_packet->length; i++) {
18599         {
18600           int readin;
18601 
18602           if (!DIO_GET(uint8, &din, "orders", &readin)) {
18603             RECEIVE_PACKET_FIELD_ERROR(orders);
18604           }
18605           real_packet->orders[i] = readin;
18606         }
18607       }
18608     }
18609   }
18610   if (BV_ISSET(fields, 6)) {
18611     log_packet_detailed("  got field 'dir'");
18612 
18613     {
18614       int i;
18615 
18616       if (real_packet->length > MAX_LEN_ROUTE) {
18617         RECEIVE_PACKET_FIELD_ERROR(dir, ": truncation array");
18618       }
18619       for (i = 0; i < real_packet->length; i++) {
18620         {
18621           int readin;
18622 
18623           if (!DIO_GET(sint8, &din, "dir", &readin)) {
18624             RECEIVE_PACKET_FIELD_ERROR(dir);
18625           }
18626           real_packet->dir[i] = readin;
18627         }
18628       }
18629     }
18630   }
18631   if (BV_ISSET(fields, 7)) {
18632     log_packet_detailed("  got field 'activity'");
18633 
18634     {
18635       int i;
18636 
18637       if (real_packet->length > MAX_LEN_ROUTE) {
18638         RECEIVE_PACKET_FIELD_ERROR(activity, ": truncation array");
18639       }
18640       for (i = 0; i < real_packet->length; i++) {
18641         {
18642           int readin;
18643 
18644           if (!DIO_GET(uint8, &din, "activity", &readin)) {
18645             RECEIVE_PACKET_FIELD_ERROR(activity);
18646           }
18647           real_packet->activity[i] = readin;
18648         }
18649       }
18650     }
18651   }
18652   if (BV_ISSET(fields, 8)) {
18653     log_packet_detailed("  got field 'target'");
18654 
18655     {
18656       int i;
18657 
18658       if (real_packet->length > MAX_LEN_ROUTE) {
18659         RECEIVE_PACKET_FIELD_ERROR(target, ": truncation array");
18660       }
18661       for (i = 0; i < real_packet->length; i++) {
18662         if (!DIO_GET(sint8, &din, "target", &real_packet->target[i])) {
18663           RECEIVE_PACKET_FIELD_ERROR(target);
18664         }
18665       }
18666     }
18667   }
18668   if (BV_ISSET(fields, 9)) {
18669     log_packet_detailed("  got field 'dest_tile'");
18670     if (!DIO_GET(sint32, &din, "dest_tile", &real_packet->dest_tile)) {
18671       RECEIVE_PACKET_FIELD_ERROR(dest_tile);
18672     }
18673   }
18674 
18675   if (NULL == old) {
18676     old = fc_malloc(sizeof(*old));
18677     *old = *real_packet;
18678     genhash_insert(*hash, old, old);
18679   } else {
18680     *old = *real_packet;
18681   }
18682   RECEIVE_PACKET_END(real_packet);
18683 }
18684 
send_packet_unit_orders_100(struct connection * pc,const struct packet_unit_orders * packet)18685 static int send_packet_unit_orders_100(struct connection *pc, const struct packet_unit_orders *packet)
18686 {
18687   const struct packet_unit_orders *real_packet = packet;
18688   packet_unit_orders_100_fields fields;
18689   struct packet_unit_orders *old;
18690   bool differ;
18691   struct genhash **hash = pc->phs.sent + PACKET_UNIT_ORDERS;
18692   int different = 0;
18693   SEND_PACKET_START(PACKET_UNIT_ORDERS);
18694 
18695   log_packet_detailed("packet_unit_orders_100: sending info about ()");
18696 
18697   if (NULL == *hash) {
18698     *hash = genhash_new_full(hash_packet_unit_orders_100, cmp_packet_unit_orders_100,
18699                              NULL, NULL, NULL, free);
18700   }
18701   BV_CLR_ALL(fields);
18702 
18703   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
18704     old = fc_malloc(sizeof(*old));
18705     *old = *real_packet;
18706     genhash_insert(*hash, old, old);
18707     memset(old, 0, sizeof(*old));
18708     different = 1;      /* Force to send. */
18709   }
18710 
18711   differ = (old->unit_id != real_packet->unit_id);
18712   if (differ) {
18713     different++;
18714     BV_SET(fields, 0);
18715   }
18716 
18717   differ = (old->src_tile != real_packet->src_tile);
18718   if (differ) {
18719     different++;
18720     BV_SET(fields, 1);
18721   }
18722 
18723   differ = (old->length != real_packet->length);
18724   if (differ) {
18725     different++;
18726     BV_SET(fields, 2);
18727   }
18728 
18729   differ = (old->repeat != real_packet->repeat);
18730   if (differ) {
18731     different++;
18732   }
18733   if (packet->repeat) {
18734     BV_SET(fields, 3);
18735   }
18736 
18737   differ = (old->vigilant != real_packet->vigilant);
18738   if (differ) {
18739     different++;
18740   }
18741   if (packet->vigilant) {
18742     BV_SET(fields, 4);
18743   }
18744 
18745 
18746     {
18747       differ = (old->length != real_packet->length);
18748       if (!differ) {
18749         int i;
18750 
18751         for (i = 0; i < real_packet->length; i++) {
18752           if (old->orders[i] != real_packet->orders[i]) {
18753             differ = TRUE;
18754             break;
18755           }
18756         }
18757       }
18758     }
18759   if (differ) {
18760     different++;
18761     BV_SET(fields, 5);
18762   }
18763 
18764 
18765     {
18766       differ = (old->length != real_packet->length);
18767       if (!differ) {
18768         int i;
18769 
18770         for (i = 0; i < real_packet->length; i++) {
18771           if (old->dir[i] != real_packet->dir[i]) {
18772             differ = TRUE;
18773             break;
18774           }
18775         }
18776       }
18777     }
18778   if (differ) {
18779     different++;
18780     BV_SET(fields, 6);
18781   }
18782 
18783 
18784     {
18785       differ = (old->length != real_packet->length);
18786       if (!differ) {
18787         int i;
18788 
18789         for (i = 0; i < real_packet->length; i++) {
18790           if (old->activity[i] != real_packet->activity[i]) {
18791             differ = TRUE;
18792             break;
18793           }
18794         }
18795       }
18796     }
18797   if (differ) {
18798     different++;
18799     BV_SET(fields, 7);
18800   }
18801 
18802 
18803     {
18804       differ = (old->length != real_packet->length);
18805       if (!differ) {
18806         int i;
18807 
18808         for (i = 0; i < real_packet->length; i++) {
18809           if (old->target[i] != real_packet->target[i]) {
18810             differ = TRUE;
18811             break;
18812           }
18813         }
18814       }
18815     }
18816   if (differ) {
18817     different++;
18818     BV_SET(fields, 8);
18819   }
18820 
18821   differ = (old->dest_tile != real_packet->dest_tile);
18822   if (differ) {
18823     different++;
18824     BV_SET(fields, 9);
18825   }
18826 
18827 
18828   DIO_BV_PUT(&dout, "fields", fields);
18829 
18830   if (BV_ISSET(fields, 0)) {
18831     log_packet_detailed("  field 'unit_id' has changed");
18832     DIO_PUT(uint16, &dout, "unit_id", real_packet->unit_id);
18833   }
18834   if (BV_ISSET(fields, 1)) {
18835     log_packet_detailed("  field 'src_tile' has changed");
18836     DIO_PUT(sint32, &dout, "src_tile", real_packet->src_tile);
18837   }
18838   if (BV_ISSET(fields, 2)) {
18839     log_packet_detailed("  field 'length' has changed");
18840     DIO_PUT(uint16, &dout, "length", real_packet->length);
18841   }
18842   /* field 3 is folded into the header */
18843   /* field 4 is folded into the header */
18844   if (BV_ISSET(fields, 5)) {
18845     log_packet_detailed("  field 'orders' has changed");
18846 
18847     {
18848       int i;
18849 
18850       for (i = 0; i < real_packet->length; i++) {
18851         dio_put_uint8(&dout, real_packet->orders[i]);
18852       }
18853     }
18854   }
18855   if (BV_ISSET(fields, 6)) {
18856     log_packet_detailed("  field 'dir' has changed");
18857 
18858     {
18859       int i;
18860 
18861       for (i = 0; i < real_packet->length; i++) {
18862         dio_put_sint8(&dout, real_packet->dir[i]);
18863       }
18864     }
18865   }
18866   if (BV_ISSET(fields, 7)) {
18867     log_packet_detailed("  field 'activity' has changed");
18868 
18869     {
18870       int i;
18871 
18872       for (i = 0; i < real_packet->length; i++) {
18873         dio_put_uint8(&dout, real_packet->activity[i]);
18874       }
18875     }
18876   }
18877   if (BV_ISSET(fields, 8)) {
18878     log_packet_detailed("  field 'target' has changed");
18879 
18880     {
18881       int i;
18882 
18883       for (i = 0; i < real_packet->length; i++) {
18884         dio_put_sint8(&dout, real_packet->target[i]);
18885       }
18886     }
18887   }
18888   if (BV_ISSET(fields, 9)) {
18889     log_packet_detailed("  field 'dest_tile' has changed");
18890     DIO_PUT(sint32, &dout, "dest_tile", real_packet->dest_tile);
18891   }
18892 
18893   *old = *real_packet;
18894   SEND_PACKET_END(PACKET_UNIT_ORDERS);
18895 }
18896 
send_packet_unit_orders(struct connection * pc,const struct packet_unit_orders * packet)18897 int send_packet_unit_orders(struct connection *pc, const struct packet_unit_orders *packet)
18898 {
18899   if (!pc->used) {
18900     log_error("WARNING: trying to send data to the closed connection %s",
18901               conn_description(pc));
18902     return -1;
18903   }
18904   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_ORDERS].packet != NULL, -1,
18905                         "Handler for PACKET_UNIT_ORDERS not installed");
18906   return pc->phs.handlers->send[PACKET_UNIT_ORDERS].packet(pc, packet);
18907 }
18908 
18909 #define hash_packet_unit_autosettlers_100 hash_const
18910 
18911 #define cmp_packet_unit_autosettlers_100 cmp_const
18912 
18913 BV_DEFINE(packet_unit_autosettlers_100_fields, 1);
18914 
receive_packet_unit_autosettlers_100(struct connection * pc)18915 static struct packet_unit_autosettlers *receive_packet_unit_autosettlers_100(struct connection *pc)
18916 {
18917   packet_unit_autosettlers_100_fields fields;
18918   struct packet_unit_autosettlers *old;
18919   struct genhash **hash = pc->phs.received + PACKET_UNIT_AUTOSETTLERS;
18920   RECEIVE_PACKET_START(packet_unit_autosettlers, real_packet);
18921 
18922   DIO_BV_GET(&din, fields);
18923 
18924   log_packet_detailed("packet_unit_autosettlers_100: got info about ()");
18925 
18926   if (NULL == *hash) {
18927     *hash = genhash_new_full(hash_packet_unit_autosettlers_100, cmp_packet_unit_autosettlers_100,
18928                              NULL, NULL, NULL, free);
18929   }
18930 
18931   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
18932     *real_packet = *old;
18933   } else {
18934     log_packet_detailed("  no old info");
18935     memset(real_packet, 0, sizeof(*real_packet));
18936   }
18937 
18938   if (BV_ISSET(fields, 0)) {
18939     log_packet_detailed("  got field 'unit_id'");
18940     if (!DIO_GET(uint16, &din, "unit_id", &real_packet->unit_id)) {
18941       RECEIVE_PACKET_FIELD_ERROR(unit_id);
18942     }
18943   }
18944 
18945   if (NULL == old) {
18946     old = fc_malloc(sizeof(*old));
18947     *old = *real_packet;
18948     genhash_insert(*hash, old, old);
18949   } else {
18950     *old = *real_packet;
18951   }
18952   RECEIVE_PACKET_END(real_packet);
18953 }
18954 
send_packet_unit_autosettlers_100(struct connection * pc,const struct packet_unit_autosettlers * packet)18955 static int send_packet_unit_autosettlers_100(struct connection *pc, const struct packet_unit_autosettlers *packet)
18956 {
18957   const struct packet_unit_autosettlers *real_packet = packet;
18958   packet_unit_autosettlers_100_fields fields;
18959   struct packet_unit_autosettlers *old;
18960   bool differ;
18961   struct genhash **hash = pc->phs.sent + PACKET_UNIT_AUTOSETTLERS;
18962   int different = 0;
18963   SEND_PACKET_START(PACKET_UNIT_AUTOSETTLERS);
18964 
18965   log_packet_detailed("packet_unit_autosettlers_100: sending info about ()");
18966 
18967   if (NULL == *hash) {
18968     *hash = genhash_new_full(hash_packet_unit_autosettlers_100, cmp_packet_unit_autosettlers_100,
18969                              NULL, NULL, NULL, free);
18970   }
18971   BV_CLR_ALL(fields);
18972 
18973   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
18974     old = fc_malloc(sizeof(*old));
18975     *old = *real_packet;
18976     genhash_insert(*hash, old, old);
18977     memset(old, 0, sizeof(*old));
18978     different = 1;      /* Force to send. */
18979   }
18980 
18981   differ = (old->unit_id != real_packet->unit_id);
18982   if (differ) {
18983     different++;
18984     BV_SET(fields, 0);
18985   }
18986 
18987 
18988   DIO_BV_PUT(&dout, "fields", fields);
18989 
18990   if (BV_ISSET(fields, 0)) {
18991     log_packet_detailed("  field 'unit_id' has changed");
18992     DIO_PUT(uint16, &dout, "unit_id", real_packet->unit_id);
18993   }
18994 
18995   *old = *real_packet;
18996   SEND_PACKET_END(PACKET_UNIT_AUTOSETTLERS);
18997 }
18998 
send_packet_unit_autosettlers(struct connection * pc,const struct packet_unit_autosettlers * packet)18999 int send_packet_unit_autosettlers(struct connection *pc, const struct packet_unit_autosettlers *packet)
19000 {
19001   if (!pc->used) {
19002     log_error("WARNING: trying to send data to the closed connection %s",
19003               conn_description(pc));
19004     return -1;
19005   }
19006   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_AUTOSETTLERS].packet != NULL, -1,
19007                         "Handler for PACKET_UNIT_AUTOSETTLERS not installed");
19008   return pc->phs.handlers->send[PACKET_UNIT_AUTOSETTLERS].packet(pc, packet);
19009 }
19010 
dsend_packet_unit_autosettlers(struct connection * pc,int unit_id)19011 int dsend_packet_unit_autosettlers(struct connection *pc, int unit_id)
19012 {
19013   struct packet_unit_autosettlers packet, *real_packet = &packet;
19014 
19015   real_packet->unit_id = unit_id;
19016 
19017   return send_packet_unit_autosettlers(pc, real_packet);
19018 }
19019 
19020 #define hash_packet_unit_load_100 hash_const
19021 
19022 #define cmp_packet_unit_load_100 cmp_const
19023 
19024 BV_DEFINE(packet_unit_load_100_fields, 3);
19025 
receive_packet_unit_load_100(struct connection * pc)19026 static struct packet_unit_load *receive_packet_unit_load_100(struct connection *pc)
19027 {
19028   packet_unit_load_100_fields fields;
19029   struct packet_unit_load *old;
19030   struct genhash **hash = pc->phs.received + PACKET_UNIT_LOAD;
19031   RECEIVE_PACKET_START(packet_unit_load, real_packet);
19032 
19033   DIO_BV_GET(&din, fields);
19034 
19035   log_packet_detailed("packet_unit_load_100: got info about ()");
19036 
19037   if (NULL == *hash) {
19038     *hash = genhash_new_full(hash_packet_unit_load_100, cmp_packet_unit_load_100,
19039                              NULL, NULL, NULL, free);
19040   }
19041 
19042   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
19043     *real_packet = *old;
19044   } else {
19045     log_packet_detailed("  no old info");
19046     memset(real_packet, 0, sizeof(*real_packet));
19047   }
19048 
19049   if (BV_ISSET(fields, 0)) {
19050     log_packet_detailed("  got field 'cargo_id'");
19051     if (!DIO_GET(uint16, &din, "cargo_id", &real_packet->cargo_id)) {
19052       RECEIVE_PACKET_FIELD_ERROR(cargo_id);
19053     }
19054   }
19055   if (BV_ISSET(fields, 1)) {
19056     log_packet_detailed("  got field 'transporter_id'");
19057     if (!DIO_GET(uint16, &din, "transporter_id", &real_packet->transporter_id)) {
19058       RECEIVE_PACKET_FIELD_ERROR(transporter_id);
19059     }
19060   }
19061   if (BV_ISSET(fields, 2)) {
19062     log_packet_detailed("  got field 'transporter_tile'");
19063     if (!DIO_GET(sint32, &din, "transporter_tile", &real_packet->transporter_tile)) {
19064       RECEIVE_PACKET_FIELD_ERROR(transporter_tile);
19065     }
19066   }
19067 
19068   if (NULL == old) {
19069     old = fc_malloc(sizeof(*old));
19070     *old = *real_packet;
19071     genhash_insert(*hash, old, old);
19072   } else {
19073     *old = *real_packet;
19074   }
19075   RECEIVE_PACKET_END(real_packet);
19076 }
19077 
send_packet_unit_load_100(struct connection * pc,const struct packet_unit_load * packet)19078 static int send_packet_unit_load_100(struct connection *pc, const struct packet_unit_load *packet)
19079 {
19080   const struct packet_unit_load *real_packet = packet;
19081   packet_unit_load_100_fields fields;
19082   struct packet_unit_load *old;
19083   bool differ;
19084   struct genhash **hash = pc->phs.sent + PACKET_UNIT_LOAD;
19085   int different = 0;
19086   SEND_PACKET_START(PACKET_UNIT_LOAD);
19087 
19088   log_packet_detailed("packet_unit_load_100: sending info about ()");
19089 
19090   if (NULL == *hash) {
19091     *hash = genhash_new_full(hash_packet_unit_load_100, cmp_packet_unit_load_100,
19092                              NULL, NULL, NULL, free);
19093   }
19094   BV_CLR_ALL(fields);
19095 
19096   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
19097     old = fc_malloc(sizeof(*old));
19098     *old = *real_packet;
19099     genhash_insert(*hash, old, old);
19100     memset(old, 0, sizeof(*old));
19101     different = 1;      /* Force to send. */
19102   }
19103 
19104   differ = (old->cargo_id != real_packet->cargo_id);
19105   if (differ) {
19106     different++;
19107     BV_SET(fields, 0);
19108   }
19109 
19110   differ = (old->transporter_id != real_packet->transporter_id);
19111   if (differ) {
19112     different++;
19113     BV_SET(fields, 1);
19114   }
19115 
19116   differ = (old->transporter_tile != real_packet->transporter_tile);
19117   if (differ) {
19118     different++;
19119     BV_SET(fields, 2);
19120   }
19121 
19122 
19123   DIO_BV_PUT(&dout, "fields", fields);
19124 
19125   if (BV_ISSET(fields, 0)) {
19126     log_packet_detailed("  field 'cargo_id' has changed");
19127     DIO_PUT(uint16, &dout, "cargo_id", real_packet->cargo_id);
19128   }
19129   if (BV_ISSET(fields, 1)) {
19130     log_packet_detailed("  field 'transporter_id' has changed");
19131     DIO_PUT(uint16, &dout, "transporter_id", real_packet->transporter_id);
19132   }
19133   if (BV_ISSET(fields, 2)) {
19134     log_packet_detailed("  field 'transporter_tile' has changed");
19135     DIO_PUT(sint32, &dout, "transporter_tile", real_packet->transporter_tile);
19136   }
19137 
19138   *old = *real_packet;
19139   SEND_PACKET_END(PACKET_UNIT_LOAD);
19140 }
19141 
send_packet_unit_load(struct connection * pc,const struct packet_unit_load * packet)19142 int send_packet_unit_load(struct connection *pc, const struct packet_unit_load *packet)
19143 {
19144   if (!pc->used) {
19145     log_error("WARNING: trying to send data to the closed connection %s",
19146               conn_description(pc));
19147     return -1;
19148   }
19149   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_LOAD].packet != NULL, -1,
19150                         "Handler for PACKET_UNIT_LOAD not installed");
19151   return pc->phs.handlers->send[PACKET_UNIT_LOAD].packet(pc, packet);
19152 }
19153 
dsend_packet_unit_load(struct connection * pc,int cargo_id,int transporter_id,int transporter_tile)19154 int dsend_packet_unit_load(struct connection *pc, int cargo_id, int transporter_id, int transporter_tile)
19155 {
19156   struct packet_unit_load packet, *real_packet = &packet;
19157 
19158   real_packet->cargo_id = cargo_id;
19159   real_packet->transporter_id = transporter_id;
19160   real_packet->transporter_tile = transporter_tile;
19161 
19162   return send_packet_unit_load(pc, real_packet);
19163 }
19164 
19165 #define hash_packet_unit_unload_100 hash_const
19166 
19167 #define cmp_packet_unit_unload_100 cmp_const
19168 
19169 BV_DEFINE(packet_unit_unload_100_fields, 2);
19170 
receive_packet_unit_unload_100(struct connection * pc)19171 static struct packet_unit_unload *receive_packet_unit_unload_100(struct connection *pc)
19172 {
19173   packet_unit_unload_100_fields fields;
19174   struct packet_unit_unload *old;
19175   struct genhash **hash = pc->phs.received + PACKET_UNIT_UNLOAD;
19176   RECEIVE_PACKET_START(packet_unit_unload, real_packet);
19177 
19178   DIO_BV_GET(&din, fields);
19179 
19180   log_packet_detailed("packet_unit_unload_100: got info about ()");
19181 
19182   if (NULL == *hash) {
19183     *hash = genhash_new_full(hash_packet_unit_unload_100, cmp_packet_unit_unload_100,
19184                              NULL, NULL, NULL, free);
19185   }
19186 
19187   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
19188     *real_packet = *old;
19189   } else {
19190     log_packet_detailed("  no old info");
19191     memset(real_packet, 0, sizeof(*real_packet));
19192   }
19193 
19194   if (BV_ISSET(fields, 0)) {
19195     log_packet_detailed("  got field 'cargo_id'");
19196     if (!DIO_GET(uint16, &din, "cargo_id", &real_packet->cargo_id)) {
19197       RECEIVE_PACKET_FIELD_ERROR(cargo_id);
19198     }
19199   }
19200   if (BV_ISSET(fields, 1)) {
19201     log_packet_detailed("  got field 'transporter_id'");
19202     if (!DIO_GET(uint16, &din, "transporter_id", &real_packet->transporter_id)) {
19203       RECEIVE_PACKET_FIELD_ERROR(transporter_id);
19204     }
19205   }
19206 
19207   if (NULL == old) {
19208     old = fc_malloc(sizeof(*old));
19209     *old = *real_packet;
19210     genhash_insert(*hash, old, old);
19211   } else {
19212     *old = *real_packet;
19213   }
19214   RECEIVE_PACKET_END(real_packet);
19215 }
19216 
send_packet_unit_unload_100(struct connection * pc,const struct packet_unit_unload * packet)19217 static int send_packet_unit_unload_100(struct connection *pc, const struct packet_unit_unload *packet)
19218 {
19219   const struct packet_unit_unload *real_packet = packet;
19220   packet_unit_unload_100_fields fields;
19221   struct packet_unit_unload *old;
19222   bool differ;
19223   struct genhash **hash = pc->phs.sent + PACKET_UNIT_UNLOAD;
19224   int different = 0;
19225   SEND_PACKET_START(PACKET_UNIT_UNLOAD);
19226 
19227   log_packet_detailed("packet_unit_unload_100: sending info about ()");
19228 
19229   if (NULL == *hash) {
19230     *hash = genhash_new_full(hash_packet_unit_unload_100, cmp_packet_unit_unload_100,
19231                              NULL, NULL, NULL, free);
19232   }
19233   BV_CLR_ALL(fields);
19234 
19235   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
19236     old = fc_malloc(sizeof(*old));
19237     *old = *real_packet;
19238     genhash_insert(*hash, old, old);
19239     memset(old, 0, sizeof(*old));
19240     different = 1;      /* Force to send. */
19241   }
19242 
19243   differ = (old->cargo_id != real_packet->cargo_id);
19244   if (differ) {
19245     different++;
19246     BV_SET(fields, 0);
19247   }
19248 
19249   differ = (old->transporter_id != real_packet->transporter_id);
19250   if (differ) {
19251     different++;
19252     BV_SET(fields, 1);
19253   }
19254 
19255 
19256   DIO_BV_PUT(&dout, "fields", fields);
19257 
19258   if (BV_ISSET(fields, 0)) {
19259     log_packet_detailed("  field 'cargo_id' has changed");
19260     DIO_PUT(uint16, &dout, "cargo_id", real_packet->cargo_id);
19261   }
19262   if (BV_ISSET(fields, 1)) {
19263     log_packet_detailed("  field 'transporter_id' has changed");
19264     DIO_PUT(uint16, &dout, "transporter_id", real_packet->transporter_id);
19265   }
19266 
19267   *old = *real_packet;
19268   SEND_PACKET_END(PACKET_UNIT_UNLOAD);
19269 }
19270 
send_packet_unit_unload(struct connection * pc,const struct packet_unit_unload * packet)19271 int send_packet_unit_unload(struct connection *pc, const struct packet_unit_unload *packet)
19272 {
19273   if (!pc->used) {
19274     log_error("WARNING: trying to send data to the closed connection %s",
19275               conn_description(pc));
19276     return -1;
19277   }
19278   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_UNLOAD].packet != NULL, -1,
19279                         "Handler for PACKET_UNIT_UNLOAD not installed");
19280   return pc->phs.handlers->send[PACKET_UNIT_UNLOAD].packet(pc, packet);
19281 }
19282 
dsend_packet_unit_unload(struct connection * pc,int cargo_id,int transporter_id)19283 int dsend_packet_unit_unload(struct connection *pc, int cargo_id, int transporter_id)
19284 {
19285   struct packet_unit_unload packet, *real_packet = &packet;
19286 
19287   real_packet->cargo_id = cargo_id;
19288   real_packet->transporter_id = transporter_id;
19289 
19290   return send_packet_unit_unload(pc, real_packet);
19291 }
19292 
19293 #define hash_packet_unit_upgrade_100 hash_const
19294 
19295 #define cmp_packet_unit_upgrade_100 cmp_const
19296 
19297 BV_DEFINE(packet_unit_upgrade_100_fields, 1);
19298 
receive_packet_unit_upgrade_100(struct connection * pc)19299 static struct packet_unit_upgrade *receive_packet_unit_upgrade_100(struct connection *pc)
19300 {
19301   packet_unit_upgrade_100_fields fields;
19302   struct packet_unit_upgrade *old;
19303   struct genhash **hash = pc->phs.received + PACKET_UNIT_UPGRADE;
19304   RECEIVE_PACKET_START(packet_unit_upgrade, real_packet);
19305 
19306   DIO_BV_GET(&din, fields);
19307 
19308   log_packet_detailed("packet_unit_upgrade_100: got info about ()");
19309 
19310   if (NULL == *hash) {
19311     *hash = genhash_new_full(hash_packet_unit_upgrade_100, cmp_packet_unit_upgrade_100,
19312                              NULL, NULL, NULL, free);
19313   }
19314 
19315   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
19316     *real_packet = *old;
19317   } else {
19318     log_packet_detailed("  no old info");
19319     memset(real_packet, 0, sizeof(*real_packet));
19320   }
19321 
19322   if (BV_ISSET(fields, 0)) {
19323     log_packet_detailed("  got field 'unit_id'");
19324     if (!DIO_GET(uint16, &din, "unit_id", &real_packet->unit_id)) {
19325       RECEIVE_PACKET_FIELD_ERROR(unit_id);
19326     }
19327   }
19328 
19329   if (NULL == old) {
19330     old = fc_malloc(sizeof(*old));
19331     *old = *real_packet;
19332     genhash_insert(*hash, old, old);
19333   } else {
19334     *old = *real_packet;
19335   }
19336   RECEIVE_PACKET_END(real_packet);
19337 }
19338 
send_packet_unit_upgrade_100(struct connection * pc,const struct packet_unit_upgrade * packet)19339 static int send_packet_unit_upgrade_100(struct connection *pc, const struct packet_unit_upgrade *packet)
19340 {
19341   const struct packet_unit_upgrade *real_packet = packet;
19342   packet_unit_upgrade_100_fields fields;
19343   struct packet_unit_upgrade *old;
19344   bool differ;
19345   struct genhash **hash = pc->phs.sent + PACKET_UNIT_UPGRADE;
19346   int different = 0;
19347   SEND_PACKET_START(PACKET_UNIT_UPGRADE);
19348 
19349   log_packet_detailed("packet_unit_upgrade_100: sending info about ()");
19350 
19351   if (NULL == *hash) {
19352     *hash = genhash_new_full(hash_packet_unit_upgrade_100, cmp_packet_unit_upgrade_100,
19353                              NULL, NULL, NULL, free);
19354   }
19355   BV_CLR_ALL(fields);
19356 
19357   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
19358     old = fc_malloc(sizeof(*old));
19359     *old = *real_packet;
19360     genhash_insert(*hash, old, old);
19361     memset(old, 0, sizeof(*old));
19362     different = 1;      /* Force to send. */
19363   }
19364 
19365   differ = (old->unit_id != real_packet->unit_id);
19366   if (differ) {
19367     different++;
19368     BV_SET(fields, 0);
19369   }
19370 
19371 
19372   DIO_BV_PUT(&dout, "fields", fields);
19373 
19374   if (BV_ISSET(fields, 0)) {
19375     log_packet_detailed("  field 'unit_id' has changed");
19376     DIO_PUT(uint16, &dout, "unit_id", real_packet->unit_id);
19377   }
19378 
19379   *old = *real_packet;
19380   SEND_PACKET_END(PACKET_UNIT_UPGRADE);
19381 }
19382 
send_packet_unit_upgrade(struct connection * pc,const struct packet_unit_upgrade * packet)19383 int send_packet_unit_upgrade(struct connection *pc, const struct packet_unit_upgrade *packet)
19384 {
19385   if (!pc->used) {
19386     log_error("WARNING: trying to send data to the closed connection %s",
19387               conn_description(pc));
19388     return -1;
19389   }
19390   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_UPGRADE].packet != NULL, -1,
19391                         "Handler for PACKET_UNIT_UPGRADE not installed");
19392   return pc->phs.handlers->send[PACKET_UNIT_UPGRADE].packet(pc, packet);
19393 }
19394 
dsend_packet_unit_upgrade(struct connection * pc,int unit_id)19395 int dsend_packet_unit_upgrade(struct connection *pc, int unit_id)
19396 {
19397   struct packet_unit_upgrade packet, *real_packet = &packet;
19398 
19399   real_packet->unit_id = unit_id;
19400 
19401   return send_packet_unit_upgrade(pc, real_packet);
19402 }
19403 
19404 #define hash_packet_unit_nuke_100 hash_const
19405 
19406 #define cmp_packet_unit_nuke_100 cmp_const
19407 
19408 BV_DEFINE(packet_unit_nuke_100_fields, 1);
19409 
receive_packet_unit_nuke_100(struct connection * pc)19410 static struct packet_unit_nuke *receive_packet_unit_nuke_100(struct connection *pc)
19411 {
19412   packet_unit_nuke_100_fields fields;
19413   struct packet_unit_nuke *old;
19414   struct genhash **hash = pc->phs.received + PACKET_UNIT_NUKE;
19415   RECEIVE_PACKET_START(packet_unit_nuke, real_packet);
19416 
19417   DIO_BV_GET(&din, fields);
19418 
19419   log_packet_detailed("packet_unit_nuke_100: got info about ()");
19420 
19421   if (NULL == *hash) {
19422     *hash = genhash_new_full(hash_packet_unit_nuke_100, cmp_packet_unit_nuke_100,
19423                              NULL, NULL, NULL, free);
19424   }
19425 
19426   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
19427     *real_packet = *old;
19428   } else {
19429     log_packet_detailed("  no old info");
19430     memset(real_packet, 0, sizeof(*real_packet));
19431   }
19432 
19433   if (BV_ISSET(fields, 0)) {
19434     log_packet_detailed("  got field 'unit_id'");
19435     if (!DIO_GET(uint16, &din, "unit_id", &real_packet->unit_id)) {
19436       RECEIVE_PACKET_FIELD_ERROR(unit_id);
19437     }
19438   }
19439 
19440   if (NULL == old) {
19441     old = fc_malloc(sizeof(*old));
19442     *old = *real_packet;
19443     genhash_insert(*hash, old, old);
19444   } else {
19445     *old = *real_packet;
19446   }
19447   RECEIVE_PACKET_END(real_packet);
19448 }
19449 
send_packet_unit_nuke_100(struct connection * pc,const struct packet_unit_nuke * packet)19450 static int send_packet_unit_nuke_100(struct connection *pc, const struct packet_unit_nuke *packet)
19451 {
19452   const struct packet_unit_nuke *real_packet = packet;
19453   packet_unit_nuke_100_fields fields;
19454   struct packet_unit_nuke *old;
19455   bool differ;
19456   struct genhash **hash = pc->phs.sent + PACKET_UNIT_NUKE;
19457   int different = 0;
19458   SEND_PACKET_START(PACKET_UNIT_NUKE);
19459 
19460   log_packet_detailed("packet_unit_nuke_100: sending info about ()");
19461 
19462   if (NULL == *hash) {
19463     *hash = genhash_new_full(hash_packet_unit_nuke_100, cmp_packet_unit_nuke_100,
19464                              NULL, NULL, NULL, free);
19465   }
19466   BV_CLR_ALL(fields);
19467 
19468   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
19469     old = fc_malloc(sizeof(*old));
19470     *old = *real_packet;
19471     genhash_insert(*hash, old, old);
19472     memset(old, 0, sizeof(*old));
19473     different = 1;      /* Force to send. */
19474   }
19475 
19476   differ = (old->unit_id != real_packet->unit_id);
19477   if (differ) {
19478     different++;
19479     BV_SET(fields, 0);
19480   }
19481 
19482 
19483   DIO_BV_PUT(&dout, "fields", fields);
19484 
19485   if (BV_ISSET(fields, 0)) {
19486     log_packet_detailed("  field 'unit_id' has changed");
19487     DIO_PUT(uint16, &dout, "unit_id", real_packet->unit_id);
19488   }
19489 
19490   *old = *real_packet;
19491   SEND_PACKET_END(PACKET_UNIT_NUKE);
19492 }
19493 
send_packet_unit_nuke(struct connection * pc,const struct packet_unit_nuke * packet)19494 int send_packet_unit_nuke(struct connection *pc, const struct packet_unit_nuke *packet)
19495 {
19496   if (!pc->used) {
19497     log_error("WARNING: trying to send data to the closed connection %s",
19498               conn_description(pc));
19499     return -1;
19500   }
19501   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_NUKE].packet != NULL, -1,
19502                         "Handler for PACKET_UNIT_NUKE not installed");
19503   return pc->phs.handlers->send[PACKET_UNIT_NUKE].packet(pc, packet);
19504 }
19505 
dsend_packet_unit_nuke(struct connection * pc,int unit_id)19506 int dsend_packet_unit_nuke(struct connection *pc, int unit_id)
19507 {
19508   struct packet_unit_nuke packet, *real_packet = &packet;
19509 
19510   real_packet->unit_id = unit_id;
19511 
19512   return send_packet_unit_nuke(pc, real_packet);
19513 }
19514 
19515 #define hash_packet_unit_paradrop_to_100 hash_const
19516 
19517 #define cmp_packet_unit_paradrop_to_100 cmp_const
19518 
19519 BV_DEFINE(packet_unit_paradrop_to_100_fields, 2);
19520 
receive_packet_unit_paradrop_to_100(struct connection * pc)19521 static struct packet_unit_paradrop_to *receive_packet_unit_paradrop_to_100(struct connection *pc)
19522 {
19523   packet_unit_paradrop_to_100_fields fields;
19524   struct packet_unit_paradrop_to *old;
19525   struct genhash **hash = pc->phs.received + PACKET_UNIT_PARADROP_TO;
19526   RECEIVE_PACKET_START(packet_unit_paradrop_to, real_packet);
19527 
19528   DIO_BV_GET(&din, fields);
19529 
19530   log_packet_detailed("packet_unit_paradrop_to_100: got info about ()");
19531 
19532   if (NULL == *hash) {
19533     *hash = genhash_new_full(hash_packet_unit_paradrop_to_100, cmp_packet_unit_paradrop_to_100,
19534                              NULL, NULL, NULL, free);
19535   }
19536 
19537   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
19538     *real_packet = *old;
19539   } else {
19540     log_packet_detailed("  no old info");
19541     memset(real_packet, 0, sizeof(*real_packet));
19542   }
19543 
19544   if (BV_ISSET(fields, 0)) {
19545     log_packet_detailed("  got field 'unit_id'");
19546     if (!DIO_GET(uint16, &din, "unit_id", &real_packet->unit_id)) {
19547       RECEIVE_PACKET_FIELD_ERROR(unit_id);
19548     }
19549   }
19550   if (BV_ISSET(fields, 1)) {
19551     log_packet_detailed("  got field 'tile'");
19552     if (!DIO_GET(sint32, &din, "tile", &real_packet->tile)) {
19553       RECEIVE_PACKET_FIELD_ERROR(tile);
19554     }
19555   }
19556 
19557   if (NULL == old) {
19558     old = fc_malloc(sizeof(*old));
19559     *old = *real_packet;
19560     genhash_insert(*hash, old, old);
19561   } else {
19562     *old = *real_packet;
19563   }
19564   RECEIVE_PACKET_END(real_packet);
19565 }
19566 
send_packet_unit_paradrop_to_100(struct connection * pc,const struct packet_unit_paradrop_to * packet)19567 static int send_packet_unit_paradrop_to_100(struct connection *pc, const struct packet_unit_paradrop_to *packet)
19568 {
19569   const struct packet_unit_paradrop_to *real_packet = packet;
19570   packet_unit_paradrop_to_100_fields fields;
19571   struct packet_unit_paradrop_to *old;
19572   bool differ;
19573   struct genhash **hash = pc->phs.sent + PACKET_UNIT_PARADROP_TO;
19574   int different = 0;
19575   SEND_PACKET_START(PACKET_UNIT_PARADROP_TO);
19576 
19577   log_packet_detailed("packet_unit_paradrop_to_100: sending info about ()");
19578 
19579   if (NULL == *hash) {
19580     *hash = genhash_new_full(hash_packet_unit_paradrop_to_100, cmp_packet_unit_paradrop_to_100,
19581                              NULL, NULL, NULL, free);
19582   }
19583   BV_CLR_ALL(fields);
19584 
19585   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
19586     old = fc_malloc(sizeof(*old));
19587     *old = *real_packet;
19588     genhash_insert(*hash, old, old);
19589     memset(old, 0, sizeof(*old));
19590     different = 1;      /* Force to send. */
19591   }
19592 
19593   differ = (old->unit_id != real_packet->unit_id);
19594   if (differ) {
19595     different++;
19596     BV_SET(fields, 0);
19597   }
19598 
19599   differ = (old->tile != real_packet->tile);
19600   if (differ) {
19601     different++;
19602     BV_SET(fields, 1);
19603   }
19604 
19605 
19606   DIO_BV_PUT(&dout, "fields", fields);
19607 
19608   if (BV_ISSET(fields, 0)) {
19609     log_packet_detailed("  field 'unit_id' has changed");
19610     DIO_PUT(uint16, &dout, "unit_id", real_packet->unit_id);
19611   }
19612   if (BV_ISSET(fields, 1)) {
19613     log_packet_detailed("  field 'tile' has changed");
19614     DIO_PUT(sint32, &dout, "tile", real_packet->tile);
19615   }
19616 
19617   *old = *real_packet;
19618   SEND_PACKET_END(PACKET_UNIT_PARADROP_TO);
19619 }
19620 
send_packet_unit_paradrop_to(struct connection * pc,const struct packet_unit_paradrop_to * packet)19621 int send_packet_unit_paradrop_to(struct connection *pc, const struct packet_unit_paradrop_to *packet)
19622 {
19623   if (!pc->used) {
19624     log_error("WARNING: trying to send data to the closed connection %s",
19625               conn_description(pc));
19626     return -1;
19627   }
19628   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_PARADROP_TO].packet != NULL, -1,
19629                         "Handler for PACKET_UNIT_PARADROP_TO not installed");
19630   return pc->phs.handlers->send[PACKET_UNIT_PARADROP_TO].packet(pc, packet);
19631 }
19632 
dsend_packet_unit_paradrop_to(struct connection * pc,int unit_id,int tile)19633 int dsend_packet_unit_paradrop_to(struct connection *pc, int unit_id, int tile)
19634 {
19635   struct packet_unit_paradrop_to packet, *real_packet = &packet;
19636 
19637   real_packet->unit_id = unit_id;
19638   real_packet->tile = tile;
19639 
19640   return send_packet_unit_paradrop_to(pc, real_packet);
19641 }
19642 
19643 #define hash_packet_unit_airlift_100 hash_const
19644 
19645 #define cmp_packet_unit_airlift_100 cmp_const
19646 
19647 BV_DEFINE(packet_unit_airlift_100_fields, 2);
19648 
receive_packet_unit_airlift_100(struct connection * pc)19649 static struct packet_unit_airlift *receive_packet_unit_airlift_100(struct connection *pc)
19650 {
19651   packet_unit_airlift_100_fields fields;
19652   struct packet_unit_airlift *old;
19653   struct genhash **hash = pc->phs.received + PACKET_UNIT_AIRLIFT;
19654   RECEIVE_PACKET_START(packet_unit_airlift, real_packet);
19655 
19656   DIO_BV_GET(&din, fields);
19657 
19658   log_packet_detailed("packet_unit_airlift_100: got info about ()");
19659 
19660   if (NULL == *hash) {
19661     *hash = genhash_new_full(hash_packet_unit_airlift_100, cmp_packet_unit_airlift_100,
19662                              NULL, NULL, NULL, free);
19663   }
19664 
19665   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
19666     *real_packet = *old;
19667   } else {
19668     log_packet_detailed("  no old info");
19669     memset(real_packet, 0, sizeof(*real_packet));
19670   }
19671 
19672   if (BV_ISSET(fields, 0)) {
19673     log_packet_detailed("  got field 'unit_id'");
19674     if (!DIO_GET(uint16, &din, "unit_id", &real_packet->unit_id)) {
19675       RECEIVE_PACKET_FIELD_ERROR(unit_id);
19676     }
19677   }
19678   if (BV_ISSET(fields, 1)) {
19679     log_packet_detailed("  got field 'city_id'");
19680     if (!DIO_GET(uint16, &din, "city_id", &real_packet->city_id)) {
19681       RECEIVE_PACKET_FIELD_ERROR(city_id);
19682     }
19683   }
19684 
19685   if (NULL == old) {
19686     old = fc_malloc(sizeof(*old));
19687     *old = *real_packet;
19688     genhash_insert(*hash, old, old);
19689   } else {
19690     *old = *real_packet;
19691   }
19692   RECEIVE_PACKET_END(real_packet);
19693 }
19694 
send_packet_unit_airlift_100(struct connection * pc,const struct packet_unit_airlift * packet)19695 static int send_packet_unit_airlift_100(struct connection *pc, const struct packet_unit_airlift *packet)
19696 {
19697   const struct packet_unit_airlift *real_packet = packet;
19698   packet_unit_airlift_100_fields fields;
19699   struct packet_unit_airlift *old;
19700   bool differ;
19701   struct genhash **hash = pc->phs.sent + PACKET_UNIT_AIRLIFT;
19702   int different = 0;
19703   SEND_PACKET_START(PACKET_UNIT_AIRLIFT);
19704 
19705   log_packet_detailed("packet_unit_airlift_100: sending info about ()");
19706 
19707   if (NULL == *hash) {
19708     *hash = genhash_new_full(hash_packet_unit_airlift_100, cmp_packet_unit_airlift_100,
19709                              NULL, NULL, NULL, free);
19710   }
19711   BV_CLR_ALL(fields);
19712 
19713   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
19714     old = fc_malloc(sizeof(*old));
19715     *old = *real_packet;
19716     genhash_insert(*hash, old, old);
19717     memset(old, 0, sizeof(*old));
19718     different = 1;      /* Force to send. */
19719   }
19720 
19721   differ = (old->unit_id != real_packet->unit_id);
19722   if (differ) {
19723     different++;
19724     BV_SET(fields, 0);
19725   }
19726 
19727   differ = (old->city_id != real_packet->city_id);
19728   if (differ) {
19729     different++;
19730     BV_SET(fields, 1);
19731   }
19732 
19733 
19734   DIO_BV_PUT(&dout, "fields", fields);
19735 
19736   if (BV_ISSET(fields, 0)) {
19737     log_packet_detailed("  field 'unit_id' has changed");
19738     DIO_PUT(uint16, &dout, "unit_id", real_packet->unit_id);
19739   }
19740   if (BV_ISSET(fields, 1)) {
19741     log_packet_detailed("  field 'city_id' has changed");
19742     DIO_PUT(uint16, &dout, "city_id", real_packet->city_id);
19743   }
19744 
19745   *old = *real_packet;
19746   SEND_PACKET_END(PACKET_UNIT_AIRLIFT);
19747 }
19748 
send_packet_unit_airlift(struct connection * pc,const struct packet_unit_airlift * packet)19749 int send_packet_unit_airlift(struct connection *pc, const struct packet_unit_airlift *packet)
19750 {
19751   if (!pc->used) {
19752     log_error("WARNING: trying to send data to the closed connection %s",
19753               conn_description(pc));
19754     return -1;
19755   }
19756   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_AIRLIFT].packet != NULL, -1,
19757                         "Handler for PACKET_UNIT_AIRLIFT not installed");
19758   return pc->phs.handlers->send[PACKET_UNIT_AIRLIFT].packet(pc, packet);
19759 }
19760 
dsend_packet_unit_airlift(struct connection * pc,int unit_id,int city_id)19761 int dsend_packet_unit_airlift(struct connection *pc, int unit_id, int city_id)
19762 {
19763   struct packet_unit_airlift packet, *real_packet = &packet;
19764 
19765   real_packet->unit_id = unit_id;
19766   real_packet->city_id = city_id;
19767 
19768   return send_packet_unit_airlift(pc, real_packet);
19769 }
19770 
19771 #define hash_packet_unit_action_query_100 hash_const
19772 
19773 #define cmp_packet_unit_action_query_100 cmp_const
19774 
19775 BV_DEFINE(packet_unit_action_query_100_fields, 3);
19776 
receive_packet_unit_action_query_100(struct connection * pc)19777 static struct packet_unit_action_query *receive_packet_unit_action_query_100(struct connection *pc)
19778 {
19779   packet_unit_action_query_100_fields fields;
19780   struct packet_unit_action_query *old;
19781   struct genhash **hash = pc->phs.received + PACKET_UNIT_ACTION_QUERY;
19782   RECEIVE_PACKET_START(packet_unit_action_query, real_packet);
19783 
19784   DIO_BV_GET(&din, fields);
19785 
19786   log_packet_detailed("packet_unit_action_query_100: got info about ()");
19787 
19788   if (NULL == *hash) {
19789     *hash = genhash_new_full(hash_packet_unit_action_query_100, cmp_packet_unit_action_query_100,
19790                              NULL, NULL, NULL, free);
19791   }
19792 
19793   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
19794     *real_packet = *old;
19795   } else {
19796     log_packet_detailed("  no old info");
19797     memset(real_packet, 0, sizeof(*real_packet));
19798   }
19799 
19800   if (BV_ISSET(fields, 0)) {
19801     log_packet_detailed("  got field 'diplomat_id'");
19802     if (!DIO_GET(uint16, &din, "diplomat_id", &real_packet->diplomat_id)) {
19803       RECEIVE_PACKET_FIELD_ERROR(diplomat_id);
19804     }
19805   }
19806   if (BV_ISSET(fields, 1)) {
19807     log_packet_detailed("  got field 'target_id'");
19808     if (!DIO_GET(uint16, &din, "target_id", &real_packet->target_id)) {
19809       RECEIVE_PACKET_FIELD_ERROR(target_id);
19810     }
19811   }
19812   if (BV_ISSET(fields, 2)) {
19813     log_packet_detailed("  got field 'action_type'");
19814     {
19815       int readin;
19816 
19817       if (!DIO_GET(uint8, &din, "action_type", &readin)) {
19818         RECEIVE_PACKET_FIELD_ERROR(action_type);
19819       }
19820       real_packet->action_type = readin;
19821     }
19822   }
19823 
19824   if (NULL == old) {
19825     old = fc_malloc(sizeof(*old));
19826     *old = *real_packet;
19827     genhash_insert(*hash, old, old);
19828   } else {
19829     *old = *real_packet;
19830   }
19831   RECEIVE_PACKET_END(real_packet);
19832 }
19833 
send_packet_unit_action_query_100(struct connection * pc,const struct packet_unit_action_query * packet)19834 static int send_packet_unit_action_query_100(struct connection *pc, const struct packet_unit_action_query *packet)
19835 {
19836   const struct packet_unit_action_query *real_packet = packet;
19837   packet_unit_action_query_100_fields fields;
19838   struct packet_unit_action_query *old;
19839   bool differ;
19840   struct genhash **hash = pc->phs.sent + PACKET_UNIT_ACTION_QUERY;
19841   int different = 0;
19842   SEND_PACKET_START(PACKET_UNIT_ACTION_QUERY);
19843 
19844   log_packet_detailed("packet_unit_action_query_100: sending info about ()");
19845 
19846   if (NULL == *hash) {
19847     *hash = genhash_new_full(hash_packet_unit_action_query_100, cmp_packet_unit_action_query_100,
19848                              NULL, NULL, NULL, free);
19849   }
19850   BV_CLR_ALL(fields);
19851 
19852   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
19853     old = fc_malloc(sizeof(*old));
19854     *old = *real_packet;
19855     genhash_insert(*hash, old, old);
19856     memset(old, 0, sizeof(*old));
19857     different = 1;      /* Force to send. */
19858   }
19859 
19860   differ = (old->diplomat_id != real_packet->diplomat_id);
19861   if (differ) {
19862     different++;
19863     BV_SET(fields, 0);
19864   }
19865 
19866   differ = (old->target_id != real_packet->target_id);
19867   if (differ) {
19868     different++;
19869     BV_SET(fields, 1);
19870   }
19871 
19872   differ = (old->action_type != real_packet->action_type);
19873   if (differ) {
19874     different++;
19875     BV_SET(fields, 2);
19876   }
19877 
19878 
19879   DIO_BV_PUT(&dout, "fields", fields);
19880 
19881   if (BV_ISSET(fields, 0)) {
19882     log_packet_detailed("  field 'diplomat_id' has changed");
19883     DIO_PUT(uint16, &dout, "diplomat_id", real_packet->diplomat_id);
19884   }
19885   if (BV_ISSET(fields, 1)) {
19886     log_packet_detailed("  field 'target_id' has changed");
19887     DIO_PUT(uint16, &dout, "target_id", real_packet->target_id);
19888   }
19889   if (BV_ISSET(fields, 2)) {
19890     log_packet_detailed("  field 'action_type' has changed");
19891     DIO_PUT(uint8, &dout, "action_type", real_packet->action_type);
19892   }
19893 
19894   *old = *real_packet;
19895   SEND_PACKET_END(PACKET_UNIT_ACTION_QUERY);
19896 }
19897 
send_packet_unit_action_query(struct connection * pc,const struct packet_unit_action_query * packet)19898 int send_packet_unit_action_query(struct connection *pc, const struct packet_unit_action_query *packet)
19899 {
19900   if (!pc->used) {
19901     log_error("WARNING: trying to send data to the closed connection %s",
19902               conn_description(pc));
19903     return -1;
19904   }
19905   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_ACTION_QUERY].packet != NULL, -1,
19906                         "Handler for PACKET_UNIT_ACTION_QUERY not installed");
19907   return pc->phs.handlers->send[PACKET_UNIT_ACTION_QUERY].packet(pc, packet);
19908 }
19909 
dsend_packet_unit_action_query(struct connection * pc,int diplomat_id,int target_id,enum gen_action action_type)19910 int dsend_packet_unit_action_query(struct connection *pc, int diplomat_id, int target_id, enum gen_action action_type)
19911 {
19912   struct packet_unit_action_query packet, *real_packet = &packet;
19913 
19914   real_packet->diplomat_id = diplomat_id;
19915   real_packet->target_id = target_id;
19916   real_packet->action_type = action_type;
19917 
19918   return send_packet_unit_action_query(pc, real_packet);
19919 }
19920 
19921 #define hash_packet_unit_type_upgrade_100 hash_const
19922 
19923 #define cmp_packet_unit_type_upgrade_100 cmp_const
19924 
19925 BV_DEFINE(packet_unit_type_upgrade_100_fields, 1);
19926 
receive_packet_unit_type_upgrade_100(struct connection * pc)19927 static struct packet_unit_type_upgrade *receive_packet_unit_type_upgrade_100(struct connection *pc)
19928 {
19929   packet_unit_type_upgrade_100_fields fields;
19930   struct packet_unit_type_upgrade *old;
19931   struct genhash **hash = pc->phs.received + PACKET_UNIT_TYPE_UPGRADE;
19932   RECEIVE_PACKET_START(packet_unit_type_upgrade, real_packet);
19933 
19934   DIO_BV_GET(&din, fields);
19935 
19936   log_packet_detailed("packet_unit_type_upgrade_100: got info about ()");
19937 
19938   if (NULL == *hash) {
19939     *hash = genhash_new_full(hash_packet_unit_type_upgrade_100, cmp_packet_unit_type_upgrade_100,
19940                              NULL, NULL, NULL, free);
19941   }
19942 
19943   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
19944     *real_packet = *old;
19945   } else {
19946     log_packet_detailed("  no old info");
19947     memset(real_packet, 0, sizeof(*real_packet));
19948   }
19949 
19950   if (BV_ISSET(fields, 0)) {
19951     log_packet_detailed("  got field 'type'");
19952     {
19953       int readin;
19954 
19955       if (!DIO_GET(uint8, &din, "type", &readin)) {
19956         RECEIVE_PACKET_FIELD_ERROR(type);
19957       }
19958       real_packet->type = readin;
19959     }
19960   }
19961 
19962   if (NULL == old) {
19963     old = fc_malloc(sizeof(*old));
19964     *old = *real_packet;
19965     genhash_insert(*hash, old, old);
19966   } else {
19967     *old = *real_packet;
19968   }
19969   RECEIVE_PACKET_END(real_packet);
19970 }
19971 
send_packet_unit_type_upgrade_100(struct connection * pc,const struct packet_unit_type_upgrade * packet)19972 static int send_packet_unit_type_upgrade_100(struct connection *pc, const struct packet_unit_type_upgrade *packet)
19973 {
19974   const struct packet_unit_type_upgrade *real_packet = packet;
19975   packet_unit_type_upgrade_100_fields fields;
19976   struct packet_unit_type_upgrade *old;
19977   bool differ;
19978   struct genhash **hash = pc->phs.sent + PACKET_UNIT_TYPE_UPGRADE;
19979   int different = 0;
19980   SEND_PACKET_START(PACKET_UNIT_TYPE_UPGRADE);
19981 
19982   log_packet_detailed("packet_unit_type_upgrade_100: sending info about ()");
19983 
19984   if (NULL == *hash) {
19985     *hash = genhash_new_full(hash_packet_unit_type_upgrade_100, cmp_packet_unit_type_upgrade_100,
19986                              NULL, NULL, NULL, free);
19987   }
19988   BV_CLR_ALL(fields);
19989 
19990   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
19991     old = fc_malloc(sizeof(*old));
19992     *old = *real_packet;
19993     genhash_insert(*hash, old, old);
19994     memset(old, 0, sizeof(*old));
19995     different = 1;      /* Force to send. */
19996   }
19997 
19998   differ = (old->type != real_packet->type);
19999   if (differ) {
20000     different++;
20001     BV_SET(fields, 0);
20002   }
20003 
20004 
20005   DIO_BV_PUT(&dout, "fields", fields);
20006 
20007   if (BV_ISSET(fields, 0)) {
20008     log_packet_detailed("  field 'type' has changed");
20009     DIO_PUT(uint8, &dout, "type", real_packet->type);
20010   }
20011 
20012   *old = *real_packet;
20013   SEND_PACKET_END(PACKET_UNIT_TYPE_UPGRADE);
20014 }
20015 
send_packet_unit_type_upgrade(struct connection * pc,const struct packet_unit_type_upgrade * packet)20016 int send_packet_unit_type_upgrade(struct connection *pc, const struct packet_unit_type_upgrade *packet)
20017 {
20018   if (!pc->used) {
20019     log_error("WARNING: trying to send data to the closed connection %s",
20020               conn_description(pc));
20021     return -1;
20022   }
20023   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_TYPE_UPGRADE].packet != NULL, -1,
20024                         "Handler for PACKET_UNIT_TYPE_UPGRADE not installed");
20025   return pc->phs.handlers->send[PACKET_UNIT_TYPE_UPGRADE].packet(pc, packet);
20026 }
20027 
dsend_packet_unit_type_upgrade(struct connection * pc,Unit_type_id type)20028 int dsend_packet_unit_type_upgrade(struct connection *pc, Unit_type_id type)
20029 {
20030   struct packet_unit_type_upgrade packet, *real_packet = &packet;
20031 
20032   real_packet->type = type;
20033 
20034   return send_packet_unit_type_upgrade(pc, real_packet);
20035 }
20036 
20037 #define hash_packet_unit_do_action_100 hash_const
20038 
20039 #define cmp_packet_unit_do_action_100 cmp_const
20040 
20041 BV_DEFINE(packet_unit_do_action_100_fields, 4);
20042 
receive_packet_unit_do_action_100(struct connection * pc)20043 static struct packet_unit_do_action *receive_packet_unit_do_action_100(struct connection *pc)
20044 {
20045   packet_unit_do_action_100_fields fields;
20046   struct packet_unit_do_action *old;
20047   struct genhash **hash = pc->phs.received + PACKET_UNIT_DO_ACTION;
20048   RECEIVE_PACKET_START(packet_unit_do_action, real_packet);
20049 
20050   DIO_BV_GET(&din, fields);
20051 
20052   log_packet_detailed("packet_unit_do_action_100: got info about ()");
20053 
20054   if (NULL == *hash) {
20055     *hash = genhash_new_full(hash_packet_unit_do_action_100, cmp_packet_unit_do_action_100,
20056                              NULL, NULL, NULL, free);
20057   }
20058 
20059   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
20060     *real_packet = *old;
20061   } else {
20062     log_packet_detailed("  no old info");
20063     memset(real_packet, 0, sizeof(*real_packet));
20064   }
20065 
20066   if (BV_ISSET(fields, 0)) {
20067     log_packet_detailed("  got field 'actor_id'");
20068     if (!DIO_GET(uint16, &din, "actor_id", &real_packet->actor_id)) {
20069       RECEIVE_PACKET_FIELD_ERROR(actor_id);
20070     }
20071   }
20072   if (BV_ISSET(fields, 1)) {
20073     log_packet_detailed("  got field 'target_id'");
20074     if (!DIO_GET(sint32, &din, "target_id", &real_packet->target_id)) {
20075       RECEIVE_PACKET_FIELD_ERROR(target_id);
20076     }
20077   }
20078   if (BV_ISSET(fields, 2)) {
20079     log_packet_detailed("  got field 'value'");
20080     if (!DIO_GET(sint16, &din, "value", &real_packet->value)) {
20081       RECEIVE_PACKET_FIELD_ERROR(value);
20082     }
20083   }
20084   if (BV_ISSET(fields, 3)) {
20085     log_packet_detailed("  got field 'action_type'");
20086     {
20087       int readin;
20088 
20089       if (!DIO_GET(uint8, &din, "action_type", &readin)) {
20090         RECEIVE_PACKET_FIELD_ERROR(action_type);
20091       }
20092       real_packet->action_type = readin;
20093     }
20094   }
20095 
20096   if (NULL == old) {
20097     old = fc_malloc(sizeof(*old));
20098     *old = *real_packet;
20099     genhash_insert(*hash, old, old);
20100   } else {
20101     *old = *real_packet;
20102   }
20103   RECEIVE_PACKET_END(real_packet);
20104 }
20105 
send_packet_unit_do_action_100(struct connection * pc,const struct packet_unit_do_action * packet)20106 static int send_packet_unit_do_action_100(struct connection *pc, const struct packet_unit_do_action *packet)
20107 {
20108   const struct packet_unit_do_action *real_packet = packet;
20109   packet_unit_do_action_100_fields fields;
20110   struct packet_unit_do_action *old;
20111   bool differ;
20112   struct genhash **hash = pc->phs.sent + PACKET_UNIT_DO_ACTION;
20113   int different = 0;
20114   SEND_PACKET_START(PACKET_UNIT_DO_ACTION);
20115 
20116   log_packet_detailed("packet_unit_do_action_100: sending info about ()");
20117 
20118   if (NULL == *hash) {
20119     *hash = genhash_new_full(hash_packet_unit_do_action_100, cmp_packet_unit_do_action_100,
20120                              NULL, NULL, NULL, free);
20121   }
20122   BV_CLR_ALL(fields);
20123 
20124   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
20125     old = fc_malloc(sizeof(*old));
20126     *old = *real_packet;
20127     genhash_insert(*hash, old, old);
20128     memset(old, 0, sizeof(*old));
20129     different = 1;      /* Force to send. */
20130   }
20131 
20132   differ = (old->actor_id != real_packet->actor_id);
20133   if (differ) {
20134     different++;
20135     BV_SET(fields, 0);
20136   }
20137 
20138   differ = (old->target_id != real_packet->target_id);
20139   if (differ) {
20140     different++;
20141     BV_SET(fields, 1);
20142   }
20143 
20144   differ = (old->value != real_packet->value);
20145   if (differ) {
20146     different++;
20147     BV_SET(fields, 2);
20148   }
20149 
20150   differ = (old->action_type != real_packet->action_type);
20151   if (differ) {
20152     different++;
20153     BV_SET(fields, 3);
20154   }
20155 
20156 
20157   DIO_BV_PUT(&dout, "fields", fields);
20158 
20159   if (BV_ISSET(fields, 0)) {
20160     log_packet_detailed("  field 'actor_id' has changed");
20161     DIO_PUT(uint16, &dout, "actor_id", real_packet->actor_id);
20162   }
20163   if (BV_ISSET(fields, 1)) {
20164     log_packet_detailed("  field 'target_id' has changed");
20165     DIO_PUT(sint32, &dout, "target_id", real_packet->target_id);
20166   }
20167   if (BV_ISSET(fields, 2)) {
20168     log_packet_detailed("  field 'value' has changed");
20169     DIO_PUT(sint16, &dout, "value", real_packet->value);
20170   }
20171   if (BV_ISSET(fields, 3)) {
20172     log_packet_detailed("  field 'action_type' has changed");
20173     DIO_PUT(uint8, &dout, "action_type", real_packet->action_type);
20174   }
20175 
20176   *old = *real_packet;
20177   SEND_PACKET_END(PACKET_UNIT_DO_ACTION);
20178 }
20179 
send_packet_unit_do_action(struct connection * pc,const struct packet_unit_do_action * packet)20180 int send_packet_unit_do_action(struct connection *pc, const struct packet_unit_do_action *packet)
20181 {
20182   if (!pc->used) {
20183     log_error("WARNING: trying to send data to the closed connection %s",
20184               conn_description(pc));
20185     return -1;
20186   }
20187   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_DO_ACTION].packet != NULL, -1,
20188                         "Handler for PACKET_UNIT_DO_ACTION not installed");
20189   return pc->phs.handlers->send[PACKET_UNIT_DO_ACTION].packet(pc, packet);
20190 }
20191 
dsend_packet_unit_do_action(struct connection * pc,int actor_id,int target_id,int value,enum gen_action action_type)20192 int dsend_packet_unit_do_action(struct connection *pc, int actor_id, int target_id, int value, enum gen_action action_type)
20193 {
20194   struct packet_unit_do_action packet, *real_packet = &packet;
20195 
20196   real_packet->actor_id = actor_id;
20197   real_packet->target_id = target_id;
20198   real_packet->value = value;
20199   real_packet->action_type = action_type;
20200 
20201   return send_packet_unit_do_action(pc, real_packet);
20202 }
20203 
20204 #define hash_packet_unit_action_answer_100 hash_const
20205 
20206 #define cmp_packet_unit_action_answer_100 cmp_const
20207 
20208 BV_DEFINE(packet_unit_action_answer_100_fields, 4);
20209 
receive_packet_unit_action_answer_100(struct connection * pc)20210 static struct packet_unit_action_answer *receive_packet_unit_action_answer_100(struct connection *pc)
20211 {
20212   packet_unit_action_answer_100_fields fields;
20213   struct packet_unit_action_answer *old;
20214   struct genhash **hash = pc->phs.received + PACKET_UNIT_ACTION_ANSWER;
20215   RECEIVE_PACKET_START(packet_unit_action_answer, real_packet);
20216 
20217   DIO_BV_GET(&din, fields);
20218 
20219   log_packet_detailed("packet_unit_action_answer_100: got info about ()");
20220 
20221   if (NULL == *hash) {
20222     *hash = genhash_new_full(hash_packet_unit_action_answer_100, cmp_packet_unit_action_answer_100,
20223                              NULL, NULL, NULL, free);
20224   }
20225 
20226   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
20227     *real_packet = *old;
20228   } else {
20229     log_packet_detailed("  no old info");
20230     memset(real_packet, 0, sizeof(*real_packet));
20231   }
20232 
20233   if (BV_ISSET(fields, 0)) {
20234     log_packet_detailed("  got field 'diplomat_id'");
20235     if (!DIO_GET(uint16, &din, "diplomat_id", &real_packet->diplomat_id)) {
20236       RECEIVE_PACKET_FIELD_ERROR(diplomat_id);
20237     }
20238   }
20239   if (BV_ISSET(fields, 1)) {
20240     log_packet_detailed("  got field 'target_id'");
20241     if (!DIO_GET(uint16, &din, "target_id", &real_packet->target_id)) {
20242       RECEIVE_PACKET_FIELD_ERROR(target_id);
20243     }
20244   }
20245   if (BV_ISSET(fields, 2)) {
20246     log_packet_detailed("  got field 'cost'");
20247     if (!DIO_GET(uint32, &din, "cost", &real_packet->cost)) {
20248       RECEIVE_PACKET_FIELD_ERROR(cost);
20249     }
20250   }
20251   if (BV_ISSET(fields, 3)) {
20252     log_packet_detailed("  got field 'action_type'");
20253     {
20254       int readin;
20255 
20256       if (!DIO_GET(uint8, &din, "action_type", &readin)) {
20257         RECEIVE_PACKET_FIELD_ERROR(action_type);
20258       }
20259       real_packet->action_type = readin;
20260     }
20261   }
20262 
20263   if (NULL == old) {
20264     old = fc_malloc(sizeof(*old));
20265     *old = *real_packet;
20266     genhash_insert(*hash, old, old);
20267   } else {
20268     *old = *real_packet;
20269   }
20270   RECEIVE_PACKET_END(real_packet);
20271 }
20272 
send_packet_unit_action_answer_100(struct connection * pc,const struct packet_unit_action_answer * packet)20273 static int send_packet_unit_action_answer_100(struct connection *pc, const struct packet_unit_action_answer *packet)
20274 {
20275   const struct packet_unit_action_answer *real_packet = packet;
20276   packet_unit_action_answer_100_fields fields;
20277   struct packet_unit_action_answer *old;
20278   bool differ;
20279   struct genhash **hash = pc->phs.sent + PACKET_UNIT_ACTION_ANSWER;
20280   int different = 0;
20281   SEND_PACKET_START(PACKET_UNIT_ACTION_ANSWER);
20282 
20283   log_packet_detailed("packet_unit_action_answer_100: sending info about ()");
20284 
20285   if (NULL == *hash) {
20286     *hash = genhash_new_full(hash_packet_unit_action_answer_100, cmp_packet_unit_action_answer_100,
20287                              NULL, NULL, NULL, free);
20288   }
20289   BV_CLR_ALL(fields);
20290 
20291   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
20292     old = fc_malloc(sizeof(*old));
20293     *old = *real_packet;
20294     genhash_insert(*hash, old, old);
20295     memset(old, 0, sizeof(*old));
20296     different = 1;      /* Force to send. */
20297   }
20298 
20299   differ = (old->diplomat_id != real_packet->diplomat_id);
20300   if (differ) {
20301     different++;
20302     BV_SET(fields, 0);
20303   }
20304 
20305   differ = (old->target_id != real_packet->target_id);
20306   if (differ) {
20307     different++;
20308     BV_SET(fields, 1);
20309   }
20310 
20311   differ = (old->cost != real_packet->cost);
20312   if (differ) {
20313     different++;
20314     BV_SET(fields, 2);
20315   }
20316 
20317   differ = (old->action_type != real_packet->action_type);
20318   if (differ) {
20319     different++;
20320     BV_SET(fields, 3);
20321   }
20322 
20323 
20324   DIO_BV_PUT(&dout, "fields", fields);
20325 
20326   if (BV_ISSET(fields, 0)) {
20327     log_packet_detailed("  field 'diplomat_id' has changed");
20328     DIO_PUT(uint16, &dout, "diplomat_id", real_packet->diplomat_id);
20329   }
20330   if (BV_ISSET(fields, 1)) {
20331     log_packet_detailed("  field 'target_id' has changed");
20332     DIO_PUT(uint16, &dout, "target_id", real_packet->target_id);
20333   }
20334   if (BV_ISSET(fields, 2)) {
20335     log_packet_detailed("  field 'cost' has changed");
20336     DIO_PUT(uint32, &dout, "cost", real_packet->cost);
20337   }
20338   if (BV_ISSET(fields, 3)) {
20339     log_packet_detailed("  field 'action_type' has changed");
20340     DIO_PUT(uint8, &dout, "action_type", real_packet->action_type);
20341   }
20342 
20343   *old = *real_packet;
20344   SEND_PACKET_END(PACKET_UNIT_ACTION_ANSWER);
20345 }
20346 
send_packet_unit_action_answer(struct connection * pc,const struct packet_unit_action_answer * packet)20347 int send_packet_unit_action_answer(struct connection *pc, const struct packet_unit_action_answer *packet)
20348 {
20349   if (!pc->used) {
20350     log_error("WARNING: trying to send data to the closed connection %s",
20351               conn_description(pc));
20352     return -1;
20353   }
20354   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_ACTION_ANSWER].packet != NULL, -1,
20355                         "Handler for PACKET_UNIT_ACTION_ANSWER not installed");
20356   return pc->phs.handlers->send[PACKET_UNIT_ACTION_ANSWER].packet(pc, packet);
20357 }
20358 
dsend_packet_unit_action_answer(struct connection * pc,int diplomat_id,int target_id,int cost,enum gen_action action_type)20359 int dsend_packet_unit_action_answer(struct connection *pc, int diplomat_id, int target_id, int cost, enum gen_action action_type)
20360 {
20361   struct packet_unit_action_answer packet, *real_packet = &packet;
20362 
20363   real_packet->diplomat_id = diplomat_id;
20364   real_packet->target_id = target_id;
20365   real_packet->cost = cost;
20366   real_packet->action_type = action_type;
20367 
20368   return send_packet_unit_action_answer(pc, real_packet);
20369 }
20370 
20371 #define hash_packet_unit_get_actions_100 hash_const
20372 
20373 #define cmp_packet_unit_get_actions_100 cmp_const
20374 
20375 BV_DEFINE(packet_unit_get_actions_100_fields, 5);
20376 
receive_packet_unit_get_actions_100(struct connection * pc)20377 static struct packet_unit_get_actions *receive_packet_unit_get_actions_100(struct connection *pc)
20378 {
20379   packet_unit_get_actions_100_fields fields;
20380   struct packet_unit_get_actions *old;
20381   struct genhash **hash = pc->phs.received + PACKET_UNIT_GET_ACTIONS;
20382   RECEIVE_PACKET_START(packet_unit_get_actions, real_packet);
20383 
20384   DIO_BV_GET(&din, fields);
20385 
20386   log_packet_detailed("packet_unit_get_actions_100: got info about ()");
20387 
20388   if (NULL == *hash) {
20389     *hash = genhash_new_full(hash_packet_unit_get_actions_100, cmp_packet_unit_get_actions_100,
20390                              NULL, NULL, NULL, free);
20391   }
20392 
20393   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
20394     *real_packet = *old;
20395   } else {
20396     log_packet_detailed("  no old info");
20397     memset(real_packet, 0, sizeof(*real_packet));
20398   }
20399 
20400   if (BV_ISSET(fields, 0)) {
20401     log_packet_detailed("  got field 'actor_unit_id'");
20402     if (!DIO_GET(uint16, &din, "actor_unit_id", &real_packet->actor_unit_id)) {
20403       RECEIVE_PACKET_FIELD_ERROR(actor_unit_id);
20404     }
20405   }
20406   if (BV_ISSET(fields, 1)) {
20407     log_packet_detailed("  got field 'target_unit_id'");
20408     if (!DIO_GET(uint16, &din, "target_unit_id", &real_packet->target_unit_id)) {
20409       RECEIVE_PACKET_FIELD_ERROR(target_unit_id);
20410     }
20411   }
20412   if (BV_ISSET(fields, 2)) {
20413     log_packet_detailed("  got field 'target_city_id'");
20414     if (!DIO_GET(uint16, &din, "target_city_id", &real_packet->target_city_id)) {
20415       RECEIVE_PACKET_FIELD_ERROR(target_city_id);
20416     }
20417   }
20418   if (BV_ISSET(fields, 3)) {
20419     log_packet_detailed("  got field 'target_tile_id'");
20420     if (!DIO_GET(sint32, &din, "target_tile_id", &real_packet->target_tile_id)) {
20421       RECEIVE_PACKET_FIELD_ERROR(target_tile_id);
20422     }
20423   }
20424   real_packet->disturb_player = BV_ISSET(fields, 4);
20425 
20426   if (NULL == old) {
20427     old = fc_malloc(sizeof(*old));
20428     *old = *real_packet;
20429     genhash_insert(*hash, old, old);
20430   } else {
20431     *old = *real_packet;
20432   }
20433   RECEIVE_PACKET_END(real_packet);
20434 }
20435 
send_packet_unit_get_actions_100(struct connection * pc,const struct packet_unit_get_actions * packet)20436 static int send_packet_unit_get_actions_100(struct connection *pc, const struct packet_unit_get_actions *packet)
20437 {
20438   const struct packet_unit_get_actions *real_packet = packet;
20439   packet_unit_get_actions_100_fields fields;
20440   struct packet_unit_get_actions *old;
20441   bool differ;
20442   struct genhash **hash = pc->phs.sent + PACKET_UNIT_GET_ACTIONS;
20443   int different = 0;
20444   SEND_PACKET_START(PACKET_UNIT_GET_ACTIONS);
20445 
20446   log_packet_detailed("packet_unit_get_actions_100: sending info about ()");
20447 
20448   if (NULL == *hash) {
20449     *hash = genhash_new_full(hash_packet_unit_get_actions_100, cmp_packet_unit_get_actions_100,
20450                              NULL, NULL, NULL, free);
20451   }
20452   BV_CLR_ALL(fields);
20453 
20454   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
20455     old = fc_malloc(sizeof(*old));
20456     *old = *real_packet;
20457     genhash_insert(*hash, old, old);
20458     memset(old, 0, sizeof(*old));
20459     different = 1;      /* Force to send. */
20460   }
20461 
20462   differ = (old->actor_unit_id != real_packet->actor_unit_id);
20463   if (differ) {
20464     different++;
20465     BV_SET(fields, 0);
20466   }
20467 
20468   differ = (old->target_unit_id != real_packet->target_unit_id);
20469   if (differ) {
20470     different++;
20471     BV_SET(fields, 1);
20472   }
20473 
20474   differ = (old->target_city_id != real_packet->target_city_id);
20475   if (differ) {
20476     different++;
20477     BV_SET(fields, 2);
20478   }
20479 
20480   differ = (old->target_tile_id != real_packet->target_tile_id);
20481   if (differ) {
20482     different++;
20483     BV_SET(fields, 3);
20484   }
20485 
20486   differ = (old->disturb_player != real_packet->disturb_player);
20487   if (differ) {
20488     different++;
20489   }
20490   if (packet->disturb_player) {
20491     BV_SET(fields, 4);
20492   }
20493 
20494 
20495   DIO_BV_PUT(&dout, "fields", fields);
20496 
20497   if (BV_ISSET(fields, 0)) {
20498     log_packet_detailed("  field 'actor_unit_id' has changed");
20499     DIO_PUT(uint16, &dout, "actor_unit_id", real_packet->actor_unit_id);
20500   }
20501   if (BV_ISSET(fields, 1)) {
20502     log_packet_detailed("  field 'target_unit_id' has changed");
20503     DIO_PUT(uint16, &dout, "target_unit_id", real_packet->target_unit_id);
20504   }
20505   if (BV_ISSET(fields, 2)) {
20506     log_packet_detailed("  field 'target_city_id' has changed");
20507     DIO_PUT(uint16, &dout, "target_city_id", real_packet->target_city_id);
20508   }
20509   if (BV_ISSET(fields, 3)) {
20510     log_packet_detailed("  field 'target_tile_id' has changed");
20511     DIO_PUT(sint32, &dout, "target_tile_id", real_packet->target_tile_id);
20512   }
20513   /* field 4 is folded into the header */
20514 
20515   *old = *real_packet;
20516   SEND_PACKET_END(PACKET_UNIT_GET_ACTIONS);
20517 }
20518 
send_packet_unit_get_actions(struct connection * pc,const struct packet_unit_get_actions * packet)20519 int send_packet_unit_get_actions(struct connection *pc, const struct packet_unit_get_actions *packet)
20520 {
20521   if (!pc->used) {
20522     log_error("WARNING: trying to send data to the closed connection %s",
20523               conn_description(pc));
20524     return -1;
20525   }
20526   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_GET_ACTIONS].packet != NULL, -1,
20527                         "Handler for PACKET_UNIT_GET_ACTIONS not installed");
20528   return pc->phs.handlers->send[PACKET_UNIT_GET_ACTIONS].packet(pc, packet);
20529 }
20530 
dsend_packet_unit_get_actions(struct connection * pc,int actor_unit_id,int target_unit_id,int target_city_id,int target_tile_id,bool disturb_player)20531 int dsend_packet_unit_get_actions(struct connection *pc, int actor_unit_id, int target_unit_id, int target_city_id, int target_tile_id, bool disturb_player)
20532 {
20533   struct packet_unit_get_actions packet, *real_packet = &packet;
20534 
20535   real_packet->actor_unit_id = actor_unit_id;
20536   real_packet->target_unit_id = target_unit_id;
20537   real_packet->target_city_id = target_city_id;
20538   real_packet->target_tile_id = target_tile_id;
20539   real_packet->disturb_player = disturb_player;
20540 
20541   return send_packet_unit_get_actions(pc, real_packet);
20542 }
20543 
20544 #define hash_packet_unit_actions_100 hash_const
20545 
20546 #define cmp_packet_unit_actions_100 cmp_const
20547 
20548 BV_DEFINE(packet_unit_actions_100_fields, 6);
20549 
receive_packet_unit_actions_100(struct connection * pc)20550 static struct packet_unit_actions *receive_packet_unit_actions_100(struct connection *pc)
20551 {
20552   packet_unit_actions_100_fields fields;
20553   struct packet_unit_actions *old;
20554   struct genhash **hash = pc->phs.received + PACKET_UNIT_ACTIONS;
20555   RECEIVE_PACKET_START(packet_unit_actions, real_packet);
20556 
20557   DIO_BV_GET(&din, fields);
20558 
20559   log_packet_detailed("packet_unit_actions_100: got info about ()");
20560 
20561   if (NULL == *hash) {
20562     *hash = genhash_new_full(hash_packet_unit_actions_100, cmp_packet_unit_actions_100,
20563                              NULL, NULL, NULL, free);
20564   }
20565 
20566   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
20567     *real_packet = *old;
20568   } else {
20569     log_packet_detailed("  no old info");
20570     memset(real_packet, 0, sizeof(*real_packet));
20571   }
20572 
20573   if (BV_ISSET(fields, 0)) {
20574     log_packet_detailed("  got field 'actor_unit_id'");
20575     if (!DIO_GET(uint16, &din, "actor_unit_id", &real_packet->actor_unit_id)) {
20576       RECEIVE_PACKET_FIELD_ERROR(actor_unit_id);
20577     }
20578   }
20579   if (BV_ISSET(fields, 1)) {
20580     log_packet_detailed("  got field 'target_unit_id'");
20581     if (!DIO_GET(uint16, &din, "target_unit_id", &real_packet->target_unit_id)) {
20582       RECEIVE_PACKET_FIELD_ERROR(target_unit_id);
20583     }
20584   }
20585   if (BV_ISSET(fields, 2)) {
20586     log_packet_detailed("  got field 'target_city_id'");
20587     if (!DIO_GET(uint16, &din, "target_city_id", &real_packet->target_city_id)) {
20588       RECEIVE_PACKET_FIELD_ERROR(target_city_id);
20589     }
20590   }
20591   if (BV_ISSET(fields, 3)) {
20592     log_packet_detailed("  got field 'target_tile_id'");
20593     if (!DIO_GET(sint32, &din, "target_tile_id", &real_packet->target_tile_id)) {
20594       RECEIVE_PACKET_FIELD_ERROR(target_tile_id);
20595     }
20596   }
20597   real_packet->disturb_player = BV_ISSET(fields, 4);
20598   if (BV_ISSET(fields, 5)) {
20599     log_packet_detailed("  got field 'action_probabilities'");
20600 
20601     {
20602       int i;
20603 
20604       for (i = 0; i < ACTION_COUNT; i++) {
20605         if (!DIO_GET(action_probability, &din, "action_probabilities", &real_packet->action_probabilities[i])) {
20606           RECEIVE_PACKET_FIELD_ERROR(action_probabilities);
20607         }
20608       }
20609     }
20610   }
20611 
20612   if (NULL == old) {
20613     old = fc_malloc(sizeof(*old));
20614     *old = *real_packet;
20615     genhash_insert(*hash, old, old);
20616   } else {
20617     *old = *real_packet;
20618   }
20619   RECEIVE_PACKET_END(real_packet);
20620 }
20621 
send_packet_unit_actions_100(struct connection * pc,const struct packet_unit_actions * packet)20622 static int send_packet_unit_actions_100(struct connection *pc, const struct packet_unit_actions *packet)
20623 {
20624   const struct packet_unit_actions *real_packet = packet;
20625   packet_unit_actions_100_fields fields;
20626   struct packet_unit_actions *old;
20627   bool differ;
20628   struct genhash **hash = pc->phs.sent + PACKET_UNIT_ACTIONS;
20629   int different = 0;
20630   SEND_PACKET_START(PACKET_UNIT_ACTIONS);
20631 
20632   log_packet_detailed("packet_unit_actions_100: sending info about ()");
20633 
20634   if (NULL == *hash) {
20635     *hash = genhash_new_full(hash_packet_unit_actions_100, cmp_packet_unit_actions_100,
20636                              NULL, NULL, NULL, free);
20637   }
20638   BV_CLR_ALL(fields);
20639 
20640   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
20641     old = fc_malloc(sizeof(*old));
20642     *old = *real_packet;
20643     genhash_insert(*hash, old, old);
20644     memset(old, 0, sizeof(*old));
20645     different = 1;      /* Force to send. */
20646   }
20647 
20648   differ = (old->actor_unit_id != real_packet->actor_unit_id);
20649   if (differ) {
20650     different++;
20651     BV_SET(fields, 0);
20652   }
20653 
20654   differ = (old->target_unit_id != real_packet->target_unit_id);
20655   if (differ) {
20656     different++;
20657     BV_SET(fields, 1);
20658   }
20659 
20660   differ = (old->target_city_id != real_packet->target_city_id);
20661   if (differ) {
20662     different++;
20663     BV_SET(fields, 2);
20664   }
20665 
20666   differ = (old->target_tile_id != real_packet->target_tile_id);
20667   if (differ) {
20668     different++;
20669     BV_SET(fields, 3);
20670   }
20671 
20672   differ = (old->disturb_player != real_packet->disturb_player);
20673   if (differ) {
20674     different++;
20675   }
20676   if (packet->disturb_player) {
20677     BV_SET(fields, 4);
20678   }
20679 
20680 
20681     {
20682       differ = (ACTION_COUNT != ACTION_COUNT);
20683       if (!differ) {
20684         int i;
20685 
20686         for (i = 0; i < ACTION_COUNT; i++) {
20687           if (!are_action_probabilitys_equal(&old->action_probabilities[i], &real_packet->action_probabilities[i])) {
20688             differ = TRUE;
20689             break;
20690           }
20691         }
20692       }
20693     }
20694   if (differ) {
20695     different++;
20696     BV_SET(fields, 5);
20697   }
20698 
20699 
20700   DIO_BV_PUT(&dout, "fields", fields);
20701 
20702   if (BV_ISSET(fields, 0)) {
20703     log_packet_detailed("  field 'actor_unit_id' has changed");
20704     DIO_PUT(uint16, &dout, "actor_unit_id", real_packet->actor_unit_id);
20705   }
20706   if (BV_ISSET(fields, 1)) {
20707     log_packet_detailed("  field 'target_unit_id' has changed");
20708     DIO_PUT(uint16, &dout, "target_unit_id", real_packet->target_unit_id);
20709   }
20710   if (BV_ISSET(fields, 2)) {
20711     log_packet_detailed("  field 'target_city_id' has changed");
20712     DIO_PUT(uint16, &dout, "target_city_id", real_packet->target_city_id);
20713   }
20714   if (BV_ISSET(fields, 3)) {
20715     log_packet_detailed("  field 'target_tile_id' has changed");
20716     DIO_PUT(sint32, &dout, "target_tile_id", real_packet->target_tile_id);
20717   }
20718   /* field 4 is folded into the header */
20719   if (BV_ISSET(fields, 5)) {
20720     log_packet_detailed("  field 'action_probabilities' has changed");
20721 
20722     {
20723       int i;
20724 
20725       for (i = 0; i < ACTION_COUNT; i++) {
20726         dio_put_action_probability(&dout, &real_packet->action_probabilities[i]);
20727       }
20728     }
20729   }
20730 
20731   *old = *real_packet;
20732   SEND_PACKET_END(PACKET_UNIT_ACTIONS);
20733 }
20734 
send_packet_unit_actions(struct connection * pc,const struct packet_unit_actions * packet)20735 int send_packet_unit_actions(struct connection *pc, const struct packet_unit_actions *packet)
20736 {
20737   if (!pc->used) {
20738     log_error("WARNING: trying to send data to the closed connection %s",
20739               conn_description(pc));
20740     return -1;
20741   }
20742   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_ACTIONS].packet != NULL, -1,
20743                         "Handler for PACKET_UNIT_ACTIONS not installed");
20744   return pc->phs.handlers->send[PACKET_UNIT_ACTIONS].packet(pc, packet);
20745 }
20746 
dsend_packet_unit_actions(struct connection * pc,int actor_unit_id,int target_unit_id,int target_city_id,int target_tile_id,bool disturb_player,const struct act_prob * action_probabilities)20747 int dsend_packet_unit_actions(struct connection *pc, int actor_unit_id, int target_unit_id, int target_city_id, int target_tile_id, bool disturb_player, const struct act_prob *action_probabilities)
20748 {
20749   struct packet_unit_actions packet, *real_packet = &packet;
20750 
20751   real_packet->actor_unit_id = actor_unit_id;
20752   real_packet->target_unit_id = target_unit_id;
20753   real_packet->target_city_id = target_city_id;
20754   real_packet->target_tile_id = target_tile_id;
20755   real_packet->disturb_player = disturb_player;
20756   {
20757     int i;
20758 
20759     for (i = 0; i < ACTION_COUNT; i++) {
20760       real_packet->action_probabilities[i] = action_probabilities[i];
20761     }
20762   }
20763 
20764   return send_packet_unit_actions(pc, real_packet);
20765 }
20766 
20767 #define hash_packet_unit_change_activity_100 hash_const
20768 
20769 #define cmp_packet_unit_change_activity_100 cmp_const
20770 
20771 BV_DEFINE(packet_unit_change_activity_100_fields, 3);
20772 
receive_packet_unit_change_activity_100(struct connection * pc)20773 static struct packet_unit_change_activity *receive_packet_unit_change_activity_100(struct connection *pc)
20774 {
20775   packet_unit_change_activity_100_fields fields;
20776   struct packet_unit_change_activity *old;
20777   struct genhash **hash = pc->phs.received + PACKET_UNIT_CHANGE_ACTIVITY;
20778   RECEIVE_PACKET_START(packet_unit_change_activity, real_packet);
20779 
20780   DIO_BV_GET(&din, fields);
20781 
20782   log_packet_detailed("packet_unit_change_activity_100: got info about ()");
20783 
20784   if (NULL == *hash) {
20785     *hash = genhash_new_full(hash_packet_unit_change_activity_100, cmp_packet_unit_change_activity_100,
20786                              NULL, NULL, NULL, free);
20787   }
20788 
20789   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
20790     *real_packet = *old;
20791   } else {
20792     log_packet_detailed("  no old info");
20793     memset(real_packet, 0, sizeof(*real_packet));
20794   }
20795 
20796   if (BV_ISSET(fields, 0)) {
20797     log_packet_detailed("  got field 'unit_id'");
20798     if (!DIO_GET(uint16, &din, "unit_id", &real_packet->unit_id)) {
20799       RECEIVE_PACKET_FIELD_ERROR(unit_id);
20800     }
20801   }
20802   if (BV_ISSET(fields, 1)) {
20803     log_packet_detailed("  got field 'activity'");
20804     {
20805       int readin;
20806 
20807       if (!DIO_GET(uint8, &din, "activity", &readin)) {
20808         RECEIVE_PACKET_FIELD_ERROR(activity);
20809       }
20810       real_packet->activity = readin;
20811     }
20812   }
20813   if (BV_ISSET(fields, 2)) {
20814     log_packet_detailed("  got field 'target'");
20815     if (!DIO_GET(sint8, &din, "target", &real_packet->target)) {
20816       RECEIVE_PACKET_FIELD_ERROR(target);
20817     }
20818   }
20819 
20820   if (NULL == old) {
20821     old = fc_malloc(sizeof(*old));
20822     *old = *real_packet;
20823     genhash_insert(*hash, old, old);
20824   } else {
20825     *old = *real_packet;
20826   }
20827   RECEIVE_PACKET_END(real_packet);
20828 }
20829 
send_packet_unit_change_activity_100(struct connection * pc,const struct packet_unit_change_activity * packet)20830 static int send_packet_unit_change_activity_100(struct connection *pc, const struct packet_unit_change_activity *packet)
20831 {
20832   const struct packet_unit_change_activity *real_packet = packet;
20833   packet_unit_change_activity_100_fields fields;
20834   struct packet_unit_change_activity *old;
20835   bool differ;
20836   struct genhash **hash = pc->phs.sent + PACKET_UNIT_CHANGE_ACTIVITY;
20837   int different = 0;
20838   SEND_PACKET_START(PACKET_UNIT_CHANGE_ACTIVITY);
20839 
20840   log_packet_detailed("packet_unit_change_activity_100: sending info about ()");
20841 
20842   if (NULL == *hash) {
20843     *hash = genhash_new_full(hash_packet_unit_change_activity_100, cmp_packet_unit_change_activity_100,
20844                              NULL, NULL, NULL, free);
20845   }
20846   BV_CLR_ALL(fields);
20847 
20848   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
20849     old = fc_malloc(sizeof(*old));
20850     *old = *real_packet;
20851     genhash_insert(*hash, old, old);
20852     memset(old, 0, sizeof(*old));
20853     different = 1;      /* Force to send. */
20854   }
20855 
20856   differ = (old->unit_id != real_packet->unit_id);
20857   if (differ) {
20858     different++;
20859     BV_SET(fields, 0);
20860   }
20861 
20862   differ = (old->activity != real_packet->activity);
20863   if (differ) {
20864     different++;
20865     BV_SET(fields, 1);
20866   }
20867 
20868   differ = (old->target != real_packet->target);
20869   if (differ) {
20870     different++;
20871     BV_SET(fields, 2);
20872   }
20873 
20874 
20875   DIO_BV_PUT(&dout, "fields", fields);
20876 
20877   if (BV_ISSET(fields, 0)) {
20878     log_packet_detailed("  field 'unit_id' has changed");
20879     DIO_PUT(uint16, &dout, "unit_id", real_packet->unit_id);
20880   }
20881   if (BV_ISSET(fields, 1)) {
20882     log_packet_detailed("  field 'activity' has changed");
20883     DIO_PUT(uint8, &dout, "activity", real_packet->activity);
20884   }
20885   if (BV_ISSET(fields, 2)) {
20886     log_packet_detailed("  field 'target' has changed");
20887     DIO_PUT(sint8, &dout, "target", real_packet->target);
20888   }
20889 
20890   *old = *real_packet;
20891   SEND_PACKET_END(PACKET_UNIT_CHANGE_ACTIVITY);
20892 }
20893 
send_packet_unit_change_activity(struct connection * pc,const struct packet_unit_change_activity * packet)20894 int send_packet_unit_change_activity(struct connection *pc, const struct packet_unit_change_activity *packet)
20895 {
20896   if (!pc->used) {
20897     log_error("WARNING: trying to send data to the closed connection %s",
20898               conn_description(pc));
20899     return -1;
20900   }
20901   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_CHANGE_ACTIVITY].packet != NULL, -1,
20902                         "Handler for PACKET_UNIT_CHANGE_ACTIVITY not installed");
20903   return pc->phs.handlers->send[PACKET_UNIT_CHANGE_ACTIVITY].packet(pc, packet);
20904 }
20905 
dsend_packet_unit_change_activity(struct connection * pc,int unit_id,enum unit_activity activity,int target)20906 int dsend_packet_unit_change_activity(struct connection *pc, int unit_id, enum unit_activity activity, int target)
20907 {
20908   struct packet_unit_change_activity packet, *real_packet = &packet;
20909 
20910   real_packet->unit_id = unit_id;
20911   real_packet->activity = activity;
20912   real_packet->target = target;
20913 
20914   return send_packet_unit_change_activity(pc, real_packet);
20915 }
20916 
20917 #define hash_packet_diplomacy_init_meeting_req_100 hash_const
20918 
20919 #define cmp_packet_diplomacy_init_meeting_req_100 cmp_const
20920 
20921 BV_DEFINE(packet_diplomacy_init_meeting_req_100_fields, 1);
20922 
receive_packet_diplomacy_init_meeting_req_100(struct connection * pc)20923 static struct packet_diplomacy_init_meeting_req *receive_packet_diplomacy_init_meeting_req_100(struct connection *pc)
20924 {
20925   packet_diplomacy_init_meeting_req_100_fields fields;
20926   struct packet_diplomacy_init_meeting_req *old;
20927   struct genhash **hash = pc->phs.received + PACKET_DIPLOMACY_INIT_MEETING_REQ;
20928   RECEIVE_PACKET_START(packet_diplomacy_init_meeting_req, real_packet);
20929 
20930   DIO_BV_GET(&din, fields);
20931 
20932   log_packet_detailed("packet_diplomacy_init_meeting_req_100: got info about ()");
20933 
20934   if (NULL == *hash) {
20935     *hash = genhash_new_full(hash_packet_diplomacy_init_meeting_req_100, cmp_packet_diplomacy_init_meeting_req_100,
20936                              NULL, NULL, NULL, free);
20937   }
20938 
20939   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
20940     *real_packet = *old;
20941   } else {
20942     log_packet_detailed("  no old info");
20943     memset(real_packet, 0, sizeof(*real_packet));
20944   }
20945 
20946   if (BV_ISSET(fields, 0)) {
20947     log_packet_detailed("  got field 'counterpart'");
20948     if (!DIO_GET(uint8, &din, "counterpart", &real_packet->counterpart)) {
20949       RECEIVE_PACKET_FIELD_ERROR(counterpart);
20950     }
20951   }
20952 
20953   if (NULL == old) {
20954     old = fc_malloc(sizeof(*old));
20955     *old = *real_packet;
20956     genhash_insert(*hash, old, old);
20957   } else {
20958     *old = *real_packet;
20959   }
20960   RECEIVE_PACKET_END(real_packet);
20961 }
20962 
send_packet_diplomacy_init_meeting_req_100(struct connection * pc,const struct packet_diplomacy_init_meeting_req * packet)20963 static int send_packet_diplomacy_init_meeting_req_100(struct connection *pc, const struct packet_diplomacy_init_meeting_req *packet)
20964 {
20965   const struct packet_diplomacy_init_meeting_req *real_packet = packet;
20966   packet_diplomacy_init_meeting_req_100_fields fields;
20967   struct packet_diplomacy_init_meeting_req *old;
20968   bool differ;
20969   struct genhash **hash = pc->phs.sent + PACKET_DIPLOMACY_INIT_MEETING_REQ;
20970   int different = 0;
20971   SEND_PACKET_START(PACKET_DIPLOMACY_INIT_MEETING_REQ);
20972 
20973   log_packet_detailed("packet_diplomacy_init_meeting_req_100: sending info about ()");
20974 
20975   if (NULL == *hash) {
20976     *hash = genhash_new_full(hash_packet_diplomacy_init_meeting_req_100, cmp_packet_diplomacy_init_meeting_req_100,
20977                              NULL, NULL, NULL, free);
20978   }
20979   BV_CLR_ALL(fields);
20980 
20981   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
20982     old = fc_malloc(sizeof(*old));
20983     *old = *real_packet;
20984     genhash_insert(*hash, old, old);
20985     memset(old, 0, sizeof(*old));
20986     different = 1;      /* Force to send. */
20987   }
20988 
20989   differ = (old->counterpart != real_packet->counterpart);
20990   if (differ) {
20991     different++;
20992     BV_SET(fields, 0);
20993   }
20994 
20995 
20996   DIO_BV_PUT(&dout, "fields", fields);
20997 
20998   if (BV_ISSET(fields, 0)) {
20999     log_packet_detailed("  field 'counterpart' has changed");
21000     DIO_PUT(uint8, &dout, "counterpart", real_packet->counterpart);
21001   }
21002 
21003   *old = *real_packet;
21004   SEND_PACKET_END(PACKET_DIPLOMACY_INIT_MEETING_REQ);
21005 }
21006 
send_packet_diplomacy_init_meeting_req(struct connection * pc,const struct packet_diplomacy_init_meeting_req * packet)21007 int send_packet_diplomacy_init_meeting_req(struct connection *pc, const struct packet_diplomacy_init_meeting_req *packet)
21008 {
21009   if (!pc->used) {
21010     log_error("WARNING: trying to send data to the closed connection %s",
21011               conn_description(pc));
21012     return -1;
21013   }
21014   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_DIPLOMACY_INIT_MEETING_REQ].packet != NULL, -1,
21015                         "Handler for PACKET_DIPLOMACY_INIT_MEETING_REQ not installed");
21016   return pc->phs.handlers->send[PACKET_DIPLOMACY_INIT_MEETING_REQ].packet(pc, packet);
21017 }
21018 
dsend_packet_diplomacy_init_meeting_req(struct connection * pc,int counterpart)21019 int dsend_packet_diplomacy_init_meeting_req(struct connection *pc, int counterpart)
21020 {
21021   struct packet_diplomacy_init_meeting_req packet, *real_packet = &packet;
21022 
21023   real_packet->counterpart = counterpart;
21024 
21025   return send_packet_diplomacy_init_meeting_req(pc, real_packet);
21026 }
21027 
21028 #define hash_packet_diplomacy_init_meeting_100 hash_const
21029 
21030 #define cmp_packet_diplomacy_init_meeting_100 cmp_const
21031 
21032 BV_DEFINE(packet_diplomacy_init_meeting_100_fields, 2);
21033 
receive_packet_diplomacy_init_meeting_100(struct connection * pc)21034 static struct packet_diplomacy_init_meeting *receive_packet_diplomacy_init_meeting_100(struct connection *pc)
21035 {
21036   packet_diplomacy_init_meeting_100_fields fields;
21037   struct packet_diplomacy_init_meeting *old;
21038   struct genhash **hash = pc->phs.received + PACKET_DIPLOMACY_INIT_MEETING;
21039   RECEIVE_PACKET_START(packet_diplomacy_init_meeting, real_packet);
21040 
21041   DIO_BV_GET(&din, fields);
21042 
21043   log_packet_detailed("packet_diplomacy_init_meeting_100: got info about ()");
21044 
21045   if (NULL == *hash) {
21046     *hash = genhash_new_full(hash_packet_diplomacy_init_meeting_100, cmp_packet_diplomacy_init_meeting_100,
21047                              NULL, NULL, NULL, free);
21048   }
21049 
21050   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
21051     *real_packet = *old;
21052   } else {
21053     log_packet_detailed("  no old info");
21054     memset(real_packet, 0, sizeof(*real_packet));
21055   }
21056 
21057   if (BV_ISSET(fields, 0)) {
21058     log_packet_detailed("  got field 'counterpart'");
21059     if (!DIO_GET(uint8, &din, "counterpart", &real_packet->counterpart)) {
21060       RECEIVE_PACKET_FIELD_ERROR(counterpart);
21061     }
21062   }
21063   if (BV_ISSET(fields, 1)) {
21064     log_packet_detailed("  got field 'initiated_from'");
21065     if (!DIO_GET(uint8, &din, "initiated_from", &real_packet->initiated_from)) {
21066       RECEIVE_PACKET_FIELD_ERROR(initiated_from);
21067     }
21068   }
21069 
21070   if (NULL == old) {
21071     old = fc_malloc(sizeof(*old));
21072     *old = *real_packet;
21073     genhash_insert(*hash, old, old);
21074   } else {
21075     *old = *real_packet;
21076   }
21077   RECEIVE_PACKET_END(real_packet);
21078 }
21079 
send_packet_diplomacy_init_meeting_100(struct connection * pc,const struct packet_diplomacy_init_meeting * packet)21080 static int send_packet_diplomacy_init_meeting_100(struct connection *pc, const struct packet_diplomacy_init_meeting *packet)
21081 {
21082   const struct packet_diplomacy_init_meeting *real_packet = packet;
21083   packet_diplomacy_init_meeting_100_fields fields;
21084   struct packet_diplomacy_init_meeting *old;
21085   bool differ;
21086   struct genhash **hash = pc->phs.sent + PACKET_DIPLOMACY_INIT_MEETING;
21087   int different = 0;
21088   SEND_PACKET_START(PACKET_DIPLOMACY_INIT_MEETING);
21089 
21090   log_packet_detailed("packet_diplomacy_init_meeting_100: sending info about ()");
21091 
21092   if (NULL == *hash) {
21093     *hash = genhash_new_full(hash_packet_diplomacy_init_meeting_100, cmp_packet_diplomacy_init_meeting_100,
21094                              NULL, NULL, NULL, free);
21095   }
21096   BV_CLR_ALL(fields);
21097 
21098   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
21099     old = fc_malloc(sizeof(*old));
21100     *old = *real_packet;
21101     genhash_insert(*hash, old, old);
21102     memset(old, 0, sizeof(*old));
21103     different = 1;      /* Force to send. */
21104   }
21105 
21106   differ = (old->counterpart != real_packet->counterpart);
21107   if (differ) {
21108     different++;
21109     BV_SET(fields, 0);
21110   }
21111 
21112   differ = (old->initiated_from != real_packet->initiated_from);
21113   if (differ) {
21114     different++;
21115     BV_SET(fields, 1);
21116   }
21117 
21118 
21119   DIO_BV_PUT(&dout, "fields", fields);
21120 
21121   if (BV_ISSET(fields, 0)) {
21122     log_packet_detailed("  field 'counterpart' has changed");
21123     DIO_PUT(uint8, &dout, "counterpart", real_packet->counterpart);
21124   }
21125   if (BV_ISSET(fields, 1)) {
21126     log_packet_detailed("  field 'initiated_from' has changed");
21127     DIO_PUT(uint8, &dout, "initiated_from", real_packet->initiated_from);
21128   }
21129 
21130   *old = *real_packet;
21131   SEND_PACKET_END(PACKET_DIPLOMACY_INIT_MEETING);
21132 }
21133 
send_packet_diplomacy_init_meeting(struct connection * pc,const struct packet_diplomacy_init_meeting * packet)21134 int send_packet_diplomacy_init_meeting(struct connection *pc, const struct packet_diplomacy_init_meeting *packet)
21135 {
21136   if (!pc->used) {
21137     log_error("WARNING: trying to send data to the closed connection %s",
21138               conn_description(pc));
21139     return -1;
21140   }
21141   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_DIPLOMACY_INIT_MEETING].packet != NULL, -1,
21142                         "Handler for PACKET_DIPLOMACY_INIT_MEETING not installed");
21143   return pc->phs.handlers->send[PACKET_DIPLOMACY_INIT_MEETING].packet(pc, packet);
21144 }
21145 
lsend_packet_diplomacy_init_meeting(struct conn_list * dest,const struct packet_diplomacy_init_meeting * packet)21146 void lsend_packet_diplomacy_init_meeting(struct conn_list *dest, const struct packet_diplomacy_init_meeting *packet)
21147 {
21148   conn_list_iterate(dest, pconn) {
21149     send_packet_diplomacy_init_meeting(pconn, packet);
21150   } conn_list_iterate_end;
21151 }
21152 
dsend_packet_diplomacy_init_meeting(struct connection * pc,int counterpart,int initiated_from)21153 int dsend_packet_diplomacy_init_meeting(struct connection *pc, int counterpart, int initiated_from)
21154 {
21155   struct packet_diplomacy_init_meeting packet, *real_packet = &packet;
21156 
21157   real_packet->counterpart = counterpart;
21158   real_packet->initiated_from = initiated_from;
21159 
21160   return send_packet_diplomacy_init_meeting(pc, real_packet);
21161 }
21162 
dlsend_packet_diplomacy_init_meeting(struct conn_list * dest,int counterpart,int initiated_from)21163 void dlsend_packet_diplomacy_init_meeting(struct conn_list *dest, int counterpart, int initiated_from)
21164 {
21165   struct packet_diplomacy_init_meeting packet, *real_packet = &packet;
21166 
21167   real_packet->counterpart = counterpart;
21168   real_packet->initiated_from = initiated_from;
21169 
21170   lsend_packet_diplomacy_init_meeting(dest, real_packet);
21171 }
21172 
21173 #define hash_packet_diplomacy_cancel_meeting_req_100 hash_const
21174 
21175 #define cmp_packet_diplomacy_cancel_meeting_req_100 cmp_const
21176 
21177 BV_DEFINE(packet_diplomacy_cancel_meeting_req_100_fields, 1);
21178 
receive_packet_diplomacy_cancel_meeting_req_100(struct connection * pc)21179 static struct packet_diplomacy_cancel_meeting_req *receive_packet_diplomacy_cancel_meeting_req_100(struct connection *pc)
21180 {
21181   packet_diplomacy_cancel_meeting_req_100_fields fields;
21182   struct packet_diplomacy_cancel_meeting_req *old;
21183   struct genhash **hash = pc->phs.received + PACKET_DIPLOMACY_CANCEL_MEETING_REQ;
21184   RECEIVE_PACKET_START(packet_diplomacy_cancel_meeting_req, real_packet);
21185 
21186   DIO_BV_GET(&din, fields);
21187 
21188   log_packet_detailed("packet_diplomacy_cancel_meeting_req_100: got info about ()");
21189 
21190   if (NULL == *hash) {
21191     *hash = genhash_new_full(hash_packet_diplomacy_cancel_meeting_req_100, cmp_packet_diplomacy_cancel_meeting_req_100,
21192                              NULL, NULL, NULL, free);
21193   }
21194 
21195   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
21196     *real_packet = *old;
21197   } else {
21198     log_packet_detailed("  no old info");
21199     memset(real_packet, 0, sizeof(*real_packet));
21200   }
21201 
21202   if (BV_ISSET(fields, 0)) {
21203     log_packet_detailed("  got field 'counterpart'");
21204     if (!DIO_GET(uint8, &din, "counterpart", &real_packet->counterpart)) {
21205       RECEIVE_PACKET_FIELD_ERROR(counterpart);
21206     }
21207   }
21208 
21209   if (NULL == old) {
21210     old = fc_malloc(sizeof(*old));
21211     *old = *real_packet;
21212     genhash_insert(*hash, old, old);
21213   } else {
21214     *old = *real_packet;
21215   }
21216   RECEIVE_PACKET_END(real_packet);
21217 }
21218 
send_packet_diplomacy_cancel_meeting_req_100(struct connection * pc,const struct packet_diplomacy_cancel_meeting_req * packet)21219 static int send_packet_diplomacy_cancel_meeting_req_100(struct connection *pc, const struct packet_diplomacy_cancel_meeting_req *packet)
21220 {
21221   const struct packet_diplomacy_cancel_meeting_req *real_packet = packet;
21222   packet_diplomacy_cancel_meeting_req_100_fields fields;
21223   struct packet_diplomacy_cancel_meeting_req *old;
21224   bool differ;
21225   struct genhash **hash = pc->phs.sent + PACKET_DIPLOMACY_CANCEL_MEETING_REQ;
21226   int different = 0;
21227   SEND_PACKET_START(PACKET_DIPLOMACY_CANCEL_MEETING_REQ);
21228 
21229   log_packet_detailed("packet_diplomacy_cancel_meeting_req_100: sending info about ()");
21230 
21231   if (NULL == *hash) {
21232     *hash = genhash_new_full(hash_packet_diplomacy_cancel_meeting_req_100, cmp_packet_diplomacy_cancel_meeting_req_100,
21233                              NULL, NULL, NULL, free);
21234   }
21235   BV_CLR_ALL(fields);
21236 
21237   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
21238     old = fc_malloc(sizeof(*old));
21239     *old = *real_packet;
21240     genhash_insert(*hash, old, old);
21241     memset(old, 0, sizeof(*old));
21242     different = 1;      /* Force to send. */
21243   }
21244 
21245   differ = (old->counterpart != real_packet->counterpart);
21246   if (differ) {
21247     different++;
21248     BV_SET(fields, 0);
21249   }
21250 
21251 
21252   DIO_BV_PUT(&dout, "fields", fields);
21253 
21254   if (BV_ISSET(fields, 0)) {
21255     log_packet_detailed("  field 'counterpart' has changed");
21256     DIO_PUT(uint8, &dout, "counterpart", real_packet->counterpart);
21257   }
21258 
21259   *old = *real_packet;
21260   SEND_PACKET_END(PACKET_DIPLOMACY_CANCEL_MEETING_REQ);
21261 }
21262 
send_packet_diplomacy_cancel_meeting_req(struct connection * pc,const struct packet_diplomacy_cancel_meeting_req * packet)21263 int send_packet_diplomacy_cancel_meeting_req(struct connection *pc, const struct packet_diplomacy_cancel_meeting_req *packet)
21264 {
21265   if (!pc->used) {
21266     log_error("WARNING: trying to send data to the closed connection %s",
21267               conn_description(pc));
21268     return -1;
21269   }
21270   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_DIPLOMACY_CANCEL_MEETING_REQ].packet != NULL, -1,
21271                         "Handler for PACKET_DIPLOMACY_CANCEL_MEETING_REQ not installed");
21272   return pc->phs.handlers->send[PACKET_DIPLOMACY_CANCEL_MEETING_REQ].packet(pc, packet);
21273 }
21274 
dsend_packet_diplomacy_cancel_meeting_req(struct connection * pc,int counterpart)21275 int dsend_packet_diplomacy_cancel_meeting_req(struct connection *pc, int counterpart)
21276 {
21277   struct packet_diplomacy_cancel_meeting_req packet, *real_packet = &packet;
21278 
21279   real_packet->counterpart = counterpart;
21280 
21281   return send_packet_diplomacy_cancel_meeting_req(pc, real_packet);
21282 }
21283 
21284 #define hash_packet_diplomacy_cancel_meeting_100 hash_const
21285 
21286 #define cmp_packet_diplomacy_cancel_meeting_100 cmp_const
21287 
21288 BV_DEFINE(packet_diplomacy_cancel_meeting_100_fields, 2);
21289 
receive_packet_diplomacy_cancel_meeting_100(struct connection * pc)21290 static struct packet_diplomacy_cancel_meeting *receive_packet_diplomacy_cancel_meeting_100(struct connection *pc)
21291 {
21292   packet_diplomacy_cancel_meeting_100_fields fields;
21293   struct packet_diplomacy_cancel_meeting *old;
21294   struct genhash **hash = pc->phs.received + PACKET_DIPLOMACY_CANCEL_MEETING;
21295   RECEIVE_PACKET_START(packet_diplomacy_cancel_meeting, real_packet);
21296 
21297   DIO_BV_GET(&din, fields);
21298 
21299   log_packet_detailed("packet_diplomacy_cancel_meeting_100: got info about ()");
21300 
21301   if (NULL == *hash) {
21302     *hash = genhash_new_full(hash_packet_diplomacy_cancel_meeting_100, cmp_packet_diplomacy_cancel_meeting_100,
21303                              NULL, NULL, NULL, free);
21304   }
21305 
21306   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
21307     *real_packet = *old;
21308   } else {
21309     log_packet_detailed("  no old info");
21310     memset(real_packet, 0, sizeof(*real_packet));
21311   }
21312 
21313   if (BV_ISSET(fields, 0)) {
21314     log_packet_detailed("  got field 'counterpart'");
21315     if (!DIO_GET(uint8, &din, "counterpart", &real_packet->counterpart)) {
21316       RECEIVE_PACKET_FIELD_ERROR(counterpart);
21317     }
21318   }
21319   if (BV_ISSET(fields, 1)) {
21320     log_packet_detailed("  got field 'initiated_from'");
21321     if (!DIO_GET(uint8, &din, "initiated_from", &real_packet->initiated_from)) {
21322       RECEIVE_PACKET_FIELD_ERROR(initiated_from);
21323     }
21324   }
21325 
21326   if (NULL == old) {
21327     old = fc_malloc(sizeof(*old));
21328     *old = *real_packet;
21329     genhash_insert(*hash, old, old);
21330   } else {
21331     *old = *real_packet;
21332   }
21333   RECEIVE_PACKET_END(real_packet);
21334 }
21335 
send_packet_diplomacy_cancel_meeting_100(struct connection * pc,const struct packet_diplomacy_cancel_meeting * packet)21336 static int send_packet_diplomacy_cancel_meeting_100(struct connection *pc, const struct packet_diplomacy_cancel_meeting *packet)
21337 {
21338   const struct packet_diplomacy_cancel_meeting *real_packet = packet;
21339   packet_diplomacy_cancel_meeting_100_fields fields;
21340   struct packet_diplomacy_cancel_meeting *old;
21341   bool differ;
21342   struct genhash **hash = pc->phs.sent + PACKET_DIPLOMACY_CANCEL_MEETING;
21343   int different = 0;
21344   SEND_PACKET_START(PACKET_DIPLOMACY_CANCEL_MEETING);
21345 
21346   log_packet_detailed("packet_diplomacy_cancel_meeting_100: sending info about ()");
21347 
21348   if (NULL == *hash) {
21349     *hash = genhash_new_full(hash_packet_diplomacy_cancel_meeting_100, cmp_packet_diplomacy_cancel_meeting_100,
21350                              NULL, NULL, NULL, free);
21351   }
21352   BV_CLR_ALL(fields);
21353 
21354   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
21355     old = fc_malloc(sizeof(*old));
21356     *old = *real_packet;
21357     genhash_insert(*hash, old, old);
21358     memset(old, 0, sizeof(*old));
21359     different = 1;      /* Force to send. */
21360   }
21361 
21362   differ = (old->counterpart != real_packet->counterpart);
21363   if (differ) {
21364     different++;
21365     BV_SET(fields, 0);
21366   }
21367 
21368   differ = (old->initiated_from != real_packet->initiated_from);
21369   if (differ) {
21370     different++;
21371     BV_SET(fields, 1);
21372   }
21373 
21374 
21375   DIO_BV_PUT(&dout, "fields", fields);
21376 
21377   if (BV_ISSET(fields, 0)) {
21378     log_packet_detailed("  field 'counterpart' has changed");
21379     DIO_PUT(uint8, &dout, "counterpart", real_packet->counterpart);
21380   }
21381   if (BV_ISSET(fields, 1)) {
21382     log_packet_detailed("  field 'initiated_from' has changed");
21383     DIO_PUT(uint8, &dout, "initiated_from", real_packet->initiated_from);
21384   }
21385 
21386   *old = *real_packet;
21387   SEND_PACKET_END(PACKET_DIPLOMACY_CANCEL_MEETING);
21388 }
21389 
send_packet_diplomacy_cancel_meeting(struct connection * pc,const struct packet_diplomacy_cancel_meeting * packet)21390 int send_packet_diplomacy_cancel_meeting(struct connection *pc, const struct packet_diplomacy_cancel_meeting *packet)
21391 {
21392   if (!pc->used) {
21393     log_error("WARNING: trying to send data to the closed connection %s",
21394               conn_description(pc));
21395     return -1;
21396   }
21397   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_DIPLOMACY_CANCEL_MEETING].packet != NULL, -1,
21398                         "Handler for PACKET_DIPLOMACY_CANCEL_MEETING not installed");
21399   return pc->phs.handlers->send[PACKET_DIPLOMACY_CANCEL_MEETING].packet(pc, packet);
21400 }
21401 
lsend_packet_diplomacy_cancel_meeting(struct conn_list * dest,const struct packet_diplomacy_cancel_meeting * packet)21402 void lsend_packet_diplomacy_cancel_meeting(struct conn_list *dest, const struct packet_diplomacy_cancel_meeting *packet)
21403 {
21404   conn_list_iterate(dest, pconn) {
21405     send_packet_diplomacy_cancel_meeting(pconn, packet);
21406   } conn_list_iterate_end;
21407 }
21408 
dsend_packet_diplomacy_cancel_meeting(struct connection * pc,int counterpart,int initiated_from)21409 int dsend_packet_diplomacy_cancel_meeting(struct connection *pc, int counterpart, int initiated_from)
21410 {
21411   struct packet_diplomacy_cancel_meeting packet, *real_packet = &packet;
21412 
21413   real_packet->counterpart = counterpart;
21414   real_packet->initiated_from = initiated_from;
21415 
21416   return send_packet_diplomacy_cancel_meeting(pc, real_packet);
21417 }
21418 
dlsend_packet_diplomacy_cancel_meeting(struct conn_list * dest,int counterpart,int initiated_from)21419 void dlsend_packet_diplomacy_cancel_meeting(struct conn_list *dest, int counterpart, int initiated_from)
21420 {
21421   struct packet_diplomacy_cancel_meeting packet, *real_packet = &packet;
21422 
21423   real_packet->counterpart = counterpart;
21424   real_packet->initiated_from = initiated_from;
21425 
21426   lsend_packet_diplomacy_cancel_meeting(dest, real_packet);
21427 }
21428 
21429 #define hash_packet_diplomacy_create_clause_req_100 hash_const
21430 
21431 #define cmp_packet_diplomacy_create_clause_req_100 cmp_const
21432 
21433 BV_DEFINE(packet_diplomacy_create_clause_req_100_fields, 4);
21434 
receive_packet_diplomacy_create_clause_req_100(struct connection * pc)21435 static struct packet_diplomacy_create_clause_req *receive_packet_diplomacy_create_clause_req_100(struct connection *pc)
21436 {
21437   packet_diplomacy_create_clause_req_100_fields fields;
21438   struct packet_diplomacy_create_clause_req *old;
21439   struct genhash **hash = pc->phs.received + PACKET_DIPLOMACY_CREATE_CLAUSE_REQ;
21440   RECEIVE_PACKET_START(packet_diplomacy_create_clause_req, real_packet);
21441 
21442   DIO_BV_GET(&din, fields);
21443 
21444   log_packet_detailed("packet_diplomacy_create_clause_req_100: got info about ()");
21445 
21446   if (NULL == *hash) {
21447     *hash = genhash_new_full(hash_packet_diplomacy_create_clause_req_100, cmp_packet_diplomacy_create_clause_req_100,
21448                              NULL, NULL, NULL, free);
21449   }
21450 
21451   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
21452     *real_packet = *old;
21453   } else {
21454     log_packet_detailed("  no old info");
21455     memset(real_packet, 0, sizeof(*real_packet));
21456   }
21457 
21458   if (BV_ISSET(fields, 0)) {
21459     log_packet_detailed("  got field 'counterpart'");
21460     if (!DIO_GET(uint8, &din, "counterpart", &real_packet->counterpart)) {
21461       RECEIVE_PACKET_FIELD_ERROR(counterpart);
21462     }
21463   }
21464   if (BV_ISSET(fields, 1)) {
21465     log_packet_detailed("  got field 'giver'");
21466     if (!DIO_GET(uint8, &din, "giver", &real_packet->giver)) {
21467       RECEIVE_PACKET_FIELD_ERROR(giver);
21468     }
21469   }
21470   if (BV_ISSET(fields, 2)) {
21471     log_packet_detailed("  got field 'type'");
21472     {
21473       int readin;
21474 
21475       if (!DIO_GET(uint8, &din, "type", &readin)) {
21476         RECEIVE_PACKET_FIELD_ERROR(type);
21477       }
21478       real_packet->type = readin;
21479     }
21480   }
21481   if (BV_ISSET(fields, 3)) {
21482     log_packet_detailed("  got field 'value'");
21483     if (!DIO_GET(uint32, &din, "value", &real_packet->value)) {
21484       RECEIVE_PACKET_FIELD_ERROR(value);
21485     }
21486   }
21487 
21488   if (NULL == old) {
21489     old = fc_malloc(sizeof(*old));
21490     *old = *real_packet;
21491     genhash_insert(*hash, old, old);
21492   } else {
21493     *old = *real_packet;
21494   }
21495   RECEIVE_PACKET_END(real_packet);
21496 }
21497 
send_packet_diplomacy_create_clause_req_100(struct connection * pc,const struct packet_diplomacy_create_clause_req * packet)21498 static int send_packet_diplomacy_create_clause_req_100(struct connection *pc, const struct packet_diplomacy_create_clause_req *packet)
21499 {
21500   const struct packet_diplomacy_create_clause_req *real_packet = packet;
21501   packet_diplomacy_create_clause_req_100_fields fields;
21502   struct packet_diplomacy_create_clause_req *old;
21503   bool differ;
21504   struct genhash **hash = pc->phs.sent + PACKET_DIPLOMACY_CREATE_CLAUSE_REQ;
21505   int different = 0;
21506   SEND_PACKET_START(PACKET_DIPLOMACY_CREATE_CLAUSE_REQ);
21507 
21508   log_packet_detailed("packet_diplomacy_create_clause_req_100: sending info about ()");
21509 
21510   if (NULL == *hash) {
21511     *hash = genhash_new_full(hash_packet_diplomacy_create_clause_req_100, cmp_packet_diplomacy_create_clause_req_100,
21512                              NULL, NULL, NULL, free);
21513   }
21514   BV_CLR_ALL(fields);
21515 
21516   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
21517     old = fc_malloc(sizeof(*old));
21518     *old = *real_packet;
21519     genhash_insert(*hash, old, old);
21520     memset(old, 0, sizeof(*old));
21521     different = 1;      /* Force to send. */
21522   }
21523 
21524   differ = (old->counterpart != real_packet->counterpart);
21525   if (differ) {
21526     different++;
21527     BV_SET(fields, 0);
21528   }
21529 
21530   differ = (old->giver != real_packet->giver);
21531   if (differ) {
21532     different++;
21533     BV_SET(fields, 1);
21534   }
21535 
21536   differ = (old->type != real_packet->type);
21537   if (differ) {
21538     different++;
21539     BV_SET(fields, 2);
21540   }
21541 
21542   differ = (old->value != real_packet->value);
21543   if (differ) {
21544     different++;
21545     BV_SET(fields, 3);
21546   }
21547 
21548 
21549   DIO_BV_PUT(&dout, "fields", fields);
21550 
21551   if (BV_ISSET(fields, 0)) {
21552     log_packet_detailed("  field 'counterpart' has changed");
21553     DIO_PUT(uint8, &dout, "counterpart", real_packet->counterpart);
21554   }
21555   if (BV_ISSET(fields, 1)) {
21556     log_packet_detailed("  field 'giver' has changed");
21557     DIO_PUT(uint8, &dout, "giver", real_packet->giver);
21558   }
21559   if (BV_ISSET(fields, 2)) {
21560     log_packet_detailed("  field 'type' has changed");
21561     DIO_PUT(uint8, &dout, "type", real_packet->type);
21562   }
21563   if (BV_ISSET(fields, 3)) {
21564     log_packet_detailed("  field 'value' has changed");
21565     DIO_PUT(uint32, &dout, "value", real_packet->value);
21566   }
21567 
21568   *old = *real_packet;
21569   SEND_PACKET_END(PACKET_DIPLOMACY_CREATE_CLAUSE_REQ);
21570 }
21571 
send_packet_diplomacy_create_clause_req(struct connection * pc,const struct packet_diplomacy_create_clause_req * packet)21572 int send_packet_diplomacy_create_clause_req(struct connection *pc, const struct packet_diplomacy_create_clause_req *packet)
21573 {
21574   if (!pc->used) {
21575     log_error("WARNING: trying to send data to the closed connection %s",
21576               conn_description(pc));
21577     return -1;
21578   }
21579   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_DIPLOMACY_CREATE_CLAUSE_REQ].packet != NULL, -1,
21580                         "Handler for PACKET_DIPLOMACY_CREATE_CLAUSE_REQ not installed");
21581   return pc->phs.handlers->send[PACKET_DIPLOMACY_CREATE_CLAUSE_REQ].packet(pc, packet);
21582 }
21583 
dsend_packet_diplomacy_create_clause_req(struct connection * pc,int counterpart,int giver,enum clause_type type,int value)21584 int dsend_packet_diplomacy_create_clause_req(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
21585 {
21586   struct packet_diplomacy_create_clause_req packet, *real_packet = &packet;
21587 
21588   real_packet->counterpart = counterpart;
21589   real_packet->giver = giver;
21590   real_packet->type = type;
21591   real_packet->value = value;
21592 
21593   return send_packet_diplomacy_create_clause_req(pc, real_packet);
21594 }
21595 
21596 #define hash_packet_diplomacy_create_clause_100 hash_const
21597 
21598 #define cmp_packet_diplomacy_create_clause_100 cmp_const
21599 
21600 BV_DEFINE(packet_diplomacy_create_clause_100_fields, 4);
21601 
receive_packet_diplomacy_create_clause_100(struct connection * pc)21602 static struct packet_diplomacy_create_clause *receive_packet_diplomacy_create_clause_100(struct connection *pc)
21603 {
21604   packet_diplomacy_create_clause_100_fields fields;
21605   struct packet_diplomacy_create_clause *old;
21606   struct genhash **hash = pc->phs.received + PACKET_DIPLOMACY_CREATE_CLAUSE;
21607   RECEIVE_PACKET_START(packet_diplomacy_create_clause, real_packet);
21608 
21609   DIO_BV_GET(&din, fields);
21610 
21611   log_packet_detailed("packet_diplomacy_create_clause_100: got info about ()");
21612 
21613   if (NULL == *hash) {
21614     *hash = genhash_new_full(hash_packet_diplomacy_create_clause_100, cmp_packet_diplomacy_create_clause_100,
21615                              NULL, NULL, NULL, free);
21616   }
21617 
21618   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
21619     *real_packet = *old;
21620   } else {
21621     log_packet_detailed("  no old info");
21622     memset(real_packet, 0, sizeof(*real_packet));
21623   }
21624 
21625   if (BV_ISSET(fields, 0)) {
21626     log_packet_detailed("  got field 'counterpart'");
21627     if (!DIO_GET(uint8, &din, "counterpart", &real_packet->counterpart)) {
21628       RECEIVE_PACKET_FIELD_ERROR(counterpart);
21629     }
21630   }
21631   if (BV_ISSET(fields, 1)) {
21632     log_packet_detailed("  got field 'giver'");
21633     if (!DIO_GET(uint8, &din, "giver", &real_packet->giver)) {
21634       RECEIVE_PACKET_FIELD_ERROR(giver);
21635     }
21636   }
21637   if (BV_ISSET(fields, 2)) {
21638     log_packet_detailed("  got field 'type'");
21639     {
21640       int readin;
21641 
21642       if (!DIO_GET(uint8, &din, "type", &readin)) {
21643         RECEIVE_PACKET_FIELD_ERROR(type);
21644       }
21645       real_packet->type = readin;
21646     }
21647   }
21648   if (BV_ISSET(fields, 3)) {
21649     log_packet_detailed("  got field 'value'");
21650     if (!DIO_GET(uint32, &din, "value", &real_packet->value)) {
21651       RECEIVE_PACKET_FIELD_ERROR(value);
21652     }
21653   }
21654 
21655   if (NULL == old) {
21656     old = fc_malloc(sizeof(*old));
21657     *old = *real_packet;
21658     genhash_insert(*hash, old, old);
21659   } else {
21660     *old = *real_packet;
21661   }
21662   RECEIVE_PACKET_END(real_packet);
21663 }
21664 
send_packet_diplomacy_create_clause_100(struct connection * pc,const struct packet_diplomacy_create_clause * packet)21665 static int send_packet_diplomacy_create_clause_100(struct connection *pc, const struct packet_diplomacy_create_clause *packet)
21666 {
21667   const struct packet_diplomacy_create_clause *real_packet = packet;
21668   packet_diplomacy_create_clause_100_fields fields;
21669   struct packet_diplomacy_create_clause *old;
21670   bool differ;
21671   struct genhash **hash = pc->phs.sent + PACKET_DIPLOMACY_CREATE_CLAUSE;
21672   int different = 0;
21673   SEND_PACKET_START(PACKET_DIPLOMACY_CREATE_CLAUSE);
21674 
21675   log_packet_detailed("packet_diplomacy_create_clause_100: sending info about ()");
21676 
21677   if (NULL == *hash) {
21678     *hash = genhash_new_full(hash_packet_diplomacy_create_clause_100, cmp_packet_diplomacy_create_clause_100,
21679                              NULL, NULL, NULL, free);
21680   }
21681   BV_CLR_ALL(fields);
21682 
21683   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
21684     old = fc_malloc(sizeof(*old));
21685     *old = *real_packet;
21686     genhash_insert(*hash, old, old);
21687     memset(old, 0, sizeof(*old));
21688     different = 1;      /* Force to send. */
21689   }
21690 
21691   differ = (old->counterpart != real_packet->counterpart);
21692   if (differ) {
21693     different++;
21694     BV_SET(fields, 0);
21695   }
21696 
21697   differ = (old->giver != real_packet->giver);
21698   if (differ) {
21699     different++;
21700     BV_SET(fields, 1);
21701   }
21702 
21703   differ = (old->type != real_packet->type);
21704   if (differ) {
21705     different++;
21706     BV_SET(fields, 2);
21707   }
21708 
21709   differ = (old->value != real_packet->value);
21710   if (differ) {
21711     different++;
21712     BV_SET(fields, 3);
21713   }
21714 
21715 
21716   DIO_BV_PUT(&dout, "fields", fields);
21717 
21718   if (BV_ISSET(fields, 0)) {
21719     log_packet_detailed("  field 'counterpart' has changed");
21720     DIO_PUT(uint8, &dout, "counterpart", real_packet->counterpart);
21721   }
21722   if (BV_ISSET(fields, 1)) {
21723     log_packet_detailed("  field 'giver' has changed");
21724     DIO_PUT(uint8, &dout, "giver", real_packet->giver);
21725   }
21726   if (BV_ISSET(fields, 2)) {
21727     log_packet_detailed("  field 'type' has changed");
21728     DIO_PUT(uint8, &dout, "type", real_packet->type);
21729   }
21730   if (BV_ISSET(fields, 3)) {
21731     log_packet_detailed("  field 'value' has changed");
21732     DIO_PUT(uint32, &dout, "value", real_packet->value);
21733   }
21734 
21735   *old = *real_packet;
21736   SEND_PACKET_END(PACKET_DIPLOMACY_CREATE_CLAUSE);
21737 }
21738 
send_packet_diplomacy_create_clause(struct connection * pc,const struct packet_diplomacy_create_clause * packet)21739 int send_packet_diplomacy_create_clause(struct connection *pc, const struct packet_diplomacy_create_clause *packet)
21740 {
21741   if (!pc->used) {
21742     log_error("WARNING: trying to send data to the closed connection %s",
21743               conn_description(pc));
21744     return -1;
21745   }
21746   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_DIPLOMACY_CREATE_CLAUSE].packet != NULL, -1,
21747                         "Handler for PACKET_DIPLOMACY_CREATE_CLAUSE not installed");
21748   return pc->phs.handlers->send[PACKET_DIPLOMACY_CREATE_CLAUSE].packet(pc, packet);
21749 }
21750 
lsend_packet_diplomacy_create_clause(struct conn_list * dest,const struct packet_diplomacy_create_clause * packet)21751 void lsend_packet_diplomacy_create_clause(struct conn_list *dest, const struct packet_diplomacy_create_clause *packet)
21752 {
21753   conn_list_iterate(dest, pconn) {
21754     send_packet_diplomacy_create_clause(pconn, packet);
21755   } conn_list_iterate_end;
21756 }
21757 
dsend_packet_diplomacy_create_clause(struct connection * pc,int counterpart,int giver,enum clause_type type,int value)21758 int dsend_packet_diplomacy_create_clause(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
21759 {
21760   struct packet_diplomacy_create_clause packet, *real_packet = &packet;
21761 
21762   real_packet->counterpart = counterpart;
21763   real_packet->giver = giver;
21764   real_packet->type = type;
21765   real_packet->value = value;
21766 
21767   return send_packet_diplomacy_create_clause(pc, real_packet);
21768 }
21769 
dlsend_packet_diplomacy_create_clause(struct conn_list * dest,int counterpart,int giver,enum clause_type type,int value)21770 void dlsend_packet_diplomacy_create_clause(struct conn_list *dest, int counterpart, int giver, enum clause_type type, int value)
21771 {
21772   struct packet_diplomacy_create_clause packet, *real_packet = &packet;
21773 
21774   real_packet->counterpart = counterpart;
21775   real_packet->giver = giver;
21776   real_packet->type = type;
21777   real_packet->value = value;
21778 
21779   lsend_packet_diplomacy_create_clause(dest, real_packet);
21780 }
21781 
21782 #define hash_packet_diplomacy_remove_clause_req_100 hash_const
21783 
21784 #define cmp_packet_diplomacy_remove_clause_req_100 cmp_const
21785 
21786 BV_DEFINE(packet_diplomacy_remove_clause_req_100_fields, 4);
21787 
receive_packet_diplomacy_remove_clause_req_100(struct connection * pc)21788 static struct packet_diplomacy_remove_clause_req *receive_packet_diplomacy_remove_clause_req_100(struct connection *pc)
21789 {
21790   packet_diplomacy_remove_clause_req_100_fields fields;
21791   struct packet_diplomacy_remove_clause_req *old;
21792   struct genhash **hash = pc->phs.received + PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ;
21793   RECEIVE_PACKET_START(packet_diplomacy_remove_clause_req, real_packet);
21794 
21795   DIO_BV_GET(&din, fields);
21796 
21797   log_packet_detailed("packet_diplomacy_remove_clause_req_100: got info about ()");
21798 
21799   if (NULL == *hash) {
21800     *hash = genhash_new_full(hash_packet_diplomacy_remove_clause_req_100, cmp_packet_diplomacy_remove_clause_req_100,
21801                              NULL, NULL, NULL, free);
21802   }
21803 
21804   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
21805     *real_packet = *old;
21806   } else {
21807     log_packet_detailed("  no old info");
21808     memset(real_packet, 0, sizeof(*real_packet));
21809   }
21810 
21811   if (BV_ISSET(fields, 0)) {
21812     log_packet_detailed("  got field 'counterpart'");
21813     if (!DIO_GET(uint8, &din, "counterpart", &real_packet->counterpart)) {
21814       RECEIVE_PACKET_FIELD_ERROR(counterpart);
21815     }
21816   }
21817   if (BV_ISSET(fields, 1)) {
21818     log_packet_detailed("  got field 'giver'");
21819     if (!DIO_GET(uint8, &din, "giver", &real_packet->giver)) {
21820       RECEIVE_PACKET_FIELD_ERROR(giver);
21821     }
21822   }
21823   if (BV_ISSET(fields, 2)) {
21824     log_packet_detailed("  got field 'type'");
21825     {
21826       int readin;
21827 
21828       if (!DIO_GET(uint8, &din, "type", &readin)) {
21829         RECEIVE_PACKET_FIELD_ERROR(type);
21830       }
21831       real_packet->type = readin;
21832     }
21833   }
21834   if (BV_ISSET(fields, 3)) {
21835     log_packet_detailed("  got field 'value'");
21836     if (!DIO_GET(uint32, &din, "value", &real_packet->value)) {
21837       RECEIVE_PACKET_FIELD_ERROR(value);
21838     }
21839   }
21840 
21841   if (NULL == old) {
21842     old = fc_malloc(sizeof(*old));
21843     *old = *real_packet;
21844     genhash_insert(*hash, old, old);
21845   } else {
21846     *old = *real_packet;
21847   }
21848   RECEIVE_PACKET_END(real_packet);
21849 }
21850 
send_packet_diplomacy_remove_clause_req_100(struct connection * pc,const struct packet_diplomacy_remove_clause_req * packet)21851 static int send_packet_diplomacy_remove_clause_req_100(struct connection *pc, const struct packet_diplomacy_remove_clause_req *packet)
21852 {
21853   const struct packet_diplomacy_remove_clause_req *real_packet = packet;
21854   packet_diplomacy_remove_clause_req_100_fields fields;
21855   struct packet_diplomacy_remove_clause_req *old;
21856   bool differ;
21857   struct genhash **hash = pc->phs.sent + PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ;
21858   int different = 0;
21859   SEND_PACKET_START(PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ);
21860 
21861   log_packet_detailed("packet_diplomacy_remove_clause_req_100: sending info about ()");
21862 
21863   if (NULL == *hash) {
21864     *hash = genhash_new_full(hash_packet_diplomacy_remove_clause_req_100, cmp_packet_diplomacy_remove_clause_req_100,
21865                              NULL, NULL, NULL, free);
21866   }
21867   BV_CLR_ALL(fields);
21868 
21869   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
21870     old = fc_malloc(sizeof(*old));
21871     *old = *real_packet;
21872     genhash_insert(*hash, old, old);
21873     memset(old, 0, sizeof(*old));
21874     different = 1;      /* Force to send. */
21875   }
21876 
21877   differ = (old->counterpart != real_packet->counterpart);
21878   if (differ) {
21879     different++;
21880     BV_SET(fields, 0);
21881   }
21882 
21883   differ = (old->giver != real_packet->giver);
21884   if (differ) {
21885     different++;
21886     BV_SET(fields, 1);
21887   }
21888 
21889   differ = (old->type != real_packet->type);
21890   if (differ) {
21891     different++;
21892     BV_SET(fields, 2);
21893   }
21894 
21895   differ = (old->value != real_packet->value);
21896   if (differ) {
21897     different++;
21898     BV_SET(fields, 3);
21899   }
21900 
21901 
21902   DIO_BV_PUT(&dout, "fields", fields);
21903 
21904   if (BV_ISSET(fields, 0)) {
21905     log_packet_detailed("  field 'counterpart' has changed");
21906     DIO_PUT(uint8, &dout, "counterpart", real_packet->counterpart);
21907   }
21908   if (BV_ISSET(fields, 1)) {
21909     log_packet_detailed("  field 'giver' has changed");
21910     DIO_PUT(uint8, &dout, "giver", real_packet->giver);
21911   }
21912   if (BV_ISSET(fields, 2)) {
21913     log_packet_detailed("  field 'type' has changed");
21914     DIO_PUT(uint8, &dout, "type", real_packet->type);
21915   }
21916   if (BV_ISSET(fields, 3)) {
21917     log_packet_detailed("  field 'value' has changed");
21918     DIO_PUT(uint32, &dout, "value", real_packet->value);
21919   }
21920 
21921   *old = *real_packet;
21922   SEND_PACKET_END(PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ);
21923 }
21924 
send_packet_diplomacy_remove_clause_req(struct connection * pc,const struct packet_diplomacy_remove_clause_req * packet)21925 int send_packet_diplomacy_remove_clause_req(struct connection *pc, const struct packet_diplomacy_remove_clause_req *packet)
21926 {
21927   if (!pc->used) {
21928     log_error("WARNING: trying to send data to the closed connection %s",
21929               conn_description(pc));
21930     return -1;
21931   }
21932   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ].packet != NULL, -1,
21933                         "Handler for PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ not installed");
21934   return pc->phs.handlers->send[PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ].packet(pc, packet);
21935 }
21936 
dsend_packet_diplomacy_remove_clause_req(struct connection * pc,int counterpart,int giver,enum clause_type type,int value)21937 int dsend_packet_diplomacy_remove_clause_req(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
21938 {
21939   struct packet_diplomacy_remove_clause_req packet, *real_packet = &packet;
21940 
21941   real_packet->counterpart = counterpart;
21942   real_packet->giver = giver;
21943   real_packet->type = type;
21944   real_packet->value = value;
21945 
21946   return send_packet_diplomacy_remove_clause_req(pc, real_packet);
21947 }
21948 
21949 #define hash_packet_diplomacy_remove_clause_100 hash_const
21950 
21951 #define cmp_packet_diplomacy_remove_clause_100 cmp_const
21952 
21953 BV_DEFINE(packet_diplomacy_remove_clause_100_fields, 4);
21954 
receive_packet_diplomacy_remove_clause_100(struct connection * pc)21955 static struct packet_diplomacy_remove_clause *receive_packet_diplomacy_remove_clause_100(struct connection *pc)
21956 {
21957   packet_diplomacy_remove_clause_100_fields fields;
21958   struct packet_diplomacy_remove_clause *old;
21959   struct genhash **hash = pc->phs.received + PACKET_DIPLOMACY_REMOVE_CLAUSE;
21960   RECEIVE_PACKET_START(packet_diplomacy_remove_clause, real_packet);
21961 
21962   DIO_BV_GET(&din, fields);
21963 
21964   log_packet_detailed("packet_diplomacy_remove_clause_100: got info about ()");
21965 
21966   if (NULL == *hash) {
21967     *hash = genhash_new_full(hash_packet_diplomacy_remove_clause_100, cmp_packet_diplomacy_remove_clause_100,
21968                              NULL, NULL, NULL, free);
21969   }
21970 
21971   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
21972     *real_packet = *old;
21973   } else {
21974     log_packet_detailed("  no old info");
21975     memset(real_packet, 0, sizeof(*real_packet));
21976   }
21977 
21978   if (BV_ISSET(fields, 0)) {
21979     log_packet_detailed("  got field 'counterpart'");
21980     if (!DIO_GET(uint8, &din, "counterpart", &real_packet->counterpart)) {
21981       RECEIVE_PACKET_FIELD_ERROR(counterpart);
21982     }
21983   }
21984   if (BV_ISSET(fields, 1)) {
21985     log_packet_detailed("  got field 'giver'");
21986     if (!DIO_GET(uint8, &din, "giver", &real_packet->giver)) {
21987       RECEIVE_PACKET_FIELD_ERROR(giver);
21988     }
21989   }
21990   if (BV_ISSET(fields, 2)) {
21991     log_packet_detailed("  got field 'type'");
21992     {
21993       int readin;
21994 
21995       if (!DIO_GET(uint8, &din, "type", &readin)) {
21996         RECEIVE_PACKET_FIELD_ERROR(type);
21997       }
21998       real_packet->type = readin;
21999     }
22000   }
22001   if (BV_ISSET(fields, 3)) {
22002     log_packet_detailed("  got field 'value'");
22003     if (!DIO_GET(uint32, &din, "value", &real_packet->value)) {
22004       RECEIVE_PACKET_FIELD_ERROR(value);
22005     }
22006   }
22007 
22008   if (NULL == old) {
22009     old = fc_malloc(sizeof(*old));
22010     *old = *real_packet;
22011     genhash_insert(*hash, old, old);
22012   } else {
22013     *old = *real_packet;
22014   }
22015   RECEIVE_PACKET_END(real_packet);
22016 }
22017 
send_packet_diplomacy_remove_clause_100(struct connection * pc,const struct packet_diplomacy_remove_clause * packet)22018 static int send_packet_diplomacy_remove_clause_100(struct connection *pc, const struct packet_diplomacy_remove_clause *packet)
22019 {
22020   const struct packet_diplomacy_remove_clause *real_packet = packet;
22021   packet_diplomacy_remove_clause_100_fields fields;
22022   struct packet_diplomacy_remove_clause *old;
22023   bool differ;
22024   struct genhash **hash = pc->phs.sent + PACKET_DIPLOMACY_REMOVE_CLAUSE;
22025   int different = 0;
22026   SEND_PACKET_START(PACKET_DIPLOMACY_REMOVE_CLAUSE);
22027 
22028   log_packet_detailed("packet_diplomacy_remove_clause_100: sending info about ()");
22029 
22030   if (NULL == *hash) {
22031     *hash = genhash_new_full(hash_packet_diplomacy_remove_clause_100, cmp_packet_diplomacy_remove_clause_100,
22032                              NULL, NULL, NULL, free);
22033   }
22034   BV_CLR_ALL(fields);
22035 
22036   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
22037     old = fc_malloc(sizeof(*old));
22038     *old = *real_packet;
22039     genhash_insert(*hash, old, old);
22040     memset(old, 0, sizeof(*old));
22041     different = 1;      /* Force to send. */
22042   }
22043 
22044   differ = (old->counterpart != real_packet->counterpart);
22045   if (differ) {
22046     different++;
22047     BV_SET(fields, 0);
22048   }
22049 
22050   differ = (old->giver != real_packet->giver);
22051   if (differ) {
22052     different++;
22053     BV_SET(fields, 1);
22054   }
22055 
22056   differ = (old->type != real_packet->type);
22057   if (differ) {
22058     different++;
22059     BV_SET(fields, 2);
22060   }
22061 
22062   differ = (old->value != real_packet->value);
22063   if (differ) {
22064     different++;
22065     BV_SET(fields, 3);
22066   }
22067 
22068 
22069   DIO_BV_PUT(&dout, "fields", fields);
22070 
22071   if (BV_ISSET(fields, 0)) {
22072     log_packet_detailed("  field 'counterpart' has changed");
22073     DIO_PUT(uint8, &dout, "counterpart", real_packet->counterpart);
22074   }
22075   if (BV_ISSET(fields, 1)) {
22076     log_packet_detailed("  field 'giver' has changed");
22077     DIO_PUT(uint8, &dout, "giver", real_packet->giver);
22078   }
22079   if (BV_ISSET(fields, 2)) {
22080     log_packet_detailed("  field 'type' has changed");
22081     DIO_PUT(uint8, &dout, "type", real_packet->type);
22082   }
22083   if (BV_ISSET(fields, 3)) {
22084     log_packet_detailed("  field 'value' has changed");
22085     DIO_PUT(uint32, &dout, "value", real_packet->value);
22086   }
22087 
22088   *old = *real_packet;
22089   SEND_PACKET_END(PACKET_DIPLOMACY_REMOVE_CLAUSE);
22090 }
22091 
send_packet_diplomacy_remove_clause(struct connection * pc,const struct packet_diplomacy_remove_clause * packet)22092 int send_packet_diplomacy_remove_clause(struct connection *pc, const struct packet_diplomacy_remove_clause *packet)
22093 {
22094   if (!pc->used) {
22095     log_error("WARNING: trying to send data to the closed connection %s",
22096               conn_description(pc));
22097     return -1;
22098   }
22099   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_DIPLOMACY_REMOVE_CLAUSE].packet != NULL, -1,
22100                         "Handler for PACKET_DIPLOMACY_REMOVE_CLAUSE not installed");
22101   return pc->phs.handlers->send[PACKET_DIPLOMACY_REMOVE_CLAUSE].packet(pc, packet);
22102 }
22103 
lsend_packet_diplomacy_remove_clause(struct conn_list * dest,const struct packet_diplomacy_remove_clause * packet)22104 void lsend_packet_diplomacy_remove_clause(struct conn_list *dest, const struct packet_diplomacy_remove_clause *packet)
22105 {
22106   conn_list_iterate(dest, pconn) {
22107     send_packet_diplomacy_remove_clause(pconn, packet);
22108   } conn_list_iterate_end;
22109 }
22110 
dsend_packet_diplomacy_remove_clause(struct connection * pc,int counterpart,int giver,enum clause_type type,int value)22111 int dsend_packet_diplomacy_remove_clause(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
22112 {
22113   struct packet_diplomacy_remove_clause packet, *real_packet = &packet;
22114 
22115   real_packet->counterpart = counterpart;
22116   real_packet->giver = giver;
22117   real_packet->type = type;
22118   real_packet->value = value;
22119 
22120   return send_packet_diplomacy_remove_clause(pc, real_packet);
22121 }
22122 
dlsend_packet_diplomacy_remove_clause(struct conn_list * dest,int counterpart,int giver,enum clause_type type,int value)22123 void dlsend_packet_diplomacy_remove_clause(struct conn_list *dest, int counterpart, int giver, enum clause_type type, int value)
22124 {
22125   struct packet_diplomacy_remove_clause packet, *real_packet = &packet;
22126 
22127   real_packet->counterpart = counterpart;
22128   real_packet->giver = giver;
22129   real_packet->type = type;
22130   real_packet->value = value;
22131 
22132   lsend_packet_diplomacy_remove_clause(dest, real_packet);
22133 }
22134 
22135 #define hash_packet_diplomacy_accept_treaty_req_100 hash_const
22136 
22137 #define cmp_packet_diplomacy_accept_treaty_req_100 cmp_const
22138 
22139 BV_DEFINE(packet_diplomacy_accept_treaty_req_100_fields, 1);
22140 
receive_packet_diplomacy_accept_treaty_req_100(struct connection * pc)22141 static struct packet_diplomacy_accept_treaty_req *receive_packet_diplomacy_accept_treaty_req_100(struct connection *pc)
22142 {
22143   packet_diplomacy_accept_treaty_req_100_fields fields;
22144   struct packet_diplomacy_accept_treaty_req *old;
22145   struct genhash **hash = pc->phs.received + PACKET_DIPLOMACY_ACCEPT_TREATY_REQ;
22146   RECEIVE_PACKET_START(packet_diplomacy_accept_treaty_req, real_packet);
22147 
22148   DIO_BV_GET(&din, fields);
22149 
22150   log_packet_detailed("packet_diplomacy_accept_treaty_req_100: got info about ()");
22151 
22152   if (NULL == *hash) {
22153     *hash = genhash_new_full(hash_packet_diplomacy_accept_treaty_req_100, cmp_packet_diplomacy_accept_treaty_req_100,
22154                              NULL, NULL, NULL, free);
22155   }
22156 
22157   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
22158     *real_packet = *old;
22159   } else {
22160     log_packet_detailed("  no old info");
22161     memset(real_packet, 0, sizeof(*real_packet));
22162   }
22163 
22164   if (BV_ISSET(fields, 0)) {
22165     log_packet_detailed("  got field 'counterpart'");
22166     if (!DIO_GET(uint8, &din, "counterpart", &real_packet->counterpart)) {
22167       RECEIVE_PACKET_FIELD_ERROR(counterpart);
22168     }
22169   }
22170 
22171   if (NULL == old) {
22172     old = fc_malloc(sizeof(*old));
22173     *old = *real_packet;
22174     genhash_insert(*hash, old, old);
22175   } else {
22176     *old = *real_packet;
22177   }
22178   RECEIVE_PACKET_END(real_packet);
22179 }
22180 
send_packet_diplomacy_accept_treaty_req_100(struct connection * pc,const struct packet_diplomacy_accept_treaty_req * packet)22181 static int send_packet_diplomacy_accept_treaty_req_100(struct connection *pc, const struct packet_diplomacy_accept_treaty_req *packet)
22182 {
22183   const struct packet_diplomacy_accept_treaty_req *real_packet = packet;
22184   packet_diplomacy_accept_treaty_req_100_fields fields;
22185   struct packet_diplomacy_accept_treaty_req *old;
22186   bool differ;
22187   struct genhash **hash = pc->phs.sent + PACKET_DIPLOMACY_ACCEPT_TREATY_REQ;
22188   int different = 0;
22189   SEND_PACKET_START(PACKET_DIPLOMACY_ACCEPT_TREATY_REQ);
22190 
22191   log_packet_detailed("packet_diplomacy_accept_treaty_req_100: sending info about ()");
22192 
22193   if (NULL == *hash) {
22194     *hash = genhash_new_full(hash_packet_diplomacy_accept_treaty_req_100, cmp_packet_diplomacy_accept_treaty_req_100,
22195                              NULL, NULL, NULL, free);
22196   }
22197   BV_CLR_ALL(fields);
22198 
22199   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
22200     old = fc_malloc(sizeof(*old));
22201     *old = *real_packet;
22202     genhash_insert(*hash, old, old);
22203     memset(old, 0, sizeof(*old));
22204     different = 1;      /* Force to send. */
22205   }
22206 
22207   differ = (old->counterpart != real_packet->counterpart);
22208   if (differ) {
22209     different++;
22210     BV_SET(fields, 0);
22211   }
22212 
22213 
22214   DIO_BV_PUT(&dout, "fields", fields);
22215 
22216   if (BV_ISSET(fields, 0)) {
22217     log_packet_detailed("  field 'counterpart' has changed");
22218     DIO_PUT(uint8, &dout, "counterpart", real_packet->counterpart);
22219   }
22220 
22221   *old = *real_packet;
22222   SEND_PACKET_END(PACKET_DIPLOMACY_ACCEPT_TREATY_REQ);
22223 }
22224 
send_packet_diplomacy_accept_treaty_req(struct connection * pc,const struct packet_diplomacy_accept_treaty_req * packet)22225 int send_packet_diplomacy_accept_treaty_req(struct connection *pc, const struct packet_diplomacy_accept_treaty_req *packet)
22226 {
22227   if (!pc->used) {
22228     log_error("WARNING: trying to send data to the closed connection %s",
22229               conn_description(pc));
22230     return -1;
22231   }
22232   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_DIPLOMACY_ACCEPT_TREATY_REQ].packet != NULL, -1,
22233                         "Handler for PACKET_DIPLOMACY_ACCEPT_TREATY_REQ not installed");
22234   return pc->phs.handlers->send[PACKET_DIPLOMACY_ACCEPT_TREATY_REQ].packet(pc, packet);
22235 }
22236 
dsend_packet_diplomacy_accept_treaty_req(struct connection * pc,int counterpart)22237 int dsend_packet_diplomacy_accept_treaty_req(struct connection *pc, int counterpart)
22238 {
22239   struct packet_diplomacy_accept_treaty_req packet, *real_packet = &packet;
22240 
22241   real_packet->counterpart = counterpart;
22242 
22243   return send_packet_diplomacy_accept_treaty_req(pc, real_packet);
22244 }
22245 
22246 #define hash_packet_diplomacy_accept_treaty_100 hash_const
22247 
22248 #define cmp_packet_diplomacy_accept_treaty_100 cmp_const
22249 
22250 BV_DEFINE(packet_diplomacy_accept_treaty_100_fields, 3);
22251 
receive_packet_diplomacy_accept_treaty_100(struct connection * pc)22252 static struct packet_diplomacy_accept_treaty *receive_packet_diplomacy_accept_treaty_100(struct connection *pc)
22253 {
22254   packet_diplomacy_accept_treaty_100_fields fields;
22255   struct packet_diplomacy_accept_treaty *old;
22256   struct genhash **hash = pc->phs.received + PACKET_DIPLOMACY_ACCEPT_TREATY;
22257   RECEIVE_PACKET_START(packet_diplomacy_accept_treaty, real_packet);
22258 
22259   DIO_BV_GET(&din, fields);
22260 
22261   log_packet_detailed("packet_diplomacy_accept_treaty_100: got info about ()");
22262 
22263   if (NULL == *hash) {
22264     *hash = genhash_new_full(hash_packet_diplomacy_accept_treaty_100, cmp_packet_diplomacy_accept_treaty_100,
22265                              NULL, NULL, NULL, free);
22266   }
22267 
22268   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
22269     *real_packet = *old;
22270   } else {
22271     log_packet_detailed("  no old info");
22272     memset(real_packet, 0, sizeof(*real_packet));
22273   }
22274 
22275   if (BV_ISSET(fields, 0)) {
22276     log_packet_detailed("  got field 'counterpart'");
22277     if (!DIO_GET(uint8, &din, "counterpart", &real_packet->counterpart)) {
22278       RECEIVE_PACKET_FIELD_ERROR(counterpart);
22279     }
22280   }
22281   real_packet->I_accepted = BV_ISSET(fields, 1);
22282   real_packet->other_accepted = BV_ISSET(fields, 2);
22283 
22284   if (NULL == old) {
22285     old = fc_malloc(sizeof(*old));
22286     *old = *real_packet;
22287     genhash_insert(*hash, old, old);
22288   } else {
22289     *old = *real_packet;
22290   }
22291   RECEIVE_PACKET_END(real_packet);
22292 }
22293 
send_packet_diplomacy_accept_treaty_100(struct connection * pc,const struct packet_diplomacy_accept_treaty * packet)22294 static int send_packet_diplomacy_accept_treaty_100(struct connection *pc, const struct packet_diplomacy_accept_treaty *packet)
22295 {
22296   const struct packet_diplomacy_accept_treaty *real_packet = packet;
22297   packet_diplomacy_accept_treaty_100_fields fields;
22298   struct packet_diplomacy_accept_treaty *old;
22299   bool differ;
22300   struct genhash **hash = pc->phs.sent + PACKET_DIPLOMACY_ACCEPT_TREATY;
22301   int different = 0;
22302   SEND_PACKET_START(PACKET_DIPLOMACY_ACCEPT_TREATY);
22303 
22304   log_packet_detailed("packet_diplomacy_accept_treaty_100: sending info about ()");
22305 
22306   if (NULL == *hash) {
22307     *hash = genhash_new_full(hash_packet_diplomacy_accept_treaty_100, cmp_packet_diplomacy_accept_treaty_100,
22308                              NULL, NULL, NULL, free);
22309   }
22310   BV_CLR_ALL(fields);
22311 
22312   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
22313     old = fc_malloc(sizeof(*old));
22314     *old = *real_packet;
22315     genhash_insert(*hash, old, old);
22316     memset(old, 0, sizeof(*old));
22317     different = 1;      /* Force to send. */
22318   }
22319 
22320   differ = (old->counterpart != real_packet->counterpart);
22321   if (differ) {
22322     different++;
22323     BV_SET(fields, 0);
22324   }
22325 
22326   differ = (old->I_accepted != real_packet->I_accepted);
22327   if (differ) {
22328     different++;
22329   }
22330   if (packet->I_accepted) {
22331     BV_SET(fields, 1);
22332   }
22333 
22334   differ = (old->other_accepted != real_packet->other_accepted);
22335   if (differ) {
22336     different++;
22337   }
22338   if (packet->other_accepted) {
22339     BV_SET(fields, 2);
22340   }
22341 
22342 
22343   DIO_BV_PUT(&dout, "fields", fields);
22344 
22345   if (BV_ISSET(fields, 0)) {
22346     log_packet_detailed("  field 'counterpart' has changed");
22347     DIO_PUT(uint8, &dout, "counterpart", real_packet->counterpart);
22348   }
22349   /* field 1 is folded into the header */
22350   /* field 2 is folded into the header */
22351 
22352   *old = *real_packet;
22353   SEND_PACKET_END(PACKET_DIPLOMACY_ACCEPT_TREATY);
22354 }
22355 
send_packet_diplomacy_accept_treaty(struct connection * pc,const struct packet_diplomacy_accept_treaty * packet)22356 int send_packet_diplomacy_accept_treaty(struct connection *pc, const struct packet_diplomacy_accept_treaty *packet)
22357 {
22358   if (!pc->used) {
22359     log_error("WARNING: trying to send data to the closed connection %s",
22360               conn_description(pc));
22361     return -1;
22362   }
22363   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_DIPLOMACY_ACCEPT_TREATY].packet != NULL, -1,
22364                         "Handler for PACKET_DIPLOMACY_ACCEPT_TREATY not installed");
22365   return pc->phs.handlers->send[PACKET_DIPLOMACY_ACCEPT_TREATY].packet(pc, packet);
22366 }
22367 
lsend_packet_diplomacy_accept_treaty(struct conn_list * dest,const struct packet_diplomacy_accept_treaty * packet)22368 void lsend_packet_diplomacy_accept_treaty(struct conn_list *dest, const struct packet_diplomacy_accept_treaty *packet)
22369 {
22370   conn_list_iterate(dest, pconn) {
22371     send_packet_diplomacy_accept_treaty(pconn, packet);
22372   } conn_list_iterate_end;
22373 }
22374 
dsend_packet_diplomacy_accept_treaty(struct connection * pc,int counterpart,bool I_accepted,bool other_accepted)22375 int dsend_packet_diplomacy_accept_treaty(struct connection *pc, int counterpart, bool I_accepted, bool other_accepted)
22376 {
22377   struct packet_diplomacy_accept_treaty packet, *real_packet = &packet;
22378 
22379   real_packet->counterpart = counterpart;
22380   real_packet->I_accepted = I_accepted;
22381   real_packet->other_accepted = other_accepted;
22382 
22383   return send_packet_diplomacy_accept_treaty(pc, real_packet);
22384 }
22385 
dlsend_packet_diplomacy_accept_treaty(struct conn_list * dest,int counterpart,bool I_accepted,bool other_accepted)22386 void dlsend_packet_diplomacy_accept_treaty(struct conn_list *dest, int counterpart, bool I_accepted, bool other_accepted)
22387 {
22388   struct packet_diplomacy_accept_treaty packet, *real_packet = &packet;
22389 
22390   real_packet->counterpart = counterpart;
22391   real_packet->I_accepted = I_accepted;
22392   real_packet->other_accepted = other_accepted;
22393 
22394   lsend_packet_diplomacy_accept_treaty(dest, real_packet);
22395 }
22396 
22397 #define hash_packet_diplomacy_cancel_pact_100 hash_const
22398 
22399 #define cmp_packet_diplomacy_cancel_pact_100 cmp_const
22400 
22401 BV_DEFINE(packet_diplomacy_cancel_pact_100_fields, 2);
22402 
receive_packet_diplomacy_cancel_pact_100(struct connection * pc)22403 static struct packet_diplomacy_cancel_pact *receive_packet_diplomacy_cancel_pact_100(struct connection *pc)
22404 {
22405   packet_diplomacy_cancel_pact_100_fields fields;
22406   struct packet_diplomacy_cancel_pact *old;
22407   struct genhash **hash = pc->phs.received + PACKET_DIPLOMACY_CANCEL_PACT;
22408   RECEIVE_PACKET_START(packet_diplomacy_cancel_pact, real_packet);
22409 
22410   DIO_BV_GET(&din, fields);
22411 
22412   log_packet_detailed("packet_diplomacy_cancel_pact_100: got info about ()");
22413 
22414   if (NULL == *hash) {
22415     *hash = genhash_new_full(hash_packet_diplomacy_cancel_pact_100, cmp_packet_diplomacy_cancel_pact_100,
22416                              NULL, NULL, NULL, free);
22417   }
22418 
22419   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
22420     *real_packet = *old;
22421   } else {
22422     log_packet_detailed("  no old info");
22423     memset(real_packet, 0, sizeof(*real_packet));
22424   }
22425 
22426   if (BV_ISSET(fields, 0)) {
22427     log_packet_detailed("  got field 'other_player_id'");
22428     if (!DIO_GET(uint8, &din, "other_player_id", &real_packet->other_player_id)) {
22429       RECEIVE_PACKET_FIELD_ERROR(other_player_id);
22430     }
22431   }
22432   if (BV_ISSET(fields, 1)) {
22433     log_packet_detailed("  got field 'clause'");
22434     {
22435       int readin;
22436 
22437       if (!DIO_GET(uint8, &din, "clause", &readin)) {
22438         RECEIVE_PACKET_FIELD_ERROR(clause);
22439       }
22440       real_packet->clause = readin;
22441     }
22442   }
22443 
22444   if (NULL == old) {
22445     old = fc_malloc(sizeof(*old));
22446     *old = *real_packet;
22447     genhash_insert(*hash, old, old);
22448   } else {
22449     *old = *real_packet;
22450   }
22451   RECEIVE_PACKET_END(real_packet);
22452 }
22453 
send_packet_diplomacy_cancel_pact_100(struct connection * pc,const struct packet_diplomacy_cancel_pact * packet)22454 static int send_packet_diplomacy_cancel_pact_100(struct connection *pc, const struct packet_diplomacy_cancel_pact *packet)
22455 {
22456   const struct packet_diplomacy_cancel_pact *real_packet = packet;
22457   packet_diplomacy_cancel_pact_100_fields fields;
22458   struct packet_diplomacy_cancel_pact *old;
22459   bool differ;
22460   struct genhash **hash = pc->phs.sent + PACKET_DIPLOMACY_CANCEL_PACT;
22461   int different = 0;
22462   SEND_PACKET_START(PACKET_DIPLOMACY_CANCEL_PACT);
22463 
22464   log_packet_detailed("packet_diplomacy_cancel_pact_100: sending info about ()");
22465 
22466   if (NULL == *hash) {
22467     *hash = genhash_new_full(hash_packet_diplomacy_cancel_pact_100, cmp_packet_diplomacy_cancel_pact_100,
22468                              NULL, NULL, NULL, free);
22469   }
22470   BV_CLR_ALL(fields);
22471 
22472   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
22473     old = fc_malloc(sizeof(*old));
22474     *old = *real_packet;
22475     genhash_insert(*hash, old, old);
22476     memset(old, 0, sizeof(*old));
22477     different = 1;      /* Force to send. */
22478   }
22479 
22480   differ = (old->other_player_id != real_packet->other_player_id);
22481   if (differ) {
22482     different++;
22483     BV_SET(fields, 0);
22484   }
22485 
22486   differ = (old->clause != real_packet->clause);
22487   if (differ) {
22488     different++;
22489     BV_SET(fields, 1);
22490   }
22491 
22492 
22493   DIO_BV_PUT(&dout, "fields", fields);
22494 
22495   if (BV_ISSET(fields, 0)) {
22496     log_packet_detailed("  field 'other_player_id' has changed");
22497     DIO_PUT(uint8, &dout, "other_player_id", real_packet->other_player_id);
22498   }
22499   if (BV_ISSET(fields, 1)) {
22500     log_packet_detailed("  field 'clause' has changed");
22501     DIO_PUT(uint8, &dout, "clause", real_packet->clause);
22502   }
22503 
22504   *old = *real_packet;
22505   SEND_PACKET_END(PACKET_DIPLOMACY_CANCEL_PACT);
22506 }
22507 
send_packet_diplomacy_cancel_pact(struct connection * pc,const struct packet_diplomacy_cancel_pact * packet)22508 int send_packet_diplomacy_cancel_pact(struct connection *pc, const struct packet_diplomacy_cancel_pact *packet)
22509 {
22510   if (!pc->used) {
22511     log_error("WARNING: trying to send data to the closed connection %s",
22512               conn_description(pc));
22513     return -1;
22514   }
22515   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_DIPLOMACY_CANCEL_PACT].packet != NULL, -1,
22516                         "Handler for PACKET_DIPLOMACY_CANCEL_PACT not installed");
22517   return pc->phs.handlers->send[PACKET_DIPLOMACY_CANCEL_PACT].packet(pc, packet);
22518 }
22519 
dsend_packet_diplomacy_cancel_pact(struct connection * pc,int other_player_id,enum clause_type clause)22520 int dsend_packet_diplomacy_cancel_pact(struct connection *pc, int other_player_id, enum clause_type clause)
22521 {
22522   struct packet_diplomacy_cancel_pact packet, *real_packet = &packet;
22523 
22524   real_packet->other_player_id = other_player_id;
22525   real_packet->clause = clause;
22526 
22527   return send_packet_diplomacy_cancel_pact(pc, real_packet);
22528 }
22529 
22530 #define hash_packet_page_msg_100 hash_const
22531 
22532 #define cmp_packet_page_msg_100 cmp_const
22533 
22534 BV_DEFINE(packet_page_msg_100_fields, 5);
22535 
receive_packet_page_msg_100(struct connection * pc)22536 static struct packet_page_msg *receive_packet_page_msg_100(struct connection *pc)
22537 {
22538   packet_page_msg_100_fields fields;
22539   struct packet_page_msg *old;
22540   struct genhash **hash = pc->phs.received + PACKET_PAGE_MSG;
22541   RECEIVE_PACKET_START(packet_page_msg, real_packet);
22542 
22543   DIO_BV_GET(&din, fields);
22544 
22545   log_packet_detailed("packet_page_msg_100: got info about ()");
22546 
22547   if (NULL == *hash) {
22548     *hash = genhash_new_full(hash_packet_page_msg_100, cmp_packet_page_msg_100,
22549                              NULL, NULL, NULL, free);
22550   }
22551 
22552   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
22553     *real_packet = *old;
22554   } else {
22555     log_packet_detailed("  no old info");
22556     memset(real_packet, 0, sizeof(*real_packet));
22557   }
22558 
22559   if (BV_ISSET(fields, 0)) {
22560     log_packet_detailed("  got field 'caption'");
22561     if (!DIO_GET(string, &din, "caption", real_packet->caption, sizeof(real_packet->caption))) {
22562       RECEIVE_PACKET_FIELD_ERROR(caption);
22563     }
22564   }
22565   if (BV_ISSET(fields, 1)) {
22566     log_packet_detailed("  got field 'headline'");
22567     if (!DIO_GET(string, &din, "headline", real_packet->headline, sizeof(real_packet->headline))) {
22568       RECEIVE_PACKET_FIELD_ERROR(headline);
22569     }
22570   }
22571   if (BV_ISSET(fields, 2)) {
22572     log_packet_detailed("  got field 'event'");
22573     {
22574       int readin;
22575 
22576       if (!DIO_GET(sint16, &din, "event", &readin)) {
22577         RECEIVE_PACKET_FIELD_ERROR(event);
22578       }
22579       real_packet->event = readin;
22580     }
22581   }
22582   if (BV_ISSET(fields, 3)) {
22583     log_packet_detailed("  got field 'len'");
22584     if (!DIO_GET(uint32, &din, "len", &real_packet->len)) {
22585       RECEIVE_PACKET_FIELD_ERROR(len);
22586     }
22587   }
22588   if (BV_ISSET(fields, 4)) {
22589     log_packet_detailed("  got field 'parts'");
22590     if (!DIO_GET(uint16, &din, "parts", &real_packet->parts)) {
22591       RECEIVE_PACKET_FIELD_ERROR(parts);
22592     }
22593   }
22594 
22595   if (NULL == old) {
22596     old = fc_malloc(sizeof(*old));
22597     *old = *real_packet;
22598     genhash_insert(*hash, old, old);
22599   } else {
22600     *old = *real_packet;
22601   }
22602   RECEIVE_PACKET_END(real_packet);
22603 }
22604 
send_packet_page_msg_100(struct connection * pc,const struct packet_page_msg * packet)22605 static int send_packet_page_msg_100(struct connection *pc, const struct packet_page_msg *packet)
22606 {
22607   const struct packet_page_msg *real_packet = packet;
22608   packet_page_msg_100_fields fields;
22609   struct packet_page_msg *old;
22610   bool differ;
22611   struct genhash **hash = pc->phs.sent + PACKET_PAGE_MSG;
22612   int different = 0;
22613   SEND_PACKET_START(PACKET_PAGE_MSG);
22614 
22615   log_packet_detailed("packet_page_msg_100: sending info about ()");
22616 
22617   if (NULL == *hash) {
22618     *hash = genhash_new_full(hash_packet_page_msg_100, cmp_packet_page_msg_100,
22619                              NULL, NULL, NULL, free);
22620   }
22621   BV_CLR_ALL(fields);
22622 
22623   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
22624     old = fc_malloc(sizeof(*old));
22625     *old = *real_packet;
22626     genhash_insert(*hash, old, old);
22627     memset(old, 0, sizeof(*old));
22628     different = 1;      /* Force to send. */
22629   }
22630 
22631   differ = (strcmp(old->caption, real_packet->caption) != 0);
22632   if (differ) {
22633     different++;
22634     BV_SET(fields, 0);
22635   }
22636 
22637   differ = (strcmp(old->headline, real_packet->headline) != 0);
22638   if (differ) {
22639     different++;
22640     BV_SET(fields, 1);
22641   }
22642 
22643   differ = (old->event != real_packet->event);
22644   if (differ) {
22645     different++;
22646     BV_SET(fields, 2);
22647   }
22648 
22649   differ = (old->len != real_packet->len);
22650   if (differ) {
22651     different++;
22652     BV_SET(fields, 3);
22653   }
22654 
22655   differ = (old->parts != real_packet->parts);
22656   if (differ) {
22657     different++;
22658     BV_SET(fields, 4);
22659   }
22660 
22661 
22662   DIO_BV_PUT(&dout, "fields", fields);
22663 
22664   if (BV_ISSET(fields, 0)) {
22665     log_packet_detailed("  field 'caption' has changed");
22666     DIO_PUT(string, &dout, "caption", real_packet->caption);
22667   }
22668   if (BV_ISSET(fields, 1)) {
22669     log_packet_detailed("  field 'headline' has changed");
22670     DIO_PUT(string, &dout, "headline", real_packet->headline);
22671   }
22672   if (BV_ISSET(fields, 2)) {
22673     log_packet_detailed("  field 'event' has changed");
22674     DIO_PUT(sint16, &dout, "event", real_packet->event);
22675   }
22676   if (BV_ISSET(fields, 3)) {
22677     log_packet_detailed("  field 'len' has changed");
22678     DIO_PUT(uint32, &dout, "len", real_packet->len);
22679   }
22680   if (BV_ISSET(fields, 4)) {
22681     log_packet_detailed("  field 'parts' has changed");
22682     DIO_PUT(uint16, &dout, "parts", real_packet->parts);
22683   }
22684 
22685   *old = *real_packet;
22686   SEND_PACKET_END(PACKET_PAGE_MSG);
22687 }
22688 
send_packet_page_msg(struct connection * pc,const struct packet_page_msg * packet)22689 int send_packet_page_msg(struct connection *pc, const struct packet_page_msg *packet)
22690 {
22691   if (!pc->used) {
22692     log_error("WARNING: trying to send data to the closed connection %s",
22693               conn_description(pc));
22694     return -1;
22695   }
22696   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PAGE_MSG].packet != NULL, -1,
22697                         "Handler for PACKET_PAGE_MSG not installed");
22698   return pc->phs.handlers->send[PACKET_PAGE_MSG].packet(pc, packet);
22699 }
22700 
lsend_packet_page_msg(struct conn_list * dest,const struct packet_page_msg * packet)22701 void lsend_packet_page_msg(struct conn_list *dest, const struct packet_page_msg *packet)
22702 {
22703   conn_list_iterate(dest, pconn) {
22704     send_packet_page_msg(pconn, packet);
22705   } conn_list_iterate_end;
22706 }
22707 
22708 #define hash_packet_page_msg_part_100 hash_const
22709 
22710 #define cmp_packet_page_msg_part_100 cmp_const
22711 
22712 BV_DEFINE(packet_page_msg_part_100_fields, 1);
22713 
receive_packet_page_msg_part_100(struct connection * pc)22714 static struct packet_page_msg_part *receive_packet_page_msg_part_100(struct connection *pc)
22715 {
22716   packet_page_msg_part_100_fields fields;
22717   struct packet_page_msg_part *old;
22718   struct genhash **hash = pc->phs.received + PACKET_PAGE_MSG_PART;
22719   RECEIVE_PACKET_START(packet_page_msg_part, real_packet);
22720 
22721   DIO_BV_GET(&din, fields);
22722 
22723   log_packet_detailed("packet_page_msg_part_100: got info about ()");
22724 
22725   if (NULL == *hash) {
22726     *hash = genhash_new_full(hash_packet_page_msg_part_100, cmp_packet_page_msg_part_100,
22727                              NULL, NULL, NULL, free);
22728   }
22729 
22730   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
22731     *real_packet = *old;
22732   } else {
22733     log_packet_detailed("  no old info");
22734     memset(real_packet, 0, sizeof(*real_packet));
22735   }
22736 
22737   if (BV_ISSET(fields, 0)) {
22738     log_packet_detailed("  got field 'lines'");
22739     if (!DIO_GET(string, &din, "lines", real_packet->lines, sizeof(real_packet->lines))) {
22740       RECEIVE_PACKET_FIELD_ERROR(lines);
22741     }
22742   }
22743 
22744   if (NULL == old) {
22745     old = fc_malloc(sizeof(*old));
22746     *old = *real_packet;
22747     genhash_insert(*hash, old, old);
22748   } else {
22749     *old = *real_packet;
22750   }
22751   RECEIVE_PACKET_END(real_packet);
22752 }
22753 
send_packet_page_msg_part_100(struct connection * pc,const struct packet_page_msg_part * packet)22754 static int send_packet_page_msg_part_100(struct connection *pc, const struct packet_page_msg_part *packet)
22755 {
22756   const struct packet_page_msg_part *real_packet = packet;
22757   packet_page_msg_part_100_fields fields;
22758   struct packet_page_msg_part *old;
22759   bool differ;
22760   struct genhash **hash = pc->phs.sent + PACKET_PAGE_MSG_PART;
22761   int different = 0;
22762   SEND_PACKET_START(PACKET_PAGE_MSG_PART);
22763 
22764   log_packet_detailed("packet_page_msg_part_100: sending info about ()");
22765 
22766   if (NULL == *hash) {
22767     *hash = genhash_new_full(hash_packet_page_msg_part_100, cmp_packet_page_msg_part_100,
22768                              NULL, NULL, NULL, free);
22769   }
22770   BV_CLR_ALL(fields);
22771 
22772   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
22773     old = fc_malloc(sizeof(*old));
22774     *old = *real_packet;
22775     genhash_insert(*hash, old, old);
22776     memset(old, 0, sizeof(*old));
22777     different = 1;      /* Force to send. */
22778   }
22779 
22780   differ = (strcmp(old->lines, real_packet->lines) != 0);
22781   if (differ) {
22782     different++;
22783     BV_SET(fields, 0);
22784   }
22785 
22786 
22787   DIO_BV_PUT(&dout, "fields", fields);
22788 
22789   if (BV_ISSET(fields, 0)) {
22790     log_packet_detailed("  field 'lines' has changed");
22791     DIO_PUT(string, &dout, "lines", real_packet->lines);
22792   }
22793 
22794   *old = *real_packet;
22795   SEND_PACKET_END(PACKET_PAGE_MSG_PART);
22796 }
22797 
send_packet_page_msg_part(struct connection * pc,const struct packet_page_msg_part * packet)22798 int send_packet_page_msg_part(struct connection *pc, const struct packet_page_msg_part *packet)
22799 {
22800   if (!pc->used) {
22801     log_error("WARNING: trying to send data to the closed connection %s",
22802               conn_description(pc));
22803     return -1;
22804   }
22805   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PAGE_MSG_PART].packet != NULL, -1,
22806                         "Handler for PACKET_PAGE_MSG_PART not installed");
22807   return pc->phs.handlers->send[PACKET_PAGE_MSG_PART].packet(pc, packet);
22808 }
22809 
lsend_packet_page_msg_part(struct conn_list * dest,const struct packet_page_msg_part * packet)22810 void lsend_packet_page_msg_part(struct conn_list *dest, const struct packet_page_msg_part *packet)
22811 {
22812   conn_list_iterate(dest, pconn) {
22813     send_packet_page_msg_part(pconn, packet);
22814   } conn_list_iterate_end;
22815 }
22816 
22817 #define hash_packet_report_req_100 hash_const
22818 
22819 #define cmp_packet_report_req_100 cmp_const
22820 
22821 BV_DEFINE(packet_report_req_100_fields, 1);
22822 
receive_packet_report_req_100(struct connection * pc)22823 static struct packet_report_req *receive_packet_report_req_100(struct connection *pc)
22824 {
22825   packet_report_req_100_fields fields;
22826   struct packet_report_req *old;
22827   struct genhash **hash = pc->phs.received + PACKET_REPORT_REQ;
22828   RECEIVE_PACKET_START(packet_report_req, real_packet);
22829 
22830   DIO_BV_GET(&din, fields);
22831 
22832   log_packet_detailed("packet_report_req_100: got info about ()");
22833 
22834   if (NULL == *hash) {
22835     *hash = genhash_new_full(hash_packet_report_req_100, cmp_packet_report_req_100,
22836                              NULL, NULL, NULL, free);
22837   }
22838 
22839   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
22840     *real_packet = *old;
22841   } else {
22842     log_packet_detailed("  no old info");
22843     memset(real_packet, 0, sizeof(*real_packet));
22844   }
22845 
22846   if (BV_ISSET(fields, 0)) {
22847     log_packet_detailed("  got field 'type'");
22848     {
22849       int readin;
22850 
22851       if (!DIO_GET(uint8, &din, "type", &readin)) {
22852         RECEIVE_PACKET_FIELD_ERROR(type);
22853       }
22854       real_packet->type = readin;
22855     }
22856   }
22857 
22858   if (NULL == old) {
22859     old = fc_malloc(sizeof(*old));
22860     *old = *real_packet;
22861     genhash_insert(*hash, old, old);
22862   } else {
22863     *old = *real_packet;
22864   }
22865   RECEIVE_PACKET_END(real_packet);
22866 }
22867 
send_packet_report_req_100(struct connection * pc,const struct packet_report_req * packet)22868 static int send_packet_report_req_100(struct connection *pc, const struct packet_report_req *packet)
22869 {
22870   const struct packet_report_req *real_packet = packet;
22871   packet_report_req_100_fields fields;
22872   struct packet_report_req *old;
22873   bool differ;
22874   struct genhash **hash = pc->phs.sent + PACKET_REPORT_REQ;
22875   int different = 0;
22876   SEND_PACKET_START(PACKET_REPORT_REQ);
22877 
22878   log_packet_detailed("packet_report_req_100: sending info about ()");
22879 
22880   if (NULL == *hash) {
22881     *hash = genhash_new_full(hash_packet_report_req_100, cmp_packet_report_req_100,
22882                              NULL, NULL, NULL, free);
22883   }
22884   BV_CLR_ALL(fields);
22885 
22886   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
22887     old = fc_malloc(sizeof(*old));
22888     *old = *real_packet;
22889     genhash_insert(*hash, old, old);
22890     memset(old, 0, sizeof(*old));
22891     different = 1;      /* Force to send. */
22892   }
22893 
22894   differ = (old->type != real_packet->type);
22895   if (differ) {
22896     different++;
22897     BV_SET(fields, 0);
22898   }
22899 
22900 
22901   DIO_BV_PUT(&dout, "fields", fields);
22902 
22903   if (BV_ISSET(fields, 0)) {
22904     log_packet_detailed("  field 'type' has changed");
22905     DIO_PUT(uint8, &dout, "type", real_packet->type);
22906   }
22907 
22908   *old = *real_packet;
22909   SEND_PACKET_END(PACKET_REPORT_REQ);
22910 }
22911 
send_packet_report_req(struct connection * pc,const struct packet_report_req * packet)22912 int send_packet_report_req(struct connection *pc, const struct packet_report_req *packet)
22913 {
22914   if (!pc->used) {
22915     log_error("WARNING: trying to send data to the closed connection %s",
22916               conn_description(pc));
22917     return -1;
22918   }
22919   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_REPORT_REQ].packet != NULL, -1,
22920                         "Handler for PACKET_REPORT_REQ not installed");
22921   return pc->phs.handlers->send[PACKET_REPORT_REQ].packet(pc, packet);
22922 }
22923 
dsend_packet_report_req(struct connection * pc,enum report_type type)22924 int dsend_packet_report_req(struct connection *pc, enum report_type type)
22925 {
22926   struct packet_report_req packet, *real_packet = &packet;
22927 
22928   real_packet->type = type;
22929 
22930   return send_packet_report_req(pc, real_packet);
22931 }
22932 
hash_packet_conn_info_100(const void * vkey)22933 static genhash_val_t hash_packet_conn_info_100(const void *vkey)
22934 {
22935   const struct packet_conn_info *key = (const struct packet_conn_info *) vkey;
22936 
22937   return key->id;
22938 }
22939 
cmp_packet_conn_info_100(const void * vkey1,const void * vkey2)22940 static bool cmp_packet_conn_info_100(const void *vkey1, const void *vkey2)
22941 {
22942   const struct packet_conn_info *key1 = (const struct packet_conn_info *) vkey1;
22943   const struct packet_conn_info *key2 = (const struct packet_conn_info *) vkey2;
22944 
22945   return key1->id == key2->id;
22946 }
22947 
22948 BV_DEFINE(packet_conn_info_100_fields, 8);
22949 
receive_packet_conn_info_100(struct connection * pc)22950 static struct packet_conn_info *receive_packet_conn_info_100(struct connection *pc)
22951 {
22952   packet_conn_info_100_fields fields;
22953   struct packet_conn_info *old;
22954   struct genhash **hash = pc->phs.received + PACKET_CONN_INFO;
22955   RECEIVE_PACKET_START(packet_conn_info, real_packet);
22956 
22957   DIO_BV_GET(&din, fields);
22958   if (!DIO_GET(sint16, &din, "id", &real_packet->id)) {
22959     RECEIVE_PACKET_FIELD_ERROR(id);
22960   }
22961 
22962   log_packet_detailed("packet_conn_info_100: got info about (%d)",
22963     real_packet->id);
22964 
22965   if (NULL == *hash) {
22966     *hash = genhash_new_full(hash_packet_conn_info_100, cmp_packet_conn_info_100,
22967                              NULL, NULL, NULL, free);
22968   }
22969 
22970   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
22971     *real_packet = *old;
22972   } else {
22973     int id = real_packet->id;
22974 
22975     log_packet_detailed("  no old info");
22976     memset(real_packet, 0, sizeof(*real_packet));
22977 
22978     real_packet->id = id;
22979   }
22980 
22981   real_packet->used = BV_ISSET(fields, 0);
22982   real_packet->established = BV_ISSET(fields, 1);
22983   real_packet->observer = BV_ISSET(fields, 2);
22984   if (BV_ISSET(fields, 3)) {
22985     log_packet_detailed("  got field 'player_num'");
22986     if (!DIO_GET(uint8, &din, "player_num", &real_packet->player_num)) {
22987       RECEIVE_PACKET_FIELD_ERROR(player_num);
22988     }
22989   }
22990   if (BV_ISSET(fields, 4)) {
22991     log_packet_detailed("  got field 'access_level'");
22992     {
22993       int readin;
22994 
22995       if (!DIO_GET(uint8, &din, "access_level", &readin)) {
22996         RECEIVE_PACKET_FIELD_ERROR(access_level);
22997       }
22998       real_packet->access_level = readin;
22999     }
23000   }
23001   if (BV_ISSET(fields, 5)) {
23002     log_packet_detailed("  got field 'username'");
23003     if (!DIO_GET(string, &din, "username", real_packet->username, sizeof(real_packet->username))) {
23004       RECEIVE_PACKET_FIELD_ERROR(username);
23005     }
23006   }
23007   if (BV_ISSET(fields, 6)) {
23008     log_packet_detailed("  got field 'addr'");
23009     if (!DIO_GET(string, &din, "addr", real_packet->addr, sizeof(real_packet->addr))) {
23010       RECEIVE_PACKET_FIELD_ERROR(addr);
23011     }
23012   }
23013   if (BV_ISSET(fields, 7)) {
23014     log_packet_detailed("  got field 'capability'");
23015     if (!DIO_GET(string, &din, "capability", real_packet->capability, sizeof(real_packet->capability))) {
23016       RECEIVE_PACKET_FIELD_ERROR(capability);
23017     }
23018   }
23019 
23020   if (NULL == old) {
23021     old = fc_malloc(sizeof(*old));
23022     *old = *real_packet;
23023     genhash_insert(*hash, old, old);
23024   } else {
23025     *old = *real_packet;
23026   }
23027   RECEIVE_PACKET_END(real_packet);
23028 }
23029 
send_packet_conn_info_100(struct connection * pc,const struct packet_conn_info * packet)23030 static int send_packet_conn_info_100(struct connection *pc, const struct packet_conn_info *packet)
23031 {
23032   const struct packet_conn_info *real_packet = packet;
23033   packet_conn_info_100_fields fields;
23034   struct packet_conn_info *old;
23035   bool differ;
23036   struct genhash **hash = pc->phs.sent + PACKET_CONN_INFO;
23037   int different = 0;
23038   SEND_PACKET_START(PACKET_CONN_INFO);
23039 
23040   log_packet_detailed("packet_conn_info_100: sending info about (%d)",
23041     real_packet->id);
23042 
23043   if (NULL == *hash) {
23044     *hash = genhash_new_full(hash_packet_conn_info_100, cmp_packet_conn_info_100,
23045                              NULL, NULL, NULL, free);
23046   }
23047   BV_CLR_ALL(fields);
23048 
23049   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
23050     old = fc_malloc(sizeof(*old));
23051     *old = *real_packet;
23052     genhash_insert(*hash, old, old);
23053     memset(old, 0, sizeof(*old));
23054     different = 1;      /* Force to send. */
23055   }
23056 
23057   differ = (old->used != real_packet->used);
23058   if (differ) {
23059     different++;
23060   }
23061   if (packet->used) {
23062     BV_SET(fields, 0);
23063   }
23064 
23065   differ = (old->established != real_packet->established);
23066   if (differ) {
23067     different++;
23068   }
23069   if (packet->established) {
23070     BV_SET(fields, 1);
23071   }
23072 
23073   differ = (old->observer != real_packet->observer);
23074   if (differ) {
23075     different++;
23076   }
23077   if (packet->observer) {
23078     BV_SET(fields, 2);
23079   }
23080 
23081   differ = (old->player_num != real_packet->player_num);
23082   if (differ) {
23083     different++;
23084     BV_SET(fields, 3);
23085   }
23086 
23087   differ = (old->access_level != real_packet->access_level);
23088   if (differ) {
23089     different++;
23090     BV_SET(fields, 4);
23091   }
23092 
23093   differ = (strcmp(old->username, real_packet->username) != 0);
23094   if (differ) {
23095     different++;
23096     BV_SET(fields, 5);
23097   }
23098 
23099   differ = (strcmp(old->addr, real_packet->addr) != 0);
23100   if (differ) {
23101     different++;
23102     BV_SET(fields, 6);
23103   }
23104 
23105   differ = (strcmp(old->capability, real_packet->capability) != 0);
23106   if (differ) {
23107     different++;
23108     BV_SET(fields, 7);
23109   }
23110 
23111 
23112   if (different == 0) {
23113     log_packet_detailed("  no change -> discard");
23114     return 0;
23115   }
23116 
23117   DIO_BV_PUT(&dout, "fields", fields);
23118   DIO_PUT(sint16, &dout, "id", real_packet->id);
23119 
23120   /* field 0 is folded into the header */
23121   /* field 1 is folded into the header */
23122   /* field 2 is folded into the header */
23123   if (BV_ISSET(fields, 3)) {
23124     log_packet_detailed("  field 'player_num' has changed");
23125     DIO_PUT(uint8, &dout, "player_num", real_packet->player_num);
23126   }
23127   if (BV_ISSET(fields, 4)) {
23128     log_packet_detailed("  field 'access_level' has changed");
23129     DIO_PUT(uint8, &dout, "access_level", real_packet->access_level);
23130   }
23131   if (BV_ISSET(fields, 5)) {
23132     log_packet_detailed("  field 'username' has changed");
23133     DIO_PUT(string, &dout, "username", real_packet->username);
23134   }
23135   if (BV_ISSET(fields, 6)) {
23136     log_packet_detailed("  field 'addr' has changed");
23137     DIO_PUT(string, &dout, "addr", real_packet->addr);
23138   }
23139   if (BV_ISSET(fields, 7)) {
23140     log_packet_detailed("  field 'capability' has changed");
23141     DIO_PUT(string, &dout, "capability", real_packet->capability);
23142   }
23143 
23144   *old = *real_packet;
23145   SEND_PACKET_END(PACKET_CONN_INFO);
23146 }
23147 
send_packet_conn_info(struct connection * pc,const struct packet_conn_info * packet)23148 int send_packet_conn_info(struct connection *pc, const struct packet_conn_info *packet)
23149 {
23150   if (!pc->used) {
23151     log_error("WARNING: trying to send data to the closed connection %s",
23152               conn_description(pc));
23153     return -1;
23154   }
23155   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CONN_INFO].packet != NULL, -1,
23156                         "Handler for PACKET_CONN_INFO not installed");
23157   return pc->phs.handlers->send[PACKET_CONN_INFO].packet(pc, packet);
23158 }
23159 
lsend_packet_conn_info(struct conn_list * dest,const struct packet_conn_info * packet)23160 void lsend_packet_conn_info(struct conn_list *dest, const struct packet_conn_info *packet)
23161 {
23162   conn_list_iterate(dest, pconn) {
23163     send_packet_conn_info(pconn, packet);
23164   } conn_list_iterate_end;
23165 }
23166 
23167 #define hash_packet_conn_ping_info_100 hash_const
23168 
23169 #define cmp_packet_conn_ping_info_100 cmp_const
23170 
23171 BV_DEFINE(packet_conn_ping_info_100_fields, 3);
23172 
receive_packet_conn_ping_info_100(struct connection * pc)23173 static struct packet_conn_ping_info *receive_packet_conn_ping_info_100(struct connection *pc)
23174 {
23175   packet_conn_ping_info_100_fields fields;
23176   struct packet_conn_ping_info *old;
23177   struct genhash **hash = pc->phs.received + PACKET_CONN_PING_INFO;
23178   RECEIVE_PACKET_START(packet_conn_ping_info, real_packet);
23179 
23180   DIO_BV_GET(&din, fields);
23181 
23182   log_packet_detailed("packet_conn_ping_info_100: got info about ()");
23183 
23184   if (NULL == *hash) {
23185     *hash = genhash_new_full(hash_packet_conn_ping_info_100, cmp_packet_conn_ping_info_100,
23186                              NULL, NULL, NULL, free);
23187   }
23188 
23189   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
23190     *real_packet = *old;
23191   } else {
23192     log_packet_detailed("  no old info");
23193     memset(real_packet, 0, sizeof(*real_packet));
23194   }
23195 
23196   if (BV_ISSET(fields, 0)) {
23197     log_packet_detailed("  got field 'connections'");
23198     if (!DIO_GET(uint8, &din, "connections", &real_packet->connections)) {
23199       RECEIVE_PACKET_FIELD_ERROR(connections);
23200     }
23201   }
23202   if (BV_ISSET(fields, 1)) {
23203     log_packet_detailed("  got field 'conn_id'");
23204 
23205     {
23206       int i;
23207 
23208       if (real_packet->connections > MAX_NUM_CONNECTIONS) {
23209         RECEIVE_PACKET_FIELD_ERROR(conn_id, ": truncation array");
23210       }
23211       for (i = 0; i < real_packet->connections; i++) {
23212         if (!DIO_GET(sint16, &din, "conn_id", &real_packet->conn_id[i])) {
23213           RECEIVE_PACKET_FIELD_ERROR(conn_id);
23214         }
23215       }
23216     }
23217   }
23218   if (BV_ISSET(fields, 2)) {
23219     log_packet_detailed("  got field 'ping_time'");
23220 
23221     {
23222       int i;
23223 
23224       if (real_packet->connections > MAX_NUM_CONNECTIONS) {
23225         RECEIVE_PACKET_FIELD_ERROR(ping_time, ": truncation array");
23226       }
23227       for (i = 0; i < real_packet->connections; i++) {
23228         if (!DIO_GET(sfloat, &din, "ping_time", &real_packet->ping_time[i], 1000000)) {
23229           RECEIVE_PACKET_FIELD_ERROR(ping_time);
23230         }
23231       }
23232     }
23233   }
23234 
23235   if (NULL == old) {
23236     old = fc_malloc(sizeof(*old));
23237     *old = *real_packet;
23238     genhash_insert(*hash, old, old);
23239   } else {
23240     *old = *real_packet;
23241   }
23242   RECEIVE_PACKET_END(real_packet);
23243 }
23244 
send_packet_conn_ping_info_100(struct connection * pc,const struct packet_conn_ping_info * packet)23245 static int send_packet_conn_ping_info_100(struct connection *pc, const struct packet_conn_ping_info *packet)
23246 {
23247   const struct packet_conn_ping_info *real_packet = packet;
23248   packet_conn_ping_info_100_fields fields;
23249   struct packet_conn_ping_info *old;
23250   bool differ;
23251   struct genhash **hash = pc->phs.sent + PACKET_CONN_PING_INFO;
23252   int different = 0;
23253   SEND_PACKET_START(PACKET_CONN_PING_INFO);
23254 
23255   log_packet_detailed("packet_conn_ping_info_100: sending info about ()");
23256 
23257   if (NULL == *hash) {
23258     *hash = genhash_new_full(hash_packet_conn_ping_info_100, cmp_packet_conn_ping_info_100,
23259                              NULL, NULL, NULL, free);
23260   }
23261   BV_CLR_ALL(fields);
23262 
23263   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
23264     old = fc_malloc(sizeof(*old));
23265     *old = *real_packet;
23266     genhash_insert(*hash, old, old);
23267     memset(old, 0, sizeof(*old));
23268     different = 1;      /* Force to send. */
23269   }
23270 
23271   differ = (old->connections != real_packet->connections);
23272   if (differ) {
23273     different++;
23274     BV_SET(fields, 0);
23275   }
23276 
23277 
23278     {
23279       differ = (old->connections != real_packet->connections);
23280       if (!differ) {
23281         int i;
23282 
23283         for (i = 0; i < real_packet->connections; i++) {
23284           if (old->conn_id[i] != real_packet->conn_id[i]) {
23285             differ = TRUE;
23286             break;
23287           }
23288         }
23289       }
23290     }
23291   if (differ) {
23292     different++;
23293     BV_SET(fields, 1);
23294   }
23295 
23296 
23297     {
23298       differ = (old->connections != real_packet->connections);
23299       if (!differ) {
23300         int i;
23301 
23302         for (i = 0; i < real_packet->connections; i++) {
23303           if (old->ping_time[i] != real_packet->ping_time[i]) {
23304             differ = TRUE;
23305             break;
23306           }
23307         }
23308       }
23309     }
23310   if (differ) {
23311     different++;
23312     BV_SET(fields, 2);
23313   }
23314 
23315 
23316   DIO_BV_PUT(&dout, "fields", fields);
23317 
23318   if (BV_ISSET(fields, 0)) {
23319     log_packet_detailed("  field 'connections' has changed");
23320     DIO_PUT(uint8, &dout, "connections", real_packet->connections);
23321   }
23322   if (BV_ISSET(fields, 1)) {
23323     log_packet_detailed("  field 'conn_id' has changed");
23324 
23325     {
23326       int i;
23327 
23328       for (i = 0; i < real_packet->connections; i++) {
23329         dio_put_sint16(&dout, real_packet->conn_id[i]);
23330       }
23331     }
23332   }
23333   if (BV_ISSET(fields, 2)) {
23334     log_packet_detailed("  field 'ping_time' has changed");
23335 
23336     {
23337       int i;
23338 
23339       for (i = 0; i < real_packet->connections; i++) {
23340           dio_put_sfloat(&dout, real_packet->ping_time[i], 1000000);
23341       }
23342     }
23343   }
23344 
23345   *old = *real_packet;
23346   SEND_PACKET_END(PACKET_CONN_PING_INFO);
23347 }
23348 
send_packet_conn_ping_info(struct connection * pc,const struct packet_conn_ping_info * packet)23349 int send_packet_conn_ping_info(struct connection *pc, const struct packet_conn_ping_info *packet)
23350 {
23351   if (!pc->used) {
23352     log_error("WARNING: trying to send data to the closed connection %s",
23353               conn_description(pc));
23354     return -1;
23355   }
23356   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CONN_PING_INFO].packet != NULL, -1,
23357                         "Handler for PACKET_CONN_PING_INFO not installed");
23358   return pc->phs.handlers->send[PACKET_CONN_PING_INFO].packet(pc, packet);
23359 }
23360 
lsend_packet_conn_ping_info(struct conn_list * dest,const struct packet_conn_ping_info * packet)23361 void lsend_packet_conn_ping_info(struct conn_list *dest, const struct packet_conn_ping_info *packet)
23362 {
23363   conn_list_iterate(dest, pconn) {
23364     send_packet_conn_ping_info(pconn, packet);
23365   } conn_list_iterate_end;
23366 }
23367 
receive_packet_conn_ping_100(struct connection * pc)23368 static struct packet_conn_ping *receive_packet_conn_ping_100(struct connection *pc)
23369 {
23370   RECEIVE_PACKET_START(packet_conn_ping, real_packet);
23371   real_packet->__dummy = 0xff;
23372   log_packet_detailed("packet_conn_ping_100: got info about ()");
23373   RECEIVE_PACKET_END(real_packet);
23374 }
23375 
send_packet_conn_ping_100(struct connection * pc)23376 static int send_packet_conn_ping_100(struct connection *pc)
23377 {
23378   SEND_PACKET_START(PACKET_CONN_PING);
23379 
23380   log_packet_detailed("packet_conn_ping_100: sending info about ()");
23381   SEND_PACKET_END(PACKET_CONN_PING);
23382 }
23383 
send_packet_conn_ping(struct connection * pc)23384 int send_packet_conn_ping(struct connection *pc)
23385 {
23386   if (!pc->used) {
23387     log_error("WARNING: trying to send data to the closed connection %s",
23388               conn_description(pc));
23389     return -1;
23390   }
23391   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CONN_PING].no_packet != NULL, -1,
23392                         "Handler for PACKET_CONN_PING not installed");
23393   return pc->phs.handlers->send[PACKET_CONN_PING].no_packet(pc);
23394 }
23395 
receive_packet_conn_pong_100(struct connection * pc)23396 static struct packet_conn_pong *receive_packet_conn_pong_100(struct connection *pc)
23397 {
23398   RECEIVE_PACKET_START(packet_conn_pong, real_packet);
23399   real_packet->__dummy = 0xff;
23400   log_packet_detailed("packet_conn_pong_100: got info about ()");
23401   RECEIVE_PACKET_END(real_packet);
23402 }
23403 
send_packet_conn_pong_100(struct connection * pc)23404 static int send_packet_conn_pong_100(struct connection *pc)
23405 {
23406   SEND_PACKET_START(PACKET_CONN_PONG);
23407 
23408   log_packet_detailed("packet_conn_pong_100: sending info about ()");
23409   SEND_PACKET_END(PACKET_CONN_PONG);
23410 }
23411 
send_packet_conn_pong(struct connection * pc)23412 int send_packet_conn_pong(struct connection *pc)
23413 {
23414   if (!pc->used) {
23415     log_error("WARNING: trying to send data to the closed connection %s",
23416               conn_description(pc));
23417     return -1;
23418   }
23419   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CONN_PONG].no_packet != NULL, -1,
23420                         "Handler for PACKET_CONN_PONG not installed");
23421   return pc->phs.handlers->send[PACKET_CONN_PONG].no_packet(pc);
23422 }
23423 
receive_packet_client_heartbeat_100(struct connection * pc)23424 static struct packet_client_heartbeat *receive_packet_client_heartbeat_100(struct connection *pc)
23425 {
23426   RECEIVE_PACKET_START(packet_client_heartbeat, real_packet);
23427   real_packet->__dummy = 0xff;
23428   log_packet_detailed("packet_client_heartbeat_100: got info about ()");
23429   RECEIVE_PACKET_END(real_packet);
23430 }
23431 
send_packet_client_heartbeat_100(struct connection * pc)23432 static int send_packet_client_heartbeat_100(struct connection *pc)
23433 {
23434   SEND_PACKET_START(PACKET_CLIENT_HEARTBEAT);
23435 
23436   log_packet_detailed("packet_client_heartbeat_100: sending info about ()");
23437   SEND_PACKET_END(PACKET_CLIENT_HEARTBEAT);
23438 }
23439 
send_packet_client_heartbeat(struct connection * pc)23440 int send_packet_client_heartbeat(struct connection *pc)
23441 {
23442   if (!pc->used) {
23443     log_error("WARNING: trying to send data to the closed connection %s",
23444               conn_description(pc));
23445     return -1;
23446   }
23447   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CLIENT_HEARTBEAT].no_packet != NULL, -1,
23448                         "Handler for PACKET_CLIENT_HEARTBEAT not installed");
23449   return pc->phs.handlers->send[PACKET_CLIENT_HEARTBEAT].no_packet(pc);
23450 }
23451 
23452 #define hash_packet_client_info_100 hash_const
23453 
23454 #define cmp_packet_client_info_100 cmp_const
23455 
23456 BV_DEFINE(packet_client_info_100_fields, 2);
23457 
receive_packet_client_info_100(struct connection * pc)23458 static struct packet_client_info *receive_packet_client_info_100(struct connection *pc)
23459 {
23460   packet_client_info_100_fields fields;
23461   struct packet_client_info *old;
23462   struct genhash **hash = pc->phs.received + PACKET_CLIENT_INFO;
23463   RECEIVE_PACKET_START(packet_client_info, real_packet);
23464 
23465   DIO_BV_GET(&din, fields);
23466 
23467   log_packet_detailed("packet_client_info_100: got info about ()");
23468 
23469   if (NULL == *hash) {
23470     *hash = genhash_new_full(hash_packet_client_info_100, cmp_packet_client_info_100,
23471                              NULL, NULL, NULL, free);
23472   }
23473 
23474   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
23475     *real_packet = *old;
23476   } else {
23477     log_packet_detailed("  no old info");
23478     memset(real_packet, 0, sizeof(*real_packet));
23479   }
23480 
23481   if (BV_ISSET(fields, 0)) {
23482     log_packet_detailed("  got field 'gui'");
23483     {
23484       int readin;
23485 
23486       if (!DIO_GET(uint8, &din, "gui", &readin)) {
23487         RECEIVE_PACKET_FIELD_ERROR(gui);
23488       }
23489       real_packet->gui = readin;
23490     }
23491   }
23492   if (BV_ISSET(fields, 1)) {
23493     log_packet_detailed("  got field 'distribution'");
23494     if (!DIO_GET(string, &din, "distribution", real_packet->distribution, sizeof(real_packet->distribution))) {
23495       RECEIVE_PACKET_FIELD_ERROR(distribution);
23496     }
23497   }
23498 
23499   if (NULL == old) {
23500     old = fc_malloc(sizeof(*old));
23501     *old = *real_packet;
23502     genhash_insert(*hash, old, old);
23503   } else {
23504     *old = *real_packet;
23505   }
23506   RECEIVE_PACKET_END(real_packet);
23507 }
23508 
send_packet_client_info_100(struct connection * pc,const struct packet_client_info * packet)23509 static int send_packet_client_info_100(struct connection *pc, const struct packet_client_info *packet)
23510 {
23511   const struct packet_client_info *real_packet = packet;
23512   packet_client_info_100_fields fields;
23513   struct packet_client_info *old;
23514   bool differ;
23515   struct genhash **hash = pc->phs.sent + PACKET_CLIENT_INFO;
23516   int different = 0;
23517   SEND_PACKET_START(PACKET_CLIENT_INFO);
23518 
23519   log_packet_detailed("packet_client_info_100: sending info about ()");
23520 
23521   if (NULL == *hash) {
23522     *hash = genhash_new_full(hash_packet_client_info_100, cmp_packet_client_info_100,
23523                              NULL, NULL, NULL, free);
23524   }
23525   BV_CLR_ALL(fields);
23526 
23527   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
23528     old = fc_malloc(sizeof(*old));
23529     *old = *real_packet;
23530     genhash_insert(*hash, old, old);
23531     memset(old, 0, sizeof(*old));
23532     different = 1;      /* Force to send. */
23533   }
23534 
23535   differ = (old->gui != real_packet->gui);
23536   if (differ) {
23537     different++;
23538     BV_SET(fields, 0);
23539   }
23540 
23541   differ = (strcmp(old->distribution, real_packet->distribution) != 0);
23542   if (differ) {
23543     different++;
23544     BV_SET(fields, 1);
23545   }
23546 
23547 
23548   DIO_BV_PUT(&dout, "fields", fields);
23549 
23550   if (BV_ISSET(fields, 0)) {
23551     log_packet_detailed("  field 'gui' has changed");
23552     DIO_PUT(uint8, &dout, "gui", real_packet->gui);
23553   }
23554   if (BV_ISSET(fields, 1)) {
23555     log_packet_detailed("  field 'distribution' has changed");
23556     DIO_PUT(string, &dout, "distribution", real_packet->distribution);
23557   }
23558 
23559   *old = *real_packet;
23560   SEND_PACKET_END(PACKET_CLIENT_INFO);
23561 }
23562 
send_packet_client_info(struct connection * pc,const struct packet_client_info * packet)23563 int send_packet_client_info(struct connection *pc, const struct packet_client_info *packet)
23564 {
23565   if (!pc->used) {
23566     log_error("WARNING: trying to send data to the closed connection %s",
23567               conn_description(pc));
23568     return -1;
23569   }
23570   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CLIENT_INFO].packet != NULL, -1,
23571                         "Handler for PACKET_CLIENT_INFO not installed");
23572   return pc->phs.handlers->send[PACKET_CLIENT_INFO].packet(pc, packet);
23573 }
23574 
receive_packet_end_phase_100(struct connection * pc)23575 static struct packet_end_phase *receive_packet_end_phase_100(struct connection *pc)
23576 {
23577   RECEIVE_PACKET_START(packet_end_phase, real_packet);
23578   real_packet->__dummy = 0xff;
23579   log_packet_detailed("packet_end_phase_100: got info about ()");
23580   RECEIVE_PACKET_END(real_packet);
23581 }
23582 
send_packet_end_phase_100(struct connection * pc)23583 static int send_packet_end_phase_100(struct connection *pc)
23584 {
23585   SEND_PACKET_START(PACKET_END_PHASE);
23586 
23587   log_packet_detailed("packet_end_phase_100: sending info about ()");
23588   SEND_PACKET_END(PACKET_END_PHASE);
23589 }
23590 
send_packet_end_phase(struct connection * pc)23591 int send_packet_end_phase(struct connection *pc)
23592 {
23593   if (!pc->used) {
23594     log_error("WARNING: trying to send data to the closed connection %s",
23595               conn_description(pc));
23596     return -1;
23597   }
23598   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_END_PHASE].no_packet != NULL, -1,
23599                         "Handler for PACKET_END_PHASE not installed");
23600   return pc->phs.handlers->send[PACKET_END_PHASE].no_packet(pc);
23601 }
23602 
lsend_packet_end_phase(struct conn_list * dest)23603 void lsend_packet_end_phase(struct conn_list *dest)
23604 {
23605   conn_list_iterate(dest, pconn) {
23606     send_packet_end_phase(pconn);
23607   } conn_list_iterate_end;
23608 }
23609 
23610 #define hash_packet_start_phase_100 hash_const
23611 
23612 #define cmp_packet_start_phase_100 cmp_const
23613 
23614 BV_DEFINE(packet_start_phase_100_fields, 1);
23615 
receive_packet_start_phase_100(struct connection * pc)23616 static struct packet_start_phase *receive_packet_start_phase_100(struct connection *pc)
23617 {
23618   packet_start_phase_100_fields fields;
23619   struct packet_start_phase *old;
23620   struct genhash **hash = pc->phs.received + PACKET_START_PHASE;
23621   RECEIVE_PACKET_START(packet_start_phase, real_packet);
23622 
23623   DIO_BV_GET(&din, fields);
23624 
23625   log_packet_detailed("packet_start_phase_100: got info about ()");
23626 
23627   if (NULL == *hash) {
23628     *hash = genhash_new_full(hash_packet_start_phase_100, cmp_packet_start_phase_100,
23629                              NULL, NULL, NULL, free);
23630   }
23631 
23632   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
23633     *real_packet = *old;
23634   } else {
23635     log_packet_detailed("  no old info");
23636     memset(real_packet, 0, sizeof(*real_packet));
23637   }
23638 
23639   if (BV_ISSET(fields, 0)) {
23640     log_packet_detailed("  got field 'phase'");
23641     if (!DIO_GET(sint16, &din, "phase", &real_packet->phase)) {
23642       RECEIVE_PACKET_FIELD_ERROR(phase);
23643     }
23644   }
23645 
23646   if (NULL == old) {
23647     old = fc_malloc(sizeof(*old));
23648     *old = *real_packet;
23649     genhash_insert(*hash, old, old);
23650   } else {
23651     *old = *real_packet;
23652   }
23653   RECEIVE_PACKET_END(real_packet);
23654 }
23655 
send_packet_start_phase_100(struct connection * pc,const struct packet_start_phase * packet)23656 static int send_packet_start_phase_100(struct connection *pc, const struct packet_start_phase *packet)
23657 {
23658   const struct packet_start_phase *real_packet = packet;
23659   packet_start_phase_100_fields fields;
23660   struct packet_start_phase *old;
23661   bool differ;
23662   struct genhash **hash = pc->phs.sent + PACKET_START_PHASE;
23663   int different = 0;
23664   SEND_PACKET_START(PACKET_START_PHASE);
23665 
23666   log_packet_detailed("packet_start_phase_100: sending info about ()");
23667 
23668   if (NULL == *hash) {
23669     *hash = genhash_new_full(hash_packet_start_phase_100, cmp_packet_start_phase_100,
23670                              NULL, NULL, NULL, free);
23671   }
23672   BV_CLR_ALL(fields);
23673 
23674   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
23675     old = fc_malloc(sizeof(*old));
23676     *old = *real_packet;
23677     genhash_insert(*hash, old, old);
23678     memset(old, 0, sizeof(*old));
23679     different = 1;      /* Force to send. */
23680   }
23681 
23682   differ = (old->phase != real_packet->phase);
23683   if (differ) {
23684     different++;
23685     BV_SET(fields, 0);
23686   }
23687 
23688 
23689   DIO_BV_PUT(&dout, "fields", fields);
23690 
23691   if (BV_ISSET(fields, 0)) {
23692     log_packet_detailed("  field 'phase' has changed");
23693     DIO_PUT(sint16, &dout, "phase", real_packet->phase);
23694   }
23695 
23696   *old = *real_packet;
23697   SEND_PACKET_END(PACKET_START_PHASE);
23698 }
23699 
send_packet_start_phase(struct connection * pc,const struct packet_start_phase * packet)23700 int send_packet_start_phase(struct connection *pc, const struct packet_start_phase *packet)
23701 {
23702   if (!pc->used) {
23703     log_error("WARNING: trying to send data to the closed connection %s",
23704               conn_description(pc));
23705     return -1;
23706   }
23707   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_START_PHASE].packet != NULL, -1,
23708                         "Handler for PACKET_START_PHASE not installed");
23709   return pc->phs.handlers->send[PACKET_START_PHASE].packet(pc, packet);
23710 }
23711 
lsend_packet_start_phase(struct conn_list * dest,const struct packet_start_phase * packet)23712 void lsend_packet_start_phase(struct conn_list *dest, const struct packet_start_phase *packet)
23713 {
23714   conn_list_iterate(dest, pconn) {
23715     send_packet_start_phase(pconn, packet);
23716   } conn_list_iterate_end;
23717 }
23718 
dsend_packet_start_phase(struct connection * pc,int phase)23719 int dsend_packet_start_phase(struct connection *pc, int phase)
23720 {
23721   struct packet_start_phase packet, *real_packet = &packet;
23722 
23723   real_packet->phase = phase;
23724 
23725   return send_packet_start_phase(pc, real_packet);
23726 }
23727 
dlsend_packet_start_phase(struct conn_list * dest,int phase)23728 void dlsend_packet_start_phase(struct conn_list *dest, int phase)
23729 {
23730   struct packet_start_phase packet, *real_packet = &packet;
23731 
23732   real_packet->phase = phase;
23733 
23734   lsend_packet_start_phase(dest, real_packet);
23735 }
23736 
23737 #define hash_packet_new_year_100 hash_const
23738 
23739 #define cmp_packet_new_year_100 cmp_const
23740 
23741 BV_DEFINE(packet_new_year_100_fields, 3);
23742 
receive_packet_new_year_100(struct connection * pc)23743 static struct packet_new_year *receive_packet_new_year_100(struct connection *pc)
23744 {
23745   packet_new_year_100_fields fields;
23746   struct packet_new_year *old;
23747   struct genhash **hash = pc->phs.received + PACKET_NEW_YEAR;
23748   RECEIVE_PACKET_START(packet_new_year, real_packet);
23749 
23750   DIO_BV_GET(&din, fields);
23751 
23752   log_packet_detailed("packet_new_year_100: got info about ()");
23753 
23754   if (NULL == *hash) {
23755     *hash = genhash_new_full(hash_packet_new_year_100, cmp_packet_new_year_100,
23756                              NULL, NULL, NULL, free);
23757   }
23758 
23759   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
23760     *real_packet = *old;
23761   } else {
23762     log_packet_detailed("  no old info");
23763     memset(real_packet, 0, sizeof(*real_packet));
23764   }
23765 
23766   if (BV_ISSET(fields, 0)) {
23767     log_packet_detailed("  got field 'year32'");
23768     if (!DIO_GET(sint32, &din, "year32", &real_packet->year32)) {
23769       RECEIVE_PACKET_FIELD_ERROR(year32);
23770     }
23771   }
23772   if (BV_ISSET(fields, 1)) {
23773     log_packet_detailed("  got field 'fragments'");
23774     if (!DIO_GET(uint16, &din, "fragments", &real_packet->fragments)) {
23775       RECEIVE_PACKET_FIELD_ERROR(fragments);
23776     }
23777   }
23778   if (BV_ISSET(fields, 2)) {
23779     log_packet_detailed("  got field 'turn'");
23780     if (!DIO_GET(sint16, &din, "turn", &real_packet->turn)) {
23781       RECEIVE_PACKET_FIELD_ERROR(turn);
23782     }
23783   }
23784 
23785   if (NULL == old) {
23786     old = fc_malloc(sizeof(*old));
23787     *old = *real_packet;
23788     genhash_insert(*hash, old, old);
23789   } else {
23790     *old = *real_packet;
23791   }
23792   RECEIVE_PACKET_END(real_packet);
23793 }
23794 
send_packet_new_year_100(struct connection * pc,const struct packet_new_year * packet)23795 static int send_packet_new_year_100(struct connection *pc, const struct packet_new_year *packet)
23796 {
23797   const struct packet_new_year *real_packet = packet;
23798   packet_new_year_100_fields fields;
23799   struct packet_new_year *old;
23800   bool differ;
23801   struct genhash **hash = pc->phs.sent + PACKET_NEW_YEAR;
23802   int different = 0;
23803   SEND_PACKET_START(PACKET_NEW_YEAR);
23804 
23805   log_packet_detailed("packet_new_year_100: sending info about ()");
23806 
23807   if (NULL == *hash) {
23808     *hash = genhash_new_full(hash_packet_new_year_100, cmp_packet_new_year_100,
23809                              NULL, NULL, NULL, free);
23810   }
23811   BV_CLR_ALL(fields);
23812 
23813   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
23814     old = fc_malloc(sizeof(*old));
23815     *old = *real_packet;
23816     genhash_insert(*hash, old, old);
23817     memset(old, 0, sizeof(*old));
23818     different = 1;      /* Force to send. */
23819   }
23820 
23821   differ = (old->year32 != real_packet->year32);
23822   if (differ) {
23823     different++;
23824     BV_SET(fields, 0);
23825   }
23826 
23827   differ = (old->fragments != real_packet->fragments);
23828   if (differ) {
23829     different++;
23830     BV_SET(fields, 1);
23831   }
23832 
23833   differ = (old->turn != real_packet->turn);
23834   if (differ) {
23835     different++;
23836     BV_SET(fields, 2);
23837   }
23838 
23839 
23840   DIO_BV_PUT(&dout, "fields", fields);
23841 
23842   if (BV_ISSET(fields, 0)) {
23843     log_packet_detailed("  field 'year32' has changed");
23844     DIO_PUT(sint32, &dout, "year32", real_packet->year32);
23845   }
23846   if (BV_ISSET(fields, 1)) {
23847     log_packet_detailed("  field 'fragments' has changed");
23848     DIO_PUT(uint16, &dout, "fragments", real_packet->fragments);
23849   }
23850   if (BV_ISSET(fields, 2)) {
23851     log_packet_detailed("  field 'turn' has changed");
23852     DIO_PUT(sint16, &dout, "turn", real_packet->turn);
23853   }
23854 
23855   *old = *real_packet;
23856   SEND_PACKET_END(PACKET_NEW_YEAR);
23857 }
23858 
23859 #define hash_packet_new_year_101 hash_const
23860 
23861 #define cmp_packet_new_year_101 cmp_const
23862 
23863 BV_DEFINE(packet_new_year_101_fields, 3);
23864 
receive_packet_new_year_101(struct connection * pc)23865 static struct packet_new_year *receive_packet_new_year_101(struct connection *pc)
23866 {
23867   packet_new_year_101_fields fields;
23868   struct packet_new_year *old;
23869   struct genhash **hash = pc->phs.received + PACKET_NEW_YEAR;
23870   RECEIVE_PACKET_START(packet_new_year, real_packet);
23871 
23872   DIO_BV_GET(&din, fields);
23873 
23874   log_packet_detailed("packet_new_year_101: got info about ()");
23875 
23876   if (NULL == *hash) {
23877     *hash = genhash_new_full(hash_packet_new_year_101, cmp_packet_new_year_101,
23878                              NULL, NULL, NULL, free);
23879   }
23880 
23881   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
23882     *real_packet = *old;
23883   } else {
23884     log_packet_detailed("  no old info");
23885     memset(real_packet, 0, sizeof(*real_packet));
23886   }
23887 
23888   if (BV_ISSET(fields, 0)) {
23889     log_packet_detailed("  got field 'year16'");
23890     if (!DIO_GET(sint16, &din, "year16", &real_packet->year16)) {
23891       RECEIVE_PACKET_FIELD_ERROR(year16);
23892     }
23893   }
23894   if (BV_ISSET(fields, 1)) {
23895     log_packet_detailed("  got field 'fragments'");
23896     if (!DIO_GET(uint16, &din, "fragments", &real_packet->fragments)) {
23897       RECEIVE_PACKET_FIELD_ERROR(fragments);
23898     }
23899   }
23900   if (BV_ISSET(fields, 2)) {
23901     log_packet_detailed("  got field 'turn'");
23902     if (!DIO_GET(sint16, &din, "turn", &real_packet->turn)) {
23903       RECEIVE_PACKET_FIELD_ERROR(turn);
23904     }
23905   }
23906 
23907   if (NULL == old) {
23908     old = fc_malloc(sizeof(*old));
23909     *old = *real_packet;
23910     genhash_insert(*hash, old, old);
23911   } else {
23912     *old = *real_packet;
23913   }
23914   RECEIVE_PACKET_END(real_packet);
23915 }
23916 
send_packet_new_year_101(struct connection * pc,const struct packet_new_year * packet)23917 static int send_packet_new_year_101(struct connection *pc, const struct packet_new_year *packet)
23918 {
23919   const struct packet_new_year *real_packet = packet;
23920   packet_new_year_101_fields fields;
23921   struct packet_new_year *old;
23922   bool differ;
23923   struct genhash **hash = pc->phs.sent + PACKET_NEW_YEAR;
23924   int different = 0;
23925   SEND_PACKET_START(PACKET_NEW_YEAR);
23926 
23927   log_packet_detailed("packet_new_year_101: sending info about ()");
23928 
23929   if (NULL == *hash) {
23930     *hash = genhash_new_full(hash_packet_new_year_101, cmp_packet_new_year_101,
23931                              NULL, NULL, NULL, free);
23932   }
23933   BV_CLR_ALL(fields);
23934 
23935   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
23936     old = fc_malloc(sizeof(*old));
23937     *old = *real_packet;
23938     genhash_insert(*hash, old, old);
23939     memset(old, 0, sizeof(*old));
23940     different = 1;      /* Force to send. */
23941   }
23942 
23943   differ = (old->year16 != real_packet->year16);
23944   if (differ) {
23945     different++;
23946     BV_SET(fields, 0);
23947   }
23948 
23949   differ = (old->fragments != real_packet->fragments);
23950   if (differ) {
23951     different++;
23952     BV_SET(fields, 1);
23953   }
23954 
23955   differ = (old->turn != real_packet->turn);
23956   if (differ) {
23957     different++;
23958     BV_SET(fields, 2);
23959   }
23960 
23961 
23962   DIO_BV_PUT(&dout, "fields", fields);
23963 
23964   if (BV_ISSET(fields, 0)) {
23965     log_packet_detailed("  field 'year16' has changed");
23966     DIO_PUT(sint16, &dout, "year16", real_packet->year16);
23967   }
23968   if (BV_ISSET(fields, 1)) {
23969     log_packet_detailed("  field 'fragments' has changed");
23970     DIO_PUT(uint16, &dout, "fragments", real_packet->fragments);
23971   }
23972   if (BV_ISSET(fields, 2)) {
23973     log_packet_detailed("  field 'turn' has changed");
23974     DIO_PUT(sint16, &dout, "turn", real_packet->turn);
23975   }
23976 
23977   *old = *real_packet;
23978   SEND_PACKET_END(PACKET_NEW_YEAR);
23979 }
23980 
send_packet_new_year(struct connection * pc,const struct packet_new_year * packet)23981 int send_packet_new_year(struct connection *pc, const struct packet_new_year *packet)
23982 {
23983   if (!pc->used) {
23984     log_error("WARNING: trying to send data to the closed connection %s",
23985               conn_description(pc));
23986     return -1;
23987   }
23988   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_NEW_YEAR].packet != NULL, -1,
23989                         "Handler for PACKET_NEW_YEAR not installed");
23990   return pc->phs.handlers->send[PACKET_NEW_YEAR].packet(pc, packet);
23991 }
23992 
lsend_packet_new_year(struct conn_list * dest,const struct packet_new_year * packet)23993 void lsend_packet_new_year(struct conn_list *dest, const struct packet_new_year *packet)
23994 {
23995   conn_list_iterate(dest, pconn) {
23996     send_packet_new_year(pconn, packet);
23997   } conn_list_iterate_end;
23998 }
23999 
receive_packet_begin_turn_100(struct connection * pc)24000 static struct packet_begin_turn *receive_packet_begin_turn_100(struct connection *pc)
24001 {
24002   RECEIVE_PACKET_START(packet_begin_turn, real_packet);
24003   real_packet->__dummy = 0xff;
24004   log_packet_detailed("packet_begin_turn_100: got info about ()");
24005   RECEIVE_PACKET_END(real_packet);
24006 }
24007 
send_packet_begin_turn_100(struct connection * pc)24008 static int send_packet_begin_turn_100(struct connection *pc)
24009 {
24010   SEND_PACKET_START(PACKET_BEGIN_TURN);
24011 
24012   log_packet_detailed("packet_begin_turn_100: sending info about ()");
24013   SEND_PACKET_END(PACKET_BEGIN_TURN);
24014 }
24015 
send_packet_begin_turn(struct connection * pc)24016 int send_packet_begin_turn(struct connection *pc)
24017 {
24018   if (!pc->used) {
24019     log_error("WARNING: trying to send data to the closed connection %s",
24020               conn_description(pc));
24021     return -1;
24022   }
24023   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_BEGIN_TURN].no_packet != NULL, -1,
24024                         "Handler for PACKET_BEGIN_TURN not installed");
24025   return pc->phs.handlers->send[PACKET_BEGIN_TURN].no_packet(pc);
24026 }
24027 
lsend_packet_begin_turn(struct conn_list * dest)24028 void lsend_packet_begin_turn(struct conn_list *dest)
24029 {
24030   conn_list_iterate(dest, pconn) {
24031     send_packet_begin_turn(pconn);
24032   } conn_list_iterate_end;
24033 }
24034 
receive_packet_end_turn_100(struct connection * pc)24035 static struct packet_end_turn *receive_packet_end_turn_100(struct connection *pc)
24036 {
24037   RECEIVE_PACKET_START(packet_end_turn, real_packet);
24038   real_packet->__dummy = 0xff;
24039   log_packet_detailed("packet_end_turn_100: got info about ()");
24040   RECEIVE_PACKET_END(real_packet);
24041 }
24042 
send_packet_end_turn_100(struct connection * pc)24043 static int send_packet_end_turn_100(struct connection *pc)
24044 {
24045   SEND_PACKET_START(PACKET_END_TURN);
24046 
24047   log_packet_detailed("packet_end_turn_100: sending info about ()");
24048   SEND_PACKET_END(PACKET_END_TURN);
24049 }
24050 
send_packet_end_turn(struct connection * pc)24051 int send_packet_end_turn(struct connection *pc)
24052 {
24053   if (!pc->used) {
24054     log_error("WARNING: trying to send data to the closed connection %s",
24055               conn_description(pc));
24056     return -1;
24057   }
24058   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_END_TURN].no_packet != NULL, -1,
24059                         "Handler for PACKET_END_TURN not installed");
24060   return pc->phs.handlers->send[PACKET_END_TURN].no_packet(pc);
24061 }
24062 
lsend_packet_end_turn(struct conn_list * dest)24063 void lsend_packet_end_turn(struct conn_list *dest)
24064 {
24065   conn_list_iterate(dest, pconn) {
24066     send_packet_end_turn(pconn);
24067   } conn_list_iterate_end;
24068 }
24069 
receive_packet_freeze_client_100(struct connection * pc)24070 static struct packet_freeze_client *receive_packet_freeze_client_100(struct connection *pc)
24071 {
24072   RECEIVE_PACKET_START(packet_freeze_client, real_packet);
24073   real_packet->__dummy = 0xff;
24074   log_packet_detailed("packet_freeze_client_100: got info about ()");
24075   RECEIVE_PACKET_END(real_packet);
24076 }
24077 
send_packet_freeze_client_100(struct connection * pc)24078 static int send_packet_freeze_client_100(struct connection *pc)
24079 {
24080   SEND_PACKET_START(PACKET_FREEZE_CLIENT);
24081 
24082   log_packet_detailed("packet_freeze_client_100: sending info about ()");
24083   SEND_PACKET_END(PACKET_FREEZE_CLIENT);
24084 }
24085 
send_packet_freeze_client(struct connection * pc)24086 int send_packet_freeze_client(struct connection *pc)
24087 {
24088   if (!pc->used) {
24089     log_error("WARNING: trying to send data to the closed connection %s",
24090               conn_description(pc));
24091     return -1;
24092   }
24093   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_FREEZE_CLIENT].no_packet != NULL, -1,
24094                         "Handler for PACKET_FREEZE_CLIENT not installed");
24095   return pc->phs.handlers->send[PACKET_FREEZE_CLIENT].no_packet(pc);
24096 }
24097 
lsend_packet_freeze_client(struct conn_list * dest)24098 void lsend_packet_freeze_client(struct conn_list *dest)
24099 {
24100   conn_list_iterate(dest, pconn) {
24101     send_packet_freeze_client(pconn);
24102   } conn_list_iterate_end;
24103 }
24104 
receive_packet_thaw_client_100(struct connection * pc)24105 static struct packet_thaw_client *receive_packet_thaw_client_100(struct connection *pc)
24106 {
24107   RECEIVE_PACKET_START(packet_thaw_client, real_packet);
24108   real_packet->__dummy = 0xff;
24109   log_packet_detailed("packet_thaw_client_100: got info about ()");
24110   RECEIVE_PACKET_END(real_packet);
24111 }
24112 
send_packet_thaw_client_100(struct connection * pc)24113 static int send_packet_thaw_client_100(struct connection *pc)
24114 {
24115   SEND_PACKET_START(PACKET_THAW_CLIENT);
24116 
24117   log_packet_detailed("packet_thaw_client_100: sending info about ()");
24118   SEND_PACKET_END(PACKET_THAW_CLIENT);
24119 }
24120 
send_packet_thaw_client(struct connection * pc)24121 int send_packet_thaw_client(struct connection *pc)
24122 {
24123   if (!pc->used) {
24124     log_error("WARNING: trying to send data to the closed connection %s",
24125               conn_description(pc));
24126     return -1;
24127   }
24128   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_THAW_CLIENT].no_packet != NULL, -1,
24129                         "Handler for PACKET_THAW_CLIENT not installed");
24130   return pc->phs.handlers->send[PACKET_THAW_CLIENT].no_packet(pc);
24131 }
24132 
lsend_packet_thaw_client(struct conn_list * dest)24133 void lsend_packet_thaw_client(struct conn_list *dest)
24134 {
24135   conn_list_iterate(dest, pconn) {
24136     send_packet_thaw_client(pconn);
24137   } conn_list_iterate_end;
24138 }
24139 
receive_packet_spaceship_launch_100(struct connection * pc)24140 static struct packet_spaceship_launch *receive_packet_spaceship_launch_100(struct connection *pc)
24141 {
24142   RECEIVE_PACKET_START(packet_spaceship_launch, real_packet);
24143   real_packet->__dummy = 0xff;
24144   log_packet_detailed("packet_spaceship_launch_100: got info about ()");
24145   RECEIVE_PACKET_END(real_packet);
24146 }
24147 
send_packet_spaceship_launch_100(struct connection * pc)24148 static int send_packet_spaceship_launch_100(struct connection *pc)
24149 {
24150   SEND_PACKET_START(PACKET_SPACESHIP_LAUNCH);
24151 
24152   log_packet_detailed("packet_spaceship_launch_100: sending info about ()");
24153   SEND_PACKET_END(PACKET_SPACESHIP_LAUNCH);
24154 }
24155 
send_packet_spaceship_launch(struct connection * pc)24156 int send_packet_spaceship_launch(struct connection *pc)
24157 {
24158   if (!pc->used) {
24159     log_error("WARNING: trying to send data to the closed connection %s",
24160               conn_description(pc));
24161     return -1;
24162   }
24163   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SPACESHIP_LAUNCH].no_packet != NULL, -1,
24164                         "Handler for PACKET_SPACESHIP_LAUNCH not installed");
24165   return pc->phs.handlers->send[PACKET_SPACESHIP_LAUNCH].no_packet(pc);
24166 }
24167 
24168 #define hash_packet_spaceship_place_100 hash_const
24169 
24170 #define cmp_packet_spaceship_place_100 cmp_const
24171 
24172 BV_DEFINE(packet_spaceship_place_100_fields, 2);
24173 
receive_packet_spaceship_place_100(struct connection * pc)24174 static struct packet_spaceship_place *receive_packet_spaceship_place_100(struct connection *pc)
24175 {
24176   packet_spaceship_place_100_fields fields;
24177   struct packet_spaceship_place *old;
24178   struct genhash **hash = pc->phs.received + PACKET_SPACESHIP_PLACE;
24179   RECEIVE_PACKET_START(packet_spaceship_place, real_packet);
24180 
24181   DIO_BV_GET(&din, fields);
24182 
24183   log_packet_detailed("packet_spaceship_place_100: got info about ()");
24184 
24185   if (NULL == *hash) {
24186     *hash = genhash_new_full(hash_packet_spaceship_place_100, cmp_packet_spaceship_place_100,
24187                              NULL, NULL, NULL, free);
24188   }
24189 
24190   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
24191     *real_packet = *old;
24192   } else {
24193     log_packet_detailed("  no old info");
24194     memset(real_packet, 0, sizeof(*real_packet));
24195   }
24196 
24197   if (BV_ISSET(fields, 0)) {
24198     log_packet_detailed("  got field 'type'");
24199     {
24200       int readin;
24201 
24202       if (!DIO_GET(uint8, &din, "type", &readin)) {
24203         RECEIVE_PACKET_FIELD_ERROR(type);
24204       }
24205       real_packet->type = readin;
24206     }
24207   }
24208   if (BV_ISSET(fields, 1)) {
24209     log_packet_detailed("  got field 'num'");
24210     if (!DIO_GET(uint8, &din, "num", &real_packet->num)) {
24211       RECEIVE_PACKET_FIELD_ERROR(num);
24212     }
24213   }
24214 
24215   if (NULL == old) {
24216     old = fc_malloc(sizeof(*old));
24217     *old = *real_packet;
24218     genhash_insert(*hash, old, old);
24219   } else {
24220     *old = *real_packet;
24221   }
24222   RECEIVE_PACKET_END(real_packet);
24223 }
24224 
send_packet_spaceship_place_100(struct connection * pc,const struct packet_spaceship_place * packet)24225 static int send_packet_spaceship_place_100(struct connection *pc, const struct packet_spaceship_place *packet)
24226 {
24227   const struct packet_spaceship_place *real_packet = packet;
24228   packet_spaceship_place_100_fields fields;
24229   struct packet_spaceship_place *old;
24230   bool differ;
24231   struct genhash **hash = pc->phs.sent + PACKET_SPACESHIP_PLACE;
24232   int different = 0;
24233   SEND_PACKET_START(PACKET_SPACESHIP_PLACE);
24234 
24235   log_packet_detailed("packet_spaceship_place_100: sending info about ()");
24236 
24237   if (NULL == *hash) {
24238     *hash = genhash_new_full(hash_packet_spaceship_place_100, cmp_packet_spaceship_place_100,
24239                              NULL, NULL, NULL, free);
24240   }
24241   BV_CLR_ALL(fields);
24242 
24243   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
24244     old = fc_malloc(sizeof(*old));
24245     *old = *real_packet;
24246     genhash_insert(*hash, old, old);
24247     memset(old, 0, sizeof(*old));
24248     different = 1;      /* Force to send. */
24249   }
24250 
24251   differ = (old->type != real_packet->type);
24252   if (differ) {
24253     different++;
24254     BV_SET(fields, 0);
24255   }
24256 
24257   differ = (old->num != real_packet->num);
24258   if (differ) {
24259     different++;
24260     BV_SET(fields, 1);
24261   }
24262 
24263 
24264   DIO_BV_PUT(&dout, "fields", fields);
24265 
24266   if (BV_ISSET(fields, 0)) {
24267     log_packet_detailed("  field 'type' has changed");
24268     DIO_PUT(uint8, &dout, "type", real_packet->type);
24269   }
24270   if (BV_ISSET(fields, 1)) {
24271     log_packet_detailed("  field 'num' has changed");
24272     DIO_PUT(uint8, &dout, "num", real_packet->num);
24273   }
24274 
24275   *old = *real_packet;
24276   SEND_PACKET_END(PACKET_SPACESHIP_PLACE);
24277 }
24278 
send_packet_spaceship_place(struct connection * pc,const struct packet_spaceship_place * packet)24279 int send_packet_spaceship_place(struct connection *pc, const struct packet_spaceship_place *packet)
24280 {
24281   if (!pc->used) {
24282     log_error("WARNING: trying to send data to the closed connection %s",
24283               conn_description(pc));
24284     return -1;
24285   }
24286   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SPACESHIP_PLACE].packet != NULL, -1,
24287                         "Handler for PACKET_SPACESHIP_PLACE not installed");
24288   return pc->phs.handlers->send[PACKET_SPACESHIP_PLACE].packet(pc, packet);
24289 }
24290 
dsend_packet_spaceship_place(struct connection * pc,enum spaceship_place_type type,int num)24291 int dsend_packet_spaceship_place(struct connection *pc, enum spaceship_place_type type, int num)
24292 {
24293   struct packet_spaceship_place packet, *real_packet = &packet;
24294 
24295   real_packet->type = type;
24296   real_packet->num = num;
24297 
24298   return send_packet_spaceship_place(pc, real_packet);
24299 }
24300 
hash_packet_spaceship_info_100(const void * vkey)24301 static genhash_val_t hash_packet_spaceship_info_100(const void *vkey)
24302 {
24303   const struct packet_spaceship_info *key = (const struct packet_spaceship_info *) vkey;
24304 
24305   return key->player_num;
24306 }
24307 
cmp_packet_spaceship_info_100(const void * vkey1,const void * vkey2)24308 static bool cmp_packet_spaceship_info_100(const void *vkey1, const void *vkey2)
24309 {
24310   const struct packet_spaceship_info *key1 = (const struct packet_spaceship_info *) vkey1;
24311   const struct packet_spaceship_info *key2 = (const struct packet_spaceship_info *) vkey2;
24312 
24313   return key1->player_num == key2->player_num;
24314 }
24315 
24316 BV_DEFINE(packet_spaceship_info_100_fields, 17);
24317 
receive_packet_spaceship_info_100(struct connection * pc)24318 static struct packet_spaceship_info *receive_packet_spaceship_info_100(struct connection *pc)
24319 {
24320   packet_spaceship_info_100_fields fields;
24321   struct packet_spaceship_info *old;
24322   struct genhash **hash = pc->phs.received + PACKET_SPACESHIP_INFO;
24323   RECEIVE_PACKET_START(packet_spaceship_info, real_packet);
24324 
24325   DIO_BV_GET(&din, fields);
24326   if (!DIO_GET(uint8, &din, "player_num", &real_packet->player_num)) {
24327     RECEIVE_PACKET_FIELD_ERROR(player_num);
24328   }
24329 
24330   log_packet_detailed("packet_spaceship_info_100: got info about (%d)",
24331     real_packet->player_num);
24332 
24333   if (NULL == *hash) {
24334     *hash = genhash_new_full(hash_packet_spaceship_info_100, cmp_packet_spaceship_info_100,
24335                              NULL, NULL, NULL, free);
24336   }
24337 
24338   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
24339     *real_packet = *old;
24340   } else {
24341     int player_num = real_packet->player_num;
24342 
24343     log_packet_detailed("  no old info");
24344     memset(real_packet, 0, sizeof(*real_packet));
24345 
24346     real_packet->player_num = player_num;
24347   }
24348 
24349   if (BV_ISSET(fields, 0)) {
24350     log_packet_detailed("  got field 'sship_state'");
24351     if (!DIO_GET(uint8, &din, "sship_state", &real_packet->sship_state)) {
24352       RECEIVE_PACKET_FIELD_ERROR(sship_state);
24353     }
24354   }
24355   if (BV_ISSET(fields, 1)) {
24356     log_packet_detailed("  got field 'structurals'");
24357     if (!DIO_GET(uint8, &din, "structurals", &real_packet->structurals)) {
24358       RECEIVE_PACKET_FIELD_ERROR(structurals);
24359     }
24360   }
24361   if (BV_ISSET(fields, 2)) {
24362     log_packet_detailed("  got field 'components'");
24363     if (!DIO_GET(uint8, &din, "components", &real_packet->components)) {
24364       RECEIVE_PACKET_FIELD_ERROR(components);
24365     }
24366   }
24367   if (BV_ISSET(fields, 3)) {
24368     log_packet_detailed("  got field 'modules'");
24369     if (!DIO_GET(uint8, &din, "modules", &real_packet->modules)) {
24370       RECEIVE_PACKET_FIELD_ERROR(modules);
24371     }
24372   }
24373   if (BV_ISSET(fields, 4)) {
24374     log_packet_detailed("  got field 'fuel'");
24375     if (!DIO_GET(uint8, &din, "fuel", &real_packet->fuel)) {
24376       RECEIVE_PACKET_FIELD_ERROR(fuel);
24377     }
24378   }
24379   if (BV_ISSET(fields, 5)) {
24380     log_packet_detailed("  got field 'propulsion'");
24381     if (!DIO_GET(uint8, &din, "propulsion", &real_packet->propulsion)) {
24382       RECEIVE_PACKET_FIELD_ERROR(propulsion);
24383     }
24384   }
24385   if (BV_ISSET(fields, 6)) {
24386     log_packet_detailed("  got field 'habitation'");
24387     if (!DIO_GET(uint8, &din, "habitation", &real_packet->habitation)) {
24388       RECEIVE_PACKET_FIELD_ERROR(habitation);
24389     }
24390   }
24391   if (BV_ISSET(fields, 7)) {
24392     log_packet_detailed("  got field 'life_support'");
24393     if (!DIO_GET(uint8, &din, "life_support", &real_packet->life_support)) {
24394       RECEIVE_PACKET_FIELD_ERROR(life_support);
24395     }
24396   }
24397   if (BV_ISSET(fields, 8)) {
24398     log_packet_detailed("  got field 'solar_panels'");
24399     if (!DIO_GET(uint8, &din, "solar_panels", &real_packet->solar_panels)) {
24400       RECEIVE_PACKET_FIELD_ERROR(solar_panels);
24401     }
24402   }
24403   if (BV_ISSET(fields, 9)) {
24404     log_packet_detailed("  got field 'launch_year32'");
24405     if (!DIO_GET(sint32, &din, "launch_year32", &real_packet->launch_year32)) {
24406       RECEIVE_PACKET_FIELD_ERROR(launch_year32);
24407     }
24408   }
24409   if (BV_ISSET(fields, 10)) {
24410     log_packet_detailed("  got field 'population'");
24411     if (!DIO_GET(uint32, &din, "population", &real_packet->population)) {
24412       RECEIVE_PACKET_FIELD_ERROR(population);
24413     }
24414   }
24415   if (BV_ISSET(fields, 11)) {
24416     log_packet_detailed("  got field 'mass'");
24417     if (!DIO_GET(uint32, &din, "mass", &real_packet->mass)) {
24418       RECEIVE_PACKET_FIELD_ERROR(mass);
24419     }
24420   }
24421   if (BV_ISSET(fields, 12)) {
24422     log_packet_detailed("  got field 'structure'");
24423     if (!DIO_BV_GET(&din, real_packet->structure)) {
24424       RECEIVE_PACKET_FIELD_ERROR(structure);
24425     }
24426   }
24427   if (BV_ISSET(fields, 13)) {
24428     log_packet_detailed("  got field 'support_rate'");
24429     if (!DIO_GET(ufloat, &din, "support_rate", &real_packet->support_rate, 10000)) {
24430       RECEIVE_PACKET_FIELD_ERROR(support_rate);
24431     }
24432   }
24433   if (BV_ISSET(fields, 14)) {
24434     log_packet_detailed("  got field 'energy_rate'");
24435     if (!DIO_GET(ufloat, &din, "energy_rate", &real_packet->energy_rate, 10000)) {
24436       RECEIVE_PACKET_FIELD_ERROR(energy_rate);
24437     }
24438   }
24439   if (BV_ISSET(fields, 15)) {
24440     log_packet_detailed("  got field 'success_rate'");
24441     if (!DIO_GET(ufloat, &din, "success_rate", &real_packet->success_rate, 10000)) {
24442       RECEIVE_PACKET_FIELD_ERROR(success_rate);
24443     }
24444   }
24445   if (BV_ISSET(fields, 16)) {
24446     log_packet_detailed("  got field 'travel_time'");
24447     if (!DIO_GET(ufloat, &din, "travel_time", &real_packet->travel_time, 10000)) {
24448       RECEIVE_PACKET_FIELD_ERROR(travel_time);
24449     }
24450   }
24451 
24452   if (NULL == old) {
24453     old = fc_malloc(sizeof(*old));
24454     *old = *real_packet;
24455     genhash_insert(*hash, old, old);
24456   } else {
24457     *old = *real_packet;
24458   }
24459   RECEIVE_PACKET_END(real_packet);
24460 }
24461 
send_packet_spaceship_info_100(struct connection * pc,const struct packet_spaceship_info * packet)24462 static int send_packet_spaceship_info_100(struct connection *pc, const struct packet_spaceship_info *packet)
24463 {
24464   const struct packet_spaceship_info *real_packet = packet;
24465   packet_spaceship_info_100_fields fields;
24466   struct packet_spaceship_info *old;
24467   bool differ;
24468   struct genhash **hash = pc->phs.sent + PACKET_SPACESHIP_INFO;
24469   int different = 0;
24470   SEND_PACKET_START(PACKET_SPACESHIP_INFO);
24471 
24472   log_packet_detailed("packet_spaceship_info_100: sending info about (%d)",
24473     real_packet->player_num);
24474 
24475   if (NULL == *hash) {
24476     *hash = genhash_new_full(hash_packet_spaceship_info_100, cmp_packet_spaceship_info_100,
24477                              NULL, NULL, NULL, free);
24478   }
24479   BV_CLR_ALL(fields);
24480 
24481   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
24482     old = fc_malloc(sizeof(*old));
24483     *old = *real_packet;
24484     genhash_insert(*hash, old, old);
24485     memset(old, 0, sizeof(*old));
24486     different = 1;      /* Force to send. */
24487   }
24488 
24489   differ = (old->sship_state != real_packet->sship_state);
24490   if (differ) {
24491     different++;
24492     BV_SET(fields, 0);
24493   }
24494 
24495   differ = (old->structurals != real_packet->structurals);
24496   if (differ) {
24497     different++;
24498     BV_SET(fields, 1);
24499   }
24500 
24501   differ = (old->components != real_packet->components);
24502   if (differ) {
24503     different++;
24504     BV_SET(fields, 2);
24505   }
24506 
24507   differ = (old->modules != real_packet->modules);
24508   if (differ) {
24509     different++;
24510     BV_SET(fields, 3);
24511   }
24512 
24513   differ = (old->fuel != real_packet->fuel);
24514   if (differ) {
24515     different++;
24516     BV_SET(fields, 4);
24517   }
24518 
24519   differ = (old->propulsion != real_packet->propulsion);
24520   if (differ) {
24521     different++;
24522     BV_SET(fields, 5);
24523   }
24524 
24525   differ = (old->habitation != real_packet->habitation);
24526   if (differ) {
24527     different++;
24528     BV_SET(fields, 6);
24529   }
24530 
24531   differ = (old->life_support != real_packet->life_support);
24532   if (differ) {
24533     different++;
24534     BV_SET(fields, 7);
24535   }
24536 
24537   differ = (old->solar_panels != real_packet->solar_panels);
24538   if (differ) {
24539     different++;
24540     BV_SET(fields, 8);
24541   }
24542 
24543   differ = (old->launch_year32 != real_packet->launch_year32);
24544   if (differ) {
24545     different++;
24546     BV_SET(fields, 9);
24547   }
24548 
24549   differ = (old->population != real_packet->population);
24550   if (differ) {
24551     different++;
24552     BV_SET(fields, 10);
24553   }
24554 
24555   differ = (old->mass != real_packet->mass);
24556   if (differ) {
24557     different++;
24558     BV_SET(fields, 11);
24559   }
24560 
24561   differ = !BV_ARE_EQUAL(old->structure, real_packet->structure);
24562   if (differ) {
24563     different++;
24564     BV_SET(fields, 12);
24565   }
24566 
24567   differ = (old->support_rate != real_packet->support_rate);
24568   if (differ) {
24569     different++;
24570     BV_SET(fields, 13);
24571   }
24572 
24573   differ = (old->energy_rate != real_packet->energy_rate);
24574   if (differ) {
24575     different++;
24576     BV_SET(fields, 14);
24577   }
24578 
24579   differ = (old->success_rate != real_packet->success_rate);
24580   if (differ) {
24581     different++;
24582     BV_SET(fields, 15);
24583   }
24584 
24585   differ = (old->travel_time != real_packet->travel_time);
24586   if (differ) {
24587     different++;
24588     BV_SET(fields, 16);
24589   }
24590 
24591 
24592   if (different == 0) {
24593     log_packet_detailed("  no change -> discard");
24594     return 0;
24595   }
24596 
24597   DIO_BV_PUT(&dout, "fields", fields);
24598   DIO_PUT(uint8, &dout, "player_num", real_packet->player_num);
24599 
24600   if (BV_ISSET(fields, 0)) {
24601     log_packet_detailed("  field 'sship_state' has changed");
24602     DIO_PUT(uint8, &dout, "sship_state", real_packet->sship_state);
24603   }
24604   if (BV_ISSET(fields, 1)) {
24605     log_packet_detailed("  field 'structurals' has changed");
24606     DIO_PUT(uint8, &dout, "structurals", real_packet->structurals);
24607   }
24608   if (BV_ISSET(fields, 2)) {
24609     log_packet_detailed("  field 'components' has changed");
24610     DIO_PUT(uint8, &dout, "components", real_packet->components);
24611   }
24612   if (BV_ISSET(fields, 3)) {
24613     log_packet_detailed("  field 'modules' has changed");
24614     DIO_PUT(uint8, &dout, "modules", real_packet->modules);
24615   }
24616   if (BV_ISSET(fields, 4)) {
24617     log_packet_detailed("  field 'fuel' has changed");
24618     DIO_PUT(uint8, &dout, "fuel", real_packet->fuel);
24619   }
24620   if (BV_ISSET(fields, 5)) {
24621     log_packet_detailed("  field 'propulsion' has changed");
24622     DIO_PUT(uint8, &dout, "propulsion", real_packet->propulsion);
24623   }
24624   if (BV_ISSET(fields, 6)) {
24625     log_packet_detailed("  field 'habitation' has changed");
24626     DIO_PUT(uint8, &dout, "habitation", real_packet->habitation);
24627   }
24628   if (BV_ISSET(fields, 7)) {
24629     log_packet_detailed("  field 'life_support' has changed");
24630     DIO_PUT(uint8, &dout, "life_support", real_packet->life_support);
24631   }
24632   if (BV_ISSET(fields, 8)) {
24633     log_packet_detailed("  field 'solar_panels' has changed");
24634     DIO_PUT(uint8, &dout, "solar_panels", real_packet->solar_panels);
24635   }
24636   if (BV_ISSET(fields, 9)) {
24637     log_packet_detailed("  field 'launch_year32' has changed");
24638     DIO_PUT(sint32, &dout, "launch_year32", real_packet->launch_year32);
24639   }
24640   if (BV_ISSET(fields, 10)) {
24641     log_packet_detailed("  field 'population' has changed");
24642     DIO_PUT(uint32, &dout, "population", real_packet->population);
24643   }
24644   if (BV_ISSET(fields, 11)) {
24645     log_packet_detailed("  field 'mass' has changed");
24646     DIO_PUT(uint32, &dout, "mass", real_packet->mass);
24647   }
24648   if (BV_ISSET(fields, 12)) {
24649     log_packet_detailed("  field 'structure' has changed");
24650   DIO_BV_PUT(&dout, "structure", packet->structure);
24651   }
24652   if (BV_ISSET(fields, 13)) {
24653     log_packet_detailed("  field 'support_rate' has changed");
24654     DIO_PUT(ufloat, &dout, "support_rate", real_packet->support_rate, 10000);
24655   }
24656   if (BV_ISSET(fields, 14)) {
24657     log_packet_detailed("  field 'energy_rate' has changed");
24658     DIO_PUT(ufloat, &dout, "energy_rate", real_packet->energy_rate, 10000);
24659   }
24660   if (BV_ISSET(fields, 15)) {
24661     log_packet_detailed("  field 'success_rate' has changed");
24662     DIO_PUT(ufloat, &dout, "success_rate", real_packet->success_rate, 10000);
24663   }
24664   if (BV_ISSET(fields, 16)) {
24665     log_packet_detailed("  field 'travel_time' has changed");
24666     DIO_PUT(ufloat, &dout, "travel_time", real_packet->travel_time, 10000);
24667   }
24668 
24669   *old = *real_packet;
24670   SEND_PACKET_END(PACKET_SPACESHIP_INFO);
24671 }
24672 
hash_packet_spaceship_info_101(const void * vkey)24673 static genhash_val_t hash_packet_spaceship_info_101(const void *vkey)
24674 {
24675   const struct packet_spaceship_info *key = (const struct packet_spaceship_info *) vkey;
24676 
24677   return key->player_num;
24678 }
24679 
cmp_packet_spaceship_info_101(const void * vkey1,const void * vkey2)24680 static bool cmp_packet_spaceship_info_101(const void *vkey1, const void *vkey2)
24681 {
24682   const struct packet_spaceship_info *key1 = (const struct packet_spaceship_info *) vkey1;
24683   const struct packet_spaceship_info *key2 = (const struct packet_spaceship_info *) vkey2;
24684 
24685   return key1->player_num == key2->player_num;
24686 }
24687 
24688 BV_DEFINE(packet_spaceship_info_101_fields, 17);
24689 
receive_packet_spaceship_info_101(struct connection * pc)24690 static struct packet_spaceship_info *receive_packet_spaceship_info_101(struct connection *pc)
24691 {
24692   packet_spaceship_info_101_fields fields;
24693   struct packet_spaceship_info *old;
24694   struct genhash **hash = pc->phs.received + PACKET_SPACESHIP_INFO;
24695   RECEIVE_PACKET_START(packet_spaceship_info, real_packet);
24696 
24697   DIO_BV_GET(&din, fields);
24698   if (!DIO_GET(uint8, &din, "player_num", &real_packet->player_num)) {
24699     RECEIVE_PACKET_FIELD_ERROR(player_num);
24700   }
24701 
24702   log_packet_detailed("packet_spaceship_info_101: got info about (%d)",
24703     real_packet->player_num);
24704 
24705   if (NULL == *hash) {
24706     *hash = genhash_new_full(hash_packet_spaceship_info_101, cmp_packet_spaceship_info_101,
24707                              NULL, NULL, NULL, free);
24708   }
24709 
24710   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
24711     *real_packet = *old;
24712   } else {
24713     int player_num = real_packet->player_num;
24714 
24715     log_packet_detailed("  no old info");
24716     memset(real_packet, 0, sizeof(*real_packet));
24717 
24718     real_packet->player_num = player_num;
24719   }
24720 
24721   if (BV_ISSET(fields, 0)) {
24722     log_packet_detailed("  got field 'sship_state'");
24723     if (!DIO_GET(uint8, &din, "sship_state", &real_packet->sship_state)) {
24724       RECEIVE_PACKET_FIELD_ERROR(sship_state);
24725     }
24726   }
24727   if (BV_ISSET(fields, 1)) {
24728     log_packet_detailed("  got field 'structurals'");
24729     if (!DIO_GET(uint8, &din, "structurals", &real_packet->structurals)) {
24730       RECEIVE_PACKET_FIELD_ERROR(structurals);
24731     }
24732   }
24733   if (BV_ISSET(fields, 2)) {
24734     log_packet_detailed("  got field 'components'");
24735     if (!DIO_GET(uint8, &din, "components", &real_packet->components)) {
24736       RECEIVE_PACKET_FIELD_ERROR(components);
24737     }
24738   }
24739   if (BV_ISSET(fields, 3)) {
24740     log_packet_detailed("  got field 'modules'");
24741     if (!DIO_GET(uint8, &din, "modules", &real_packet->modules)) {
24742       RECEIVE_PACKET_FIELD_ERROR(modules);
24743     }
24744   }
24745   if (BV_ISSET(fields, 4)) {
24746     log_packet_detailed("  got field 'fuel'");
24747     if (!DIO_GET(uint8, &din, "fuel", &real_packet->fuel)) {
24748       RECEIVE_PACKET_FIELD_ERROR(fuel);
24749     }
24750   }
24751   if (BV_ISSET(fields, 5)) {
24752     log_packet_detailed("  got field 'propulsion'");
24753     if (!DIO_GET(uint8, &din, "propulsion", &real_packet->propulsion)) {
24754       RECEIVE_PACKET_FIELD_ERROR(propulsion);
24755     }
24756   }
24757   if (BV_ISSET(fields, 6)) {
24758     log_packet_detailed("  got field 'habitation'");
24759     if (!DIO_GET(uint8, &din, "habitation", &real_packet->habitation)) {
24760       RECEIVE_PACKET_FIELD_ERROR(habitation);
24761     }
24762   }
24763   if (BV_ISSET(fields, 7)) {
24764     log_packet_detailed("  got field 'life_support'");
24765     if (!DIO_GET(uint8, &din, "life_support", &real_packet->life_support)) {
24766       RECEIVE_PACKET_FIELD_ERROR(life_support);
24767     }
24768   }
24769   if (BV_ISSET(fields, 8)) {
24770     log_packet_detailed("  got field 'solar_panels'");
24771     if (!DIO_GET(uint8, &din, "solar_panels", &real_packet->solar_panels)) {
24772       RECEIVE_PACKET_FIELD_ERROR(solar_panels);
24773     }
24774   }
24775   if (BV_ISSET(fields, 9)) {
24776     log_packet_detailed("  got field 'launch_year16'");
24777     if (!DIO_GET(sint16, &din, "launch_year16", &real_packet->launch_year16)) {
24778       RECEIVE_PACKET_FIELD_ERROR(launch_year16);
24779     }
24780   }
24781   if (BV_ISSET(fields, 10)) {
24782     log_packet_detailed("  got field 'population'");
24783     if (!DIO_GET(uint32, &din, "population", &real_packet->population)) {
24784       RECEIVE_PACKET_FIELD_ERROR(population);
24785     }
24786   }
24787   if (BV_ISSET(fields, 11)) {
24788     log_packet_detailed("  got field 'mass'");
24789     if (!DIO_GET(uint32, &din, "mass", &real_packet->mass)) {
24790       RECEIVE_PACKET_FIELD_ERROR(mass);
24791     }
24792   }
24793   if (BV_ISSET(fields, 12)) {
24794     log_packet_detailed("  got field 'structure'");
24795     if (!DIO_BV_GET(&din, real_packet->structure)) {
24796       RECEIVE_PACKET_FIELD_ERROR(structure);
24797     }
24798   }
24799   if (BV_ISSET(fields, 13)) {
24800     log_packet_detailed("  got field 'support_rate'");
24801     if (!DIO_GET(ufloat, &din, "support_rate", &real_packet->support_rate, 10000)) {
24802       RECEIVE_PACKET_FIELD_ERROR(support_rate);
24803     }
24804   }
24805   if (BV_ISSET(fields, 14)) {
24806     log_packet_detailed("  got field 'energy_rate'");
24807     if (!DIO_GET(ufloat, &din, "energy_rate", &real_packet->energy_rate, 10000)) {
24808       RECEIVE_PACKET_FIELD_ERROR(energy_rate);
24809     }
24810   }
24811   if (BV_ISSET(fields, 15)) {
24812     log_packet_detailed("  got field 'success_rate'");
24813     if (!DIO_GET(ufloat, &din, "success_rate", &real_packet->success_rate, 10000)) {
24814       RECEIVE_PACKET_FIELD_ERROR(success_rate);
24815     }
24816   }
24817   if (BV_ISSET(fields, 16)) {
24818     log_packet_detailed("  got field 'travel_time'");
24819     if (!DIO_GET(ufloat, &din, "travel_time", &real_packet->travel_time, 10000)) {
24820       RECEIVE_PACKET_FIELD_ERROR(travel_time);
24821     }
24822   }
24823 
24824   if (NULL == old) {
24825     old = fc_malloc(sizeof(*old));
24826     *old = *real_packet;
24827     genhash_insert(*hash, old, old);
24828   } else {
24829     *old = *real_packet;
24830   }
24831   RECEIVE_PACKET_END(real_packet);
24832 }
24833 
send_packet_spaceship_info_101(struct connection * pc,const struct packet_spaceship_info * packet)24834 static int send_packet_spaceship_info_101(struct connection *pc, const struct packet_spaceship_info *packet)
24835 {
24836   const struct packet_spaceship_info *real_packet = packet;
24837   packet_spaceship_info_101_fields fields;
24838   struct packet_spaceship_info *old;
24839   bool differ;
24840   struct genhash **hash = pc->phs.sent + PACKET_SPACESHIP_INFO;
24841   int different = 0;
24842   SEND_PACKET_START(PACKET_SPACESHIP_INFO);
24843 
24844   log_packet_detailed("packet_spaceship_info_101: sending info about (%d)",
24845     real_packet->player_num);
24846 
24847   if (NULL == *hash) {
24848     *hash = genhash_new_full(hash_packet_spaceship_info_101, cmp_packet_spaceship_info_101,
24849                              NULL, NULL, NULL, free);
24850   }
24851   BV_CLR_ALL(fields);
24852 
24853   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
24854     old = fc_malloc(sizeof(*old));
24855     *old = *real_packet;
24856     genhash_insert(*hash, old, old);
24857     memset(old, 0, sizeof(*old));
24858     different = 1;      /* Force to send. */
24859   }
24860 
24861   differ = (old->sship_state != real_packet->sship_state);
24862   if (differ) {
24863     different++;
24864     BV_SET(fields, 0);
24865   }
24866 
24867   differ = (old->structurals != real_packet->structurals);
24868   if (differ) {
24869     different++;
24870     BV_SET(fields, 1);
24871   }
24872 
24873   differ = (old->components != real_packet->components);
24874   if (differ) {
24875     different++;
24876     BV_SET(fields, 2);
24877   }
24878 
24879   differ = (old->modules != real_packet->modules);
24880   if (differ) {
24881     different++;
24882     BV_SET(fields, 3);
24883   }
24884 
24885   differ = (old->fuel != real_packet->fuel);
24886   if (differ) {
24887     different++;
24888     BV_SET(fields, 4);
24889   }
24890 
24891   differ = (old->propulsion != real_packet->propulsion);
24892   if (differ) {
24893     different++;
24894     BV_SET(fields, 5);
24895   }
24896 
24897   differ = (old->habitation != real_packet->habitation);
24898   if (differ) {
24899     different++;
24900     BV_SET(fields, 6);
24901   }
24902 
24903   differ = (old->life_support != real_packet->life_support);
24904   if (differ) {
24905     different++;
24906     BV_SET(fields, 7);
24907   }
24908 
24909   differ = (old->solar_panels != real_packet->solar_panels);
24910   if (differ) {
24911     different++;
24912     BV_SET(fields, 8);
24913   }
24914 
24915   differ = (old->launch_year16 != real_packet->launch_year16);
24916   if (differ) {
24917     different++;
24918     BV_SET(fields, 9);
24919   }
24920 
24921   differ = (old->population != real_packet->population);
24922   if (differ) {
24923     different++;
24924     BV_SET(fields, 10);
24925   }
24926 
24927   differ = (old->mass != real_packet->mass);
24928   if (differ) {
24929     different++;
24930     BV_SET(fields, 11);
24931   }
24932 
24933   differ = !BV_ARE_EQUAL(old->structure, real_packet->structure);
24934   if (differ) {
24935     different++;
24936     BV_SET(fields, 12);
24937   }
24938 
24939   differ = (old->support_rate != real_packet->support_rate);
24940   if (differ) {
24941     different++;
24942     BV_SET(fields, 13);
24943   }
24944 
24945   differ = (old->energy_rate != real_packet->energy_rate);
24946   if (differ) {
24947     different++;
24948     BV_SET(fields, 14);
24949   }
24950 
24951   differ = (old->success_rate != real_packet->success_rate);
24952   if (differ) {
24953     different++;
24954     BV_SET(fields, 15);
24955   }
24956 
24957   differ = (old->travel_time != real_packet->travel_time);
24958   if (differ) {
24959     different++;
24960     BV_SET(fields, 16);
24961   }
24962 
24963 
24964   if (different == 0) {
24965     log_packet_detailed("  no change -> discard");
24966     return 0;
24967   }
24968 
24969   DIO_BV_PUT(&dout, "fields", fields);
24970   DIO_PUT(uint8, &dout, "player_num", real_packet->player_num);
24971 
24972   if (BV_ISSET(fields, 0)) {
24973     log_packet_detailed("  field 'sship_state' has changed");
24974     DIO_PUT(uint8, &dout, "sship_state", real_packet->sship_state);
24975   }
24976   if (BV_ISSET(fields, 1)) {
24977     log_packet_detailed("  field 'structurals' has changed");
24978     DIO_PUT(uint8, &dout, "structurals", real_packet->structurals);
24979   }
24980   if (BV_ISSET(fields, 2)) {
24981     log_packet_detailed("  field 'components' has changed");
24982     DIO_PUT(uint8, &dout, "components", real_packet->components);
24983   }
24984   if (BV_ISSET(fields, 3)) {
24985     log_packet_detailed("  field 'modules' has changed");
24986     DIO_PUT(uint8, &dout, "modules", real_packet->modules);
24987   }
24988   if (BV_ISSET(fields, 4)) {
24989     log_packet_detailed("  field 'fuel' has changed");
24990     DIO_PUT(uint8, &dout, "fuel", real_packet->fuel);
24991   }
24992   if (BV_ISSET(fields, 5)) {
24993     log_packet_detailed("  field 'propulsion' has changed");
24994     DIO_PUT(uint8, &dout, "propulsion", real_packet->propulsion);
24995   }
24996   if (BV_ISSET(fields, 6)) {
24997     log_packet_detailed("  field 'habitation' has changed");
24998     DIO_PUT(uint8, &dout, "habitation", real_packet->habitation);
24999   }
25000   if (BV_ISSET(fields, 7)) {
25001     log_packet_detailed("  field 'life_support' has changed");
25002     DIO_PUT(uint8, &dout, "life_support", real_packet->life_support);
25003   }
25004   if (BV_ISSET(fields, 8)) {
25005     log_packet_detailed("  field 'solar_panels' has changed");
25006     DIO_PUT(uint8, &dout, "solar_panels", real_packet->solar_panels);
25007   }
25008   if (BV_ISSET(fields, 9)) {
25009     log_packet_detailed("  field 'launch_year16' has changed");
25010     DIO_PUT(sint16, &dout, "launch_year16", real_packet->launch_year16);
25011   }
25012   if (BV_ISSET(fields, 10)) {
25013     log_packet_detailed("  field 'population' has changed");
25014     DIO_PUT(uint32, &dout, "population", real_packet->population);
25015   }
25016   if (BV_ISSET(fields, 11)) {
25017     log_packet_detailed("  field 'mass' has changed");
25018     DIO_PUT(uint32, &dout, "mass", real_packet->mass);
25019   }
25020   if (BV_ISSET(fields, 12)) {
25021     log_packet_detailed("  field 'structure' has changed");
25022   DIO_BV_PUT(&dout, "structure", packet->structure);
25023   }
25024   if (BV_ISSET(fields, 13)) {
25025     log_packet_detailed("  field 'support_rate' has changed");
25026     DIO_PUT(ufloat, &dout, "support_rate", real_packet->support_rate, 10000);
25027   }
25028   if (BV_ISSET(fields, 14)) {
25029     log_packet_detailed("  field 'energy_rate' has changed");
25030     DIO_PUT(ufloat, &dout, "energy_rate", real_packet->energy_rate, 10000);
25031   }
25032   if (BV_ISSET(fields, 15)) {
25033     log_packet_detailed("  field 'success_rate' has changed");
25034     DIO_PUT(ufloat, &dout, "success_rate", real_packet->success_rate, 10000);
25035   }
25036   if (BV_ISSET(fields, 16)) {
25037     log_packet_detailed("  field 'travel_time' has changed");
25038     DIO_PUT(ufloat, &dout, "travel_time", real_packet->travel_time, 10000);
25039   }
25040 
25041   *old = *real_packet;
25042   SEND_PACKET_END(PACKET_SPACESHIP_INFO);
25043 }
25044 
send_packet_spaceship_info(struct connection * pc,const struct packet_spaceship_info * packet)25045 int send_packet_spaceship_info(struct connection *pc, const struct packet_spaceship_info *packet)
25046 {
25047   if (!pc->used) {
25048     log_error("WARNING: trying to send data to the closed connection %s",
25049               conn_description(pc));
25050     return -1;
25051   }
25052   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SPACESHIP_INFO].packet != NULL, -1,
25053                         "Handler for PACKET_SPACESHIP_INFO not installed");
25054   return pc->phs.handlers->send[PACKET_SPACESHIP_INFO].packet(pc, packet);
25055 }
25056 
lsend_packet_spaceship_info(struct conn_list * dest,const struct packet_spaceship_info * packet)25057 void lsend_packet_spaceship_info(struct conn_list *dest, const struct packet_spaceship_info *packet)
25058 {
25059   conn_list_iterate(dest, pconn) {
25060     send_packet_spaceship_info(pconn, packet);
25061   } conn_list_iterate_end;
25062 }
25063 
25064 #define hash_packet_ruleset_unit_100 hash_const
25065 
25066 #define cmp_packet_ruleset_unit_100 cmp_const
25067 
25068 BV_DEFINE(packet_ruleset_unit_100_fields, 44);
25069 
receive_packet_ruleset_unit_100(struct connection * pc)25070 static struct packet_ruleset_unit *receive_packet_ruleset_unit_100(struct connection *pc)
25071 {
25072   packet_ruleset_unit_100_fields fields;
25073   struct packet_ruleset_unit *old;
25074   struct genhash **hash = pc->phs.received + PACKET_RULESET_UNIT;
25075   RECEIVE_PACKET_START(packet_ruleset_unit, real_packet);
25076 
25077   DIO_BV_GET(&din, fields);
25078 
25079   log_packet_detailed("packet_ruleset_unit_100: got info about ()");
25080 
25081   if (NULL == *hash) {
25082     *hash = genhash_new_full(hash_packet_ruleset_unit_100, cmp_packet_ruleset_unit_100,
25083                              NULL, NULL, NULL, free);
25084   }
25085 
25086   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
25087     *real_packet = *old;
25088   } else {
25089     log_packet_detailed("  no old info");
25090     memset(real_packet, 0, sizeof(*real_packet));
25091   }
25092 
25093   if (BV_ISSET(fields, 0)) {
25094     log_packet_detailed("  got field 'id'");
25095     {
25096       int readin;
25097 
25098       if (!DIO_GET(uint8, &din, "id", &readin)) {
25099         RECEIVE_PACKET_FIELD_ERROR(id);
25100       }
25101       real_packet->id = readin;
25102     }
25103   }
25104   if (BV_ISSET(fields, 1)) {
25105     log_packet_detailed("  got field 'name'");
25106     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
25107       RECEIVE_PACKET_FIELD_ERROR(name);
25108     }
25109   }
25110   if (BV_ISSET(fields, 2)) {
25111     log_packet_detailed("  got field 'rule_name'");
25112     if (!DIO_GET(string, &din, "rule_name", real_packet->rule_name, sizeof(real_packet->rule_name))) {
25113       RECEIVE_PACKET_FIELD_ERROR(rule_name);
25114     }
25115   }
25116   if (BV_ISSET(fields, 3)) {
25117     log_packet_detailed("  got field 'graphic_str'");
25118     if (!DIO_GET(string, &din, "graphic_str", real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
25119       RECEIVE_PACKET_FIELD_ERROR(graphic_str);
25120     }
25121   }
25122   if (BV_ISSET(fields, 4)) {
25123     log_packet_detailed("  got field 'graphic_alt'");
25124     if (!DIO_GET(string, &din, "graphic_alt", real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
25125       RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
25126     }
25127   }
25128   if (BV_ISSET(fields, 5)) {
25129     log_packet_detailed("  got field 'sound_move'");
25130     if (!DIO_GET(string, &din, "sound_move", real_packet->sound_move, sizeof(real_packet->sound_move))) {
25131       RECEIVE_PACKET_FIELD_ERROR(sound_move);
25132     }
25133   }
25134   if (BV_ISSET(fields, 6)) {
25135     log_packet_detailed("  got field 'sound_move_alt'");
25136     if (!DIO_GET(string, &din, "sound_move_alt", real_packet->sound_move_alt, sizeof(real_packet->sound_move_alt))) {
25137       RECEIVE_PACKET_FIELD_ERROR(sound_move_alt);
25138     }
25139   }
25140   if (BV_ISSET(fields, 7)) {
25141     log_packet_detailed("  got field 'sound_fight'");
25142     if (!DIO_GET(string, &din, "sound_fight", real_packet->sound_fight, sizeof(real_packet->sound_fight))) {
25143       RECEIVE_PACKET_FIELD_ERROR(sound_fight);
25144     }
25145   }
25146   if (BV_ISSET(fields, 8)) {
25147     log_packet_detailed("  got field 'sound_fight_alt'");
25148     if (!DIO_GET(string, &din, "sound_fight_alt", real_packet->sound_fight_alt, sizeof(real_packet->sound_fight_alt))) {
25149       RECEIVE_PACKET_FIELD_ERROR(sound_fight_alt);
25150     }
25151   }
25152   if (BV_ISSET(fields, 9)) {
25153     log_packet_detailed("  got field 'unit_class_id'");
25154     if (!DIO_GET(uint8, &din, "unit_class_id", &real_packet->unit_class_id)) {
25155       RECEIVE_PACKET_FIELD_ERROR(unit_class_id);
25156     }
25157   }
25158   if (BV_ISSET(fields, 10)) {
25159     log_packet_detailed("  got field 'build_cost'");
25160     if (!DIO_GET(uint16, &din, "build_cost", &real_packet->build_cost)) {
25161       RECEIVE_PACKET_FIELD_ERROR(build_cost);
25162     }
25163   }
25164   if (BV_ISSET(fields, 11)) {
25165     log_packet_detailed("  got field 'pop_cost'");
25166     if (!DIO_GET(uint8, &din, "pop_cost", &real_packet->pop_cost)) {
25167       RECEIVE_PACKET_FIELD_ERROR(pop_cost);
25168     }
25169   }
25170   if (BV_ISSET(fields, 12)) {
25171     log_packet_detailed("  got field 'attack_strength'");
25172     if (!DIO_GET(uint8, &din, "attack_strength", &real_packet->attack_strength)) {
25173       RECEIVE_PACKET_FIELD_ERROR(attack_strength);
25174     }
25175   }
25176   if (BV_ISSET(fields, 13)) {
25177     log_packet_detailed("  got field 'defense_strength'");
25178     if (!DIO_GET(uint8, &din, "defense_strength", &real_packet->defense_strength)) {
25179       RECEIVE_PACKET_FIELD_ERROR(defense_strength);
25180     }
25181   }
25182   if (BV_ISSET(fields, 14)) {
25183     log_packet_detailed("  got field 'move_rate'");
25184     if (!DIO_GET(uint16, &din, "move_rate", &real_packet->move_rate)) {
25185       RECEIVE_PACKET_FIELD_ERROR(move_rate);
25186     }
25187   }
25188   if (BV_ISSET(fields, 15)) {
25189     log_packet_detailed("  got field 'tech_requirement'");
25190     if (!DIO_GET(uint8, &din, "tech_requirement", &real_packet->tech_requirement)) {
25191       RECEIVE_PACKET_FIELD_ERROR(tech_requirement);
25192     }
25193   }
25194   if (BV_ISSET(fields, 16)) {
25195     log_packet_detailed("  got field 'impr_requirement'");
25196     if (!DIO_GET(uint8, &din, "impr_requirement", &real_packet->impr_requirement)) {
25197       RECEIVE_PACKET_FIELD_ERROR(impr_requirement);
25198     }
25199   }
25200   if (BV_ISSET(fields, 17)) {
25201     log_packet_detailed("  got field 'gov_requirement'");
25202     {
25203       int readin;
25204 
25205       if (!DIO_GET(sint8, &din, "gov_requirement", &readin)) {
25206         RECEIVE_PACKET_FIELD_ERROR(gov_requirement);
25207       }
25208       real_packet->gov_requirement = readin;
25209     }
25210   }
25211   if (BV_ISSET(fields, 18)) {
25212     log_packet_detailed("  got field 'vision_radius_sq'");
25213     if (!DIO_GET(uint16, &din, "vision_radius_sq", &real_packet->vision_radius_sq)) {
25214       RECEIVE_PACKET_FIELD_ERROR(vision_radius_sq);
25215     }
25216   }
25217   if (BV_ISSET(fields, 19)) {
25218     log_packet_detailed("  got field 'transport_capacity'");
25219     if (!DIO_GET(uint8, &din, "transport_capacity", &real_packet->transport_capacity)) {
25220       RECEIVE_PACKET_FIELD_ERROR(transport_capacity);
25221     }
25222   }
25223   if (BV_ISSET(fields, 20)) {
25224     log_packet_detailed("  got field 'hp'");
25225     if (!DIO_GET(uint8, &din, "hp", &real_packet->hp)) {
25226       RECEIVE_PACKET_FIELD_ERROR(hp);
25227     }
25228   }
25229   if (BV_ISSET(fields, 21)) {
25230     log_packet_detailed("  got field 'firepower'");
25231     if (!DIO_GET(uint8, &din, "firepower", &real_packet->firepower)) {
25232       RECEIVE_PACKET_FIELD_ERROR(firepower);
25233     }
25234   }
25235   if (BV_ISSET(fields, 22)) {
25236     log_packet_detailed("  got field 'obsoleted_by'");
25237     if (!DIO_GET(uint8, &din, "obsoleted_by", &real_packet->obsoleted_by)) {
25238       RECEIVE_PACKET_FIELD_ERROR(obsoleted_by);
25239     }
25240   }
25241   if (BV_ISSET(fields, 23)) {
25242     log_packet_detailed("  got field 'converted_to'");
25243     if (!DIO_GET(uint8, &din, "converted_to", &real_packet->converted_to)) {
25244       RECEIVE_PACKET_FIELD_ERROR(converted_to);
25245     }
25246   }
25247   if (BV_ISSET(fields, 24)) {
25248     log_packet_detailed("  got field 'convert_time'");
25249     if (!DIO_GET(uint8, &din, "convert_time", &real_packet->convert_time)) {
25250       RECEIVE_PACKET_FIELD_ERROR(convert_time);
25251     }
25252   }
25253   if (BV_ISSET(fields, 25)) {
25254     log_packet_detailed("  got field 'fuel'");
25255     if (!DIO_GET(uint8, &din, "fuel", &real_packet->fuel)) {
25256       RECEIVE_PACKET_FIELD_ERROR(fuel);
25257     }
25258   }
25259   if (BV_ISSET(fields, 26)) {
25260     log_packet_detailed("  got field 'happy_cost'");
25261     if (!DIO_GET(uint8, &din, "happy_cost", &real_packet->happy_cost)) {
25262       RECEIVE_PACKET_FIELD_ERROR(happy_cost);
25263     }
25264   }
25265   if (BV_ISSET(fields, 27)) {
25266     log_packet_detailed("  got field 'upkeep'");
25267 
25268     {
25269       int i;
25270 
25271       for (i = 0; i < O_LAST; i++) {
25272         if (!DIO_GET(uint8, &din, "upkeep", &real_packet->upkeep[i])) {
25273           RECEIVE_PACKET_FIELD_ERROR(upkeep);
25274         }
25275       }
25276     }
25277   }
25278   if (BV_ISSET(fields, 28)) {
25279     log_packet_detailed("  got field 'paratroopers_range'");
25280     if (!DIO_GET(uint16, &din, "paratroopers_range", &real_packet->paratroopers_range)) {
25281       RECEIVE_PACKET_FIELD_ERROR(paratroopers_range);
25282     }
25283   }
25284   if (BV_ISSET(fields, 29)) {
25285     log_packet_detailed("  got field 'paratroopers_mr_req'");
25286     if (!DIO_GET(uint8, &din, "paratroopers_mr_req", &real_packet->paratroopers_mr_req)) {
25287       RECEIVE_PACKET_FIELD_ERROR(paratroopers_mr_req);
25288     }
25289   }
25290   if (BV_ISSET(fields, 30)) {
25291     log_packet_detailed("  got field 'paratroopers_mr_sub'");
25292     if (!DIO_GET(uint8, &din, "paratroopers_mr_sub", &real_packet->paratroopers_mr_sub)) {
25293       RECEIVE_PACKET_FIELD_ERROR(paratroopers_mr_sub);
25294     }
25295   }
25296   if (BV_ISSET(fields, 31)) {
25297     log_packet_detailed("  got field 'veteran_levels'");
25298     if (!DIO_GET(uint8, &din, "veteran_levels", &real_packet->veteran_levels)) {
25299       RECEIVE_PACKET_FIELD_ERROR(veteran_levels);
25300     }
25301   }
25302   if (BV_ISSET(fields, 32)) {
25303     log_packet_detailed("  got field 'veteran_name'");
25304 
25305     {
25306       int i;
25307 
25308       if (real_packet->veteran_levels > MAX_VET_LEVELS) {
25309         RECEIVE_PACKET_FIELD_ERROR(veteran_name, ": truncation array");
25310       }
25311       for (i = 0; i < real_packet->veteran_levels; i++) {
25312         if (!DIO_GET(string, &din, "veteran_name", real_packet->veteran_name[i], sizeof(real_packet->veteran_name[i]))) {
25313           RECEIVE_PACKET_FIELD_ERROR(veteran_name);
25314         }
25315       }
25316     }
25317   }
25318   if (BV_ISSET(fields, 33)) {
25319     log_packet_detailed("  got field 'power_fact'");
25320 
25321     {
25322       int i;
25323 
25324       if (real_packet->veteran_levels > MAX_VET_LEVELS) {
25325         RECEIVE_PACKET_FIELD_ERROR(power_fact, ": truncation array");
25326       }
25327       for (i = 0; i < real_packet->veteran_levels; i++) {
25328         if (!DIO_GET(uint16, &din, "power_fact", &real_packet->power_fact[i])) {
25329           RECEIVE_PACKET_FIELD_ERROR(power_fact);
25330         }
25331       }
25332     }
25333   }
25334   if (BV_ISSET(fields, 34)) {
25335     log_packet_detailed("  got field 'move_bonus'");
25336 
25337     {
25338       int i;
25339 
25340       if (real_packet->veteran_levels > MAX_VET_LEVELS) {
25341         RECEIVE_PACKET_FIELD_ERROR(move_bonus, ": truncation array");
25342       }
25343       for (i = 0; i < real_packet->veteran_levels; i++) {
25344         if (!DIO_GET(uint16, &din, "move_bonus", &real_packet->move_bonus[i])) {
25345           RECEIVE_PACKET_FIELD_ERROR(move_bonus);
25346         }
25347       }
25348     }
25349   }
25350   if (BV_ISSET(fields, 35)) {
25351     log_packet_detailed("  got field 'bombard_rate'");
25352     if (!DIO_GET(uint8, &din, "bombard_rate", &real_packet->bombard_rate)) {
25353       RECEIVE_PACKET_FIELD_ERROR(bombard_rate);
25354     }
25355   }
25356   if (BV_ISSET(fields, 36)) {
25357     log_packet_detailed("  got field 'city_size'");
25358     if (!DIO_GET(uint8, &din, "city_size", &real_packet->city_size)) {
25359       RECEIVE_PACKET_FIELD_ERROR(city_size);
25360     }
25361   }
25362   if (BV_ISSET(fields, 37)) {
25363     log_packet_detailed("  got field 'cargo'");
25364     if (!DIO_BV_GET(&din, real_packet->cargo)) {
25365       RECEIVE_PACKET_FIELD_ERROR(cargo);
25366     }
25367   }
25368   if (BV_ISSET(fields, 38)) {
25369     log_packet_detailed("  got field 'targets'");
25370     if (!DIO_BV_GET(&din, real_packet->targets)) {
25371       RECEIVE_PACKET_FIELD_ERROR(targets);
25372     }
25373   }
25374   if (BV_ISSET(fields, 39)) {
25375     log_packet_detailed("  got field 'embarks'");
25376     if (!DIO_BV_GET(&din, real_packet->embarks)) {
25377       RECEIVE_PACKET_FIELD_ERROR(embarks);
25378     }
25379   }
25380   if (BV_ISSET(fields, 40)) {
25381     log_packet_detailed("  got field 'disembarks'");
25382     if (!DIO_BV_GET(&din, real_packet->disembarks)) {
25383       RECEIVE_PACKET_FIELD_ERROR(disembarks);
25384     }
25385   }
25386   if (BV_ISSET(fields, 41)) {
25387     log_packet_detailed("  got field 'helptext'");
25388     if (!DIO_GET(string, &din, "helptext", real_packet->helptext, sizeof(real_packet->helptext))) {
25389       RECEIVE_PACKET_FIELD_ERROR(helptext);
25390     }
25391   }
25392   if (BV_ISSET(fields, 42)) {
25393     log_packet_detailed("  got field 'flags'");
25394     if (!DIO_BV_GET(&din, real_packet->flags)) {
25395       RECEIVE_PACKET_FIELD_ERROR(flags);
25396     }
25397   }
25398   if (BV_ISSET(fields, 43)) {
25399     log_packet_detailed("  got field 'roles'");
25400     if (!DIO_BV_GET(&din, real_packet->roles)) {
25401       RECEIVE_PACKET_FIELD_ERROR(roles);
25402     }
25403   }
25404 
25405   if (NULL == old) {
25406     old = fc_malloc(sizeof(*old));
25407     *old = *real_packet;
25408     genhash_insert(*hash, old, old);
25409   } else {
25410     *old = *real_packet;
25411   }
25412   RECEIVE_PACKET_END(real_packet);
25413 }
25414 
send_packet_ruleset_unit_100(struct connection * pc,const struct packet_ruleset_unit * packet)25415 static int send_packet_ruleset_unit_100(struct connection *pc, const struct packet_ruleset_unit *packet)
25416 {
25417   const struct packet_ruleset_unit *real_packet = packet;
25418   packet_ruleset_unit_100_fields fields;
25419   struct packet_ruleset_unit *old;
25420   bool differ;
25421   struct genhash **hash = pc->phs.sent + PACKET_RULESET_UNIT;
25422   int different = 0;
25423   SEND_PACKET_START(PACKET_RULESET_UNIT);
25424 
25425   log_packet_detailed("packet_ruleset_unit_100: sending info about ()");
25426 
25427   if (NULL == *hash) {
25428     *hash = genhash_new_full(hash_packet_ruleset_unit_100, cmp_packet_ruleset_unit_100,
25429                              NULL, NULL, NULL, free);
25430   }
25431   BV_CLR_ALL(fields);
25432 
25433   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
25434     old = fc_malloc(sizeof(*old));
25435     *old = *real_packet;
25436     genhash_insert(*hash, old, old);
25437     memset(old, 0, sizeof(*old));
25438     different = 1;      /* Force to send. */
25439   }
25440 
25441   differ = (old->id != real_packet->id);
25442   if (differ) {
25443     different++;
25444     BV_SET(fields, 0);
25445   }
25446 
25447   differ = (strcmp(old->name, real_packet->name) != 0);
25448   if (differ) {
25449     different++;
25450     BV_SET(fields, 1);
25451   }
25452 
25453   differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
25454   if (differ) {
25455     different++;
25456     BV_SET(fields, 2);
25457   }
25458 
25459   differ = (strcmp(old->graphic_str, real_packet->graphic_str) != 0);
25460   if (differ) {
25461     different++;
25462     BV_SET(fields, 3);
25463   }
25464 
25465   differ = (strcmp(old->graphic_alt, real_packet->graphic_alt) != 0);
25466   if (differ) {
25467     different++;
25468     BV_SET(fields, 4);
25469   }
25470 
25471   differ = (strcmp(old->sound_move, real_packet->sound_move) != 0);
25472   if (differ) {
25473     different++;
25474     BV_SET(fields, 5);
25475   }
25476 
25477   differ = (strcmp(old->sound_move_alt, real_packet->sound_move_alt) != 0);
25478   if (differ) {
25479     different++;
25480     BV_SET(fields, 6);
25481   }
25482 
25483   differ = (strcmp(old->sound_fight, real_packet->sound_fight) != 0);
25484   if (differ) {
25485     different++;
25486     BV_SET(fields, 7);
25487   }
25488 
25489   differ = (strcmp(old->sound_fight_alt, real_packet->sound_fight_alt) != 0);
25490   if (differ) {
25491     different++;
25492     BV_SET(fields, 8);
25493   }
25494 
25495   differ = (old->unit_class_id != real_packet->unit_class_id);
25496   if (differ) {
25497     different++;
25498     BV_SET(fields, 9);
25499   }
25500 
25501   differ = (old->build_cost != real_packet->build_cost);
25502   if (differ) {
25503     different++;
25504     BV_SET(fields, 10);
25505   }
25506 
25507   differ = (old->pop_cost != real_packet->pop_cost);
25508   if (differ) {
25509     different++;
25510     BV_SET(fields, 11);
25511   }
25512 
25513   differ = (old->attack_strength != real_packet->attack_strength);
25514   if (differ) {
25515     different++;
25516     BV_SET(fields, 12);
25517   }
25518 
25519   differ = (old->defense_strength != real_packet->defense_strength);
25520   if (differ) {
25521     different++;
25522     BV_SET(fields, 13);
25523   }
25524 
25525   differ = (old->move_rate != real_packet->move_rate);
25526   if (differ) {
25527     different++;
25528     BV_SET(fields, 14);
25529   }
25530 
25531   differ = (old->tech_requirement != real_packet->tech_requirement);
25532   if (differ) {
25533     different++;
25534     BV_SET(fields, 15);
25535   }
25536 
25537   differ = (old->impr_requirement != real_packet->impr_requirement);
25538   if (differ) {
25539     different++;
25540     BV_SET(fields, 16);
25541   }
25542 
25543   differ = (old->gov_requirement != real_packet->gov_requirement);
25544   if (differ) {
25545     different++;
25546     BV_SET(fields, 17);
25547   }
25548 
25549   differ = (old->vision_radius_sq != real_packet->vision_radius_sq);
25550   if (differ) {
25551     different++;
25552     BV_SET(fields, 18);
25553   }
25554 
25555   differ = (old->transport_capacity != real_packet->transport_capacity);
25556   if (differ) {
25557     different++;
25558     BV_SET(fields, 19);
25559   }
25560 
25561   differ = (old->hp != real_packet->hp);
25562   if (differ) {
25563     different++;
25564     BV_SET(fields, 20);
25565   }
25566 
25567   differ = (old->firepower != real_packet->firepower);
25568   if (differ) {
25569     different++;
25570     BV_SET(fields, 21);
25571   }
25572 
25573   differ = (old->obsoleted_by != real_packet->obsoleted_by);
25574   if (differ) {
25575     different++;
25576     BV_SET(fields, 22);
25577   }
25578 
25579   differ = (old->converted_to != real_packet->converted_to);
25580   if (differ) {
25581     different++;
25582     BV_SET(fields, 23);
25583   }
25584 
25585   differ = (old->convert_time != real_packet->convert_time);
25586   if (differ) {
25587     different++;
25588     BV_SET(fields, 24);
25589   }
25590 
25591   differ = (old->fuel != real_packet->fuel);
25592   if (differ) {
25593     different++;
25594     BV_SET(fields, 25);
25595   }
25596 
25597   differ = (old->happy_cost != real_packet->happy_cost);
25598   if (differ) {
25599     different++;
25600     BV_SET(fields, 26);
25601   }
25602 
25603 
25604     {
25605       differ = (O_LAST != O_LAST);
25606       if (!differ) {
25607         int i;
25608 
25609         for (i = 0; i < O_LAST; i++) {
25610           if (old->upkeep[i] != real_packet->upkeep[i]) {
25611             differ = TRUE;
25612             break;
25613           }
25614         }
25615       }
25616     }
25617   if (differ) {
25618     different++;
25619     BV_SET(fields, 27);
25620   }
25621 
25622   differ = (old->paratroopers_range != real_packet->paratroopers_range);
25623   if (differ) {
25624     different++;
25625     BV_SET(fields, 28);
25626   }
25627 
25628   differ = (old->paratroopers_mr_req != real_packet->paratroopers_mr_req);
25629   if (differ) {
25630     different++;
25631     BV_SET(fields, 29);
25632   }
25633 
25634   differ = (old->paratroopers_mr_sub != real_packet->paratroopers_mr_sub);
25635   if (differ) {
25636     different++;
25637     BV_SET(fields, 30);
25638   }
25639 
25640   differ = (old->veteran_levels != real_packet->veteran_levels);
25641   if (differ) {
25642     different++;
25643     BV_SET(fields, 31);
25644   }
25645 
25646 
25647     {
25648       differ = (old->veteran_levels != real_packet->veteran_levels);
25649       if (!differ) {
25650         int i;
25651 
25652         for (i = 0; i < real_packet->veteran_levels; i++) {
25653           if (strcmp(old->veteran_name[i], real_packet->veteran_name[i]) != 0) {
25654             differ = TRUE;
25655             break;
25656           }
25657         }
25658       }
25659     }
25660   if (differ) {
25661     different++;
25662     BV_SET(fields, 32);
25663   }
25664 
25665 
25666     {
25667       differ = (old->veteran_levels != real_packet->veteran_levels);
25668       if (!differ) {
25669         int i;
25670 
25671         for (i = 0; i < real_packet->veteran_levels; i++) {
25672           if (old->power_fact[i] != real_packet->power_fact[i]) {
25673             differ = TRUE;
25674             break;
25675           }
25676         }
25677       }
25678     }
25679   if (differ) {
25680     different++;
25681     BV_SET(fields, 33);
25682   }
25683 
25684 
25685     {
25686       differ = (old->veteran_levels != real_packet->veteran_levels);
25687       if (!differ) {
25688         int i;
25689 
25690         for (i = 0; i < real_packet->veteran_levels; i++) {
25691           if (old->move_bonus[i] != real_packet->move_bonus[i]) {
25692             differ = TRUE;
25693             break;
25694           }
25695         }
25696       }
25697     }
25698   if (differ) {
25699     different++;
25700     BV_SET(fields, 34);
25701   }
25702 
25703   differ = (old->bombard_rate != real_packet->bombard_rate);
25704   if (differ) {
25705     different++;
25706     BV_SET(fields, 35);
25707   }
25708 
25709   differ = (old->city_size != real_packet->city_size);
25710   if (differ) {
25711     different++;
25712     BV_SET(fields, 36);
25713   }
25714 
25715   differ = !BV_ARE_EQUAL(old->cargo, real_packet->cargo);
25716   if (differ) {
25717     different++;
25718     BV_SET(fields, 37);
25719   }
25720 
25721   differ = !BV_ARE_EQUAL(old->targets, real_packet->targets);
25722   if (differ) {
25723     different++;
25724     BV_SET(fields, 38);
25725   }
25726 
25727   differ = !BV_ARE_EQUAL(old->embarks, real_packet->embarks);
25728   if (differ) {
25729     different++;
25730     BV_SET(fields, 39);
25731   }
25732 
25733   differ = !BV_ARE_EQUAL(old->disembarks, real_packet->disembarks);
25734   if (differ) {
25735     different++;
25736     BV_SET(fields, 40);
25737   }
25738 
25739   differ = (strcmp(old->helptext, real_packet->helptext) != 0);
25740   if (differ) {
25741     different++;
25742     BV_SET(fields, 41);
25743   }
25744 
25745   differ = !BV_ARE_EQUAL(old->flags, real_packet->flags);
25746   if (differ) {
25747     different++;
25748     BV_SET(fields, 42);
25749   }
25750 
25751   differ = !BV_ARE_EQUAL(old->roles, real_packet->roles);
25752   if (differ) {
25753     different++;
25754     BV_SET(fields, 43);
25755   }
25756 
25757 
25758   DIO_BV_PUT(&dout, "fields", fields);
25759 
25760   if (BV_ISSET(fields, 0)) {
25761     log_packet_detailed("  field 'id' has changed");
25762     DIO_PUT(uint8, &dout, "id", real_packet->id);
25763   }
25764   if (BV_ISSET(fields, 1)) {
25765     log_packet_detailed("  field 'name' has changed");
25766     DIO_PUT(string, &dout, "name", real_packet->name);
25767   }
25768   if (BV_ISSET(fields, 2)) {
25769     log_packet_detailed("  field 'rule_name' has changed");
25770     DIO_PUT(string, &dout, "rule_name", real_packet->rule_name);
25771   }
25772   if (BV_ISSET(fields, 3)) {
25773     log_packet_detailed("  field 'graphic_str' has changed");
25774     DIO_PUT(string, &dout, "graphic_str", real_packet->graphic_str);
25775   }
25776   if (BV_ISSET(fields, 4)) {
25777     log_packet_detailed("  field 'graphic_alt' has changed");
25778     DIO_PUT(string, &dout, "graphic_alt", real_packet->graphic_alt);
25779   }
25780   if (BV_ISSET(fields, 5)) {
25781     log_packet_detailed("  field 'sound_move' has changed");
25782     DIO_PUT(string, &dout, "sound_move", real_packet->sound_move);
25783   }
25784   if (BV_ISSET(fields, 6)) {
25785     log_packet_detailed("  field 'sound_move_alt' has changed");
25786     DIO_PUT(string, &dout, "sound_move_alt", real_packet->sound_move_alt);
25787   }
25788   if (BV_ISSET(fields, 7)) {
25789     log_packet_detailed("  field 'sound_fight' has changed");
25790     DIO_PUT(string, &dout, "sound_fight", real_packet->sound_fight);
25791   }
25792   if (BV_ISSET(fields, 8)) {
25793     log_packet_detailed("  field 'sound_fight_alt' has changed");
25794     DIO_PUT(string, &dout, "sound_fight_alt", real_packet->sound_fight_alt);
25795   }
25796   if (BV_ISSET(fields, 9)) {
25797     log_packet_detailed("  field 'unit_class_id' has changed");
25798     DIO_PUT(uint8, &dout, "unit_class_id", real_packet->unit_class_id);
25799   }
25800   if (BV_ISSET(fields, 10)) {
25801     log_packet_detailed("  field 'build_cost' has changed");
25802     DIO_PUT(uint16, &dout, "build_cost", real_packet->build_cost);
25803   }
25804   if (BV_ISSET(fields, 11)) {
25805     log_packet_detailed("  field 'pop_cost' has changed");
25806     DIO_PUT(uint8, &dout, "pop_cost", real_packet->pop_cost);
25807   }
25808   if (BV_ISSET(fields, 12)) {
25809     log_packet_detailed("  field 'attack_strength' has changed");
25810     DIO_PUT(uint8, &dout, "attack_strength", real_packet->attack_strength);
25811   }
25812   if (BV_ISSET(fields, 13)) {
25813     log_packet_detailed("  field 'defense_strength' has changed");
25814     DIO_PUT(uint8, &dout, "defense_strength", real_packet->defense_strength);
25815   }
25816   if (BV_ISSET(fields, 14)) {
25817     log_packet_detailed("  field 'move_rate' has changed");
25818     DIO_PUT(uint16, &dout, "move_rate", real_packet->move_rate);
25819   }
25820   if (BV_ISSET(fields, 15)) {
25821     log_packet_detailed("  field 'tech_requirement' has changed");
25822     DIO_PUT(uint8, &dout, "tech_requirement", real_packet->tech_requirement);
25823   }
25824   if (BV_ISSET(fields, 16)) {
25825     log_packet_detailed("  field 'impr_requirement' has changed");
25826     DIO_PUT(uint8, &dout, "impr_requirement", real_packet->impr_requirement);
25827   }
25828   if (BV_ISSET(fields, 17)) {
25829     log_packet_detailed("  field 'gov_requirement' has changed");
25830     DIO_PUT(sint8, &dout, "gov_requirement", real_packet->gov_requirement);
25831   }
25832   if (BV_ISSET(fields, 18)) {
25833     log_packet_detailed("  field 'vision_radius_sq' has changed");
25834     DIO_PUT(uint16, &dout, "vision_radius_sq", real_packet->vision_radius_sq);
25835   }
25836   if (BV_ISSET(fields, 19)) {
25837     log_packet_detailed("  field 'transport_capacity' has changed");
25838     DIO_PUT(uint8, &dout, "transport_capacity", real_packet->transport_capacity);
25839   }
25840   if (BV_ISSET(fields, 20)) {
25841     log_packet_detailed("  field 'hp' has changed");
25842     DIO_PUT(uint8, &dout, "hp", real_packet->hp);
25843   }
25844   if (BV_ISSET(fields, 21)) {
25845     log_packet_detailed("  field 'firepower' has changed");
25846     DIO_PUT(uint8, &dout, "firepower", real_packet->firepower);
25847   }
25848   if (BV_ISSET(fields, 22)) {
25849     log_packet_detailed("  field 'obsoleted_by' has changed");
25850     DIO_PUT(uint8, &dout, "obsoleted_by", real_packet->obsoleted_by);
25851   }
25852   if (BV_ISSET(fields, 23)) {
25853     log_packet_detailed("  field 'converted_to' has changed");
25854     DIO_PUT(uint8, &dout, "converted_to", real_packet->converted_to);
25855   }
25856   if (BV_ISSET(fields, 24)) {
25857     log_packet_detailed("  field 'convert_time' has changed");
25858     DIO_PUT(uint8, &dout, "convert_time", real_packet->convert_time);
25859   }
25860   if (BV_ISSET(fields, 25)) {
25861     log_packet_detailed("  field 'fuel' has changed");
25862     DIO_PUT(uint8, &dout, "fuel", real_packet->fuel);
25863   }
25864   if (BV_ISSET(fields, 26)) {
25865     log_packet_detailed("  field 'happy_cost' has changed");
25866     DIO_PUT(uint8, &dout, "happy_cost", real_packet->happy_cost);
25867   }
25868   if (BV_ISSET(fields, 27)) {
25869     log_packet_detailed("  field 'upkeep' has changed");
25870 
25871     {
25872       int i;
25873 
25874       for (i = 0; i < O_LAST; i++) {
25875         dio_put_uint8(&dout, real_packet->upkeep[i]);
25876       }
25877     }
25878   }
25879   if (BV_ISSET(fields, 28)) {
25880     log_packet_detailed("  field 'paratroopers_range' has changed");
25881     DIO_PUT(uint16, &dout, "paratroopers_range", real_packet->paratroopers_range);
25882   }
25883   if (BV_ISSET(fields, 29)) {
25884     log_packet_detailed("  field 'paratroopers_mr_req' has changed");
25885     DIO_PUT(uint8, &dout, "paratroopers_mr_req", real_packet->paratroopers_mr_req);
25886   }
25887   if (BV_ISSET(fields, 30)) {
25888     log_packet_detailed("  field 'paratroopers_mr_sub' has changed");
25889     DIO_PUT(uint8, &dout, "paratroopers_mr_sub", real_packet->paratroopers_mr_sub);
25890   }
25891   if (BV_ISSET(fields, 31)) {
25892     log_packet_detailed("  field 'veteran_levels' has changed");
25893     DIO_PUT(uint8, &dout, "veteran_levels", real_packet->veteran_levels);
25894   }
25895   if (BV_ISSET(fields, 32)) {
25896     log_packet_detailed("  field 'veteran_name' has changed");
25897 
25898     {
25899       int i;
25900 
25901       for (i = 0; i < real_packet->veteran_levels; i++) {
25902         dio_put_string(&dout, real_packet->veteran_name[i]);
25903       }
25904     }
25905   }
25906   if (BV_ISSET(fields, 33)) {
25907     log_packet_detailed("  field 'power_fact' has changed");
25908 
25909     {
25910       int i;
25911 
25912       for (i = 0; i < real_packet->veteran_levels; i++) {
25913         dio_put_uint16(&dout, real_packet->power_fact[i]);
25914       }
25915     }
25916   }
25917   if (BV_ISSET(fields, 34)) {
25918     log_packet_detailed("  field 'move_bonus' has changed");
25919 
25920     {
25921       int i;
25922 
25923       for (i = 0; i < real_packet->veteran_levels; i++) {
25924         dio_put_uint16(&dout, real_packet->move_bonus[i]);
25925       }
25926     }
25927   }
25928   if (BV_ISSET(fields, 35)) {
25929     log_packet_detailed("  field 'bombard_rate' has changed");
25930     DIO_PUT(uint8, &dout, "bombard_rate", real_packet->bombard_rate);
25931   }
25932   if (BV_ISSET(fields, 36)) {
25933     log_packet_detailed("  field 'city_size' has changed");
25934     DIO_PUT(uint8, &dout, "city_size", real_packet->city_size);
25935   }
25936   if (BV_ISSET(fields, 37)) {
25937     log_packet_detailed("  field 'cargo' has changed");
25938   DIO_BV_PUT(&dout, "cargo", packet->cargo);
25939   }
25940   if (BV_ISSET(fields, 38)) {
25941     log_packet_detailed("  field 'targets' has changed");
25942   DIO_BV_PUT(&dout, "targets", packet->targets);
25943   }
25944   if (BV_ISSET(fields, 39)) {
25945     log_packet_detailed("  field 'embarks' has changed");
25946   DIO_BV_PUT(&dout, "embarks", packet->embarks);
25947   }
25948   if (BV_ISSET(fields, 40)) {
25949     log_packet_detailed("  field 'disembarks' has changed");
25950   DIO_BV_PUT(&dout, "disembarks", packet->disembarks);
25951   }
25952   if (BV_ISSET(fields, 41)) {
25953     log_packet_detailed("  field 'helptext' has changed");
25954     DIO_PUT(string, &dout, "helptext", real_packet->helptext);
25955   }
25956   if (BV_ISSET(fields, 42)) {
25957     log_packet_detailed("  field 'flags' has changed");
25958   DIO_BV_PUT(&dout, "flags", packet->flags);
25959   }
25960   if (BV_ISSET(fields, 43)) {
25961     log_packet_detailed("  field 'roles' has changed");
25962   DIO_BV_PUT(&dout, "roles", packet->roles);
25963   }
25964 
25965   *old = *real_packet;
25966   SEND_PACKET_END(PACKET_RULESET_UNIT);
25967 }
25968 
send_packet_ruleset_unit(struct connection * pc,const struct packet_ruleset_unit * packet)25969 int send_packet_ruleset_unit(struct connection *pc, const struct packet_ruleset_unit *packet)
25970 {
25971   if (!pc->used) {
25972     log_error("WARNING: trying to send data to the closed connection %s",
25973               conn_description(pc));
25974     return -1;
25975   }
25976   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_UNIT].packet != NULL, -1,
25977                         "Handler for PACKET_RULESET_UNIT not installed");
25978   return pc->phs.handlers->send[PACKET_RULESET_UNIT].packet(pc, packet);
25979 }
25980 
lsend_packet_ruleset_unit(struct conn_list * dest,const struct packet_ruleset_unit * packet)25981 void lsend_packet_ruleset_unit(struct conn_list *dest, const struct packet_ruleset_unit *packet)
25982 {
25983   conn_list_iterate(dest, pconn) {
25984     send_packet_ruleset_unit(pconn, packet);
25985   } conn_list_iterate_end;
25986 }
25987 
25988 #define hash_packet_ruleset_unit_bonus_100 hash_const
25989 
25990 #define cmp_packet_ruleset_unit_bonus_100 cmp_const
25991 
25992 BV_DEFINE(packet_ruleset_unit_bonus_100_fields, 5);
25993 
receive_packet_ruleset_unit_bonus_100(struct connection * pc)25994 static struct packet_ruleset_unit_bonus *receive_packet_ruleset_unit_bonus_100(struct connection *pc)
25995 {
25996   packet_ruleset_unit_bonus_100_fields fields;
25997   struct packet_ruleset_unit_bonus *old;
25998   struct genhash **hash = pc->phs.received + PACKET_RULESET_UNIT_BONUS;
25999   RECEIVE_PACKET_START(packet_ruleset_unit_bonus, real_packet);
26000 
26001   DIO_BV_GET(&din, fields);
26002 
26003   log_packet_detailed("packet_ruleset_unit_bonus_100: got info about ()");
26004 
26005   if (NULL == *hash) {
26006     *hash = genhash_new_full(hash_packet_ruleset_unit_bonus_100, cmp_packet_ruleset_unit_bonus_100,
26007                              NULL, NULL, NULL, free);
26008   }
26009 
26010   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
26011     *real_packet = *old;
26012   } else {
26013     log_packet_detailed("  no old info");
26014     memset(real_packet, 0, sizeof(*real_packet));
26015   }
26016 
26017   if (BV_ISSET(fields, 0)) {
26018     log_packet_detailed("  got field 'unit'");
26019     {
26020       int readin;
26021 
26022       if (!DIO_GET(uint8, &din, "unit", &readin)) {
26023         RECEIVE_PACKET_FIELD_ERROR(unit);
26024       }
26025       real_packet->unit = readin;
26026     }
26027   }
26028   if (BV_ISSET(fields, 1)) {
26029     log_packet_detailed("  got field 'flag'");
26030     {
26031       int readin;
26032 
26033       if (!DIO_GET(uint8, &din, "flag", &readin)) {
26034         RECEIVE_PACKET_FIELD_ERROR(flag);
26035       }
26036       real_packet->flag = readin;
26037     }
26038   }
26039   if (BV_ISSET(fields, 2)) {
26040     log_packet_detailed("  got field 'type'");
26041     {
26042       int readin;
26043 
26044       if (!DIO_GET(uint8, &din, "type", &readin)) {
26045         RECEIVE_PACKET_FIELD_ERROR(type);
26046       }
26047       real_packet->type = readin;
26048     }
26049   }
26050   if (BV_ISSET(fields, 3)) {
26051     log_packet_detailed("  got field 'value'");
26052     if (!DIO_GET(uint8, &din, "value", &real_packet->value)) {
26053       RECEIVE_PACKET_FIELD_ERROR(value);
26054     }
26055   }
26056   real_packet->quiet = BV_ISSET(fields, 4);
26057 
26058   if (NULL == old) {
26059     old = fc_malloc(sizeof(*old));
26060     *old = *real_packet;
26061     genhash_insert(*hash, old, old);
26062   } else {
26063     *old = *real_packet;
26064   }
26065   RECEIVE_PACKET_END(real_packet);
26066 }
26067 
send_packet_ruleset_unit_bonus_100(struct connection * pc,const struct packet_ruleset_unit_bonus * packet)26068 static int send_packet_ruleset_unit_bonus_100(struct connection *pc, const struct packet_ruleset_unit_bonus *packet)
26069 {
26070   const struct packet_ruleset_unit_bonus *real_packet = packet;
26071   packet_ruleset_unit_bonus_100_fields fields;
26072   struct packet_ruleset_unit_bonus *old;
26073   bool differ;
26074   struct genhash **hash = pc->phs.sent + PACKET_RULESET_UNIT_BONUS;
26075   int different = 0;
26076   SEND_PACKET_START(PACKET_RULESET_UNIT_BONUS);
26077 
26078   log_packet_detailed("packet_ruleset_unit_bonus_100: sending info about ()");
26079 
26080   if (NULL == *hash) {
26081     *hash = genhash_new_full(hash_packet_ruleset_unit_bonus_100, cmp_packet_ruleset_unit_bonus_100,
26082                              NULL, NULL, NULL, free);
26083   }
26084   BV_CLR_ALL(fields);
26085 
26086   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
26087     old = fc_malloc(sizeof(*old));
26088     *old = *real_packet;
26089     genhash_insert(*hash, old, old);
26090     memset(old, 0, sizeof(*old));
26091     different = 1;      /* Force to send. */
26092   }
26093 
26094   differ = (old->unit != real_packet->unit);
26095   if (differ) {
26096     different++;
26097     BV_SET(fields, 0);
26098   }
26099 
26100   differ = (old->flag != real_packet->flag);
26101   if (differ) {
26102     different++;
26103     BV_SET(fields, 1);
26104   }
26105 
26106   differ = (old->type != real_packet->type);
26107   if (differ) {
26108     different++;
26109     BV_SET(fields, 2);
26110   }
26111 
26112   differ = (old->value != real_packet->value);
26113   if (differ) {
26114     different++;
26115     BV_SET(fields, 3);
26116   }
26117 
26118   differ = (old->quiet != real_packet->quiet);
26119   if (differ) {
26120     different++;
26121   }
26122   if (packet->quiet) {
26123     BV_SET(fields, 4);
26124   }
26125 
26126 
26127   DIO_BV_PUT(&dout, "fields", fields);
26128 
26129   if (BV_ISSET(fields, 0)) {
26130     log_packet_detailed("  field 'unit' has changed");
26131     DIO_PUT(uint8, &dout, "unit", real_packet->unit);
26132   }
26133   if (BV_ISSET(fields, 1)) {
26134     log_packet_detailed("  field 'flag' has changed");
26135     DIO_PUT(uint8, &dout, "flag", real_packet->flag);
26136   }
26137   if (BV_ISSET(fields, 2)) {
26138     log_packet_detailed("  field 'type' has changed");
26139     DIO_PUT(uint8, &dout, "type", real_packet->type);
26140   }
26141   if (BV_ISSET(fields, 3)) {
26142     log_packet_detailed("  field 'value' has changed");
26143     DIO_PUT(uint8, &dout, "value", real_packet->value);
26144   }
26145   /* field 4 is folded into the header */
26146 
26147   *old = *real_packet;
26148   SEND_PACKET_END(PACKET_RULESET_UNIT_BONUS);
26149 }
26150 
send_packet_ruleset_unit_bonus(struct connection * pc,const struct packet_ruleset_unit_bonus * packet)26151 int send_packet_ruleset_unit_bonus(struct connection *pc, const struct packet_ruleset_unit_bonus *packet)
26152 {
26153   if (!pc->used) {
26154     log_error("WARNING: trying to send data to the closed connection %s",
26155               conn_description(pc));
26156     return -1;
26157   }
26158   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_UNIT_BONUS].packet != NULL, -1,
26159                         "Handler for PACKET_RULESET_UNIT_BONUS not installed");
26160   return pc->phs.handlers->send[PACKET_RULESET_UNIT_BONUS].packet(pc, packet);
26161 }
26162 
lsend_packet_ruleset_unit_bonus(struct conn_list * dest,const struct packet_ruleset_unit_bonus * packet)26163 void lsend_packet_ruleset_unit_bonus(struct conn_list *dest, const struct packet_ruleset_unit_bonus *packet)
26164 {
26165   conn_list_iterate(dest, pconn) {
26166     send_packet_ruleset_unit_bonus(pconn, packet);
26167   } conn_list_iterate_end;
26168 }
26169 
26170 #define hash_packet_ruleset_unit_flag_100 hash_const
26171 
26172 #define cmp_packet_ruleset_unit_flag_100 cmp_const
26173 
26174 BV_DEFINE(packet_ruleset_unit_flag_100_fields, 3);
26175 
receive_packet_ruleset_unit_flag_100(struct connection * pc)26176 static struct packet_ruleset_unit_flag *receive_packet_ruleset_unit_flag_100(struct connection *pc)
26177 {
26178   packet_ruleset_unit_flag_100_fields fields;
26179   struct packet_ruleset_unit_flag *old;
26180   struct genhash **hash = pc->phs.received + PACKET_RULESET_UNIT_FLAG;
26181   RECEIVE_PACKET_START(packet_ruleset_unit_flag, real_packet);
26182 
26183   DIO_BV_GET(&din, fields);
26184 
26185   log_packet_detailed("packet_ruleset_unit_flag_100: got info about ()");
26186 
26187   if (NULL == *hash) {
26188     *hash = genhash_new_full(hash_packet_ruleset_unit_flag_100, cmp_packet_ruleset_unit_flag_100,
26189                              NULL, NULL, NULL, free);
26190   }
26191 
26192   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
26193     *real_packet = *old;
26194   } else {
26195     log_packet_detailed("  no old info");
26196     memset(real_packet, 0, sizeof(*real_packet));
26197   }
26198 
26199   if (BV_ISSET(fields, 0)) {
26200     log_packet_detailed("  got field 'id'");
26201     if (!DIO_GET(uint8, &din, "id", &real_packet->id)) {
26202       RECEIVE_PACKET_FIELD_ERROR(id);
26203     }
26204   }
26205   if (BV_ISSET(fields, 1)) {
26206     log_packet_detailed("  got field 'name'");
26207     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
26208       RECEIVE_PACKET_FIELD_ERROR(name);
26209     }
26210   }
26211   if (BV_ISSET(fields, 2)) {
26212     log_packet_detailed("  got field 'helptxt'");
26213     if (!DIO_GET(string, &din, "helptxt", real_packet->helptxt, sizeof(real_packet->helptxt))) {
26214       RECEIVE_PACKET_FIELD_ERROR(helptxt);
26215     }
26216   }
26217 
26218   if (NULL == old) {
26219     old = fc_malloc(sizeof(*old));
26220     *old = *real_packet;
26221     genhash_insert(*hash, old, old);
26222   } else {
26223     *old = *real_packet;
26224   }
26225   RECEIVE_PACKET_END(real_packet);
26226 }
26227 
send_packet_ruleset_unit_flag_100(struct connection * pc,const struct packet_ruleset_unit_flag * packet)26228 static int send_packet_ruleset_unit_flag_100(struct connection *pc, const struct packet_ruleset_unit_flag *packet)
26229 {
26230   const struct packet_ruleset_unit_flag *real_packet = packet;
26231   packet_ruleset_unit_flag_100_fields fields;
26232   struct packet_ruleset_unit_flag *old;
26233   bool differ;
26234   struct genhash **hash = pc->phs.sent + PACKET_RULESET_UNIT_FLAG;
26235   int different = 0;
26236   SEND_PACKET_START(PACKET_RULESET_UNIT_FLAG);
26237 
26238   log_packet_detailed("packet_ruleset_unit_flag_100: sending info about ()");
26239 
26240   if (NULL == *hash) {
26241     *hash = genhash_new_full(hash_packet_ruleset_unit_flag_100, cmp_packet_ruleset_unit_flag_100,
26242                              NULL, NULL, NULL, free);
26243   }
26244   BV_CLR_ALL(fields);
26245 
26246   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
26247     old = fc_malloc(sizeof(*old));
26248     *old = *real_packet;
26249     genhash_insert(*hash, old, old);
26250     memset(old, 0, sizeof(*old));
26251     different = 1;      /* Force to send. */
26252   }
26253 
26254   differ = (old->id != real_packet->id);
26255   if (differ) {
26256     different++;
26257     BV_SET(fields, 0);
26258   }
26259 
26260   differ = (strcmp(old->name, real_packet->name) != 0);
26261   if (differ) {
26262     different++;
26263     BV_SET(fields, 1);
26264   }
26265 
26266   differ = (strcmp(old->helptxt, real_packet->helptxt) != 0);
26267   if (differ) {
26268     different++;
26269     BV_SET(fields, 2);
26270   }
26271 
26272 
26273   DIO_BV_PUT(&dout, "fields", fields);
26274 
26275   if (BV_ISSET(fields, 0)) {
26276     log_packet_detailed("  field 'id' has changed");
26277     DIO_PUT(uint8, &dout, "id", real_packet->id);
26278   }
26279   if (BV_ISSET(fields, 1)) {
26280     log_packet_detailed("  field 'name' has changed");
26281     DIO_PUT(string, &dout, "name", real_packet->name);
26282   }
26283   if (BV_ISSET(fields, 2)) {
26284     log_packet_detailed("  field 'helptxt' has changed");
26285     DIO_PUT(string, &dout, "helptxt", real_packet->helptxt);
26286   }
26287 
26288   *old = *real_packet;
26289   SEND_PACKET_END(PACKET_RULESET_UNIT_FLAG);
26290 }
26291 
send_packet_ruleset_unit_flag(struct connection * pc,const struct packet_ruleset_unit_flag * packet)26292 int send_packet_ruleset_unit_flag(struct connection *pc, const struct packet_ruleset_unit_flag *packet)
26293 {
26294   if (!pc->used) {
26295     log_error("WARNING: trying to send data to the closed connection %s",
26296               conn_description(pc));
26297     return -1;
26298   }
26299   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_UNIT_FLAG].packet != NULL, -1,
26300                         "Handler for PACKET_RULESET_UNIT_FLAG not installed");
26301   return pc->phs.handlers->send[PACKET_RULESET_UNIT_FLAG].packet(pc, packet);
26302 }
26303 
lsend_packet_ruleset_unit_flag(struct conn_list * dest,const struct packet_ruleset_unit_flag * packet)26304 void lsend_packet_ruleset_unit_flag(struct conn_list *dest, const struct packet_ruleset_unit_flag *packet)
26305 {
26306   conn_list_iterate(dest, pconn) {
26307     send_packet_ruleset_unit_flag(pconn, packet);
26308   } conn_list_iterate_end;
26309 }
26310 
26311 #define hash_packet_ruleset_game_100 hash_const
26312 
26313 #define cmp_packet_ruleset_game_100 cmp_const
26314 
26315 BV_DEFINE(packet_ruleset_game_100_fields, 10);
26316 
receive_packet_ruleset_game_100(struct connection * pc)26317 static struct packet_ruleset_game *receive_packet_ruleset_game_100(struct connection *pc)
26318 {
26319   packet_ruleset_game_100_fields fields;
26320   struct packet_ruleset_game *old;
26321   struct genhash **hash = pc->phs.received + PACKET_RULESET_GAME;
26322   RECEIVE_PACKET_START(packet_ruleset_game, real_packet);
26323 
26324   DIO_BV_GET(&din, fields);
26325 
26326   log_packet_detailed("packet_ruleset_game_100: got info about ()");
26327 
26328   if (NULL == *hash) {
26329     *hash = genhash_new_full(hash_packet_ruleset_game_100, cmp_packet_ruleset_game_100,
26330                              NULL, NULL, NULL, free);
26331   }
26332 
26333   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
26334     *real_packet = *old;
26335   } else {
26336     log_packet_detailed("  no old info");
26337     memset(real_packet, 0, sizeof(*real_packet));
26338   }
26339 
26340   if (BV_ISSET(fields, 0)) {
26341     log_packet_detailed("  got field 'default_specialist'");
26342     if (!DIO_GET(uint8, &din, "default_specialist", &real_packet->default_specialist)) {
26343       RECEIVE_PACKET_FIELD_ERROR(default_specialist);
26344     }
26345   }
26346   if (BV_ISSET(fields, 1)) {
26347     log_packet_detailed("  got field 'global_init_techs'");
26348     if (!DIO_GET(tech_list, &din, "global_init_techs", real_packet->global_init_techs)) {
26349       RECEIVE_PACKET_FIELD_ERROR(global_init_techs);
26350     }
26351   }
26352   if (BV_ISSET(fields, 2)) {
26353     log_packet_detailed("  got field 'global_init_buildings'");
26354     if (!DIO_GET(building_list, &din, "global_init_buildings", real_packet->global_init_buildings)) {
26355       RECEIVE_PACKET_FIELD_ERROR(global_init_buildings);
26356     }
26357   }
26358   if (BV_ISSET(fields, 3)) {
26359     log_packet_detailed("  got field 'veteran_levels'");
26360     if (!DIO_GET(uint8, &din, "veteran_levels", &real_packet->veteran_levels)) {
26361       RECEIVE_PACKET_FIELD_ERROR(veteran_levels);
26362     }
26363   }
26364   if (BV_ISSET(fields, 4)) {
26365     log_packet_detailed("  got field 'veteran_name'");
26366 
26367     {
26368       int i;
26369 
26370       if (real_packet->veteran_levels > MAX_VET_LEVELS) {
26371         RECEIVE_PACKET_FIELD_ERROR(veteran_name, ": truncation array");
26372       }
26373       for (i = 0; i < real_packet->veteran_levels; i++) {
26374         if (!DIO_GET(string, &din, "veteran_name", real_packet->veteran_name[i], sizeof(real_packet->veteran_name[i]))) {
26375           RECEIVE_PACKET_FIELD_ERROR(veteran_name);
26376         }
26377       }
26378     }
26379   }
26380   if (BV_ISSET(fields, 5)) {
26381     log_packet_detailed("  got field 'power_fact'");
26382 
26383     {
26384       int i;
26385 
26386       if (real_packet->veteran_levels > MAX_VET_LEVELS) {
26387         RECEIVE_PACKET_FIELD_ERROR(power_fact, ": truncation array");
26388       }
26389       for (i = 0; i < real_packet->veteran_levels; i++) {
26390         if (!DIO_GET(uint16, &din, "power_fact", &real_packet->power_fact[i])) {
26391           RECEIVE_PACKET_FIELD_ERROR(power_fact);
26392         }
26393       }
26394     }
26395   }
26396   if (BV_ISSET(fields, 6)) {
26397     log_packet_detailed("  got field 'move_bonus'");
26398 
26399     {
26400       int i;
26401 
26402       if (real_packet->veteran_levels > MAX_VET_LEVELS) {
26403         RECEIVE_PACKET_FIELD_ERROR(move_bonus, ": truncation array");
26404       }
26405       for (i = 0; i < real_packet->veteran_levels; i++) {
26406         if (!DIO_GET(uint16, &din, "move_bonus", &real_packet->move_bonus[i])) {
26407           RECEIVE_PACKET_FIELD_ERROR(move_bonus);
26408         }
26409       }
26410     }
26411   }
26412   if (BV_ISSET(fields, 7)) {
26413     log_packet_detailed("  got field 'background_red'");
26414     if (!DIO_GET(uint8, &din, "background_red", &real_packet->background_red)) {
26415       RECEIVE_PACKET_FIELD_ERROR(background_red);
26416     }
26417   }
26418   if (BV_ISSET(fields, 8)) {
26419     log_packet_detailed("  got field 'background_green'");
26420     if (!DIO_GET(uint8, &din, "background_green", &real_packet->background_green)) {
26421       RECEIVE_PACKET_FIELD_ERROR(background_green);
26422     }
26423   }
26424   if (BV_ISSET(fields, 9)) {
26425     log_packet_detailed("  got field 'background_blue'");
26426     if (!DIO_GET(uint8, &din, "background_blue", &real_packet->background_blue)) {
26427       RECEIVE_PACKET_FIELD_ERROR(background_blue);
26428     }
26429   }
26430 
26431   if (NULL == old) {
26432     old = fc_malloc(sizeof(*old));
26433     *old = *real_packet;
26434     genhash_insert(*hash, old, old);
26435   } else {
26436     *old = *real_packet;
26437   }
26438   RECEIVE_PACKET_END(real_packet);
26439 }
26440 
send_packet_ruleset_game_100(struct connection * pc,const struct packet_ruleset_game * packet)26441 static int send_packet_ruleset_game_100(struct connection *pc, const struct packet_ruleset_game *packet)
26442 {
26443   const struct packet_ruleset_game *real_packet = packet;
26444   packet_ruleset_game_100_fields fields;
26445   struct packet_ruleset_game *old;
26446   bool differ;
26447   struct genhash **hash = pc->phs.sent + PACKET_RULESET_GAME;
26448   int different = 0;
26449   SEND_PACKET_START(PACKET_RULESET_GAME);
26450 
26451   log_packet_detailed("packet_ruleset_game_100: sending info about ()");
26452 
26453   if (NULL == *hash) {
26454     *hash = genhash_new_full(hash_packet_ruleset_game_100, cmp_packet_ruleset_game_100,
26455                              NULL, NULL, NULL, free);
26456   }
26457   BV_CLR_ALL(fields);
26458 
26459   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
26460     old = fc_malloc(sizeof(*old));
26461     *old = *real_packet;
26462     genhash_insert(*hash, old, old);
26463     memset(old, 0, sizeof(*old));
26464     different = 1;      /* Force to send. */
26465   }
26466 
26467   differ = (old->default_specialist != real_packet->default_specialist);
26468   if (differ) {
26469     different++;
26470     BV_SET(fields, 0);
26471   }
26472 
26473 
26474     {
26475       differ = (MAX_NUM_TECH_LIST != MAX_NUM_TECH_LIST);
26476       if (!differ) {
26477         int i;
26478 
26479         for (i = 0; i < MAX_NUM_TECH_LIST; i++) {
26480           if (old->global_init_techs[i] != real_packet->global_init_techs[i]) {
26481             differ = TRUE;
26482             break;
26483           }
26484         }
26485       }
26486     }
26487   if (differ) {
26488     different++;
26489     BV_SET(fields, 1);
26490   }
26491 
26492 
26493     {
26494       differ = (MAX_NUM_BUILDING_LIST != MAX_NUM_BUILDING_LIST);
26495       if (!differ) {
26496         int i;
26497 
26498         for (i = 0; i < MAX_NUM_BUILDING_LIST; i++) {
26499           if (old->global_init_buildings[i] != real_packet->global_init_buildings[i]) {
26500             differ = TRUE;
26501             break;
26502           }
26503         }
26504       }
26505     }
26506   if (differ) {
26507     different++;
26508     BV_SET(fields, 2);
26509   }
26510 
26511   differ = (old->veteran_levels != real_packet->veteran_levels);
26512   if (differ) {
26513     different++;
26514     BV_SET(fields, 3);
26515   }
26516 
26517 
26518     {
26519       differ = (old->veteran_levels != real_packet->veteran_levels);
26520       if (!differ) {
26521         int i;
26522 
26523         for (i = 0; i < real_packet->veteran_levels; i++) {
26524           if (strcmp(old->veteran_name[i], real_packet->veteran_name[i]) != 0) {
26525             differ = TRUE;
26526             break;
26527           }
26528         }
26529       }
26530     }
26531   if (differ) {
26532     different++;
26533     BV_SET(fields, 4);
26534   }
26535 
26536 
26537     {
26538       differ = (old->veteran_levels != real_packet->veteran_levels);
26539       if (!differ) {
26540         int i;
26541 
26542         for (i = 0; i < real_packet->veteran_levels; i++) {
26543           if (old->power_fact[i] != real_packet->power_fact[i]) {
26544             differ = TRUE;
26545             break;
26546           }
26547         }
26548       }
26549     }
26550   if (differ) {
26551     different++;
26552     BV_SET(fields, 5);
26553   }
26554 
26555 
26556     {
26557       differ = (old->veteran_levels != real_packet->veteran_levels);
26558       if (!differ) {
26559         int i;
26560 
26561         for (i = 0; i < real_packet->veteran_levels; i++) {
26562           if (old->move_bonus[i] != real_packet->move_bonus[i]) {
26563             differ = TRUE;
26564             break;
26565           }
26566         }
26567       }
26568     }
26569   if (differ) {
26570     different++;
26571     BV_SET(fields, 6);
26572   }
26573 
26574   differ = (old->background_red != real_packet->background_red);
26575   if (differ) {
26576     different++;
26577     BV_SET(fields, 7);
26578   }
26579 
26580   differ = (old->background_green != real_packet->background_green);
26581   if (differ) {
26582     different++;
26583     BV_SET(fields, 8);
26584   }
26585 
26586   differ = (old->background_blue != real_packet->background_blue);
26587   if (differ) {
26588     different++;
26589     BV_SET(fields, 9);
26590   }
26591 
26592 
26593   DIO_BV_PUT(&dout, "fields", fields);
26594 
26595   if (BV_ISSET(fields, 0)) {
26596     log_packet_detailed("  field 'default_specialist' has changed");
26597     DIO_PUT(uint8, &dout, "default_specialist", real_packet->default_specialist);
26598   }
26599   if (BV_ISSET(fields, 1)) {
26600     log_packet_detailed("  field 'global_init_techs' has changed");
26601     DIO_PUT(tech_list, &dout, "global_init_techs", real_packet->global_init_techs);
26602   }
26603   if (BV_ISSET(fields, 2)) {
26604     log_packet_detailed("  field 'global_init_buildings' has changed");
26605     DIO_PUT(building_list, &dout, "global_init_buildings", real_packet->global_init_buildings);
26606   }
26607   if (BV_ISSET(fields, 3)) {
26608     log_packet_detailed("  field 'veteran_levels' has changed");
26609     DIO_PUT(uint8, &dout, "veteran_levels", real_packet->veteran_levels);
26610   }
26611   if (BV_ISSET(fields, 4)) {
26612     log_packet_detailed("  field 'veteran_name' has changed");
26613 
26614     {
26615       int i;
26616 
26617       for (i = 0; i < real_packet->veteran_levels; i++) {
26618         dio_put_string(&dout, real_packet->veteran_name[i]);
26619       }
26620     }
26621   }
26622   if (BV_ISSET(fields, 5)) {
26623     log_packet_detailed("  field 'power_fact' has changed");
26624 
26625     {
26626       int i;
26627 
26628       for (i = 0; i < real_packet->veteran_levels; i++) {
26629         dio_put_uint16(&dout, real_packet->power_fact[i]);
26630       }
26631     }
26632   }
26633   if (BV_ISSET(fields, 6)) {
26634     log_packet_detailed("  field 'move_bonus' has changed");
26635 
26636     {
26637       int i;
26638 
26639       for (i = 0; i < real_packet->veteran_levels; i++) {
26640         dio_put_uint16(&dout, real_packet->move_bonus[i]);
26641       }
26642     }
26643   }
26644   if (BV_ISSET(fields, 7)) {
26645     log_packet_detailed("  field 'background_red' has changed");
26646     DIO_PUT(uint8, &dout, "background_red", real_packet->background_red);
26647   }
26648   if (BV_ISSET(fields, 8)) {
26649     log_packet_detailed("  field 'background_green' has changed");
26650     DIO_PUT(uint8, &dout, "background_green", real_packet->background_green);
26651   }
26652   if (BV_ISSET(fields, 9)) {
26653     log_packet_detailed("  field 'background_blue' has changed");
26654     DIO_PUT(uint8, &dout, "background_blue", real_packet->background_blue);
26655   }
26656 
26657   *old = *real_packet;
26658   SEND_PACKET_END(PACKET_RULESET_GAME);
26659 }
26660 
send_packet_ruleset_game(struct connection * pc,const struct packet_ruleset_game * packet)26661 int send_packet_ruleset_game(struct connection *pc, const struct packet_ruleset_game *packet)
26662 {
26663   if (!pc->used) {
26664     log_error("WARNING: trying to send data to the closed connection %s",
26665               conn_description(pc));
26666     return -1;
26667   }
26668   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_GAME].packet != NULL, -1,
26669                         "Handler for PACKET_RULESET_GAME not installed");
26670   return pc->phs.handlers->send[PACKET_RULESET_GAME].packet(pc, packet);
26671 }
26672 
lsend_packet_ruleset_game(struct conn_list * dest,const struct packet_ruleset_game * packet)26673 void lsend_packet_ruleset_game(struct conn_list *dest, const struct packet_ruleset_game *packet)
26674 {
26675   conn_list_iterate(dest, pconn) {
26676     send_packet_ruleset_game(pconn, packet);
26677   } conn_list_iterate_end;
26678 }
26679 
26680 #define hash_packet_ruleset_specialist_100 hash_const
26681 
26682 #define cmp_packet_ruleset_specialist_100 cmp_const
26683 
26684 BV_DEFINE(packet_ruleset_specialist_100_fields, 8);
26685 
receive_packet_ruleset_specialist_100(struct connection * pc)26686 static struct packet_ruleset_specialist *receive_packet_ruleset_specialist_100(struct connection *pc)
26687 {
26688   packet_ruleset_specialist_100_fields fields;
26689   struct packet_ruleset_specialist *old;
26690   struct genhash **hash = pc->phs.received + PACKET_RULESET_SPECIALIST;
26691   RECEIVE_PACKET_START(packet_ruleset_specialist, real_packet);
26692 
26693   DIO_BV_GET(&din, fields);
26694 
26695   log_packet_detailed("packet_ruleset_specialist_100: got info about ()");
26696 
26697   if (NULL == *hash) {
26698     *hash = genhash_new_full(hash_packet_ruleset_specialist_100, cmp_packet_ruleset_specialist_100,
26699                              NULL, NULL, NULL, free);
26700   }
26701 
26702   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
26703     *real_packet = *old;
26704   } else {
26705     log_packet_detailed("  no old info");
26706     memset(real_packet, 0, sizeof(*real_packet));
26707   }
26708 
26709   if (BV_ISSET(fields, 0)) {
26710     log_packet_detailed("  got field 'id'");
26711     {
26712       int readin;
26713 
26714       if (!DIO_GET(uint8, &din, "id", &readin)) {
26715         RECEIVE_PACKET_FIELD_ERROR(id);
26716       }
26717       real_packet->id = readin;
26718     }
26719   }
26720   if (BV_ISSET(fields, 1)) {
26721     log_packet_detailed("  got field 'plural_name'");
26722     if (!DIO_GET(string, &din, "plural_name", real_packet->plural_name, sizeof(real_packet->plural_name))) {
26723       RECEIVE_PACKET_FIELD_ERROR(plural_name);
26724     }
26725   }
26726   if (BV_ISSET(fields, 2)) {
26727     log_packet_detailed("  got field 'rule_name'");
26728     if (!DIO_GET(string, &din, "rule_name", real_packet->rule_name, sizeof(real_packet->rule_name))) {
26729       RECEIVE_PACKET_FIELD_ERROR(rule_name);
26730     }
26731   }
26732   if (BV_ISSET(fields, 3)) {
26733     log_packet_detailed("  got field 'short_name'");
26734     if (!DIO_GET(string, &din, "short_name", real_packet->short_name, sizeof(real_packet->short_name))) {
26735       RECEIVE_PACKET_FIELD_ERROR(short_name);
26736     }
26737   }
26738   if (BV_ISSET(fields, 4)) {
26739     log_packet_detailed("  got field 'graphic_alt'");
26740     if (!DIO_GET(string, &din, "graphic_alt", real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
26741       RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
26742     }
26743   }
26744   if (BV_ISSET(fields, 5)) {
26745     log_packet_detailed("  got field 'reqs_count'");
26746     if (!DIO_GET(uint8, &din, "reqs_count", &real_packet->reqs_count)) {
26747       RECEIVE_PACKET_FIELD_ERROR(reqs_count);
26748     }
26749   }
26750   if (BV_ISSET(fields, 6)) {
26751     log_packet_detailed("  got field 'reqs'");
26752 
26753     {
26754       int i;
26755 
26756       if (real_packet->reqs_count > MAX_NUM_REQS) {
26757         RECEIVE_PACKET_FIELD_ERROR(reqs, ": truncation array");
26758       }
26759       for (i = 0; i < real_packet->reqs_count; i++) {
26760         if (!DIO_GET(requirement, &din, "reqs", &real_packet->reqs[i])) {
26761           RECEIVE_PACKET_FIELD_ERROR(reqs);
26762         }
26763       }
26764     }
26765   }
26766   if (BV_ISSET(fields, 7)) {
26767     log_packet_detailed("  got field 'helptext'");
26768     if (!DIO_GET(string, &din, "helptext", real_packet->helptext, sizeof(real_packet->helptext))) {
26769       RECEIVE_PACKET_FIELD_ERROR(helptext);
26770     }
26771   }
26772 
26773   if (NULL == old) {
26774     old = fc_malloc(sizeof(*old));
26775     *old = *real_packet;
26776     genhash_insert(*hash, old, old);
26777   } else {
26778     *old = *real_packet;
26779   }
26780   RECEIVE_PACKET_END(real_packet);
26781 }
26782 
send_packet_ruleset_specialist_100(struct connection * pc,const struct packet_ruleset_specialist * packet)26783 static int send_packet_ruleset_specialist_100(struct connection *pc, const struct packet_ruleset_specialist *packet)
26784 {
26785   const struct packet_ruleset_specialist *real_packet = packet;
26786   packet_ruleset_specialist_100_fields fields;
26787   struct packet_ruleset_specialist *old;
26788   bool differ;
26789   struct genhash **hash = pc->phs.sent + PACKET_RULESET_SPECIALIST;
26790   int different = 0;
26791   SEND_PACKET_START(PACKET_RULESET_SPECIALIST);
26792 
26793   log_packet_detailed("packet_ruleset_specialist_100: sending info about ()");
26794 
26795   if (NULL == *hash) {
26796     *hash = genhash_new_full(hash_packet_ruleset_specialist_100, cmp_packet_ruleset_specialist_100,
26797                              NULL, NULL, NULL, free);
26798   }
26799   BV_CLR_ALL(fields);
26800 
26801   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
26802     old = fc_malloc(sizeof(*old));
26803     *old = *real_packet;
26804     genhash_insert(*hash, old, old);
26805     memset(old, 0, sizeof(*old));
26806     different = 1;      /* Force to send. */
26807   }
26808 
26809   differ = (old->id != real_packet->id);
26810   if (differ) {
26811     different++;
26812     BV_SET(fields, 0);
26813   }
26814 
26815   differ = (strcmp(old->plural_name, real_packet->plural_name) != 0);
26816   if (differ) {
26817     different++;
26818     BV_SET(fields, 1);
26819   }
26820 
26821   differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
26822   if (differ) {
26823     different++;
26824     BV_SET(fields, 2);
26825   }
26826 
26827   differ = (strcmp(old->short_name, real_packet->short_name) != 0);
26828   if (differ) {
26829     different++;
26830     BV_SET(fields, 3);
26831   }
26832 
26833   differ = (strcmp(old->graphic_alt, real_packet->graphic_alt) != 0);
26834   if (differ) {
26835     different++;
26836     BV_SET(fields, 4);
26837   }
26838 
26839   differ = (old->reqs_count != real_packet->reqs_count);
26840   if (differ) {
26841     different++;
26842     BV_SET(fields, 5);
26843   }
26844 
26845 
26846     {
26847       differ = (old->reqs_count != real_packet->reqs_count);
26848       if (!differ) {
26849         int i;
26850 
26851         for (i = 0; i < real_packet->reqs_count; i++) {
26852           if (!are_requirements_equal(&old->reqs[i], &real_packet->reqs[i])) {
26853             differ = TRUE;
26854             break;
26855           }
26856         }
26857       }
26858     }
26859   if (differ) {
26860     different++;
26861     BV_SET(fields, 6);
26862   }
26863 
26864   differ = (strcmp(old->helptext, real_packet->helptext) != 0);
26865   if (differ) {
26866     different++;
26867     BV_SET(fields, 7);
26868   }
26869 
26870 
26871   DIO_BV_PUT(&dout, "fields", fields);
26872 
26873   if (BV_ISSET(fields, 0)) {
26874     log_packet_detailed("  field 'id' has changed");
26875     DIO_PUT(uint8, &dout, "id", real_packet->id);
26876   }
26877   if (BV_ISSET(fields, 1)) {
26878     log_packet_detailed("  field 'plural_name' has changed");
26879     DIO_PUT(string, &dout, "plural_name", real_packet->plural_name);
26880   }
26881   if (BV_ISSET(fields, 2)) {
26882     log_packet_detailed("  field 'rule_name' has changed");
26883     DIO_PUT(string, &dout, "rule_name", real_packet->rule_name);
26884   }
26885   if (BV_ISSET(fields, 3)) {
26886     log_packet_detailed("  field 'short_name' has changed");
26887     DIO_PUT(string, &dout, "short_name", real_packet->short_name);
26888   }
26889   if (BV_ISSET(fields, 4)) {
26890     log_packet_detailed("  field 'graphic_alt' has changed");
26891     DIO_PUT(string, &dout, "graphic_alt", real_packet->graphic_alt);
26892   }
26893   if (BV_ISSET(fields, 5)) {
26894     log_packet_detailed("  field 'reqs_count' has changed");
26895     DIO_PUT(uint8, &dout, "reqs_count", real_packet->reqs_count);
26896   }
26897   if (BV_ISSET(fields, 6)) {
26898     log_packet_detailed("  field 'reqs' has changed");
26899 
26900     {
26901       int i;
26902 
26903       for (i = 0; i < real_packet->reqs_count; i++) {
26904         dio_put_requirement(&dout, &real_packet->reqs[i]);
26905       }
26906     }
26907   }
26908   if (BV_ISSET(fields, 7)) {
26909     log_packet_detailed("  field 'helptext' has changed");
26910     DIO_PUT(string, &dout, "helptext", real_packet->helptext);
26911   }
26912 
26913   *old = *real_packet;
26914   SEND_PACKET_END(PACKET_RULESET_SPECIALIST);
26915 }
26916 
send_packet_ruleset_specialist(struct connection * pc,const struct packet_ruleset_specialist * packet)26917 int send_packet_ruleset_specialist(struct connection *pc, const struct packet_ruleset_specialist *packet)
26918 {
26919   if (!pc->used) {
26920     log_error("WARNING: trying to send data to the closed connection %s",
26921               conn_description(pc));
26922     return -1;
26923   }
26924   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_SPECIALIST].packet != NULL, -1,
26925                         "Handler for PACKET_RULESET_SPECIALIST not installed");
26926   return pc->phs.handlers->send[PACKET_RULESET_SPECIALIST].packet(pc, packet);
26927 }
26928 
lsend_packet_ruleset_specialist(struct conn_list * dest,const struct packet_ruleset_specialist * packet)26929 void lsend_packet_ruleset_specialist(struct conn_list *dest, const struct packet_ruleset_specialist *packet)
26930 {
26931   conn_list_iterate(dest, pconn) {
26932     send_packet_ruleset_specialist(pconn, packet);
26933   } conn_list_iterate_end;
26934 }
26935 
26936 #define hash_packet_ruleset_government_ruler_title_100 hash_const
26937 
26938 #define cmp_packet_ruleset_government_ruler_title_100 cmp_const
26939 
26940 BV_DEFINE(packet_ruleset_government_ruler_title_100_fields, 4);
26941 
receive_packet_ruleset_government_ruler_title_100(struct connection * pc)26942 static struct packet_ruleset_government_ruler_title *receive_packet_ruleset_government_ruler_title_100(struct connection *pc)
26943 {
26944   packet_ruleset_government_ruler_title_100_fields fields;
26945   struct packet_ruleset_government_ruler_title *old;
26946   struct genhash **hash = pc->phs.received + PACKET_RULESET_GOVERNMENT_RULER_TITLE;
26947   RECEIVE_PACKET_START(packet_ruleset_government_ruler_title, real_packet);
26948 
26949   DIO_BV_GET(&din, fields);
26950 
26951   log_packet_detailed("packet_ruleset_government_ruler_title_100: got info about ()");
26952 
26953   if (NULL == *hash) {
26954     *hash = genhash_new_full(hash_packet_ruleset_government_ruler_title_100, cmp_packet_ruleset_government_ruler_title_100,
26955                              NULL, NULL, NULL, free);
26956   }
26957 
26958   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
26959     *real_packet = *old;
26960   } else {
26961     log_packet_detailed("  no old info");
26962     memset(real_packet, 0, sizeof(*real_packet));
26963   }
26964 
26965   if (BV_ISSET(fields, 0)) {
26966     log_packet_detailed("  got field 'gov'");
26967     {
26968       int readin;
26969 
26970       if (!DIO_GET(sint8, &din, "gov", &readin)) {
26971         RECEIVE_PACKET_FIELD_ERROR(gov);
26972       }
26973       real_packet->gov = readin;
26974     }
26975   }
26976   if (BV_ISSET(fields, 1)) {
26977     log_packet_detailed("  got field 'nation'");
26978     {
26979       int readin;
26980 
26981       if (!DIO_GET(sint16, &din, "nation", &readin)) {
26982         RECEIVE_PACKET_FIELD_ERROR(nation);
26983       }
26984       real_packet->nation = readin;
26985     }
26986   }
26987   if (BV_ISSET(fields, 2)) {
26988     log_packet_detailed("  got field 'male_title'");
26989     if (!DIO_GET(string, &din, "male_title", real_packet->male_title, sizeof(real_packet->male_title))) {
26990       RECEIVE_PACKET_FIELD_ERROR(male_title);
26991     }
26992   }
26993   if (BV_ISSET(fields, 3)) {
26994     log_packet_detailed("  got field 'female_title'");
26995     if (!DIO_GET(string, &din, "female_title", real_packet->female_title, sizeof(real_packet->female_title))) {
26996       RECEIVE_PACKET_FIELD_ERROR(female_title);
26997     }
26998   }
26999 
27000   if (NULL == old) {
27001     old = fc_malloc(sizeof(*old));
27002     *old = *real_packet;
27003     genhash_insert(*hash, old, old);
27004   } else {
27005     *old = *real_packet;
27006   }
27007   RECEIVE_PACKET_END(real_packet);
27008 }
27009 
send_packet_ruleset_government_ruler_title_100(struct connection * pc,const struct packet_ruleset_government_ruler_title * packet)27010 static int send_packet_ruleset_government_ruler_title_100(struct connection *pc, const struct packet_ruleset_government_ruler_title *packet)
27011 {
27012   const struct packet_ruleset_government_ruler_title *real_packet = packet;
27013   packet_ruleset_government_ruler_title_100_fields fields;
27014   struct packet_ruleset_government_ruler_title *old;
27015   bool differ;
27016   struct genhash **hash = pc->phs.sent + PACKET_RULESET_GOVERNMENT_RULER_TITLE;
27017   int different = 0;
27018   SEND_PACKET_START(PACKET_RULESET_GOVERNMENT_RULER_TITLE);
27019 
27020   log_packet_detailed("packet_ruleset_government_ruler_title_100: sending info about ()");
27021 
27022   if (NULL == *hash) {
27023     *hash = genhash_new_full(hash_packet_ruleset_government_ruler_title_100, cmp_packet_ruleset_government_ruler_title_100,
27024                              NULL, NULL, NULL, free);
27025   }
27026   BV_CLR_ALL(fields);
27027 
27028   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
27029     old = fc_malloc(sizeof(*old));
27030     *old = *real_packet;
27031     genhash_insert(*hash, old, old);
27032     memset(old, 0, sizeof(*old));
27033     different = 1;      /* Force to send. */
27034   }
27035 
27036   differ = (old->gov != real_packet->gov);
27037   if (differ) {
27038     different++;
27039     BV_SET(fields, 0);
27040   }
27041 
27042   differ = (old->nation != real_packet->nation);
27043   if (differ) {
27044     different++;
27045     BV_SET(fields, 1);
27046   }
27047 
27048   differ = (strcmp(old->male_title, real_packet->male_title) != 0);
27049   if (differ) {
27050     different++;
27051     BV_SET(fields, 2);
27052   }
27053 
27054   differ = (strcmp(old->female_title, real_packet->female_title) != 0);
27055   if (differ) {
27056     different++;
27057     BV_SET(fields, 3);
27058   }
27059 
27060 
27061   DIO_BV_PUT(&dout, "fields", fields);
27062 
27063   if (BV_ISSET(fields, 0)) {
27064     log_packet_detailed("  field 'gov' has changed");
27065     DIO_PUT(sint8, &dout, "gov", real_packet->gov);
27066   }
27067   if (BV_ISSET(fields, 1)) {
27068     log_packet_detailed("  field 'nation' has changed");
27069     DIO_PUT(sint16, &dout, "nation", real_packet->nation);
27070   }
27071   if (BV_ISSET(fields, 2)) {
27072     log_packet_detailed("  field 'male_title' has changed");
27073     DIO_PUT(string, &dout, "male_title", real_packet->male_title);
27074   }
27075   if (BV_ISSET(fields, 3)) {
27076     log_packet_detailed("  field 'female_title' has changed");
27077     DIO_PUT(string, &dout, "female_title", real_packet->female_title);
27078   }
27079 
27080   *old = *real_packet;
27081   SEND_PACKET_END(PACKET_RULESET_GOVERNMENT_RULER_TITLE);
27082 }
27083 
send_packet_ruleset_government_ruler_title(struct connection * pc,const struct packet_ruleset_government_ruler_title * packet)27084 int send_packet_ruleset_government_ruler_title(struct connection *pc, const struct packet_ruleset_government_ruler_title *packet)
27085 {
27086   if (!pc->used) {
27087     log_error("WARNING: trying to send data to the closed connection %s",
27088               conn_description(pc));
27089     return -1;
27090   }
27091   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_GOVERNMENT_RULER_TITLE].packet != NULL, -1,
27092                         "Handler for PACKET_RULESET_GOVERNMENT_RULER_TITLE not installed");
27093   return pc->phs.handlers->send[PACKET_RULESET_GOVERNMENT_RULER_TITLE].packet(pc, packet);
27094 }
27095 
lsend_packet_ruleset_government_ruler_title(struct conn_list * dest,const struct packet_ruleset_government_ruler_title * packet)27096 void lsend_packet_ruleset_government_ruler_title(struct conn_list *dest, const struct packet_ruleset_government_ruler_title *packet)
27097 {
27098   conn_list_iterate(dest, pconn) {
27099     send_packet_ruleset_government_ruler_title(pconn, packet);
27100   } conn_list_iterate_end;
27101 }
27102 
27103 #define hash_packet_ruleset_tech_100 hash_const
27104 
27105 #define cmp_packet_ruleset_tech_100 cmp_const
27106 
27107 BV_DEFINE(packet_ruleset_tech_100_fields, 11);
27108 
receive_packet_ruleset_tech_100(struct connection * pc)27109 static struct packet_ruleset_tech *receive_packet_ruleset_tech_100(struct connection *pc)
27110 {
27111   packet_ruleset_tech_100_fields fields;
27112   struct packet_ruleset_tech *old;
27113   struct genhash **hash = pc->phs.received + PACKET_RULESET_TECH;
27114   RECEIVE_PACKET_START(packet_ruleset_tech, real_packet);
27115 
27116   DIO_BV_GET(&din, fields);
27117 
27118   log_packet_detailed("packet_ruleset_tech_100: got info about ()");
27119 
27120   if (NULL == *hash) {
27121     *hash = genhash_new_full(hash_packet_ruleset_tech_100, cmp_packet_ruleset_tech_100,
27122                              NULL, NULL, NULL, free);
27123   }
27124 
27125   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
27126     *real_packet = *old;
27127   } else {
27128     log_packet_detailed("  no old info");
27129     memset(real_packet, 0, sizeof(*real_packet));
27130   }
27131 
27132   if (BV_ISSET(fields, 0)) {
27133     log_packet_detailed("  got field 'id'");
27134     if (!DIO_GET(uint8, &din, "id", &real_packet->id)) {
27135       RECEIVE_PACKET_FIELD_ERROR(id);
27136     }
27137   }
27138   if (BV_ISSET(fields, 1)) {
27139     log_packet_detailed("  got field 'req'");
27140 
27141     {
27142       int i;
27143 
27144       for (i = 0; i < 2; i++) {
27145         if (!DIO_GET(uint8, &din, "req", &real_packet->req[i])) {
27146           RECEIVE_PACKET_FIELD_ERROR(req);
27147         }
27148       }
27149     }
27150   }
27151   if (BV_ISSET(fields, 2)) {
27152     log_packet_detailed("  got field 'root_req'");
27153     if (!DIO_GET(uint8, &din, "root_req", &real_packet->root_req)) {
27154       RECEIVE_PACKET_FIELD_ERROR(root_req);
27155     }
27156   }
27157   if (BV_ISSET(fields, 3)) {
27158     log_packet_detailed("  got field 'flags'");
27159     if (!DIO_BV_GET(&din, real_packet->flags)) {
27160       RECEIVE_PACKET_FIELD_ERROR(flags);
27161     }
27162   }
27163   if (BV_ISSET(fields, 4)) {
27164     log_packet_detailed("  got field 'cost'");
27165     if (!DIO_GET(ufloat, &din, "cost", &real_packet->cost, 100)) {
27166       RECEIVE_PACKET_FIELD_ERROR(cost);
27167     }
27168   }
27169   if (BV_ISSET(fields, 5)) {
27170     log_packet_detailed("  got field 'num_reqs'");
27171     if (!DIO_GET(uint32, &din, "num_reqs", &real_packet->num_reqs)) {
27172       RECEIVE_PACKET_FIELD_ERROR(num_reqs);
27173     }
27174   }
27175   if (BV_ISSET(fields, 6)) {
27176     log_packet_detailed("  got field 'name'");
27177     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
27178       RECEIVE_PACKET_FIELD_ERROR(name);
27179     }
27180   }
27181   if (BV_ISSET(fields, 7)) {
27182     log_packet_detailed("  got field 'rule_name'");
27183     if (!DIO_GET(string, &din, "rule_name", real_packet->rule_name, sizeof(real_packet->rule_name))) {
27184       RECEIVE_PACKET_FIELD_ERROR(rule_name);
27185     }
27186   }
27187   if (BV_ISSET(fields, 8)) {
27188     log_packet_detailed("  got field 'helptext'");
27189     if (!DIO_GET(string, &din, "helptext", real_packet->helptext, sizeof(real_packet->helptext))) {
27190       RECEIVE_PACKET_FIELD_ERROR(helptext);
27191     }
27192   }
27193   if (BV_ISSET(fields, 9)) {
27194     log_packet_detailed("  got field 'graphic_str'");
27195     if (!DIO_GET(string, &din, "graphic_str", real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
27196       RECEIVE_PACKET_FIELD_ERROR(graphic_str);
27197     }
27198   }
27199   if (BV_ISSET(fields, 10)) {
27200     log_packet_detailed("  got field 'graphic_alt'");
27201     if (!DIO_GET(string, &din, "graphic_alt", real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
27202       RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
27203     }
27204   }
27205 
27206   if (NULL == old) {
27207     old = fc_malloc(sizeof(*old));
27208     *old = *real_packet;
27209     genhash_insert(*hash, old, old);
27210   } else {
27211     *old = *real_packet;
27212   }
27213   RECEIVE_PACKET_END(real_packet);
27214 }
27215 
send_packet_ruleset_tech_100(struct connection * pc,const struct packet_ruleset_tech * packet)27216 static int send_packet_ruleset_tech_100(struct connection *pc, const struct packet_ruleset_tech *packet)
27217 {
27218   const struct packet_ruleset_tech *real_packet = packet;
27219   packet_ruleset_tech_100_fields fields;
27220   struct packet_ruleset_tech *old;
27221   bool differ;
27222   struct genhash **hash = pc->phs.sent + PACKET_RULESET_TECH;
27223   int different = 0;
27224   SEND_PACKET_START(PACKET_RULESET_TECH);
27225 
27226   log_packet_detailed("packet_ruleset_tech_100: sending info about ()");
27227 
27228   if (NULL == *hash) {
27229     *hash = genhash_new_full(hash_packet_ruleset_tech_100, cmp_packet_ruleset_tech_100,
27230                              NULL, NULL, NULL, free);
27231   }
27232   BV_CLR_ALL(fields);
27233 
27234   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
27235     old = fc_malloc(sizeof(*old));
27236     *old = *real_packet;
27237     genhash_insert(*hash, old, old);
27238     memset(old, 0, sizeof(*old));
27239     different = 1;      /* Force to send. */
27240   }
27241 
27242   differ = (old->id != real_packet->id);
27243   if (differ) {
27244     different++;
27245     BV_SET(fields, 0);
27246   }
27247 
27248 
27249     {
27250       differ = (2 != 2);
27251       if (!differ) {
27252         int i;
27253 
27254         for (i = 0; i < 2; i++) {
27255           if (old->req[i] != real_packet->req[i]) {
27256             differ = TRUE;
27257             break;
27258           }
27259         }
27260       }
27261     }
27262   if (differ) {
27263     different++;
27264     BV_SET(fields, 1);
27265   }
27266 
27267   differ = (old->root_req != real_packet->root_req);
27268   if (differ) {
27269     different++;
27270     BV_SET(fields, 2);
27271   }
27272 
27273   differ = !BV_ARE_EQUAL(old->flags, real_packet->flags);
27274   if (differ) {
27275     different++;
27276     BV_SET(fields, 3);
27277   }
27278 
27279   differ = (old->cost != real_packet->cost);
27280   if (differ) {
27281     different++;
27282     BV_SET(fields, 4);
27283   }
27284 
27285   differ = (old->num_reqs != real_packet->num_reqs);
27286   if (differ) {
27287     different++;
27288     BV_SET(fields, 5);
27289   }
27290 
27291   differ = (strcmp(old->name, real_packet->name) != 0);
27292   if (differ) {
27293     different++;
27294     BV_SET(fields, 6);
27295   }
27296 
27297   differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
27298   if (differ) {
27299     different++;
27300     BV_SET(fields, 7);
27301   }
27302 
27303   differ = (strcmp(old->helptext, real_packet->helptext) != 0);
27304   if (differ) {
27305     different++;
27306     BV_SET(fields, 8);
27307   }
27308 
27309   differ = (strcmp(old->graphic_str, real_packet->graphic_str) != 0);
27310   if (differ) {
27311     different++;
27312     BV_SET(fields, 9);
27313   }
27314 
27315   differ = (strcmp(old->graphic_alt, real_packet->graphic_alt) != 0);
27316   if (differ) {
27317     different++;
27318     BV_SET(fields, 10);
27319   }
27320 
27321 
27322   DIO_BV_PUT(&dout, "fields", fields);
27323 
27324   if (BV_ISSET(fields, 0)) {
27325     log_packet_detailed("  field 'id' has changed");
27326     DIO_PUT(uint8, &dout, "id", real_packet->id);
27327   }
27328   if (BV_ISSET(fields, 1)) {
27329     log_packet_detailed("  field 'req' has changed");
27330 
27331     {
27332       int i;
27333 
27334       for (i = 0; i < 2; i++) {
27335         dio_put_uint8(&dout, real_packet->req[i]);
27336       }
27337     }
27338   }
27339   if (BV_ISSET(fields, 2)) {
27340     log_packet_detailed("  field 'root_req' has changed");
27341     DIO_PUT(uint8, &dout, "root_req", real_packet->root_req);
27342   }
27343   if (BV_ISSET(fields, 3)) {
27344     log_packet_detailed("  field 'flags' has changed");
27345   DIO_BV_PUT(&dout, "flags", packet->flags);
27346   }
27347   if (BV_ISSET(fields, 4)) {
27348     log_packet_detailed("  field 'cost' has changed");
27349     DIO_PUT(ufloat, &dout, "cost", real_packet->cost, 100);
27350   }
27351   if (BV_ISSET(fields, 5)) {
27352     log_packet_detailed("  field 'num_reqs' has changed");
27353     DIO_PUT(uint32, &dout, "num_reqs", real_packet->num_reqs);
27354   }
27355   if (BV_ISSET(fields, 6)) {
27356     log_packet_detailed("  field 'name' has changed");
27357     DIO_PUT(string, &dout, "name", real_packet->name);
27358   }
27359   if (BV_ISSET(fields, 7)) {
27360     log_packet_detailed("  field 'rule_name' has changed");
27361     DIO_PUT(string, &dout, "rule_name", real_packet->rule_name);
27362   }
27363   if (BV_ISSET(fields, 8)) {
27364     log_packet_detailed("  field 'helptext' has changed");
27365     DIO_PUT(string, &dout, "helptext", real_packet->helptext);
27366   }
27367   if (BV_ISSET(fields, 9)) {
27368     log_packet_detailed("  field 'graphic_str' has changed");
27369     DIO_PUT(string, &dout, "graphic_str", real_packet->graphic_str);
27370   }
27371   if (BV_ISSET(fields, 10)) {
27372     log_packet_detailed("  field 'graphic_alt' has changed");
27373     DIO_PUT(string, &dout, "graphic_alt", real_packet->graphic_alt);
27374   }
27375 
27376   *old = *real_packet;
27377   SEND_PACKET_END(PACKET_RULESET_TECH);
27378 }
27379 
send_packet_ruleset_tech(struct connection * pc,const struct packet_ruleset_tech * packet)27380 int send_packet_ruleset_tech(struct connection *pc, const struct packet_ruleset_tech *packet)
27381 {
27382   if (!pc->used) {
27383     log_error("WARNING: trying to send data to the closed connection %s",
27384               conn_description(pc));
27385     return -1;
27386   }
27387   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_TECH].packet != NULL, -1,
27388                         "Handler for PACKET_RULESET_TECH not installed");
27389   return pc->phs.handlers->send[PACKET_RULESET_TECH].packet(pc, packet);
27390 }
27391 
lsend_packet_ruleset_tech(struct conn_list * dest,const struct packet_ruleset_tech * packet)27392 void lsend_packet_ruleset_tech(struct conn_list *dest, const struct packet_ruleset_tech *packet)
27393 {
27394   conn_list_iterate(dest, pconn) {
27395     send_packet_ruleset_tech(pconn, packet);
27396   } conn_list_iterate_end;
27397 }
27398 
27399 #define hash_packet_ruleset_tech_flag_100 hash_const
27400 
27401 #define cmp_packet_ruleset_tech_flag_100 cmp_const
27402 
27403 BV_DEFINE(packet_ruleset_tech_flag_100_fields, 3);
27404 
receive_packet_ruleset_tech_flag_100(struct connection * pc)27405 static struct packet_ruleset_tech_flag *receive_packet_ruleset_tech_flag_100(struct connection *pc)
27406 {
27407   packet_ruleset_tech_flag_100_fields fields;
27408   struct packet_ruleset_tech_flag *old;
27409   struct genhash **hash = pc->phs.received + PACKET_RULESET_TECH_FLAG;
27410   RECEIVE_PACKET_START(packet_ruleset_tech_flag, real_packet);
27411 
27412   DIO_BV_GET(&din, fields);
27413 
27414   log_packet_detailed("packet_ruleset_tech_flag_100: got info about ()");
27415 
27416   if (NULL == *hash) {
27417     *hash = genhash_new_full(hash_packet_ruleset_tech_flag_100, cmp_packet_ruleset_tech_flag_100,
27418                              NULL, NULL, NULL, free);
27419   }
27420 
27421   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
27422     *real_packet = *old;
27423   } else {
27424     log_packet_detailed("  no old info");
27425     memset(real_packet, 0, sizeof(*real_packet));
27426   }
27427 
27428   if (BV_ISSET(fields, 0)) {
27429     log_packet_detailed("  got field 'id'");
27430     if (!DIO_GET(uint8, &din, "id", &real_packet->id)) {
27431       RECEIVE_PACKET_FIELD_ERROR(id);
27432     }
27433   }
27434   if (BV_ISSET(fields, 1)) {
27435     log_packet_detailed("  got field 'name'");
27436     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
27437       RECEIVE_PACKET_FIELD_ERROR(name);
27438     }
27439   }
27440   if (BV_ISSET(fields, 2)) {
27441     log_packet_detailed("  got field 'helptxt'");
27442     if (!DIO_GET(string, &din, "helptxt", real_packet->helptxt, sizeof(real_packet->helptxt))) {
27443       RECEIVE_PACKET_FIELD_ERROR(helptxt);
27444     }
27445   }
27446 
27447   if (NULL == old) {
27448     old = fc_malloc(sizeof(*old));
27449     *old = *real_packet;
27450     genhash_insert(*hash, old, old);
27451   } else {
27452     *old = *real_packet;
27453   }
27454   RECEIVE_PACKET_END(real_packet);
27455 }
27456 
send_packet_ruleset_tech_flag_100(struct connection * pc,const struct packet_ruleset_tech_flag * packet)27457 static int send_packet_ruleset_tech_flag_100(struct connection *pc, const struct packet_ruleset_tech_flag *packet)
27458 {
27459   const struct packet_ruleset_tech_flag *real_packet = packet;
27460   packet_ruleset_tech_flag_100_fields fields;
27461   struct packet_ruleset_tech_flag *old;
27462   bool differ;
27463   struct genhash **hash = pc->phs.sent + PACKET_RULESET_TECH_FLAG;
27464   int different = 0;
27465   SEND_PACKET_START(PACKET_RULESET_TECH_FLAG);
27466 
27467   log_packet_detailed("packet_ruleset_tech_flag_100: sending info about ()");
27468 
27469   if (NULL == *hash) {
27470     *hash = genhash_new_full(hash_packet_ruleset_tech_flag_100, cmp_packet_ruleset_tech_flag_100,
27471                              NULL, NULL, NULL, free);
27472   }
27473   BV_CLR_ALL(fields);
27474 
27475   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
27476     old = fc_malloc(sizeof(*old));
27477     *old = *real_packet;
27478     genhash_insert(*hash, old, old);
27479     memset(old, 0, sizeof(*old));
27480     different = 1;      /* Force to send. */
27481   }
27482 
27483   differ = (old->id != real_packet->id);
27484   if (differ) {
27485     different++;
27486     BV_SET(fields, 0);
27487   }
27488 
27489   differ = (strcmp(old->name, real_packet->name) != 0);
27490   if (differ) {
27491     different++;
27492     BV_SET(fields, 1);
27493   }
27494 
27495   differ = (strcmp(old->helptxt, real_packet->helptxt) != 0);
27496   if (differ) {
27497     different++;
27498     BV_SET(fields, 2);
27499   }
27500 
27501 
27502   DIO_BV_PUT(&dout, "fields", fields);
27503 
27504   if (BV_ISSET(fields, 0)) {
27505     log_packet_detailed("  field 'id' has changed");
27506     DIO_PUT(uint8, &dout, "id", real_packet->id);
27507   }
27508   if (BV_ISSET(fields, 1)) {
27509     log_packet_detailed("  field 'name' has changed");
27510     DIO_PUT(string, &dout, "name", real_packet->name);
27511   }
27512   if (BV_ISSET(fields, 2)) {
27513     log_packet_detailed("  field 'helptxt' has changed");
27514     DIO_PUT(string, &dout, "helptxt", real_packet->helptxt);
27515   }
27516 
27517   *old = *real_packet;
27518   SEND_PACKET_END(PACKET_RULESET_TECH_FLAG);
27519 }
27520 
send_packet_ruleset_tech_flag(struct connection * pc,const struct packet_ruleset_tech_flag * packet)27521 int send_packet_ruleset_tech_flag(struct connection *pc, const struct packet_ruleset_tech_flag *packet)
27522 {
27523   if (!pc->used) {
27524     log_error("WARNING: trying to send data to the closed connection %s",
27525               conn_description(pc));
27526     return -1;
27527   }
27528   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_TECH_FLAG].packet != NULL, -1,
27529                         "Handler for PACKET_RULESET_TECH_FLAG not installed");
27530   return pc->phs.handlers->send[PACKET_RULESET_TECH_FLAG].packet(pc, packet);
27531 }
27532 
lsend_packet_ruleset_tech_flag(struct conn_list * dest,const struct packet_ruleset_tech_flag * packet)27533 void lsend_packet_ruleset_tech_flag(struct conn_list *dest, const struct packet_ruleset_tech_flag *packet)
27534 {
27535   conn_list_iterate(dest, pconn) {
27536     send_packet_ruleset_tech_flag(pconn, packet);
27537   } conn_list_iterate_end;
27538 }
27539 
27540 #define hash_packet_ruleset_government_100 hash_const
27541 
27542 #define cmp_packet_ruleset_government_100 cmp_const
27543 
27544 BV_DEFINE(packet_ruleset_government_100_fields, 8);
27545 
receive_packet_ruleset_government_100(struct connection * pc)27546 static struct packet_ruleset_government *receive_packet_ruleset_government_100(struct connection *pc)
27547 {
27548   packet_ruleset_government_100_fields fields;
27549   struct packet_ruleset_government *old;
27550   struct genhash **hash = pc->phs.received + PACKET_RULESET_GOVERNMENT;
27551   RECEIVE_PACKET_START(packet_ruleset_government, real_packet);
27552 
27553   DIO_BV_GET(&din, fields);
27554 
27555   log_packet_detailed("packet_ruleset_government_100: got info about ()");
27556 
27557   if (NULL == *hash) {
27558     *hash = genhash_new_full(hash_packet_ruleset_government_100, cmp_packet_ruleset_government_100,
27559                              NULL, NULL, NULL, free);
27560   }
27561 
27562   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
27563     *real_packet = *old;
27564   } else {
27565     log_packet_detailed("  no old info");
27566     memset(real_packet, 0, sizeof(*real_packet));
27567   }
27568 
27569   if (BV_ISSET(fields, 0)) {
27570     log_packet_detailed("  got field 'id'");
27571     {
27572       int readin;
27573 
27574       if (!DIO_GET(sint8, &din, "id", &readin)) {
27575         RECEIVE_PACKET_FIELD_ERROR(id);
27576       }
27577       real_packet->id = readin;
27578     }
27579   }
27580   if (BV_ISSET(fields, 1)) {
27581     log_packet_detailed("  got field 'reqs_count'");
27582     if (!DIO_GET(uint8, &din, "reqs_count", &real_packet->reqs_count)) {
27583       RECEIVE_PACKET_FIELD_ERROR(reqs_count);
27584     }
27585   }
27586   if (BV_ISSET(fields, 2)) {
27587     log_packet_detailed("  got field 'reqs'");
27588 
27589     {
27590       int i;
27591 
27592       if (real_packet->reqs_count > MAX_NUM_REQS) {
27593         RECEIVE_PACKET_FIELD_ERROR(reqs, ": truncation array");
27594       }
27595       for (i = 0; i < real_packet->reqs_count; i++) {
27596         if (!DIO_GET(requirement, &din, "reqs", &real_packet->reqs[i])) {
27597           RECEIVE_PACKET_FIELD_ERROR(reqs);
27598         }
27599       }
27600     }
27601   }
27602   if (BV_ISSET(fields, 3)) {
27603     log_packet_detailed("  got field 'name'");
27604     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
27605       RECEIVE_PACKET_FIELD_ERROR(name);
27606     }
27607   }
27608   if (BV_ISSET(fields, 4)) {
27609     log_packet_detailed("  got field 'rule_name'");
27610     if (!DIO_GET(string, &din, "rule_name", real_packet->rule_name, sizeof(real_packet->rule_name))) {
27611       RECEIVE_PACKET_FIELD_ERROR(rule_name);
27612     }
27613   }
27614   if (BV_ISSET(fields, 5)) {
27615     log_packet_detailed("  got field 'graphic_str'");
27616     if (!DIO_GET(string, &din, "graphic_str", real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
27617       RECEIVE_PACKET_FIELD_ERROR(graphic_str);
27618     }
27619   }
27620   if (BV_ISSET(fields, 6)) {
27621     log_packet_detailed("  got field 'graphic_alt'");
27622     if (!DIO_GET(string, &din, "graphic_alt", real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
27623       RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
27624     }
27625   }
27626   if (BV_ISSET(fields, 7)) {
27627     log_packet_detailed("  got field 'helptext'");
27628     if (!DIO_GET(string, &din, "helptext", real_packet->helptext, sizeof(real_packet->helptext))) {
27629       RECEIVE_PACKET_FIELD_ERROR(helptext);
27630     }
27631   }
27632 
27633   if (NULL == old) {
27634     old = fc_malloc(sizeof(*old));
27635     *old = *real_packet;
27636     genhash_insert(*hash, old, old);
27637   } else {
27638     *old = *real_packet;
27639   }
27640   RECEIVE_PACKET_END(real_packet);
27641 }
27642 
send_packet_ruleset_government_100(struct connection * pc,const struct packet_ruleset_government * packet)27643 static int send_packet_ruleset_government_100(struct connection *pc, const struct packet_ruleset_government *packet)
27644 {
27645   const struct packet_ruleset_government *real_packet = packet;
27646   packet_ruleset_government_100_fields fields;
27647   struct packet_ruleset_government *old;
27648   bool differ;
27649   struct genhash **hash = pc->phs.sent + PACKET_RULESET_GOVERNMENT;
27650   int different = 0;
27651   SEND_PACKET_START(PACKET_RULESET_GOVERNMENT);
27652 
27653   log_packet_detailed("packet_ruleset_government_100: sending info about ()");
27654 
27655   if (NULL == *hash) {
27656     *hash = genhash_new_full(hash_packet_ruleset_government_100, cmp_packet_ruleset_government_100,
27657                              NULL, NULL, NULL, free);
27658   }
27659   BV_CLR_ALL(fields);
27660 
27661   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
27662     old = fc_malloc(sizeof(*old));
27663     *old = *real_packet;
27664     genhash_insert(*hash, old, old);
27665     memset(old, 0, sizeof(*old));
27666     different = 1;      /* Force to send. */
27667   }
27668 
27669   differ = (old->id != real_packet->id);
27670   if (differ) {
27671     different++;
27672     BV_SET(fields, 0);
27673   }
27674 
27675   differ = (old->reqs_count != real_packet->reqs_count);
27676   if (differ) {
27677     different++;
27678     BV_SET(fields, 1);
27679   }
27680 
27681 
27682     {
27683       differ = (old->reqs_count != real_packet->reqs_count);
27684       if (!differ) {
27685         int i;
27686 
27687         for (i = 0; i < real_packet->reqs_count; i++) {
27688           if (!are_requirements_equal(&old->reqs[i], &real_packet->reqs[i])) {
27689             differ = TRUE;
27690             break;
27691           }
27692         }
27693       }
27694     }
27695   if (differ) {
27696     different++;
27697     BV_SET(fields, 2);
27698   }
27699 
27700   differ = (strcmp(old->name, real_packet->name) != 0);
27701   if (differ) {
27702     different++;
27703     BV_SET(fields, 3);
27704   }
27705 
27706   differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
27707   if (differ) {
27708     different++;
27709     BV_SET(fields, 4);
27710   }
27711 
27712   differ = (strcmp(old->graphic_str, real_packet->graphic_str) != 0);
27713   if (differ) {
27714     different++;
27715     BV_SET(fields, 5);
27716   }
27717 
27718   differ = (strcmp(old->graphic_alt, real_packet->graphic_alt) != 0);
27719   if (differ) {
27720     different++;
27721     BV_SET(fields, 6);
27722   }
27723 
27724   differ = (strcmp(old->helptext, real_packet->helptext) != 0);
27725   if (differ) {
27726     different++;
27727     BV_SET(fields, 7);
27728   }
27729 
27730 
27731   DIO_BV_PUT(&dout, "fields", fields);
27732 
27733   if (BV_ISSET(fields, 0)) {
27734     log_packet_detailed("  field 'id' has changed");
27735     DIO_PUT(sint8, &dout, "id", real_packet->id);
27736   }
27737   if (BV_ISSET(fields, 1)) {
27738     log_packet_detailed("  field 'reqs_count' has changed");
27739     DIO_PUT(uint8, &dout, "reqs_count", real_packet->reqs_count);
27740   }
27741   if (BV_ISSET(fields, 2)) {
27742     log_packet_detailed("  field 'reqs' has changed");
27743 
27744     {
27745       int i;
27746 
27747       for (i = 0; i < real_packet->reqs_count; i++) {
27748         dio_put_requirement(&dout, &real_packet->reqs[i]);
27749       }
27750     }
27751   }
27752   if (BV_ISSET(fields, 3)) {
27753     log_packet_detailed("  field 'name' has changed");
27754     DIO_PUT(string, &dout, "name", real_packet->name);
27755   }
27756   if (BV_ISSET(fields, 4)) {
27757     log_packet_detailed("  field 'rule_name' has changed");
27758     DIO_PUT(string, &dout, "rule_name", real_packet->rule_name);
27759   }
27760   if (BV_ISSET(fields, 5)) {
27761     log_packet_detailed("  field 'graphic_str' has changed");
27762     DIO_PUT(string, &dout, "graphic_str", real_packet->graphic_str);
27763   }
27764   if (BV_ISSET(fields, 6)) {
27765     log_packet_detailed("  field 'graphic_alt' has changed");
27766     DIO_PUT(string, &dout, "graphic_alt", real_packet->graphic_alt);
27767   }
27768   if (BV_ISSET(fields, 7)) {
27769     log_packet_detailed("  field 'helptext' has changed");
27770     DIO_PUT(string, &dout, "helptext", real_packet->helptext);
27771   }
27772 
27773   *old = *real_packet;
27774   SEND_PACKET_END(PACKET_RULESET_GOVERNMENT);
27775 }
27776 
send_packet_ruleset_government(struct connection * pc,const struct packet_ruleset_government * packet)27777 int send_packet_ruleset_government(struct connection *pc, const struct packet_ruleset_government *packet)
27778 {
27779   if (!pc->used) {
27780     log_error("WARNING: trying to send data to the closed connection %s",
27781               conn_description(pc));
27782     return -1;
27783   }
27784   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_GOVERNMENT].packet != NULL, -1,
27785                         "Handler for PACKET_RULESET_GOVERNMENT not installed");
27786   return pc->phs.handlers->send[PACKET_RULESET_GOVERNMENT].packet(pc, packet);
27787 }
27788 
lsend_packet_ruleset_government(struct conn_list * dest,const struct packet_ruleset_government * packet)27789 void lsend_packet_ruleset_government(struct conn_list *dest, const struct packet_ruleset_government *packet)
27790 {
27791   conn_list_iterate(dest, pconn) {
27792     send_packet_ruleset_government(pconn, packet);
27793   } conn_list_iterate_end;
27794 }
27795 
27796 #define hash_packet_ruleset_terrain_control_100 hash_const
27797 
27798 #define cmp_packet_ruleset_terrain_control_100 cmp_const
27799 
27800 BV_DEFINE(packet_ruleset_terrain_control_100_fields, 11);
27801 
receive_packet_ruleset_terrain_control_100(struct connection * pc)27802 static struct packet_ruleset_terrain_control *receive_packet_ruleset_terrain_control_100(struct connection *pc)
27803 {
27804   packet_ruleset_terrain_control_100_fields fields;
27805   struct packet_ruleset_terrain_control *old;
27806   struct genhash **hash = pc->phs.received + PACKET_RULESET_TERRAIN_CONTROL;
27807   RECEIVE_PACKET_START(packet_ruleset_terrain_control, real_packet);
27808 
27809   DIO_BV_GET(&din, fields);
27810 
27811   log_packet_detailed("packet_ruleset_terrain_control_100: got info about ()");
27812 
27813   if (NULL == *hash) {
27814     *hash = genhash_new_full(hash_packet_ruleset_terrain_control_100, cmp_packet_ruleset_terrain_control_100,
27815                              NULL, NULL, NULL, free);
27816   }
27817 
27818   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
27819     *real_packet = *old;
27820   } else {
27821     log_packet_detailed("  no old info");
27822     memset(real_packet, 0, sizeof(*real_packet));
27823   }
27824 
27825   if (BV_ISSET(fields, 0)) {
27826     log_packet_detailed("  got field 'ocean_reclaim_requirement_pct'");
27827     if (!DIO_GET(uint8, &din, "ocean_reclaim_requirement_pct", &real_packet->ocean_reclaim_requirement_pct)) {
27828       RECEIVE_PACKET_FIELD_ERROR(ocean_reclaim_requirement_pct);
27829     }
27830   }
27831   if (BV_ISSET(fields, 1)) {
27832     log_packet_detailed("  got field 'land_channel_requirement_pct'");
27833     if (!DIO_GET(uint8, &din, "land_channel_requirement_pct", &real_packet->land_channel_requirement_pct)) {
27834       RECEIVE_PACKET_FIELD_ERROR(land_channel_requirement_pct);
27835     }
27836   }
27837   if (BV_ISSET(fields, 2)) {
27838     log_packet_detailed("  got field 'terrain_thaw_requirement_pct'");
27839     if (!DIO_GET(uint8, &din, "terrain_thaw_requirement_pct", &real_packet->terrain_thaw_requirement_pct)) {
27840       RECEIVE_PACKET_FIELD_ERROR(terrain_thaw_requirement_pct);
27841     }
27842   }
27843   if (BV_ISSET(fields, 3)) {
27844     log_packet_detailed("  got field 'terrain_freeze_requirement_pct'");
27845     if (!DIO_GET(uint8, &din, "terrain_freeze_requirement_pct", &real_packet->terrain_freeze_requirement_pct)) {
27846       RECEIVE_PACKET_FIELD_ERROR(terrain_freeze_requirement_pct);
27847     }
27848   }
27849   if (BV_ISSET(fields, 4)) {
27850     log_packet_detailed("  got field 'lake_max_size'");
27851     if (!DIO_GET(uint8, &din, "lake_max_size", &real_packet->lake_max_size)) {
27852       RECEIVE_PACKET_FIELD_ERROR(lake_max_size);
27853     }
27854   }
27855   if (BV_ISSET(fields, 5)) {
27856     log_packet_detailed("  got field 'min_start_native_area'");
27857     if (!DIO_GET(uint8, &din, "min_start_native_area", &real_packet->min_start_native_area)) {
27858       RECEIVE_PACKET_FIELD_ERROR(min_start_native_area);
27859     }
27860   }
27861   if (BV_ISSET(fields, 6)) {
27862     log_packet_detailed("  got field 'move_fragments'");
27863     if (!DIO_GET(uint16, &din, "move_fragments", &real_packet->move_fragments)) {
27864       RECEIVE_PACKET_FIELD_ERROR(move_fragments);
27865     }
27866   }
27867   if (BV_ISSET(fields, 7)) {
27868     log_packet_detailed("  got field 'igter_cost'");
27869     if (!DIO_GET(uint16, &din, "igter_cost", &real_packet->igter_cost)) {
27870       RECEIVE_PACKET_FIELD_ERROR(igter_cost);
27871     }
27872   }
27873   real_packet->pythagorean_diagonal = BV_ISSET(fields, 8);
27874   if (BV_ISSET(fields, 9)) {
27875     log_packet_detailed("  got field 'gui_type_base0'");
27876     if (!DIO_GET(string, &din, "gui_type_base0", real_packet->gui_type_base0, sizeof(real_packet->gui_type_base0))) {
27877       RECEIVE_PACKET_FIELD_ERROR(gui_type_base0);
27878     }
27879   }
27880   if (BV_ISSET(fields, 10)) {
27881     log_packet_detailed("  got field 'gui_type_base1'");
27882     if (!DIO_GET(string, &din, "gui_type_base1", real_packet->gui_type_base1, sizeof(real_packet->gui_type_base1))) {
27883       RECEIVE_PACKET_FIELD_ERROR(gui_type_base1);
27884     }
27885   }
27886 
27887   if (NULL == old) {
27888     old = fc_malloc(sizeof(*old));
27889     *old = *real_packet;
27890     genhash_insert(*hash, old, old);
27891   } else {
27892     *old = *real_packet;
27893   }
27894   RECEIVE_PACKET_END(real_packet);
27895 }
27896 
send_packet_ruleset_terrain_control_100(struct connection * pc,const struct packet_ruleset_terrain_control * packet)27897 static int send_packet_ruleset_terrain_control_100(struct connection *pc, const struct packet_ruleset_terrain_control *packet)
27898 {
27899   const struct packet_ruleset_terrain_control *real_packet = packet;
27900   packet_ruleset_terrain_control_100_fields fields;
27901   struct packet_ruleset_terrain_control *old;
27902   bool differ;
27903   struct genhash **hash = pc->phs.sent + PACKET_RULESET_TERRAIN_CONTROL;
27904   int different = 0;
27905   SEND_PACKET_START(PACKET_RULESET_TERRAIN_CONTROL);
27906 
27907   log_packet_detailed("packet_ruleset_terrain_control_100: sending info about ()");
27908 
27909   if (NULL == *hash) {
27910     *hash = genhash_new_full(hash_packet_ruleset_terrain_control_100, cmp_packet_ruleset_terrain_control_100,
27911                              NULL, NULL, NULL, free);
27912   }
27913   BV_CLR_ALL(fields);
27914 
27915   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
27916     old = fc_malloc(sizeof(*old));
27917     *old = *real_packet;
27918     genhash_insert(*hash, old, old);
27919     memset(old, 0, sizeof(*old));
27920     different = 1;      /* Force to send. */
27921   }
27922 
27923   differ = (old->ocean_reclaim_requirement_pct != real_packet->ocean_reclaim_requirement_pct);
27924   if (differ) {
27925     different++;
27926     BV_SET(fields, 0);
27927   }
27928 
27929   differ = (old->land_channel_requirement_pct != real_packet->land_channel_requirement_pct);
27930   if (differ) {
27931     different++;
27932     BV_SET(fields, 1);
27933   }
27934 
27935   differ = (old->terrain_thaw_requirement_pct != real_packet->terrain_thaw_requirement_pct);
27936   if (differ) {
27937     different++;
27938     BV_SET(fields, 2);
27939   }
27940 
27941   differ = (old->terrain_freeze_requirement_pct != real_packet->terrain_freeze_requirement_pct);
27942   if (differ) {
27943     different++;
27944     BV_SET(fields, 3);
27945   }
27946 
27947   differ = (old->lake_max_size != real_packet->lake_max_size);
27948   if (differ) {
27949     different++;
27950     BV_SET(fields, 4);
27951   }
27952 
27953   differ = (old->min_start_native_area != real_packet->min_start_native_area);
27954   if (differ) {
27955     different++;
27956     BV_SET(fields, 5);
27957   }
27958 
27959   differ = (old->move_fragments != real_packet->move_fragments);
27960   if (differ) {
27961     different++;
27962     BV_SET(fields, 6);
27963   }
27964 
27965   differ = (old->igter_cost != real_packet->igter_cost);
27966   if (differ) {
27967     different++;
27968     BV_SET(fields, 7);
27969   }
27970 
27971   differ = (old->pythagorean_diagonal != real_packet->pythagorean_diagonal);
27972   if (differ) {
27973     different++;
27974   }
27975   if (packet->pythagorean_diagonal) {
27976     BV_SET(fields, 8);
27977   }
27978 
27979   differ = (strcmp(old->gui_type_base0, real_packet->gui_type_base0) != 0);
27980   if (differ) {
27981     different++;
27982     BV_SET(fields, 9);
27983   }
27984 
27985   differ = (strcmp(old->gui_type_base1, real_packet->gui_type_base1) != 0);
27986   if (differ) {
27987     different++;
27988     BV_SET(fields, 10);
27989   }
27990 
27991 
27992   DIO_BV_PUT(&dout, "fields", fields);
27993 
27994   if (BV_ISSET(fields, 0)) {
27995     log_packet_detailed("  field 'ocean_reclaim_requirement_pct' has changed");
27996     DIO_PUT(uint8, &dout, "ocean_reclaim_requirement_pct", real_packet->ocean_reclaim_requirement_pct);
27997   }
27998   if (BV_ISSET(fields, 1)) {
27999     log_packet_detailed("  field 'land_channel_requirement_pct' has changed");
28000     DIO_PUT(uint8, &dout, "land_channel_requirement_pct", real_packet->land_channel_requirement_pct);
28001   }
28002   if (BV_ISSET(fields, 2)) {
28003     log_packet_detailed("  field 'terrain_thaw_requirement_pct' has changed");
28004     DIO_PUT(uint8, &dout, "terrain_thaw_requirement_pct", real_packet->terrain_thaw_requirement_pct);
28005   }
28006   if (BV_ISSET(fields, 3)) {
28007     log_packet_detailed("  field 'terrain_freeze_requirement_pct' has changed");
28008     DIO_PUT(uint8, &dout, "terrain_freeze_requirement_pct", real_packet->terrain_freeze_requirement_pct);
28009   }
28010   if (BV_ISSET(fields, 4)) {
28011     log_packet_detailed("  field 'lake_max_size' has changed");
28012     DIO_PUT(uint8, &dout, "lake_max_size", real_packet->lake_max_size);
28013   }
28014   if (BV_ISSET(fields, 5)) {
28015     log_packet_detailed("  field 'min_start_native_area' has changed");
28016     DIO_PUT(uint8, &dout, "min_start_native_area", real_packet->min_start_native_area);
28017   }
28018   if (BV_ISSET(fields, 6)) {
28019     log_packet_detailed("  field 'move_fragments' has changed");
28020     DIO_PUT(uint16, &dout, "move_fragments", real_packet->move_fragments);
28021   }
28022   if (BV_ISSET(fields, 7)) {
28023     log_packet_detailed("  field 'igter_cost' has changed");
28024     DIO_PUT(uint16, &dout, "igter_cost", real_packet->igter_cost);
28025   }
28026   /* field 8 is folded into the header */
28027   if (BV_ISSET(fields, 9)) {
28028     log_packet_detailed("  field 'gui_type_base0' has changed");
28029     DIO_PUT(string, &dout, "gui_type_base0", real_packet->gui_type_base0);
28030   }
28031   if (BV_ISSET(fields, 10)) {
28032     log_packet_detailed("  field 'gui_type_base1' has changed");
28033     DIO_PUT(string, &dout, "gui_type_base1", real_packet->gui_type_base1);
28034   }
28035 
28036   *old = *real_packet;
28037   SEND_PACKET_END(PACKET_RULESET_TERRAIN_CONTROL);
28038 }
28039 
send_packet_ruleset_terrain_control(struct connection * pc,const struct packet_ruleset_terrain_control * packet)28040 int send_packet_ruleset_terrain_control(struct connection *pc, const struct packet_ruleset_terrain_control *packet)
28041 {
28042   if (!pc->used) {
28043     log_error("WARNING: trying to send data to the closed connection %s",
28044               conn_description(pc));
28045     return -1;
28046   }
28047   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_TERRAIN_CONTROL].packet != NULL, -1,
28048                         "Handler for PACKET_RULESET_TERRAIN_CONTROL not installed");
28049   return pc->phs.handlers->send[PACKET_RULESET_TERRAIN_CONTROL].packet(pc, packet);
28050 }
28051 
lsend_packet_ruleset_terrain_control(struct conn_list * dest,const struct packet_ruleset_terrain_control * packet)28052 void lsend_packet_ruleset_terrain_control(struct conn_list *dest, const struct packet_ruleset_terrain_control *packet)
28053 {
28054   conn_list_iterate(dest, pconn) {
28055     send_packet_ruleset_terrain_control(pconn, packet);
28056   } conn_list_iterate_end;
28057 }
28058 
receive_packet_rulesets_ready_100(struct connection * pc)28059 static struct packet_rulesets_ready *receive_packet_rulesets_ready_100(struct connection *pc)
28060 {
28061   RECEIVE_PACKET_START(packet_rulesets_ready, real_packet);
28062   real_packet->__dummy = 0xff;
28063   log_packet_detailed("packet_rulesets_ready_100: got info about ()");
28064   RECEIVE_PACKET_END(real_packet);
28065 }
28066 
send_packet_rulesets_ready_100(struct connection * pc)28067 static int send_packet_rulesets_ready_100(struct connection *pc)
28068 {
28069   SEND_PACKET_START(PACKET_RULESETS_READY);
28070 
28071   log_packet_detailed("packet_rulesets_ready_100: sending info about ()");
28072   SEND_PACKET_END(PACKET_RULESETS_READY);
28073 }
28074 
send_packet_rulesets_ready(struct connection * pc)28075 int send_packet_rulesets_ready(struct connection *pc)
28076 {
28077   if (!pc->used) {
28078     log_error("WARNING: trying to send data to the closed connection %s",
28079               conn_description(pc));
28080     return -1;
28081   }
28082   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESETS_READY].no_packet != NULL, -1,
28083                         "Handler for PACKET_RULESETS_READY not installed");
28084   return pc->phs.handlers->send[PACKET_RULESETS_READY].no_packet(pc);
28085 }
28086 
lsend_packet_rulesets_ready(struct conn_list * dest)28087 void lsend_packet_rulesets_ready(struct conn_list *dest)
28088 {
28089   conn_list_iterate(dest, pconn) {
28090     send_packet_rulesets_ready(pconn);
28091   } conn_list_iterate_end;
28092 }
28093 
28094 #define hash_packet_ruleset_nation_sets_100 hash_const
28095 
28096 #define cmp_packet_ruleset_nation_sets_100 cmp_const
28097 
28098 BV_DEFINE(packet_ruleset_nation_sets_100_fields, 4);
28099 
receive_packet_ruleset_nation_sets_100(struct connection * pc)28100 static struct packet_ruleset_nation_sets *receive_packet_ruleset_nation_sets_100(struct connection *pc)
28101 {
28102   packet_ruleset_nation_sets_100_fields fields;
28103   struct packet_ruleset_nation_sets *old;
28104   struct genhash **hash = pc->phs.received + PACKET_RULESET_NATION_SETS;
28105   RECEIVE_PACKET_START(packet_ruleset_nation_sets, real_packet);
28106 
28107   DIO_BV_GET(&din, fields);
28108 
28109   log_packet_detailed("packet_ruleset_nation_sets_100: got info about ()");
28110 
28111   if (NULL == *hash) {
28112     *hash = genhash_new_full(hash_packet_ruleset_nation_sets_100, cmp_packet_ruleset_nation_sets_100,
28113                              NULL, NULL, NULL, free);
28114   }
28115 
28116   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
28117     *real_packet = *old;
28118   } else {
28119     log_packet_detailed("  no old info");
28120     memset(real_packet, 0, sizeof(*real_packet));
28121   }
28122 
28123   if (BV_ISSET(fields, 0)) {
28124     log_packet_detailed("  got field 'nsets'");
28125     if (!DIO_GET(uint8, &din, "nsets", &real_packet->nsets)) {
28126       RECEIVE_PACKET_FIELD_ERROR(nsets);
28127     }
28128   }
28129   if (BV_ISSET(fields, 1)) {
28130     log_packet_detailed("  got field 'names'");
28131 
28132     {
28133       int i;
28134 
28135       if (real_packet->nsets > MAX_NUM_NATION_SETS) {
28136         RECEIVE_PACKET_FIELD_ERROR(names, ": truncation array");
28137       }
28138       for (i = 0; i < real_packet->nsets; i++) {
28139         if (!DIO_GET(string, &din, "names", real_packet->names[i], sizeof(real_packet->names[i]))) {
28140           RECEIVE_PACKET_FIELD_ERROR(names);
28141         }
28142       }
28143     }
28144   }
28145   if (BV_ISSET(fields, 2)) {
28146     log_packet_detailed("  got field 'rule_names'");
28147 
28148     {
28149       int i;
28150 
28151       if (real_packet->nsets > MAX_NUM_NATION_SETS) {
28152         RECEIVE_PACKET_FIELD_ERROR(rule_names, ": truncation array");
28153       }
28154       for (i = 0; i < real_packet->nsets; i++) {
28155         if (!DIO_GET(string, &din, "rule_names", real_packet->rule_names[i], sizeof(real_packet->rule_names[i]))) {
28156           RECEIVE_PACKET_FIELD_ERROR(rule_names);
28157         }
28158       }
28159     }
28160   }
28161   if (BV_ISSET(fields, 3)) {
28162     log_packet_detailed("  got field 'descriptions'");
28163 
28164     {
28165       int i;
28166 
28167       if (real_packet->nsets > MAX_NUM_NATION_SETS) {
28168         RECEIVE_PACKET_FIELD_ERROR(descriptions, ": truncation array");
28169       }
28170       for (i = 0; i < real_packet->nsets; i++) {
28171         if (!DIO_GET(string, &din, "descriptions", real_packet->descriptions[i], sizeof(real_packet->descriptions[i]))) {
28172           RECEIVE_PACKET_FIELD_ERROR(descriptions);
28173         }
28174       }
28175     }
28176   }
28177 
28178   if (NULL == old) {
28179     old = fc_malloc(sizeof(*old));
28180     *old = *real_packet;
28181     genhash_insert(*hash, old, old);
28182   } else {
28183     *old = *real_packet;
28184   }
28185   RECEIVE_PACKET_END(real_packet);
28186 }
28187 
send_packet_ruleset_nation_sets_100(struct connection * pc,const struct packet_ruleset_nation_sets * packet)28188 static int send_packet_ruleset_nation_sets_100(struct connection *pc, const struct packet_ruleset_nation_sets *packet)
28189 {
28190   const struct packet_ruleset_nation_sets *real_packet = packet;
28191   packet_ruleset_nation_sets_100_fields fields;
28192   struct packet_ruleset_nation_sets *old;
28193   bool differ;
28194   struct genhash **hash = pc->phs.sent + PACKET_RULESET_NATION_SETS;
28195   int different = 0;
28196   SEND_PACKET_START(PACKET_RULESET_NATION_SETS);
28197 
28198   log_packet_detailed("packet_ruleset_nation_sets_100: sending info about ()");
28199 
28200   if (NULL == *hash) {
28201     *hash = genhash_new_full(hash_packet_ruleset_nation_sets_100, cmp_packet_ruleset_nation_sets_100,
28202                              NULL, NULL, NULL, free);
28203   }
28204   BV_CLR_ALL(fields);
28205 
28206   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
28207     old = fc_malloc(sizeof(*old));
28208     *old = *real_packet;
28209     genhash_insert(*hash, old, old);
28210     memset(old, 0, sizeof(*old));
28211     different = 1;      /* Force to send. */
28212   }
28213 
28214   differ = (old->nsets != real_packet->nsets);
28215   if (differ) {
28216     different++;
28217     BV_SET(fields, 0);
28218   }
28219 
28220 
28221     {
28222       differ = (old->nsets != real_packet->nsets);
28223       if (!differ) {
28224         int i;
28225 
28226         for (i = 0; i < real_packet->nsets; i++) {
28227           if (strcmp(old->names[i], real_packet->names[i]) != 0) {
28228             differ = TRUE;
28229             break;
28230           }
28231         }
28232       }
28233     }
28234   if (differ) {
28235     different++;
28236     BV_SET(fields, 1);
28237   }
28238 
28239 
28240     {
28241       differ = (old->nsets != real_packet->nsets);
28242       if (!differ) {
28243         int i;
28244 
28245         for (i = 0; i < real_packet->nsets; i++) {
28246           if (strcmp(old->rule_names[i], real_packet->rule_names[i]) != 0) {
28247             differ = TRUE;
28248             break;
28249           }
28250         }
28251       }
28252     }
28253   if (differ) {
28254     different++;
28255     BV_SET(fields, 2);
28256   }
28257 
28258 
28259     {
28260       differ = (old->nsets != real_packet->nsets);
28261       if (!differ) {
28262         int i;
28263 
28264         for (i = 0; i < real_packet->nsets; i++) {
28265           if (strcmp(old->descriptions[i], real_packet->descriptions[i]) != 0) {
28266             differ = TRUE;
28267             break;
28268           }
28269         }
28270       }
28271     }
28272   if (differ) {
28273     different++;
28274     BV_SET(fields, 3);
28275   }
28276 
28277 
28278   DIO_BV_PUT(&dout, "fields", fields);
28279 
28280   if (BV_ISSET(fields, 0)) {
28281     log_packet_detailed("  field 'nsets' has changed");
28282     DIO_PUT(uint8, &dout, "nsets", real_packet->nsets);
28283   }
28284   if (BV_ISSET(fields, 1)) {
28285     log_packet_detailed("  field 'names' has changed");
28286 
28287     {
28288       int i;
28289 
28290       for (i = 0; i < real_packet->nsets; i++) {
28291         dio_put_string(&dout, real_packet->names[i]);
28292       }
28293     }
28294   }
28295   if (BV_ISSET(fields, 2)) {
28296     log_packet_detailed("  field 'rule_names' has changed");
28297 
28298     {
28299       int i;
28300 
28301       for (i = 0; i < real_packet->nsets; i++) {
28302         dio_put_string(&dout, real_packet->rule_names[i]);
28303       }
28304     }
28305   }
28306   if (BV_ISSET(fields, 3)) {
28307     log_packet_detailed("  field 'descriptions' has changed");
28308 
28309     {
28310       int i;
28311 
28312       for (i = 0; i < real_packet->nsets; i++) {
28313         dio_put_string(&dout, real_packet->descriptions[i]);
28314       }
28315     }
28316   }
28317 
28318   *old = *real_packet;
28319   SEND_PACKET_END(PACKET_RULESET_NATION_SETS);
28320 }
28321 
send_packet_ruleset_nation_sets(struct connection * pc,const struct packet_ruleset_nation_sets * packet)28322 int send_packet_ruleset_nation_sets(struct connection *pc, const struct packet_ruleset_nation_sets *packet)
28323 {
28324   if (!pc->used) {
28325     log_error("WARNING: trying to send data to the closed connection %s",
28326               conn_description(pc));
28327     return -1;
28328   }
28329   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_NATION_SETS].packet != NULL, -1,
28330                         "Handler for PACKET_RULESET_NATION_SETS not installed");
28331   return pc->phs.handlers->send[PACKET_RULESET_NATION_SETS].packet(pc, packet);
28332 }
28333 
lsend_packet_ruleset_nation_sets(struct conn_list * dest,const struct packet_ruleset_nation_sets * packet)28334 void lsend_packet_ruleset_nation_sets(struct conn_list *dest, const struct packet_ruleset_nation_sets *packet)
28335 {
28336   conn_list_iterate(dest, pconn) {
28337     send_packet_ruleset_nation_sets(pconn, packet);
28338   } conn_list_iterate_end;
28339 }
28340 
28341 #define hash_packet_ruleset_nation_groups_100 hash_const
28342 
28343 #define cmp_packet_ruleset_nation_groups_100 cmp_const
28344 
28345 BV_DEFINE(packet_ruleset_nation_groups_100_fields, 3);
28346 
receive_packet_ruleset_nation_groups_100(struct connection * pc)28347 static struct packet_ruleset_nation_groups *receive_packet_ruleset_nation_groups_100(struct connection *pc)
28348 {
28349   packet_ruleset_nation_groups_100_fields fields;
28350   struct packet_ruleset_nation_groups *old;
28351   struct genhash **hash = pc->phs.received + PACKET_RULESET_NATION_GROUPS;
28352   RECEIVE_PACKET_START(packet_ruleset_nation_groups, real_packet);
28353 
28354   DIO_BV_GET(&din, fields);
28355 
28356   log_packet_detailed("packet_ruleset_nation_groups_100: got info about ()");
28357 
28358   if (NULL == *hash) {
28359     *hash = genhash_new_full(hash_packet_ruleset_nation_groups_100, cmp_packet_ruleset_nation_groups_100,
28360                              NULL, NULL, NULL, free);
28361   }
28362 
28363   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
28364     *real_packet = *old;
28365   } else {
28366     log_packet_detailed("  no old info");
28367     memset(real_packet, 0, sizeof(*real_packet));
28368   }
28369 
28370   if (BV_ISSET(fields, 0)) {
28371     log_packet_detailed("  got field 'ngroups'");
28372     if (!DIO_GET(uint8, &din, "ngroups", &real_packet->ngroups)) {
28373       RECEIVE_PACKET_FIELD_ERROR(ngroups);
28374     }
28375   }
28376   if (BV_ISSET(fields, 1)) {
28377     log_packet_detailed("  got field 'groups'");
28378 
28379     {
28380       int i;
28381 
28382       if (real_packet->ngroups > MAX_NUM_NATION_GROUPS) {
28383         RECEIVE_PACKET_FIELD_ERROR(groups, ": truncation array");
28384       }
28385       for (i = 0; i < real_packet->ngroups; i++) {
28386         if (!DIO_GET(string, &din, "groups", real_packet->groups[i], sizeof(real_packet->groups[i]))) {
28387           RECEIVE_PACKET_FIELD_ERROR(groups);
28388         }
28389       }
28390     }
28391   }
28392   if (BV_ISSET(fields, 2)) {
28393     log_packet_detailed("  got field 'hidden'");
28394 
28395     {
28396       int i;
28397 
28398       if (real_packet->ngroups > MAX_NUM_NATION_GROUPS) {
28399         RECEIVE_PACKET_FIELD_ERROR(hidden, ": truncation array");
28400       }
28401       for (i = 0; i < real_packet->ngroups; i++) {
28402         if (!DIO_GET(bool8, &din, "hidden", &real_packet->hidden[i])) {
28403           RECEIVE_PACKET_FIELD_ERROR(hidden);
28404         }
28405       }
28406     }
28407   }
28408 
28409   if (NULL == old) {
28410     old = fc_malloc(sizeof(*old));
28411     *old = *real_packet;
28412     genhash_insert(*hash, old, old);
28413   } else {
28414     *old = *real_packet;
28415   }
28416   RECEIVE_PACKET_END(real_packet);
28417 }
28418 
send_packet_ruleset_nation_groups_100(struct connection * pc,const struct packet_ruleset_nation_groups * packet)28419 static int send_packet_ruleset_nation_groups_100(struct connection *pc, const struct packet_ruleset_nation_groups *packet)
28420 {
28421   const struct packet_ruleset_nation_groups *real_packet = packet;
28422   packet_ruleset_nation_groups_100_fields fields;
28423   struct packet_ruleset_nation_groups *old;
28424   bool differ;
28425   struct genhash **hash = pc->phs.sent + PACKET_RULESET_NATION_GROUPS;
28426   int different = 0;
28427   SEND_PACKET_START(PACKET_RULESET_NATION_GROUPS);
28428 
28429   log_packet_detailed("packet_ruleset_nation_groups_100: sending info about ()");
28430 
28431   if (NULL == *hash) {
28432     *hash = genhash_new_full(hash_packet_ruleset_nation_groups_100, cmp_packet_ruleset_nation_groups_100,
28433                              NULL, NULL, NULL, free);
28434   }
28435   BV_CLR_ALL(fields);
28436 
28437   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
28438     old = fc_malloc(sizeof(*old));
28439     *old = *real_packet;
28440     genhash_insert(*hash, old, old);
28441     memset(old, 0, sizeof(*old));
28442     different = 1;      /* Force to send. */
28443   }
28444 
28445   differ = (old->ngroups != real_packet->ngroups);
28446   if (differ) {
28447     different++;
28448     BV_SET(fields, 0);
28449   }
28450 
28451 
28452     {
28453       differ = (old->ngroups != real_packet->ngroups);
28454       if (!differ) {
28455         int i;
28456 
28457         for (i = 0; i < real_packet->ngroups; i++) {
28458           if (strcmp(old->groups[i], real_packet->groups[i]) != 0) {
28459             differ = TRUE;
28460             break;
28461           }
28462         }
28463       }
28464     }
28465   if (differ) {
28466     different++;
28467     BV_SET(fields, 1);
28468   }
28469 
28470 
28471     {
28472       differ = (old->ngroups != real_packet->ngroups);
28473       if (!differ) {
28474         int i;
28475 
28476         for (i = 0; i < real_packet->ngroups; i++) {
28477           if (old->hidden[i] != real_packet->hidden[i]) {
28478             differ = TRUE;
28479             break;
28480           }
28481         }
28482       }
28483     }
28484   if (differ) {
28485     different++;
28486     BV_SET(fields, 2);
28487   }
28488 
28489 
28490   DIO_BV_PUT(&dout, "fields", fields);
28491 
28492   if (BV_ISSET(fields, 0)) {
28493     log_packet_detailed("  field 'ngroups' has changed");
28494     DIO_PUT(uint8, &dout, "ngroups", real_packet->ngroups);
28495   }
28496   if (BV_ISSET(fields, 1)) {
28497     log_packet_detailed("  field 'groups' has changed");
28498 
28499     {
28500       int i;
28501 
28502       for (i = 0; i < real_packet->ngroups; i++) {
28503         dio_put_string(&dout, real_packet->groups[i]);
28504       }
28505     }
28506   }
28507   if (BV_ISSET(fields, 2)) {
28508     log_packet_detailed("  field 'hidden' has changed");
28509 
28510     {
28511       int i;
28512 
28513       for (i = 0; i < real_packet->ngroups; i++) {
28514         dio_put_bool8(&dout, real_packet->hidden[i]);
28515       }
28516     }
28517   }
28518 
28519   *old = *real_packet;
28520   SEND_PACKET_END(PACKET_RULESET_NATION_GROUPS);
28521 }
28522 
send_packet_ruleset_nation_groups(struct connection * pc,const struct packet_ruleset_nation_groups * packet)28523 int send_packet_ruleset_nation_groups(struct connection *pc, const struct packet_ruleset_nation_groups *packet)
28524 {
28525   if (!pc->used) {
28526     log_error("WARNING: trying to send data to the closed connection %s",
28527               conn_description(pc));
28528     return -1;
28529   }
28530   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_NATION_GROUPS].packet != NULL, -1,
28531                         "Handler for PACKET_RULESET_NATION_GROUPS not installed");
28532   return pc->phs.handlers->send[PACKET_RULESET_NATION_GROUPS].packet(pc, packet);
28533 }
28534 
lsend_packet_ruleset_nation_groups(struct conn_list * dest,const struct packet_ruleset_nation_groups * packet)28535 void lsend_packet_ruleset_nation_groups(struct conn_list *dest, const struct packet_ruleset_nation_groups *packet)
28536 {
28537   conn_list_iterate(dest, pconn) {
28538     send_packet_ruleset_nation_groups(pconn, packet);
28539   } conn_list_iterate_end;
28540 }
28541 
hash_packet_ruleset_nation_100(const void * vkey)28542 static genhash_val_t hash_packet_ruleset_nation_100(const void *vkey)
28543 {
28544   const struct packet_ruleset_nation *key = (const struct packet_ruleset_nation *) vkey;
28545 
28546   return key->id;
28547 }
28548 
cmp_packet_ruleset_nation_100(const void * vkey1,const void * vkey2)28549 static bool cmp_packet_ruleset_nation_100(const void *vkey1, const void *vkey2)
28550 {
28551   const struct packet_ruleset_nation *key1 = (const struct packet_ruleset_nation *) vkey1;
28552   const struct packet_ruleset_nation *key2 = (const struct packet_ruleset_nation *) vkey2;
28553 
28554   return key1->id == key2->id;
28555 }
28556 
28557 BV_DEFINE(packet_ruleset_nation_100_fields, 21);
28558 
receive_packet_ruleset_nation_100(struct connection * pc)28559 static struct packet_ruleset_nation *receive_packet_ruleset_nation_100(struct connection *pc)
28560 {
28561   packet_ruleset_nation_100_fields fields;
28562   struct packet_ruleset_nation *old;
28563   struct genhash **hash = pc->phs.received + PACKET_RULESET_NATION;
28564   RECEIVE_PACKET_START(packet_ruleset_nation, real_packet);
28565 
28566   DIO_BV_GET(&din, fields);
28567   {
28568     int readin;
28569 
28570     if (!DIO_GET(sint16, &din, "id", &readin)) {
28571       RECEIVE_PACKET_FIELD_ERROR(id);
28572     }
28573     real_packet->id = readin;
28574   }
28575 
28576   log_packet_detailed("packet_ruleset_nation_100: got info about (%d)",
28577     real_packet->id);
28578 
28579   if (NULL == *hash) {
28580     *hash = genhash_new_full(hash_packet_ruleset_nation_100, cmp_packet_ruleset_nation_100,
28581                              NULL, NULL, NULL, free);
28582   }
28583 
28584   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
28585     *real_packet = *old;
28586   } else {
28587     Nation_type_id id = real_packet->id;
28588 
28589     log_packet_detailed("  no old info");
28590     memset(real_packet, 0, sizeof(*real_packet));
28591 
28592     real_packet->id = id;
28593   }
28594 
28595   if (BV_ISSET(fields, 0)) {
28596     log_packet_detailed("  got field 'translation_domain'");
28597     if (!DIO_GET(string, &din, "translation_domain", real_packet->translation_domain, sizeof(real_packet->translation_domain))) {
28598       RECEIVE_PACKET_FIELD_ERROR(translation_domain);
28599     }
28600   }
28601   if (BV_ISSET(fields, 1)) {
28602     log_packet_detailed("  got field 'adjective'");
28603     if (!DIO_GET(string, &din, "adjective", real_packet->adjective, sizeof(real_packet->adjective))) {
28604       RECEIVE_PACKET_FIELD_ERROR(adjective);
28605     }
28606   }
28607   if (BV_ISSET(fields, 2)) {
28608     log_packet_detailed("  got field 'rule_name'");
28609     if (!DIO_GET(string, &din, "rule_name", real_packet->rule_name, sizeof(real_packet->rule_name))) {
28610       RECEIVE_PACKET_FIELD_ERROR(rule_name);
28611     }
28612   }
28613   if (BV_ISSET(fields, 3)) {
28614     log_packet_detailed("  got field 'noun_plural'");
28615     if (!DIO_GET(string, &din, "noun_plural", real_packet->noun_plural, sizeof(real_packet->noun_plural))) {
28616       RECEIVE_PACKET_FIELD_ERROR(noun_plural);
28617     }
28618   }
28619   if (BV_ISSET(fields, 4)) {
28620     log_packet_detailed("  got field 'graphic_str'");
28621     if (!DIO_GET(string, &din, "graphic_str", real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
28622       RECEIVE_PACKET_FIELD_ERROR(graphic_str);
28623     }
28624   }
28625   if (BV_ISSET(fields, 5)) {
28626     log_packet_detailed("  got field 'graphic_alt'");
28627     if (!DIO_GET(string, &din, "graphic_alt", real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
28628       RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
28629     }
28630   }
28631   if (BV_ISSET(fields, 6)) {
28632     log_packet_detailed("  got field 'legend'");
28633     if (!DIO_GET(string, &din, "legend", real_packet->legend, sizeof(real_packet->legend))) {
28634       RECEIVE_PACKET_FIELD_ERROR(legend);
28635     }
28636   }
28637   if (BV_ISSET(fields, 7)) {
28638     log_packet_detailed("  got field 'style'");
28639     if (!DIO_GET(uint8, &din, "style", &real_packet->style)) {
28640       RECEIVE_PACKET_FIELD_ERROR(style);
28641     }
28642   }
28643   if (BV_ISSET(fields, 8)) {
28644     log_packet_detailed("  got field 'leader_count'");
28645     if (!DIO_GET(uint8, &din, "leader_count", &real_packet->leader_count)) {
28646       RECEIVE_PACKET_FIELD_ERROR(leader_count);
28647     }
28648   }
28649   if (BV_ISSET(fields, 9)) {
28650     log_packet_detailed("  got field 'leader_name'");
28651 
28652     {
28653       int i;
28654 
28655       if (real_packet->leader_count > MAX_NUM_LEADERS) {
28656         RECEIVE_PACKET_FIELD_ERROR(leader_name, ": truncation array");
28657       }
28658       for (i = 0; i < real_packet->leader_count; i++) {
28659         if (!DIO_GET(string, &din, "leader_name", real_packet->leader_name[i], sizeof(real_packet->leader_name[i]))) {
28660           RECEIVE_PACKET_FIELD_ERROR(leader_name);
28661         }
28662       }
28663     }
28664   }
28665   if (BV_ISSET(fields, 10)) {
28666     log_packet_detailed("  got field 'leader_is_male'");
28667 
28668     {
28669       int i;
28670 
28671       if (real_packet->leader_count > MAX_NUM_LEADERS) {
28672         RECEIVE_PACKET_FIELD_ERROR(leader_is_male, ": truncation array");
28673       }
28674       for (i = 0; i < real_packet->leader_count; i++) {
28675         if (!DIO_GET(bool8, &din, "leader_is_male", &real_packet->leader_is_male[i])) {
28676           RECEIVE_PACKET_FIELD_ERROR(leader_is_male);
28677         }
28678       }
28679     }
28680   }
28681   real_packet->is_playable = BV_ISSET(fields, 11);
28682   if (BV_ISSET(fields, 12)) {
28683     log_packet_detailed("  got field 'barbarian_type'");
28684     {
28685       int readin;
28686 
28687       if (!DIO_GET(uint8, &din, "barbarian_type", &readin)) {
28688         RECEIVE_PACKET_FIELD_ERROR(barbarian_type);
28689       }
28690       real_packet->barbarian_type = readin;
28691     }
28692   }
28693   if (BV_ISSET(fields, 13)) {
28694     log_packet_detailed("  got field 'nsets'");
28695     if (!DIO_GET(uint8, &din, "nsets", &real_packet->nsets)) {
28696       RECEIVE_PACKET_FIELD_ERROR(nsets);
28697     }
28698   }
28699   if (BV_ISSET(fields, 14)) {
28700     log_packet_detailed("  got field 'sets'");
28701 
28702     {
28703       int i;
28704 
28705       if (real_packet->nsets > MAX_NUM_NATION_SETS) {
28706         RECEIVE_PACKET_FIELD_ERROR(sets, ": truncation array");
28707       }
28708       for (i = 0; i < real_packet->nsets; i++) {
28709         if (!DIO_GET(uint8, &din, "sets", &real_packet->sets[i])) {
28710           RECEIVE_PACKET_FIELD_ERROR(sets);
28711         }
28712       }
28713     }
28714   }
28715   if (BV_ISSET(fields, 15)) {
28716     log_packet_detailed("  got field 'ngroups'");
28717     if (!DIO_GET(uint8, &din, "ngroups", &real_packet->ngroups)) {
28718       RECEIVE_PACKET_FIELD_ERROR(ngroups);
28719     }
28720   }
28721   if (BV_ISSET(fields, 16)) {
28722     log_packet_detailed("  got field 'groups'");
28723 
28724     {
28725       int i;
28726 
28727       if (real_packet->ngroups > MAX_NUM_NATION_GROUPS) {
28728         RECEIVE_PACKET_FIELD_ERROR(groups, ": truncation array");
28729       }
28730       for (i = 0; i < real_packet->ngroups; i++) {
28731         if (!DIO_GET(uint8, &din, "groups", &real_packet->groups[i])) {
28732           RECEIVE_PACKET_FIELD_ERROR(groups);
28733         }
28734       }
28735     }
28736   }
28737   if (BV_ISSET(fields, 17)) {
28738     log_packet_detailed("  got field 'init_government_id'");
28739     {
28740       int readin;
28741 
28742       if (!DIO_GET(sint8, &din, "init_government_id", &readin)) {
28743         RECEIVE_PACKET_FIELD_ERROR(init_government_id);
28744       }
28745       real_packet->init_government_id = readin;
28746     }
28747   }
28748   if (BV_ISSET(fields, 18)) {
28749     log_packet_detailed("  got field 'init_techs'");
28750     if (!DIO_GET(tech_list, &din, "init_techs", real_packet->init_techs)) {
28751       RECEIVE_PACKET_FIELD_ERROR(init_techs);
28752     }
28753   }
28754   if (BV_ISSET(fields, 19)) {
28755     log_packet_detailed("  got field 'init_units'");
28756     if (!DIO_GET(unit_list, &din, "init_units", real_packet->init_units)) {
28757       RECEIVE_PACKET_FIELD_ERROR(init_units);
28758     }
28759   }
28760   if (BV_ISSET(fields, 20)) {
28761     log_packet_detailed("  got field 'init_buildings'");
28762     if (!DIO_GET(building_list, &din, "init_buildings", real_packet->init_buildings)) {
28763       RECEIVE_PACKET_FIELD_ERROR(init_buildings);
28764     }
28765   }
28766 
28767   if (NULL == old) {
28768     old = fc_malloc(sizeof(*old));
28769     *old = *real_packet;
28770     genhash_insert(*hash, old, old);
28771   } else {
28772     *old = *real_packet;
28773   }
28774   RECEIVE_PACKET_END(real_packet);
28775 }
28776 
send_packet_ruleset_nation_100(struct connection * pc,const struct packet_ruleset_nation * packet)28777 static int send_packet_ruleset_nation_100(struct connection *pc, const struct packet_ruleset_nation *packet)
28778 {
28779   const struct packet_ruleset_nation *real_packet = packet;
28780   packet_ruleset_nation_100_fields fields;
28781   struct packet_ruleset_nation *old;
28782   bool differ;
28783   struct genhash **hash = pc->phs.sent + PACKET_RULESET_NATION;
28784   int different = 0;
28785   SEND_PACKET_START(PACKET_RULESET_NATION);
28786 
28787   log_packet_detailed("packet_ruleset_nation_100: sending info about (%d)",
28788     real_packet->id);
28789 
28790   if (NULL == *hash) {
28791     *hash = genhash_new_full(hash_packet_ruleset_nation_100, cmp_packet_ruleset_nation_100,
28792                              NULL, NULL, NULL, free);
28793   }
28794   BV_CLR_ALL(fields);
28795 
28796   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
28797     old = fc_malloc(sizeof(*old));
28798     *old = *real_packet;
28799     genhash_insert(*hash, old, old);
28800     memset(old, 0, sizeof(*old));
28801     different = 1;      /* Force to send. */
28802   }
28803 
28804   differ = (strcmp(old->translation_domain, real_packet->translation_domain) != 0);
28805   if (differ) {
28806     different++;
28807     BV_SET(fields, 0);
28808   }
28809 
28810   differ = (strcmp(old->adjective, real_packet->adjective) != 0);
28811   if (differ) {
28812     different++;
28813     BV_SET(fields, 1);
28814   }
28815 
28816   differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
28817   if (differ) {
28818     different++;
28819     BV_SET(fields, 2);
28820   }
28821 
28822   differ = (strcmp(old->noun_plural, real_packet->noun_plural) != 0);
28823   if (differ) {
28824     different++;
28825     BV_SET(fields, 3);
28826   }
28827 
28828   differ = (strcmp(old->graphic_str, real_packet->graphic_str) != 0);
28829   if (differ) {
28830     different++;
28831     BV_SET(fields, 4);
28832   }
28833 
28834   differ = (strcmp(old->graphic_alt, real_packet->graphic_alt) != 0);
28835   if (differ) {
28836     different++;
28837     BV_SET(fields, 5);
28838   }
28839 
28840   differ = (strcmp(old->legend, real_packet->legend) != 0);
28841   if (differ) {
28842     different++;
28843     BV_SET(fields, 6);
28844   }
28845 
28846   differ = (old->style != real_packet->style);
28847   if (differ) {
28848     different++;
28849     BV_SET(fields, 7);
28850   }
28851 
28852   differ = (old->leader_count != real_packet->leader_count);
28853   if (differ) {
28854     different++;
28855     BV_SET(fields, 8);
28856   }
28857 
28858 
28859     {
28860       differ = (old->leader_count != real_packet->leader_count);
28861       if (!differ) {
28862         int i;
28863 
28864         for (i = 0; i < real_packet->leader_count; i++) {
28865           if (strcmp(old->leader_name[i], real_packet->leader_name[i]) != 0) {
28866             differ = TRUE;
28867             break;
28868           }
28869         }
28870       }
28871     }
28872   if (differ) {
28873     different++;
28874     BV_SET(fields, 9);
28875   }
28876 
28877 
28878     {
28879       differ = (old->leader_count != real_packet->leader_count);
28880       if (!differ) {
28881         int i;
28882 
28883         for (i = 0; i < real_packet->leader_count; i++) {
28884           if (old->leader_is_male[i] != real_packet->leader_is_male[i]) {
28885             differ = TRUE;
28886             break;
28887           }
28888         }
28889       }
28890     }
28891   if (differ) {
28892     different++;
28893     BV_SET(fields, 10);
28894   }
28895 
28896   differ = (old->is_playable != real_packet->is_playable);
28897   if (differ) {
28898     different++;
28899   }
28900   if (packet->is_playable) {
28901     BV_SET(fields, 11);
28902   }
28903 
28904   differ = (old->barbarian_type != real_packet->barbarian_type);
28905   if (differ) {
28906     different++;
28907     BV_SET(fields, 12);
28908   }
28909 
28910   differ = (old->nsets != real_packet->nsets);
28911   if (differ) {
28912     different++;
28913     BV_SET(fields, 13);
28914   }
28915 
28916 
28917     {
28918       differ = (old->nsets != real_packet->nsets);
28919       if (!differ) {
28920         int i;
28921 
28922         for (i = 0; i < real_packet->nsets; i++) {
28923           if (old->sets[i] != real_packet->sets[i]) {
28924             differ = TRUE;
28925             break;
28926           }
28927         }
28928       }
28929     }
28930   if (differ) {
28931     different++;
28932     BV_SET(fields, 14);
28933   }
28934 
28935   differ = (old->ngroups != real_packet->ngroups);
28936   if (differ) {
28937     different++;
28938     BV_SET(fields, 15);
28939   }
28940 
28941 
28942     {
28943       differ = (old->ngroups != real_packet->ngroups);
28944       if (!differ) {
28945         int i;
28946 
28947         for (i = 0; i < real_packet->ngroups; i++) {
28948           if (old->groups[i] != real_packet->groups[i]) {
28949             differ = TRUE;
28950             break;
28951           }
28952         }
28953       }
28954     }
28955   if (differ) {
28956     different++;
28957     BV_SET(fields, 16);
28958   }
28959 
28960   differ = (old->init_government_id != real_packet->init_government_id);
28961   if (differ) {
28962     different++;
28963     BV_SET(fields, 17);
28964   }
28965 
28966 
28967     {
28968       differ = (MAX_NUM_TECH_LIST != MAX_NUM_TECH_LIST);
28969       if (!differ) {
28970         int i;
28971 
28972         for (i = 0; i < MAX_NUM_TECH_LIST; i++) {
28973           if (old->init_techs[i] != real_packet->init_techs[i]) {
28974             differ = TRUE;
28975             break;
28976           }
28977         }
28978       }
28979     }
28980   if (differ) {
28981     different++;
28982     BV_SET(fields, 18);
28983   }
28984 
28985 
28986     {
28987       differ = (MAX_NUM_UNIT_LIST != MAX_NUM_UNIT_LIST);
28988       if (!differ) {
28989         int i;
28990 
28991         for (i = 0; i < MAX_NUM_UNIT_LIST; i++) {
28992           if (old->init_units[i] != real_packet->init_units[i]) {
28993             differ = TRUE;
28994             break;
28995           }
28996         }
28997       }
28998     }
28999   if (differ) {
29000     different++;
29001     BV_SET(fields, 19);
29002   }
29003 
29004 
29005     {
29006       differ = (MAX_NUM_BUILDING_LIST != MAX_NUM_BUILDING_LIST);
29007       if (!differ) {
29008         int i;
29009 
29010         for (i = 0; i < MAX_NUM_BUILDING_LIST; i++) {
29011           if (old->init_buildings[i] != real_packet->init_buildings[i]) {
29012             differ = TRUE;
29013             break;
29014           }
29015         }
29016       }
29017     }
29018   if (differ) {
29019     different++;
29020     BV_SET(fields, 20);
29021   }
29022 
29023 
29024   DIO_BV_PUT(&dout, "fields", fields);
29025   DIO_PUT(sint16, &dout, "id", real_packet->id);
29026 
29027   if (BV_ISSET(fields, 0)) {
29028     log_packet_detailed("  field 'translation_domain' has changed");
29029     DIO_PUT(string, &dout, "translation_domain", real_packet->translation_domain);
29030   }
29031   if (BV_ISSET(fields, 1)) {
29032     log_packet_detailed("  field 'adjective' has changed");
29033     DIO_PUT(string, &dout, "adjective", real_packet->adjective);
29034   }
29035   if (BV_ISSET(fields, 2)) {
29036     log_packet_detailed("  field 'rule_name' has changed");
29037     DIO_PUT(string, &dout, "rule_name", real_packet->rule_name);
29038   }
29039   if (BV_ISSET(fields, 3)) {
29040     log_packet_detailed("  field 'noun_plural' has changed");
29041     DIO_PUT(string, &dout, "noun_plural", real_packet->noun_plural);
29042   }
29043   if (BV_ISSET(fields, 4)) {
29044     log_packet_detailed("  field 'graphic_str' has changed");
29045     DIO_PUT(string, &dout, "graphic_str", real_packet->graphic_str);
29046   }
29047   if (BV_ISSET(fields, 5)) {
29048     log_packet_detailed("  field 'graphic_alt' has changed");
29049     DIO_PUT(string, &dout, "graphic_alt", real_packet->graphic_alt);
29050   }
29051   if (BV_ISSET(fields, 6)) {
29052     log_packet_detailed("  field 'legend' has changed");
29053     DIO_PUT(string, &dout, "legend", real_packet->legend);
29054   }
29055   if (BV_ISSET(fields, 7)) {
29056     log_packet_detailed("  field 'style' has changed");
29057     DIO_PUT(uint8, &dout, "style", real_packet->style);
29058   }
29059   if (BV_ISSET(fields, 8)) {
29060     log_packet_detailed("  field 'leader_count' has changed");
29061     DIO_PUT(uint8, &dout, "leader_count", real_packet->leader_count);
29062   }
29063   if (BV_ISSET(fields, 9)) {
29064     log_packet_detailed("  field 'leader_name' has changed");
29065 
29066     {
29067       int i;
29068 
29069       for (i = 0; i < real_packet->leader_count; i++) {
29070         dio_put_string(&dout, real_packet->leader_name[i]);
29071       }
29072     }
29073   }
29074   if (BV_ISSET(fields, 10)) {
29075     log_packet_detailed("  field 'leader_is_male' has changed");
29076 
29077     {
29078       int i;
29079 
29080       for (i = 0; i < real_packet->leader_count; i++) {
29081         dio_put_bool8(&dout, real_packet->leader_is_male[i]);
29082       }
29083     }
29084   }
29085   /* field 11 is folded into the header */
29086   if (BV_ISSET(fields, 12)) {
29087     log_packet_detailed("  field 'barbarian_type' has changed");
29088     DIO_PUT(uint8, &dout, "barbarian_type", real_packet->barbarian_type);
29089   }
29090   if (BV_ISSET(fields, 13)) {
29091     log_packet_detailed("  field 'nsets' has changed");
29092     DIO_PUT(uint8, &dout, "nsets", real_packet->nsets);
29093   }
29094   if (BV_ISSET(fields, 14)) {
29095     log_packet_detailed("  field 'sets' has changed");
29096 
29097     {
29098       int i;
29099 
29100       for (i = 0; i < real_packet->nsets; i++) {
29101         dio_put_uint8(&dout, real_packet->sets[i]);
29102       }
29103     }
29104   }
29105   if (BV_ISSET(fields, 15)) {
29106     log_packet_detailed("  field 'ngroups' has changed");
29107     DIO_PUT(uint8, &dout, "ngroups", real_packet->ngroups);
29108   }
29109   if (BV_ISSET(fields, 16)) {
29110     log_packet_detailed("  field 'groups' has changed");
29111 
29112     {
29113       int i;
29114 
29115       for (i = 0; i < real_packet->ngroups; i++) {
29116         dio_put_uint8(&dout, real_packet->groups[i]);
29117       }
29118     }
29119   }
29120   if (BV_ISSET(fields, 17)) {
29121     log_packet_detailed("  field 'init_government_id' has changed");
29122     DIO_PUT(sint8, &dout, "init_government_id", real_packet->init_government_id);
29123   }
29124   if (BV_ISSET(fields, 18)) {
29125     log_packet_detailed("  field 'init_techs' has changed");
29126     DIO_PUT(tech_list, &dout, "init_techs", real_packet->init_techs);
29127   }
29128   if (BV_ISSET(fields, 19)) {
29129     log_packet_detailed("  field 'init_units' has changed");
29130     DIO_PUT(unit_list, &dout, "init_units", real_packet->init_units);
29131   }
29132   if (BV_ISSET(fields, 20)) {
29133     log_packet_detailed("  field 'init_buildings' has changed");
29134     DIO_PUT(building_list, &dout, "init_buildings", real_packet->init_buildings);
29135   }
29136 
29137   *old = *real_packet;
29138   SEND_PACKET_END(PACKET_RULESET_NATION);
29139 }
29140 
send_packet_ruleset_nation(struct connection * pc,const struct packet_ruleset_nation * packet)29141 int send_packet_ruleset_nation(struct connection *pc, const struct packet_ruleset_nation *packet)
29142 {
29143   if (!pc->used) {
29144     log_error("WARNING: trying to send data to the closed connection %s",
29145               conn_description(pc));
29146     return -1;
29147   }
29148   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_NATION].packet != NULL, -1,
29149                         "Handler for PACKET_RULESET_NATION not installed");
29150   return pc->phs.handlers->send[PACKET_RULESET_NATION].packet(pc, packet);
29151 }
29152 
lsend_packet_ruleset_nation(struct conn_list * dest,const struct packet_ruleset_nation * packet)29153 void lsend_packet_ruleset_nation(struct conn_list *dest, const struct packet_ruleset_nation *packet)
29154 {
29155   conn_list_iterate(dest, pconn) {
29156     send_packet_ruleset_nation(pconn, packet);
29157   } conn_list_iterate_end;
29158 }
29159 
29160 #define hash_packet_nation_availability_100 hash_const
29161 
29162 #define cmp_packet_nation_availability_100 cmp_const
29163 
29164 BV_DEFINE(packet_nation_availability_100_fields, 3);
29165 
receive_packet_nation_availability_100(struct connection * pc)29166 static struct packet_nation_availability *receive_packet_nation_availability_100(struct connection *pc)
29167 {
29168   packet_nation_availability_100_fields fields;
29169   struct packet_nation_availability *old;
29170   struct genhash **hash = pc->phs.received + PACKET_NATION_AVAILABILITY;
29171   RECEIVE_PACKET_START(packet_nation_availability, real_packet);
29172 
29173   DIO_BV_GET(&din, fields);
29174 
29175   log_packet_detailed("packet_nation_availability_100: got info about ()");
29176 
29177   if (NULL == *hash) {
29178     *hash = genhash_new_full(hash_packet_nation_availability_100, cmp_packet_nation_availability_100,
29179                              NULL, NULL, NULL, free);
29180   }
29181 
29182   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
29183     *real_packet = *old;
29184   } else {
29185     log_packet_detailed("  no old info");
29186     memset(real_packet, 0, sizeof(*real_packet));
29187   }
29188 
29189   if (BV_ISSET(fields, 0)) {
29190     log_packet_detailed("  got field 'ncount'");
29191     if (!DIO_GET(uint16, &din, "ncount", &real_packet->ncount)) {
29192       RECEIVE_PACKET_FIELD_ERROR(ncount);
29193     }
29194   }
29195   if (BV_ISSET(fields, 1)) {
29196     log_packet_detailed("  got field 'is_pickable'");
29197 
29198     {
29199       int i;
29200 
29201       if (real_packet->ncount > MAX_NUM_NATIONS) {
29202         RECEIVE_PACKET_FIELD_ERROR(is_pickable, ": truncation array");
29203       }
29204       for (i = 0; i < real_packet->ncount; i++) {
29205         if (!DIO_GET(bool8, &din, "is_pickable", &real_packet->is_pickable[i])) {
29206           RECEIVE_PACKET_FIELD_ERROR(is_pickable);
29207         }
29208       }
29209     }
29210   }
29211   real_packet->nationset_change = BV_ISSET(fields, 2);
29212 
29213   if (NULL == old) {
29214     old = fc_malloc(sizeof(*old));
29215     *old = *real_packet;
29216     genhash_insert(*hash, old, old);
29217   } else {
29218     *old = *real_packet;
29219   }
29220   RECEIVE_PACKET_END(real_packet);
29221 }
29222 
send_packet_nation_availability_100(struct connection * pc,const struct packet_nation_availability * packet)29223 static int send_packet_nation_availability_100(struct connection *pc, const struct packet_nation_availability *packet)
29224 {
29225   const struct packet_nation_availability *real_packet = packet;
29226   packet_nation_availability_100_fields fields;
29227   struct packet_nation_availability *old;
29228   bool differ;
29229   struct genhash **hash = pc->phs.sent + PACKET_NATION_AVAILABILITY;
29230   int different = 0;
29231   SEND_PACKET_START(PACKET_NATION_AVAILABILITY);
29232 
29233   log_packet_detailed("packet_nation_availability_100: sending info about ()");
29234 
29235   if (NULL == *hash) {
29236     *hash = genhash_new_full(hash_packet_nation_availability_100, cmp_packet_nation_availability_100,
29237                              NULL, NULL, NULL, free);
29238   }
29239   BV_CLR_ALL(fields);
29240 
29241   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
29242     old = fc_malloc(sizeof(*old));
29243     *old = *real_packet;
29244     genhash_insert(*hash, old, old);
29245     memset(old, 0, sizeof(*old));
29246     different = 1;      /* Force to send. */
29247   }
29248 
29249   differ = (old->ncount != real_packet->ncount);
29250   if (differ) {
29251     different++;
29252     BV_SET(fields, 0);
29253   }
29254 
29255 
29256     {
29257       differ = (old->ncount != real_packet->ncount);
29258       if (!differ) {
29259         int i;
29260 
29261         for (i = 0; i < real_packet->ncount; i++) {
29262           if (old->is_pickable[i] != real_packet->is_pickable[i]) {
29263             differ = TRUE;
29264             break;
29265           }
29266         }
29267       }
29268     }
29269   if (differ) {
29270     different++;
29271     BV_SET(fields, 1);
29272   }
29273 
29274   differ = (old->nationset_change != real_packet->nationset_change);
29275   if (differ) {
29276     different++;
29277   }
29278   if (packet->nationset_change) {
29279     BV_SET(fields, 2);
29280   }
29281 
29282 
29283   DIO_BV_PUT(&dout, "fields", fields);
29284 
29285   if (BV_ISSET(fields, 0)) {
29286     log_packet_detailed("  field 'ncount' has changed");
29287     DIO_PUT(uint16, &dout, "ncount", real_packet->ncount);
29288   }
29289   if (BV_ISSET(fields, 1)) {
29290     log_packet_detailed("  field 'is_pickable' has changed");
29291 
29292     {
29293       int i;
29294 
29295       for (i = 0; i < real_packet->ncount; i++) {
29296         dio_put_bool8(&dout, real_packet->is_pickable[i]);
29297       }
29298     }
29299   }
29300   /* field 2 is folded into the header */
29301 
29302   *old = *real_packet;
29303   SEND_PACKET_END(PACKET_NATION_AVAILABILITY);
29304 }
29305 
send_packet_nation_availability(struct connection * pc,const struct packet_nation_availability * packet)29306 int send_packet_nation_availability(struct connection *pc, const struct packet_nation_availability *packet)
29307 {
29308   if (!pc->used) {
29309     log_error("WARNING: trying to send data to the closed connection %s",
29310               conn_description(pc));
29311     return -1;
29312   }
29313   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_NATION_AVAILABILITY].packet != NULL, -1,
29314                         "Handler for PACKET_NATION_AVAILABILITY not installed");
29315   return pc->phs.handlers->send[PACKET_NATION_AVAILABILITY].packet(pc, packet);
29316 }
29317 
lsend_packet_nation_availability(struct conn_list * dest,const struct packet_nation_availability * packet)29318 void lsend_packet_nation_availability(struct conn_list *dest, const struct packet_nation_availability *packet)
29319 {
29320   conn_list_iterate(dest, pconn) {
29321     send_packet_nation_availability(pconn, packet);
29322   } conn_list_iterate_end;
29323 }
29324 
29325 #define hash_packet_ruleset_style_100 hash_const
29326 
29327 #define cmp_packet_ruleset_style_100 cmp_const
29328 
29329 BV_DEFINE(packet_ruleset_style_100_fields, 3);
29330 
receive_packet_ruleset_style_100(struct connection * pc)29331 static struct packet_ruleset_style *receive_packet_ruleset_style_100(struct connection *pc)
29332 {
29333   packet_ruleset_style_100_fields fields;
29334   struct packet_ruleset_style *old;
29335   struct genhash **hash = pc->phs.received + PACKET_RULESET_STYLE;
29336   RECEIVE_PACKET_START(packet_ruleset_style, real_packet);
29337 
29338   DIO_BV_GET(&din, fields);
29339 
29340   log_packet_detailed("packet_ruleset_style_100: got info about ()");
29341 
29342   if (NULL == *hash) {
29343     *hash = genhash_new_full(hash_packet_ruleset_style_100, cmp_packet_ruleset_style_100,
29344                              NULL, NULL, NULL, free);
29345   }
29346 
29347   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
29348     *real_packet = *old;
29349   } else {
29350     log_packet_detailed("  no old info");
29351     memset(real_packet, 0, sizeof(*real_packet));
29352   }
29353 
29354   if (BV_ISSET(fields, 0)) {
29355     log_packet_detailed("  got field 'id'");
29356     if (!DIO_GET(uint8, &din, "id", &real_packet->id)) {
29357       RECEIVE_PACKET_FIELD_ERROR(id);
29358     }
29359   }
29360   if (BV_ISSET(fields, 1)) {
29361     log_packet_detailed("  got field 'name'");
29362     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
29363       RECEIVE_PACKET_FIELD_ERROR(name);
29364     }
29365   }
29366   if (BV_ISSET(fields, 2)) {
29367     log_packet_detailed("  got field 'rule_name'");
29368     if (!DIO_GET(string, &din, "rule_name", real_packet->rule_name, sizeof(real_packet->rule_name))) {
29369       RECEIVE_PACKET_FIELD_ERROR(rule_name);
29370     }
29371   }
29372 
29373   if (NULL == old) {
29374     old = fc_malloc(sizeof(*old));
29375     *old = *real_packet;
29376     genhash_insert(*hash, old, old);
29377   } else {
29378     *old = *real_packet;
29379   }
29380   RECEIVE_PACKET_END(real_packet);
29381 }
29382 
send_packet_ruleset_style_100(struct connection * pc,const struct packet_ruleset_style * packet)29383 static int send_packet_ruleset_style_100(struct connection *pc, const struct packet_ruleset_style *packet)
29384 {
29385   const struct packet_ruleset_style *real_packet = packet;
29386   packet_ruleset_style_100_fields fields;
29387   struct packet_ruleset_style *old;
29388   bool differ;
29389   struct genhash **hash = pc->phs.sent + PACKET_RULESET_STYLE;
29390   int different = 0;
29391   SEND_PACKET_START(PACKET_RULESET_STYLE);
29392 
29393   log_packet_detailed("packet_ruleset_style_100: sending info about ()");
29394 
29395   if (NULL == *hash) {
29396     *hash = genhash_new_full(hash_packet_ruleset_style_100, cmp_packet_ruleset_style_100,
29397                              NULL, NULL, NULL, free);
29398   }
29399   BV_CLR_ALL(fields);
29400 
29401   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
29402     old = fc_malloc(sizeof(*old));
29403     *old = *real_packet;
29404     genhash_insert(*hash, old, old);
29405     memset(old, 0, sizeof(*old));
29406     different = 1;      /* Force to send. */
29407   }
29408 
29409   differ = (old->id != real_packet->id);
29410   if (differ) {
29411     different++;
29412     BV_SET(fields, 0);
29413   }
29414 
29415   differ = (strcmp(old->name, real_packet->name) != 0);
29416   if (differ) {
29417     different++;
29418     BV_SET(fields, 1);
29419   }
29420 
29421   differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
29422   if (differ) {
29423     different++;
29424     BV_SET(fields, 2);
29425   }
29426 
29427 
29428   DIO_BV_PUT(&dout, "fields", fields);
29429 
29430   if (BV_ISSET(fields, 0)) {
29431     log_packet_detailed("  field 'id' has changed");
29432     DIO_PUT(uint8, &dout, "id", real_packet->id);
29433   }
29434   if (BV_ISSET(fields, 1)) {
29435     log_packet_detailed("  field 'name' has changed");
29436     DIO_PUT(string, &dout, "name", real_packet->name);
29437   }
29438   if (BV_ISSET(fields, 2)) {
29439     log_packet_detailed("  field 'rule_name' has changed");
29440     DIO_PUT(string, &dout, "rule_name", real_packet->rule_name);
29441   }
29442 
29443   *old = *real_packet;
29444   SEND_PACKET_END(PACKET_RULESET_STYLE);
29445 }
29446 
send_packet_ruleset_style(struct connection * pc,const struct packet_ruleset_style * packet)29447 int send_packet_ruleset_style(struct connection *pc, const struct packet_ruleset_style *packet)
29448 {
29449   if (!pc->used) {
29450     log_error("WARNING: trying to send data to the closed connection %s",
29451               conn_description(pc));
29452     return -1;
29453   }
29454   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_STYLE].packet != NULL, -1,
29455                         "Handler for PACKET_RULESET_STYLE not installed");
29456   return pc->phs.handlers->send[PACKET_RULESET_STYLE].packet(pc, packet);
29457 }
29458 
lsend_packet_ruleset_style(struct conn_list * dest,const struct packet_ruleset_style * packet)29459 void lsend_packet_ruleset_style(struct conn_list *dest, const struct packet_ruleset_style *packet)
29460 {
29461   conn_list_iterate(dest, pconn) {
29462     send_packet_ruleset_style(pconn, packet);
29463   } conn_list_iterate_end;
29464 }
29465 
29466 #define hash_packet_ruleset_city_100 hash_const
29467 
29468 #define cmp_packet_ruleset_city_100 cmp_const
29469 
29470 BV_DEFINE(packet_ruleset_city_100_fields, 9);
29471 
receive_packet_ruleset_city_100(struct connection * pc)29472 static struct packet_ruleset_city *receive_packet_ruleset_city_100(struct connection *pc)
29473 {
29474   packet_ruleset_city_100_fields fields;
29475   struct packet_ruleset_city *old;
29476   struct genhash **hash = pc->phs.received + PACKET_RULESET_CITY;
29477   RECEIVE_PACKET_START(packet_ruleset_city, real_packet);
29478 
29479   DIO_BV_GET(&din, fields);
29480 
29481   log_packet_detailed("packet_ruleset_city_100: got info about ()");
29482 
29483   if (NULL == *hash) {
29484     *hash = genhash_new_full(hash_packet_ruleset_city_100, cmp_packet_ruleset_city_100,
29485                              NULL, NULL, NULL, free);
29486   }
29487 
29488   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
29489     *real_packet = *old;
29490   } else {
29491     log_packet_detailed("  no old info");
29492     memset(real_packet, 0, sizeof(*real_packet));
29493   }
29494 
29495   if (BV_ISSET(fields, 0)) {
29496     log_packet_detailed("  got field 'style_id'");
29497     if (!DIO_GET(uint8, &din, "style_id", &real_packet->style_id)) {
29498       RECEIVE_PACKET_FIELD_ERROR(style_id);
29499     }
29500   }
29501   if (BV_ISSET(fields, 1)) {
29502     log_packet_detailed("  got field 'name'");
29503     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
29504       RECEIVE_PACKET_FIELD_ERROR(name);
29505     }
29506   }
29507   if (BV_ISSET(fields, 2)) {
29508     log_packet_detailed("  got field 'rule_name'");
29509     if (!DIO_GET(string, &din, "rule_name", real_packet->rule_name, sizeof(real_packet->rule_name))) {
29510       RECEIVE_PACKET_FIELD_ERROR(rule_name);
29511     }
29512   }
29513   if (BV_ISSET(fields, 3)) {
29514     log_packet_detailed("  got field 'citizens_graphic'");
29515     if (!DIO_GET(string, &din, "citizens_graphic", real_packet->citizens_graphic, sizeof(real_packet->citizens_graphic))) {
29516       RECEIVE_PACKET_FIELD_ERROR(citizens_graphic);
29517     }
29518   }
29519   if (BV_ISSET(fields, 4)) {
29520     log_packet_detailed("  got field 'citizens_graphic_alt'");
29521     if (!DIO_GET(string, &din, "citizens_graphic_alt", real_packet->citizens_graphic_alt, sizeof(real_packet->citizens_graphic_alt))) {
29522       RECEIVE_PACKET_FIELD_ERROR(citizens_graphic_alt);
29523     }
29524   }
29525   if (BV_ISSET(fields, 5)) {
29526     log_packet_detailed("  got field 'reqs_count'");
29527     if (!DIO_GET(uint8, &din, "reqs_count", &real_packet->reqs_count)) {
29528       RECEIVE_PACKET_FIELD_ERROR(reqs_count);
29529     }
29530   }
29531   if (BV_ISSET(fields, 6)) {
29532     log_packet_detailed("  got field 'reqs'");
29533 
29534     {
29535       int i;
29536 
29537       if (real_packet->reqs_count > MAX_NUM_REQS) {
29538         RECEIVE_PACKET_FIELD_ERROR(reqs, ": truncation array");
29539       }
29540       for (i = 0; i < real_packet->reqs_count; i++) {
29541         if (!DIO_GET(requirement, &din, "reqs", &real_packet->reqs[i])) {
29542           RECEIVE_PACKET_FIELD_ERROR(reqs);
29543         }
29544       }
29545     }
29546   }
29547   if (BV_ISSET(fields, 7)) {
29548     log_packet_detailed("  got field 'graphic'");
29549     if (!DIO_GET(string, &din, "graphic", real_packet->graphic, sizeof(real_packet->graphic))) {
29550       RECEIVE_PACKET_FIELD_ERROR(graphic);
29551     }
29552   }
29553   if (BV_ISSET(fields, 8)) {
29554     log_packet_detailed("  got field 'graphic_alt'");
29555     if (!DIO_GET(string, &din, "graphic_alt", real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
29556       RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
29557     }
29558   }
29559 
29560   if (NULL == old) {
29561     old = fc_malloc(sizeof(*old));
29562     *old = *real_packet;
29563     genhash_insert(*hash, old, old);
29564   } else {
29565     *old = *real_packet;
29566   }
29567   RECEIVE_PACKET_END(real_packet);
29568 }
29569 
send_packet_ruleset_city_100(struct connection * pc,const struct packet_ruleset_city * packet)29570 static int send_packet_ruleset_city_100(struct connection *pc, const struct packet_ruleset_city *packet)
29571 {
29572   const struct packet_ruleset_city *real_packet = packet;
29573   packet_ruleset_city_100_fields fields;
29574   struct packet_ruleset_city *old;
29575   bool differ;
29576   struct genhash **hash = pc->phs.sent + PACKET_RULESET_CITY;
29577   int different = 0;
29578   SEND_PACKET_START(PACKET_RULESET_CITY);
29579 
29580   log_packet_detailed("packet_ruleset_city_100: sending info about ()");
29581 
29582   if (NULL == *hash) {
29583     *hash = genhash_new_full(hash_packet_ruleset_city_100, cmp_packet_ruleset_city_100,
29584                              NULL, NULL, NULL, free);
29585   }
29586   BV_CLR_ALL(fields);
29587 
29588   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
29589     old = fc_malloc(sizeof(*old));
29590     *old = *real_packet;
29591     genhash_insert(*hash, old, old);
29592     memset(old, 0, sizeof(*old));
29593     different = 1;      /* Force to send. */
29594   }
29595 
29596   differ = (old->style_id != real_packet->style_id);
29597   if (differ) {
29598     different++;
29599     BV_SET(fields, 0);
29600   }
29601 
29602   differ = (strcmp(old->name, real_packet->name) != 0);
29603   if (differ) {
29604     different++;
29605     BV_SET(fields, 1);
29606   }
29607 
29608   differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
29609   if (differ) {
29610     different++;
29611     BV_SET(fields, 2);
29612   }
29613 
29614   differ = (strcmp(old->citizens_graphic, real_packet->citizens_graphic) != 0);
29615   if (differ) {
29616     different++;
29617     BV_SET(fields, 3);
29618   }
29619 
29620   differ = (strcmp(old->citizens_graphic_alt, real_packet->citizens_graphic_alt) != 0);
29621   if (differ) {
29622     different++;
29623     BV_SET(fields, 4);
29624   }
29625 
29626   differ = (old->reqs_count != real_packet->reqs_count);
29627   if (differ) {
29628     different++;
29629     BV_SET(fields, 5);
29630   }
29631 
29632 
29633     {
29634       differ = (old->reqs_count != real_packet->reqs_count);
29635       if (!differ) {
29636         int i;
29637 
29638         for (i = 0; i < real_packet->reqs_count; i++) {
29639           if (!are_requirements_equal(&old->reqs[i], &real_packet->reqs[i])) {
29640             differ = TRUE;
29641             break;
29642           }
29643         }
29644       }
29645     }
29646   if (differ) {
29647     different++;
29648     BV_SET(fields, 6);
29649   }
29650 
29651   differ = (strcmp(old->graphic, real_packet->graphic) != 0);
29652   if (differ) {
29653     different++;
29654     BV_SET(fields, 7);
29655   }
29656 
29657   differ = (strcmp(old->graphic_alt, real_packet->graphic_alt) != 0);
29658   if (differ) {
29659     different++;
29660     BV_SET(fields, 8);
29661   }
29662 
29663 
29664   DIO_BV_PUT(&dout, "fields", fields);
29665 
29666   if (BV_ISSET(fields, 0)) {
29667     log_packet_detailed("  field 'style_id' has changed");
29668     DIO_PUT(uint8, &dout, "style_id", real_packet->style_id);
29669   }
29670   if (BV_ISSET(fields, 1)) {
29671     log_packet_detailed("  field 'name' has changed");
29672     DIO_PUT(string, &dout, "name", real_packet->name);
29673   }
29674   if (BV_ISSET(fields, 2)) {
29675     log_packet_detailed("  field 'rule_name' has changed");
29676     DIO_PUT(string, &dout, "rule_name", real_packet->rule_name);
29677   }
29678   if (BV_ISSET(fields, 3)) {
29679     log_packet_detailed("  field 'citizens_graphic' has changed");
29680     DIO_PUT(string, &dout, "citizens_graphic", real_packet->citizens_graphic);
29681   }
29682   if (BV_ISSET(fields, 4)) {
29683     log_packet_detailed("  field 'citizens_graphic_alt' has changed");
29684     DIO_PUT(string, &dout, "citizens_graphic_alt", real_packet->citizens_graphic_alt);
29685   }
29686   if (BV_ISSET(fields, 5)) {
29687     log_packet_detailed("  field 'reqs_count' has changed");
29688     DIO_PUT(uint8, &dout, "reqs_count", real_packet->reqs_count);
29689   }
29690   if (BV_ISSET(fields, 6)) {
29691     log_packet_detailed("  field 'reqs' has changed");
29692 
29693     {
29694       int i;
29695 
29696       for (i = 0; i < real_packet->reqs_count; i++) {
29697         dio_put_requirement(&dout, &real_packet->reqs[i]);
29698       }
29699     }
29700   }
29701   if (BV_ISSET(fields, 7)) {
29702     log_packet_detailed("  field 'graphic' has changed");
29703     DIO_PUT(string, &dout, "graphic", real_packet->graphic);
29704   }
29705   if (BV_ISSET(fields, 8)) {
29706     log_packet_detailed("  field 'graphic_alt' has changed");
29707     DIO_PUT(string, &dout, "graphic_alt", real_packet->graphic_alt);
29708   }
29709 
29710   *old = *real_packet;
29711   SEND_PACKET_END(PACKET_RULESET_CITY);
29712 }
29713 
send_packet_ruleset_city(struct connection * pc,const struct packet_ruleset_city * packet)29714 int send_packet_ruleset_city(struct connection *pc, const struct packet_ruleset_city *packet)
29715 {
29716   if (!pc->used) {
29717     log_error("WARNING: trying to send data to the closed connection %s",
29718               conn_description(pc));
29719     return -1;
29720   }
29721   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_CITY].packet != NULL, -1,
29722                         "Handler for PACKET_RULESET_CITY not installed");
29723   return pc->phs.handlers->send[PACKET_RULESET_CITY].packet(pc, packet);
29724 }
29725 
lsend_packet_ruleset_city(struct conn_list * dest,const struct packet_ruleset_city * packet)29726 void lsend_packet_ruleset_city(struct conn_list *dest, const struct packet_ruleset_city *packet)
29727 {
29728   conn_list_iterate(dest, pconn) {
29729     send_packet_ruleset_city(pconn, packet);
29730   } conn_list_iterate_end;
29731 }
29732 
29733 #define hash_packet_ruleset_building_100 hash_const
29734 
29735 #define cmp_packet_ruleset_building_100 cmp_const
29736 
29737 BV_DEFINE(packet_ruleset_building_100_fields, 17);
29738 
receive_packet_ruleset_building_100(struct connection * pc)29739 static struct packet_ruleset_building *receive_packet_ruleset_building_100(struct connection *pc)
29740 {
29741   packet_ruleset_building_100_fields fields;
29742   struct packet_ruleset_building *old;
29743   struct genhash **hash = pc->phs.received + PACKET_RULESET_BUILDING;
29744   RECEIVE_PACKET_START(packet_ruleset_building, real_packet);
29745 
29746   DIO_BV_GET(&din, fields);
29747 
29748   log_packet_detailed("packet_ruleset_building_100: got info about ()");
29749 
29750   if (NULL == *hash) {
29751     *hash = genhash_new_full(hash_packet_ruleset_building_100, cmp_packet_ruleset_building_100,
29752                              NULL, NULL, NULL, free);
29753   }
29754 
29755   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
29756     *real_packet = *old;
29757   } else {
29758     log_packet_detailed("  no old info");
29759     memset(real_packet, 0, sizeof(*real_packet));
29760   }
29761 
29762   if (BV_ISSET(fields, 0)) {
29763     log_packet_detailed("  got field 'id'");
29764     {
29765       int readin;
29766 
29767       if (!DIO_GET(uint8, &din, "id", &readin)) {
29768         RECEIVE_PACKET_FIELD_ERROR(id);
29769       }
29770       real_packet->id = readin;
29771     }
29772   }
29773   if (BV_ISSET(fields, 1)) {
29774     log_packet_detailed("  got field 'genus'");
29775     {
29776       int readin;
29777 
29778       if (!DIO_GET(uint8, &din, "genus", &readin)) {
29779         RECEIVE_PACKET_FIELD_ERROR(genus);
29780       }
29781       real_packet->genus = readin;
29782     }
29783   }
29784   if (BV_ISSET(fields, 2)) {
29785     log_packet_detailed("  got field 'name'");
29786     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
29787       RECEIVE_PACKET_FIELD_ERROR(name);
29788     }
29789   }
29790   if (BV_ISSET(fields, 3)) {
29791     log_packet_detailed("  got field 'rule_name'");
29792     if (!DIO_GET(string, &din, "rule_name", real_packet->rule_name, sizeof(real_packet->rule_name))) {
29793       RECEIVE_PACKET_FIELD_ERROR(rule_name);
29794     }
29795   }
29796   if (BV_ISSET(fields, 4)) {
29797     log_packet_detailed("  got field 'graphic_str'");
29798     if (!DIO_GET(string, &din, "graphic_str", real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
29799       RECEIVE_PACKET_FIELD_ERROR(graphic_str);
29800     }
29801   }
29802   if (BV_ISSET(fields, 5)) {
29803     log_packet_detailed("  got field 'graphic_alt'");
29804     if (!DIO_GET(string, &din, "graphic_alt", real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
29805       RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
29806     }
29807   }
29808   if (BV_ISSET(fields, 6)) {
29809     log_packet_detailed("  got field 'reqs_count'");
29810     if (!DIO_GET(uint8, &din, "reqs_count", &real_packet->reqs_count)) {
29811       RECEIVE_PACKET_FIELD_ERROR(reqs_count);
29812     }
29813   }
29814   if (BV_ISSET(fields, 7)) {
29815     log_packet_detailed("  got field 'reqs'");
29816 
29817     {
29818       int i;
29819 
29820       if (real_packet->reqs_count > MAX_NUM_REQS) {
29821         RECEIVE_PACKET_FIELD_ERROR(reqs, ": truncation array");
29822       }
29823       for (i = 0; i < real_packet->reqs_count; i++) {
29824         if (!DIO_GET(requirement, &din, "reqs", &real_packet->reqs[i])) {
29825           RECEIVE_PACKET_FIELD_ERROR(reqs);
29826         }
29827       }
29828     }
29829   }
29830   if (BV_ISSET(fields, 8)) {
29831     log_packet_detailed("  got field 'obs_count'");
29832     if (!DIO_GET(uint8, &din, "obs_count", &real_packet->obs_count)) {
29833       RECEIVE_PACKET_FIELD_ERROR(obs_count);
29834     }
29835   }
29836   if (BV_ISSET(fields, 9)) {
29837     log_packet_detailed("  got field 'obs_reqs'");
29838 
29839     {
29840       int i;
29841 
29842       if (real_packet->obs_count > MAX_NUM_REQS) {
29843         RECEIVE_PACKET_FIELD_ERROR(obs_reqs, ": truncation array");
29844       }
29845       for (i = 0; i < real_packet->obs_count; i++) {
29846         if (!DIO_GET(requirement, &din, "obs_reqs", &real_packet->obs_reqs[i])) {
29847           RECEIVE_PACKET_FIELD_ERROR(obs_reqs);
29848         }
29849       }
29850     }
29851   }
29852   if (BV_ISSET(fields, 10)) {
29853     log_packet_detailed("  got field 'build_cost'");
29854     if (!DIO_GET(uint16, &din, "build_cost", &real_packet->build_cost)) {
29855       RECEIVE_PACKET_FIELD_ERROR(build_cost);
29856     }
29857   }
29858   if (BV_ISSET(fields, 11)) {
29859     log_packet_detailed("  got field 'upkeep'");
29860     if (!DIO_GET(uint8, &din, "upkeep", &real_packet->upkeep)) {
29861       RECEIVE_PACKET_FIELD_ERROR(upkeep);
29862     }
29863   }
29864   if (BV_ISSET(fields, 12)) {
29865     log_packet_detailed("  got field 'sabotage'");
29866     if (!DIO_GET(uint8, &din, "sabotage", &real_packet->sabotage)) {
29867       RECEIVE_PACKET_FIELD_ERROR(sabotage);
29868     }
29869   }
29870   if (BV_ISSET(fields, 13)) {
29871     log_packet_detailed("  got field 'flags'");
29872     if (!DIO_BV_GET(&din, real_packet->flags)) {
29873       RECEIVE_PACKET_FIELD_ERROR(flags);
29874     }
29875   }
29876   if (BV_ISSET(fields, 14)) {
29877     log_packet_detailed("  got field 'soundtag'");
29878     if (!DIO_GET(string, &din, "soundtag", real_packet->soundtag, sizeof(real_packet->soundtag))) {
29879       RECEIVE_PACKET_FIELD_ERROR(soundtag);
29880     }
29881   }
29882   if (BV_ISSET(fields, 15)) {
29883     log_packet_detailed("  got field 'soundtag_alt'");
29884     if (!DIO_GET(string, &din, "soundtag_alt", real_packet->soundtag_alt, sizeof(real_packet->soundtag_alt))) {
29885       RECEIVE_PACKET_FIELD_ERROR(soundtag_alt);
29886     }
29887   }
29888   if (BV_ISSET(fields, 16)) {
29889     log_packet_detailed("  got field 'helptext'");
29890     if (!DIO_GET(string, &din, "helptext", real_packet->helptext, sizeof(real_packet->helptext))) {
29891       RECEIVE_PACKET_FIELD_ERROR(helptext);
29892     }
29893   }
29894 
29895   if (NULL == old) {
29896     old = fc_malloc(sizeof(*old));
29897     *old = *real_packet;
29898     genhash_insert(*hash, old, old);
29899   } else {
29900     *old = *real_packet;
29901   }
29902   RECEIVE_PACKET_END(real_packet);
29903 }
29904 
send_packet_ruleset_building_100(struct connection * pc,const struct packet_ruleset_building * packet)29905 static int send_packet_ruleset_building_100(struct connection *pc, const struct packet_ruleset_building *packet)
29906 {
29907   const struct packet_ruleset_building *real_packet = packet;
29908   packet_ruleset_building_100_fields fields;
29909   struct packet_ruleset_building *old;
29910   bool differ;
29911   struct genhash **hash = pc->phs.sent + PACKET_RULESET_BUILDING;
29912   int different = 0;
29913   SEND_PACKET_START(PACKET_RULESET_BUILDING);
29914 
29915   log_packet_detailed("packet_ruleset_building_100: sending info about ()");
29916 
29917   if (NULL == *hash) {
29918     *hash = genhash_new_full(hash_packet_ruleset_building_100, cmp_packet_ruleset_building_100,
29919                              NULL, NULL, NULL, free);
29920   }
29921   BV_CLR_ALL(fields);
29922 
29923   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
29924     old = fc_malloc(sizeof(*old));
29925     *old = *real_packet;
29926     genhash_insert(*hash, old, old);
29927     memset(old, 0, sizeof(*old));
29928     different = 1;      /* Force to send. */
29929   }
29930 
29931   differ = (old->id != real_packet->id);
29932   if (differ) {
29933     different++;
29934     BV_SET(fields, 0);
29935   }
29936 
29937   differ = (old->genus != real_packet->genus);
29938   if (differ) {
29939     different++;
29940     BV_SET(fields, 1);
29941   }
29942 
29943   differ = (strcmp(old->name, real_packet->name) != 0);
29944   if (differ) {
29945     different++;
29946     BV_SET(fields, 2);
29947   }
29948 
29949   differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
29950   if (differ) {
29951     different++;
29952     BV_SET(fields, 3);
29953   }
29954 
29955   differ = (strcmp(old->graphic_str, real_packet->graphic_str) != 0);
29956   if (differ) {
29957     different++;
29958     BV_SET(fields, 4);
29959   }
29960 
29961   differ = (strcmp(old->graphic_alt, real_packet->graphic_alt) != 0);
29962   if (differ) {
29963     different++;
29964     BV_SET(fields, 5);
29965   }
29966 
29967   differ = (old->reqs_count != real_packet->reqs_count);
29968   if (differ) {
29969     different++;
29970     BV_SET(fields, 6);
29971   }
29972 
29973 
29974     {
29975       differ = (old->reqs_count != real_packet->reqs_count);
29976       if (!differ) {
29977         int i;
29978 
29979         for (i = 0; i < real_packet->reqs_count; i++) {
29980           if (!are_requirements_equal(&old->reqs[i], &real_packet->reqs[i])) {
29981             differ = TRUE;
29982             break;
29983           }
29984         }
29985       }
29986     }
29987   if (differ) {
29988     different++;
29989     BV_SET(fields, 7);
29990   }
29991 
29992   differ = (old->obs_count != real_packet->obs_count);
29993   if (differ) {
29994     different++;
29995     BV_SET(fields, 8);
29996   }
29997 
29998 
29999     {
30000       differ = (old->obs_count != real_packet->obs_count);
30001       if (!differ) {
30002         int i;
30003 
30004         for (i = 0; i < real_packet->obs_count; i++) {
30005           if (!are_requirements_equal(&old->obs_reqs[i], &real_packet->obs_reqs[i])) {
30006             differ = TRUE;
30007             break;
30008           }
30009         }
30010       }
30011     }
30012   if (differ) {
30013     different++;
30014     BV_SET(fields, 9);
30015   }
30016 
30017   differ = (old->build_cost != real_packet->build_cost);
30018   if (differ) {
30019     different++;
30020     BV_SET(fields, 10);
30021   }
30022 
30023   differ = (old->upkeep != real_packet->upkeep);
30024   if (differ) {
30025     different++;
30026     BV_SET(fields, 11);
30027   }
30028 
30029   differ = (old->sabotage != real_packet->sabotage);
30030   if (differ) {
30031     different++;
30032     BV_SET(fields, 12);
30033   }
30034 
30035   differ = !BV_ARE_EQUAL(old->flags, real_packet->flags);
30036   if (differ) {
30037     different++;
30038     BV_SET(fields, 13);
30039   }
30040 
30041   differ = (strcmp(old->soundtag, real_packet->soundtag) != 0);
30042   if (differ) {
30043     different++;
30044     BV_SET(fields, 14);
30045   }
30046 
30047   differ = (strcmp(old->soundtag_alt, real_packet->soundtag_alt) != 0);
30048   if (differ) {
30049     different++;
30050     BV_SET(fields, 15);
30051   }
30052 
30053   differ = (strcmp(old->helptext, real_packet->helptext) != 0);
30054   if (differ) {
30055     different++;
30056     BV_SET(fields, 16);
30057   }
30058 
30059 
30060   DIO_BV_PUT(&dout, "fields", fields);
30061 
30062   if (BV_ISSET(fields, 0)) {
30063     log_packet_detailed("  field 'id' has changed");
30064     DIO_PUT(uint8, &dout, "id", real_packet->id);
30065   }
30066   if (BV_ISSET(fields, 1)) {
30067     log_packet_detailed("  field 'genus' has changed");
30068     DIO_PUT(uint8, &dout, "genus", real_packet->genus);
30069   }
30070   if (BV_ISSET(fields, 2)) {
30071     log_packet_detailed("  field 'name' has changed");
30072     DIO_PUT(string, &dout, "name", real_packet->name);
30073   }
30074   if (BV_ISSET(fields, 3)) {
30075     log_packet_detailed("  field 'rule_name' has changed");
30076     DIO_PUT(string, &dout, "rule_name", real_packet->rule_name);
30077   }
30078   if (BV_ISSET(fields, 4)) {
30079     log_packet_detailed("  field 'graphic_str' has changed");
30080     DIO_PUT(string, &dout, "graphic_str", real_packet->graphic_str);
30081   }
30082   if (BV_ISSET(fields, 5)) {
30083     log_packet_detailed("  field 'graphic_alt' has changed");
30084     DIO_PUT(string, &dout, "graphic_alt", real_packet->graphic_alt);
30085   }
30086   if (BV_ISSET(fields, 6)) {
30087     log_packet_detailed("  field 'reqs_count' has changed");
30088     DIO_PUT(uint8, &dout, "reqs_count", real_packet->reqs_count);
30089   }
30090   if (BV_ISSET(fields, 7)) {
30091     log_packet_detailed("  field 'reqs' has changed");
30092 
30093     {
30094       int i;
30095 
30096       for (i = 0; i < real_packet->reqs_count; i++) {
30097         dio_put_requirement(&dout, &real_packet->reqs[i]);
30098       }
30099     }
30100   }
30101   if (BV_ISSET(fields, 8)) {
30102     log_packet_detailed("  field 'obs_count' has changed");
30103     DIO_PUT(uint8, &dout, "obs_count", real_packet->obs_count);
30104   }
30105   if (BV_ISSET(fields, 9)) {
30106     log_packet_detailed("  field 'obs_reqs' has changed");
30107 
30108     {
30109       int i;
30110 
30111       for (i = 0; i < real_packet->obs_count; i++) {
30112         dio_put_requirement(&dout, &real_packet->obs_reqs[i]);
30113       }
30114     }
30115   }
30116   if (BV_ISSET(fields, 10)) {
30117     log_packet_detailed("  field 'build_cost' has changed");
30118     DIO_PUT(uint16, &dout, "build_cost", real_packet->build_cost);
30119   }
30120   if (BV_ISSET(fields, 11)) {
30121     log_packet_detailed("  field 'upkeep' has changed");
30122     DIO_PUT(uint8, &dout, "upkeep", real_packet->upkeep);
30123   }
30124   if (BV_ISSET(fields, 12)) {
30125     log_packet_detailed("  field 'sabotage' has changed");
30126     DIO_PUT(uint8, &dout, "sabotage", real_packet->sabotage);
30127   }
30128   if (BV_ISSET(fields, 13)) {
30129     log_packet_detailed("  field 'flags' has changed");
30130   DIO_BV_PUT(&dout, "flags", packet->flags);
30131   }
30132   if (BV_ISSET(fields, 14)) {
30133     log_packet_detailed("  field 'soundtag' has changed");
30134     DIO_PUT(string, &dout, "soundtag", real_packet->soundtag);
30135   }
30136   if (BV_ISSET(fields, 15)) {
30137     log_packet_detailed("  field 'soundtag_alt' has changed");
30138     DIO_PUT(string, &dout, "soundtag_alt", real_packet->soundtag_alt);
30139   }
30140   if (BV_ISSET(fields, 16)) {
30141     log_packet_detailed("  field 'helptext' has changed");
30142     DIO_PUT(string, &dout, "helptext", real_packet->helptext);
30143   }
30144 
30145   *old = *real_packet;
30146   SEND_PACKET_END(PACKET_RULESET_BUILDING);
30147 }
30148 
send_packet_ruleset_building(struct connection * pc,const struct packet_ruleset_building * packet)30149 int send_packet_ruleset_building(struct connection *pc, const struct packet_ruleset_building *packet)
30150 {
30151   if (!pc->used) {
30152     log_error("WARNING: trying to send data to the closed connection %s",
30153               conn_description(pc));
30154     return -1;
30155   }
30156   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_BUILDING].packet != NULL, -1,
30157                         "Handler for PACKET_RULESET_BUILDING not installed");
30158   return pc->phs.handlers->send[PACKET_RULESET_BUILDING].packet(pc, packet);
30159 }
30160 
lsend_packet_ruleset_building(struct conn_list * dest,const struct packet_ruleset_building * packet)30161 void lsend_packet_ruleset_building(struct conn_list *dest, const struct packet_ruleset_building *packet)
30162 {
30163   conn_list_iterate(dest, pconn) {
30164     send_packet_ruleset_building(pconn, packet);
30165   } conn_list_iterate_end;
30166 }
30167 
30168 #define hash_packet_ruleset_terrain_100 hash_const
30169 
30170 #define cmp_packet_ruleset_terrain_100 cmp_const
30171 
30172 BV_DEFINE(packet_ruleset_terrain_100_fields, 32);
30173 
receive_packet_ruleset_terrain_100(struct connection * pc)30174 static struct packet_ruleset_terrain *receive_packet_ruleset_terrain_100(struct connection *pc)
30175 {
30176   packet_ruleset_terrain_100_fields fields;
30177   struct packet_ruleset_terrain *old;
30178   struct genhash **hash = pc->phs.received + PACKET_RULESET_TERRAIN;
30179   RECEIVE_PACKET_START(packet_ruleset_terrain, real_packet);
30180 
30181   DIO_BV_GET(&din, fields);
30182 
30183   log_packet_detailed("packet_ruleset_terrain_100: got info about ()");
30184 
30185   if (NULL == *hash) {
30186     *hash = genhash_new_full(hash_packet_ruleset_terrain_100, cmp_packet_ruleset_terrain_100,
30187                              NULL, NULL, NULL, free);
30188   }
30189 
30190   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
30191     *real_packet = *old;
30192   } else {
30193     log_packet_detailed("  no old info");
30194     memset(real_packet, 0, sizeof(*real_packet));
30195   }
30196 
30197   if (BV_ISSET(fields, 0)) {
30198     log_packet_detailed("  got field 'id'");
30199     {
30200       int readin;
30201 
30202       if (!DIO_GET(uint8, &din, "id", &readin)) {
30203         RECEIVE_PACKET_FIELD_ERROR(id);
30204       }
30205       real_packet->id = readin;
30206     }
30207   }
30208   if (BV_ISSET(fields, 1)) {
30209     log_packet_detailed("  got field 'tclass'");
30210     if (!DIO_GET(uint8, &din, "tclass", &real_packet->tclass)) {
30211       RECEIVE_PACKET_FIELD_ERROR(tclass);
30212     }
30213   }
30214   if (BV_ISSET(fields, 2)) {
30215     log_packet_detailed("  got field 'flags'");
30216     if (!DIO_BV_GET(&din, real_packet->flags)) {
30217       RECEIVE_PACKET_FIELD_ERROR(flags);
30218     }
30219   }
30220   if (BV_ISSET(fields, 3)) {
30221     log_packet_detailed("  got field 'native_to'");
30222     if (!DIO_BV_GET(&din, real_packet->native_to)) {
30223       RECEIVE_PACKET_FIELD_ERROR(native_to);
30224     }
30225   }
30226   if (BV_ISSET(fields, 4)) {
30227     log_packet_detailed("  got field 'name'");
30228     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
30229       RECEIVE_PACKET_FIELD_ERROR(name);
30230     }
30231   }
30232   if (BV_ISSET(fields, 5)) {
30233     log_packet_detailed("  got field 'rule_name'");
30234     if (!DIO_GET(string, &din, "rule_name", real_packet->rule_name, sizeof(real_packet->rule_name))) {
30235       RECEIVE_PACKET_FIELD_ERROR(rule_name);
30236     }
30237   }
30238   if (BV_ISSET(fields, 6)) {
30239     log_packet_detailed("  got field 'graphic_str'");
30240     if (!DIO_GET(string, &din, "graphic_str", real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
30241       RECEIVE_PACKET_FIELD_ERROR(graphic_str);
30242     }
30243   }
30244   if (BV_ISSET(fields, 7)) {
30245     log_packet_detailed("  got field 'graphic_alt'");
30246     if (!DIO_GET(string, &din, "graphic_alt", real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
30247       RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
30248     }
30249   }
30250   if (BV_ISSET(fields, 8)) {
30251     log_packet_detailed("  got field 'movement_cost'");
30252     if (!DIO_GET(uint8, &din, "movement_cost", &real_packet->movement_cost)) {
30253       RECEIVE_PACKET_FIELD_ERROR(movement_cost);
30254     }
30255   }
30256   if (BV_ISSET(fields, 9)) {
30257     log_packet_detailed("  got field 'defense_bonus'");
30258     if (!DIO_GET(sint16, &din, "defense_bonus", &real_packet->defense_bonus)) {
30259       RECEIVE_PACKET_FIELD_ERROR(defense_bonus);
30260     }
30261   }
30262   if (BV_ISSET(fields, 10)) {
30263     log_packet_detailed("  got field 'output'");
30264 
30265     {
30266       int i;
30267 
30268       for (i = 0; i < O_LAST; i++) {
30269         if (!DIO_GET(uint8, &din, "output", &real_packet->output[i])) {
30270           RECEIVE_PACKET_FIELD_ERROR(output);
30271         }
30272       }
30273     }
30274   }
30275   if (BV_ISSET(fields, 11)) {
30276     log_packet_detailed("  got field 'num_resources'");
30277     if (!DIO_GET(uint8, &din, "num_resources", &real_packet->num_resources)) {
30278       RECEIVE_PACKET_FIELD_ERROR(num_resources);
30279     }
30280   }
30281   if (BV_ISSET(fields, 12)) {
30282     log_packet_detailed("  got field 'resources'");
30283 
30284     {
30285       int i;
30286 
30287       if (real_packet->num_resources > MAX_NUM_RESOURCES) {
30288         RECEIVE_PACKET_FIELD_ERROR(resources, ": truncation array");
30289       }
30290       for (i = 0; i < real_packet->num_resources; i++) {
30291         {
30292           int readin;
30293 
30294           if (!DIO_GET(uint8, &din, "resources", &readin)) {
30295             RECEIVE_PACKET_FIELD_ERROR(resources);
30296           }
30297           real_packet->resources[i] = readin;
30298         }
30299       }
30300     }
30301   }
30302   if (BV_ISSET(fields, 13)) {
30303     log_packet_detailed("  got field 'road_output_incr_pct'");
30304 
30305     {
30306       int i;
30307 
30308       for (i = 0; i < O_LAST; i++) {
30309         if (!DIO_GET(uint16, &din, "road_output_incr_pct", &real_packet->road_output_incr_pct[i])) {
30310           RECEIVE_PACKET_FIELD_ERROR(road_output_incr_pct);
30311         }
30312       }
30313     }
30314   }
30315   if (BV_ISSET(fields, 14)) {
30316     log_packet_detailed("  got field 'base_time'");
30317     if (!DIO_GET(uint8, &din, "base_time", &real_packet->base_time)) {
30318       RECEIVE_PACKET_FIELD_ERROR(base_time);
30319     }
30320   }
30321   if (BV_ISSET(fields, 15)) {
30322     log_packet_detailed("  got field 'road_time'");
30323     if (!DIO_GET(uint8, &din, "road_time", &real_packet->road_time)) {
30324       RECEIVE_PACKET_FIELD_ERROR(road_time);
30325     }
30326   }
30327   if (BV_ISSET(fields, 16)) {
30328     log_packet_detailed("  got field 'irrigation_result'");
30329     {
30330       int readin;
30331 
30332       if (!DIO_GET(uint8, &din, "irrigation_result", &readin)) {
30333         RECEIVE_PACKET_FIELD_ERROR(irrigation_result);
30334       }
30335       real_packet->irrigation_result = readin;
30336     }
30337   }
30338   if (BV_ISSET(fields, 17)) {
30339     log_packet_detailed("  got field 'irrigation_food_incr'");
30340     if (!DIO_GET(uint8, &din, "irrigation_food_incr", &real_packet->irrigation_food_incr)) {
30341       RECEIVE_PACKET_FIELD_ERROR(irrigation_food_incr);
30342     }
30343   }
30344   if (BV_ISSET(fields, 18)) {
30345     log_packet_detailed("  got field 'irrigation_time'");
30346     if (!DIO_GET(uint8, &din, "irrigation_time", &real_packet->irrigation_time)) {
30347       RECEIVE_PACKET_FIELD_ERROR(irrigation_time);
30348     }
30349   }
30350   if (BV_ISSET(fields, 19)) {
30351     log_packet_detailed("  got field 'mining_result'");
30352     {
30353       int readin;
30354 
30355       if (!DIO_GET(uint8, &din, "mining_result", &readin)) {
30356         RECEIVE_PACKET_FIELD_ERROR(mining_result);
30357       }
30358       real_packet->mining_result = readin;
30359     }
30360   }
30361   if (BV_ISSET(fields, 20)) {
30362     log_packet_detailed("  got field 'mining_shield_incr'");
30363     if (!DIO_GET(uint8, &din, "mining_shield_incr", &real_packet->mining_shield_incr)) {
30364       RECEIVE_PACKET_FIELD_ERROR(mining_shield_incr);
30365     }
30366   }
30367   if (BV_ISSET(fields, 21)) {
30368     log_packet_detailed("  got field 'mining_time'");
30369     if (!DIO_GET(uint8, &din, "mining_time", &real_packet->mining_time)) {
30370       RECEIVE_PACKET_FIELD_ERROR(mining_time);
30371     }
30372   }
30373   if (BV_ISSET(fields, 22)) {
30374     log_packet_detailed("  got field 'animal'");
30375     if (!DIO_GET(sint16, &din, "animal", &real_packet->animal)) {
30376       RECEIVE_PACKET_FIELD_ERROR(animal);
30377     }
30378   }
30379   if (BV_ISSET(fields, 23)) {
30380     log_packet_detailed("  got field 'transform_result'");
30381     {
30382       int readin;
30383 
30384       if (!DIO_GET(uint8, &din, "transform_result", &readin)) {
30385         RECEIVE_PACKET_FIELD_ERROR(transform_result);
30386       }
30387       real_packet->transform_result = readin;
30388     }
30389   }
30390   if (BV_ISSET(fields, 24)) {
30391     log_packet_detailed("  got field 'transform_time'");
30392     if (!DIO_GET(uint8, &din, "transform_time", &real_packet->transform_time)) {
30393       RECEIVE_PACKET_FIELD_ERROR(transform_time);
30394     }
30395   }
30396   if (BV_ISSET(fields, 25)) {
30397     log_packet_detailed("  got field 'clean_pollution_time'");
30398     if (!DIO_GET(uint8, &din, "clean_pollution_time", &real_packet->clean_pollution_time)) {
30399       RECEIVE_PACKET_FIELD_ERROR(clean_pollution_time);
30400     }
30401   }
30402   if (BV_ISSET(fields, 26)) {
30403     log_packet_detailed("  got field 'clean_fallout_time'");
30404     if (!DIO_GET(uint8, &din, "clean_fallout_time", &real_packet->clean_fallout_time)) {
30405       RECEIVE_PACKET_FIELD_ERROR(clean_fallout_time);
30406     }
30407   }
30408   if (BV_ISSET(fields, 27)) {
30409     log_packet_detailed("  got field 'pillage_time'");
30410     if (!DIO_GET(uint8, &din, "pillage_time", &real_packet->pillage_time)) {
30411       RECEIVE_PACKET_FIELD_ERROR(pillage_time);
30412     }
30413   }
30414   if (BV_ISSET(fields, 28)) {
30415     log_packet_detailed("  got field 'color_red'");
30416     if (!DIO_GET(uint8, &din, "color_red", &real_packet->color_red)) {
30417       RECEIVE_PACKET_FIELD_ERROR(color_red);
30418     }
30419   }
30420   if (BV_ISSET(fields, 29)) {
30421     log_packet_detailed("  got field 'color_green'");
30422     if (!DIO_GET(uint8, &din, "color_green", &real_packet->color_green)) {
30423       RECEIVE_PACKET_FIELD_ERROR(color_green);
30424     }
30425   }
30426   if (BV_ISSET(fields, 30)) {
30427     log_packet_detailed("  got field 'color_blue'");
30428     if (!DIO_GET(uint8, &din, "color_blue", &real_packet->color_blue)) {
30429       RECEIVE_PACKET_FIELD_ERROR(color_blue);
30430     }
30431   }
30432   if (BV_ISSET(fields, 31)) {
30433     log_packet_detailed("  got field 'helptext'");
30434     if (!DIO_GET(string, &din, "helptext", real_packet->helptext, sizeof(real_packet->helptext))) {
30435       RECEIVE_PACKET_FIELD_ERROR(helptext);
30436     }
30437   }
30438 
30439   if (NULL == old) {
30440     old = fc_malloc(sizeof(*old));
30441     *old = *real_packet;
30442     genhash_insert(*hash, old, old);
30443   } else {
30444     *old = *real_packet;
30445   }
30446   RECEIVE_PACKET_END(real_packet);
30447 }
30448 
send_packet_ruleset_terrain_100(struct connection * pc,const struct packet_ruleset_terrain * packet)30449 static int send_packet_ruleset_terrain_100(struct connection *pc, const struct packet_ruleset_terrain *packet)
30450 {
30451   const struct packet_ruleset_terrain *real_packet = packet;
30452   packet_ruleset_terrain_100_fields fields;
30453   struct packet_ruleset_terrain *old;
30454   bool differ;
30455   struct genhash **hash = pc->phs.sent + PACKET_RULESET_TERRAIN;
30456   int different = 0;
30457   SEND_PACKET_START(PACKET_RULESET_TERRAIN);
30458 
30459   log_packet_detailed("packet_ruleset_terrain_100: sending info about ()");
30460 
30461   if (NULL == *hash) {
30462     *hash = genhash_new_full(hash_packet_ruleset_terrain_100, cmp_packet_ruleset_terrain_100,
30463                              NULL, NULL, NULL, free);
30464   }
30465   BV_CLR_ALL(fields);
30466 
30467   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
30468     old = fc_malloc(sizeof(*old));
30469     *old = *real_packet;
30470     genhash_insert(*hash, old, old);
30471     memset(old, 0, sizeof(*old));
30472     different = 1;      /* Force to send. */
30473   }
30474 
30475   differ = (old->id != real_packet->id);
30476   if (differ) {
30477     different++;
30478     BV_SET(fields, 0);
30479   }
30480 
30481   differ = (old->tclass != real_packet->tclass);
30482   if (differ) {
30483     different++;
30484     BV_SET(fields, 1);
30485   }
30486 
30487   differ = !BV_ARE_EQUAL(old->flags, real_packet->flags);
30488   if (differ) {
30489     different++;
30490     BV_SET(fields, 2);
30491   }
30492 
30493   differ = !BV_ARE_EQUAL(old->native_to, real_packet->native_to);
30494   if (differ) {
30495     different++;
30496     BV_SET(fields, 3);
30497   }
30498 
30499   differ = (strcmp(old->name, real_packet->name) != 0);
30500   if (differ) {
30501     different++;
30502     BV_SET(fields, 4);
30503   }
30504 
30505   differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
30506   if (differ) {
30507     different++;
30508     BV_SET(fields, 5);
30509   }
30510 
30511   differ = (strcmp(old->graphic_str, real_packet->graphic_str) != 0);
30512   if (differ) {
30513     different++;
30514     BV_SET(fields, 6);
30515   }
30516 
30517   differ = (strcmp(old->graphic_alt, real_packet->graphic_alt) != 0);
30518   if (differ) {
30519     different++;
30520     BV_SET(fields, 7);
30521   }
30522 
30523   differ = (old->movement_cost != real_packet->movement_cost);
30524   if (differ) {
30525     different++;
30526     BV_SET(fields, 8);
30527   }
30528 
30529   differ = (old->defense_bonus != real_packet->defense_bonus);
30530   if (differ) {
30531     different++;
30532     BV_SET(fields, 9);
30533   }
30534 
30535 
30536     {
30537       differ = (O_LAST != O_LAST);
30538       if (!differ) {
30539         int i;
30540 
30541         for (i = 0; i < O_LAST; i++) {
30542           if (old->output[i] != real_packet->output[i]) {
30543             differ = TRUE;
30544             break;
30545           }
30546         }
30547       }
30548     }
30549   if (differ) {
30550     different++;
30551     BV_SET(fields, 10);
30552   }
30553 
30554   differ = (old->num_resources != real_packet->num_resources);
30555   if (differ) {
30556     different++;
30557     BV_SET(fields, 11);
30558   }
30559 
30560 
30561     {
30562       differ = (old->num_resources != real_packet->num_resources);
30563       if (!differ) {
30564         int i;
30565 
30566         for (i = 0; i < real_packet->num_resources; i++) {
30567           if (old->resources[i] != real_packet->resources[i]) {
30568             differ = TRUE;
30569             break;
30570           }
30571         }
30572       }
30573     }
30574   if (differ) {
30575     different++;
30576     BV_SET(fields, 12);
30577   }
30578 
30579 
30580     {
30581       differ = (O_LAST != O_LAST);
30582       if (!differ) {
30583         int i;
30584 
30585         for (i = 0; i < O_LAST; i++) {
30586           if (old->road_output_incr_pct[i] != real_packet->road_output_incr_pct[i]) {
30587             differ = TRUE;
30588             break;
30589           }
30590         }
30591       }
30592     }
30593   if (differ) {
30594     different++;
30595     BV_SET(fields, 13);
30596   }
30597 
30598   differ = (old->base_time != real_packet->base_time);
30599   if (differ) {
30600     different++;
30601     BV_SET(fields, 14);
30602   }
30603 
30604   differ = (old->road_time != real_packet->road_time);
30605   if (differ) {
30606     different++;
30607     BV_SET(fields, 15);
30608   }
30609 
30610   differ = (old->irrigation_result != real_packet->irrigation_result);
30611   if (differ) {
30612     different++;
30613     BV_SET(fields, 16);
30614   }
30615 
30616   differ = (old->irrigation_food_incr != real_packet->irrigation_food_incr);
30617   if (differ) {
30618     different++;
30619     BV_SET(fields, 17);
30620   }
30621 
30622   differ = (old->irrigation_time != real_packet->irrigation_time);
30623   if (differ) {
30624     different++;
30625     BV_SET(fields, 18);
30626   }
30627 
30628   differ = (old->mining_result != real_packet->mining_result);
30629   if (differ) {
30630     different++;
30631     BV_SET(fields, 19);
30632   }
30633 
30634   differ = (old->mining_shield_incr != real_packet->mining_shield_incr);
30635   if (differ) {
30636     different++;
30637     BV_SET(fields, 20);
30638   }
30639 
30640   differ = (old->mining_time != real_packet->mining_time);
30641   if (differ) {
30642     different++;
30643     BV_SET(fields, 21);
30644   }
30645 
30646   differ = (old->animal != real_packet->animal);
30647   if (differ) {
30648     different++;
30649     BV_SET(fields, 22);
30650   }
30651 
30652   differ = (old->transform_result != real_packet->transform_result);
30653   if (differ) {
30654     different++;
30655     BV_SET(fields, 23);
30656   }
30657 
30658   differ = (old->transform_time != real_packet->transform_time);
30659   if (differ) {
30660     different++;
30661     BV_SET(fields, 24);
30662   }
30663 
30664   differ = (old->clean_pollution_time != real_packet->clean_pollution_time);
30665   if (differ) {
30666     different++;
30667     BV_SET(fields, 25);
30668   }
30669 
30670   differ = (old->clean_fallout_time != real_packet->clean_fallout_time);
30671   if (differ) {
30672     different++;
30673     BV_SET(fields, 26);
30674   }
30675 
30676   differ = (old->pillage_time != real_packet->pillage_time);
30677   if (differ) {
30678     different++;
30679     BV_SET(fields, 27);
30680   }
30681 
30682   differ = (old->color_red != real_packet->color_red);
30683   if (differ) {
30684     different++;
30685     BV_SET(fields, 28);
30686   }
30687 
30688   differ = (old->color_green != real_packet->color_green);
30689   if (differ) {
30690     different++;
30691     BV_SET(fields, 29);
30692   }
30693 
30694   differ = (old->color_blue != real_packet->color_blue);
30695   if (differ) {
30696     different++;
30697     BV_SET(fields, 30);
30698   }
30699 
30700   differ = (strcmp(old->helptext, real_packet->helptext) != 0);
30701   if (differ) {
30702     different++;
30703     BV_SET(fields, 31);
30704   }
30705 
30706 
30707   DIO_BV_PUT(&dout, "fields", fields);
30708 
30709   if (BV_ISSET(fields, 0)) {
30710     log_packet_detailed("  field 'id' has changed");
30711     DIO_PUT(uint8, &dout, "id", real_packet->id);
30712   }
30713   if (BV_ISSET(fields, 1)) {
30714     log_packet_detailed("  field 'tclass' has changed");
30715     DIO_PUT(uint8, &dout, "tclass", real_packet->tclass);
30716   }
30717   if (BV_ISSET(fields, 2)) {
30718     log_packet_detailed("  field 'flags' has changed");
30719   DIO_BV_PUT(&dout, "flags", packet->flags);
30720   }
30721   if (BV_ISSET(fields, 3)) {
30722     log_packet_detailed("  field 'native_to' has changed");
30723   DIO_BV_PUT(&dout, "native_to", packet->native_to);
30724   }
30725   if (BV_ISSET(fields, 4)) {
30726     log_packet_detailed("  field 'name' has changed");
30727     DIO_PUT(string, &dout, "name", real_packet->name);
30728   }
30729   if (BV_ISSET(fields, 5)) {
30730     log_packet_detailed("  field 'rule_name' has changed");
30731     DIO_PUT(string, &dout, "rule_name", real_packet->rule_name);
30732   }
30733   if (BV_ISSET(fields, 6)) {
30734     log_packet_detailed("  field 'graphic_str' has changed");
30735     DIO_PUT(string, &dout, "graphic_str", real_packet->graphic_str);
30736   }
30737   if (BV_ISSET(fields, 7)) {
30738     log_packet_detailed("  field 'graphic_alt' has changed");
30739     DIO_PUT(string, &dout, "graphic_alt", real_packet->graphic_alt);
30740   }
30741   if (BV_ISSET(fields, 8)) {
30742     log_packet_detailed("  field 'movement_cost' has changed");
30743     DIO_PUT(uint8, &dout, "movement_cost", real_packet->movement_cost);
30744   }
30745   if (BV_ISSET(fields, 9)) {
30746     log_packet_detailed("  field 'defense_bonus' has changed");
30747     DIO_PUT(sint16, &dout, "defense_bonus", real_packet->defense_bonus);
30748   }
30749   if (BV_ISSET(fields, 10)) {
30750     log_packet_detailed("  field 'output' has changed");
30751 
30752     {
30753       int i;
30754 
30755       for (i = 0; i < O_LAST; i++) {
30756         dio_put_uint8(&dout, real_packet->output[i]);
30757       }
30758     }
30759   }
30760   if (BV_ISSET(fields, 11)) {
30761     log_packet_detailed("  field 'num_resources' has changed");
30762     DIO_PUT(uint8, &dout, "num_resources", real_packet->num_resources);
30763   }
30764   if (BV_ISSET(fields, 12)) {
30765     log_packet_detailed("  field 'resources' has changed");
30766 
30767     {
30768       int i;
30769 
30770       for (i = 0; i < real_packet->num_resources; i++) {
30771         dio_put_uint8(&dout, real_packet->resources[i]);
30772       }
30773     }
30774   }
30775   if (BV_ISSET(fields, 13)) {
30776     log_packet_detailed("  field 'road_output_incr_pct' has changed");
30777 
30778     {
30779       int i;
30780 
30781       for (i = 0; i < O_LAST; i++) {
30782         dio_put_uint16(&dout, real_packet->road_output_incr_pct[i]);
30783       }
30784     }
30785   }
30786   if (BV_ISSET(fields, 14)) {
30787     log_packet_detailed("  field 'base_time' has changed");
30788     DIO_PUT(uint8, &dout, "base_time", real_packet->base_time);
30789   }
30790   if (BV_ISSET(fields, 15)) {
30791     log_packet_detailed("  field 'road_time' has changed");
30792     DIO_PUT(uint8, &dout, "road_time", real_packet->road_time);
30793   }
30794   if (BV_ISSET(fields, 16)) {
30795     log_packet_detailed("  field 'irrigation_result' has changed");
30796     DIO_PUT(uint8, &dout, "irrigation_result", real_packet->irrigation_result);
30797   }
30798   if (BV_ISSET(fields, 17)) {
30799     log_packet_detailed("  field 'irrigation_food_incr' has changed");
30800     DIO_PUT(uint8, &dout, "irrigation_food_incr", real_packet->irrigation_food_incr);
30801   }
30802   if (BV_ISSET(fields, 18)) {
30803     log_packet_detailed("  field 'irrigation_time' has changed");
30804     DIO_PUT(uint8, &dout, "irrigation_time", real_packet->irrigation_time);
30805   }
30806   if (BV_ISSET(fields, 19)) {
30807     log_packet_detailed("  field 'mining_result' has changed");
30808     DIO_PUT(uint8, &dout, "mining_result", real_packet->mining_result);
30809   }
30810   if (BV_ISSET(fields, 20)) {
30811     log_packet_detailed("  field 'mining_shield_incr' has changed");
30812     DIO_PUT(uint8, &dout, "mining_shield_incr", real_packet->mining_shield_incr);
30813   }
30814   if (BV_ISSET(fields, 21)) {
30815     log_packet_detailed("  field 'mining_time' has changed");
30816     DIO_PUT(uint8, &dout, "mining_time", real_packet->mining_time);
30817   }
30818   if (BV_ISSET(fields, 22)) {
30819     log_packet_detailed("  field 'animal' has changed");
30820     DIO_PUT(sint16, &dout, "animal", real_packet->animal);
30821   }
30822   if (BV_ISSET(fields, 23)) {
30823     log_packet_detailed("  field 'transform_result' has changed");
30824     DIO_PUT(uint8, &dout, "transform_result", real_packet->transform_result);
30825   }
30826   if (BV_ISSET(fields, 24)) {
30827     log_packet_detailed("  field 'transform_time' has changed");
30828     DIO_PUT(uint8, &dout, "transform_time", real_packet->transform_time);
30829   }
30830   if (BV_ISSET(fields, 25)) {
30831     log_packet_detailed("  field 'clean_pollution_time' has changed");
30832     DIO_PUT(uint8, &dout, "clean_pollution_time", real_packet->clean_pollution_time);
30833   }
30834   if (BV_ISSET(fields, 26)) {
30835     log_packet_detailed("  field 'clean_fallout_time' has changed");
30836     DIO_PUT(uint8, &dout, "clean_fallout_time", real_packet->clean_fallout_time);
30837   }
30838   if (BV_ISSET(fields, 27)) {
30839     log_packet_detailed("  field 'pillage_time' has changed");
30840     DIO_PUT(uint8, &dout, "pillage_time", real_packet->pillage_time);
30841   }
30842   if (BV_ISSET(fields, 28)) {
30843     log_packet_detailed("  field 'color_red' has changed");
30844     DIO_PUT(uint8, &dout, "color_red", real_packet->color_red);
30845   }
30846   if (BV_ISSET(fields, 29)) {
30847     log_packet_detailed("  field 'color_green' has changed");
30848     DIO_PUT(uint8, &dout, "color_green", real_packet->color_green);
30849   }
30850   if (BV_ISSET(fields, 30)) {
30851     log_packet_detailed("  field 'color_blue' has changed");
30852     DIO_PUT(uint8, &dout, "color_blue", real_packet->color_blue);
30853   }
30854   if (BV_ISSET(fields, 31)) {
30855     log_packet_detailed("  field 'helptext' has changed");
30856     DIO_PUT(string, &dout, "helptext", real_packet->helptext);
30857   }
30858 
30859   *old = *real_packet;
30860   SEND_PACKET_END(PACKET_RULESET_TERRAIN);
30861 }
30862 
send_packet_ruleset_terrain(struct connection * pc,const struct packet_ruleset_terrain * packet)30863 int send_packet_ruleset_terrain(struct connection *pc, const struct packet_ruleset_terrain *packet)
30864 {
30865   if (!pc->used) {
30866     log_error("WARNING: trying to send data to the closed connection %s",
30867               conn_description(pc));
30868     return -1;
30869   }
30870   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_TERRAIN].packet != NULL, -1,
30871                         "Handler for PACKET_RULESET_TERRAIN not installed");
30872   return pc->phs.handlers->send[PACKET_RULESET_TERRAIN].packet(pc, packet);
30873 }
30874 
lsend_packet_ruleset_terrain(struct conn_list * dest,const struct packet_ruleset_terrain * packet)30875 void lsend_packet_ruleset_terrain(struct conn_list *dest, const struct packet_ruleset_terrain *packet)
30876 {
30877   conn_list_iterate(dest, pconn) {
30878     send_packet_ruleset_terrain(pconn, packet);
30879   } conn_list_iterate_end;
30880 }
30881 
30882 #define hash_packet_ruleset_terrain_flag_100 hash_const
30883 
30884 #define cmp_packet_ruleset_terrain_flag_100 cmp_const
30885 
30886 BV_DEFINE(packet_ruleset_terrain_flag_100_fields, 3);
30887 
receive_packet_ruleset_terrain_flag_100(struct connection * pc)30888 static struct packet_ruleset_terrain_flag *receive_packet_ruleset_terrain_flag_100(struct connection *pc)
30889 {
30890   packet_ruleset_terrain_flag_100_fields fields;
30891   struct packet_ruleset_terrain_flag *old;
30892   struct genhash **hash = pc->phs.received + PACKET_RULESET_TERRAIN_FLAG;
30893   RECEIVE_PACKET_START(packet_ruleset_terrain_flag, real_packet);
30894 
30895   DIO_BV_GET(&din, fields);
30896 
30897   log_packet_detailed("packet_ruleset_terrain_flag_100: got info about ()");
30898 
30899   if (NULL == *hash) {
30900     *hash = genhash_new_full(hash_packet_ruleset_terrain_flag_100, cmp_packet_ruleset_terrain_flag_100,
30901                              NULL, NULL, NULL, free);
30902   }
30903 
30904   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
30905     *real_packet = *old;
30906   } else {
30907     log_packet_detailed("  no old info");
30908     memset(real_packet, 0, sizeof(*real_packet));
30909   }
30910 
30911   if (BV_ISSET(fields, 0)) {
30912     log_packet_detailed("  got field 'id'");
30913     if (!DIO_GET(uint8, &din, "id", &real_packet->id)) {
30914       RECEIVE_PACKET_FIELD_ERROR(id);
30915     }
30916   }
30917   if (BV_ISSET(fields, 1)) {
30918     log_packet_detailed("  got field 'name'");
30919     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
30920       RECEIVE_PACKET_FIELD_ERROR(name);
30921     }
30922   }
30923   if (BV_ISSET(fields, 2)) {
30924     log_packet_detailed("  got field 'helptxt'");
30925     if (!DIO_GET(string, &din, "helptxt", real_packet->helptxt, sizeof(real_packet->helptxt))) {
30926       RECEIVE_PACKET_FIELD_ERROR(helptxt);
30927     }
30928   }
30929 
30930   if (NULL == old) {
30931     old = fc_malloc(sizeof(*old));
30932     *old = *real_packet;
30933     genhash_insert(*hash, old, old);
30934   } else {
30935     *old = *real_packet;
30936   }
30937   RECEIVE_PACKET_END(real_packet);
30938 }
30939 
send_packet_ruleset_terrain_flag_100(struct connection * pc,const struct packet_ruleset_terrain_flag * packet)30940 static int send_packet_ruleset_terrain_flag_100(struct connection *pc, const struct packet_ruleset_terrain_flag *packet)
30941 {
30942   const struct packet_ruleset_terrain_flag *real_packet = packet;
30943   packet_ruleset_terrain_flag_100_fields fields;
30944   struct packet_ruleset_terrain_flag *old;
30945   bool differ;
30946   struct genhash **hash = pc->phs.sent + PACKET_RULESET_TERRAIN_FLAG;
30947   int different = 0;
30948   SEND_PACKET_START(PACKET_RULESET_TERRAIN_FLAG);
30949 
30950   log_packet_detailed("packet_ruleset_terrain_flag_100: sending info about ()");
30951 
30952   if (NULL == *hash) {
30953     *hash = genhash_new_full(hash_packet_ruleset_terrain_flag_100, cmp_packet_ruleset_terrain_flag_100,
30954                              NULL, NULL, NULL, free);
30955   }
30956   BV_CLR_ALL(fields);
30957 
30958   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
30959     old = fc_malloc(sizeof(*old));
30960     *old = *real_packet;
30961     genhash_insert(*hash, old, old);
30962     memset(old, 0, sizeof(*old));
30963     different = 1;      /* Force to send. */
30964   }
30965 
30966   differ = (old->id != real_packet->id);
30967   if (differ) {
30968     different++;
30969     BV_SET(fields, 0);
30970   }
30971 
30972   differ = (strcmp(old->name, real_packet->name) != 0);
30973   if (differ) {
30974     different++;
30975     BV_SET(fields, 1);
30976   }
30977 
30978   differ = (strcmp(old->helptxt, real_packet->helptxt) != 0);
30979   if (differ) {
30980     different++;
30981     BV_SET(fields, 2);
30982   }
30983 
30984 
30985   DIO_BV_PUT(&dout, "fields", fields);
30986 
30987   if (BV_ISSET(fields, 0)) {
30988     log_packet_detailed("  field 'id' has changed");
30989     DIO_PUT(uint8, &dout, "id", real_packet->id);
30990   }
30991   if (BV_ISSET(fields, 1)) {
30992     log_packet_detailed("  field 'name' has changed");
30993     DIO_PUT(string, &dout, "name", real_packet->name);
30994   }
30995   if (BV_ISSET(fields, 2)) {
30996     log_packet_detailed("  field 'helptxt' has changed");
30997     DIO_PUT(string, &dout, "helptxt", real_packet->helptxt);
30998   }
30999 
31000   *old = *real_packet;
31001   SEND_PACKET_END(PACKET_RULESET_TERRAIN_FLAG);
31002 }
31003 
send_packet_ruleset_terrain_flag(struct connection * pc,const struct packet_ruleset_terrain_flag * packet)31004 int send_packet_ruleset_terrain_flag(struct connection *pc, const struct packet_ruleset_terrain_flag *packet)
31005 {
31006   if (!pc->used) {
31007     log_error("WARNING: trying to send data to the closed connection %s",
31008               conn_description(pc));
31009     return -1;
31010   }
31011   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_TERRAIN_FLAG].packet != NULL, -1,
31012                         "Handler for PACKET_RULESET_TERRAIN_FLAG not installed");
31013   return pc->phs.handlers->send[PACKET_RULESET_TERRAIN_FLAG].packet(pc, packet);
31014 }
31015 
lsend_packet_ruleset_terrain_flag(struct conn_list * dest,const struct packet_ruleset_terrain_flag * packet)31016 void lsend_packet_ruleset_terrain_flag(struct conn_list *dest, const struct packet_ruleset_terrain_flag *packet)
31017 {
31018   conn_list_iterate(dest, pconn) {
31019     send_packet_ruleset_terrain_flag(pconn, packet);
31020   } conn_list_iterate_end;
31021 }
31022 
31023 #define hash_packet_ruleset_unit_class_100 hash_const
31024 
31025 #define cmp_packet_ruleset_unit_class_100 cmp_const
31026 
31027 BV_DEFINE(packet_ruleset_unit_class_100_fields, 9);
31028 
receive_packet_ruleset_unit_class_100(struct connection * pc)31029 static struct packet_ruleset_unit_class *receive_packet_ruleset_unit_class_100(struct connection *pc)
31030 {
31031   packet_ruleset_unit_class_100_fields fields;
31032   struct packet_ruleset_unit_class *old;
31033   struct genhash **hash = pc->phs.received + PACKET_RULESET_UNIT_CLASS;
31034   RECEIVE_PACKET_START(packet_ruleset_unit_class, real_packet);
31035 
31036   DIO_BV_GET(&din, fields);
31037 
31038   log_packet_detailed("packet_ruleset_unit_class_100: got info about ()");
31039 
31040   if (NULL == *hash) {
31041     *hash = genhash_new_full(hash_packet_ruleset_unit_class_100, cmp_packet_ruleset_unit_class_100,
31042                              NULL, NULL, NULL, free);
31043   }
31044 
31045   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
31046     *real_packet = *old;
31047   } else {
31048     log_packet_detailed("  no old info");
31049     memset(real_packet, 0, sizeof(*real_packet));
31050   }
31051 
31052   if (BV_ISSET(fields, 0)) {
31053     log_packet_detailed("  got field 'id'");
31054     if (!DIO_GET(uint8, &din, "id", &real_packet->id)) {
31055       RECEIVE_PACKET_FIELD_ERROR(id);
31056     }
31057   }
31058   if (BV_ISSET(fields, 1)) {
31059     log_packet_detailed("  got field 'name'");
31060     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
31061       RECEIVE_PACKET_FIELD_ERROR(name);
31062     }
31063   }
31064   if (BV_ISSET(fields, 2)) {
31065     log_packet_detailed("  got field 'rule_name'");
31066     if (!DIO_GET(string, &din, "rule_name", real_packet->rule_name, sizeof(real_packet->rule_name))) {
31067       RECEIVE_PACKET_FIELD_ERROR(rule_name);
31068     }
31069   }
31070   if (BV_ISSET(fields, 3)) {
31071     log_packet_detailed("  got field 'min_speed'");
31072     if (!DIO_GET(uint16, &din, "min_speed", &real_packet->min_speed)) {
31073       RECEIVE_PACKET_FIELD_ERROR(min_speed);
31074     }
31075   }
31076   if (BV_ISSET(fields, 4)) {
31077     log_packet_detailed("  got field 'hp_loss_pct'");
31078     if (!DIO_GET(uint8, &din, "hp_loss_pct", &real_packet->hp_loss_pct)) {
31079       RECEIVE_PACKET_FIELD_ERROR(hp_loss_pct);
31080     }
31081   }
31082   if (BV_ISSET(fields, 5)) {
31083     log_packet_detailed("  got field 'hut_behavior'");
31084     if (!DIO_GET(uint8, &din, "hut_behavior", &real_packet->hut_behavior)) {
31085       RECEIVE_PACKET_FIELD_ERROR(hut_behavior);
31086     }
31087   }
31088   if (BV_ISSET(fields, 6)) {
31089     log_packet_detailed("  got field 'non_native_def_pct'");
31090     if (!DIO_GET(uint16, &din, "non_native_def_pct", &real_packet->non_native_def_pct)) {
31091       RECEIVE_PACKET_FIELD_ERROR(non_native_def_pct);
31092     }
31093   }
31094   if (BV_ISSET(fields, 7)) {
31095     log_packet_detailed("  got field 'flags'");
31096     if (!DIO_BV_GET(&din, real_packet->flags)) {
31097       RECEIVE_PACKET_FIELD_ERROR(flags);
31098     }
31099   }
31100   if (BV_ISSET(fields, 8)) {
31101     log_packet_detailed("  got field 'helptext'");
31102     if (!DIO_GET(string, &din, "helptext", real_packet->helptext, sizeof(real_packet->helptext))) {
31103       RECEIVE_PACKET_FIELD_ERROR(helptext);
31104     }
31105   }
31106 
31107   if (NULL == old) {
31108     old = fc_malloc(sizeof(*old));
31109     *old = *real_packet;
31110     genhash_insert(*hash, old, old);
31111   } else {
31112     *old = *real_packet;
31113   }
31114   RECEIVE_PACKET_END(real_packet);
31115 }
31116 
send_packet_ruleset_unit_class_100(struct connection * pc,const struct packet_ruleset_unit_class * packet)31117 static int send_packet_ruleset_unit_class_100(struct connection *pc, const struct packet_ruleset_unit_class *packet)
31118 {
31119   const struct packet_ruleset_unit_class *real_packet = packet;
31120   packet_ruleset_unit_class_100_fields fields;
31121   struct packet_ruleset_unit_class *old;
31122   bool differ;
31123   struct genhash **hash = pc->phs.sent + PACKET_RULESET_UNIT_CLASS;
31124   int different = 0;
31125   SEND_PACKET_START(PACKET_RULESET_UNIT_CLASS);
31126 
31127   log_packet_detailed("packet_ruleset_unit_class_100: sending info about ()");
31128 
31129   if (NULL == *hash) {
31130     *hash = genhash_new_full(hash_packet_ruleset_unit_class_100, cmp_packet_ruleset_unit_class_100,
31131                              NULL, NULL, NULL, free);
31132   }
31133   BV_CLR_ALL(fields);
31134 
31135   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
31136     old = fc_malloc(sizeof(*old));
31137     *old = *real_packet;
31138     genhash_insert(*hash, old, old);
31139     memset(old, 0, sizeof(*old));
31140     different = 1;      /* Force to send. */
31141   }
31142 
31143   differ = (old->id != real_packet->id);
31144   if (differ) {
31145     different++;
31146     BV_SET(fields, 0);
31147   }
31148 
31149   differ = (strcmp(old->name, real_packet->name) != 0);
31150   if (differ) {
31151     different++;
31152     BV_SET(fields, 1);
31153   }
31154 
31155   differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
31156   if (differ) {
31157     different++;
31158     BV_SET(fields, 2);
31159   }
31160 
31161   differ = (old->min_speed != real_packet->min_speed);
31162   if (differ) {
31163     different++;
31164     BV_SET(fields, 3);
31165   }
31166 
31167   differ = (old->hp_loss_pct != real_packet->hp_loss_pct);
31168   if (differ) {
31169     different++;
31170     BV_SET(fields, 4);
31171   }
31172 
31173   differ = (old->hut_behavior != real_packet->hut_behavior);
31174   if (differ) {
31175     different++;
31176     BV_SET(fields, 5);
31177   }
31178 
31179   differ = (old->non_native_def_pct != real_packet->non_native_def_pct);
31180   if (differ) {
31181     different++;
31182     BV_SET(fields, 6);
31183   }
31184 
31185   differ = !BV_ARE_EQUAL(old->flags, real_packet->flags);
31186   if (differ) {
31187     different++;
31188     BV_SET(fields, 7);
31189   }
31190 
31191   differ = (strcmp(old->helptext, real_packet->helptext) != 0);
31192   if (differ) {
31193     different++;
31194     BV_SET(fields, 8);
31195   }
31196 
31197 
31198   DIO_BV_PUT(&dout, "fields", fields);
31199 
31200   if (BV_ISSET(fields, 0)) {
31201     log_packet_detailed("  field 'id' has changed");
31202     DIO_PUT(uint8, &dout, "id", real_packet->id);
31203   }
31204   if (BV_ISSET(fields, 1)) {
31205     log_packet_detailed("  field 'name' has changed");
31206     DIO_PUT(string, &dout, "name", real_packet->name);
31207   }
31208   if (BV_ISSET(fields, 2)) {
31209     log_packet_detailed("  field 'rule_name' has changed");
31210     DIO_PUT(string, &dout, "rule_name", real_packet->rule_name);
31211   }
31212   if (BV_ISSET(fields, 3)) {
31213     log_packet_detailed("  field 'min_speed' has changed");
31214     DIO_PUT(uint16, &dout, "min_speed", real_packet->min_speed);
31215   }
31216   if (BV_ISSET(fields, 4)) {
31217     log_packet_detailed("  field 'hp_loss_pct' has changed");
31218     DIO_PUT(uint8, &dout, "hp_loss_pct", real_packet->hp_loss_pct);
31219   }
31220   if (BV_ISSET(fields, 5)) {
31221     log_packet_detailed("  field 'hut_behavior' has changed");
31222     DIO_PUT(uint8, &dout, "hut_behavior", real_packet->hut_behavior);
31223   }
31224   if (BV_ISSET(fields, 6)) {
31225     log_packet_detailed("  field 'non_native_def_pct' has changed");
31226     DIO_PUT(uint16, &dout, "non_native_def_pct", real_packet->non_native_def_pct);
31227   }
31228   if (BV_ISSET(fields, 7)) {
31229     log_packet_detailed("  field 'flags' has changed");
31230   DIO_BV_PUT(&dout, "flags", packet->flags);
31231   }
31232   if (BV_ISSET(fields, 8)) {
31233     log_packet_detailed("  field 'helptext' has changed");
31234     DIO_PUT(string, &dout, "helptext", real_packet->helptext);
31235   }
31236 
31237   *old = *real_packet;
31238   SEND_PACKET_END(PACKET_RULESET_UNIT_CLASS);
31239 }
31240 
send_packet_ruleset_unit_class(struct connection * pc,const struct packet_ruleset_unit_class * packet)31241 int send_packet_ruleset_unit_class(struct connection *pc, const struct packet_ruleset_unit_class *packet)
31242 {
31243   if (!pc->used) {
31244     log_error("WARNING: trying to send data to the closed connection %s",
31245               conn_description(pc));
31246     return -1;
31247   }
31248   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_UNIT_CLASS].packet != NULL, -1,
31249                         "Handler for PACKET_RULESET_UNIT_CLASS not installed");
31250   return pc->phs.handlers->send[PACKET_RULESET_UNIT_CLASS].packet(pc, packet);
31251 }
31252 
lsend_packet_ruleset_unit_class(struct conn_list * dest,const struct packet_ruleset_unit_class * packet)31253 void lsend_packet_ruleset_unit_class(struct conn_list *dest, const struct packet_ruleset_unit_class *packet)
31254 {
31255   conn_list_iterate(dest, pconn) {
31256     send_packet_ruleset_unit_class(pconn, packet);
31257   } conn_list_iterate_end;
31258 }
31259 
31260 #define hash_packet_ruleset_extra_100 hash_const
31261 
31262 #define cmp_packet_ruleset_extra_100 cmp_const
31263 
31264 BV_DEFINE(packet_ruleset_extra_100_fields, 28);
31265 
receive_packet_ruleset_extra_100(struct connection * pc)31266 static struct packet_ruleset_extra *receive_packet_ruleset_extra_100(struct connection *pc)
31267 {
31268   packet_ruleset_extra_100_fields fields;
31269   struct packet_ruleset_extra *old;
31270   struct genhash **hash = pc->phs.received + PACKET_RULESET_EXTRA;
31271   RECEIVE_PACKET_START(packet_ruleset_extra, real_packet);
31272 
31273   DIO_BV_GET(&din, fields);
31274 
31275   log_packet_detailed("packet_ruleset_extra_100: got info about ()");
31276 
31277   if (NULL == *hash) {
31278     *hash = genhash_new_full(hash_packet_ruleset_extra_100, cmp_packet_ruleset_extra_100,
31279                              NULL, NULL, NULL, free);
31280   }
31281 
31282   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
31283     *real_packet = *old;
31284   } else {
31285     log_packet_detailed("  no old info");
31286     memset(real_packet, 0, sizeof(*real_packet));
31287   }
31288 
31289   if (BV_ISSET(fields, 0)) {
31290     log_packet_detailed("  got field 'id'");
31291     if (!DIO_GET(uint8, &din, "id", &real_packet->id)) {
31292       RECEIVE_PACKET_FIELD_ERROR(id);
31293     }
31294   }
31295   if (BV_ISSET(fields, 1)) {
31296     log_packet_detailed("  got field 'name'");
31297     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
31298       RECEIVE_PACKET_FIELD_ERROR(name);
31299     }
31300   }
31301   if (BV_ISSET(fields, 2)) {
31302     log_packet_detailed("  got field 'rule_name'");
31303     if (!DIO_GET(string, &din, "rule_name", real_packet->rule_name, sizeof(real_packet->rule_name))) {
31304       RECEIVE_PACKET_FIELD_ERROR(rule_name);
31305     }
31306   }
31307   if (BV_ISSET(fields, 3)) {
31308     log_packet_detailed("  got field 'category'");
31309     if (!DIO_GET(uint8, &din, "category", &real_packet->category)) {
31310       RECEIVE_PACKET_FIELD_ERROR(category);
31311     }
31312   }
31313   if (BV_ISSET(fields, 4)) {
31314     log_packet_detailed("  got field 'causes'");
31315     if (!DIO_GET(uint8, &din, "causes", &real_packet->causes)) {
31316       RECEIVE_PACKET_FIELD_ERROR(causes);
31317     }
31318   }
31319   if (BV_ISSET(fields, 5)) {
31320     log_packet_detailed("  got field 'rmcauses'");
31321     if (!DIO_GET(uint8, &din, "rmcauses", &real_packet->rmcauses)) {
31322       RECEIVE_PACKET_FIELD_ERROR(rmcauses);
31323     }
31324   }
31325   if (BV_ISSET(fields, 6)) {
31326     log_packet_detailed("  got field 'activity_gfx'");
31327     if (!DIO_GET(string, &din, "activity_gfx", real_packet->activity_gfx, sizeof(real_packet->activity_gfx))) {
31328       RECEIVE_PACKET_FIELD_ERROR(activity_gfx);
31329     }
31330   }
31331   if (BV_ISSET(fields, 7)) {
31332     log_packet_detailed("  got field 'act_gfx_alt'");
31333     if (!DIO_GET(string, &din, "act_gfx_alt", real_packet->act_gfx_alt, sizeof(real_packet->act_gfx_alt))) {
31334       RECEIVE_PACKET_FIELD_ERROR(act_gfx_alt);
31335     }
31336   }
31337   if (BV_ISSET(fields, 8)) {
31338     log_packet_detailed("  got field 'act_gfx_alt2'");
31339     if (!DIO_GET(string, &din, "act_gfx_alt2", real_packet->act_gfx_alt2, sizeof(real_packet->act_gfx_alt2))) {
31340       RECEIVE_PACKET_FIELD_ERROR(act_gfx_alt2);
31341     }
31342   }
31343   if (BV_ISSET(fields, 9)) {
31344     log_packet_detailed("  got field 'rmact_gfx'");
31345     if (!DIO_GET(string, &din, "rmact_gfx", real_packet->rmact_gfx, sizeof(real_packet->rmact_gfx))) {
31346       RECEIVE_PACKET_FIELD_ERROR(rmact_gfx);
31347     }
31348   }
31349   if (BV_ISSET(fields, 10)) {
31350     log_packet_detailed("  got field 'rmact_gfx_alt'");
31351     if (!DIO_GET(string, &din, "rmact_gfx_alt", real_packet->rmact_gfx_alt, sizeof(real_packet->rmact_gfx_alt))) {
31352       RECEIVE_PACKET_FIELD_ERROR(rmact_gfx_alt);
31353     }
31354   }
31355   if (BV_ISSET(fields, 11)) {
31356     log_packet_detailed("  got field 'graphic_str'");
31357     if (!DIO_GET(string, &din, "graphic_str", real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
31358       RECEIVE_PACKET_FIELD_ERROR(graphic_str);
31359     }
31360   }
31361   if (BV_ISSET(fields, 12)) {
31362     log_packet_detailed("  got field 'graphic_alt'");
31363     if (!DIO_GET(string, &din, "graphic_alt", real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
31364       RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
31365     }
31366   }
31367   if (BV_ISSET(fields, 13)) {
31368     log_packet_detailed("  got field 'reqs_count'");
31369     if (!DIO_GET(uint8, &din, "reqs_count", &real_packet->reqs_count)) {
31370       RECEIVE_PACKET_FIELD_ERROR(reqs_count);
31371     }
31372   }
31373   if (BV_ISSET(fields, 14)) {
31374     log_packet_detailed("  got field 'reqs'");
31375 
31376     {
31377       int i;
31378 
31379       if (real_packet->reqs_count > MAX_NUM_REQS) {
31380         RECEIVE_PACKET_FIELD_ERROR(reqs, ": truncation array");
31381       }
31382       for (i = 0; i < real_packet->reqs_count; i++) {
31383         if (!DIO_GET(requirement, &din, "reqs", &real_packet->reqs[i])) {
31384           RECEIVE_PACKET_FIELD_ERROR(reqs);
31385         }
31386       }
31387     }
31388   }
31389   if (BV_ISSET(fields, 15)) {
31390     log_packet_detailed("  got field 'rmreqs_count'");
31391     if (!DIO_GET(uint8, &din, "rmreqs_count", &real_packet->rmreqs_count)) {
31392       RECEIVE_PACKET_FIELD_ERROR(rmreqs_count);
31393     }
31394   }
31395   if (BV_ISSET(fields, 16)) {
31396     log_packet_detailed("  got field 'rmreqs'");
31397 
31398     {
31399       int i;
31400 
31401       if (real_packet->rmreqs_count > MAX_NUM_REQS) {
31402         RECEIVE_PACKET_FIELD_ERROR(rmreqs, ": truncation array");
31403       }
31404       for (i = 0; i < real_packet->rmreqs_count; i++) {
31405         if (!DIO_GET(requirement, &din, "rmreqs", &real_packet->rmreqs[i])) {
31406           RECEIVE_PACKET_FIELD_ERROR(rmreqs);
31407         }
31408       }
31409     }
31410   }
31411   real_packet->buildable = BV_ISSET(fields, 17);
31412   if (BV_ISSET(fields, 18)) {
31413     log_packet_detailed("  got field 'build_time'");
31414     if (!DIO_GET(uint8, &din, "build_time", &real_packet->build_time)) {
31415       RECEIVE_PACKET_FIELD_ERROR(build_time);
31416     }
31417   }
31418   if (BV_ISSET(fields, 19)) {
31419     log_packet_detailed("  got field 'build_time_factor'");
31420     if (!DIO_GET(uint8, &din, "build_time_factor", &real_packet->build_time_factor)) {
31421       RECEIVE_PACKET_FIELD_ERROR(build_time_factor);
31422     }
31423   }
31424   if (BV_ISSET(fields, 20)) {
31425     log_packet_detailed("  got field 'removal_time'");
31426     if (!DIO_GET(uint8, &din, "removal_time", &real_packet->removal_time)) {
31427       RECEIVE_PACKET_FIELD_ERROR(removal_time);
31428     }
31429   }
31430   if (BV_ISSET(fields, 21)) {
31431     log_packet_detailed("  got field 'removal_time_factor'");
31432     if (!DIO_GET(uint8, &din, "removal_time_factor", &real_packet->removal_time_factor)) {
31433       RECEIVE_PACKET_FIELD_ERROR(removal_time_factor);
31434     }
31435   }
31436   if (BV_ISSET(fields, 22)) {
31437     log_packet_detailed("  got field 'defense_bonus'");
31438     if (!DIO_GET(uint8, &din, "defense_bonus", &real_packet->defense_bonus)) {
31439       RECEIVE_PACKET_FIELD_ERROR(defense_bonus);
31440     }
31441   }
31442   if (BV_ISSET(fields, 23)) {
31443     log_packet_detailed("  got field 'native_to'");
31444     if (!DIO_BV_GET(&din, real_packet->native_to)) {
31445       RECEIVE_PACKET_FIELD_ERROR(native_to);
31446     }
31447   }
31448   if (BV_ISSET(fields, 24)) {
31449     log_packet_detailed("  got field 'flags'");
31450     if (!DIO_BV_GET(&din, real_packet->flags)) {
31451       RECEIVE_PACKET_FIELD_ERROR(flags);
31452     }
31453   }
31454   if (BV_ISSET(fields, 25)) {
31455     log_packet_detailed("  got field 'hidden_by'");
31456     if (!DIO_BV_GET(&din, real_packet->hidden_by)) {
31457       RECEIVE_PACKET_FIELD_ERROR(hidden_by);
31458     }
31459   }
31460   if (BV_ISSET(fields, 26)) {
31461     log_packet_detailed("  got field 'conflicts'");
31462     if (!DIO_BV_GET(&din, real_packet->conflicts)) {
31463       RECEIVE_PACKET_FIELD_ERROR(conflicts);
31464     }
31465   }
31466   if (BV_ISSET(fields, 27)) {
31467     log_packet_detailed("  got field 'helptext'");
31468     if (!DIO_GET(string, &din, "helptext", real_packet->helptext, sizeof(real_packet->helptext))) {
31469       RECEIVE_PACKET_FIELD_ERROR(helptext);
31470     }
31471   }
31472 
31473   if (NULL == old) {
31474     old = fc_malloc(sizeof(*old));
31475     *old = *real_packet;
31476     genhash_insert(*hash, old, old);
31477   } else {
31478     *old = *real_packet;
31479   }
31480   RECEIVE_PACKET_END(real_packet);
31481 }
31482 
send_packet_ruleset_extra_100(struct connection * pc,const struct packet_ruleset_extra * packet)31483 static int send_packet_ruleset_extra_100(struct connection *pc, const struct packet_ruleset_extra *packet)
31484 {
31485   const struct packet_ruleset_extra *real_packet = packet;
31486   packet_ruleset_extra_100_fields fields;
31487   struct packet_ruleset_extra *old;
31488   bool differ;
31489   struct genhash **hash = pc->phs.sent + PACKET_RULESET_EXTRA;
31490   int different = 0;
31491   SEND_PACKET_START(PACKET_RULESET_EXTRA);
31492 
31493   log_packet_detailed("packet_ruleset_extra_100: sending info about ()");
31494 
31495   if (NULL == *hash) {
31496     *hash = genhash_new_full(hash_packet_ruleset_extra_100, cmp_packet_ruleset_extra_100,
31497                              NULL, NULL, NULL, free);
31498   }
31499   BV_CLR_ALL(fields);
31500 
31501   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
31502     old = fc_malloc(sizeof(*old));
31503     *old = *real_packet;
31504     genhash_insert(*hash, old, old);
31505     memset(old, 0, sizeof(*old));
31506     different = 1;      /* Force to send. */
31507   }
31508 
31509   differ = (old->id != real_packet->id);
31510   if (differ) {
31511     different++;
31512     BV_SET(fields, 0);
31513   }
31514 
31515   differ = (strcmp(old->name, real_packet->name) != 0);
31516   if (differ) {
31517     different++;
31518     BV_SET(fields, 1);
31519   }
31520 
31521   differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
31522   if (differ) {
31523     different++;
31524     BV_SET(fields, 2);
31525   }
31526 
31527   differ = (old->category != real_packet->category);
31528   if (differ) {
31529     different++;
31530     BV_SET(fields, 3);
31531   }
31532 
31533   differ = (old->causes != real_packet->causes);
31534   if (differ) {
31535     different++;
31536     BV_SET(fields, 4);
31537   }
31538 
31539   differ = (old->rmcauses != real_packet->rmcauses);
31540   if (differ) {
31541     different++;
31542     BV_SET(fields, 5);
31543   }
31544 
31545   differ = (strcmp(old->activity_gfx, real_packet->activity_gfx) != 0);
31546   if (differ) {
31547     different++;
31548     BV_SET(fields, 6);
31549   }
31550 
31551   differ = (strcmp(old->act_gfx_alt, real_packet->act_gfx_alt) != 0);
31552   if (differ) {
31553     different++;
31554     BV_SET(fields, 7);
31555   }
31556 
31557   differ = (strcmp(old->act_gfx_alt2, real_packet->act_gfx_alt2) != 0);
31558   if (differ) {
31559     different++;
31560     BV_SET(fields, 8);
31561   }
31562 
31563   differ = (strcmp(old->rmact_gfx, real_packet->rmact_gfx) != 0);
31564   if (differ) {
31565     different++;
31566     BV_SET(fields, 9);
31567   }
31568 
31569   differ = (strcmp(old->rmact_gfx_alt, real_packet->rmact_gfx_alt) != 0);
31570   if (differ) {
31571     different++;
31572     BV_SET(fields, 10);
31573   }
31574 
31575   differ = (strcmp(old->graphic_str, real_packet->graphic_str) != 0);
31576   if (differ) {
31577     different++;
31578     BV_SET(fields, 11);
31579   }
31580 
31581   differ = (strcmp(old->graphic_alt, real_packet->graphic_alt) != 0);
31582   if (differ) {
31583     different++;
31584     BV_SET(fields, 12);
31585   }
31586 
31587   differ = (old->reqs_count != real_packet->reqs_count);
31588   if (differ) {
31589     different++;
31590     BV_SET(fields, 13);
31591   }
31592 
31593 
31594     {
31595       differ = (old->reqs_count != real_packet->reqs_count);
31596       if (!differ) {
31597         int i;
31598 
31599         for (i = 0; i < real_packet->reqs_count; i++) {
31600           if (!are_requirements_equal(&old->reqs[i], &real_packet->reqs[i])) {
31601             differ = TRUE;
31602             break;
31603           }
31604         }
31605       }
31606     }
31607   if (differ) {
31608     different++;
31609     BV_SET(fields, 14);
31610   }
31611 
31612   differ = (old->rmreqs_count != real_packet->rmreqs_count);
31613   if (differ) {
31614     different++;
31615     BV_SET(fields, 15);
31616   }
31617 
31618 
31619     {
31620       differ = (old->rmreqs_count != real_packet->rmreqs_count);
31621       if (!differ) {
31622         int i;
31623 
31624         for (i = 0; i < real_packet->rmreqs_count; i++) {
31625           if (!are_requirements_equal(&old->rmreqs[i], &real_packet->rmreqs[i])) {
31626             differ = TRUE;
31627             break;
31628           }
31629         }
31630       }
31631     }
31632   if (differ) {
31633     different++;
31634     BV_SET(fields, 16);
31635   }
31636 
31637   differ = (old->buildable != real_packet->buildable);
31638   if (differ) {
31639     different++;
31640   }
31641   if (packet->buildable) {
31642     BV_SET(fields, 17);
31643   }
31644 
31645   differ = (old->build_time != real_packet->build_time);
31646   if (differ) {
31647     different++;
31648     BV_SET(fields, 18);
31649   }
31650 
31651   differ = (old->build_time_factor != real_packet->build_time_factor);
31652   if (differ) {
31653     different++;
31654     BV_SET(fields, 19);
31655   }
31656 
31657   differ = (old->removal_time != real_packet->removal_time);
31658   if (differ) {
31659     different++;
31660     BV_SET(fields, 20);
31661   }
31662 
31663   differ = (old->removal_time_factor != real_packet->removal_time_factor);
31664   if (differ) {
31665     different++;
31666     BV_SET(fields, 21);
31667   }
31668 
31669   differ = (old->defense_bonus != real_packet->defense_bonus);
31670   if (differ) {
31671     different++;
31672     BV_SET(fields, 22);
31673   }
31674 
31675   differ = !BV_ARE_EQUAL(old->native_to, real_packet->native_to);
31676   if (differ) {
31677     different++;
31678     BV_SET(fields, 23);
31679   }
31680 
31681   differ = !BV_ARE_EQUAL(old->flags, real_packet->flags);
31682   if (differ) {
31683     different++;
31684     BV_SET(fields, 24);
31685   }
31686 
31687   differ = !BV_ARE_EQUAL(old->hidden_by, real_packet->hidden_by);
31688   if (differ) {
31689     different++;
31690     BV_SET(fields, 25);
31691   }
31692 
31693   differ = !BV_ARE_EQUAL(old->conflicts, real_packet->conflicts);
31694   if (differ) {
31695     different++;
31696     BV_SET(fields, 26);
31697   }
31698 
31699   differ = (strcmp(old->helptext, real_packet->helptext) != 0);
31700   if (differ) {
31701     different++;
31702     BV_SET(fields, 27);
31703   }
31704 
31705 
31706   DIO_BV_PUT(&dout, "fields", fields);
31707 
31708   if (BV_ISSET(fields, 0)) {
31709     log_packet_detailed("  field 'id' has changed");
31710     DIO_PUT(uint8, &dout, "id", real_packet->id);
31711   }
31712   if (BV_ISSET(fields, 1)) {
31713     log_packet_detailed("  field 'name' has changed");
31714     DIO_PUT(string, &dout, "name", real_packet->name);
31715   }
31716   if (BV_ISSET(fields, 2)) {
31717     log_packet_detailed("  field 'rule_name' has changed");
31718     DIO_PUT(string, &dout, "rule_name", real_packet->rule_name);
31719   }
31720   if (BV_ISSET(fields, 3)) {
31721     log_packet_detailed("  field 'category' has changed");
31722     DIO_PUT(uint8, &dout, "category", real_packet->category);
31723   }
31724   if (BV_ISSET(fields, 4)) {
31725     log_packet_detailed("  field 'causes' has changed");
31726     DIO_PUT(uint8, &dout, "causes", real_packet->causes);
31727   }
31728   if (BV_ISSET(fields, 5)) {
31729     log_packet_detailed("  field 'rmcauses' has changed");
31730     DIO_PUT(uint8, &dout, "rmcauses", real_packet->rmcauses);
31731   }
31732   if (BV_ISSET(fields, 6)) {
31733     log_packet_detailed("  field 'activity_gfx' has changed");
31734     DIO_PUT(string, &dout, "activity_gfx", real_packet->activity_gfx);
31735   }
31736   if (BV_ISSET(fields, 7)) {
31737     log_packet_detailed("  field 'act_gfx_alt' has changed");
31738     DIO_PUT(string, &dout, "act_gfx_alt", real_packet->act_gfx_alt);
31739   }
31740   if (BV_ISSET(fields, 8)) {
31741     log_packet_detailed("  field 'act_gfx_alt2' has changed");
31742     DIO_PUT(string, &dout, "act_gfx_alt2", real_packet->act_gfx_alt2);
31743   }
31744   if (BV_ISSET(fields, 9)) {
31745     log_packet_detailed("  field 'rmact_gfx' has changed");
31746     DIO_PUT(string, &dout, "rmact_gfx", real_packet->rmact_gfx);
31747   }
31748   if (BV_ISSET(fields, 10)) {
31749     log_packet_detailed("  field 'rmact_gfx_alt' has changed");
31750     DIO_PUT(string, &dout, "rmact_gfx_alt", real_packet->rmact_gfx_alt);
31751   }
31752   if (BV_ISSET(fields, 11)) {
31753     log_packet_detailed("  field 'graphic_str' has changed");
31754     DIO_PUT(string, &dout, "graphic_str", real_packet->graphic_str);
31755   }
31756   if (BV_ISSET(fields, 12)) {
31757     log_packet_detailed("  field 'graphic_alt' has changed");
31758     DIO_PUT(string, &dout, "graphic_alt", real_packet->graphic_alt);
31759   }
31760   if (BV_ISSET(fields, 13)) {
31761     log_packet_detailed("  field 'reqs_count' has changed");
31762     DIO_PUT(uint8, &dout, "reqs_count", real_packet->reqs_count);
31763   }
31764   if (BV_ISSET(fields, 14)) {
31765     log_packet_detailed("  field 'reqs' has changed");
31766 
31767     {
31768       int i;
31769 
31770       for (i = 0; i < real_packet->reqs_count; i++) {
31771         dio_put_requirement(&dout, &real_packet->reqs[i]);
31772       }
31773     }
31774   }
31775   if (BV_ISSET(fields, 15)) {
31776     log_packet_detailed("  field 'rmreqs_count' has changed");
31777     DIO_PUT(uint8, &dout, "rmreqs_count", real_packet->rmreqs_count);
31778   }
31779   if (BV_ISSET(fields, 16)) {
31780     log_packet_detailed("  field 'rmreqs' has changed");
31781 
31782     {
31783       int i;
31784 
31785       for (i = 0; i < real_packet->rmreqs_count; i++) {
31786         dio_put_requirement(&dout, &real_packet->rmreqs[i]);
31787       }
31788     }
31789   }
31790   /* field 17 is folded into the header */
31791   if (BV_ISSET(fields, 18)) {
31792     log_packet_detailed("  field 'build_time' has changed");
31793     DIO_PUT(uint8, &dout, "build_time", real_packet->build_time);
31794   }
31795   if (BV_ISSET(fields, 19)) {
31796     log_packet_detailed("  field 'build_time_factor' has changed");
31797     DIO_PUT(uint8, &dout, "build_time_factor", real_packet->build_time_factor);
31798   }
31799   if (BV_ISSET(fields, 20)) {
31800     log_packet_detailed("  field 'removal_time' has changed");
31801     DIO_PUT(uint8, &dout, "removal_time", real_packet->removal_time);
31802   }
31803   if (BV_ISSET(fields, 21)) {
31804     log_packet_detailed("  field 'removal_time_factor' has changed");
31805     DIO_PUT(uint8, &dout, "removal_time_factor", real_packet->removal_time_factor);
31806   }
31807   if (BV_ISSET(fields, 22)) {
31808     log_packet_detailed("  field 'defense_bonus' has changed");
31809     DIO_PUT(uint8, &dout, "defense_bonus", real_packet->defense_bonus);
31810   }
31811   if (BV_ISSET(fields, 23)) {
31812     log_packet_detailed("  field 'native_to' has changed");
31813   DIO_BV_PUT(&dout, "native_to", packet->native_to);
31814   }
31815   if (BV_ISSET(fields, 24)) {
31816     log_packet_detailed("  field 'flags' has changed");
31817   DIO_BV_PUT(&dout, "flags", packet->flags);
31818   }
31819   if (BV_ISSET(fields, 25)) {
31820     log_packet_detailed("  field 'hidden_by' has changed");
31821   DIO_BV_PUT(&dout, "hidden_by", packet->hidden_by);
31822   }
31823   if (BV_ISSET(fields, 26)) {
31824     log_packet_detailed("  field 'conflicts' has changed");
31825   DIO_BV_PUT(&dout, "conflicts", packet->conflicts);
31826   }
31827   if (BV_ISSET(fields, 27)) {
31828     log_packet_detailed("  field 'helptext' has changed");
31829     DIO_PUT(string, &dout, "helptext", real_packet->helptext);
31830   }
31831 
31832   *old = *real_packet;
31833   SEND_PACKET_END(PACKET_RULESET_EXTRA);
31834 }
31835 
send_packet_ruleset_extra(struct connection * pc,const struct packet_ruleset_extra * packet)31836 int send_packet_ruleset_extra(struct connection *pc, const struct packet_ruleset_extra *packet)
31837 {
31838   if (!pc->used) {
31839     log_error("WARNING: trying to send data to the closed connection %s",
31840               conn_description(pc));
31841     return -1;
31842   }
31843   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_EXTRA].packet != NULL, -1,
31844                         "Handler for PACKET_RULESET_EXTRA not installed");
31845   return pc->phs.handlers->send[PACKET_RULESET_EXTRA].packet(pc, packet);
31846 }
31847 
lsend_packet_ruleset_extra(struct conn_list * dest,const struct packet_ruleset_extra * packet)31848 void lsend_packet_ruleset_extra(struct conn_list *dest, const struct packet_ruleset_extra *packet)
31849 {
31850   conn_list_iterate(dest, pconn) {
31851     send_packet_ruleset_extra(pconn, packet);
31852   } conn_list_iterate_end;
31853 }
31854 
31855 #define hash_packet_ruleset_base_100 hash_const
31856 
31857 #define cmp_packet_ruleset_base_100 cmp_const
31858 
31859 BV_DEFINE(packet_ruleset_base_100_fields, 6);
31860 
receive_packet_ruleset_base_100(struct connection * pc)31861 static struct packet_ruleset_base *receive_packet_ruleset_base_100(struct connection *pc)
31862 {
31863   packet_ruleset_base_100_fields fields;
31864   struct packet_ruleset_base *old;
31865   struct genhash **hash = pc->phs.received + PACKET_RULESET_BASE;
31866   RECEIVE_PACKET_START(packet_ruleset_base, real_packet);
31867 
31868   DIO_BV_GET(&din, fields);
31869 
31870   log_packet_detailed("packet_ruleset_base_100: got info about ()");
31871 
31872   if (NULL == *hash) {
31873     *hash = genhash_new_full(hash_packet_ruleset_base_100, cmp_packet_ruleset_base_100,
31874                              NULL, NULL, NULL, free);
31875   }
31876 
31877   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
31878     *real_packet = *old;
31879   } else {
31880     log_packet_detailed("  no old info");
31881     memset(real_packet, 0, sizeof(*real_packet));
31882   }
31883 
31884   if (BV_ISSET(fields, 0)) {
31885     log_packet_detailed("  got field 'id'");
31886     if (!DIO_GET(uint8, &din, "id", &real_packet->id)) {
31887       RECEIVE_PACKET_FIELD_ERROR(id);
31888     }
31889   }
31890   if (BV_ISSET(fields, 1)) {
31891     log_packet_detailed("  got field 'gui_type'");
31892     {
31893       int readin;
31894 
31895       if (!DIO_GET(uint8, &din, "gui_type", &readin)) {
31896         RECEIVE_PACKET_FIELD_ERROR(gui_type);
31897       }
31898       real_packet->gui_type = readin;
31899     }
31900   }
31901   if (BV_ISSET(fields, 2)) {
31902     log_packet_detailed("  got field 'border_sq'");
31903     if (!DIO_GET(sint8, &din, "border_sq", &real_packet->border_sq)) {
31904       RECEIVE_PACKET_FIELD_ERROR(border_sq);
31905     }
31906   }
31907   if (BV_ISSET(fields, 3)) {
31908     log_packet_detailed("  got field 'vision_main_sq'");
31909     if (!DIO_GET(sint8, &din, "vision_main_sq", &real_packet->vision_main_sq)) {
31910       RECEIVE_PACKET_FIELD_ERROR(vision_main_sq);
31911     }
31912   }
31913   if (BV_ISSET(fields, 4)) {
31914     log_packet_detailed("  got field 'vision_invis_sq'");
31915     if (!DIO_GET(sint8, &din, "vision_invis_sq", &real_packet->vision_invis_sq)) {
31916       RECEIVE_PACKET_FIELD_ERROR(vision_invis_sq);
31917     }
31918   }
31919   if (BV_ISSET(fields, 5)) {
31920     log_packet_detailed("  got field 'flags'");
31921     if (!DIO_BV_GET(&din, real_packet->flags)) {
31922       RECEIVE_PACKET_FIELD_ERROR(flags);
31923     }
31924   }
31925 
31926   if (NULL == old) {
31927     old = fc_malloc(sizeof(*old));
31928     *old = *real_packet;
31929     genhash_insert(*hash, old, old);
31930   } else {
31931     *old = *real_packet;
31932   }
31933   RECEIVE_PACKET_END(real_packet);
31934 }
31935 
send_packet_ruleset_base_100(struct connection * pc,const struct packet_ruleset_base * packet)31936 static int send_packet_ruleset_base_100(struct connection *pc, const struct packet_ruleset_base *packet)
31937 {
31938   const struct packet_ruleset_base *real_packet = packet;
31939   packet_ruleset_base_100_fields fields;
31940   struct packet_ruleset_base *old;
31941   bool differ;
31942   struct genhash **hash = pc->phs.sent + PACKET_RULESET_BASE;
31943   int different = 0;
31944   SEND_PACKET_START(PACKET_RULESET_BASE);
31945 
31946   log_packet_detailed("packet_ruleset_base_100: sending info about ()");
31947 
31948   if (NULL == *hash) {
31949     *hash = genhash_new_full(hash_packet_ruleset_base_100, cmp_packet_ruleset_base_100,
31950                              NULL, NULL, NULL, free);
31951   }
31952   BV_CLR_ALL(fields);
31953 
31954   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
31955     old = fc_malloc(sizeof(*old));
31956     *old = *real_packet;
31957     genhash_insert(*hash, old, old);
31958     memset(old, 0, sizeof(*old));
31959     different = 1;      /* Force to send. */
31960   }
31961 
31962   differ = (old->id != real_packet->id);
31963   if (differ) {
31964     different++;
31965     BV_SET(fields, 0);
31966   }
31967 
31968   differ = (old->gui_type != real_packet->gui_type);
31969   if (differ) {
31970     different++;
31971     BV_SET(fields, 1);
31972   }
31973 
31974   differ = (old->border_sq != real_packet->border_sq);
31975   if (differ) {
31976     different++;
31977     BV_SET(fields, 2);
31978   }
31979 
31980   differ = (old->vision_main_sq != real_packet->vision_main_sq);
31981   if (differ) {
31982     different++;
31983     BV_SET(fields, 3);
31984   }
31985 
31986   differ = (old->vision_invis_sq != real_packet->vision_invis_sq);
31987   if (differ) {
31988     different++;
31989     BV_SET(fields, 4);
31990   }
31991 
31992   differ = !BV_ARE_EQUAL(old->flags, real_packet->flags);
31993   if (differ) {
31994     different++;
31995     BV_SET(fields, 5);
31996   }
31997 
31998 
31999   DIO_BV_PUT(&dout, "fields", fields);
32000 
32001   if (BV_ISSET(fields, 0)) {
32002     log_packet_detailed("  field 'id' has changed");
32003     DIO_PUT(uint8, &dout, "id", real_packet->id);
32004   }
32005   if (BV_ISSET(fields, 1)) {
32006     log_packet_detailed("  field 'gui_type' has changed");
32007     DIO_PUT(uint8, &dout, "gui_type", real_packet->gui_type);
32008   }
32009   if (BV_ISSET(fields, 2)) {
32010     log_packet_detailed("  field 'border_sq' has changed");
32011     DIO_PUT(sint8, &dout, "border_sq", real_packet->border_sq);
32012   }
32013   if (BV_ISSET(fields, 3)) {
32014     log_packet_detailed("  field 'vision_main_sq' has changed");
32015     DIO_PUT(sint8, &dout, "vision_main_sq", real_packet->vision_main_sq);
32016   }
32017   if (BV_ISSET(fields, 4)) {
32018     log_packet_detailed("  field 'vision_invis_sq' has changed");
32019     DIO_PUT(sint8, &dout, "vision_invis_sq", real_packet->vision_invis_sq);
32020   }
32021   if (BV_ISSET(fields, 5)) {
32022     log_packet_detailed("  field 'flags' has changed");
32023   DIO_BV_PUT(&dout, "flags", packet->flags);
32024   }
32025 
32026   *old = *real_packet;
32027   SEND_PACKET_END(PACKET_RULESET_BASE);
32028 }
32029 
send_packet_ruleset_base(struct connection * pc,const struct packet_ruleset_base * packet)32030 int send_packet_ruleset_base(struct connection *pc, const struct packet_ruleset_base *packet)
32031 {
32032   if (!pc->used) {
32033     log_error("WARNING: trying to send data to the closed connection %s",
32034               conn_description(pc));
32035     return -1;
32036   }
32037   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_BASE].packet != NULL, -1,
32038                         "Handler for PACKET_RULESET_BASE not installed");
32039   return pc->phs.handlers->send[PACKET_RULESET_BASE].packet(pc, packet);
32040 }
32041 
lsend_packet_ruleset_base(struct conn_list * dest,const struct packet_ruleset_base * packet)32042 void lsend_packet_ruleset_base(struct conn_list *dest, const struct packet_ruleset_base *packet)
32043 {
32044   conn_list_iterate(dest, pconn) {
32045     send_packet_ruleset_base(pconn, packet);
32046   } conn_list_iterate_end;
32047 }
32048 
32049 #define hash_packet_ruleset_road_100 hash_const
32050 
32051 #define cmp_packet_ruleset_road_100 cmp_const
32052 
32053 BV_DEFINE(packet_ruleset_road_100_fields, 11);
32054 
receive_packet_ruleset_road_100(struct connection * pc)32055 static struct packet_ruleset_road *receive_packet_ruleset_road_100(struct connection *pc)
32056 {
32057   packet_ruleset_road_100_fields fields;
32058   struct packet_ruleset_road *old;
32059   struct genhash **hash = pc->phs.received + PACKET_RULESET_ROAD;
32060   RECEIVE_PACKET_START(packet_ruleset_road, real_packet);
32061 
32062   DIO_BV_GET(&din, fields);
32063 
32064   log_packet_detailed("packet_ruleset_road_100: got info about ()");
32065 
32066   if (NULL == *hash) {
32067     *hash = genhash_new_full(hash_packet_ruleset_road_100, cmp_packet_ruleset_road_100,
32068                              NULL, NULL, NULL, free);
32069   }
32070 
32071   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
32072     *real_packet = *old;
32073   } else {
32074     log_packet_detailed("  no old info");
32075     memset(real_packet, 0, sizeof(*real_packet));
32076   }
32077 
32078   if (BV_ISSET(fields, 0)) {
32079     log_packet_detailed("  got field 'id'");
32080     if (!DIO_GET(uint8, &din, "id", &real_packet->id)) {
32081       RECEIVE_PACKET_FIELD_ERROR(id);
32082     }
32083   }
32084   if (BV_ISSET(fields, 1)) {
32085     log_packet_detailed("  got field 'first_reqs_count'");
32086     if (!DIO_GET(uint8, &din, "first_reqs_count", &real_packet->first_reqs_count)) {
32087       RECEIVE_PACKET_FIELD_ERROR(first_reqs_count);
32088     }
32089   }
32090   if (BV_ISSET(fields, 2)) {
32091     log_packet_detailed("  got field 'first_reqs'");
32092 
32093     {
32094       int i;
32095 
32096       if (real_packet->first_reqs_count > MAX_NUM_REQS) {
32097         RECEIVE_PACKET_FIELD_ERROR(first_reqs, ": truncation array");
32098       }
32099       for (i = 0; i < real_packet->first_reqs_count; i++) {
32100         if (!DIO_GET(requirement, &din, "first_reqs", &real_packet->first_reqs[i])) {
32101           RECEIVE_PACKET_FIELD_ERROR(first_reqs);
32102         }
32103       }
32104     }
32105   }
32106   if (BV_ISSET(fields, 3)) {
32107     log_packet_detailed("  got field 'move_cost'");
32108     if (!DIO_GET(sint16, &din, "move_cost", &real_packet->move_cost)) {
32109       RECEIVE_PACKET_FIELD_ERROR(move_cost);
32110     }
32111   }
32112   if (BV_ISSET(fields, 4)) {
32113     log_packet_detailed("  got field 'move_mode'");
32114     {
32115       int readin;
32116 
32117       if (!DIO_GET(uint8, &din, "move_mode", &readin)) {
32118         RECEIVE_PACKET_FIELD_ERROR(move_mode);
32119       }
32120       real_packet->move_mode = readin;
32121     }
32122   }
32123   if (BV_ISSET(fields, 5)) {
32124     log_packet_detailed("  got field 'tile_incr_const'");
32125 
32126     {
32127       int i;
32128 
32129       for (i = 0; i < O_LAST; i++) {
32130         if (!DIO_GET(uint16, &din, "tile_incr_const", &real_packet->tile_incr_const[i])) {
32131           RECEIVE_PACKET_FIELD_ERROR(tile_incr_const);
32132         }
32133       }
32134     }
32135   }
32136   if (BV_ISSET(fields, 6)) {
32137     log_packet_detailed("  got field 'tile_incr'");
32138 
32139     {
32140       int i;
32141 
32142       for (i = 0; i < O_LAST; i++) {
32143         if (!DIO_GET(uint16, &din, "tile_incr", &real_packet->tile_incr[i])) {
32144           RECEIVE_PACKET_FIELD_ERROR(tile_incr);
32145         }
32146       }
32147     }
32148   }
32149   if (BV_ISSET(fields, 7)) {
32150     log_packet_detailed("  got field 'tile_bonus'");
32151 
32152     {
32153       int i;
32154 
32155       for (i = 0; i < O_LAST; i++) {
32156         if (!DIO_GET(uint16, &din, "tile_bonus", &real_packet->tile_bonus[i])) {
32157           RECEIVE_PACKET_FIELD_ERROR(tile_bonus);
32158         }
32159       }
32160     }
32161   }
32162   if (BV_ISSET(fields, 8)) {
32163     log_packet_detailed("  got field 'compat'");
32164     {
32165       int readin;
32166 
32167       if (!DIO_GET(uint8, &din, "compat", &readin)) {
32168         RECEIVE_PACKET_FIELD_ERROR(compat);
32169       }
32170       real_packet->compat = readin;
32171     }
32172   }
32173   if (BV_ISSET(fields, 9)) {
32174     log_packet_detailed("  got field 'integrates'");
32175     if (!DIO_BV_GET(&din, real_packet->integrates)) {
32176       RECEIVE_PACKET_FIELD_ERROR(integrates);
32177     }
32178   }
32179   if (BV_ISSET(fields, 10)) {
32180     log_packet_detailed("  got field 'flags'");
32181     if (!DIO_BV_GET(&din, real_packet->flags)) {
32182       RECEIVE_PACKET_FIELD_ERROR(flags);
32183     }
32184   }
32185 
32186   if (NULL == old) {
32187     old = fc_malloc(sizeof(*old));
32188     *old = *real_packet;
32189     genhash_insert(*hash, old, old);
32190   } else {
32191     *old = *real_packet;
32192   }
32193   RECEIVE_PACKET_END(real_packet);
32194 }
32195 
send_packet_ruleset_road_100(struct connection * pc,const struct packet_ruleset_road * packet)32196 static int send_packet_ruleset_road_100(struct connection *pc, const struct packet_ruleset_road *packet)
32197 {
32198   const struct packet_ruleset_road *real_packet = packet;
32199   packet_ruleset_road_100_fields fields;
32200   struct packet_ruleset_road *old;
32201   bool differ;
32202   struct genhash **hash = pc->phs.sent + PACKET_RULESET_ROAD;
32203   int different = 0;
32204   SEND_PACKET_START(PACKET_RULESET_ROAD);
32205 
32206   log_packet_detailed("packet_ruleset_road_100: sending info about ()");
32207 
32208   if (NULL == *hash) {
32209     *hash = genhash_new_full(hash_packet_ruleset_road_100, cmp_packet_ruleset_road_100,
32210                              NULL, NULL, NULL, free);
32211   }
32212   BV_CLR_ALL(fields);
32213 
32214   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
32215     old = fc_malloc(sizeof(*old));
32216     *old = *real_packet;
32217     genhash_insert(*hash, old, old);
32218     memset(old, 0, sizeof(*old));
32219     different = 1;      /* Force to send. */
32220   }
32221 
32222   differ = (old->id != real_packet->id);
32223   if (differ) {
32224     different++;
32225     BV_SET(fields, 0);
32226   }
32227 
32228   differ = (old->first_reqs_count != real_packet->first_reqs_count);
32229   if (differ) {
32230     different++;
32231     BV_SET(fields, 1);
32232   }
32233 
32234 
32235     {
32236       differ = (old->first_reqs_count != real_packet->first_reqs_count);
32237       if (!differ) {
32238         int i;
32239 
32240         for (i = 0; i < real_packet->first_reqs_count; i++) {
32241           if (!are_requirements_equal(&old->first_reqs[i], &real_packet->first_reqs[i])) {
32242             differ = TRUE;
32243             break;
32244           }
32245         }
32246       }
32247     }
32248   if (differ) {
32249     different++;
32250     BV_SET(fields, 2);
32251   }
32252 
32253   differ = (old->move_cost != real_packet->move_cost);
32254   if (differ) {
32255     different++;
32256     BV_SET(fields, 3);
32257   }
32258 
32259   differ = (old->move_mode != real_packet->move_mode);
32260   if (differ) {
32261     different++;
32262     BV_SET(fields, 4);
32263   }
32264 
32265 
32266     {
32267       differ = (O_LAST != O_LAST);
32268       if (!differ) {
32269         int i;
32270 
32271         for (i = 0; i < O_LAST; i++) {
32272           if (old->tile_incr_const[i] != real_packet->tile_incr_const[i]) {
32273             differ = TRUE;
32274             break;
32275           }
32276         }
32277       }
32278     }
32279   if (differ) {
32280     different++;
32281     BV_SET(fields, 5);
32282   }
32283 
32284 
32285     {
32286       differ = (O_LAST != O_LAST);
32287       if (!differ) {
32288         int i;
32289 
32290         for (i = 0; i < O_LAST; i++) {
32291           if (old->tile_incr[i] != real_packet->tile_incr[i]) {
32292             differ = TRUE;
32293             break;
32294           }
32295         }
32296       }
32297     }
32298   if (differ) {
32299     different++;
32300     BV_SET(fields, 6);
32301   }
32302 
32303 
32304     {
32305       differ = (O_LAST != O_LAST);
32306       if (!differ) {
32307         int i;
32308 
32309         for (i = 0; i < O_LAST; i++) {
32310           if (old->tile_bonus[i] != real_packet->tile_bonus[i]) {
32311             differ = TRUE;
32312             break;
32313           }
32314         }
32315       }
32316     }
32317   if (differ) {
32318     different++;
32319     BV_SET(fields, 7);
32320   }
32321 
32322   differ = (old->compat != real_packet->compat);
32323   if (differ) {
32324     different++;
32325     BV_SET(fields, 8);
32326   }
32327 
32328   differ = !BV_ARE_EQUAL(old->integrates, real_packet->integrates);
32329   if (differ) {
32330     different++;
32331     BV_SET(fields, 9);
32332   }
32333 
32334   differ = !BV_ARE_EQUAL(old->flags, real_packet->flags);
32335   if (differ) {
32336     different++;
32337     BV_SET(fields, 10);
32338   }
32339 
32340 
32341   DIO_BV_PUT(&dout, "fields", fields);
32342 
32343   if (BV_ISSET(fields, 0)) {
32344     log_packet_detailed("  field 'id' has changed");
32345     DIO_PUT(uint8, &dout, "id", real_packet->id);
32346   }
32347   if (BV_ISSET(fields, 1)) {
32348     log_packet_detailed("  field 'first_reqs_count' has changed");
32349     DIO_PUT(uint8, &dout, "first_reqs_count", real_packet->first_reqs_count);
32350   }
32351   if (BV_ISSET(fields, 2)) {
32352     log_packet_detailed("  field 'first_reqs' has changed");
32353 
32354     {
32355       int i;
32356 
32357       for (i = 0; i < real_packet->first_reqs_count; i++) {
32358         dio_put_requirement(&dout, &real_packet->first_reqs[i]);
32359       }
32360     }
32361   }
32362   if (BV_ISSET(fields, 3)) {
32363     log_packet_detailed("  field 'move_cost' has changed");
32364     DIO_PUT(sint16, &dout, "move_cost", real_packet->move_cost);
32365   }
32366   if (BV_ISSET(fields, 4)) {
32367     log_packet_detailed("  field 'move_mode' has changed");
32368     DIO_PUT(uint8, &dout, "move_mode", real_packet->move_mode);
32369   }
32370   if (BV_ISSET(fields, 5)) {
32371     log_packet_detailed("  field 'tile_incr_const' has changed");
32372 
32373     {
32374       int i;
32375 
32376       for (i = 0; i < O_LAST; i++) {
32377         dio_put_uint16(&dout, real_packet->tile_incr_const[i]);
32378       }
32379     }
32380   }
32381   if (BV_ISSET(fields, 6)) {
32382     log_packet_detailed("  field 'tile_incr' has changed");
32383 
32384     {
32385       int i;
32386 
32387       for (i = 0; i < O_LAST; i++) {
32388         dio_put_uint16(&dout, real_packet->tile_incr[i]);
32389       }
32390     }
32391   }
32392   if (BV_ISSET(fields, 7)) {
32393     log_packet_detailed("  field 'tile_bonus' has changed");
32394 
32395     {
32396       int i;
32397 
32398       for (i = 0; i < O_LAST; i++) {
32399         dio_put_uint16(&dout, real_packet->tile_bonus[i]);
32400       }
32401     }
32402   }
32403   if (BV_ISSET(fields, 8)) {
32404     log_packet_detailed("  field 'compat' has changed");
32405     DIO_PUT(uint8, &dout, "compat", real_packet->compat);
32406   }
32407   if (BV_ISSET(fields, 9)) {
32408     log_packet_detailed("  field 'integrates' has changed");
32409   DIO_BV_PUT(&dout, "integrates", packet->integrates);
32410   }
32411   if (BV_ISSET(fields, 10)) {
32412     log_packet_detailed("  field 'flags' has changed");
32413   DIO_BV_PUT(&dout, "flags", packet->flags);
32414   }
32415 
32416   *old = *real_packet;
32417   SEND_PACKET_END(PACKET_RULESET_ROAD);
32418 }
32419 
send_packet_ruleset_road(struct connection * pc,const struct packet_ruleset_road * packet)32420 int send_packet_ruleset_road(struct connection *pc, const struct packet_ruleset_road *packet)
32421 {
32422   if (!pc->used) {
32423     log_error("WARNING: trying to send data to the closed connection %s",
32424               conn_description(pc));
32425     return -1;
32426   }
32427   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_ROAD].packet != NULL, -1,
32428                         "Handler for PACKET_RULESET_ROAD not installed");
32429   return pc->phs.handlers->send[PACKET_RULESET_ROAD].packet(pc, packet);
32430 }
32431 
lsend_packet_ruleset_road(struct conn_list * dest,const struct packet_ruleset_road * packet)32432 void lsend_packet_ruleset_road(struct conn_list *dest, const struct packet_ruleset_road *packet)
32433 {
32434   conn_list_iterate(dest, pconn) {
32435     send_packet_ruleset_road(pconn, packet);
32436   } conn_list_iterate_end;
32437 }
32438 
32439 #define hash_packet_ruleset_disaster_100 hash_const
32440 
32441 #define cmp_packet_ruleset_disaster_100 cmp_const
32442 
32443 BV_DEFINE(packet_ruleset_disaster_100_fields, 7);
32444 
receive_packet_ruleset_disaster_100(struct connection * pc)32445 static struct packet_ruleset_disaster *receive_packet_ruleset_disaster_100(struct connection *pc)
32446 {
32447   packet_ruleset_disaster_100_fields fields;
32448   struct packet_ruleset_disaster *old;
32449   struct genhash **hash = pc->phs.received + PACKET_RULESET_DISASTER;
32450   RECEIVE_PACKET_START(packet_ruleset_disaster, real_packet);
32451 
32452   DIO_BV_GET(&din, fields);
32453 
32454   log_packet_detailed("packet_ruleset_disaster_100: got info about ()");
32455 
32456   if (NULL == *hash) {
32457     *hash = genhash_new_full(hash_packet_ruleset_disaster_100, cmp_packet_ruleset_disaster_100,
32458                              NULL, NULL, NULL, free);
32459   }
32460 
32461   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
32462     *real_packet = *old;
32463   } else {
32464     log_packet_detailed("  no old info");
32465     memset(real_packet, 0, sizeof(*real_packet));
32466   }
32467 
32468   if (BV_ISSET(fields, 0)) {
32469     log_packet_detailed("  got field 'id'");
32470     if (!DIO_GET(uint8, &din, "id", &real_packet->id)) {
32471       RECEIVE_PACKET_FIELD_ERROR(id);
32472     }
32473   }
32474   if (BV_ISSET(fields, 1)) {
32475     log_packet_detailed("  got field 'name'");
32476     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
32477       RECEIVE_PACKET_FIELD_ERROR(name);
32478     }
32479   }
32480   if (BV_ISSET(fields, 2)) {
32481     log_packet_detailed("  got field 'rule_name'");
32482     if (!DIO_GET(string, &din, "rule_name", real_packet->rule_name, sizeof(real_packet->rule_name))) {
32483       RECEIVE_PACKET_FIELD_ERROR(rule_name);
32484     }
32485   }
32486   if (BV_ISSET(fields, 3)) {
32487     log_packet_detailed("  got field 'reqs_count'");
32488     if (!DIO_GET(uint8, &din, "reqs_count", &real_packet->reqs_count)) {
32489       RECEIVE_PACKET_FIELD_ERROR(reqs_count);
32490     }
32491   }
32492   if (BV_ISSET(fields, 4)) {
32493     log_packet_detailed("  got field 'reqs'");
32494 
32495     {
32496       int i;
32497 
32498       if (real_packet->reqs_count > MAX_NUM_REQS) {
32499         RECEIVE_PACKET_FIELD_ERROR(reqs, ": truncation array");
32500       }
32501       for (i = 0; i < real_packet->reqs_count; i++) {
32502         if (!DIO_GET(requirement, &din, "reqs", &real_packet->reqs[i])) {
32503           RECEIVE_PACKET_FIELD_ERROR(reqs);
32504         }
32505       }
32506     }
32507   }
32508   if (BV_ISSET(fields, 5)) {
32509     log_packet_detailed("  got field 'frequency'");
32510     if (!DIO_GET(uint8, &din, "frequency", &real_packet->frequency)) {
32511       RECEIVE_PACKET_FIELD_ERROR(frequency);
32512     }
32513   }
32514   if (BV_ISSET(fields, 6)) {
32515     log_packet_detailed("  got field 'effects'");
32516     if (!DIO_BV_GET(&din, real_packet->effects)) {
32517       RECEIVE_PACKET_FIELD_ERROR(effects);
32518     }
32519   }
32520 
32521   if (NULL == old) {
32522     old = fc_malloc(sizeof(*old));
32523     *old = *real_packet;
32524     genhash_insert(*hash, old, old);
32525   } else {
32526     *old = *real_packet;
32527   }
32528   RECEIVE_PACKET_END(real_packet);
32529 }
32530 
send_packet_ruleset_disaster_100(struct connection * pc,const struct packet_ruleset_disaster * packet)32531 static int send_packet_ruleset_disaster_100(struct connection *pc, const struct packet_ruleset_disaster *packet)
32532 {
32533   const struct packet_ruleset_disaster *real_packet = packet;
32534   packet_ruleset_disaster_100_fields fields;
32535   struct packet_ruleset_disaster *old;
32536   bool differ;
32537   struct genhash **hash = pc->phs.sent + PACKET_RULESET_DISASTER;
32538   int different = 0;
32539   SEND_PACKET_START(PACKET_RULESET_DISASTER);
32540 
32541   log_packet_detailed("packet_ruleset_disaster_100: sending info about ()");
32542 
32543   if (NULL == *hash) {
32544     *hash = genhash_new_full(hash_packet_ruleset_disaster_100, cmp_packet_ruleset_disaster_100,
32545                              NULL, NULL, NULL, free);
32546   }
32547   BV_CLR_ALL(fields);
32548 
32549   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
32550     old = fc_malloc(sizeof(*old));
32551     *old = *real_packet;
32552     genhash_insert(*hash, old, old);
32553     memset(old, 0, sizeof(*old));
32554     different = 1;      /* Force to send. */
32555   }
32556 
32557   differ = (old->id != real_packet->id);
32558   if (differ) {
32559     different++;
32560     BV_SET(fields, 0);
32561   }
32562 
32563   differ = (strcmp(old->name, real_packet->name) != 0);
32564   if (differ) {
32565     different++;
32566     BV_SET(fields, 1);
32567   }
32568 
32569   differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
32570   if (differ) {
32571     different++;
32572     BV_SET(fields, 2);
32573   }
32574 
32575   differ = (old->reqs_count != real_packet->reqs_count);
32576   if (differ) {
32577     different++;
32578     BV_SET(fields, 3);
32579   }
32580 
32581 
32582     {
32583       differ = (old->reqs_count != real_packet->reqs_count);
32584       if (!differ) {
32585         int i;
32586 
32587         for (i = 0; i < real_packet->reqs_count; i++) {
32588           if (!are_requirements_equal(&old->reqs[i], &real_packet->reqs[i])) {
32589             differ = TRUE;
32590             break;
32591           }
32592         }
32593       }
32594     }
32595   if (differ) {
32596     different++;
32597     BV_SET(fields, 4);
32598   }
32599 
32600   differ = (old->frequency != real_packet->frequency);
32601   if (differ) {
32602     different++;
32603     BV_SET(fields, 5);
32604   }
32605 
32606   differ = !BV_ARE_EQUAL(old->effects, real_packet->effects);
32607   if (differ) {
32608     different++;
32609     BV_SET(fields, 6);
32610   }
32611 
32612 
32613   DIO_BV_PUT(&dout, "fields", fields);
32614 
32615   if (BV_ISSET(fields, 0)) {
32616     log_packet_detailed("  field 'id' has changed");
32617     DIO_PUT(uint8, &dout, "id", real_packet->id);
32618   }
32619   if (BV_ISSET(fields, 1)) {
32620     log_packet_detailed("  field 'name' has changed");
32621     DIO_PUT(string, &dout, "name", real_packet->name);
32622   }
32623   if (BV_ISSET(fields, 2)) {
32624     log_packet_detailed("  field 'rule_name' has changed");
32625     DIO_PUT(string, &dout, "rule_name", real_packet->rule_name);
32626   }
32627   if (BV_ISSET(fields, 3)) {
32628     log_packet_detailed("  field 'reqs_count' has changed");
32629     DIO_PUT(uint8, &dout, "reqs_count", real_packet->reqs_count);
32630   }
32631   if (BV_ISSET(fields, 4)) {
32632     log_packet_detailed("  field 'reqs' has changed");
32633 
32634     {
32635       int i;
32636 
32637       for (i = 0; i < real_packet->reqs_count; i++) {
32638         dio_put_requirement(&dout, &real_packet->reqs[i]);
32639       }
32640     }
32641   }
32642   if (BV_ISSET(fields, 5)) {
32643     log_packet_detailed("  field 'frequency' has changed");
32644     DIO_PUT(uint8, &dout, "frequency", real_packet->frequency);
32645   }
32646   if (BV_ISSET(fields, 6)) {
32647     log_packet_detailed("  field 'effects' has changed");
32648   DIO_BV_PUT(&dout, "effects", packet->effects);
32649   }
32650 
32651   *old = *real_packet;
32652   SEND_PACKET_END(PACKET_RULESET_DISASTER);
32653 }
32654 
send_packet_ruleset_disaster(struct connection * pc,const struct packet_ruleset_disaster * packet)32655 int send_packet_ruleset_disaster(struct connection *pc, const struct packet_ruleset_disaster *packet)
32656 {
32657   if (!pc->used) {
32658     log_error("WARNING: trying to send data to the closed connection %s",
32659               conn_description(pc));
32660     return -1;
32661   }
32662   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_DISASTER].packet != NULL, -1,
32663                         "Handler for PACKET_RULESET_DISASTER not installed");
32664   return pc->phs.handlers->send[PACKET_RULESET_DISASTER].packet(pc, packet);
32665 }
32666 
lsend_packet_ruleset_disaster(struct conn_list * dest,const struct packet_ruleset_disaster * packet)32667 void lsend_packet_ruleset_disaster(struct conn_list *dest, const struct packet_ruleset_disaster *packet)
32668 {
32669   conn_list_iterate(dest, pconn) {
32670     send_packet_ruleset_disaster(pconn, packet);
32671   } conn_list_iterate_end;
32672 }
32673 
32674 #define hash_packet_ruleset_achievement_100 hash_const
32675 
32676 #define cmp_packet_ruleset_achievement_100 cmp_const
32677 
32678 BV_DEFINE(packet_ruleset_achievement_100_fields, 6);
32679 
receive_packet_ruleset_achievement_100(struct connection * pc)32680 static struct packet_ruleset_achievement *receive_packet_ruleset_achievement_100(struct connection *pc)
32681 {
32682   packet_ruleset_achievement_100_fields fields;
32683   struct packet_ruleset_achievement *old;
32684   struct genhash **hash = pc->phs.received + PACKET_RULESET_ACHIEVEMENT;
32685   RECEIVE_PACKET_START(packet_ruleset_achievement, real_packet);
32686 
32687   DIO_BV_GET(&din, fields);
32688 
32689   log_packet_detailed("packet_ruleset_achievement_100: got info about ()");
32690 
32691   if (NULL == *hash) {
32692     *hash = genhash_new_full(hash_packet_ruleset_achievement_100, cmp_packet_ruleset_achievement_100,
32693                              NULL, NULL, NULL, free);
32694   }
32695 
32696   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
32697     *real_packet = *old;
32698   } else {
32699     log_packet_detailed("  no old info");
32700     memset(real_packet, 0, sizeof(*real_packet));
32701   }
32702 
32703   if (BV_ISSET(fields, 0)) {
32704     log_packet_detailed("  got field 'id'");
32705     if (!DIO_GET(uint8, &din, "id", &real_packet->id)) {
32706       RECEIVE_PACKET_FIELD_ERROR(id);
32707     }
32708   }
32709   if (BV_ISSET(fields, 1)) {
32710     log_packet_detailed("  got field 'name'");
32711     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
32712       RECEIVE_PACKET_FIELD_ERROR(name);
32713     }
32714   }
32715   if (BV_ISSET(fields, 2)) {
32716     log_packet_detailed("  got field 'rule_name'");
32717     if (!DIO_GET(string, &din, "rule_name", real_packet->rule_name, sizeof(real_packet->rule_name))) {
32718       RECEIVE_PACKET_FIELD_ERROR(rule_name);
32719     }
32720   }
32721   if (BV_ISSET(fields, 3)) {
32722     log_packet_detailed("  got field 'type'");
32723     {
32724       int readin;
32725 
32726       if (!DIO_GET(uint8, &din, "type", &readin)) {
32727         RECEIVE_PACKET_FIELD_ERROR(type);
32728       }
32729       real_packet->type = readin;
32730     }
32731   }
32732   real_packet->unique = BV_ISSET(fields, 4);
32733   if (BV_ISSET(fields, 5)) {
32734     log_packet_detailed("  got field 'value'");
32735     if (!DIO_GET(uint16, &din, "value", &real_packet->value)) {
32736       RECEIVE_PACKET_FIELD_ERROR(value);
32737     }
32738   }
32739 
32740   if (NULL == old) {
32741     old = fc_malloc(sizeof(*old));
32742     *old = *real_packet;
32743     genhash_insert(*hash, old, old);
32744   } else {
32745     *old = *real_packet;
32746   }
32747   RECEIVE_PACKET_END(real_packet);
32748 }
32749 
send_packet_ruleset_achievement_100(struct connection * pc,const struct packet_ruleset_achievement * packet)32750 static int send_packet_ruleset_achievement_100(struct connection *pc, const struct packet_ruleset_achievement *packet)
32751 {
32752   const struct packet_ruleset_achievement *real_packet = packet;
32753   packet_ruleset_achievement_100_fields fields;
32754   struct packet_ruleset_achievement *old;
32755   bool differ;
32756   struct genhash **hash = pc->phs.sent + PACKET_RULESET_ACHIEVEMENT;
32757   int different = 0;
32758   SEND_PACKET_START(PACKET_RULESET_ACHIEVEMENT);
32759 
32760   log_packet_detailed("packet_ruleset_achievement_100: sending info about ()");
32761 
32762   if (NULL == *hash) {
32763     *hash = genhash_new_full(hash_packet_ruleset_achievement_100, cmp_packet_ruleset_achievement_100,
32764                              NULL, NULL, NULL, free);
32765   }
32766   BV_CLR_ALL(fields);
32767 
32768   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
32769     old = fc_malloc(sizeof(*old));
32770     *old = *real_packet;
32771     genhash_insert(*hash, old, old);
32772     memset(old, 0, sizeof(*old));
32773     different = 1;      /* Force to send. */
32774   }
32775 
32776   differ = (old->id != real_packet->id);
32777   if (differ) {
32778     different++;
32779     BV_SET(fields, 0);
32780   }
32781 
32782   differ = (strcmp(old->name, real_packet->name) != 0);
32783   if (differ) {
32784     different++;
32785     BV_SET(fields, 1);
32786   }
32787 
32788   differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
32789   if (differ) {
32790     different++;
32791     BV_SET(fields, 2);
32792   }
32793 
32794   differ = (old->type != real_packet->type);
32795   if (differ) {
32796     different++;
32797     BV_SET(fields, 3);
32798   }
32799 
32800   differ = (old->unique != real_packet->unique);
32801   if (differ) {
32802     different++;
32803   }
32804   if (packet->unique) {
32805     BV_SET(fields, 4);
32806   }
32807 
32808   differ = (old->value != real_packet->value);
32809   if (differ) {
32810     different++;
32811     BV_SET(fields, 5);
32812   }
32813 
32814 
32815   DIO_BV_PUT(&dout, "fields", fields);
32816 
32817   if (BV_ISSET(fields, 0)) {
32818     log_packet_detailed("  field 'id' has changed");
32819     DIO_PUT(uint8, &dout, "id", real_packet->id);
32820   }
32821   if (BV_ISSET(fields, 1)) {
32822     log_packet_detailed("  field 'name' has changed");
32823     DIO_PUT(string, &dout, "name", real_packet->name);
32824   }
32825   if (BV_ISSET(fields, 2)) {
32826     log_packet_detailed("  field 'rule_name' has changed");
32827     DIO_PUT(string, &dout, "rule_name", real_packet->rule_name);
32828   }
32829   if (BV_ISSET(fields, 3)) {
32830     log_packet_detailed("  field 'type' has changed");
32831     DIO_PUT(uint8, &dout, "type", real_packet->type);
32832   }
32833   /* field 4 is folded into the header */
32834   if (BV_ISSET(fields, 5)) {
32835     log_packet_detailed("  field 'value' has changed");
32836     DIO_PUT(uint16, &dout, "value", real_packet->value);
32837   }
32838 
32839   *old = *real_packet;
32840   SEND_PACKET_END(PACKET_RULESET_ACHIEVEMENT);
32841 }
32842 
send_packet_ruleset_achievement(struct connection * pc,const struct packet_ruleset_achievement * packet)32843 int send_packet_ruleset_achievement(struct connection *pc, const struct packet_ruleset_achievement *packet)
32844 {
32845   if (!pc->used) {
32846     log_error("WARNING: trying to send data to the closed connection %s",
32847               conn_description(pc));
32848     return -1;
32849   }
32850   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_ACHIEVEMENT].packet != NULL, -1,
32851                         "Handler for PACKET_RULESET_ACHIEVEMENT not installed");
32852   return pc->phs.handlers->send[PACKET_RULESET_ACHIEVEMENT].packet(pc, packet);
32853 }
32854 
lsend_packet_ruleset_achievement(struct conn_list * dest,const struct packet_ruleset_achievement * packet)32855 void lsend_packet_ruleset_achievement(struct conn_list *dest, const struct packet_ruleset_achievement *packet)
32856 {
32857   conn_list_iterate(dest, pconn) {
32858     send_packet_ruleset_achievement(pconn, packet);
32859   } conn_list_iterate_end;
32860 }
32861 
32862 #define hash_packet_ruleset_trade_100 hash_const
32863 
32864 #define cmp_packet_ruleset_trade_100 cmp_const
32865 
32866 BV_DEFINE(packet_ruleset_trade_100_fields, 4);
32867 
receive_packet_ruleset_trade_100(struct connection * pc)32868 static struct packet_ruleset_trade *receive_packet_ruleset_trade_100(struct connection *pc)
32869 {
32870   packet_ruleset_trade_100_fields fields;
32871   struct packet_ruleset_trade *old;
32872   struct genhash **hash = pc->phs.received + PACKET_RULESET_TRADE;
32873   RECEIVE_PACKET_START(packet_ruleset_trade, real_packet);
32874 
32875   DIO_BV_GET(&din, fields);
32876 
32877   log_packet_detailed("packet_ruleset_trade_100: got info about ()");
32878 
32879   if (NULL == *hash) {
32880     *hash = genhash_new_full(hash_packet_ruleset_trade_100, cmp_packet_ruleset_trade_100,
32881                              NULL, NULL, NULL, free);
32882   }
32883 
32884   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
32885     *real_packet = *old;
32886   } else {
32887     log_packet_detailed("  no old info");
32888     memset(real_packet, 0, sizeof(*real_packet));
32889   }
32890 
32891   if (BV_ISSET(fields, 0)) {
32892     log_packet_detailed("  got field 'id'");
32893     if (!DIO_GET(uint8, &din, "id", &real_packet->id)) {
32894       RECEIVE_PACKET_FIELD_ERROR(id);
32895     }
32896   }
32897   if (BV_ISSET(fields, 1)) {
32898     log_packet_detailed("  got field 'trade_pct'");
32899     if (!DIO_GET(uint16, &din, "trade_pct", &real_packet->trade_pct)) {
32900       RECEIVE_PACKET_FIELD_ERROR(trade_pct);
32901     }
32902   }
32903   if (BV_ISSET(fields, 2)) {
32904     log_packet_detailed("  got field 'cancelling'");
32905     {
32906       int readin;
32907 
32908       if (!DIO_GET(uint8, &din, "cancelling", &readin)) {
32909         RECEIVE_PACKET_FIELD_ERROR(cancelling);
32910       }
32911       real_packet->cancelling = readin;
32912     }
32913   }
32914   if (BV_ISSET(fields, 3)) {
32915     log_packet_detailed("  got field 'bonus_type'");
32916     {
32917       int readin;
32918 
32919       if (!DIO_GET(uint8, &din, "bonus_type", &readin)) {
32920         RECEIVE_PACKET_FIELD_ERROR(bonus_type);
32921       }
32922       real_packet->bonus_type = readin;
32923     }
32924   }
32925 
32926   if (NULL == old) {
32927     old = fc_malloc(sizeof(*old));
32928     *old = *real_packet;
32929     genhash_insert(*hash, old, old);
32930   } else {
32931     *old = *real_packet;
32932   }
32933   RECEIVE_PACKET_END(real_packet);
32934 }
32935 
send_packet_ruleset_trade_100(struct connection * pc,const struct packet_ruleset_trade * packet)32936 static int send_packet_ruleset_trade_100(struct connection *pc, const struct packet_ruleset_trade *packet)
32937 {
32938   const struct packet_ruleset_trade *real_packet = packet;
32939   packet_ruleset_trade_100_fields fields;
32940   struct packet_ruleset_trade *old;
32941   bool differ;
32942   struct genhash **hash = pc->phs.sent + PACKET_RULESET_TRADE;
32943   int different = 0;
32944   SEND_PACKET_START(PACKET_RULESET_TRADE);
32945 
32946   log_packet_detailed("packet_ruleset_trade_100: sending info about ()");
32947 
32948   if (NULL == *hash) {
32949     *hash = genhash_new_full(hash_packet_ruleset_trade_100, cmp_packet_ruleset_trade_100,
32950                              NULL, NULL, NULL, free);
32951   }
32952   BV_CLR_ALL(fields);
32953 
32954   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
32955     old = fc_malloc(sizeof(*old));
32956     *old = *real_packet;
32957     genhash_insert(*hash, old, old);
32958     memset(old, 0, sizeof(*old));
32959     different = 1;      /* Force to send. */
32960   }
32961 
32962   differ = (old->id != real_packet->id);
32963   if (differ) {
32964     different++;
32965     BV_SET(fields, 0);
32966   }
32967 
32968   differ = (old->trade_pct != real_packet->trade_pct);
32969   if (differ) {
32970     different++;
32971     BV_SET(fields, 1);
32972   }
32973 
32974   differ = (old->cancelling != real_packet->cancelling);
32975   if (differ) {
32976     different++;
32977     BV_SET(fields, 2);
32978   }
32979 
32980   differ = (old->bonus_type != real_packet->bonus_type);
32981   if (differ) {
32982     different++;
32983     BV_SET(fields, 3);
32984   }
32985 
32986 
32987   DIO_BV_PUT(&dout, "fields", fields);
32988 
32989   if (BV_ISSET(fields, 0)) {
32990     log_packet_detailed("  field 'id' has changed");
32991     DIO_PUT(uint8, &dout, "id", real_packet->id);
32992   }
32993   if (BV_ISSET(fields, 1)) {
32994     log_packet_detailed("  field 'trade_pct' has changed");
32995     DIO_PUT(uint16, &dout, "trade_pct", real_packet->trade_pct);
32996   }
32997   if (BV_ISSET(fields, 2)) {
32998     log_packet_detailed("  field 'cancelling' has changed");
32999     DIO_PUT(uint8, &dout, "cancelling", real_packet->cancelling);
33000   }
33001   if (BV_ISSET(fields, 3)) {
33002     log_packet_detailed("  field 'bonus_type' has changed");
33003     DIO_PUT(uint8, &dout, "bonus_type", real_packet->bonus_type);
33004   }
33005 
33006   *old = *real_packet;
33007   SEND_PACKET_END(PACKET_RULESET_TRADE);
33008 }
33009 
send_packet_ruleset_trade(struct connection * pc,const struct packet_ruleset_trade * packet)33010 int send_packet_ruleset_trade(struct connection *pc, const struct packet_ruleset_trade *packet)
33011 {
33012   if (!pc->used) {
33013     log_error("WARNING: trying to send data to the closed connection %s",
33014               conn_description(pc));
33015     return -1;
33016   }
33017   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_TRADE].packet != NULL, -1,
33018                         "Handler for PACKET_RULESET_TRADE not installed");
33019   return pc->phs.handlers->send[PACKET_RULESET_TRADE].packet(pc, packet);
33020 }
33021 
lsend_packet_ruleset_trade(struct conn_list * dest,const struct packet_ruleset_trade * packet)33022 void lsend_packet_ruleset_trade(struct conn_list *dest, const struct packet_ruleset_trade *packet)
33023 {
33024   conn_list_iterate(dest, pconn) {
33025     send_packet_ruleset_trade(pconn, packet);
33026   } conn_list_iterate_end;
33027 }
33028 
33029 #define hash_packet_ruleset_action_100 hash_const
33030 
33031 #define cmp_packet_ruleset_action_100 cmp_const
33032 
33033 BV_DEFINE(packet_ruleset_action_100_fields, 3);
33034 
receive_packet_ruleset_action_100(struct connection * pc)33035 static struct packet_ruleset_action *receive_packet_ruleset_action_100(struct connection *pc)
33036 {
33037   packet_ruleset_action_100_fields fields;
33038   struct packet_ruleset_action *old;
33039   struct genhash **hash = pc->phs.received + PACKET_RULESET_ACTION;
33040   RECEIVE_PACKET_START(packet_ruleset_action, real_packet);
33041 
33042   DIO_BV_GET(&din, fields);
33043 
33044   log_packet_detailed("packet_ruleset_action_100: got info about ()");
33045 
33046   if (NULL == *hash) {
33047     *hash = genhash_new_full(hash_packet_ruleset_action_100, cmp_packet_ruleset_action_100,
33048                              NULL, NULL, NULL, free);
33049   }
33050 
33051   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
33052     *real_packet = *old;
33053   } else {
33054     log_packet_detailed("  no old info");
33055     memset(real_packet, 0, sizeof(*real_packet));
33056   }
33057 
33058   if (BV_ISSET(fields, 0)) {
33059     log_packet_detailed("  got field 'id'");
33060     {
33061       int readin;
33062 
33063       if (!DIO_GET(uint8, &din, "id", &readin)) {
33064         RECEIVE_PACKET_FIELD_ERROR(id);
33065       }
33066       real_packet->id = readin;
33067     }
33068   }
33069   if (BV_ISSET(fields, 1)) {
33070     log_packet_detailed("  got field 'ui_name'");
33071     if (!DIO_GET(string, &din, "ui_name", real_packet->ui_name, sizeof(real_packet->ui_name))) {
33072       RECEIVE_PACKET_FIELD_ERROR(ui_name);
33073     }
33074   }
33075   real_packet->quiet = BV_ISSET(fields, 2);
33076 
33077   if (NULL == old) {
33078     old = fc_malloc(sizeof(*old));
33079     *old = *real_packet;
33080     genhash_insert(*hash, old, old);
33081   } else {
33082     *old = *real_packet;
33083   }
33084   RECEIVE_PACKET_END(real_packet);
33085 }
33086 
send_packet_ruleset_action_100(struct connection * pc,const struct packet_ruleset_action * packet)33087 static int send_packet_ruleset_action_100(struct connection *pc, const struct packet_ruleset_action *packet)
33088 {
33089   const struct packet_ruleset_action *real_packet = packet;
33090   packet_ruleset_action_100_fields fields;
33091   struct packet_ruleset_action *old;
33092   bool differ;
33093   struct genhash **hash = pc->phs.sent + PACKET_RULESET_ACTION;
33094   int different = 0;
33095   SEND_PACKET_START(PACKET_RULESET_ACTION);
33096 
33097   log_packet_detailed("packet_ruleset_action_100: sending info about ()");
33098 
33099   if (NULL == *hash) {
33100     *hash = genhash_new_full(hash_packet_ruleset_action_100, cmp_packet_ruleset_action_100,
33101                              NULL, NULL, NULL, free);
33102   }
33103   BV_CLR_ALL(fields);
33104 
33105   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
33106     old = fc_malloc(sizeof(*old));
33107     *old = *real_packet;
33108     genhash_insert(*hash, old, old);
33109     memset(old, 0, sizeof(*old));
33110     different = 1;      /* Force to send. */
33111   }
33112 
33113   differ = (old->id != real_packet->id);
33114   if (differ) {
33115     different++;
33116     BV_SET(fields, 0);
33117   }
33118 
33119   differ = (strcmp(old->ui_name, real_packet->ui_name) != 0);
33120   if (differ) {
33121     different++;
33122     BV_SET(fields, 1);
33123   }
33124 
33125   differ = (old->quiet != real_packet->quiet);
33126   if (differ) {
33127     different++;
33128   }
33129   if (packet->quiet) {
33130     BV_SET(fields, 2);
33131   }
33132 
33133 
33134   DIO_BV_PUT(&dout, "fields", fields);
33135 
33136   if (BV_ISSET(fields, 0)) {
33137     log_packet_detailed("  field 'id' has changed");
33138     DIO_PUT(uint8, &dout, "id", real_packet->id);
33139   }
33140   if (BV_ISSET(fields, 1)) {
33141     log_packet_detailed("  field 'ui_name' has changed");
33142     DIO_PUT(string, &dout, "ui_name", real_packet->ui_name);
33143   }
33144   /* field 2 is folded into the header */
33145 
33146   *old = *real_packet;
33147   SEND_PACKET_END(PACKET_RULESET_ACTION);
33148 }
33149 
send_packet_ruleset_action(struct connection * pc,const struct packet_ruleset_action * packet)33150 int send_packet_ruleset_action(struct connection *pc, const struct packet_ruleset_action *packet)
33151 {
33152   if (!pc->used) {
33153     log_error("WARNING: trying to send data to the closed connection %s",
33154               conn_description(pc));
33155     return -1;
33156   }
33157   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_ACTION].packet != NULL, -1,
33158                         "Handler for PACKET_RULESET_ACTION not installed");
33159   return pc->phs.handlers->send[PACKET_RULESET_ACTION].packet(pc, packet);
33160 }
33161 
lsend_packet_ruleset_action(struct conn_list * dest,const struct packet_ruleset_action * packet)33162 void lsend_packet_ruleset_action(struct conn_list *dest, const struct packet_ruleset_action *packet)
33163 {
33164   conn_list_iterate(dest, pconn) {
33165     send_packet_ruleset_action(pconn, packet);
33166   } conn_list_iterate_end;
33167 }
33168 
33169 #define hash_packet_ruleset_action_enabler_100 hash_const
33170 
33171 #define cmp_packet_ruleset_action_enabler_100 cmp_const
33172 
33173 BV_DEFINE(packet_ruleset_action_enabler_100_fields, 5);
33174 
receive_packet_ruleset_action_enabler_100(struct connection * pc)33175 static struct packet_ruleset_action_enabler *receive_packet_ruleset_action_enabler_100(struct connection *pc)
33176 {
33177   packet_ruleset_action_enabler_100_fields fields;
33178   struct packet_ruleset_action_enabler *old;
33179   struct genhash **hash = pc->phs.received + PACKET_RULESET_ACTION_ENABLER;
33180   RECEIVE_PACKET_START(packet_ruleset_action_enabler, real_packet);
33181 
33182   DIO_BV_GET(&din, fields);
33183 
33184   log_packet_detailed("packet_ruleset_action_enabler_100: got info about ()");
33185 
33186   if (NULL == *hash) {
33187     *hash = genhash_new_full(hash_packet_ruleset_action_enabler_100, cmp_packet_ruleset_action_enabler_100,
33188                              NULL, NULL, NULL, free);
33189   }
33190 
33191   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
33192     *real_packet = *old;
33193   } else {
33194     log_packet_detailed("  no old info");
33195     memset(real_packet, 0, sizeof(*real_packet));
33196   }
33197 
33198   if (BV_ISSET(fields, 0)) {
33199     log_packet_detailed("  got field 'enabled_action'");
33200     {
33201       int readin;
33202 
33203       if (!DIO_GET(uint8, &din, "enabled_action", &readin)) {
33204         RECEIVE_PACKET_FIELD_ERROR(enabled_action);
33205       }
33206       real_packet->enabled_action = readin;
33207     }
33208   }
33209   if (BV_ISSET(fields, 1)) {
33210     log_packet_detailed("  got field 'actor_reqs_count'");
33211     if (!DIO_GET(uint8, &din, "actor_reqs_count", &real_packet->actor_reqs_count)) {
33212       RECEIVE_PACKET_FIELD_ERROR(actor_reqs_count);
33213     }
33214   }
33215   if (BV_ISSET(fields, 2)) {
33216     log_packet_detailed("  got field 'actor_reqs'");
33217 
33218     {
33219       int i;
33220 
33221       if (real_packet->actor_reqs_count > MAX_NUM_REQS) {
33222         RECEIVE_PACKET_FIELD_ERROR(actor_reqs, ": truncation array");
33223       }
33224       for (i = 0; i < real_packet->actor_reqs_count; i++) {
33225         if (!DIO_GET(requirement, &din, "actor_reqs", &real_packet->actor_reqs[i])) {
33226           RECEIVE_PACKET_FIELD_ERROR(actor_reqs);
33227         }
33228       }
33229     }
33230   }
33231   if (BV_ISSET(fields, 3)) {
33232     log_packet_detailed("  got field 'target_reqs_count'");
33233     if (!DIO_GET(uint8, &din, "target_reqs_count", &real_packet->target_reqs_count)) {
33234       RECEIVE_PACKET_FIELD_ERROR(target_reqs_count);
33235     }
33236   }
33237   if (BV_ISSET(fields, 4)) {
33238     log_packet_detailed("  got field 'target_reqs'");
33239 
33240     {
33241       int i;
33242 
33243       if (real_packet->target_reqs_count > MAX_NUM_REQS) {
33244         RECEIVE_PACKET_FIELD_ERROR(target_reqs, ": truncation array");
33245       }
33246       for (i = 0; i < real_packet->target_reqs_count; i++) {
33247         if (!DIO_GET(requirement, &din, "target_reqs", &real_packet->target_reqs[i])) {
33248           RECEIVE_PACKET_FIELD_ERROR(target_reqs);
33249         }
33250       }
33251     }
33252   }
33253 
33254   if (NULL == old) {
33255     old = fc_malloc(sizeof(*old));
33256     *old = *real_packet;
33257     genhash_insert(*hash, old, old);
33258   } else {
33259     *old = *real_packet;
33260   }
33261   RECEIVE_PACKET_END(real_packet);
33262 }
33263 
send_packet_ruleset_action_enabler_100(struct connection * pc,const struct packet_ruleset_action_enabler * packet)33264 static int send_packet_ruleset_action_enabler_100(struct connection *pc, const struct packet_ruleset_action_enabler *packet)
33265 {
33266   const struct packet_ruleset_action_enabler *real_packet = packet;
33267   packet_ruleset_action_enabler_100_fields fields;
33268   struct packet_ruleset_action_enabler *old;
33269   bool differ;
33270   struct genhash **hash = pc->phs.sent + PACKET_RULESET_ACTION_ENABLER;
33271   int different = 0;
33272   SEND_PACKET_START(PACKET_RULESET_ACTION_ENABLER);
33273 
33274   log_packet_detailed("packet_ruleset_action_enabler_100: sending info about ()");
33275 
33276   if (NULL == *hash) {
33277     *hash = genhash_new_full(hash_packet_ruleset_action_enabler_100, cmp_packet_ruleset_action_enabler_100,
33278                              NULL, NULL, NULL, free);
33279   }
33280   BV_CLR_ALL(fields);
33281 
33282   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
33283     old = fc_malloc(sizeof(*old));
33284     *old = *real_packet;
33285     genhash_insert(*hash, old, old);
33286     memset(old, 0, sizeof(*old));
33287     different = 1;      /* Force to send. */
33288   }
33289 
33290   differ = (old->enabled_action != real_packet->enabled_action);
33291   if (differ) {
33292     different++;
33293     BV_SET(fields, 0);
33294   }
33295 
33296   differ = (old->actor_reqs_count != real_packet->actor_reqs_count);
33297   if (differ) {
33298     different++;
33299     BV_SET(fields, 1);
33300   }
33301 
33302 
33303     {
33304       differ = (old->actor_reqs_count != real_packet->actor_reqs_count);
33305       if (!differ) {
33306         int i;
33307 
33308         for (i = 0; i < real_packet->actor_reqs_count; i++) {
33309           if (!are_requirements_equal(&old->actor_reqs[i], &real_packet->actor_reqs[i])) {
33310             differ = TRUE;
33311             break;
33312           }
33313         }
33314       }
33315     }
33316   if (differ) {
33317     different++;
33318     BV_SET(fields, 2);
33319   }
33320 
33321   differ = (old->target_reqs_count != real_packet->target_reqs_count);
33322   if (differ) {
33323     different++;
33324     BV_SET(fields, 3);
33325   }
33326 
33327 
33328     {
33329       differ = (old->target_reqs_count != real_packet->target_reqs_count);
33330       if (!differ) {
33331         int i;
33332 
33333         for (i = 0; i < real_packet->target_reqs_count; i++) {
33334           if (!are_requirements_equal(&old->target_reqs[i], &real_packet->target_reqs[i])) {
33335             differ = TRUE;
33336             break;
33337           }
33338         }
33339       }
33340     }
33341   if (differ) {
33342     different++;
33343     BV_SET(fields, 4);
33344   }
33345 
33346 
33347   DIO_BV_PUT(&dout, "fields", fields);
33348 
33349   if (BV_ISSET(fields, 0)) {
33350     log_packet_detailed("  field 'enabled_action' has changed");
33351     DIO_PUT(uint8, &dout, "enabled_action", real_packet->enabled_action);
33352   }
33353   if (BV_ISSET(fields, 1)) {
33354     log_packet_detailed("  field 'actor_reqs_count' has changed");
33355     DIO_PUT(uint8, &dout, "actor_reqs_count", real_packet->actor_reqs_count);
33356   }
33357   if (BV_ISSET(fields, 2)) {
33358     log_packet_detailed("  field 'actor_reqs' has changed");
33359 
33360     {
33361       int i;
33362 
33363       for (i = 0; i < real_packet->actor_reqs_count; i++) {
33364         dio_put_requirement(&dout, &real_packet->actor_reqs[i]);
33365       }
33366     }
33367   }
33368   if (BV_ISSET(fields, 3)) {
33369     log_packet_detailed("  field 'target_reqs_count' has changed");
33370     DIO_PUT(uint8, &dout, "target_reqs_count", real_packet->target_reqs_count);
33371   }
33372   if (BV_ISSET(fields, 4)) {
33373     log_packet_detailed("  field 'target_reqs' has changed");
33374 
33375     {
33376       int i;
33377 
33378       for (i = 0; i < real_packet->target_reqs_count; i++) {
33379         dio_put_requirement(&dout, &real_packet->target_reqs[i]);
33380       }
33381     }
33382   }
33383 
33384   *old = *real_packet;
33385   SEND_PACKET_END(PACKET_RULESET_ACTION_ENABLER);
33386 }
33387 
send_packet_ruleset_action_enabler(struct connection * pc,const struct packet_ruleset_action_enabler * packet)33388 int send_packet_ruleset_action_enabler(struct connection *pc, const struct packet_ruleset_action_enabler *packet)
33389 {
33390   if (!pc->used) {
33391     log_error("WARNING: trying to send data to the closed connection %s",
33392               conn_description(pc));
33393     return -1;
33394   }
33395   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_ACTION_ENABLER].packet != NULL, -1,
33396                         "Handler for PACKET_RULESET_ACTION_ENABLER not installed");
33397   return pc->phs.handlers->send[PACKET_RULESET_ACTION_ENABLER].packet(pc, packet);
33398 }
33399 
lsend_packet_ruleset_action_enabler(struct conn_list * dest,const struct packet_ruleset_action_enabler * packet)33400 void lsend_packet_ruleset_action_enabler(struct conn_list *dest, const struct packet_ruleset_action_enabler *packet)
33401 {
33402   conn_list_iterate(dest, pconn) {
33403     send_packet_ruleset_action_enabler(pconn, packet);
33404   } conn_list_iterate_end;
33405 }
33406 
33407 #define hash_packet_ruleset_music_100 hash_const
33408 
33409 #define cmp_packet_ruleset_music_100 cmp_const
33410 
33411 BV_DEFINE(packet_ruleset_music_100_fields, 5);
33412 
receive_packet_ruleset_music_100(struct connection * pc)33413 static struct packet_ruleset_music *receive_packet_ruleset_music_100(struct connection *pc)
33414 {
33415   packet_ruleset_music_100_fields fields;
33416   struct packet_ruleset_music *old;
33417   struct genhash **hash = pc->phs.received + PACKET_RULESET_MUSIC;
33418   RECEIVE_PACKET_START(packet_ruleset_music, real_packet);
33419 
33420   DIO_BV_GET(&din, fields);
33421 
33422   log_packet_detailed("packet_ruleset_music_100: got info about ()");
33423 
33424   if (NULL == *hash) {
33425     *hash = genhash_new_full(hash_packet_ruleset_music_100, cmp_packet_ruleset_music_100,
33426                              NULL, NULL, NULL, free);
33427   }
33428 
33429   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
33430     *real_packet = *old;
33431   } else {
33432     log_packet_detailed("  no old info");
33433     memset(real_packet, 0, sizeof(*real_packet));
33434   }
33435 
33436   if (BV_ISSET(fields, 0)) {
33437     log_packet_detailed("  got field 'id'");
33438     if (!DIO_GET(uint8, &din, "id", &real_packet->id)) {
33439       RECEIVE_PACKET_FIELD_ERROR(id);
33440     }
33441   }
33442   if (BV_ISSET(fields, 1)) {
33443     log_packet_detailed("  got field 'music_peaceful'");
33444     if (!DIO_GET(string, &din, "music_peaceful", real_packet->music_peaceful, sizeof(real_packet->music_peaceful))) {
33445       RECEIVE_PACKET_FIELD_ERROR(music_peaceful);
33446     }
33447   }
33448   if (BV_ISSET(fields, 2)) {
33449     log_packet_detailed("  got field 'music_combat'");
33450     if (!DIO_GET(string, &din, "music_combat", real_packet->music_combat, sizeof(real_packet->music_combat))) {
33451       RECEIVE_PACKET_FIELD_ERROR(music_combat);
33452     }
33453   }
33454   if (BV_ISSET(fields, 3)) {
33455     log_packet_detailed("  got field 'reqs_count'");
33456     if (!DIO_GET(uint8, &din, "reqs_count", &real_packet->reqs_count)) {
33457       RECEIVE_PACKET_FIELD_ERROR(reqs_count);
33458     }
33459   }
33460   if (BV_ISSET(fields, 4)) {
33461     log_packet_detailed("  got field 'reqs'");
33462 
33463     {
33464       int i;
33465 
33466       if (real_packet->reqs_count > MAX_NUM_REQS) {
33467         RECEIVE_PACKET_FIELD_ERROR(reqs, ": truncation array");
33468       }
33469       for (i = 0; i < real_packet->reqs_count; i++) {
33470         if (!DIO_GET(requirement, &din, "reqs", &real_packet->reqs[i])) {
33471           RECEIVE_PACKET_FIELD_ERROR(reqs);
33472         }
33473       }
33474     }
33475   }
33476 
33477   if (NULL == old) {
33478     old = fc_malloc(sizeof(*old));
33479     *old = *real_packet;
33480     genhash_insert(*hash, old, old);
33481   } else {
33482     *old = *real_packet;
33483   }
33484   RECEIVE_PACKET_END(real_packet);
33485 }
33486 
send_packet_ruleset_music_100(struct connection * pc,const struct packet_ruleset_music * packet)33487 static int send_packet_ruleset_music_100(struct connection *pc, const struct packet_ruleset_music *packet)
33488 {
33489   const struct packet_ruleset_music *real_packet = packet;
33490   packet_ruleset_music_100_fields fields;
33491   struct packet_ruleset_music *old;
33492   bool differ;
33493   struct genhash **hash = pc->phs.sent + PACKET_RULESET_MUSIC;
33494   int different = 0;
33495   SEND_PACKET_START(PACKET_RULESET_MUSIC);
33496 
33497   log_packet_detailed("packet_ruleset_music_100: sending info about ()");
33498 
33499   if (NULL == *hash) {
33500     *hash = genhash_new_full(hash_packet_ruleset_music_100, cmp_packet_ruleset_music_100,
33501                              NULL, NULL, NULL, free);
33502   }
33503   BV_CLR_ALL(fields);
33504 
33505   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
33506     old = fc_malloc(sizeof(*old));
33507     *old = *real_packet;
33508     genhash_insert(*hash, old, old);
33509     memset(old, 0, sizeof(*old));
33510     different = 1;      /* Force to send. */
33511   }
33512 
33513   differ = (old->id != real_packet->id);
33514   if (differ) {
33515     different++;
33516     BV_SET(fields, 0);
33517   }
33518 
33519   differ = (strcmp(old->music_peaceful, real_packet->music_peaceful) != 0);
33520   if (differ) {
33521     different++;
33522     BV_SET(fields, 1);
33523   }
33524 
33525   differ = (strcmp(old->music_combat, real_packet->music_combat) != 0);
33526   if (differ) {
33527     different++;
33528     BV_SET(fields, 2);
33529   }
33530 
33531   differ = (old->reqs_count != real_packet->reqs_count);
33532   if (differ) {
33533     different++;
33534     BV_SET(fields, 3);
33535   }
33536 
33537 
33538     {
33539       differ = (old->reqs_count != real_packet->reqs_count);
33540       if (!differ) {
33541         int i;
33542 
33543         for (i = 0; i < real_packet->reqs_count; i++) {
33544           if (!are_requirements_equal(&old->reqs[i], &real_packet->reqs[i])) {
33545             differ = TRUE;
33546             break;
33547           }
33548         }
33549       }
33550     }
33551   if (differ) {
33552     different++;
33553     BV_SET(fields, 4);
33554   }
33555 
33556 
33557   DIO_BV_PUT(&dout, "fields", fields);
33558 
33559   if (BV_ISSET(fields, 0)) {
33560     log_packet_detailed("  field 'id' has changed");
33561     DIO_PUT(uint8, &dout, "id", real_packet->id);
33562   }
33563   if (BV_ISSET(fields, 1)) {
33564     log_packet_detailed("  field 'music_peaceful' has changed");
33565     DIO_PUT(string, &dout, "music_peaceful", real_packet->music_peaceful);
33566   }
33567   if (BV_ISSET(fields, 2)) {
33568     log_packet_detailed("  field 'music_combat' has changed");
33569     DIO_PUT(string, &dout, "music_combat", real_packet->music_combat);
33570   }
33571   if (BV_ISSET(fields, 3)) {
33572     log_packet_detailed("  field 'reqs_count' has changed");
33573     DIO_PUT(uint8, &dout, "reqs_count", real_packet->reqs_count);
33574   }
33575   if (BV_ISSET(fields, 4)) {
33576     log_packet_detailed("  field 'reqs' has changed");
33577 
33578     {
33579       int i;
33580 
33581       for (i = 0; i < real_packet->reqs_count; i++) {
33582         dio_put_requirement(&dout, &real_packet->reqs[i]);
33583       }
33584     }
33585   }
33586 
33587   *old = *real_packet;
33588   SEND_PACKET_END(PACKET_RULESET_MUSIC);
33589 }
33590 
send_packet_ruleset_music(struct connection * pc,const struct packet_ruleset_music * packet)33591 int send_packet_ruleset_music(struct connection *pc, const struct packet_ruleset_music *packet)
33592 {
33593   if (!pc->used) {
33594     log_error("WARNING: trying to send data to the closed connection %s",
33595               conn_description(pc));
33596     return -1;
33597   }
33598   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_MUSIC].packet != NULL, -1,
33599                         "Handler for PACKET_RULESET_MUSIC not installed");
33600   return pc->phs.handlers->send[PACKET_RULESET_MUSIC].packet(pc, packet);
33601 }
33602 
lsend_packet_ruleset_music(struct conn_list * dest,const struct packet_ruleset_music * packet)33603 void lsend_packet_ruleset_music(struct conn_list *dest, const struct packet_ruleset_music *packet)
33604 {
33605   conn_list_iterate(dest, pconn) {
33606     send_packet_ruleset_music(pconn, packet);
33607   } conn_list_iterate_end;
33608 }
33609 
33610 #define hash_packet_ruleset_multiplier_100 hash_const
33611 
33612 #define cmp_packet_ruleset_multiplier_100 cmp_const
33613 
33614 BV_DEFINE(packet_ruleset_multiplier_100_fields, 10);
33615 
receive_packet_ruleset_multiplier_100(struct connection * pc)33616 static struct packet_ruleset_multiplier *receive_packet_ruleset_multiplier_100(struct connection *pc)
33617 {
33618   packet_ruleset_multiplier_100_fields fields;
33619   struct packet_ruleset_multiplier *old;
33620   struct genhash **hash = pc->phs.received + PACKET_RULESET_MULTIPLIER;
33621   RECEIVE_PACKET_START(packet_ruleset_multiplier, real_packet);
33622 
33623   DIO_BV_GET(&din, fields);
33624 
33625   log_packet_detailed("packet_ruleset_multiplier_100: got info about ()");
33626 
33627   if (NULL == *hash) {
33628     *hash = genhash_new_full(hash_packet_ruleset_multiplier_100, cmp_packet_ruleset_multiplier_100,
33629                              NULL, NULL, NULL, free);
33630   }
33631 
33632   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
33633     *real_packet = *old;
33634   } else {
33635     log_packet_detailed("  no old info");
33636     memset(real_packet, 0, sizeof(*real_packet));
33637   }
33638 
33639   if (BV_ISSET(fields, 0)) {
33640     log_packet_detailed("  got field 'id'");
33641     {
33642       int readin;
33643 
33644       if (!DIO_GET(uint8, &din, "id", &readin)) {
33645         RECEIVE_PACKET_FIELD_ERROR(id);
33646       }
33647       real_packet->id = readin;
33648     }
33649   }
33650   if (BV_ISSET(fields, 1)) {
33651     log_packet_detailed("  got field 'start'");
33652     if (!DIO_GET(sint32, &din, "start", &real_packet->start)) {
33653       RECEIVE_PACKET_FIELD_ERROR(start);
33654     }
33655   }
33656   if (BV_ISSET(fields, 2)) {
33657     log_packet_detailed("  got field 'stop'");
33658     if (!DIO_GET(sint32, &din, "stop", &real_packet->stop)) {
33659       RECEIVE_PACKET_FIELD_ERROR(stop);
33660     }
33661   }
33662   if (BV_ISSET(fields, 3)) {
33663     log_packet_detailed("  got field 'step'");
33664     if (!DIO_GET(uint32, &din, "step", &real_packet->step)) {
33665       RECEIVE_PACKET_FIELD_ERROR(step);
33666     }
33667   }
33668   if (BV_ISSET(fields, 4)) {
33669     log_packet_detailed("  got field 'def'");
33670     if (!DIO_GET(sint32, &din, "def", &real_packet->def)) {
33671       RECEIVE_PACKET_FIELD_ERROR(def);
33672     }
33673   }
33674   if (BV_ISSET(fields, 5)) {
33675     log_packet_detailed("  got field 'offset'");
33676     if (!DIO_GET(sint32, &din, "offset", &real_packet->offset)) {
33677       RECEIVE_PACKET_FIELD_ERROR(offset);
33678     }
33679   }
33680   if (BV_ISSET(fields, 6)) {
33681     log_packet_detailed("  got field 'factor'");
33682     if (!DIO_GET(sint32, &din, "factor", &real_packet->factor)) {
33683       RECEIVE_PACKET_FIELD_ERROR(factor);
33684     }
33685   }
33686   if (BV_ISSET(fields, 7)) {
33687     log_packet_detailed("  got field 'name'");
33688     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
33689       RECEIVE_PACKET_FIELD_ERROR(name);
33690     }
33691   }
33692   if (BV_ISSET(fields, 8)) {
33693     log_packet_detailed("  got field 'rule_name'");
33694     if (!DIO_GET(string, &din, "rule_name", real_packet->rule_name, sizeof(real_packet->rule_name))) {
33695       RECEIVE_PACKET_FIELD_ERROR(rule_name);
33696     }
33697   }
33698   if (BV_ISSET(fields, 9)) {
33699     log_packet_detailed("  got field 'helptext'");
33700     if (!DIO_GET(string, &din, "helptext", real_packet->helptext, sizeof(real_packet->helptext))) {
33701       RECEIVE_PACKET_FIELD_ERROR(helptext);
33702     }
33703   }
33704 
33705   if (NULL == old) {
33706     old = fc_malloc(sizeof(*old));
33707     *old = *real_packet;
33708     genhash_insert(*hash, old, old);
33709   } else {
33710     *old = *real_packet;
33711   }
33712   RECEIVE_PACKET_END(real_packet);
33713 }
33714 
send_packet_ruleset_multiplier_100(struct connection * pc,const struct packet_ruleset_multiplier * packet)33715 static int send_packet_ruleset_multiplier_100(struct connection *pc, const struct packet_ruleset_multiplier *packet)
33716 {
33717   const struct packet_ruleset_multiplier *real_packet = packet;
33718   packet_ruleset_multiplier_100_fields fields;
33719   struct packet_ruleset_multiplier *old;
33720   bool differ;
33721   struct genhash **hash = pc->phs.sent + PACKET_RULESET_MULTIPLIER;
33722   int different = 0;
33723   SEND_PACKET_START(PACKET_RULESET_MULTIPLIER);
33724 
33725   log_packet_detailed("packet_ruleset_multiplier_100: sending info about ()");
33726 
33727   if (NULL == *hash) {
33728     *hash = genhash_new_full(hash_packet_ruleset_multiplier_100, cmp_packet_ruleset_multiplier_100,
33729                              NULL, NULL, NULL, free);
33730   }
33731   BV_CLR_ALL(fields);
33732 
33733   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
33734     old = fc_malloc(sizeof(*old));
33735     *old = *real_packet;
33736     genhash_insert(*hash, old, old);
33737     memset(old, 0, sizeof(*old));
33738     different = 1;      /* Force to send. */
33739   }
33740 
33741   differ = (old->id != real_packet->id);
33742   if (differ) {
33743     different++;
33744     BV_SET(fields, 0);
33745   }
33746 
33747   differ = (old->start != real_packet->start);
33748   if (differ) {
33749     different++;
33750     BV_SET(fields, 1);
33751   }
33752 
33753   differ = (old->stop != real_packet->stop);
33754   if (differ) {
33755     different++;
33756     BV_SET(fields, 2);
33757   }
33758 
33759   differ = (old->step != real_packet->step);
33760   if (differ) {
33761     different++;
33762     BV_SET(fields, 3);
33763   }
33764 
33765   differ = (old->def != real_packet->def);
33766   if (differ) {
33767     different++;
33768     BV_SET(fields, 4);
33769   }
33770 
33771   differ = (old->offset != real_packet->offset);
33772   if (differ) {
33773     different++;
33774     BV_SET(fields, 5);
33775   }
33776 
33777   differ = (old->factor != real_packet->factor);
33778   if (differ) {
33779     different++;
33780     BV_SET(fields, 6);
33781   }
33782 
33783   differ = (strcmp(old->name, real_packet->name) != 0);
33784   if (differ) {
33785     different++;
33786     BV_SET(fields, 7);
33787   }
33788 
33789   differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
33790   if (differ) {
33791     different++;
33792     BV_SET(fields, 8);
33793   }
33794 
33795   differ = (strcmp(old->helptext, real_packet->helptext) != 0);
33796   if (differ) {
33797     different++;
33798     BV_SET(fields, 9);
33799   }
33800 
33801 
33802   DIO_BV_PUT(&dout, "fields", fields);
33803 
33804   if (BV_ISSET(fields, 0)) {
33805     log_packet_detailed("  field 'id' has changed");
33806     DIO_PUT(uint8, &dout, "id", real_packet->id);
33807   }
33808   if (BV_ISSET(fields, 1)) {
33809     log_packet_detailed("  field 'start' has changed");
33810     DIO_PUT(sint32, &dout, "start", real_packet->start);
33811   }
33812   if (BV_ISSET(fields, 2)) {
33813     log_packet_detailed("  field 'stop' has changed");
33814     DIO_PUT(sint32, &dout, "stop", real_packet->stop);
33815   }
33816   if (BV_ISSET(fields, 3)) {
33817     log_packet_detailed("  field 'step' has changed");
33818     DIO_PUT(uint32, &dout, "step", real_packet->step);
33819   }
33820   if (BV_ISSET(fields, 4)) {
33821     log_packet_detailed("  field 'def' has changed");
33822     DIO_PUT(sint32, &dout, "def", real_packet->def);
33823   }
33824   if (BV_ISSET(fields, 5)) {
33825     log_packet_detailed("  field 'offset' has changed");
33826     DIO_PUT(sint32, &dout, "offset", real_packet->offset);
33827   }
33828   if (BV_ISSET(fields, 6)) {
33829     log_packet_detailed("  field 'factor' has changed");
33830     DIO_PUT(sint32, &dout, "factor", real_packet->factor);
33831   }
33832   if (BV_ISSET(fields, 7)) {
33833     log_packet_detailed("  field 'name' has changed");
33834     DIO_PUT(string, &dout, "name", real_packet->name);
33835   }
33836   if (BV_ISSET(fields, 8)) {
33837     log_packet_detailed("  field 'rule_name' has changed");
33838     DIO_PUT(string, &dout, "rule_name", real_packet->rule_name);
33839   }
33840   if (BV_ISSET(fields, 9)) {
33841     log_packet_detailed("  field 'helptext' has changed");
33842     DIO_PUT(string, &dout, "helptext", real_packet->helptext);
33843   }
33844 
33845   *old = *real_packet;
33846   SEND_PACKET_END(PACKET_RULESET_MULTIPLIER);
33847 }
33848 
send_packet_ruleset_multiplier(struct connection * pc,const struct packet_ruleset_multiplier * packet)33849 int send_packet_ruleset_multiplier(struct connection *pc, const struct packet_ruleset_multiplier *packet)
33850 {
33851   if (!pc->used) {
33852     log_error("WARNING: trying to send data to the closed connection %s",
33853               conn_description(pc));
33854     return -1;
33855   }
33856   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_MULTIPLIER].packet != NULL, -1,
33857                         "Handler for PACKET_RULESET_MULTIPLIER not installed");
33858   return pc->phs.handlers->send[PACKET_RULESET_MULTIPLIER].packet(pc, packet);
33859 }
33860 
lsend_packet_ruleset_multiplier(struct conn_list * dest,const struct packet_ruleset_multiplier * packet)33861 void lsend_packet_ruleset_multiplier(struct conn_list *dest, const struct packet_ruleset_multiplier *packet)
33862 {
33863   conn_list_iterate(dest, pconn) {
33864     send_packet_ruleset_multiplier(pconn, packet);
33865   } conn_list_iterate_end;
33866 }
33867 
dsend_packet_ruleset_multiplier(struct connection * pc,Multiplier_type_id id,int start,int stop,int step,int def,int offset,int factor,const char * name,const char * rule_name,const char * helptext)33868 int dsend_packet_ruleset_multiplier(struct connection *pc, Multiplier_type_id id, int start, int stop, int step, int def, int offset, int factor, const char *name, const char *rule_name, const char *helptext)
33869 {
33870   struct packet_ruleset_multiplier packet, *real_packet = &packet;
33871 
33872   real_packet->id = id;
33873   real_packet->start = start;
33874   real_packet->stop = stop;
33875   real_packet->step = step;
33876   real_packet->def = def;
33877   real_packet->offset = offset;
33878   real_packet->factor = factor;
33879   sz_strlcpy(real_packet->name, name);
33880   sz_strlcpy(real_packet->rule_name, rule_name);
33881   sz_strlcpy(real_packet->helptext, helptext);
33882 
33883   return send_packet_ruleset_multiplier(pc, real_packet);
33884 }
33885 
dlsend_packet_ruleset_multiplier(struct conn_list * dest,Multiplier_type_id id,int start,int stop,int step,int def,int offset,int factor,const char * name,const char * rule_name,const char * helptext)33886 void dlsend_packet_ruleset_multiplier(struct conn_list *dest, Multiplier_type_id id, int start, int stop, int step, int def, int offset, int factor, const char *name, const char *rule_name, const char *helptext)
33887 {
33888   struct packet_ruleset_multiplier packet, *real_packet = &packet;
33889 
33890   real_packet->id = id;
33891   real_packet->start = start;
33892   real_packet->stop = stop;
33893   real_packet->step = step;
33894   real_packet->def = def;
33895   real_packet->offset = offset;
33896   real_packet->factor = factor;
33897   sz_strlcpy(real_packet->name, name);
33898   sz_strlcpy(real_packet->rule_name, rule_name);
33899   sz_strlcpy(real_packet->helptext, helptext);
33900 
33901   lsend_packet_ruleset_multiplier(dest, real_packet);
33902 }
33903 
33904 #define hash_packet_ruleset_control_100 hash_const
33905 
33906 #define cmp_packet_ruleset_control_100 cmp_const
33907 
33908 BV_DEFINE(packet_ruleset_control_100_fields, 25);
33909 
receive_packet_ruleset_control_100(struct connection * pc)33910 static struct packet_ruleset_control *receive_packet_ruleset_control_100(struct connection *pc)
33911 {
33912   packet_ruleset_control_100_fields fields;
33913   struct packet_ruleset_control *old;
33914   struct genhash **hash = pc->phs.received + PACKET_RULESET_CONTROL;
33915   RECEIVE_PACKET_START(packet_ruleset_control, real_packet);
33916 
33917   DIO_BV_GET(&din, fields);
33918 
33919   log_packet_detailed("packet_ruleset_control_100: got info about ()");
33920 
33921   if (NULL == *hash) {
33922     *hash = genhash_new_full(hash_packet_ruleset_control_100, cmp_packet_ruleset_control_100,
33923                              NULL, NULL, NULL, free);
33924   }
33925 
33926   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
33927     *real_packet = *old;
33928   } else {
33929     log_packet_detailed("  no old info");
33930     memset(real_packet, 0, sizeof(*real_packet));
33931   }
33932 
33933   if (BV_ISSET(fields, 0)) {
33934     log_packet_detailed("  got field 'num_unit_classes'");
33935     if (!DIO_GET(uint16, &din, "num_unit_classes", &real_packet->num_unit_classes)) {
33936       RECEIVE_PACKET_FIELD_ERROR(num_unit_classes);
33937     }
33938   }
33939   if (BV_ISSET(fields, 1)) {
33940     log_packet_detailed("  got field 'num_unit_types'");
33941     if (!DIO_GET(uint16, &din, "num_unit_types", &real_packet->num_unit_types)) {
33942       RECEIVE_PACKET_FIELD_ERROR(num_unit_types);
33943     }
33944   }
33945   if (BV_ISSET(fields, 2)) {
33946     log_packet_detailed("  got field 'num_impr_types'");
33947     if (!DIO_GET(uint16, &din, "num_impr_types", &real_packet->num_impr_types)) {
33948       RECEIVE_PACKET_FIELD_ERROR(num_impr_types);
33949     }
33950   }
33951   if (BV_ISSET(fields, 3)) {
33952     log_packet_detailed("  got field 'num_tech_types'");
33953     if (!DIO_GET(uint16, &din, "num_tech_types", &real_packet->num_tech_types)) {
33954       RECEIVE_PACKET_FIELD_ERROR(num_tech_types);
33955     }
33956   }
33957   if (BV_ISSET(fields, 4)) {
33958     log_packet_detailed("  got field 'num_extra_types'");
33959     if (!DIO_GET(uint16, &din, "num_extra_types", &real_packet->num_extra_types)) {
33960       RECEIVE_PACKET_FIELD_ERROR(num_extra_types);
33961     }
33962   }
33963   if (BV_ISSET(fields, 5)) {
33964     log_packet_detailed("  got field 'num_base_types'");
33965     if (!DIO_GET(uint16, &din, "num_base_types", &real_packet->num_base_types)) {
33966       RECEIVE_PACKET_FIELD_ERROR(num_base_types);
33967     }
33968   }
33969   if (BV_ISSET(fields, 6)) {
33970     log_packet_detailed("  got field 'num_road_types'");
33971     if (!DIO_GET(uint16, &din, "num_road_types", &real_packet->num_road_types)) {
33972       RECEIVE_PACKET_FIELD_ERROR(num_road_types);
33973     }
33974   }
33975   if (BV_ISSET(fields, 7)) {
33976     log_packet_detailed("  got field 'num_disaster_types'");
33977     if (!DIO_GET(uint16, &din, "num_disaster_types", &real_packet->num_disaster_types)) {
33978       RECEIVE_PACKET_FIELD_ERROR(num_disaster_types);
33979     }
33980   }
33981   if (BV_ISSET(fields, 8)) {
33982     log_packet_detailed("  got field 'num_achievement_types'");
33983     if (!DIO_GET(uint16, &din, "num_achievement_types", &real_packet->num_achievement_types)) {
33984       RECEIVE_PACKET_FIELD_ERROR(num_achievement_types);
33985     }
33986   }
33987   if (BV_ISSET(fields, 9)) {
33988     log_packet_detailed("  got field 'num_multipliers'");
33989     if (!DIO_GET(uint16, &din, "num_multipliers", &real_packet->num_multipliers)) {
33990       RECEIVE_PACKET_FIELD_ERROR(num_multipliers);
33991     }
33992   }
33993   if (BV_ISSET(fields, 10)) {
33994     log_packet_detailed("  got field 'num_styles'");
33995     if (!DIO_GET(uint16, &din, "num_styles", &real_packet->num_styles)) {
33996       RECEIVE_PACKET_FIELD_ERROR(num_styles);
33997     }
33998   }
33999   if (BV_ISSET(fields, 11)) {
34000     log_packet_detailed("  got field 'num_music_styles'");
34001     if (!DIO_GET(uint16, &din, "num_music_styles", &real_packet->num_music_styles)) {
34002       RECEIVE_PACKET_FIELD_ERROR(num_music_styles);
34003     }
34004   }
34005   if (BV_ISSET(fields, 12)) {
34006     log_packet_detailed("  got field 'government_count'");
34007     if (!DIO_GET(uint16, &din, "government_count", &real_packet->government_count)) {
34008       RECEIVE_PACKET_FIELD_ERROR(government_count);
34009     }
34010   }
34011   if (BV_ISSET(fields, 13)) {
34012     log_packet_detailed("  got field 'nation_count'");
34013     if (!DIO_GET(uint16, &din, "nation_count", &real_packet->nation_count)) {
34014       RECEIVE_PACKET_FIELD_ERROR(nation_count);
34015     }
34016   }
34017   if (BV_ISSET(fields, 14)) {
34018     log_packet_detailed("  got field 'styles_count'");
34019     if (!DIO_GET(uint16, &din, "styles_count", &real_packet->styles_count)) {
34020       RECEIVE_PACKET_FIELD_ERROR(styles_count);
34021     }
34022   }
34023   if (BV_ISSET(fields, 15)) {
34024     log_packet_detailed("  got field 'terrain_count'");
34025     if (!DIO_GET(uint16, &din, "terrain_count", &real_packet->terrain_count)) {
34026       RECEIVE_PACKET_FIELD_ERROR(terrain_count);
34027     }
34028   }
34029   if (BV_ISSET(fields, 16)) {
34030     log_packet_detailed("  got field 'resource_count'");
34031     if (!DIO_GET(uint16, &din, "resource_count", &real_packet->resource_count)) {
34032       RECEIVE_PACKET_FIELD_ERROR(resource_count);
34033     }
34034   }
34035   if (BV_ISSET(fields, 17)) {
34036     log_packet_detailed("  got field 'num_specialist_types'");
34037     if (!DIO_GET(uint16, &din, "num_specialist_types", &real_packet->num_specialist_types)) {
34038       RECEIVE_PACKET_FIELD_ERROR(num_specialist_types);
34039     }
34040   }
34041   if (BV_ISSET(fields, 18)) {
34042     log_packet_detailed("  got field 'preferred_tileset'");
34043     if (!DIO_GET(string, &din, "preferred_tileset", real_packet->preferred_tileset, sizeof(real_packet->preferred_tileset))) {
34044       RECEIVE_PACKET_FIELD_ERROR(preferred_tileset);
34045     }
34046   }
34047   if (BV_ISSET(fields, 19)) {
34048     log_packet_detailed("  got field 'preferred_soundset'");
34049     if (!DIO_GET(string, &din, "preferred_soundset", real_packet->preferred_soundset, sizeof(real_packet->preferred_soundset))) {
34050       RECEIVE_PACKET_FIELD_ERROR(preferred_soundset);
34051     }
34052   }
34053   if (BV_ISSET(fields, 20)) {
34054     log_packet_detailed("  got field 'preferred_musicset'");
34055     if (!DIO_GET(string, &din, "preferred_musicset", real_packet->preferred_musicset, sizeof(real_packet->preferred_musicset))) {
34056       RECEIVE_PACKET_FIELD_ERROR(preferred_musicset);
34057     }
34058   }
34059   real_packet->popup_tech_help = BV_ISSET(fields, 21);
34060   if (BV_ISSET(fields, 22)) {
34061     log_packet_detailed("  got field 'name'");
34062     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
34063       RECEIVE_PACKET_FIELD_ERROR(name);
34064     }
34065   }
34066   if (BV_ISSET(fields, 23)) {
34067     log_packet_detailed("  got field 'version'");
34068     if (!DIO_GET(string, &din, "version", real_packet->version, sizeof(real_packet->version))) {
34069       RECEIVE_PACKET_FIELD_ERROR(version);
34070     }
34071   }
34072   if (BV_ISSET(fields, 24)) {
34073     log_packet_detailed("  got field 'desc_length'");
34074     if (!DIO_GET(uint16, &din, "desc_length", &real_packet->desc_length)) {
34075       RECEIVE_PACKET_FIELD_ERROR(desc_length);
34076     }
34077   }
34078 
34079   if (NULL == old) {
34080     old = fc_malloc(sizeof(*old));
34081     *old = *real_packet;
34082     genhash_insert(*hash, old, old);
34083   } else {
34084     *old = *real_packet;
34085   }
34086   RECEIVE_PACKET_END(real_packet);
34087 }
34088 
send_packet_ruleset_control_100(struct connection * pc,const struct packet_ruleset_control * packet)34089 static int send_packet_ruleset_control_100(struct connection *pc, const struct packet_ruleset_control *packet)
34090 {
34091   const struct packet_ruleset_control *real_packet = packet;
34092   packet_ruleset_control_100_fields fields;
34093   struct packet_ruleset_control *old;
34094   bool differ;
34095   struct genhash **hash = pc->phs.sent + PACKET_RULESET_CONTROL;
34096   int different = 0;
34097   SEND_PACKET_START(PACKET_RULESET_CONTROL);
34098 
34099   log_packet_detailed("packet_ruleset_control_100: sending info about ()");
34100 
34101   if (NULL == *hash) {
34102     *hash = genhash_new_full(hash_packet_ruleset_control_100, cmp_packet_ruleset_control_100,
34103                              NULL, NULL, NULL, free);
34104   }
34105   BV_CLR_ALL(fields);
34106 
34107   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
34108     old = fc_malloc(sizeof(*old));
34109     *old = *real_packet;
34110     genhash_insert(*hash, old, old);
34111     memset(old, 0, sizeof(*old));
34112     different = 1;      /* Force to send. */
34113   }
34114 
34115   differ = (old->num_unit_classes != real_packet->num_unit_classes);
34116   if (differ) {
34117     different++;
34118     BV_SET(fields, 0);
34119   }
34120 
34121   differ = (old->num_unit_types != real_packet->num_unit_types);
34122   if (differ) {
34123     different++;
34124     BV_SET(fields, 1);
34125   }
34126 
34127   differ = (old->num_impr_types != real_packet->num_impr_types);
34128   if (differ) {
34129     different++;
34130     BV_SET(fields, 2);
34131   }
34132 
34133   differ = (old->num_tech_types != real_packet->num_tech_types);
34134   if (differ) {
34135     different++;
34136     BV_SET(fields, 3);
34137   }
34138 
34139   differ = (old->num_extra_types != real_packet->num_extra_types);
34140   if (differ) {
34141     different++;
34142     BV_SET(fields, 4);
34143   }
34144 
34145   differ = (old->num_base_types != real_packet->num_base_types);
34146   if (differ) {
34147     different++;
34148     BV_SET(fields, 5);
34149   }
34150 
34151   differ = (old->num_road_types != real_packet->num_road_types);
34152   if (differ) {
34153     different++;
34154     BV_SET(fields, 6);
34155   }
34156 
34157   differ = (old->num_disaster_types != real_packet->num_disaster_types);
34158   if (differ) {
34159     different++;
34160     BV_SET(fields, 7);
34161   }
34162 
34163   differ = (old->num_achievement_types != real_packet->num_achievement_types);
34164   if (differ) {
34165     different++;
34166     BV_SET(fields, 8);
34167   }
34168 
34169   differ = (old->num_multipliers != real_packet->num_multipliers);
34170   if (differ) {
34171     different++;
34172     BV_SET(fields, 9);
34173   }
34174 
34175   differ = (old->num_styles != real_packet->num_styles);
34176   if (differ) {
34177     different++;
34178     BV_SET(fields, 10);
34179   }
34180 
34181   differ = (old->num_music_styles != real_packet->num_music_styles);
34182   if (differ) {
34183     different++;
34184     BV_SET(fields, 11);
34185   }
34186 
34187   differ = (old->government_count != real_packet->government_count);
34188   if (differ) {
34189     different++;
34190     BV_SET(fields, 12);
34191   }
34192 
34193   differ = (old->nation_count != real_packet->nation_count);
34194   if (differ) {
34195     different++;
34196     BV_SET(fields, 13);
34197   }
34198 
34199   differ = (old->styles_count != real_packet->styles_count);
34200   if (differ) {
34201     different++;
34202     BV_SET(fields, 14);
34203   }
34204 
34205   differ = (old->terrain_count != real_packet->terrain_count);
34206   if (differ) {
34207     different++;
34208     BV_SET(fields, 15);
34209   }
34210 
34211   differ = (old->resource_count != real_packet->resource_count);
34212   if (differ) {
34213     different++;
34214     BV_SET(fields, 16);
34215   }
34216 
34217   differ = (old->num_specialist_types != real_packet->num_specialist_types);
34218   if (differ) {
34219     different++;
34220     BV_SET(fields, 17);
34221   }
34222 
34223   differ = (strcmp(old->preferred_tileset, real_packet->preferred_tileset) != 0);
34224   if (differ) {
34225     different++;
34226     BV_SET(fields, 18);
34227   }
34228 
34229   differ = (strcmp(old->preferred_soundset, real_packet->preferred_soundset) != 0);
34230   if (differ) {
34231     different++;
34232     BV_SET(fields, 19);
34233   }
34234 
34235   differ = (strcmp(old->preferred_musicset, real_packet->preferred_musicset) != 0);
34236   if (differ) {
34237     different++;
34238     BV_SET(fields, 20);
34239   }
34240 
34241   differ = (old->popup_tech_help != real_packet->popup_tech_help);
34242   if (differ) {
34243     different++;
34244   }
34245   if (packet->popup_tech_help) {
34246     BV_SET(fields, 21);
34247   }
34248 
34249   differ = (strcmp(old->name, real_packet->name) != 0);
34250   if (differ) {
34251     different++;
34252     BV_SET(fields, 22);
34253   }
34254 
34255   differ = (strcmp(old->version, real_packet->version) != 0);
34256   if (differ) {
34257     different++;
34258     BV_SET(fields, 23);
34259   }
34260 
34261   differ = (old->desc_length != real_packet->desc_length);
34262   if (differ) {
34263     different++;
34264     BV_SET(fields, 24);
34265   }
34266 
34267 
34268   DIO_BV_PUT(&dout, "fields", fields);
34269 
34270   if (BV_ISSET(fields, 0)) {
34271     log_packet_detailed("  field 'num_unit_classes' has changed");
34272     DIO_PUT(uint16, &dout, "num_unit_classes", real_packet->num_unit_classes);
34273   }
34274   if (BV_ISSET(fields, 1)) {
34275     log_packet_detailed("  field 'num_unit_types' has changed");
34276     DIO_PUT(uint16, &dout, "num_unit_types", real_packet->num_unit_types);
34277   }
34278   if (BV_ISSET(fields, 2)) {
34279     log_packet_detailed("  field 'num_impr_types' has changed");
34280     DIO_PUT(uint16, &dout, "num_impr_types", real_packet->num_impr_types);
34281   }
34282   if (BV_ISSET(fields, 3)) {
34283     log_packet_detailed("  field 'num_tech_types' has changed");
34284     DIO_PUT(uint16, &dout, "num_tech_types", real_packet->num_tech_types);
34285   }
34286   if (BV_ISSET(fields, 4)) {
34287     log_packet_detailed("  field 'num_extra_types' has changed");
34288     DIO_PUT(uint16, &dout, "num_extra_types", real_packet->num_extra_types);
34289   }
34290   if (BV_ISSET(fields, 5)) {
34291     log_packet_detailed("  field 'num_base_types' has changed");
34292     DIO_PUT(uint16, &dout, "num_base_types", real_packet->num_base_types);
34293   }
34294   if (BV_ISSET(fields, 6)) {
34295     log_packet_detailed("  field 'num_road_types' has changed");
34296     DIO_PUT(uint16, &dout, "num_road_types", real_packet->num_road_types);
34297   }
34298   if (BV_ISSET(fields, 7)) {
34299     log_packet_detailed("  field 'num_disaster_types' has changed");
34300     DIO_PUT(uint16, &dout, "num_disaster_types", real_packet->num_disaster_types);
34301   }
34302   if (BV_ISSET(fields, 8)) {
34303     log_packet_detailed("  field 'num_achievement_types' has changed");
34304     DIO_PUT(uint16, &dout, "num_achievement_types", real_packet->num_achievement_types);
34305   }
34306   if (BV_ISSET(fields, 9)) {
34307     log_packet_detailed("  field 'num_multipliers' has changed");
34308     DIO_PUT(uint16, &dout, "num_multipliers", real_packet->num_multipliers);
34309   }
34310   if (BV_ISSET(fields, 10)) {
34311     log_packet_detailed("  field 'num_styles' has changed");
34312     DIO_PUT(uint16, &dout, "num_styles", real_packet->num_styles);
34313   }
34314   if (BV_ISSET(fields, 11)) {
34315     log_packet_detailed("  field 'num_music_styles' has changed");
34316     DIO_PUT(uint16, &dout, "num_music_styles", real_packet->num_music_styles);
34317   }
34318   if (BV_ISSET(fields, 12)) {
34319     log_packet_detailed("  field 'government_count' has changed");
34320     DIO_PUT(uint16, &dout, "government_count", real_packet->government_count);
34321   }
34322   if (BV_ISSET(fields, 13)) {
34323     log_packet_detailed("  field 'nation_count' has changed");
34324     DIO_PUT(uint16, &dout, "nation_count", real_packet->nation_count);
34325   }
34326   if (BV_ISSET(fields, 14)) {
34327     log_packet_detailed("  field 'styles_count' has changed");
34328     DIO_PUT(uint16, &dout, "styles_count", real_packet->styles_count);
34329   }
34330   if (BV_ISSET(fields, 15)) {
34331     log_packet_detailed("  field 'terrain_count' has changed");
34332     DIO_PUT(uint16, &dout, "terrain_count", real_packet->terrain_count);
34333   }
34334   if (BV_ISSET(fields, 16)) {
34335     log_packet_detailed("  field 'resource_count' has changed");
34336     DIO_PUT(uint16, &dout, "resource_count", real_packet->resource_count);
34337   }
34338   if (BV_ISSET(fields, 17)) {
34339     log_packet_detailed("  field 'num_specialist_types' has changed");
34340     DIO_PUT(uint16, &dout, "num_specialist_types", real_packet->num_specialist_types);
34341   }
34342   if (BV_ISSET(fields, 18)) {
34343     log_packet_detailed("  field 'preferred_tileset' has changed");
34344     DIO_PUT(string, &dout, "preferred_tileset", real_packet->preferred_tileset);
34345   }
34346   if (BV_ISSET(fields, 19)) {
34347     log_packet_detailed("  field 'preferred_soundset' has changed");
34348     DIO_PUT(string, &dout, "preferred_soundset", real_packet->preferred_soundset);
34349   }
34350   if (BV_ISSET(fields, 20)) {
34351     log_packet_detailed("  field 'preferred_musicset' has changed");
34352     DIO_PUT(string, &dout, "preferred_musicset", real_packet->preferred_musicset);
34353   }
34354   /* field 21 is folded into the header */
34355   if (BV_ISSET(fields, 22)) {
34356     log_packet_detailed("  field 'name' has changed");
34357     DIO_PUT(string, &dout, "name", real_packet->name);
34358   }
34359   if (BV_ISSET(fields, 23)) {
34360     log_packet_detailed("  field 'version' has changed");
34361     DIO_PUT(string, &dout, "version", real_packet->version);
34362   }
34363   if (BV_ISSET(fields, 24)) {
34364     log_packet_detailed("  field 'desc_length' has changed");
34365     DIO_PUT(uint16, &dout, "desc_length", real_packet->desc_length);
34366   }
34367 
34368   *old = *real_packet;
34369   SEND_PACKET_END(PACKET_RULESET_CONTROL);
34370 }
34371 
send_packet_ruleset_control(struct connection * pc,const struct packet_ruleset_control * packet)34372 int send_packet_ruleset_control(struct connection *pc, const struct packet_ruleset_control *packet)
34373 {
34374   if (!pc->used) {
34375     log_error("WARNING: trying to send data to the closed connection %s",
34376               conn_description(pc));
34377     return -1;
34378   }
34379   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_CONTROL].packet != NULL, -1,
34380                         "Handler for PACKET_RULESET_CONTROL not installed");
34381   return pc->phs.handlers->send[PACKET_RULESET_CONTROL].packet(pc, packet);
34382 }
34383 
lsend_packet_ruleset_control(struct conn_list * dest,const struct packet_ruleset_control * packet)34384 void lsend_packet_ruleset_control(struct conn_list *dest, const struct packet_ruleset_control *packet)
34385 {
34386   conn_list_iterate(dest, pconn) {
34387     send_packet_ruleset_control(pconn, packet);
34388   } conn_list_iterate_end;
34389 }
34390 
34391 #define hash_packet_ruleset_summary_100 hash_const
34392 
34393 #define cmp_packet_ruleset_summary_100 cmp_const
34394 
34395 BV_DEFINE(packet_ruleset_summary_100_fields, 1);
34396 
receive_packet_ruleset_summary_100(struct connection * pc)34397 static struct packet_ruleset_summary *receive_packet_ruleset_summary_100(struct connection *pc)
34398 {
34399   packet_ruleset_summary_100_fields fields;
34400   struct packet_ruleset_summary *old;
34401   struct genhash **hash = pc->phs.received + PACKET_RULESET_SUMMARY;
34402   RECEIVE_PACKET_START(packet_ruleset_summary, real_packet);
34403 
34404   DIO_BV_GET(&din, fields);
34405 
34406   log_packet_detailed("packet_ruleset_summary_100: got info about ()");
34407 
34408   if (NULL == *hash) {
34409     *hash = genhash_new_full(hash_packet_ruleset_summary_100, cmp_packet_ruleset_summary_100,
34410                              NULL, NULL, NULL, free);
34411   }
34412 
34413   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
34414     *real_packet = *old;
34415   } else {
34416     log_packet_detailed("  no old info");
34417     memset(real_packet, 0, sizeof(*real_packet));
34418   }
34419 
34420   if (BV_ISSET(fields, 0)) {
34421     log_packet_detailed("  got field 'text'");
34422     if (!DIO_GET(string, &din, "text", real_packet->text, sizeof(real_packet->text))) {
34423       RECEIVE_PACKET_FIELD_ERROR(text);
34424     }
34425   }
34426 
34427   if (NULL == old) {
34428     old = fc_malloc(sizeof(*old));
34429     *old = *real_packet;
34430     genhash_insert(*hash, old, old);
34431   } else {
34432     *old = *real_packet;
34433   }
34434   RECEIVE_PACKET_END(real_packet);
34435 }
34436 
send_packet_ruleset_summary_100(struct connection * pc,const struct packet_ruleset_summary * packet)34437 static int send_packet_ruleset_summary_100(struct connection *pc, const struct packet_ruleset_summary *packet)
34438 {
34439   const struct packet_ruleset_summary *real_packet = packet;
34440   packet_ruleset_summary_100_fields fields;
34441   struct packet_ruleset_summary *old;
34442   bool differ;
34443   struct genhash **hash = pc->phs.sent + PACKET_RULESET_SUMMARY;
34444   int different = 0;
34445   SEND_PACKET_START(PACKET_RULESET_SUMMARY);
34446 
34447   log_packet_detailed("packet_ruleset_summary_100: sending info about ()");
34448 
34449   if (NULL == *hash) {
34450     *hash = genhash_new_full(hash_packet_ruleset_summary_100, cmp_packet_ruleset_summary_100,
34451                              NULL, NULL, NULL, free);
34452   }
34453   BV_CLR_ALL(fields);
34454 
34455   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
34456     old = fc_malloc(sizeof(*old));
34457     *old = *real_packet;
34458     genhash_insert(*hash, old, old);
34459     memset(old, 0, sizeof(*old));
34460     different = 1;      /* Force to send. */
34461   }
34462 
34463   differ = (strcmp(old->text, real_packet->text) != 0);
34464   if (differ) {
34465     different++;
34466     BV_SET(fields, 0);
34467   }
34468 
34469 
34470   DIO_BV_PUT(&dout, "fields", fields);
34471 
34472   if (BV_ISSET(fields, 0)) {
34473     log_packet_detailed("  field 'text' has changed");
34474     DIO_PUT(string, &dout, "text", real_packet->text);
34475   }
34476 
34477   *old = *real_packet;
34478   SEND_PACKET_END(PACKET_RULESET_SUMMARY);
34479 }
34480 
send_packet_ruleset_summary(struct connection * pc,const struct packet_ruleset_summary * packet)34481 int send_packet_ruleset_summary(struct connection *pc, const struct packet_ruleset_summary *packet)
34482 {
34483   if (!pc->used) {
34484     log_error("WARNING: trying to send data to the closed connection %s",
34485               conn_description(pc));
34486     return -1;
34487   }
34488   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_SUMMARY].packet != NULL, -1,
34489                         "Handler for PACKET_RULESET_SUMMARY not installed");
34490   return pc->phs.handlers->send[PACKET_RULESET_SUMMARY].packet(pc, packet);
34491 }
34492 
lsend_packet_ruleset_summary(struct conn_list * dest,const struct packet_ruleset_summary * packet)34493 void lsend_packet_ruleset_summary(struct conn_list *dest, const struct packet_ruleset_summary *packet)
34494 {
34495   conn_list_iterate(dest, pconn) {
34496     send_packet_ruleset_summary(pconn, packet);
34497   } conn_list_iterate_end;
34498 }
34499 
34500 #define hash_packet_ruleset_description_part_100 hash_const
34501 
34502 #define cmp_packet_ruleset_description_part_100 cmp_const
34503 
34504 BV_DEFINE(packet_ruleset_description_part_100_fields, 1);
34505 
receive_packet_ruleset_description_part_100(struct connection * pc)34506 static struct packet_ruleset_description_part *receive_packet_ruleset_description_part_100(struct connection *pc)
34507 {
34508   packet_ruleset_description_part_100_fields fields;
34509   struct packet_ruleset_description_part *old;
34510   struct genhash **hash = pc->phs.received + PACKET_RULESET_DESCRIPTION_PART;
34511   RECEIVE_PACKET_START(packet_ruleset_description_part, real_packet);
34512 
34513   DIO_BV_GET(&din, fields);
34514 
34515   log_packet_detailed("packet_ruleset_description_part_100: got info about ()");
34516 
34517   if (NULL == *hash) {
34518     *hash = genhash_new_full(hash_packet_ruleset_description_part_100, cmp_packet_ruleset_description_part_100,
34519                              NULL, NULL, NULL, free);
34520   }
34521 
34522   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
34523     *real_packet = *old;
34524   } else {
34525     log_packet_detailed("  no old info");
34526     memset(real_packet, 0, sizeof(*real_packet));
34527   }
34528 
34529   if (BV_ISSET(fields, 0)) {
34530     log_packet_detailed("  got field 'text'");
34531     if (!DIO_GET(string, &din, "text", real_packet->text, sizeof(real_packet->text))) {
34532       RECEIVE_PACKET_FIELD_ERROR(text);
34533     }
34534   }
34535 
34536   if (NULL == old) {
34537     old = fc_malloc(sizeof(*old));
34538     *old = *real_packet;
34539     genhash_insert(*hash, old, old);
34540   } else {
34541     *old = *real_packet;
34542   }
34543   RECEIVE_PACKET_END(real_packet);
34544 }
34545 
send_packet_ruleset_description_part_100(struct connection * pc,const struct packet_ruleset_description_part * packet)34546 static int send_packet_ruleset_description_part_100(struct connection *pc, const struct packet_ruleset_description_part *packet)
34547 {
34548   const struct packet_ruleset_description_part *real_packet = packet;
34549   packet_ruleset_description_part_100_fields fields;
34550   struct packet_ruleset_description_part *old;
34551   bool differ;
34552   struct genhash **hash = pc->phs.sent + PACKET_RULESET_DESCRIPTION_PART;
34553   int different = 0;
34554   SEND_PACKET_START(PACKET_RULESET_DESCRIPTION_PART);
34555 
34556   log_packet_detailed("packet_ruleset_description_part_100: sending info about ()");
34557 
34558   if (NULL == *hash) {
34559     *hash = genhash_new_full(hash_packet_ruleset_description_part_100, cmp_packet_ruleset_description_part_100,
34560                              NULL, NULL, NULL, free);
34561   }
34562   BV_CLR_ALL(fields);
34563 
34564   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
34565     old = fc_malloc(sizeof(*old));
34566     *old = *real_packet;
34567     genhash_insert(*hash, old, old);
34568     memset(old, 0, sizeof(*old));
34569     different = 1;      /* Force to send. */
34570   }
34571 
34572   differ = (strcmp(old->text, real_packet->text) != 0);
34573   if (differ) {
34574     different++;
34575     BV_SET(fields, 0);
34576   }
34577 
34578 
34579   DIO_BV_PUT(&dout, "fields", fields);
34580 
34581   if (BV_ISSET(fields, 0)) {
34582     log_packet_detailed("  field 'text' has changed");
34583     DIO_PUT(string, &dout, "text", real_packet->text);
34584   }
34585 
34586   *old = *real_packet;
34587   SEND_PACKET_END(PACKET_RULESET_DESCRIPTION_PART);
34588 }
34589 
send_packet_ruleset_description_part(struct connection * pc,const struct packet_ruleset_description_part * packet)34590 int send_packet_ruleset_description_part(struct connection *pc, const struct packet_ruleset_description_part *packet)
34591 {
34592   if (!pc->used) {
34593     log_error("WARNING: trying to send data to the closed connection %s",
34594               conn_description(pc));
34595     return -1;
34596   }
34597   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_DESCRIPTION_PART].packet != NULL, -1,
34598                         "Handler for PACKET_RULESET_DESCRIPTION_PART not installed");
34599   return pc->phs.handlers->send[PACKET_RULESET_DESCRIPTION_PART].packet(pc, packet);
34600 }
34601 
lsend_packet_ruleset_description_part(struct conn_list * dest,const struct packet_ruleset_description_part * packet)34602 void lsend_packet_ruleset_description_part(struct conn_list *dest, const struct packet_ruleset_description_part *packet)
34603 {
34604   conn_list_iterate(dest, pconn) {
34605     send_packet_ruleset_description_part(pconn, packet);
34606   } conn_list_iterate_end;
34607 }
34608 
34609 #define hash_packet_single_want_hack_req_100 hash_const
34610 
34611 #define cmp_packet_single_want_hack_req_100 cmp_const
34612 
34613 BV_DEFINE(packet_single_want_hack_req_100_fields, 1);
34614 
receive_packet_single_want_hack_req_100(struct connection * pc)34615 static struct packet_single_want_hack_req *receive_packet_single_want_hack_req_100(struct connection *pc)
34616 {
34617   packet_single_want_hack_req_100_fields fields;
34618   struct packet_single_want_hack_req *old;
34619   struct genhash **hash = pc->phs.received + PACKET_SINGLE_WANT_HACK_REQ;
34620   RECEIVE_PACKET_START(packet_single_want_hack_req, real_packet);
34621 
34622   DIO_BV_GET(&din, fields);
34623 
34624   log_packet_detailed("packet_single_want_hack_req_100: got info about ()");
34625 
34626   if (NULL == *hash) {
34627     *hash = genhash_new_full(hash_packet_single_want_hack_req_100, cmp_packet_single_want_hack_req_100,
34628                              NULL, NULL, NULL, free);
34629   }
34630 
34631   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
34632     *real_packet = *old;
34633   } else {
34634     log_packet_detailed("  no old info");
34635     memset(real_packet, 0, sizeof(*real_packet));
34636   }
34637 
34638   if (BV_ISSET(fields, 0)) {
34639     log_packet_detailed("  got field 'token'");
34640     if (!DIO_GET(string, &din, "token", real_packet->token, sizeof(real_packet->token))) {
34641       RECEIVE_PACKET_FIELD_ERROR(token);
34642     }
34643   }
34644 
34645   if (NULL == old) {
34646     old = fc_malloc(sizeof(*old));
34647     *old = *real_packet;
34648     genhash_insert(*hash, old, old);
34649   } else {
34650     *old = *real_packet;
34651   }
34652   RECEIVE_PACKET_END(real_packet);
34653 }
34654 
send_packet_single_want_hack_req_100(struct connection * pc,const struct packet_single_want_hack_req * packet)34655 static int send_packet_single_want_hack_req_100(struct connection *pc, const struct packet_single_want_hack_req *packet)
34656 {
34657   const struct packet_single_want_hack_req *real_packet = packet;
34658   packet_single_want_hack_req_100_fields fields;
34659   struct packet_single_want_hack_req *old;
34660   bool differ;
34661   struct genhash **hash = pc->phs.sent + PACKET_SINGLE_WANT_HACK_REQ;
34662   int different = 0;
34663   SEND_PACKET_START(PACKET_SINGLE_WANT_HACK_REQ);
34664 
34665   log_packet_detailed("packet_single_want_hack_req_100: sending info about ()");
34666 
34667   if (NULL == *hash) {
34668     *hash = genhash_new_full(hash_packet_single_want_hack_req_100, cmp_packet_single_want_hack_req_100,
34669                              NULL, NULL, NULL, free);
34670   }
34671   BV_CLR_ALL(fields);
34672 
34673   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
34674     old = fc_malloc(sizeof(*old));
34675     *old = *real_packet;
34676     genhash_insert(*hash, old, old);
34677     memset(old, 0, sizeof(*old));
34678     different = 1;      /* Force to send. */
34679   }
34680 
34681   differ = (strcmp(old->token, real_packet->token) != 0);
34682   if (differ) {
34683     different++;
34684     BV_SET(fields, 0);
34685   }
34686 
34687 
34688   DIO_BV_PUT(&dout, "fields", fields);
34689 
34690   if (BV_ISSET(fields, 0)) {
34691     log_packet_detailed("  field 'token' has changed");
34692     DIO_PUT(string, &dout, "token", real_packet->token);
34693   }
34694 
34695   *old = *real_packet;
34696   SEND_PACKET_END(PACKET_SINGLE_WANT_HACK_REQ);
34697 }
34698 
send_packet_single_want_hack_req(struct connection * pc,const struct packet_single_want_hack_req * packet)34699 int send_packet_single_want_hack_req(struct connection *pc, const struct packet_single_want_hack_req *packet)
34700 {
34701   if (!pc->used) {
34702     log_error("WARNING: trying to send data to the closed connection %s",
34703               conn_description(pc));
34704     return -1;
34705   }
34706   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SINGLE_WANT_HACK_REQ].packet != NULL, -1,
34707                         "Handler for PACKET_SINGLE_WANT_HACK_REQ not installed");
34708   return pc->phs.handlers->send[PACKET_SINGLE_WANT_HACK_REQ].packet(pc, packet);
34709 }
34710 
34711 #define hash_packet_single_want_hack_reply_100 hash_const
34712 
34713 #define cmp_packet_single_want_hack_reply_100 cmp_const
34714 
34715 BV_DEFINE(packet_single_want_hack_reply_100_fields, 1);
34716 
receive_packet_single_want_hack_reply_100(struct connection * pc)34717 static struct packet_single_want_hack_reply *receive_packet_single_want_hack_reply_100(struct connection *pc)
34718 {
34719   packet_single_want_hack_reply_100_fields fields;
34720   struct packet_single_want_hack_reply *old;
34721   struct genhash **hash = pc->phs.received + PACKET_SINGLE_WANT_HACK_REPLY;
34722   RECEIVE_PACKET_START(packet_single_want_hack_reply, real_packet);
34723 
34724   DIO_BV_GET(&din, fields);
34725 
34726   log_packet_detailed("packet_single_want_hack_reply_100: got info about ()");
34727 
34728   if (NULL == *hash) {
34729     *hash = genhash_new_full(hash_packet_single_want_hack_reply_100, cmp_packet_single_want_hack_reply_100,
34730                              NULL, NULL, NULL, free);
34731   }
34732 
34733   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
34734     *real_packet = *old;
34735   } else {
34736     log_packet_detailed("  no old info");
34737     memset(real_packet, 0, sizeof(*real_packet));
34738   }
34739 
34740   real_packet->you_have_hack = BV_ISSET(fields, 0);
34741 
34742   if (NULL == old) {
34743     old = fc_malloc(sizeof(*old));
34744     *old = *real_packet;
34745     genhash_insert(*hash, old, old);
34746   } else {
34747     *old = *real_packet;
34748   }
34749   RECEIVE_PACKET_END(real_packet);
34750 }
34751 
send_packet_single_want_hack_reply_100(struct connection * pc,const struct packet_single_want_hack_reply * packet)34752 static int send_packet_single_want_hack_reply_100(struct connection *pc, const struct packet_single_want_hack_reply *packet)
34753 {
34754   const struct packet_single_want_hack_reply *real_packet = packet;
34755   packet_single_want_hack_reply_100_fields fields;
34756   struct packet_single_want_hack_reply *old;
34757   bool differ;
34758   struct genhash **hash = pc->phs.sent + PACKET_SINGLE_WANT_HACK_REPLY;
34759   int different = 0;
34760   SEND_PACKET_START(PACKET_SINGLE_WANT_HACK_REPLY);
34761 
34762   log_packet_detailed("packet_single_want_hack_reply_100: sending info about ()");
34763 
34764   if (NULL == *hash) {
34765     *hash = genhash_new_full(hash_packet_single_want_hack_reply_100, cmp_packet_single_want_hack_reply_100,
34766                              NULL, NULL, NULL, free);
34767   }
34768   BV_CLR_ALL(fields);
34769 
34770   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
34771     old = fc_malloc(sizeof(*old));
34772     *old = *real_packet;
34773     genhash_insert(*hash, old, old);
34774     memset(old, 0, sizeof(*old));
34775     different = 1;      /* Force to send. */
34776   }
34777 
34778   differ = (old->you_have_hack != real_packet->you_have_hack);
34779   if (differ) {
34780     different++;
34781   }
34782   if (packet->you_have_hack) {
34783     BV_SET(fields, 0);
34784   }
34785 
34786 
34787   DIO_BV_PUT(&dout, "fields", fields);
34788 
34789   /* field 0 is folded into the header */
34790 
34791   *old = *real_packet;
34792   SEND_PACKET_END(PACKET_SINGLE_WANT_HACK_REPLY);
34793 }
34794 
send_packet_single_want_hack_reply(struct connection * pc,const struct packet_single_want_hack_reply * packet)34795 int send_packet_single_want_hack_reply(struct connection *pc, const struct packet_single_want_hack_reply *packet)
34796 {
34797   if (!pc->used) {
34798     log_error("WARNING: trying to send data to the closed connection %s",
34799               conn_description(pc));
34800     return -1;
34801   }
34802   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SINGLE_WANT_HACK_REPLY].packet != NULL, -1,
34803                         "Handler for PACKET_SINGLE_WANT_HACK_REPLY not installed");
34804   return pc->phs.handlers->send[PACKET_SINGLE_WANT_HACK_REPLY].packet(pc, packet);
34805 }
34806 
dsend_packet_single_want_hack_reply(struct connection * pc,bool you_have_hack)34807 int dsend_packet_single_want_hack_reply(struct connection *pc, bool you_have_hack)
34808 {
34809   struct packet_single_want_hack_reply packet, *real_packet = &packet;
34810 
34811   real_packet->you_have_hack = you_have_hack;
34812 
34813   return send_packet_single_want_hack_reply(pc, real_packet);
34814 }
34815 
34816 #define hash_packet_ruleset_choices_100 hash_const
34817 
34818 #define cmp_packet_ruleset_choices_100 cmp_const
34819 
34820 BV_DEFINE(packet_ruleset_choices_100_fields, 2);
34821 
receive_packet_ruleset_choices_100(struct connection * pc)34822 static struct packet_ruleset_choices *receive_packet_ruleset_choices_100(struct connection *pc)
34823 {
34824   packet_ruleset_choices_100_fields fields;
34825   struct packet_ruleset_choices *old;
34826   struct genhash **hash = pc->phs.received + PACKET_RULESET_CHOICES;
34827   RECEIVE_PACKET_START(packet_ruleset_choices, real_packet);
34828 
34829   DIO_BV_GET(&din, fields);
34830 
34831   log_packet_detailed("packet_ruleset_choices_100: got info about ()");
34832 
34833   if (NULL == *hash) {
34834     *hash = genhash_new_full(hash_packet_ruleset_choices_100, cmp_packet_ruleset_choices_100,
34835                              NULL, NULL, NULL, free);
34836   }
34837 
34838   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
34839     *real_packet = *old;
34840   } else {
34841     log_packet_detailed("  no old info");
34842     memset(real_packet, 0, sizeof(*real_packet));
34843   }
34844 
34845   if (BV_ISSET(fields, 0)) {
34846     log_packet_detailed("  got field 'ruleset_count'");
34847     if (!DIO_GET(uint8, &din, "ruleset_count", &real_packet->ruleset_count)) {
34848       RECEIVE_PACKET_FIELD_ERROR(ruleset_count);
34849     }
34850   }
34851   if (BV_ISSET(fields, 1)) {
34852     log_packet_detailed("  got field 'rulesets'");
34853 
34854     {
34855       int i;
34856 
34857       if (real_packet->ruleset_count > MAX_NUM_RULESETS) {
34858         RECEIVE_PACKET_FIELD_ERROR(rulesets, ": truncation array");
34859       }
34860       for (i = 0; i < real_packet->ruleset_count; i++) {
34861         if (!DIO_GET(string, &din, "rulesets", real_packet->rulesets[i], sizeof(real_packet->rulesets[i]))) {
34862           RECEIVE_PACKET_FIELD_ERROR(rulesets);
34863         }
34864       }
34865     }
34866   }
34867 
34868   if (NULL == old) {
34869     old = fc_malloc(sizeof(*old));
34870     *old = *real_packet;
34871     genhash_insert(*hash, old, old);
34872   } else {
34873     *old = *real_packet;
34874   }
34875   RECEIVE_PACKET_END(real_packet);
34876 }
34877 
send_packet_ruleset_choices_100(struct connection * pc,const struct packet_ruleset_choices * packet)34878 static int send_packet_ruleset_choices_100(struct connection *pc, const struct packet_ruleset_choices *packet)
34879 {
34880   const struct packet_ruleset_choices *real_packet = packet;
34881   packet_ruleset_choices_100_fields fields;
34882   struct packet_ruleset_choices *old;
34883   bool differ;
34884   struct genhash **hash = pc->phs.sent + PACKET_RULESET_CHOICES;
34885   int different = 0;
34886   SEND_PACKET_START(PACKET_RULESET_CHOICES);
34887 
34888   log_packet_detailed("packet_ruleset_choices_100: sending info about ()");
34889 
34890   if (NULL == *hash) {
34891     *hash = genhash_new_full(hash_packet_ruleset_choices_100, cmp_packet_ruleset_choices_100,
34892                              NULL, NULL, NULL, free);
34893   }
34894   BV_CLR_ALL(fields);
34895 
34896   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
34897     old = fc_malloc(sizeof(*old));
34898     *old = *real_packet;
34899     genhash_insert(*hash, old, old);
34900     memset(old, 0, sizeof(*old));
34901     different = 1;      /* Force to send. */
34902   }
34903 
34904   differ = (old->ruleset_count != real_packet->ruleset_count);
34905   if (differ) {
34906     different++;
34907     BV_SET(fields, 0);
34908   }
34909 
34910 
34911     {
34912       differ = (old->ruleset_count != real_packet->ruleset_count);
34913       if (!differ) {
34914         int i;
34915 
34916         for (i = 0; i < real_packet->ruleset_count; i++) {
34917           if (strcmp(old->rulesets[i], real_packet->rulesets[i]) != 0) {
34918             differ = TRUE;
34919             break;
34920           }
34921         }
34922       }
34923     }
34924   if (differ) {
34925     different++;
34926     BV_SET(fields, 1);
34927   }
34928 
34929 
34930   DIO_BV_PUT(&dout, "fields", fields);
34931 
34932   if (BV_ISSET(fields, 0)) {
34933     log_packet_detailed("  field 'ruleset_count' has changed");
34934     DIO_PUT(uint8, &dout, "ruleset_count", real_packet->ruleset_count);
34935   }
34936   if (BV_ISSET(fields, 1)) {
34937     log_packet_detailed("  field 'rulesets' has changed");
34938 
34939     {
34940       int i;
34941 
34942       for (i = 0; i < real_packet->ruleset_count; i++) {
34943         dio_put_string(&dout, real_packet->rulesets[i]);
34944       }
34945     }
34946   }
34947 
34948   *old = *real_packet;
34949   SEND_PACKET_END(PACKET_RULESET_CHOICES);
34950 }
34951 
send_packet_ruleset_choices(struct connection * pc,const struct packet_ruleset_choices * packet)34952 int send_packet_ruleset_choices(struct connection *pc, const struct packet_ruleset_choices *packet)
34953 {
34954   if (!pc->used) {
34955     log_error("WARNING: trying to send data to the closed connection %s",
34956               conn_description(pc));
34957     return -1;
34958   }
34959   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_CHOICES].packet != NULL, -1,
34960                         "Handler for PACKET_RULESET_CHOICES not installed");
34961   return pc->phs.handlers->send[PACKET_RULESET_CHOICES].packet(pc, packet);
34962 }
34963 
34964 #define hash_packet_game_load_100 hash_const
34965 
34966 #define cmp_packet_game_load_100 cmp_const
34967 
34968 BV_DEFINE(packet_game_load_100_fields, 2);
34969 
receive_packet_game_load_100(struct connection * pc)34970 static struct packet_game_load *receive_packet_game_load_100(struct connection *pc)
34971 {
34972   packet_game_load_100_fields fields;
34973   struct packet_game_load *old;
34974   struct genhash **hash = pc->phs.received + PACKET_GAME_LOAD;
34975   RECEIVE_PACKET_START(packet_game_load, real_packet);
34976 
34977   DIO_BV_GET(&din, fields);
34978 
34979   log_packet_detailed("packet_game_load_100: got info about ()");
34980 
34981   if (NULL == *hash) {
34982     *hash = genhash_new_full(hash_packet_game_load_100, cmp_packet_game_load_100,
34983                              NULL, NULL, NULL, free);
34984   }
34985 
34986   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
34987     *real_packet = *old;
34988   } else {
34989     log_packet_detailed("  no old info");
34990     memset(real_packet, 0, sizeof(*real_packet));
34991   }
34992 
34993   real_packet->load_successful = BV_ISSET(fields, 0);
34994   if (BV_ISSET(fields, 1)) {
34995     log_packet_detailed("  got field 'load_filename'");
34996     if (!DIO_GET(string, &din, "load_filename", real_packet->load_filename, sizeof(real_packet->load_filename))) {
34997       RECEIVE_PACKET_FIELD_ERROR(load_filename);
34998     }
34999   }
35000 
35001   if (NULL == old) {
35002     old = fc_malloc(sizeof(*old));
35003     *old = *real_packet;
35004     genhash_insert(*hash, old, old);
35005   } else {
35006     *old = *real_packet;
35007   }
35008   RECEIVE_PACKET_END(real_packet);
35009 }
35010 
send_packet_game_load_100(struct connection * pc,const struct packet_game_load * packet)35011 static int send_packet_game_load_100(struct connection *pc, const struct packet_game_load *packet)
35012 {
35013   const struct packet_game_load *real_packet = packet;
35014   packet_game_load_100_fields fields;
35015   struct packet_game_load *old;
35016   bool differ;
35017   struct genhash **hash = pc->phs.sent + PACKET_GAME_LOAD;
35018   int different = 0;
35019   SEND_PACKET_START(PACKET_GAME_LOAD);
35020 
35021   log_packet_detailed("packet_game_load_100: sending info about ()");
35022 
35023   if (NULL == *hash) {
35024     *hash = genhash_new_full(hash_packet_game_load_100, cmp_packet_game_load_100,
35025                              NULL, NULL, NULL, free);
35026   }
35027   BV_CLR_ALL(fields);
35028 
35029   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
35030     old = fc_malloc(sizeof(*old));
35031     *old = *real_packet;
35032     genhash_insert(*hash, old, old);
35033     memset(old, 0, sizeof(*old));
35034     different = 1;      /* Force to send. */
35035   }
35036 
35037   differ = (old->load_successful != real_packet->load_successful);
35038   if (differ) {
35039     different++;
35040   }
35041   if (packet->load_successful) {
35042     BV_SET(fields, 0);
35043   }
35044 
35045   differ = (strcmp(old->load_filename, real_packet->load_filename) != 0);
35046   if (differ) {
35047     different++;
35048     BV_SET(fields, 1);
35049   }
35050 
35051 
35052   DIO_BV_PUT(&dout, "fields", fields);
35053 
35054   /* field 0 is folded into the header */
35055   if (BV_ISSET(fields, 1)) {
35056     log_packet_detailed("  field 'load_filename' has changed");
35057     DIO_PUT(string, &dout, "load_filename", real_packet->load_filename);
35058   }
35059 
35060   *old = *real_packet;
35061   SEND_PACKET_END(PACKET_GAME_LOAD);
35062 }
35063 
send_packet_game_load(struct connection * pc,const struct packet_game_load * packet)35064 int send_packet_game_load(struct connection *pc, const struct packet_game_load *packet)
35065 {
35066   if (!pc->used) {
35067     log_error("WARNING: trying to send data to the closed connection %s",
35068               conn_description(pc));
35069     return -1;
35070   }
35071   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_GAME_LOAD].packet != NULL, -1,
35072                         "Handler for PACKET_GAME_LOAD not installed");
35073   return pc->phs.handlers->send[PACKET_GAME_LOAD].packet(pc, packet);
35074 }
35075 
lsend_packet_game_load(struct conn_list * dest,const struct packet_game_load * packet)35076 void lsend_packet_game_load(struct conn_list *dest, const struct packet_game_load *packet)
35077 {
35078   conn_list_iterate(dest, pconn) {
35079     send_packet_game_load(pconn, packet);
35080   } conn_list_iterate_end;
35081 }
35082 
dsend_packet_game_load(struct connection * pc,bool load_successful,const char * load_filename)35083 int dsend_packet_game_load(struct connection *pc, bool load_successful, const char *load_filename)
35084 {
35085   struct packet_game_load packet, *real_packet = &packet;
35086 
35087   real_packet->load_successful = load_successful;
35088   sz_strlcpy(real_packet->load_filename, load_filename);
35089 
35090   return send_packet_game_load(pc, real_packet);
35091 }
35092 
dlsend_packet_game_load(struct conn_list * dest,bool load_successful,const char * load_filename)35093 void dlsend_packet_game_load(struct conn_list *dest, bool load_successful, const char *load_filename)
35094 {
35095   struct packet_game_load packet, *real_packet = &packet;
35096 
35097   real_packet->load_successful = load_successful;
35098   sz_strlcpy(real_packet->load_filename, load_filename);
35099 
35100   lsend_packet_game_load(dest, real_packet);
35101 }
35102 
35103 #define hash_packet_server_setting_control_100 hash_const
35104 
35105 #define cmp_packet_server_setting_control_100 cmp_const
35106 
35107 BV_DEFINE(packet_server_setting_control_100_fields, 3);
35108 
receive_packet_server_setting_control_100(struct connection * pc)35109 static struct packet_server_setting_control *receive_packet_server_setting_control_100(struct connection *pc)
35110 {
35111   packet_server_setting_control_100_fields fields;
35112   struct packet_server_setting_control *old;
35113   struct genhash **hash = pc->phs.received + PACKET_SERVER_SETTING_CONTROL;
35114   RECEIVE_PACKET_START(packet_server_setting_control, real_packet);
35115 
35116   DIO_BV_GET(&din, fields);
35117 
35118   log_packet_detailed("packet_server_setting_control_100: got info about ()");
35119 
35120   if (NULL == *hash) {
35121     *hash = genhash_new_full(hash_packet_server_setting_control_100, cmp_packet_server_setting_control_100,
35122                              NULL, NULL, NULL, free);
35123   }
35124 
35125   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
35126     *real_packet = *old;
35127   } else {
35128     log_packet_detailed("  no old info");
35129     memset(real_packet, 0, sizeof(*real_packet));
35130   }
35131 
35132   if (BV_ISSET(fields, 0)) {
35133     log_packet_detailed("  got field 'settings_num'");
35134     if (!DIO_GET(uint16, &din, "settings_num", &real_packet->settings_num)) {
35135       RECEIVE_PACKET_FIELD_ERROR(settings_num);
35136     }
35137   }
35138   if (BV_ISSET(fields, 1)) {
35139     log_packet_detailed("  got field 'categories_num'");
35140     if (!DIO_GET(uint8, &din, "categories_num", &real_packet->categories_num)) {
35141       RECEIVE_PACKET_FIELD_ERROR(categories_num);
35142     }
35143   }
35144   if (BV_ISSET(fields, 2)) {
35145     log_packet_detailed("  got field 'category_names'");
35146 
35147     {
35148       int i;
35149 
35150       if (real_packet->categories_num > 256) {
35151         RECEIVE_PACKET_FIELD_ERROR(category_names, ": truncation array");
35152       }
35153       for (i = 0; i < real_packet->categories_num; i++) {
35154         if (!DIO_GET(string, &din, "category_names", real_packet->category_names[i], sizeof(real_packet->category_names[i]))) {
35155           RECEIVE_PACKET_FIELD_ERROR(category_names);
35156         }
35157       }
35158     }
35159   }
35160 
35161   if (NULL == old) {
35162     old = fc_malloc(sizeof(*old));
35163     *old = *real_packet;
35164     genhash_insert(*hash, old, old);
35165   } else {
35166     *old = *real_packet;
35167   }
35168   RECEIVE_PACKET_END(real_packet);
35169 }
35170 
send_packet_server_setting_control_100(struct connection * pc,const struct packet_server_setting_control * packet)35171 static int send_packet_server_setting_control_100(struct connection *pc, const struct packet_server_setting_control *packet)
35172 {
35173   const struct packet_server_setting_control *real_packet = packet;
35174   packet_server_setting_control_100_fields fields;
35175   struct packet_server_setting_control *old;
35176   bool differ;
35177   struct genhash **hash = pc->phs.sent + PACKET_SERVER_SETTING_CONTROL;
35178   int different = 0;
35179   SEND_PACKET_START(PACKET_SERVER_SETTING_CONTROL);
35180 
35181   log_packet_detailed("packet_server_setting_control_100: sending info about ()");
35182 
35183   if (NULL == *hash) {
35184     *hash = genhash_new_full(hash_packet_server_setting_control_100, cmp_packet_server_setting_control_100,
35185                              NULL, NULL, NULL, free);
35186   }
35187   BV_CLR_ALL(fields);
35188 
35189   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
35190     old = fc_malloc(sizeof(*old));
35191     *old = *real_packet;
35192     genhash_insert(*hash, old, old);
35193     memset(old, 0, sizeof(*old));
35194     different = 1;      /* Force to send. */
35195   }
35196 
35197   differ = (old->settings_num != real_packet->settings_num);
35198   if (differ) {
35199     different++;
35200     BV_SET(fields, 0);
35201   }
35202 
35203   differ = (old->categories_num != real_packet->categories_num);
35204   if (differ) {
35205     different++;
35206     BV_SET(fields, 1);
35207   }
35208 
35209 
35210     {
35211       differ = (old->categories_num != real_packet->categories_num);
35212       if (!differ) {
35213         int i;
35214 
35215         for (i = 0; i < real_packet->categories_num; i++) {
35216           if (strcmp(old->category_names[i], real_packet->category_names[i]) != 0) {
35217             differ = TRUE;
35218             break;
35219           }
35220         }
35221       }
35222     }
35223   if (differ) {
35224     different++;
35225     BV_SET(fields, 2);
35226   }
35227 
35228 
35229   if (different == 0) {
35230     log_packet_detailed("  no change -> discard");
35231     return 0;
35232   }
35233 
35234   DIO_BV_PUT(&dout, "fields", fields);
35235 
35236   if (BV_ISSET(fields, 0)) {
35237     log_packet_detailed("  field 'settings_num' has changed");
35238     DIO_PUT(uint16, &dout, "settings_num", real_packet->settings_num);
35239   }
35240   if (BV_ISSET(fields, 1)) {
35241     log_packet_detailed("  field 'categories_num' has changed");
35242     DIO_PUT(uint8, &dout, "categories_num", real_packet->categories_num);
35243   }
35244   if (BV_ISSET(fields, 2)) {
35245     log_packet_detailed("  field 'category_names' has changed");
35246 
35247     {
35248       int i;
35249 
35250       for (i = 0; i < real_packet->categories_num; i++) {
35251         dio_put_string(&dout, real_packet->category_names[i]);
35252       }
35253     }
35254   }
35255 
35256   *old = *real_packet;
35257   SEND_PACKET_END(PACKET_SERVER_SETTING_CONTROL);
35258 }
35259 
send_packet_server_setting_control(struct connection * pc,const struct packet_server_setting_control * packet)35260 int send_packet_server_setting_control(struct connection *pc, const struct packet_server_setting_control *packet)
35261 {
35262   if (!pc->used) {
35263     log_error("WARNING: trying to send data to the closed connection %s",
35264               conn_description(pc));
35265     return -1;
35266   }
35267   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SERVER_SETTING_CONTROL].packet != NULL, -1,
35268                         "Handler for PACKET_SERVER_SETTING_CONTROL not installed");
35269   return pc->phs.handlers->send[PACKET_SERVER_SETTING_CONTROL].packet(pc, packet);
35270 }
35271 
hash_packet_server_setting_const_100(const void * vkey)35272 static genhash_val_t hash_packet_server_setting_const_100(const void *vkey)
35273 {
35274   const struct packet_server_setting_const *key = (const struct packet_server_setting_const *) vkey;
35275 
35276   return key->id;
35277 }
35278 
cmp_packet_server_setting_const_100(const void * vkey1,const void * vkey2)35279 static bool cmp_packet_server_setting_const_100(const void *vkey1, const void *vkey2)
35280 {
35281   const struct packet_server_setting_const *key1 = (const struct packet_server_setting_const *) vkey1;
35282   const struct packet_server_setting_const *key2 = (const struct packet_server_setting_const *) vkey2;
35283 
35284   return key1->id == key2->id;
35285 }
35286 
35287 BV_DEFINE(packet_server_setting_const_100_fields, 4);
35288 
receive_packet_server_setting_const_100(struct connection * pc)35289 static struct packet_server_setting_const *receive_packet_server_setting_const_100(struct connection *pc)
35290 {
35291   packet_server_setting_const_100_fields fields;
35292   struct packet_server_setting_const *old;
35293   struct genhash **hash = pc->phs.received + PACKET_SERVER_SETTING_CONST;
35294   RECEIVE_PACKET_START(packet_server_setting_const, real_packet);
35295 
35296   DIO_BV_GET(&din, fields);
35297   if (!DIO_GET(uint16, &din, "id", &real_packet->id)) {
35298     RECEIVE_PACKET_FIELD_ERROR(id);
35299   }
35300 
35301   log_packet_detailed("packet_server_setting_const_100: got info about (%d)",
35302     real_packet->id);
35303 
35304   if (NULL == *hash) {
35305     *hash = genhash_new_full(hash_packet_server_setting_const_100, cmp_packet_server_setting_const_100,
35306                              NULL, NULL, NULL, free);
35307   }
35308 
35309   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
35310     *real_packet = *old;
35311   } else {
35312     int id = real_packet->id;
35313 
35314     log_packet_detailed("  no old info");
35315     memset(real_packet, 0, sizeof(*real_packet));
35316 
35317     real_packet->id = id;
35318   }
35319 
35320   if (BV_ISSET(fields, 0)) {
35321     log_packet_detailed("  got field 'name'");
35322     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
35323       RECEIVE_PACKET_FIELD_ERROR(name);
35324     }
35325   }
35326   if (BV_ISSET(fields, 1)) {
35327     log_packet_detailed("  got field 'short_help'");
35328     if (!DIO_GET(string, &din, "short_help", real_packet->short_help, sizeof(real_packet->short_help))) {
35329       RECEIVE_PACKET_FIELD_ERROR(short_help);
35330     }
35331   }
35332   if (BV_ISSET(fields, 2)) {
35333     log_packet_detailed("  got field 'extra_help'");
35334     if (!DIO_GET(string, &din, "extra_help", real_packet->extra_help, sizeof(real_packet->extra_help))) {
35335       RECEIVE_PACKET_FIELD_ERROR(extra_help);
35336     }
35337   }
35338   if (BV_ISSET(fields, 3)) {
35339     log_packet_detailed("  got field 'category'");
35340     if (!DIO_GET(uint8, &din, "category", &real_packet->category)) {
35341       RECEIVE_PACKET_FIELD_ERROR(category);
35342     }
35343   }
35344 
35345   if (NULL == old) {
35346     old = fc_malloc(sizeof(*old));
35347     *old = *real_packet;
35348     genhash_insert(*hash, old, old);
35349   } else {
35350     *old = *real_packet;
35351   }
35352   RECEIVE_PACKET_END(real_packet);
35353 }
35354 
send_packet_server_setting_const_100(struct connection * pc,const struct packet_server_setting_const * packet)35355 static int send_packet_server_setting_const_100(struct connection *pc, const struct packet_server_setting_const *packet)
35356 {
35357   const struct packet_server_setting_const *real_packet = packet;
35358   packet_server_setting_const_100_fields fields;
35359   struct packet_server_setting_const *old;
35360   bool differ;
35361   struct genhash **hash = pc->phs.sent + PACKET_SERVER_SETTING_CONST;
35362   int different = 0;
35363   SEND_PACKET_START(PACKET_SERVER_SETTING_CONST);
35364 
35365   log_packet_detailed("packet_server_setting_const_100: sending info about (%d)",
35366     real_packet->id);
35367 
35368   if (NULL == *hash) {
35369     *hash = genhash_new_full(hash_packet_server_setting_const_100, cmp_packet_server_setting_const_100,
35370                              NULL, NULL, NULL, free);
35371   }
35372   BV_CLR_ALL(fields);
35373 
35374   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
35375     old = fc_malloc(sizeof(*old));
35376     *old = *real_packet;
35377     genhash_insert(*hash, old, old);
35378     memset(old, 0, sizeof(*old));
35379     different = 1;      /* Force to send. */
35380   }
35381 
35382   differ = (strcmp(old->name, real_packet->name) != 0);
35383   if (differ) {
35384     different++;
35385     BV_SET(fields, 0);
35386   }
35387 
35388   differ = (strcmp(old->short_help, real_packet->short_help) != 0);
35389   if (differ) {
35390     different++;
35391     BV_SET(fields, 1);
35392   }
35393 
35394   differ = (strcmp(old->extra_help, real_packet->extra_help) != 0);
35395   if (differ) {
35396     different++;
35397     BV_SET(fields, 2);
35398   }
35399 
35400   differ = (old->category != real_packet->category);
35401   if (differ) {
35402     different++;
35403     BV_SET(fields, 3);
35404   }
35405 
35406 
35407   if (different == 0) {
35408     log_packet_detailed("  no change -> discard");
35409     return 0;
35410   }
35411 
35412   DIO_BV_PUT(&dout, "fields", fields);
35413   DIO_PUT(uint16, &dout, "id", real_packet->id);
35414 
35415   if (BV_ISSET(fields, 0)) {
35416     log_packet_detailed("  field 'name' has changed");
35417     DIO_PUT(string, &dout, "name", real_packet->name);
35418   }
35419   if (BV_ISSET(fields, 1)) {
35420     log_packet_detailed("  field 'short_help' has changed");
35421     DIO_PUT(string, &dout, "short_help", real_packet->short_help);
35422   }
35423   if (BV_ISSET(fields, 2)) {
35424     log_packet_detailed("  field 'extra_help' has changed");
35425     DIO_PUT(string, &dout, "extra_help", real_packet->extra_help);
35426   }
35427   if (BV_ISSET(fields, 3)) {
35428     log_packet_detailed("  field 'category' has changed");
35429     DIO_PUT(uint8, &dout, "category", real_packet->category);
35430   }
35431 
35432   *old = *real_packet;
35433   SEND_PACKET_END(PACKET_SERVER_SETTING_CONST);
35434 }
35435 
send_packet_server_setting_const(struct connection * pc,const struct packet_server_setting_const * packet)35436 int send_packet_server_setting_const(struct connection *pc, const struct packet_server_setting_const *packet)
35437 {
35438   if (!pc->used) {
35439     log_error("WARNING: trying to send data to the closed connection %s",
35440               conn_description(pc));
35441     return -1;
35442   }
35443   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SERVER_SETTING_CONST].packet != NULL, -1,
35444                         "Handler for PACKET_SERVER_SETTING_CONST not installed");
35445   return pc->phs.handlers->send[PACKET_SERVER_SETTING_CONST].packet(pc, packet);
35446 }
35447 
hash_packet_server_setting_bool_100(const void * vkey)35448 static genhash_val_t hash_packet_server_setting_bool_100(const void *vkey)
35449 {
35450   const struct packet_server_setting_bool *key = (const struct packet_server_setting_bool *) vkey;
35451 
35452   return key->id;
35453 }
35454 
cmp_packet_server_setting_bool_100(const void * vkey1,const void * vkey2)35455 static bool cmp_packet_server_setting_bool_100(const void *vkey1, const void *vkey2)
35456 {
35457   const struct packet_server_setting_bool *key1 = (const struct packet_server_setting_bool *) vkey1;
35458   const struct packet_server_setting_bool *key2 = (const struct packet_server_setting_bool *) vkey2;
35459 
35460   return key1->id == key2->id;
35461 }
35462 
35463 BV_DEFINE(packet_server_setting_bool_100_fields, 5);
35464 
receive_packet_server_setting_bool_100(struct connection * pc)35465 static struct packet_server_setting_bool *receive_packet_server_setting_bool_100(struct connection *pc)
35466 {
35467   packet_server_setting_bool_100_fields fields;
35468   struct packet_server_setting_bool *old;
35469   struct genhash **hash = pc->phs.received + PACKET_SERVER_SETTING_BOOL;
35470   RECEIVE_PACKET_START(packet_server_setting_bool, real_packet);
35471 
35472   DIO_BV_GET(&din, fields);
35473   if (!DIO_GET(uint16, &din, "id", &real_packet->id)) {
35474     RECEIVE_PACKET_FIELD_ERROR(id);
35475   }
35476 
35477   log_packet_detailed("packet_server_setting_bool_100: got info about (%d)",
35478     real_packet->id);
35479 
35480   if (NULL == *hash) {
35481     *hash = genhash_new_full(hash_packet_server_setting_bool_100, cmp_packet_server_setting_bool_100,
35482                              NULL, NULL, NULL, free);
35483   }
35484 
35485   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
35486     *real_packet = *old;
35487   } else {
35488     int id = real_packet->id;
35489 
35490     log_packet_detailed("  no old info");
35491     memset(real_packet, 0, sizeof(*real_packet));
35492 
35493     real_packet->id = id;
35494   }
35495 
35496   real_packet->is_visible = BV_ISSET(fields, 0);
35497   real_packet->is_changeable = BV_ISSET(fields, 1);
35498   real_packet->initial_setting = BV_ISSET(fields, 2);
35499   real_packet->val = BV_ISSET(fields, 3);
35500   real_packet->default_val = BV_ISSET(fields, 4);
35501 
35502   if (NULL == old) {
35503     old = fc_malloc(sizeof(*old));
35504     *old = *real_packet;
35505     genhash_insert(*hash, old, old);
35506   } else {
35507     *old = *real_packet;
35508   }
35509   RECEIVE_PACKET_END(real_packet);
35510 }
35511 
send_packet_server_setting_bool_100(struct connection * pc,const struct packet_server_setting_bool * packet)35512 static int send_packet_server_setting_bool_100(struct connection *pc, const struct packet_server_setting_bool *packet)
35513 {
35514   const struct packet_server_setting_bool *real_packet = packet;
35515   packet_server_setting_bool_100_fields fields;
35516   struct packet_server_setting_bool *old;
35517   bool differ;
35518   struct genhash **hash = pc->phs.sent + PACKET_SERVER_SETTING_BOOL;
35519   int different = 0;
35520   SEND_PACKET_START(PACKET_SERVER_SETTING_BOOL);
35521 
35522   log_packet_detailed("packet_server_setting_bool_100: sending info about (%d)",
35523     real_packet->id);
35524 
35525   if (NULL == *hash) {
35526     *hash = genhash_new_full(hash_packet_server_setting_bool_100, cmp_packet_server_setting_bool_100,
35527                              NULL, NULL, NULL, free);
35528   }
35529   BV_CLR_ALL(fields);
35530 
35531   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
35532     old = fc_malloc(sizeof(*old));
35533     *old = *real_packet;
35534     genhash_insert(*hash, old, old);
35535     memset(old, 0, sizeof(*old));
35536     different = 1;      /* Force to send. */
35537   }
35538 
35539   differ = (old->is_visible != real_packet->is_visible);
35540   if (differ) {
35541     different++;
35542   }
35543   if (packet->is_visible) {
35544     BV_SET(fields, 0);
35545   }
35546 
35547   differ = (old->is_changeable != real_packet->is_changeable);
35548   if (differ) {
35549     different++;
35550   }
35551   if (packet->is_changeable) {
35552     BV_SET(fields, 1);
35553   }
35554 
35555   differ = (old->initial_setting != real_packet->initial_setting);
35556   if (differ) {
35557     different++;
35558   }
35559   if (packet->initial_setting) {
35560     BV_SET(fields, 2);
35561   }
35562 
35563   differ = (old->val != real_packet->val);
35564   if (differ) {
35565     different++;
35566   }
35567   if (packet->val) {
35568     BV_SET(fields, 3);
35569   }
35570 
35571   differ = (old->default_val != real_packet->default_val);
35572   if (differ) {
35573     different++;
35574   }
35575   if (packet->default_val) {
35576     BV_SET(fields, 4);
35577   }
35578 
35579 
35580   if (different == 0) {
35581     log_packet_detailed("  no change -> discard");
35582     return 0;
35583   }
35584 
35585   DIO_BV_PUT(&dout, "fields", fields);
35586   DIO_PUT(uint16, &dout, "id", real_packet->id);
35587 
35588   /* field 0 is folded into the header */
35589   /* field 1 is folded into the header */
35590   /* field 2 is folded into the header */
35591   /* field 3 is folded into the header */
35592   /* field 4 is folded into the header */
35593 
35594   *old = *real_packet;
35595   SEND_PACKET_END(PACKET_SERVER_SETTING_BOOL);
35596 }
35597 
send_packet_server_setting_bool(struct connection * pc,const struct packet_server_setting_bool * packet)35598 int send_packet_server_setting_bool(struct connection *pc, const struct packet_server_setting_bool *packet)
35599 {
35600   if (!pc->used) {
35601     log_error("WARNING: trying to send data to the closed connection %s",
35602               conn_description(pc));
35603     return -1;
35604   }
35605   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SERVER_SETTING_BOOL].packet != NULL, -1,
35606                         "Handler for PACKET_SERVER_SETTING_BOOL not installed");
35607   return pc->phs.handlers->send[PACKET_SERVER_SETTING_BOOL].packet(pc, packet);
35608 }
35609 
hash_packet_server_setting_int_100(const void * vkey)35610 static genhash_val_t hash_packet_server_setting_int_100(const void *vkey)
35611 {
35612   const struct packet_server_setting_int *key = (const struct packet_server_setting_int *) vkey;
35613 
35614   return key->id;
35615 }
35616 
cmp_packet_server_setting_int_100(const void * vkey1,const void * vkey2)35617 static bool cmp_packet_server_setting_int_100(const void *vkey1, const void *vkey2)
35618 {
35619   const struct packet_server_setting_int *key1 = (const struct packet_server_setting_int *) vkey1;
35620   const struct packet_server_setting_int *key2 = (const struct packet_server_setting_int *) vkey2;
35621 
35622   return key1->id == key2->id;
35623 }
35624 
35625 BV_DEFINE(packet_server_setting_int_100_fields, 7);
35626 
receive_packet_server_setting_int_100(struct connection * pc)35627 static struct packet_server_setting_int *receive_packet_server_setting_int_100(struct connection *pc)
35628 {
35629   packet_server_setting_int_100_fields fields;
35630   struct packet_server_setting_int *old;
35631   struct genhash **hash = pc->phs.received + PACKET_SERVER_SETTING_INT;
35632   RECEIVE_PACKET_START(packet_server_setting_int, real_packet);
35633 
35634   DIO_BV_GET(&din, fields);
35635   if (!DIO_GET(uint16, &din, "id", &real_packet->id)) {
35636     RECEIVE_PACKET_FIELD_ERROR(id);
35637   }
35638 
35639   log_packet_detailed("packet_server_setting_int_100: got info about (%d)",
35640     real_packet->id);
35641 
35642   if (NULL == *hash) {
35643     *hash = genhash_new_full(hash_packet_server_setting_int_100, cmp_packet_server_setting_int_100,
35644                              NULL, NULL, NULL, free);
35645   }
35646 
35647   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
35648     *real_packet = *old;
35649   } else {
35650     int id = real_packet->id;
35651 
35652     log_packet_detailed("  no old info");
35653     memset(real_packet, 0, sizeof(*real_packet));
35654 
35655     real_packet->id = id;
35656   }
35657 
35658   real_packet->is_visible = BV_ISSET(fields, 0);
35659   real_packet->is_changeable = BV_ISSET(fields, 1);
35660   real_packet->initial_setting = BV_ISSET(fields, 2);
35661   if (BV_ISSET(fields, 3)) {
35662     log_packet_detailed("  got field 'val'");
35663     if (!DIO_GET(sint32, &din, "val", &real_packet->val)) {
35664       RECEIVE_PACKET_FIELD_ERROR(val);
35665     }
35666   }
35667   if (BV_ISSET(fields, 4)) {
35668     log_packet_detailed("  got field 'default_val'");
35669     if (!DIO_GET(sint32, &din, "default_val", &real_packet->default_val)) {
35670       RECEIVE_PACKET_FIELD_ERROR(default_val);
35671     }
35672   }
35673   if (BV_ISSET(fields, 5)) {
35674     log_packet_detailed("  got field 'min_val'");
35675     if (!DIO_GET(sint32, &din, "min_val", &real_packet->min_val)) {
35676       RECEIVE_PACKET_FIELD_ERROR(min_val);
35677     }
35678   }
35679   if (BV_ISSET(fields, 6)) {
35680     log_packet_detailed("  got field 'max_val'");
35681     if (!DIO_GET(sint32, &din, "max_val", &real_packet->max_val)) {
35682       RECEIVE_PACKET_FIELD_ERROR(max_val);
35683     }
35684   }
35685 
35686   if (NULL == old) {
35687     old = fc_malloc(sizeof(*old));
35688     *old = *real_packet;
35689     genhash_insert(*hash, old, old);
35690   } else {
35691     *old = *real_packet;
35692   }
35693   RECEIVE_PACKET_END(real_packet);
35694 }
35695 
send_packet_server_setting_int_100(struct connection * pc,const struct packet_server_setting_int * packet)35696 static int send_packet_server_setting_int_100(struct connection *pc, const struct packet_server_setting_int *packet)
35697 {
35698   const struct packet_server_setting_int *real_packet = packet;
35699   packet_server_setting_int_100_fields fields;
35700   struct packet_server_setting_int *old;
35701   bool differ;
35702   struct genhash **hash = pc->phs.sent + PACKET_SERVER_SETTING_INT;
35703   int different = 0;
35704   SEND_PACKET_START(PACKET_SERVER_SETTING_INT);
35705 
35706   log_packet_detailed("packet_server_setting_int_100: sending info about (%d)",
35707     real_packet->id);
35708 
35709   if (NULL == *hash) {
35710     *hash = genhash_new_full(hash_packet_server_setting_int_100, cmp_packet_server_setting_int_100,
35711                              NULL, NULL, NULL, free);
35712   }
35713   BV_CLR_ALL(fields);
35714 
35715   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
35716     old = fc_malloc(sizeof(*old));
35717     *old = *real_packet;
35718     genhash_insert(*hash, old, old);
35719     memset(old, 0, sizeof(*old));
35720     different = 1;      /* Force to send. */
35721   }
35722 
35723   differ = (old->is_visible != real_packet->is_visible);
35724   if (differ) {
35725     different++;
35726   }
35727   if (packet->is_visible) {
35728     BV_SET(fields, 0);
35729   }
35730 
35731   differ = (old->is_changeable != real_packet->is_changeable);
35732   if (differ) {
35733     different++;
35734   }
35735   if (packet->is_changeable) {
35736     BV_SET(fields, 1);
35737   }
35738 
35739   differ = (old->initial_setting != real_packet->initial_setting);
35740   if (differ) {
35741     different++;
35742   }
35743   if (packet->initial_setting) {
35744     BV_SET(fields, 2);
35745   }
35746 
35747   differ = (old->val != real_packet->val);
35748   if (differ) {
35749     different++;
35750     BV_SET(fields, 3);
35751   }
35752 
35753   differ = (old->default_val != real_packet->default_val);
35754   if (differ) {
35755     different++;
35756     BV_SET(fields, 4);
35757   }
35758 
35759   differ = (old->min_val != real_packet->min_val);
35760   if (differ) {
35761     different++;
35762     BV_SET(fields, 5);
35763   }
35764 
35765   differ = (old->max_val != real_packet->max_val);
35766   if (differ) {
35767     different++;
35768     BV_SET(fields, 6);
35769   }
35770 
35771 
35772   if (different == 0) {
35773     log_packet_detailed("  no change -> discard");
35774     return 0;
35775   }
35776 
35777   DIO_BV_PUT(&dout, "fields", fields);
35778   DIO_PUT(uint16, &dout, "id", real_packet->id);
35779 
35780   /* field 0 is folded into the header */
35781   /* field 1 is folded into the header */
35782   /* field 2 is folded into the header */
35783   if (BV_ISSET(fields, 3)) {
35784     log_packet_detailed("  field 'val' has changed");
35785     DIO_PUT(sint32, &dout, "val", real_packet->val);
35786   }
35787   if (BV_ISSET(fields, 4)) {
35788     log_packet_detailed("  field 'default_val' has changed");
35789     DIO_PUT(sint32, &dout, "default_val", real_packet->default_val);
35790   }
35791   if (BV_ISSET(fields, 5)) {
35792     log_packet_detailed("  field 'min_val' has changed");
35793     DIO_PUT(sint32, &dout, "min_val", real_packet->min_val);
35794   }
35795   if (BV_ISSET(fields, 6)) {
35796     log_packet_detailed("  field 'max_val' has changed");
35797     DIO_PUT(sint32, &dout, "max_val", real_packet->max_val);
35798   }
35799 
35800   *old = *real_packet;
35801   SEND_PACKET_END(PACKET_SERVER_SETTING_INT);
35802 }
35803 
send_packet_server_setting_int(struct connection * pc,const struct packet_server_setting_int * packet)35804 int send_packet_server_setting_int(struct connection *pc, const struct packet_server_setting_int *packet)
35805 {
35806   if (!pc->used) {
35807     log_error("WARNING: trying to send data to the closed connection %s",
35808               conn_description(pc));
35809     return -1;
35810   }
35811   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SERVER_SETTING_INT].packet != NULL, -1,
35812                         "Handler for PACKET_SERVER_SETTING_INT not installed");
35813   return pc->phs.handlers->send[PACKET_SERVER_SETTING_INT].packet(pc, packet);
35814 }
35815 
hash_packet_server_setting_str_100(const void * vkey)35816 static genhash_val_t hash_packet_server_setting_str_100(const void *vkey)
35817 {
35818   const struct packet_server_setting_str *key = (const struct packet_server_setting_str *) vkey;
35819 
35820   return key->id;
35821 }
35822 
cmp_packet_server_setting_str_100(const void * vkey1,const void * vkey2)35823 static bool cmp_packet_server_setting_str_100(const void *vkey1, const void *vkey2)
35824 {
35825   const struct packet_server_setting_str *key1 = (const struct packet_server_setting_str *) vkey1;
35826   const struct packet_server_setting_str *key2 = (const struct packet_server_setting_str *) vkey2;
35827 
35828   return key1->id == key2->id;
35829 }
35830 
35831 BV_DEFINE(packet_server_setting_str_100_fields, 5);
35832 
receive_packet_server_setting_str_100(struct connection * pc)35833 static struct packet_server_setting_str *receive_packet_server_setting_str_100(struct connection *pc)
35834 {
35835   packet_server_setting_str_100_fields fields;
35836   struct packet_server_setting_str *old;
35837   struct genhash **hash = pc->phs.received + PACKET_SERVER_SETTING_STR;
35838   RECEIVE_PACKET_START(packet_server_setting_str, real_packet);
35839 
35840   DIO_BV_GET(&din, fields);
35841   if (!DIO_GET(uint16, &din, "id", &real_packet->id)) {
35842     RECEIVE_PACKET_FIELD_ERROR(id);
35843   }
35844 
35845   log_packet_detailed("packet_server_setting_str_100: got info about (%d)",
35846     real_packet->id);
35847 
35848   if (NULL == *hash) {
35849     *hash = genhash_new_full(hash_packet_server_setting_str_100, cmp_packet_server_setting_str_100,
35850                              NULL, NULL, NULL, free);
35851   }
35852 
35853   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
35854     *real_packet = *old;
35855   } else {
35856     int id = real_packet->id;
35857 
35858     log_packet_detailed("  no old info");
35859     memset(real_packet, 0, sizeof(*real_packet));
35860 
35861     real_packet->id = id;
35862   }
35863 
35864   real_packet->is_visible = BV_ISSET(fields, 0);
35865   real_packet->is_changeable = BV_ISSET(fields, 1);
35866   real_packet->initial_setting = BV_ISSET(fields, 2);
35867   if (BV_ISSET(fields, 3)) {
35868     log_packet_detailed("  got field 'val'");
35869     if (!DIO_GET(string, &din, "val", real_packet->val, sizeof(real_packet->val))) {
35870       RECEIVE_PACKET_FIELD_ERROR(val);
35871     }
35872   }
35873   if (BV_ISSET(fields, 4)) {
35874     log_packet_detailed("  got field 'default_val'");
35875     if (!DIO_GET(string, &din, "default_val", real_packet->default_val, sizeof(real_packet->default_val))) {
35876       RECEIVE_PACKET_FIELD_ERROR(default_val);
35877     }
35878   }
35879 
35880   if (NULL == old) {
35881     old = fc_malloc(sizeof(*old));
35882     *old = *real_packet;
35883     genhash_insert(*hash, old, old);
35884   } else {
35885     *old = *real_packet;
35886   }
35887   RECEIVE_PACKET_END(real_packet);
35888 }
35889 
send_packet_server_setting_str_100(struct connection * pc,const struct packet_server_setting_str * packet)35890 static int send_packet_server_setting_str_100(struct connection *pc, const struct packet_server_setting_str *packet)
35891 {
35892   const struct packet_server_setting_str *real_packet = packet;
35893   packet_server_setting_str_100_fields fields;
35894   struct packet_server_setting_str *old;
35895   bool differ;
35896   struct genhash **hash = pc->phs.sent + PACKET_SERVER_SETTING_STR;
35897   int different = 0;
35898   SEND_PACKET_START(PACKET_SERVER_SETTING_STR);
35899 
35900   log_packet_detailed("packet_server_setting_str_100: sending info about (%d)",
35901     real_packet->id);
35902 
35903   if (NULL == *hash) {
35904     *hash = genhash_new_full(hash_packet_server_setting_str_100, cmp_packet_server_setting_str_100,
35905                              NULL, NULL, NULL, free);
35906   }
35907   BV_CLR_ALL(fields);
35908 
35909   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
35910     old = fc_malloc(sizeof(*old));
35911     *old = *real_packet;
35912     genhash_insert(*hash, old, old);
35913     memset(old, 0, sizeof(*old));
35914     different = 1;      /* Force to send. */
35915   }
35916 
35917   differ = (old->is_visible != real_packet->is_visible);
35918   if (differ) {
35919     different++;
35920   }
35921   if (packet->is_visible) {
35922     BV_SET(fields, 0);
35923   }
35924 
35925   differ = (old->is_changeable != real_packet->is_changeable);
35926   if (differ) {
35927     different++;
35928   }
35929   if (packet->is_changeable) {
35930     BV_SET(fields, 1);
35931   }
35932 
35933   differ = (old->initial_setting != real_packet->initial_setting);
35934   if (differ) {
35935     different++;
35936   }
35937   if (packet->initial_setting) {
35938     BV_SET(fields, 2);
35939   }
35940 
35941   differ = (strcmp(old->val, real_packet->val) != 0);
35942   if (differ) {
35943     different++;
35944     BV_SET(fields, 3);
35945   }
35946 
35947   differ = (strcmp(old->default_val, real_packet->default_val) != 0);
35948   if (differ) {
35949     different++;
35950     BV_SET(fields, 4);
35951   }
35952 
35953 
35954   if (different == 0) {
35955     log_packet_detailed("  no change -> discard");
35956     return 0;
35957   }
35958 
35959   DIO_BV_PUT(&dout, "fields", fields);
35960   DIO_PUT(uint16, &dout, "id", real_packet->id);
35961 
35962   /* field 0 is folded into the header */
35963   /* field 1 is folded into the header */
35964   /* field 2 is folded into the header */
35965   if (BV_ISSET(fields, 3)) {
35966     log_packet_detailed("  field 'val' has changed");
35967     DIO_PUT(string, &dout, "val", real_packet->val);
35968   }
35969   if (BV_ISSET(fields, 4)) {
35970     log_packet_detailed("  field 'default_val' has changed");
35971     DIO_PUT(string, &dout, "default_val", real_packet->default_val);
35972   }
35973 
35974   *old = *real_packet;
35975   SEND_PACKET_END(PACKET_SERVER_SETTING_STR);
35976 }
35977 
send_packet_server_setting_str(struct connection * pc,const struct packet_server_setting_str * packet)35978 int send_packet_server_setting_str(struct connection *pc, const struct packet_server_setting_str *packet)
35979 {
35980   if (!pc->used) {
35981     log_error("WARNING: trying to send data to the closed connection %s",
35982               conn_description(pc));
35983     return -1;
35984   }
35985   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SERVER_SETTING_STR].packet != NULL, -1,
35986                         "Handler for PACKET_SERVER_SETTING_STR not installed");
35987   return pc->phs.handlers->send[PACKET_SERVER_SETTING_STR].packet(pc, packet);
35988 }
35989 
hash_packet_server_setting_enum_100(const void * vkey)35990 static genhash_val_t hash_packet_server_setting_enum_100(const void *vkey)
35991 {
35992   const struct packet_server_setting_enum *key = (const struct packet_server_setting_enum *) vkey;
35993 
35994   return key->id;
35995 }
35996 
cmp_packet_server_setting_enum_100(const void * vkey1,const void * vkey2)35997 static bool cmp_packet_server_setting_enum_100(const void *vkey1, const void *vkey2)
35998 {
35999   const struct packet_server_setting_enum *key1 = (const struct packet_server_setting_enum *) vkey1;
36000   const struct packet_server_setting_enum *key2 = (const struct packet_server_setting_enum *) vkey2;
36001 
36002   return key1->id == key2->id;
36003 }
36004 
36005 BV_DEFINE(packet_server_setting_enum_100_fields, 8);
36006 
receive_packet_server_setting_enum_100(struct connection * pc)36007 static struct packet_server_setting_enum *receive_packet_server_setting_enum_100(struct connection *pc)
36008 {
36009   packet_server_setting_enum_100_fields fields;
36010   struct packet_server_setting_enum *old;
36011   struct genhash **hash = pc->phs.received + PACKET_SERVER_SETTING_ENUM;
36012   RECEIVE_PACKET_START(packet_server_setting_enum, real_packet);
36013 
36014   DIO_BV_GET(&din, fields);
36015   if (!DIO_GET(uint16, &din, "id", &real_packet->id)) {
36016     RECEIVE_PACKET_FIELD_ERROR(id);
36017   }
36018 
36019   log_packet_detailed("packet_server_setting_enum_100: got info about (%d)",
36020     real_packet->id);
36021 
36022   if (NULL == *hash) {
36023     *hash = genhash_new_full(hash_packet_server_setting_enum_100, cmp_packet_server_setting_enum_100,
36024                              NULL, NULL, NULL, free);
36025   }
36026 
36027   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
36028     *real_packet = *old;
36029   } else {
36030     int id = real_packet->id;
36031 
36032     log_packet_detailed("  no old info");
36033     memset(real_packet, 0, sizeof(*real_packet));
36034 
36035     real_packet->id = id;
36036   }
36037 
36038   real_packet->is_visible = BV_ISSET(fields, 0);
36039   real_packet->is_changeable = BV_ISSET(fields, 1);
36040   real_packet->initial_setting = BV_ISSET(fields, 2);
36041   if (BV_ISSET(fields, 3)) {
36042     log_packet_detailed("  got field 'val'");
36043     if (!DIO_GET(sint8, &din, "val", &real_packet->val)) {
36044       RECEIVE_PACKET_FIELD_ERROR(val);
36045     }
36046   }
36047   if (BV_ISSET(fields, 4)) {
36048     log_packet_detailed("  got field 'default_val'");
36049     if (!DIO_GET(sint8, &din, "default_val", &real_packet->default_val)) {
36050       RECEIVE_PACKET_FIELD_ERROR(default_val);
36051     }
36052   }
36053   if (BV_ISSET(fields, 5)) {
36054     log_packet_detailed("  got field 'values_num'");
36055     if (!DIO_GET(sint8, &din, "values_num", &real_packet->values_num)) {
36056       RECEIVE_PACKET_FIELD_ERROR(values_num);
36057     }
36058   }
36059   if (BV_ISSET(fields, 6)) {
36060     log_packet_detailed("  got field 'support_names'");
36061 
36062     {
36063       int i;
36064 
36065       if (real_packet->values_num > 64) {
36066         RECEIVE_PACKET_FIELD_ERROR(support_names, ": truncation array");
36067       }
36068       for (i = 0; i < real_packet->values_num; i++) {
36069         if (!DIO_GET(string, &din, "support_names", real_packet->support_names[i], sizeof(real_packet->support_names[i]))) {
36070           RECEIVE_PACKET_FIELD_ERROR(support_names);
36071         }
36072       }
36073     }
36074   }
36075   if (BV_ISSET(fields, 7)) {
36076     log_packet_detailed("  got field 'pretty_names'");
36077 
36078     {
36079       int i;
36080 
36081       if (real_packet->values_num > 64) {
36082         RECEIVE_PACKET_FIELD_ERROR(pretty_names, ": truncation array");
36083       }
36084       for (i = 0; i < real_packet->values_num; i++) {
36085         if (!DIO_GET(string, &din, "pretty_names", real_packet->pretty_names[i], sizeof(real_packet->pretty_names[i]))) {
36086           RECEIVE_PACKET_FIELD_ERROR(pretty_names);
36087         }
36088       }
36089     }
36090   }
36091 
36092   if (NULL == old) {
36093     old = fc_malloc(sizeof(*old));
36094     *old = *real_packet;
36095     genhash_insert(*hash, old, old);
36096   } else {
36097     *old = *real_packet;
36098   }
36099   RECEIVE_PACKET_END(real_packet);
36100 }
36101 
send_packet_server_setting_enum_100(struct connection * pc,const struct packet_server_setting_enum * packet)36102 static int send_packet_server_setting_enum_100(struct connection *pc, const struct packet_server_setting_enum *packet)
36103 {
36104   const struct packet_server_setting_enum *real_packet = packet;
36105   packet_server_setting_enum_100_fields fields;
36106   struct packet_server_setting_enum *old;
36107   bool differ;
36108   struct genhash **hash = pc->phs.sent + PACKET_SERVER_SETTING_ENUM;
36109   int different = 0;
36110   SEND_PACKET_START(PACKET_SERVER_SETTING_ENUM);
36111 
36112   log_packet_detailed("packet_server_setting_enum_100: sending info about (%d)",
36113     real_packet->id);
36114 
36115   if (NULL == *hash) {
36116     *hash = genhash_new_full(hash_packet_server_setting_enum_100, cmp_packet_server_setting_enum_100,
36117                              NULL, NULL, NULL, free);
36118   }
36119   BV_CLR_ALL(fields);
36120 
36121   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
36122     old = fc_malloc(sizeof(*old));
36123     *old = *real_packet;
36124     genhash_insert(*hash, old, old);
36125     memset(old, 0, sizeof(*old));
36126     different = 1;      /* Force to send. */
36127   }
36128 
36129   differ = (old->is_visible != real_packet->is_visible);
36130   if (differ) {
36131     different++;
36132   }
36133   if (packet->is_visible) {
36134     BV_SET(fields, 0);
36135   }
36136 
36137   differ = (old->is_changeable != real_packet->is_changeable);
36138   if (differ) {
36139     different++;
36140   }
36141   if (packet->is_changeable) {
36142     BV_SET(fields, 1);
36143   }
36144 
36145   differ = (old->initial_setting != real_packet->initial_setting);
36146   if (differ) {
36147     different++;
36148   }
36149   if (packet->initial_setting) {
36150     BV_SET(fields, 2);
36151   }
36152 
36153   differ = (old->val != real_packet->val);
36154   if (differ) {
36155     different++;
36156     BV_SET(fields, 3);
36157   }
36158 
36159   differ = (old->default_val != real_packet->default_val);
36160   if (differ) {
36161     different++;
36162     BV_SET(fields, 4);
36163   }
36164 
36165   differ = (old->values_num != real_packet->values_num);
36166   if (differ) {
36167     different++;
36168     BV_SET(fields, 5);
36169   }
36170 
36171 
36172     {
36173       differ = (old->values_num != real_packet->values_num);
36174       if (!differ) {
36175         int i;
36176 
36177         for (i = 0; i < real_packet->values_num; i++) {
36178           if (strcmp(old->support_names[i], real_packet->support_names[i]) != 0) {
36179             differ = TRUE;
36180             break;
36181           }
36182         }
36183       }
36184     }
36185   if (differ) {
36186     different++;
36187     BV_SET(fields, 6);
36188   }
36189 
36190 
36191     {
36192       differ = (old->values_num != real_packet->values_num);
36193       if (!differ) {
36194         int i;
36195 
36196         for (i = 0; i < real_packet->values_num; i++) {
36197           if (strcmp(old->pretty_names[i], real_packet->pretty_names[i]) != 0) {
36198             differ = TRUE;
36199             break;
36200           }
36201         }
36202       }
36203     }
36204   if (differ) {
36205     different++;
36206     BV_SET(fields, 7);
36207   }
36208 
36209 
36210   if (different == 0) {
36211     log_packet_detailed("  no change -> discard");
36212     return 0;
36213   }
36214 
36215   DIO_BV_PUT(&dout, "fields", fields);
36216   DIO_PUT(uint16, &dout, "id", real_packet->id);
36217 
36218   /* field 0 is folded into the header */
36219   /* field 1 is folded into the header */
36220   /* field 2 is folded into the header */
36221   if (BV_ISSET(fields, 3)) {
36222     log_packet_detailed("  field 'val' has changed");
36223     DIO_PUT(sint8, &dout, "val", real_packet->val);
36224   }
36225   if (BV_ISSET(fields, 4)) {
36226     log_packet_detailed("  field 'default_val' has changed");
36227     DIO_PUT(sint8, &dout, "default_val", real_packet->default_val);
36228   }
36229   if (BV_ISSET(fields, 5)) {
36230     log_packet_detailed("  field 'values_num' has changed");
36231     DIO_PUT(sint8, &dout, "values_num", real_packet->values_num);
36232   }
36233   if (BV_ISSET(fields, 6)) {
36234     log_packet_detailed("  field 'support_names' has changed");
36235 
36236     {
36237       int i;
36238 
36239       for (i = 0; i < real_packet->values_num; i++) {
36240         dio_put_string(&dout, real_packet->support_names[i]);
36241       }
36242     }
36243   }
36244   if (BV_ISSET(fields, 7)) {
36245     log_packet_detailed("  field 'pretty_names' has changed");
36246 
36247     {
36248       int i;
36249 
36250       for (i = 0; i < real_packet->values_num; i++) {
36251         dio_put_string(&dout, real_packet->pretty_names[i]);
36252       }
36253     }
36254   }
36255 
36256   *old = *real_packet;
36257   SEND_PACKET_END(PACKET_SERVER_SETTING_ENUM);
36258 }
36259 
send_packet_server_setting_enum(struct connection * pc,const struct packet_server_setting_enum * packet)36260 int send_packet_server_setting_enum(struct connection *pc, const struct packet_server_setting_enum *packet)
36261 {
36262   if (!pc->used) {
36263     log_error("WARNING: trying to send data to the closed connection %s",
36264               conn_description(pc));
36265     return -1;
36266   }
36267   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SERVER_SETTING_ENUM].packet != NULL, -1,
36268                         "Handler for PACKET_SERVER_SETTING_ENUM not installed");
36269   return pc->phs.handlers->send[PACKET_SERVER_SETTING_ENUM].packet(pc, packet);
36270 }
36271 
hash_packet_server_setting_bitwise_100(const void * vkey)36272 static genhash_val_t hash_packet_server_setting_bitwise_100(const void *vkey)
36273 {
36274   const struct packet_server_setting_bitwise *key = (const struct packet_server_setting_bitwise *) vkey;
36275 
36276   return key->id;
36277 }
36278 
cmp_packet_server_setting_bitwise_100(const void * vkey1,const void * vkey2)36279 static bool cmp_packet_server_setting_bitwise_100(const void *vkey1, const void *vkey2)
36280 {
36281   const struct packet_server_setting_bitwise *key1 = (const struct packet_server_setting_bitwise *) vkey1;
36282   const struct packet_server_setting_bitwise *key2 = (const struct packet_server_setting_bitwise *) vkey2;
36283 
36284   return key1->id == key2->id;
36285 }
36286 
36287 BV_DEFINE(packet_server_setting_bitwise_100_fields, 8);
36288 
receive_packet_server_setting_bitwise_100(struct connection * pc)36289 static struct packet_server_setting_bitwise *receive_packet_server_setting_bitwise_100(struct connection *pc)
36290 {
36291   packet_server_setting_bitwise_100_fields fields;
36292   struct packet_server_setting_bitwise *old;
36293   struct genhash **hash = pc->phs.received + PACKET_SERVER_SETTING_BITWISE;
36294   RECEIVE_PACKET_START(packet_server_setting_bitwise, real_packet);
36295 
36296   DIO_BV_GET(&din, fields);
36297   if (!DIO_GET(uint16, &din, "id", &real_packet->id)) {
36298     RECEIVE_PACKET_FIELD_ERROR(id);
36299   }
36300 
36301   log_packet_detailed("packet_server_setting_bitwise_100: got info about (%d)",
36302     real_packet->id);
36303 
36304   if (NULL == *hash) {
36305     *hash = genhash_new_full(hash_packet_server_setting_bitwise_100, cmp_packet_server_setting_bitwise_100,
36306                              NULL, NULL, NULL, free);
36307   }
36308 
36309   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
36310     *real_packet = *old;
36311   } else {
36312     int id = real_packet->id;
36313 
36314     log_packet_detailed("  no old info");
36315     memset(real_packet, 0, sizeof(*real_packet));
36316 
36317     real_packet->id = id;
36318   }
36319 
36320   real_packet->is_visible = BV_ISSET(fields, 0);
36321   real_packet->is_changeable = BV_ISSET(fields, 1);
36322   real_packet->initial_setting = BV_ISSET(fields, 2);
36323   if (BV_ISSET(fields, 3)) {
36324     log_packet_detailed("  got field 'val'");
36325     if (!DIO_GET(uint16, &din, "val", &real_packet->val)) {
36326       RECEIVE_PACKET_FIELD_ERROR(val);
36327     }
36328   }
36329   if (BV_ISSET(fields, 4)) {
36330     log_packet_detailed("  got field 'default_val'");
36331     if (!DIO_GET(uint16, &din, "default_val", &real_packet->default_val)) {
36332       RECEIVE_PACKET_FIELD_ERROR(default_val);
36333     }
36334   }
36335   if (BV_ISSET(fields, 5)) {
36336     log_packet_detailed("  got field 'bits_num'");
36337     if (!DIO_GET(uint8, &din, "bits_num", &real_packet->bits_num)) {
36338       RECEIVE_PACKET_FIELD_ERROR(bits_num);
36339     }
36340   }
36341   if (BV_ISSET(fields, 6)) {
36342     log_packet_detailed("  got field 'support_names'");
36343 
36344     {
36345       int i;
36346 
36347       if (real_packet->bits_num > 64) {
36348         RECEIVE_PACKET_FIELD_ERROR(support_names, ": truncation array");
36349       }
36350       for (i = 0; i < real_packet->bits_num; i++) {
36351         if (!DIO_GET(string, &din, "support_names", real_packet->support_names[i], sizeof(real_packet->support_names[i]))) {
36352           RECEIVE_PACKET_FIELD_ERROR(support_names);
36353         }
36354       }
36355     }
36356   }
36357   if (BV_ISSET(fields, 7)) {
36358     log_packet_detailed("  got field 'pretty_names'");
36359 
36360     {
36361       int i;
36362 
36363       if (real_packet->bits_num > 64) {
36364         RECEIVE_PACKET_FIELD_ERROR(pretty_names, ": truncation array");
36365       }
36366       for (i = 0; i < real_packet->bits_num; i++) {
36367         if (!DIO_GET(string, &din, "pretty_names", real_packet->pretty_names[i], sizeof(real_packet->pretty_names[i]))) {
36368           RECEIVE_PACKET_FIELD_ERROR(pretty_names);
36369         }
36370       }
36371     }
36372   }
36373 
36374   if (NULL == old) {
36375     old = fc_malloc(sizeof(*old));
36376     *old = *real_packet;
36377     genhash_insert(*hash, old, old);
36378   } else {
36379     *old = *real_packet;
36380   }
36381   RECEIVE_PACKET_END(real_packet);
36382 }
36383 
send_packet_server_setting_bitwise_100(struct connection * pc,const struct packet_server_setting_bitwise * packet)36384 static int send_packet_server_setting_bitwise_100(struct connection *pc, const struct packet_server_setting_bitwise *packet)
36385 {
36386   const struct packet_server_setting_bitwise *real_packet = packet;
36387   packet_server_setting_bitwise_100_fields fields;
36388   struct packet_server_setting_bitwise *old;
36389   bool differ;
36390   struct genhash **hash = pc->phs.sent + PACKET_SERVER_SETTING_BITWISE;
36391   int different = 0;
36392   SEND_PACKET_START(PACKET_SERVER_SETTING_BITWISE);
36393 
36394   log_packet_detailed("packet_server_setting_bitwise_100: sending info about (%d)",
36395     real_packet->id);
36396 
36397   if (NULL == *hash) {
36398     *hash = genhash_new_full(hash_packet_server_setting_bitwise_100, cmp_packet_server_setting_bitwise_100,
36399                              NULL, NULL, NULL, free);
36400   }
36401   BV_CLR_ALL(fields);
36402 
36403   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
36404     old = fc_malloc(sizeof(*old));
36405     *old = *real_packet;
36406     genhash_insert(*hash, old, old);
36407     memset(old, 0, sizeof(*old));
36408     different = 1;      /* Force to send. */
36409   }
36410 
36411   differ = (old->is_visible != real_packet->is_visible);
36412   if (differ) {
36413     different++;
36414   }
36415   if (packet->is_visible) {
36416     BV_SET(fields, 0);
36417   }
36418 
36419   differ = (old->is_changeable != real_packet->is_changeable);
36420   if (differ) {
36421     different++;
36422   }
36423   if (packet->is_changeable) {
36424     BV_SET(fields, 1);
36425   }
36426 
36427   differ = (old->initial_setting != real_packet->initial_setting);
36428   if (differ) {
36429     different++;
36430   }
36431   if (packet->initial_setting) {
36432     BV_SET(fields, 2);
36433   }
36434 
36435   differ = (old->val != real_packet->val);
36436   if (differ) {
36437     different++;
36438     BV_SET(fields, 3);
36439   }
36440 
36441   differ = (old->default_val != real_packet->default_val);
36442   if (differ) {
36443     different++;
36444     BV_SET(fields, 4);
36445   }
36446 
36447   differ = (old->bits_num != real_packet->bits_num);
36448   if (differ) {
36449     different++;
36450     BV_SET(fields, 5);
36451   }
36452 
36453 
36454     {
36455       differ = (old->bits_num != real_packet->bits_num);
36456       if (!differ) {
36457         int i;
36458 
36459         for (i = 0; i < real_packet->bits_num; i++) {
36460           if (strcmp(old->support_names[i], real_packet->support_names[i]) != 0) {
36461             differ = TRUE;
36462             break;
36463           }
36464         }
36465       }
36466     }
36467   if (differ) {
36468     different++;
36469     BV_SET(fields, 6);
36470   }
36471 
36472 
36473     {
36474       differ = (old->bits_num != real_packet->bits_num);
36475       if (!differ) {
36476         int i;
36477 
36478         for (i = 0; i < real_packet->bits_num; i++) {
36479           if (strcmp(old->pretty_names[i], real_packet->pretty_names[i]) != 0) {
36480             differ = TRUE;
36481             break;
36482           }
36483         }
36484       }
36485     }
36486   if (differ) {
36487     different++;
36488     BV_SET(fields, 7);
36489   }
36490 
36491 
36492   if (different == 0) {
36493     log_packet_detailed("  no change -> discard");
36494     return 0;
36495   }
36496 
36497   DIO_BV_PUT(&dout, "fields", fields);
36498   DIO_PUT(uint16, &dout, "id", real_packet->id);
36499 
36500   /* field 0 is folded into the header */
36501   /* field 1 is folded into the header */
36502   /* field 2 is folded into the header */
36503   if (BV_ISSET(fields, 3)) {
36504     log_packet_detailed("  field 'val' has changed");
36505     DIO_PUT(uint16, &dout, "val", real_packet->val);
36506   }
36507   if (BV_ISSET(fields, 4)) {
36508     log_packet_detailed("  field 'default_val' has changed");
36509     DIO_PUT(uint16, &dout, "default_val", real_packet->default_val);
36510   }
36511   if (BV_ISSET(fields, 5)) {
36512     log_packet_detailed("  field 'bits_num' has changed");
36513     DIO_PUT(uint8, &dout, "bits_num", real_packet->bits_num);
36514   }
36515   if (BV_ISSET(fields, 6)) {
36516     log_packet_detailed("  field 'support_names' has changed");
36517 
36518     {
36519       int i;
36520 
36521       for (i = 0; i < real_packet->bits_num; i++) {
36522         dio_put_string(&dout, real_packet->support_names[i]);
36523       }
36524     }
36525   }
36526   if (BV_ISSET(fields, 7)) {
36527     log_packet_detailed("  field 'pretty_names' has changed");
36528 
36529     {
36530       int i;
36531 
36532       for (i = 0; i < real_packet->bits_num; i++) {
36533         dio_put_string(&dout, real_packet->pretty_names[i]);
36534       }
36535     }
36536   }
36537 
36538   *old = *real_packet;
36539   SEND_PACKET_END(PACKET_SERVER_SETTING_BITWISE);
36540 }
36541 
send_packet_server_setting_bitwise(struct connection * pc,const struct packet_server_setting_bitwise * packet)36542 int send_packet_server_setting_bitwise(struct connection *pc, const struct packet_server_setting_bitwise *packet)
36543 {
36544   if (!pc->used) {
36545     log_error("WARNING: trying to send data to the closed connection %s",
36546               conn_description(pc));
36547     return -1;
36548   }
36549   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SERVER_SETTING_BITWISE].packet != NULL, -1,
36550                         "Handler for PACKET_SERVER_SETTING_BITWISE not installed");
36551   return pc->phs.handlers->send[PACKET_SERVER_SETTING_BITWISE].packet(pc, packet);
36552 }
36553 
36554 #define hash_packet_set_topology_100 hash_const
36555 
36556 #define cmp_packet_set_topology_100 cmp_const
36557 
36558 BV_DEFINE(packet_set_topology_100_fields, 1);
36559 
receive_packet_set_topology_100(struct connection * pc)36560 static struct packet_set_topology *receive_packet_set_topology_100(struct connection *pc)
36561 {
36562   packet_set_topology_100_fields fields;
36563   struct packet_set_topology *old;
36564   struct genhash **hash = pc->phs.received + PACKET_SET_TOPOLOGY;
36565   RECEIVE_PACKET_START(packet_set_topology, real_packet);
36566 
36567   DIO_BV_GET(&din, fields);
36568 
36569   log_packet_detailed("packet_set_topology_100: got info about ()");
36570 
36571   if (NULL == *hash) {
36572     *hash = genhash_new_full(hash_packet_set_topology_100, cmp_packet_set_topology_100,
36573                              NULL, NULL, NULL, free);
36574   }
36575 
36576   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
36577     *real_packet = *old;
36578   } else {
36579     log_packet_detailed("  no old info");
36580     memset(real_packet, 0, sizeof(*real_packet));
36581   }
36582 
36583   if (BV_ISSET(fields, 0)) {
36584     log_packet_detailed("  got field 'topology_id'");
36585     if (!DIO_GET(uint8, &din, "topology_id", &real_packet->topology_id)) {
36586       RECEIVE_PACKET_FIELD_ERROR(topology_id);
36587     }
36588   }
36589 
36590   if (NULL == old) {
36591     old = fc_malloc(sizeof(*old));
36592     *old = *real_packet;
36593     genhash_insert(*hash, old, old);
36594   } else {
36595     *old = *real_packet;
36596   }
36597   RECEIVE_PACKET_END(real_packet);
36598 }
36599 
send_packet_set_topology_100(struct connection * pc,const struct packet_set_topology * packet)36600 static int send_packet_set_topology_100(struct connection *pc, const struct packet_set_topology *packet)
36601 {
36602   const struct packet_set_topology *real_packet = packet;
36603   packet_set_topology_100_fields fields;
36604   struct packet_set_topology *old;
36605   bool differ;
36606   struct genhash **hash = pc->phs.sent + PACKET_SET_TOPOLOGY;
36607   int different = 0;
36608   SEND_PACKET_START(PACKET_SET_TOPOLOGY);
36609 
36610   log_packet_detailed("packet_set_topology_100: sending info about ()");
36611 
36612   if (NULL == *hash) {
36613     *hash = genhash_new_full(hash_packet_set_topology_100, cmp_packet_set_topology_100,
36614                              NULL, NULL, NULL, free);
36615   }
36616   BV_CLR_ALL(fields);
36617 
36618   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
36619     old = fc_malloc(sizeof(*old));
36620     *old = *real_packet;
36621     genhash_insert(*hash, old, old);
36622     memset(old, 0, sizeof(*old));
36623     different = 1;      /* Force to send. */
36624   }
36625 
36626   differ = (old->topology_id != real_packet->topology_id);
36627   if (differ) {
36628     different++;
36629     BV_SET(fields, 0);
36630   }
36631 
36632 
36633   DIO_BV_PUT(&dout, "fields", fields);
36634 
36635   if (BV_ISSET(fields, 0)) {
36636     log_packet_detailed("  field 'topology_id' has changed");
36637     DIO_PUT(uint8, &dout, "topology_id", real_packet->topology_id);
36638   }
36639 
36640   *old = *real_packet;
36641   SEND_PACKET_END(PACKET_SET_TOPOLOGY);
36642 }
36643 
send_packet_set_topology(struct connection * pc,const struct packet_set_topology * packet)36644 int send_packet_set_topology(struct connection *pc, const struct packet_set_topology *packet)
36645 {
36646   if (!pc->used) {
36647     log_error("WARNING: trying to send data to the closed connection %s",
36648               conn_description(pc));
36649     return -1;
36650   }
36651   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SET_TOPOLOGY].packet != NULL, -1,
36652                         "Handler for PACKET_SET_TOPOLOGY not installed");
36653   return pc->phs.handlers->send[PACKET_SET_TOPOLOGY].packet(pc, packet);
36654 }
36655 
36656 #define hash_packet_ruleset_effect_100 hash_const
36657 
36658 #define cmp_packet_ruleset_effect_100 cmp_const
36659 
36660 BV_DEFINE(packet_ruleset_effect_100_fields, 6);
36661 
receive_packet_ruleset_effect_100(struct connection * pc)36662 static struct packet_ruleset_effect *receive_packet_ruleset_effect_100(struct connection *pc)
36663 {
36664   packet_ruleset_effect_100_fields fields;
36665   struct packet_ruleset_effect *old;
36666   struct genhash **hash = pc->phs.received + PACKET_RULESET_EFFECT;
36667   RECEIVE_PACKET_START(packet_ruleset_effect, real_packet);
36668 
36669   DIO_BV_GET(&din, fields);
36670 
36671   log_packet_detailed("packet_ruleset_effect_100: got info about ()");
36672 
36673   if (NULL == *hash) {
36674     *hash = genhash_new_full(hash_packet_ruleset_effect_100, cmp_packet_ruleset_effect_100,
36675                              NULL, NULL, NULL, free);
36676   }
36677 
36678   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
36679     *real_packet = *old;
36680   } else {
36681     log_packet_detailed("  no old info");
36682     memset(real_packet, 0, sizeof(*real_packet));
36683   }
36684 
36685   if (BV_ISSET(fields, 0)) {
36686     log_packet_detailed("  got field 'effect_type'");
36687     {
36688       int readin;
36689 
36690       if (!DIO_GET(uint8, &din, "effect_type", &readin)) {
36691         RECEIVE_PACKET_FIELD_ERROR(effect_type);
36692       }
36693       real_packet->effect_type = readin;
36694     }
36695   }
36696   if (BV_ISSET(fields, 1)) {
36697     log_packet_detailed("  got field 'effect_value'");
36698     if (!DIO_GET(sint32, &din, "effect_value", &real_packet->effect_value)) {
36699       RECEIVE_PACKET_FIELD_ERROR(effect_value);
36700     }
36701   }
36702   real_packet->has_multiplier = BV_ISSET(fields, 2);
36703   if (BV_ISSET(fields, 3)) {
36704     log_packet_detailed("  got field 'multiplier'");
36705     {
36706       int readin;
36707 
36708       if (!DIO_GET(uint8, &din, "multiplier", &readin)) {
36709         RECEIVE_PACKET_FIELD_ERROR(multiplier);
36710       }
36711       real_packet->multiplier = readin;
36712     }
36713   }
36714   if (BV_ISSET(fields, 4)) {
36715     log_packet_detailed("  got field 'reqs_count'");
36716     if (!DIO_GET(uint8, &din, "reqs_count", &real_packet->reqs_count)) {
36717       RECEIVE_PACKET_FIELD_ERROR(reqs_count);
36718     }
36719   }
36720   if (BV_ISSET(fields, 5)) {
36721     log_packet_detailed("  got field 'reqs'");
36722 
36723     {
36724       int i;
36725 
36726       if (real_packet->reqs_count > MAX_NUM_REQS) {
36727         RECEIVE_PACKET_FIELD_ERROR(reqs, ": truncation array");
36728       }
36729       for (i = 0; i < real_packet->reqs_count; i++) {
36730         if (!DIO_GET(requirement, &din, "reqs", &real_packet->reqs[i])) {
36731           RECEIVE_PACKET_FIELD_ERROR(reqs);
36732         }
36733       }
36734     }
36735   }
36736 
36737   if (NULL == old) {
36738     old = fc_malloc(sizeof(*old));
36739     *old = *real_packet;
36740     genhash_insert(*hash, old, old);
36741   } else {
36742     *old = *real_packet;
36743   }
36744   RECEIVE_PACKET_END(real_packet);
36745 }
36746 
send_packet_ruleset_effect_100(struct connection * pc,const struct packet_ruleset_effect * packet)36747 static int send_packet_ruleset_effect_100(struct connection *pc, const struct packet_ruleset_effect *packet)
36748 {
36749   const struct packet_ruleset_effect *real_packet = packet;
36750   packet_ruleset_effect_100_fields fields;
36751   struct packet_ruleset_effect *old;
36752   bool differ;
36753   struct genhash **hash = pc->phs.sent + PACKET_RULESET_EFFECT;
36754   int different = 0;
36755   SEND_PACKET_START(PACKET_RULESET_EFFECT);
36756 
36757   log_packet_detailed("packet_ruleset_effect_100: sending info about ()");
36758 
36759   if (NULL == *hash) {
36760     *hash = genhash_new_full(hash_packet_ruleset_effect_100, cmp_packet_ruleset_effect_100,
36761                              NULL, NULL, NULL, free);
36762   }
36763   BV_CLR_ALL(fields);
36764 
36765   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
36766     old = fc_malloc(sizeof(*old));
36767     *old = *real_packet;
36768     genhash_insert(*hash, old, old);
36769     memset(old, 0, sizeof(*old));
36770     different = 1;      /* Force to send. */
36771   }
36772 
36773   differ = (old->effect_type != real_packet->effect_type);
36774   if (differ) {
36775     different++;
36776     BV_SET(fields, 0);
36777   }
36778 
36779   differ = (old->effect_value != real_packet->effect_value);
36780   if (differ) {
36781     different++;
36782     BV_SET(fields, 1);
36783   }
36784 
36785   differ = (old->has_multiplier != real_packet->has_multiplier);
36786   if (differ) {
36787     different++;
36788   }
36789   if (packet->has_multiplier) {
36790     BV_SET(fields, 2);
36791   }
36792 
36793   differ = (old->multiplier != real_packet->multiplier);
36794   if (differ) {
36795     different++;
36796     BV_SET(fields, 3);
36797   }
36798 
36799   differ = (old->reqs_count != real_packet->reqs_count);
36800   if (differ) {
36801     different++;
36802     BV_SET(fields, 4);
36803   }
36804 
36805 
36806     {
36807       differ = (old->reqs_count != real_packet->reqs_count);
36808       if (!differ) {
36809         int i;
36810 
36811         for (i = 0; i < real_packet->reqs_count; i++) {
36812           if (!are_requirements_equal(&old->reqs[i], &real_packet->reqs[i])) {
36813             differ = TRUE;
36814             break;
36815           }
36816         }
36817       }
36818     }
36819   if (differ) {
36820     different++;
36821     BV_SET(fields, 5);
36822   }
36823 
36824 
36825   DIO_BV_PUT(&dout, "fields", fields);
36826 
36827   if (BV_ISSET(fields, 0)) {
36828     log_packet_detailed("  field 'effect_type' has changed");
36829     DIO_PUT(uint8, &dout, "effect_type", real_packet->effect_type);
36830   }
36831   if (BV_ISSET(fields, 1)) {
36832     log_packet_detailed("  field 'effect_value' has changed");
36833     DIO_PUT(sint32, &dout, "effect_value", real_packet->effect_value);
36834   }
36835   /* field 2 is folded into the header */
36836   if (BV_ISSET(fields, 3)) {
36837     log_packet_detailed("  field 'multiplier' has changed");
36838     DIO_PUT(uint8, &dout, "multiplier", real_packet->multiplier);
36839   }
36840   if (BV_ISSET(fields, 4)) {
36841     log_packet_detailed("  field 'reqs_count' has changed");
36842     DIO_PUT(uint8, &dout, "reqs_count", real_packet->reqs_count);
36843   }
36844   if (BV_ISSET(fields, 5)) {
36845     log_packet_detailed("  field 'reqs' has changed");
36846 
36847     {
36848       int i;
36849 
36850       for (i = 0; i < real_packet->reqs_count; i++) {
36851         dio_put_requirement(&dout, &real_packet->reqs[i]);
36852       }
36853     }
36854   }
36855 
36856   *old = *real_packet;
36857   SEND_PACKET_END(PACKET_RULESET_EFFECT);
36858 }
36859 
send_packet_ruleset_effect(struct connection * pc,const struct packet_ruleset_effect * packet)36860 int send_packet_ruleset_effect(struct connection *pc, const struct packet_ruleset_effect *packet)
36861 {
36862   if (!pc->used) {
36863     log_error("WARNING: trying to send data to the closed connection %s",
36864               conn_description(pc));
36865     return -1;
36866   }
36867   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_EFFECT].packet != NULL, -1,
36868                         "Handler for PACKET_RULESET_EFFECT not installed");
36869   return pc->phs.handlers->send[PACKET_RULESET_EFFECT].packet(pc, packet);
36870 }
36871 
lsend_packet_ruleset_effect(struct conn_list * dest,const struct packet_ruleset_effect * packet)36872 void lsend_packet_ruleset_effect(struct conn_list *dest, const struct packet_ruleset_effect *packet)
36873 {
36874   conn_list_iterate(dest, pconn) {
36875     send_packet_ruleset_effect(pconn, packet);
36876   } conn_list_iterate_end;
36877 }
36878 
36879 #define hash_packet_ruleset_resource_100 hash_const
36880 
36881 #define cmp_packet_ruleset_resource_100 cmp_const
36882 
36883 BV_DEFINE(packet_ruleset_resource_100_fields, 6);
36884 
receive_packet_ruleset_resource_100(struct connection * pc)36885 static struct packet_ruleset_resource *receive_packet_ruleset_resource_100(struct connection *pc)
36886 {
36887   packet_ruleset_resource_100_fields fields;
36888   struct packet_ruleset_resource *old;
36889   struct genhash **hash = pc->phs.received + PACKET_RULESET_RESOURCE;
36890   RECEIVE_PACKET_START(packet_ruleset_resource, real_packet);
36891 
36892   DIO_BV_GET(&din, fields);
36893 
36894   log_packet_detailed("packet_ruleset_resource_100: got info about ()");
36895 
36896   if (NULL == *hash) {
36897     *hash = genhash_new_full(hash_packet_ruleset_resource_100, cmp_packet_ruleset_resource_100,
36898                              NULL, NULL, NULL, free);
36899   }
36900 
36901   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
36902     *real_packet = *old;
36903   } else {
36904     log_packet_detailed("  no old info");
36905     memset(real_packet, 0, sizeof(*real_packet));
36906   }
36907 
36908   if (BV_ISSET(fields, 0)) {
36909     log_packet_detailed("  got field 'id'");
36910     {
36911       int readin;
36912 
36913       if (!DIO_GET(uint8, &din, "id", &readin)) {
36914         RECEIVE_PACKET_FIELD_ERROR(id);
36915       }
36916       real_packet->id = readin;
36917     }
36918   }
36919   if (BV_ISSET(fields, 1)) {
36920     log_packet_detailed("  got field 'name'");
36921     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
36922       RECEIVE_PACKET_FIELD_ERROR(name);
36923     }
36924   }
36925   if (BV_ISSET(fields, 2)) {
36926     log_packet_detailed("  got field 'rule_name'");
36927     if (!DIO_GET(string, &din, "rule_name", real_packet->rule_name, sizeof(real_packet->rule_name))) {
36928       RECEIVE_PACKET_FIELD_ERROR(rule_name);
36929     }
36930   }
36931   if (BV_ISSET(fields, 3)) {
36932     log_packet_detailed("  got field 'output'");
36933 
36934     {
36935       int i;
36936 
36937       for (i = 0; i < O_LAST; i++) {
36938         if (!DIO_GET(uint8, &din, "output", &real_packet->output[i])) {
36939           RECEIVE_PACKET_FIELD_ERROR(output);
36940         }
36941       }
36942     }
36943   }
36944   if (BV_ISSET(fields, 4)) {
36945     log_packet_detailed("  got field 'graphic_str'");
36946     if (!DIO_GET(string, &din, "graphic_str", real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
36947       RECEIVE_PACKET_FIELD_ERROR(graphic_str);
36948     }
36949   }
36950   if (BV_ISSET(fields, 5)) {
36951     log_packet_detailed("  got field 'graphic_alt'");
36952     if (!DIO_GET(string, &din, "graphic_alt", real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
36953       RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
36954     }
36955   }
36956 
36957   if (NULL == old) {
36958     old = fc_malloc(sizeof(*old));
36959     *old = *real_packet;
36960     genhash_insert(*hash, old, old);
36961   } else {
36962     *old = *real_packet;
36963   }
36964   RECEIVE_PACKET_END(real_packet);
36965 }
36966 
send_packet_ruleset_resource_100(struct connection * pc,const struct packet_ruleset_resource * packet)36967 static int send_packet_ruleset_resource_100(struct connection *pc, const struct packet_ruleset_resource *packet)
36968 {
36969   const struct packet_ruleset_resource *real_packet = packet;
36970   packet_ruleset_resource_100_fields fields;
36971   struct packet_ruleset_resource *old;
36972   bool differ;
36973   struct genhash **hash = pc->phs.sent + PACKET_RULESET_RESOURCE;
36974   int different = 0;
36975   SEND_PACKET_START(PACKET_RULESET_RESOURCE);
36976 
36977   log_packet_detailed("packet_ruleset_resource_100: sending info about ()");
36978 
36979   if (NULL == *hash) {
36980     *hash = genhash_new_full(hash_packet_ruleset_resource_100, cmp_packet_ruleset_resource_100,
36981                              NULL, NULL, NULL, free);
36982   }
36983   BV_CLR_ALL(fields);
36984 
36985   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
36986     old = fc_malloc(sizeof(*old));
36987     *old = *real_packet;
36988     genhash_insert(*hash, old, old);
36989     memset(old, 0, sizeof(*old));
36990     different = 1;      /* Force to send. */
36991   }
36992 
36993   differ = (old->id != real_packet->id);
36994   if (differ) {
36995     different++;
36996     BV_SET(fields, 0);
36997   }
36998 
36999   differ = (strcmp(old->name, real_packet->name) != 0);
37000   if (differ) {
37001     different++;
37002     BV_SET(fields, 1);
37003   }
37004 
37005   differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
37006   if (differ) {
37007     different++;
37008     BV_SET(fields, 2);
37009   }
37010 
37011 
37012     {
37013       differ = (O_LAST != O_LAST);
37014       if (!differ) {
37015         int i;
37016 
37017         for (i = 0; i < O_LAST; i++) {
37018           if (old->output[i] != real_packet->output[i]) {
37019             differ = TRUE;
37020             break;
37021           }
37022         }
37023       }
37024     }
37025   if (differ) {
37026     different++;
37027     BV_SET(fields, 3);
37028   }
37029 
37030   differ = (strcmp(old->graphic_str, real_packet->graphic_str) != 0);
37031   if (differ) {
37032     different++;
37033     BV_SET(fields, 4);
37034   }
37035 
37036   differ = (strcmp(old->graphic_alt, real_packet->graphic_alt) != 0);
37037   if (differ) {
37038     different++;
37039     BV_SET(fields, 5);
37040   }
37041 
37042 
37043   DIO_BV_PUT(&dout, "fields", fields);
37044 
37045   if (BV_ISSET(fields, 0)) {
37046     log_packet_detailed("  field 'id' has changed");
37047     DIO_PUT(uint8, &dout, "id", real_packet->id);
37048   }
37049   if (BV_ISSET(fields, 1)) {
37050     log_packet_detailed("  field 'name' has changed");
37051     DIO_PUT(string, &dout, "name", real_packet->name);
37052   }
37053   if (BV_ISSET(fields, 2)) {
37054     log_packet_detailed("  field 'rule_name' has changed");
37055     DIO_PUT(string, &dout, "rule_name", real_packet->rule_name);
37056   }
37057   if (BV_ISSET(fields, 3)) {
37058     log_packet_detailed("  field 'output' has changed");
37059 
37060     {
37061       int i;
37062 
37063       for (i = 0; i < O_LAST; i++) {
37064         dio_put_uint8(&dout, real_packet->output[i]);
37065       }
37066     }
37067   }
37068   if (BV_ISSET(fields, 4)) {
37069     log_packet_detailed("  field 'graphic_str' has changed");
37070     DIO_PUT(string, &dout, "graphic_str", real_packet->graphic_str);
37071   }
37072   if (BV_ISSET(fields, 5)) {
37073     log_packet_detailed("  field 'graphic_alt' has changed");
37074     DIO_PUT(string, &dout, "graphic_alt", real_packet->graphic_alt);
37075   }
37076 
37077   *old = *real_packet;
37078   SEND_PACKET_END(PACKET_RULESET_RESOURCE);
37079 }
37080 
send_packet_ruleset_resource(struct connection * pc,const struct packet_ruleset_resource * packet)37081 int send_packet_ruleset_resource(struct connection *pc, const struct packet_ruleset_resource *packet)
37082 {
37083   if (!pc->used) {
37084     log_error("WARNING: trying to send data to the closed connection %s",
37085               conn_description(pc));
37086     return -1;
37087   }
37088   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_RESOURCE].packet != NULL, -1,
37089                         "Handler for PACKET_RULESET_RESOURCE not installed");
37090   return pc->phs.handlers->send[PACKET_RULESET_RESOURCE].packet(pc, packet);
37091 }
37092 
lsend_packet_ruleset_resource(struct conn_list * dest,const struct packet_ruleset_resource * packet)37093 void lsend_packet_ruleset_resource(struct conn_list *dest, const struct packet_ruleset_resource *packet)
37094 {
37095   conn_list_iterate(dest, pconn) {
37096     send_packet_ruleset_resource(pconn, packet);
37097   } conn_list_iterate_end;
37098 }
37099 
37100 #define hash_packet_scenario_info_100 hash_const
37101 
37102 #define cmp_packet_scenario_info_100 cmp_const
37103 
37104 BV_DEFINE(packet_scenario_info_100_fields, 11);
37105 
receive_packet_scenario_info_100(struct connection * pc)37106 static struct packet_scenario_info *receive_packet_scenario_info_100(struct connection *pc)
37107 {
37108   packet_scenario_info_100_fields fields;
37109   struct packet_scenario_info *old;
37110   struct genhash **hash = pc->phs.received + PACKET_SCENARIO_INFO;
37111   RECEIVE_PACKET_START(packet_scenario_info, real_packet);
37112 
37113   DIO_BV_GET(&din, fields);
37114 
37115   log_packet_detailed("packet_scenario_info_100: got info about ()");
37116 
37117   if (NULL == *hash) {
37118     *hash = genhash_new_full(hash_packet_scenario_info_100, cmp_packet_scenario_info_100,
37119                              NULL, NULL, NULL, free);
37120   }
37121 
37122   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
37123     *real_packet = *old;
37124   } else {
37125     log_packet_detailed("  no old info");
37126     memset(real_packet, 0, sizeof(*real_packet));
37127   }
37128 
37129   real_packet->is_scenario = BV_ISSET(fields, 0);
37130   if (BV_ISSET(fields, 1)) {
37131     log_packet_detailed("  got field 'name'");
37132     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
37133       RECEIVE_PACKET_FIELD_ERROR(name);
37134     }
37135   }
37136   if (BV_ISSET(fields, 2)) {
37137     log_packet_detailed("  got field 'authors'");
37138     if (!DIO_GET(string, &din, "authors", real_packet->authors, sizeof(real_packet->authors))) {
37139       RECEIVE_PACKET_FIELD_ERROR(authors);
37140     }
37141   }
37142   real_packet->players = BV_ISSET(fields, 3);
37143   real_packet->startpos_nations = BV_ISSET(fields, 4);
37144   real_packet->save_random = BV_ISSET(fields, 5);
37145   real_packet->prevent_new_cities = BV_ISSET(fields, 6);
37146   real_packet->lake_flooding = BV_ISSET(fields, 7);
37147   real_packet->handmade = BV_ISSET(fields, 8);
37148   real_packet->allow_ai_type_fallback = BV_ISSET(fields, 9);
37149   real_packet->have_resources = BV_ISSET(fields, 10);
37150 
37151   if (NULL == old) {
37152     old = fc_malloc(sizeof(*old));
37153     *old = *real_packet;
37154     genhash_insert(*hash, old, old);
37155   } else {
37156     *old = *real_packet;
37157   }
37158   RECEIVE_PACKET_END(real_packet);
37159 }
37160 
send_packet_scenario_info_100(struct connection * pc,const struct packet_scenario_info * packet)37161 static int send_packet_scenario_info_100(struct connection *pc, const struct packet_scenario_info *packet)
37162 {
37163   const struct packet_scenario_info *real_packet = packet;
37164   packet_scenario_info_100_fields fields;
37165   struct packet_scenario_info *old;
37166   bool differ;
37167   struct genhash **hash = pc->phs.sent + PACKET_SCENARIO_INFO;
37168   int different = 0;
37169   SEND_PACKET_START(PACKET_SCENARIO_INFO);
37170 
37171   log_packet_detailed("packet_scenario_info_100: sending info about ()");
37172 
37173   if (NULL == *hash) {
37174     *hash = genhash_new_full(hash_packet_scenario_info_100, cmp_packet_scenario_info_100,
37175                              NULL, NULL, NULL, free);
37176   }
37177   BV_CLR_ALL(fields);
37178 
37179   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
37180     old = fc_malloc(sizeof(*old));
37181     *old = *real_packet;
37182     genhash_insert(*hash, old, old);
37183     memset(old, 0, sizeof(*old));
37184     different = 1;      /* Force to send. */
37185   }
37186 
37187   differ = (old->is_scenario != real_packet->is_scenario);
37188   if (differ) {
37189     different++;
37190   }
37191   if (packet->is_scenario) {
37192     BV_SET(fields, 0);
37193   }
37194 
37195   differ = (strcmp(old->name, real_packet->name) != 0);
37196   if (differ) {
37197     different++;
37198     BV_SET(fields, 1);
37199   }
37200 
37201   differ = (strcmp(old->authors, real_packet->authors) != 0);
37202   if (differ) {
37203     different++;
37204     BV_SET(fields, 2);
37205   }
37206 
37207   differ = (old->players != real_packet->players);
37208   if (differ) {
37209     different++;
37210   }
37211   if (packet->players) {
37212     BV_SET(fields, 3);
37213   }
37214 
37215   differ = (old->startpos_nations != real_packet->startpos_nations);
37216   if (differ) {
37217     different++;
37218   }
37219   if (packet->startpos_nations) {
37220     BV_SET(fields, 4);
37221   }
37222 
37223   differ = (old->save_random != real_packet->save_random);
37224   if (differ) {
37225     different++;
37226   }
37227   if (packet->save_random) {
37228     BV_SET(fields, 5);
37229   }
37230 
37231   differ = (old->prevent_new_cities != real_packet->prevent_new_cities);
37232   if (differ) {
37233     different++;
37234   }
37235   if (packet->prevent_new_cities) {
37236     BV_SET(fields, 6);
37237   }
37238 
37239   differ = (old->lake_flooding != real_packet->lake_flooding);
37240   if (differ) {
37241     different++;
37242   }
37243   if (packet->lake_flooding) {
37244     BV_SET(fields, 7);
37245   }
37246 
37247   differ = (old->handmade != real_packet->handmade);
37248   if (differ) {
37249     different++;
37250   }
37251   if (packet->handmade) {
37252     BV_SET(fields, 8);
37253   }
37254 
37255   differ = (old->allow_ai_type_fallback != real_packet->allow_ai_type_fallback);
37256   if (differ) {
37257     different++;
37258   }
37259   if (packet->allow_ai_type_fallback) {
37260     BV_SET(fields, 9);
37261   }
37262 
37263   differ = (old->have_resources != real_packet->have_resources);
37264   if (differ) {
37265     different++;
37266   }
37267   if (packet->have_resources) {
37268     BV_SET(fields, 10);
37269   }
37270 
37271 
37272   DIO_BV_PUT(&dout, "fields", fields);
37273 
37274   /* field 0 is folded into the header */
37275   if (BV_ISSET(fields, 1)) {
37276     log_packet_detailed("  field 'name' has changed");
37277     DIO_PUT(string, &dout, "name", real_packet->name);
37278   }
37279   if (BV_ISSET(fields, 2)) {
37280     log_packet_detailed("  field 'authors' has changed");
37281     DIO_PUT(string, &dout, "authors", real_packet->authors);
37282   }
37283   /* field 3 is folded into the header */
37284   /* field 4 is folded into the header */
37285   /* field 5 is folded into the header */
37286   /* field 6 is folded into the header */
37287   /* field 7 is folded into the header */
37288   /* field 8 is folded into the header */
37289   /* field 9 is folded into the header */
37290   /* field 10 is folded into the header */
37291 
37292   *old = *real_packet;
37293   SEND_PACKET_END(PACKET_SCENARIO_INFO);
37294 }
37295 
send_packet_scenario_info(struct connection * pc,const struct packet_scenario_info * packet)37296 int send_packet_scenario_info(struct connection *pc, const struct packet_scenario_info *packet)
37297 {
37298   if (!pc->used) {
37299     log_error("WARNING: trying to send data to the closed connection %s",
37300               conn_description(pc));
37301     return -1;
37302   }
37303   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SCENARIO_INFO].packet != NULL, -1,
37304                         "Handler for PACKET_SCENARIO_INFO not installed");
37305   return pc->phs.handlers->send[PACKET_SCENARIO_INFO].packet(pc, packet);
37306 }
37307 
37308 #define hash_packet_scenario_description_100 hash_const
37309 
37310 #define cmp_packet_scenario_description_100 cmp_const
37311 
37312 BV_DEFINE(packet_scenario_description_100_fields, 1);
37313 
receive_packet_scenario_description_100(struct connection * pc)37314 static struct packet_scenario_description *receive_packet_scenario_description_100(struct connection *pc)
37315 {
37316   packet_scenario_description_100_fields fields;
37317   struct packet_scenario_description *old;
37318   struct genhash **hash = pc->phs.received + PACKET_SCENARIO_DESCRIPTION;
37319   RECEIVE_PACKET_START(packet_scenario_description, real_packet);
37320 
37321   DIO_BV_GET(&din, fields);
37322 
37323   log_packet_detailed("packet_scenario_description_100: got info about ()");
37324 
37325   if (NULL == *hash) {
37326     *hash = genhash_new_full(hash_packet_scenario_description_100, cmp_packet_scenario_description_100,
37327                              NULL, NULL, NULL, free);
37328   }
37329 
37330   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
37331     *real_packet = *old;
37332   } else {
37333     log_packet_detailed("  no old info");
37334     memset(real_packet, 0, sizeof(*real_packet));
37335   }
37336 
37337   if (BV_ISSET(fields, 0)) {
37338     log_packet_detailed("  got field 'description'");
37339     if (!DIO_GET(string, &din, "description", real_packet->description, sizeof(real_packet->description))) {
37340       RECEIVE_PACKET_FIELD_ERROR(description);
37341     }
37342   }
37343 
37344   if (NULL == old) {
37345     old = fc_malloc(sizeof(*old));
37346     *old = *real_packet;
37347     genhash_insert(*hash, old, old);
37348   } else {
37349     *old = *real_packet;
37350   }
37351   RECEIVE_PACKET_END(real_packet);
37352 }
37353 
send_packet_scenario_description_100(struct connection * pc,const struct packet_scenario_description * packet)37354 static int send_packet_scenario_description_100(struct connection *pc, const struct packet_scenario_description *packet)
37355 {
37356   const struct packet_scenario_description *real_packet = packet;
37357   packet_scenario_description_100_fields fields;
37358   struct packet_scenario_description *old;
37359   bool differ;
37360   struct genhash **hash = pc->phs.sent + PACKET_SCENARIO_DESCRIPTION;
37361   int different = 0;
37362   SEND_PACKET_START(PACKET_SCENARIO_DESCRIPTION);
37363 
37364   log_packet_detailed("packet_scenario_description_100: sending info about ()");
37365 
37366   if (NULL == *hash) {
37367     *hash = genhash_new_full(hash_packet_scenario_description_100, cmp_packet_scenario_description_100,
37368                              NULL, NULL, NULL, free);
37369   }
37370   BV_CLR_ALL(fields);
37371 
37372   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
37373     old = fc_malloc(sizeof(*old));
37374     *old = *real_packet;
37375     genhash_insert(*hash, old, old);
37376     memset(old, 0, sizeof(*old));
37377     different = 1;      /* Force to send. */
37378   }
37379 
37380   differ = (strcmp(old->description, real_packet->description) != 0);
37381   if (differ) {
37382     different++;
37383     BV_SET(fields, 0);
37384   }
37385 
37386 
37387   DIO_BV_PUT(&dout, "fields", fields);
37388 
37389   if (BV_ISSET(fields, 0)) {
37390     log_packet_detailed("  field 'description' has changed");
37391     DIO_PUT(string, &dout, "description", real_packet->description);
37392   }
37393 
37394   *old = *real_packet;
37395   SEND_PACKET_END(PACKET_SCENARIO_DESCRIPTION);
37396 }
37397 
send_packet_scenario_description(struct connection * pc,const struct packet_scenario_description * packet)37398 int send_packet_scenario_description(struct connection *pc, const struct packet_scenario_description *packet)
37399 {
37400   if (!pc->used) {
37401     log_error("WARNING: trying to send data to the closed connection %s",
37402               conn_description(pc));
37403     return -1;
37404   }
37405   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SCENARIO_DESCRIPTION].packet != NULL, -1,
37406                         "Handler for PACKET_SCENARIO_DESCRIPTION not installed");
37407   return pc->phs.handlers->send[PACKET_SCENARIO_DESCRIPTION].packet(pc, packet);
37408 }
37409 
37410 #define hash_packet_save_scenario_100 hash_const
37411 
37412 #define cmp_packet_save_scenario_100 cmp_const
37413 
37414 BV_DEFINE(packet_save_scenario_100_fields, 1);
37415 
receive_packet_save_scenario_100(struct connection * pc)37416 static struct packet_save_scenario *receive_packet_save_scenario_100(struct connection *pc)
37417 {
37418   packet_save_scenario_100_fields fields;
37419   struct packet_save_scenario *old;
37420   struct genhash **hash = pc->phs.received + PACKET_SAVE_SCENARIO;
37421   RECEIVE_PACKET_START(packet_save_scenario, real_packet);
37422 
37423   DIO_BV_GET(&din, fields);
37424 
37425   log_packet_detailed("packet_save_scenario_100: got info about ()");
37426 
37427   if (NULL == *hash) {
37428     *hash = genhash_new_full(hash_packet_save_scenario_100, cmp_packet_save_scenario_100,
37429                              NULL, NULL, NULL, free);
37430   }
37431 
37432   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
37433     *real_packet = *old;
37434   } else {
37435     log_packet_detailed("  no old info");
37436     memset(real_packet, 0, sizeof(*real_packet));
37437   }
37438 
37439   if (BV_ISSET(fields, 0)) {
37440     log_packet_detailed("  got field 'name'");
37441     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
37442       RECEIVE_PACKET_FIELD_ERROR(name);
37443     }
37444   }
37445 
37446   if (NULL == old) {
37447     old = fc_malloc(sizeof(*old));
37448     *old = *real_packet;
37449     genhash_insert(*hash, old, old);
37450   } else {
37451     *old = *real_packet;
37452   }
37453   RECEIVE_PACKET_END(real_packet);
37454 }
37455 
send_packet_save_scenario_100(struct connection * pc,const struct packet_save_scenario * packet)37456 static int send_packet_save_scenario_100(struct connection *pc, const struct packet_save_scenario *packet)
37457 {
37458   const struct packet_save_scenario *real_packet = packet;
37459   packet_save_scenario_100_fields fields;
37460   struct packet_save_scenario *old;
37461   bool differ;
37462   struct genhash **hash = pc->phs.sent + PACKET_SAVE_SCENARIO;
37463   int different = 0;
37464   SEND_PACKET_START(PACKET_SAVE_SCENARIO);
37465 
37466   log_packet_detailed("packet_save_scenario_100: sending info about ()");
37467 
37468   if (NULL == *hash) {
37469     *hash = genhash_new_full(hash_packet_save_scenario_100, cmp_packet_save_scenario_100,
37470                              NULL, NULL, NULL, free);
37471   }
37472   BV_CLR_ALL(fields);
37473 
37474   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
37475     old = fc_malloc(sizeof(*old));
37476     *old = *real_packet;
37477     genhash_insert(*hash, old, old);
37478     memset(old, 0, sizeof(*old));
37479     different = 1;      /* Force to send. */
37480   }
37481 
37482   differ = (strcmp(old->name, real_packet->name) != 0);
37483   if (differ) {
37484     different++;
37485     BV_SET(fields, 0);
37486   }
37487 
37488 
37489   DIO_BV_PUT(&dout, "fields", fields);
37490 
37491   if (BV_ISSET(fields, 0)) {
37492     log_packet_detailed("  field 'name' has changed");
37493     DIO_PUT(string, &dout, "name", real_packet->name);
37494   }
37495 
37496   *old = *real_packet;
37497   SEND_PACKET_END(PACKET_SAVE_SCENARIO);
37498 }
37499 
send_packet_save_scenario(struct connection * pc,const struct packet_save_scenario * packet)37500 int send_packet_save_scenario(struct connection *pc, const struct packet_save_scenario *packet)
37501 {
37502   if (!pc->used) {
37503     log_error("WARNING: trying to send data to the closed connection %s",
37504               conn_description(pc));
37505     return -1;
37506   }
37507   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SAVE_SCENARIO].packet != NULL, -1,
37508                         "Handler for PACKET_SAVE_SCENARIO not installed");
37509   return pc->phs.handlers->send[PACKET_SAVE_SCENARIO].packet(pc, packet);
37510 }
37511 
dsend_packet_save_scenario(struct connection * pc,const char * name)37512 int dsend_packet_save_scenario(struct connection *pc, const char *name)
37513 {
37514   struct packet_save_scenario packet, *real_packet = &packet;
37515 
37516   sz_strlcpy(real_packet->name, name);
37517 
37518   return send_packet_save_scenario(pc, real_packet);
37519 }
37520 
37521 #define hash_packet_vote_new_100 hash_const
37522 
37523 #define cmp_packet_vote_new_100 cmp_const
37524 
37525 BV_DEFINE(packet_vote_new_100_fields, 5);
37526 
receive_packet_vote_new_100(struct connection * pc)37527 static struct packet_vote_new *receive_packet_vote_new_100(struct connection *pc)
37528 {
37529   packet_vote_new_100_fields fields;
37530   struct packet_vote_new *old;
37531   struct genhash **hash = pc->phs.received + PACKET_VOTE_NEW;
37532   RECEIVE_PACKET_START(packet_vote_new, real_packet);
37533 
37534   DIO_BV_GET(&din, fields);
37535 
37536   log_packet_detailed("packet_vote_new_100: got info about ()");
37537 
37538   if (NULL == *hash) {
37539     *hash = genhash_new_full(hash_packet_vote_new_100, cmp_packet_vote_new_100,
37540                              NULL, NULL, NULL, free);
37541   }
37542 
37543   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
37544     *real_packet = *old;
37545   } else {
37546     log_packet_detailed("  no old info");
37547     memset(real_packet, 0, sizeof(*real_packet));
37548   }
37549 
37550   if (BV_ISSET(fields, 0)) {
37551     log_packet_detailed("  got field 'vote_no'");
37552     if (!DIO_GET(uint32, &din, "vote_no", &real_packet->vote_no)) {
37553       RECEIVE_PACKET_FIELD_ERROR(vote_no);
37554     }
37555   }
37556   if (BV_ISSET(fields, 1)) {
37557     log_packet_detailed("  got field 'user'");
37558     if (!DIO_GET(string, &din, "user", real_packet->user, sizeof(real_packet->user))) {
37559       RECEIVE_PACKET_FIELD_ERROR(user);
37560     }
37561   }
37562   if (BV_ISSET(fields, 2)) {
37563     log_packet_detailed("  got field 'desc'");
37564     if (!DIO_GET(string, &din, "desc", real_packet->desc, sizeof(real_packet->desc))) {
37565       RECEIVE_PACKET_FIELD_ERROR(desc);
37566     }
37567   }
37568   if (BV_ISSET(fields, 3)) {
37569     log_packet_detailed("  got field 'percent_required'");
37570     if (!DIO_GET(uint8, &din, "percent_required", &real_packet->percent_required)) {
37571       RECEIVE_PACKET_FIELD_ERROR(percent_required);
37572     }
37573   }
37574   if (BV_ISSET(fields, 4)) {
37575     log_packet_detailed("  got field 'flags'");
37576     if (!DIO_GET(uint32, &din, "flags", &real_packet->flags)) {
37577       RECEIVE_PACKET_FIELD_ERROR(flags);
37578     }
37579   }
37580 
37581   if (NULL == old) {
37582     old = fc_malloc(sizeof(*old));
37583     *old = *real_packet;
37584     genhash_insert(*hash, old, old);
37585   } else {
37586     *old = *real_packet;
37587   }
37588   RECEIVE_PACKET_END(real_packet);
37589 }
37590 
send_packet_vote_new_100(struct connection * pc,const struct packet_vote_new * packet)37591 static int send_packet_vote_new_100(struct connection *pc, const struct packet_vote_new *packet)
37592 {
37593   const struct packet_vote_new *real_packet = packet;
37594   packet_vote_new_100_fields fields;
37595   struct packet_vote_new *old;
37596   bool differ;
37597   struct genhash **hash = pc->phs.sent + PACKET_VOTE_NEW;
37598   int different = 0;
37599   SEND_PACKET_START(PACKET_VOTE_NEW);
37600 
37601   log_packet_detailed("packet_vote_new_100: sending info about ()");
37602 
37603   if (NULL == *hash) {
37604     *hash = genhash_new_full(hash_packet_vote_new_100, cmp_packet_vote_new_100,
37605                              NULL, NULL, NULL, free);
37606   }
37607   BV_CLR_ALL(fields);
37608 
37609   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
37610     old = fc_malloc(sizeof(*old));
37611     *old = *real_packet;
37612     genhash_insert(*hash, old, old);
37613     memset(old, 0, sizeof(*old));
37614     different = 1;      /* Force to send. */
37615   }
37616 
37617   differ = (old->vote_no != real_packet->vote_no);
37618   if (differ) {
37619     different++;
37620     BV_SET(fields, 0);
37621   }
37622 
37623   differ = (strcmp(old->user, real_packet->user) != 0);
37624   if (differ) {
37625     different++;
37626     BV_SET(fields, 1);
37627   }
37628 
37629   differ = (strcmp(old->desc, real_packet->desc) != 0);
37630   if (differ) {
37631     different++;
37632     BV_SET(fields, 2);
37633   }
37634 
37635   differ = (old->percent_required != real_packet->percent_required);
37636   if (differ) {
37637     different++;
37638     BV_SET(fields, 3);
37639   }
37640 
37641   differ = (old->flags != real_packet->flags);
37642   if (differ) {
37643     different++;
37644     BV_SET(fields, 4);
37645   }
37646 
37647 
37648   DIO_BV_PUT(&dout, "fields", fields);
37649 
37650   if (BV_ISSET(fields, 0)) {
37651     log_packet_detailed("  field 'vote_no' has changed");
37652     DIO_PUT(uint32, &dout, "vote_no", real_packet->vote_no);
37653   }
37654   if (BV_ISSET(fields, 1)) {
37655     log_packet_detailed("  field 'user' has changed");
37656     DIO_PUT(string, &dout, "user", real_packet->user);
37657   }
37658   if (BV_ISSET(fields, 2)) {
37659     log_packet_detailed("  field 'desc' has changed");
37660     DIO_PUT(string, &dout, "desc", real_packet->desc);
37661   }
37662   if (BV_ISSET(fields, 3)) {
37663     log_packet_detailed("  field 'percent_required' has changed");
37664     DIO_PUT(uint8, &dout, "percent_required", real_packet->percent_required);
37665   }
37666   if (BV_ISSET(fields, 4)) {
37667     log_packet_detailed("  field 'flags' has changed");
37668     DIO_PUT(uint32, &dout, "flags", real_packet->flags);
37669   }
37670 
37671   *old = *real_packet;
37672   SEND_PACKET_END(PACKET_VOTE_NEW);
37673 }
37674 
send_packet_vote_new(struct connection * pc,const struct packet_vote_new * packet)37675 int send_packet_vote_new(struct connection *pc, const struct packet_vote_new *packet)
37676 {
37677   if (!pc->used) {
37678     log_error("WARNING: trying to send data to the closed connection %s",
37679               conn_description(pc));
37680     return -1;
37681   }
37682   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_VOTE_NEW].packet != NULL, -1,
37683                         "Handler for PACKET_VOTE_NEW not installed");
37684   return pc->phs.handlers->send[PACKET_VOTE_NEW].packet(pc, packet);
37685 }
37686 
hash_packet_vote_update_100(const void * vkey)37687 static genhash_val_t hash_packet_vote_update_100(const void *vkey)
37688 {
37689   const struct packet_vote_update *key = (const struct packet_vote_update *) vkey;
37690 
37691   return key->vote_no;
37692 }
37693 
cmp_packet_vote_update_100(const void * vkey1,const void * vkey2)37694 static bool cmp_packet_vote_update_100(const void *vkey1, const void *vkey2)
37695 {
37696   const struct packet_vote_update *key1 = (const struct packet_vote_update *) vkey1;
37697   const struct packet_vote_update *key2 = (const struct packet_vote_update *) vkey2;
37698 
37699   return key1->vote_no == key2->vote_no;
37700 }
37701 
37702 BV_DEFINE(packet_vote_update_100_fields, 4);
37703 
receive_packet_vote_update_100(struct connection * pc)37704 static struct packet_vote_update *receive_packet_vote_update_100(struct connection *pc)
37705 {
37706   packet_vote_update_100_fields fields;
37707   struct packet_vote_update *old;
37708   struct genhash **hash = pc->phs.received + PACKET_VOTE_UPDATE;
37709   RECEIVE_PACKET_START(packet_vote_update, real_packet);
37710 
37711   DIO_BV_GET(&din, fields);
37712   if (!DIO_GET(uint32, &din, "vote_no", &real_packet->vote_no)) {
37713     RECEIVE_PACKET_FIELD_ERROR(vote_no);
37714   }
37715 
37716   log_packet_detailed("packet_vote_update_100: got info about (%d)",
37717     real_packet->vote_no);
37718 
37719   if (NULL == *hash) {
37720     *hash = genhash_new_full(hash_packet_vote_update_100, cmp_packet_vote_update_100,
37721                              NULL, NULL, NULL, free);
37722   }
37723 
37724   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
37725     *real_packet = *old;
37726   } else {
37727     int vote_no = real_packet->vote_no;
37728 
37729     log_packet_detailed("  no old info");
37730     memset(real_packet, 0, sizeof(*real_packet));
37731 
37732     real_packet->vote_no = vote_no;
37733   }
37734 
37735   if (BV_ISSET(fields, 0)) {
37736     log_packet_detailed("  got field 'yes'");
37737     if (!DIO_GET(uint8, &din, "yes", &real_packet->yes)) {
37738       RECEIVE_PACKET_FIELD_ERROR(yes);
37739     }
37740   }
37741   if (BV_ISSET(fields, 1)) {
37742     log_packet_detailed("  got field 'no'");
37743     if (!DIO_GET(uint8, &din, "no", &real_packet->no)) {
37744       RECEIVE_PACKET_FIELD_ERROR(no);
37745     }
37746   }
37747   if (BV_ISSET(fields, 2)) {
37748     log_packet_detailed("  got field 'abstain'");
37749     if (!DIO_GET(uint8, &din, "abstain", &real_packet->abstain)) {
37750       RECEIVE_PACKET_FIELD_ERROR(abstain);
37751     }
37752   }
37753   if (BV_ISSET(fields, 3)) {
37754     log_packet_detailed("  got field 'num_voters'");
37755     if (!DIO_GET(uint8, &din, "num_voters", &real_packet->num_voters)) {
37756       RECEIVE_PACKET_FIELD_ERROR(num_voters);
37757     }
37758   }
37759 
37760   if (NULL == old) {
37761     old = fc_malloc(sizeof(*old));
37762     *old = *real_packet;
37763     genhash_insert(*hash, old, old);
37764   } else {
37765     *old = *real_packet;
37766   }
37767   RECEIVE_PACKET_END(real_packet);
37768 }
37769 
send_packet_vote_update_100(struct connection * pc,const struct packet_vote_update * packet)37770 static int send_packet_vote_update_100(struct connection *pc, const struct packet_vote_update *packet)
37771 {
37772   const struct packet_vote_update *real_packet = packet;
37773   packet_vote_update_100_fields fields;
37774   struct packet_vote_update *old;
37775   bool differ;
37776   struct genhash **hash = pc->phs.sent + PACKET_VOTE_UPDATE;
37777   int different = 0;
37778   SEND_PACKET_START(PACKET_VOTE_UPDATE);
37779 
37780   log_packet_detailed("packet_vote_update_100: sending info about (%d)",
37781     real_packet->vote_no);
37782 
37783   if (NULL == *hash) {
37784     *hash = genhash_new_full(hash_packet_vote_update_100, cmp_packet_vote_update_100,
37785                              NULL, NULL, NULL, free);
37786   }
37787   BV_CLR_ALL(fields);
37788 
37789   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
37790     old = fc_malloc(sizeof(*old));
37791     *old = *real_packet;
37792     genhash_insert(*hash, old, old);
37793     memset(old, 0, sizeof(*old));
37794     different = 1;      /* Force to send. */
37795   }
37796 
37797   differ = (old->yes != real_packet->yes);
37798   if (differ) {
37799     different++;
37800     BV_SET(fields, 0);
37801   }
37802 
37803   differ = (old->no != real_packet->no);
37804   if (differ) {
37805     different++;
37806     BV_SET(fields, 1);
37807   }
37808 
37809   differ = (old->abstain != real_packet->abstain);
37810   if (differ) {
37811     different++;
37812     BV_SET(fields, 2);
37813   }
37814 
37815   differ = (old->num_voters != real_packet->num_voters);
37816   if (differ) {
37817     different++;
37818     BV_SET(fields, 3);
37819   }
37820 
37821 
37822   if (different == 0) {
37823     log_packet_detailed("  no change -> discard");
37824     return 0;
37825   }
37826 
37827   DIO_BV_PUT(&dout, "fields", fields);
37828   DIO_PUT(uint32, &dout, "vote_no", real_packet->vote_no);
37829 
37830   if (BV_ISSET(fields, 0)) {
37831     log_packet_detailed("  field 'yes' has changed");
37832     DIO_PUT(uint8, &dout, "yes", real_packet->yes);
37833   }
37834   if (BV_ISSET(fields, 1)) {
37835     log_packet_detailed("  field 'no' has changed");
37836     DIO_PUT(uint8, &dout, "no", real_packet->no);
37837   }
37838   if (BV_ISSET(fields, 2)) {
37839     log_packet_detailed("  field 'abstain' has changed");
37840     DIO_PUT(uint8, &dout, "abstain", real_packet->abstain);
37841   }
37842   if (BV_ISSET(fields, 3)) {
37843     log_packet_detailed("  field 'num_voters' has changed");
37844     DIO_PUT(uint8, &dout, "num_voters", real_packet->num_voters);
37845   }
37846 
37847   *old = *real_packet;
37848   SEND_PACKET_END(PACKET_VOTE_UPDATE);
37849 }
37850 
send_packet_vote_update(struct connection * pc,const struct packet_vote_update * packet)37851 int send_packet_vote_update(struct connection *pc, const struct packet_vote_update *packet)
37852 {
37853   if (!pc->used) {
37854     log_error("WARNING: trying to send data to the closed connection %s",
37855               conn_description(pc));
37856     return -1;
37857   }
37858   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_VOTE_UPDATE].packet != NULL, -1,
37859                         "Handler for PACKET_VOTE_UPDATE not installed");
37860   return pc->phs.handlers->send[PACKET_VOTE_UPDATE].packet(pc, packet);
37861 }
37862 
37863 #define hash_packet_vote_remove_100 hash_const
37864 
37865 #define cmp_packet_vote_remove_100 cmp_const
37866 
37867 BV_DEFINE(packet_vote_remove_100_fields, 1);
37868 
receive_packet_vote_remove_100(struct connection * pc)37869 static struct packet_vote_remove *receive_packet_vote_remove_100(struct connection *pc)
37870 {
37871   packet_vote_remove_100_fields fields;
37872   struct packet_vote_remove *old;
37873   struct genhash **hash = pc->phs.received + PACKET_VOTE_REMOVE;
37874   RECEIVE_PACKET_START(packet_vote_remove, real_packet);
37875 
37876   DIO_BV_GET(&din, fields);
37877 
37878   log_packet_detailed("packet_vote_remove_100: got info about ()");
37879 
37880   if (NULL == *hash) {
37881     *hash = genhash_new_full(hash_packet_vote_remove_100, cmp_packet_vote_remove_100,
37882                              NULL, NULL, NULL, free);
37883   }
37884 
37885   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
37886     *real_packet = *old;
37887   } else {
37888     log_packet_detailed("  no old info");
37889     memset(real_packet, 0, sizeof(*real_packet));
37890   }
37891 
37892   if (BV_ISSET(fields, 0)) {
37893     log_packet_detailed("  got field 'vote_no'");
37894     if (!DIO_GET(uint32, &din, "vote_no", &real_packet->vote_no)) {
37895       RECEIVE_PACKET_FIELD_ERROR(vote_no);
37896     }
37897   }
37898 
37899   if (NULL == old) {
37900     old = fc_malloc(sizeof(*old));
37901     *old = *real_packet;
37902     genhash_insert(*hash, old, old);
37903   } else {
37904     *old = *real_packet;
37905   }
37906   RECEIVE_PACKET_END(real_packet);
37907 }
37908 
send_packet_vote_remove_100(struct connection * pc,const struct packet_vote_remove * packet)37909 static int send_packet_vote_remove_100(struct connection *pc, const struct packet_vote_remove *packet)
37910 {
37911   const struct packet_vote_remove *real_packet = packet;
37912   packet_vote_remove_100_fields fields;
37913   struct packet_vote_remove *old;
37914   bool differ;
37915   struct genhash **hash = pc->phs.sent + PACKET_VOTE_REMOVE;
37916   int different = 0;
37917   SEND_PACKET_START(PACKET_VOTE_REMOVE);
37918 
37919   log_packet_detailed("packet_vote_remove_100: sending info about ()");
37920 
37921   if (NULL == *hash) {
37922     *hash = genhash_new_full(hash_packet_vote_remove_100, cmp_packet_vote_remove_100,
37923                              NULL, NULL, NULL, free);
37924   }
37925   BV_CLR_ALL(fields);
37926 
37927   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
37928     old = fc_malloc(sizeof(*old));
37929     *old = *real_packet;
37930     genhash_insert(*hash, old, old);
37931     memset(old, 0, sizeof(*old));
37932     different = 1;      /* Force to send. */
37933   }
37934 
37935   differ = (old->vote_no != real_packet->vote_no);
37936   if (differ) {
37937     different++;
37938     BV_SET(fields, 0);
37939   }
37940 
37941 
37942   DIO_BV_PUT(&dout, "fields", fields);
37943 
37944   if (BV_ISSET(fields, 0)) {
37945     log_packet_detailed("  field 'vote_no' has changed");
37946     DIO_PUT(uint32, &dout, "vote_no", real_packet->vote_no);
37947   }
37948 
37949   *old = *real_packet;
37950   SEND_PACKET_END(PACKET_VOTE_REMOVE);
37951 }
37952 
send_packet_vote_remove(struct connection * pc,const struct packet_vote_remove * packet)37953 int send_packet_vote_remove(struct connection *pc, const struct packet_vote_remove *packet)
37954 {
37955   if (!pc->used) {
37956     log_error("WARNING: trying to send data to the closed connection %s",
37957               conn_description(pc));
37958     return -1;
37959   }
37960   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_VOTE_REMOVE].packet != NULL, -1,
37961                         "Handler for PACKET_VOTE_REMOVE not installed");
37962   return pc->phs.handlers->send[PACKET_VOTE_REMOVE].packet(pc, packet);
37963 }
37964 
37965 #define hash_packet_vote_resolve_100 hash_const
37966 
37967 #define cmp_packet_vote_resolve_100 cmp_const
37968 
37969 BV_DEFINE(packet_vote_resolve_100_fields, 2);
37970 
receive_packet_vote_resolve_100(struct connection * pc)37971 static struct packet_vote_resolve *receive_packet_vote_resolve_100(struct connection *pc)
37972 {
37973   packet_vote_resolve_100_fields fields;
37974   struct packet_vote_resolve *old;
37975   struct genhash **hash = pc->phs.received + PACKET_VOTE_RESOLVE;
37976   RECEIVE_PACKET_START(packet_vote_resolve, real_packet);
37977 
37978   DIO_BV_GET(&din, fields);
37979 
37980   log_packet_detailed("packet_vote_resolve_100: got info about ()");
37981 
37982   if (NULL == *hash) {
37983     *hash = genhash_new_full(hash_packet_vote_resolve_100, cmp_packet_vote_resolve_100,
37984                              NULL, NULL, NULL, free);
37985   }
37986 
37987   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
37988     *real_packet = *old;
37989   } else {
37990     log_packet_detailed("  no old info");
37991     memset(real_packet, 0, sizeof(*real_packet));
37992   }
37993 
37994   if (BV_ISSET(fields, 0)) {
37995     log_packet_detailed("  got field 'vote_no'");
37996     if (!DIO_GET(uint32, &din, "vote_no", &real_packet->vote_no)) {
37997       RECEIVE_PACKET_FIELD_ERROR(vote_no);
37998     }
37999   }
38000   real_packet->passed = BV_ISSET(fields, 1);
38001 
38002   if (NULL == old) {
38003     old = fc_malloc(sizeof(*old));
38004     *old = *real_packet;
38005     genhash_insert(*hash, old, old);
38006   } else {
38007     *old = *real_packet;
38008   }
38009   RECEIVE_PACKET_END(real_packet);
38010 }
38011 
send_packet_vote_resolve_100(struct connection * pc,const struct packet_vote_resolve * packet)38012 static int send_packet_vote_resolve_100(struct connection *pc, const struct packet_vote_resolve *packet)
38013 {
38014   const struct packet_vote_resolve *real_packet = packet;
38015   packet_vote_resolve_100_fields fields;
38016   struct packet_vote_resolve *old;
38017   bool differ;
38018   struct genhash **hash = pc->phs.sent + PACKET_VOTE_RESOLVE;
38019   int different = 0;
38020   SEND_PACKET_START(PACKET_VOTE_RESOLVE);
38021 
38022   log_packet_detailed("packet_vote_resolve_100: sending info about ()");
38023 
38024   if (NULL == *hash) {
38025     *hash = genhash_new_full(hash_packet_vote_resolve_100, cmp_packet_vote_resolve_100,
38026                              NULL, NULL, NULL, free);
38027   }
38028   BV_CLR_ALL(fields);
38029 
38030   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
38031     old = fc_malloc(sizeof(*old));
38032     *old = *real_packet;
38033     genhash_insert(*hash, old, old);
38034     memset(old, 0, sizeof(*old));
38035     different = 1;      /* Force to send. */
38036   }
38037 
38038   differ = (old->vote_no != real_packet->vote_no);
38039   if (differ) {
38040     different++;
38041     BV_SET(fields, 0);
38042   }
38043 
38044   differ = (old->passed != real_packet->passed);
38045   if (differ) {
38046     different++;
38047   }
38048   if (packet->passed) {
38049     BV_SET(fields, 1);
38050   }
38051 
38052 
38053   DIO_BV_PUT(&dout, "fields", fields);
38054 
38055   if (BV_ISSET(fields, 0)) {
38056     log_packet_detailed("  field 'vote_no' has changed");
38057     DIO_PUT(uint32, &dout, "vote_no", real_packet->vote_no);
38058   }
38059   /* field 1 is folded into the header */
38060 
38061   *old = *real_packet;
38062   SEND_PACKET_END(PACKET_VOTE_RESOLVE);
38063 }
38064 
send_packet_vote_resolve(struct connection * pc,const struct packet_vote_resolve * packet)38065 int send_packet_vote_resolve(struct connection *pc, const struct packet_vote_resolve *packet)
38066 {
38067   if (!pc->used) {
38068     log_error("WARNING: trying to send data to the closed connection %s",
38069               conn_description(pc));
38070     return -1;
38071   }
38072   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_VOTE_RESOLVE].packet != NULL, -1,
38073                         "Handler for PACKET_VOTE_RESOLVE not installed");
38074   return pc->phs.handlers->send[PACKET_VOTE_RESOLVE].packet(pc, packet);
38075 }
38076 
receive_packet_vote_submit_100(struct connection * pc)38077 static struct packet_vote_submit *receive_packet_vote_submit_100(struct connection *pc)
38078 {
38079   RECEIVE_PACKET_START(packet_vote_submit, real_packet);
38080   if (!DIO_GET(uint32, &din, "vote_no", &real_packet->vote_no)) {
38081     RECEIVE_PACKET_FIELD_ERROR(vote_no);
38082   }
38083   if (!DIO_GET(sint8, &din, "value", &real_packet->value)) {
38084     RECEIVE_PACKET_FIELD_ERROR(value);
38085   }
38086 
38087   log_packet_detailed("packet_vote_submit_100: got info about ()");
38088   RECEIVE_PACKET_END(real_packet);
38089 }
38090 
send_packet_vote_submit_100(struct connection * pc,const struct packet_vote_submit * packet)38091 static int send_packet_vote_submit_100(struct connection *pc, const struct packet_vote_submit *packet)
38092 {
38093   const struct packet_vote_submit *real_packet = packet;
38094   SEND_PACKET_START(PACKET_VOTE_SUBMIT);
38095 
38096   log_packet_detailed("packet_vote_submit_100: sending info about ()");
38097 
38098   DIO_PUT(uint32, &dout, "vote_no", real_packet->vote_no);
38099   DIO_PUT(sint8, &dout, "value", real_packet->value);
38100 
38101   SEND_PACKET_END(PACKET_VOTE_SUBMIT);
38102 }
38103 
send_packet_vote_submit(struct connection * pc,const struct packet_vote_submit * packet)38104 int send_packet_vote_submit(struct connection *pc, const struct packet_vote_submit *packet)
38105 {
38106   if (!pc->used) {
38107     log_error("WARNING: trying to send data to the closed connection %s",
38108               conn_description(pc));
38109     return -1;
38110   }
38111   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_VOTE_SUBMIT].packet != NULL, -1,
38112                         "Handler for PACKET_VOTE_SUBMIT not installed");
38113   return pc->phs.handlers->send[PACKET_VOTE_SUBMIT].packet(pc, packet);
38114 }
38115 
38116 #define hash_packet_edit_mode_100 hash_const
38117 
38118 #define cmp_packet_edit_mode_100 cmp_const
38119 
38120 BV_DEFINE(packet_edit_mode_100_fields, 1);
38121 
receive_packet_edit_mode_100(struct connection * pc)38122 static struct packet_edit_mode *receive_packet_edit_mode_100(struct connection *pc)
38123 {
38124   packet_edit_mode_100_fields fields;
38125   struct packet_edit_mode *old;
38126   struct genhash **hash = pc->phs.received + PACKET_EDIT_MODE;
38127   RECEIVE_PACKET_START(packet_edit_mode, real_packet);
38128 
38129   DIO_BV_GET(&din, fields);
38130 
38131   log_packet_detailed("packet_edit_mode_100: got info about ()");
38132 
38133   if (NULL == *hash) {
38134     *hash = genhash_new_full(hash_packet_edit_mode_100, cmp_packet_edit_mode_100,
38135                              NULL, NULL, NULL, free);
38136   }
38137 
38138   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
38139     *real_packet = *old;
38140   } else {
38141     log_packet_detailed("  no old info");
38142     memset(real_packet, 0, sizeof(*real_packet));
38143   }
38144 
38145   real_packet->state = BV_ISSET(fields, 0);
38146 
38147   if (NULL == old) {
38148     old = fc_malloc(sizeof(*old));
38149     *old = *real_packet;
38150     genhash_insert(*hash, old, old);
38151   } else {
38152     *old = *real_packet;
38153   }
38154   RECEIVE_PACKET_END(real_packet);
38155 }
38156 
send_packet_edit_mode_100(struct connection * pc,const struct packet_edit_mode * packet)38157 static int send_packet_edit_mode_100(struct connection *pc, const struct packet_edit_mode *packet)
38158 {
38159   const struct packet_edit_mode *real_packet = packet;
38160   packet_edit_mode_100_fields fields;
38161   struct packet_edit_mode *old;
38162   bool differ;
38163   struct genhash **hash = pc->phs.sent + PACKET_EDIT_MODE;
38164   int different = 0;
38165   SEND_PACKET_START(PACKET_EDIT_MODE);
38166 
38167   log_packet_detailed("packet_edit_mode_100: sending info about ()");
38168 
38169   if (NULL == *hash) {
38170     *hash = genhash_new_full(hash_packet_edit_mode_100, cmp_packet_edit_mode_100,
38171                              NULL, NULL, NULL, free);
38172   }
38173   BV_CLR_ALL(fields);
38174 
38175   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
38176     old = fc_malloc(sizeof(*old));
38177     *old = *real_packet;
38178     genhash_insert(*hash, old, old);
38179     memset(old, 0, sizeof(*old));
38180     different = 1;      /* Force to send. */
38181   }
38182 
38183   differ = (old->state != real_packet->state);
38184   if (differ) {
38185     different++;
38186   }
38187   if (packet->state) {
38188     BV_SET(fields, 0);
38189   }
38190 
38191 
38192   DIO_BV_PUT(&dout, "fields", fields);
38193 
38194   /* field 0 is folded into the header */
38195 
38196   *old = *real_packet;
38197   SEND_PACKET_END(PACKET_EDIT_MODE);
38198 }
38199 
send_packet_edit_mode(struct connection * pc,const struct packet_edit_mode * packet)38200 int send_packet_edit_mode(struct connection *pc, const struct packet_edit_mode *packet)
38201 {
38202   if (!pc->used) {
38203     log_error("WARNING: trying to send data to the closed connection %s",
38204               conn_description(pc));
38205     return -1;
38206   }
38207   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_MODE].packet != NULL, -1,
38208                         "Handler for PACKET_EDIT_MODE not installed");
38209   return pc->phs.handlers->send[PACKET_EDIT_MODE].packet(pc, packet);
38210 }
38211 
dsend_packet_edit_mode(struct connection * pc,bool state)38212 int dsend_packet_edit_mode(struct connection *pc, bool state)
38213 {
38214   struct packet_edit_mode packet, *real_packet = &packet;
38215 
38216   real_packet->state = state;
38217 
38218   return send_packet_edit_mode(pc, real_packet);
38219 }
38220 
receive_packet_edit_recalculate_borders_100(struct connection * pc)38221 static struct packet_edit_recalculate_borders *receive_packet_edit_recalculate_borders_100(struct connection *pc)
38222 {
38223   RECEIVE_PACKET_START(packet_edit_recalculate_borders, real_packet);
38224   real_packet->__dummy = 0xff;
38225   log_packet_detailed("packet_edit_recalculate_borders_100: got info about ()");
38226   RECEIVE_PACKET_END(real_packet);
38227 }
38228 
send_packet_edit_recalculate_borders_100(struct connection * pc)38229 static int send_packet_edit_recalculate_borders_100(struct connection *pc)
38230 {
38231   SEND_PACKET_START(PACKET_EDIT_RECALCULATE_BORDERS);
38232 
38233   log_packet_detailed("packet_edit_recalculate_borders_100: sending info about ()");
38234   SEND_PACKET_END(PACKET_EDIT_RECALCULATE_BORDERS);
38235 }
38236 
send_packet_edit_recalculate_borders(struct connection * pc)38237 int send_packet_edit_recalculate_borders(struct connection *pc)
38238 {
38239   if (!pc->used) {
38240     log_error("WARNING: trying to send data to the closed connection %s",
38241               conn_description(pc));
38242     return -1;
38243   }
38244   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_RECALCULATE_BORDERS].no_packet != NULL, -1,
38245                         "Handler for PACKET_EDIT_RECALCULATE_BORDERS not installed");
38246   return pc->phs.handlers->send[PACKET_EDIT_RECALCULATE_BORDERS].no_packet(pc);
38247 }
38248 
receive_packet_edit_check_tiles_100(struct connection * pc)38249 static struct packet_edit_check_tiles *receive_packet_edit_check_tiles_100(struct connection *pc)
38250 {
38251   RECEIVE_PACKET_START(packet_edit_check_tiles, real_packet);
38252   real_packet->__dummy = 0xff;
38253   log_packet_detailed("packet_edit_check_tiles_100: got info about ()");
38254   RECEIVE_PACKET_END(real_packet);
38255 }
38256 
send_packet_edit_check_tiles_100(struct connection * pc)38257 static int send_packet_edit_check_tiles_100(struct connection *pc)
38258 {
38259   SEND_PACKET_START(PACKET_EDIT_CHECK_TILES);
38260 
38261   log_packet_detailed("packet_edit_check_tiles_100: sending info about ()");
38262   SEND_PACKET_END(PACKET_EDIT_CHECK_TILES);
38263 }
38264 
send_packet_edit_check_tiles(struct connection * pc)38265 int send_packet_edit_check_tiles(struct connection *pc)
38266 {
38267   if (!pc->used) {
38268     log_error("WARNING: trying to send data to the closed connection %s",
38269               conn_description(pc));
38270     return -1;
38271   }
38272   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_CHECK_TILES].no_packet != NULL, -1,
38273                         "Handler for PACKET_EDIT_CHECK_TILES not installed");
38274   return pc->phs.handlers->send[PACKET_EDIT_CHECK_TILES].no_packet(pc);
38275 }
38276 
38277 #define hash_packet_edit_toggle_fogofwar_100 hash_const
38278 
38279 #define cmp_packet_edit_toggle_fogofwar_100 cmp_const
38280 
38281 BV_DEFINE(packet_edit_toggle_fogofwar_100_fields, 1);
38282 
receive_packet_edit_toggle_fogofwar_100(struct connection * pc)38283 static struct packet_edit_toggle_fogofwar *receive_packet_edit_toggle_fogofwar_100(struct connection *pc)
38284 {
38285   packet_edit_toggle_fogofwar_100_fields fields;
38286   struct packet_edit_toggle_fogofwar *old;
38287   struct genhash **hash = pc->phs.received + PACKET_EDIT_TOGGLE_FOGOFWAR;
38288   RECEIVE_PACKET_START(packet_edit_toggle_fogofwar, real_packet);
38289 
38290   DIO_BV_GET(&din, fields);
38291 
38292   log_packet_detailed("packet_edit_toggle_fogofwar_100: got info about ()");
38293 
38294   if (NULL == *hash) {
38295     *hash = genhash_new_full(hash_packet_edit_toggle_fogofwar_100, cmp_packet_edit_toggle_fogofwar_100,
38296                              NULL, NULL, NULL, free);
38297   }
38298 
38299   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
38300     *real_packet = *old;
38301   } else {
38302     log_packet_detailed("  no old info");
38303     memset(real_packet, 0, sizeof(*real_packet));
38304   }
38305 
38306   if (BV_ISSET(fields, 0)) {
38307     log_packet_detailed("  got field 'player'");
38308     if (!DIO_GET(uint8, &din, "player", &real_packet->player)) {
38309       RECEIVE_PACKET_FIELD_ERROR(player);
38310     }
38311   }
38312 
38313   if (NULL == old) {
38314     old = fc_malloc(sizeof(*old));
38315     *old = *real_packet;
38316     genhash_insert(*hash, old, old);
38317   } else {
38318     *old = *real_packet;
38319   }
38320   RECEIVE_PACKET_END(real_packet);
38321 }
38322 
send_packet_edit_toggle_fogofwar_100(struct connection * pc,const struct packet_edit_toggle_fogofwar * packet)38323 static int send_packet_edit_toggle_fogofwar_100(struct connection *pc, const struct packet_edit_toggle_fogofwar *packet)
38324 {
38325   const struct packet_edit_toggle_fogofwar *real_packet = packet;
38326   packet_edit_toggle_fogofwar_100_fields fields;
38327   struct packet_edit_toggle_fogofwar *old;
38328   bool differ;
38329   struct genhash **hash = pc->phs.sent + PACKET_EDIT_TOGGLE_FOGOFWAR;
38330   int different = 0;
38331   SEND_PACKET_START(PACKET_EDIT_TOGGLE_FOGOFWAR);
38332 
38333   log_packet_detailed("packet_edit_toggle_fogofwar_100: sending info about ()");
38334 
38335   if (NULL == *hash) {
38336     *hash = genhash_new_full(hash_packet_edit_toggle_fogofwar_100, cmp_packet_edit_toggle_fogofwar_100,
38337                              NULL, NULL, NULL, free);
38338   }
38339   BV_CLR_ALL(fields);
38340 
38341   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
38342     old = fc_malloc(sizeof(*old));
38343     *old = *real_packet;
38344     genhash_insert(*hash, old, old);
38345     memset(old, 0, sizeof(*old));
38346     different = 1;      /* Force to send. */
38347   }
38348 
38349   differ = (old->player != real_packet->player);
38350   if (differ) {
38351     different++;
38352     BV_SET(fields, 0);
38353   }
38354 
38355 
38356   DIO_BV_PUT(&dout, "fields", fields);
38357 
38358   if (BV_ISSET(fields, 0)) {
38359     log_packet_detailed("  field 'player' has changed");
38360     DIO_PUT(uint8, &dout, "player", real_packet->player);
38361   }
38362 
38363   *old = *real_packet;
38364   SEND_PACKET_END(PACKET_EDIT_TOGGLE_FOGOFWAR);
38365 }
38366 
send_packet_edit_toggle_fogofwar(struct connection * pc,const struct packet_edit_toggle_fogofwar * packet)38367 int send_packet_edit_toggle_fogofwar(struct connection *pc, const struct packet_edit_toggle_fogofwar *packet)
38368 {
38369   if (!pc->used) {
38370     log_error("WARNING: trying to send data to the closed connection %s",
38371               conn_description(pc));
38372     return -1;
38373   }
38374   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_TOGGLE_FOGOFWAR].packet != NULL, -1,
38375                         "Handler for PACKET_EDIT_TOGGLE_FOGOFWAR not installed");
38376   return pc->phs.handlers->send[PACKET_EDIT_TOGGLE_FOGOFWAR].packet(pc, packet);
38377 }
38378 
dsend_packet_edit_toggle_fogofwar(struct connection * pc,int player)38379 int dsend_packet_edit_toggle_fogofwar(struct connection *pc, int player)
38380 {
38381   struct packet_edit_toggle_fogofwar packet, *real_packet = &packet;
38382 
38383   real_packet->player = player;
38384 
38385   return send_packet_edit_toggle_fogofwar(pc, real_packet);
38386 }
38387 
hash_packet_edit_tile_terrain_100(const void * vkey)38388 static genhash_val_t hash_packet_edit_tile_terrain_100(const void *vkey)
38389 {
38390   const struct packet_edit_tile_terrain *key = (const struct packet_edit_tile_terrain *) vkey;
38391 
38392   return key->tile;
38393 }
38394 
cmp_packet_edit_tile_terrain_100(const void * vkey1,const void * vkey2)38395 static bool cmp_packet_edit_tile_terrain_100(const void *vkey1, const void *vkey2)
38396 {
38397   const struct packet_edit_tile_terrain *key1 = (const struct packet_edit_tile_terrain *) vkey1;
38398   const struct packet_edit_tile_terrain *key2 = (const struct packet_edit_tile_terrain *) vkey2;
38399 
38400   return key1->tile == key2->tile;
38401 }
38402 
38403 BV_DEFINE(packet_edit_tile_terrain_100_fields, 2);
38404 
receive_packet_edit_tile_terrain_100(struct connection * pc)38405 static struct packet_edit_tile_terrain *receive_packet_edit_tile_terrain_100(struct connection *pc)
38406 {
38407   packet_edit_tile_terrain_100_fields fields;
38408   struct packet_edit_tile_terrain *old;
38409   struct genhash **hash = pc->phs.received + PACKET_EDIT_TILE_TERRAIN;
38410   RECEIVE_PACKET_START(packet_edit_tile_terrain, real_packet);
38411 
38412   DIO_BV_GET(&din, fields);
38413   if (!DIO_GET(sint32, &din, "tile", &real_packet->tile)) {
38414     RECEIVE_PACKET_FIELD_ERROR(tile);
38415   }
38416 
38417   log_packet_detailed("packet_edit_tile_terrain_100: got info about (%d)",
38418     real_packet->tile);
38419 
38420   if (NULL == *hash) {
38421     *hash = genhash_new_full(hash_packet_edit_tile_terrain_100, cmp_packet_edit_tile_terrain_100,
38422                              NULL, NULL, NULL, free);
38423   }
38424 
38425   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
38426     *real_packet = *old;
38427   } else {
38428     int tile = real_packet->tile;
38429 
38430     log_packet_detailed("  no old info");
38431     memset(real_packet, 0, sizeof(*real_packet));
38432 
38433     real_packet->tile = tile;
38434   }
38435 
38436   if (BV_ISSET(fields, 0)) {
38437     log_packet_detailed("  got field 'terrain'");
38438     {
38439       int readin;
38440 
38441       if (!DIO_GET(uint8, &din, "terrain", &readin)) {
38442         RECEIVE_PACKET_FIELD_ERROR(terrain);
38443       }
38444       real_packet->terrain = readin;
38445     }
38446   }
38447   if (BV_ISSET(fields, 1)) {
38448     log_packet_detailed("  got field 'size'");
38449     if (!DIO_GET(uint8, &din, "size", &real_packet->size)) {
38450       RECEIVE_PACKET_FIELD_ERROR(size);
38451     }
38452   }
38453 
38454   if (NULL == old) {
38455     old = fc_malloc(sizeof(*old));
38456     *old = *real_packet;
38457     genhash_insert(*hash, old, old);
38458   } else {
38459     *old = *real_packet;
38460   }
38461   RECEIVE_PACKET_END(real_packet);
38462 }
38463 
send_packet_edit_tile_terrain_100(struct connection * pc,const struct packet_edit_tile_terrain * packet)38464 static int send_packet_edit_tile_terrain_100(struct connection *pc, const struct packet_edit_tile_terrain *packet)
38465 {
38466   const struct packet_edit_tile_terrain *real_packet = packet;
38467   packet_edit_tile_terrain_100_fields fields;
38468   struct packet_edit_tile_terrain *old;
38469   bool differ;
38470   struct genhash **hash = pc->phs.sent + PACKET_EDIT_TILE_TERRAIN;
38471   int different = 0;
38472   SEND_PACKET_START(PACKET_EDIT_TILE_TERRAIN);
38473 
38474   log_packet_detailed("packet_edit_tile_terrain_100: sending info about (%d)",
38475     real_packet->tile);
38476 
38477   if (NULL == *hash) {
38478     *hash = genhash_new_full(hash_packet_edit_tile_terrain_100, cmp_packet_edit_tile_terrain_100,
38479                              NULL, NULL, NULL, free);
38480   }
38481   BV_CLR_ALL(fields);
38482 
38483   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
38484     old = fc_malloc(sizeof(*old));
38485     *old = *real_packet;
38486     genhash_insert(*hash, old, old);
38487     memset(old, 0, sizeof(*old));
38488     different = 1;      /* Force to send. */
38489   }
38490 
38491   differ = (old->terrain != real_packet->terrain);
38492   if (differ) {
38493     different++;
38494     BV_SET(fields, 0);
38495   }
38496 
38497   differ = (old->size != real_packet->size);
38498   if (differ) {
38499     different++;
38500     BV_SET(fields, 1);
38501   }
38502 
38503 
38504   DIO_BV_PUT(&dout, "fields", fields);
38505   DIO_PUT(sint32, &dout, "tile", real_packet->tile);
38506 
38507   if (BV_ISSET(fields, 0)) {
38508     log_packet_detailed("  field 'terrain' has changed");
38509     DIO_PUT(uint8, &dout, "terrain", real_packet->terrain);
38510   }
38511   if (BV_ISSET(fields, 1)) {
38512     log_packet_detailed("  field 'size' has changed");
38513     DIO_PUT(uint8, &dout, "size", real_packet->size);
38514   }
38515 
38516   *old = *real_packet;
38517   SEND_PACKET_END(PACKET_EDIT_TILE_TERRAIN);
38518 }
38519 
send_packet_edit_tile_terrain(struct connection * pc,const struct packet_edit_tile_terrain * packet)38520 int send_packet_edit_tile_terrain(struct connection *pc, const struct packet_edit_tile_terrain *packet)
38521 {
38522   if (!pc->used) {
38523     log_error("WARNING: trying to send data to the closed connection %s",
38524               conn_description(pc));
38525     return -1;
38526   }
38527   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_TILE_TERRAIN].packet != NULL, -1,
38528                         "Handler for PACKET_EDIT_TILE_TERRAIN not installed");
38529   return pc->phs.handlers->send[PACKET_EDIT_TILE_TERRAIN].packet(pc, packet);
38530 }
38531 
dsend_packet_edit_tile_terrain(struct connection * pc,int tile,Terrain_type_id terrain,int size)38532 int dsend_packet_edit_tile_terrain(struct connection *pc, int tile, Terrain_type_id terrain, int size)
38533 {
38534   struct packet_edit_tile_terrain packet, *real_packet = &packet;
38535 
38536   real_packet->tile = tile;
38537   real_packet->terrain = terrain;
38538   real_packet->size = size;
38539 
38540   return send_packet_edit_tile_terrain(pc, real_packet);
38541 }
38542 
hash_packet_edit_tile_resource_100(const void * vkey)38543 static genhash_val_t hash_packet_edit_tile_resource_100(const void *vkey)
38544 {
38545   const struct packet_edit_tile_resource *key = (const struct packet_edit_tile_resource *) vkey;
38546 
38547   return key->tile;
38548 }
38549 
cmp_packet_edit_tile_resource_100(const void * vkey1,const void * vkey2)38550 static bool cmp_packet_edit_tile_resource_100(const void *vkey1, const void *vkey2)
38551 {
38552   const struct packet_edit_tile_resource *key1 = (const struct packet_edit_tile_resource *) vkey1;
38553   const struct packet_edit_tile_resource *key2 = (const struct packet_edit_tile_resource *) vkey2;
38554 
38555   return key1->tile == key2->tile;
38556 }
38557 
38558 BV_DEFINE(packet_edit_tile_resource_100_fields, 2);
38559 
receive_packet_edit_tile_resource_100(struct connection * pc)38560 static struct packet_edit_tile_resource *receive_packet_edit_tile_resource_100(struct connection *pc)
38561 {
38562   packet_edit_tile_resource_100_fields fields;
38563   struct packet_edit_tile_resource *old;
38564   struct genhash **hash = pc->phs.received + PACKET_EDIT_TILE_RESOURCE;
38565   RECEIVE_PACKET_START(packet_edit_tile_resource, real_packet);
38566 
38567   DIO_BV_GET(&din, fields);
38568   if (!DIO_GET(sint32, &din, "tile", &real_packet->tile)) {
38569     RECEIVE_PACKET_FIELD_ERROR(tile);
38570   }
38571 
38572   log_packet_detailed("packet_edit_tile_resource_100: got info about (%d)",
38573     real_packet->tile);
38574 
38575   if (NULL == *hash) {
38576     *hash = genhash_new_full(hash_packet_edit_tile_resource_100, cmp_packet_edit_tile_resource_100,
38577                              NULL, NULL, NULL, free);
38578   }
38579 
38580   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
38581     *real_packet = *old;
38582   } else {
38583     int tile = real_packet->tile;
38584 
38585     log_packet_detailed("  no old info");
38586     memset(real_packet, 0, sizeof(*real_packet));
38587 
38588     real_packet->tile = tile;
38589   }
38590 
38591   if (BV_ISSET(fields, 0)) {
38592     log_packet_detailed("  got field 'resource'");
38593     {
38594       int readin;
38595 
38596       if (!DIO_GET(uint8, &din, "resource", &readin)) {
38597         RECEIVE_PACKET_FIELD_ERROR(resource);
38598       }
38599       real_packet->resource = readin;
38600     }
38601   }
38602   if (BV_ISSET(fields, 1)) {
38603     log_packet_detailed("  got field 'size'");
38604     if (!DIO_GET(uint8, &din, "size", &real_packet->size)) {
38605       RECEIVE_PACKET_FIELD_ERROR(size);
38606     }
38607   }
38608 
38609   if (NULL == old) {
38610     old = fc_malloc(sizeof(*old));
38611     *old = *real_packet;
38612     genhash_insert(*hash, old, old);
38613   } else {
38614     *old = *real_packet;
38615   }
38616   RECEIVE_PACKET_END(real_packet);
38617 }
38618 
send_packet_edit_tile_resource_100(struct connection * pc,const struct packet_edit_tile_resource * packet)38619 static int send_packet_edit_tile_resource_100(struct connection *pc, const struct packet_edit_tile_resource *packet)
38620 {
38621   const struct packet_edit_tile_resource *real_packet = packet;
38622   packet_edit_tile_resource_100_fields fields;
38623   struct packet_edit_tile_resource *old;
38624   bool differ;
38625   struct genhash **hash = pc->phs.sent + PACKET_EDIT_TILE_RESOURCE;
38626   int different = 0;
38627   SEND_PACKET_START(PACKET_EDIT_TILE_RESOURCE);
38628 
38629   log_packet_detailed("packet_edit_tile_resource_100: sending info about (%d)",
38630     real_packet->tile);
38631 
38632   if (NULL == *hash) {
38633     *hash = genhash_new_full(hash_packet_edit_tile_resource_100, cmp_packet_edit_tile_resource_100,
38634                              NULL, NULL, NULL, free);
38635   }
38636   BV_CLR_ALL(fields);
38637 
38638   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
38639     old = fc_malloc(sizeof(*old));
38640     *old = *real_packet;
38641     genhash_insert(*hash, old, old);
38642     memset(old, 0, sizeof(*old));
38643     different = 1;      /* Force to send. */
38644   }
38645 
38646   differ = (old->resource != real_packet->resource);
38647   if (differ) {
38648     different++;
38649     BV_SET(fields, 0);
38650   }
38651 
38652   differ = (old->size != real_packet->size);
38653   if (differ) {
38654     different++;
38655     BV_SET(fields, 1);
38656   }
38657 
38658 
38659   DIO_BV_PUT(&dout, "fields", fields);
38660   DIO_PUT(sint32, &dout, "tile", real_packet->tile);
38661 
38662   if (BV_ISSET(fields, 0)) {
38663     log_packet_detailed("  field 'resource' has changed");
38664     DIO_PUT(uint8, &dout, "resource", real_packet->resource);
38665   }
38666   if (BV_ISSET(fields, 1)) {
38667     log_packet_detailed("  field 'size' has changed");
38668     DIO_PUT(uint8, &dout, "size", real_packet->size);
38669   }
38670 
38671   *old = *real_packet;
38672   SEND_PACKET_END(PACKET_EDIT_TILE_RESOURCE);
38673 }
38674 
send_packet_edit_tile_resource(struct connection * pc,const struct packet_edit_tile_resource * packet)38675 int send_packet_edit_tile_resource(struct connection *pc, const struct packet_edit_tile_resource *packet)
38676 {
38677   if (!pc->used) {
38678     log_error("WARNING: trying to send data to the closed connection %s",
38679               conn_description(pc));
38680     return -1;
38681   }
38682   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_TILE_RESOURCE].packet != NULL, -1,
38683                         "Handler for PACKET_EDIT_TILE_RESOURCE not installed");
38684   return pc->phs.handlers->send[PACKET_EDIT_TILE_RESOURCE].packet(pc, packet);
38685 }
38686 
dsend_packet_edit_tile_resource(struct connection * pc,int tile,Resource_type_id resource,int size)38687 int dsend_packet_edit_tile_resource(struct connection *pc, int tile, Resource_type_id resource, int size)
38688 {
38689   struct packet_edit_tile_resource packet, *real_packet = &packet;
38690 
38691   real_packet->tile = tile;
38692   real_packet->resource = resource;
38693   real_packet->size = size;
38694 
38695   return send_packet_edit_tile_resource(pc, real_packet);
38696 }
38697 
hash_packet_edit_tile_extra_100(const void * vkey)38698 static genhash_val_t hash_packet_edit_tile_extra_100(const void *vkey)
38699 {
38700   const struct packet_edit_tile_extra *key = (const struct packet_edit_tile_extra *) vkey;
38701 
38702   return key->tile;
38703 }
38704 
cmp_packet_edit_tile_extra_100(const void * vkey1,const void * vkey2)38705 static bool cmp_packet_edit_tile_extra_100(const void *vkey1, const void *vkey2)
38706 {
38707   const struct packet_edit_tile_extra *key1 = (const struct packet_edit_tile_extra *) vkey1;
38708   const struct packet_edit_tile_extra *key2 = (const struct packet_edit_tile_extra *) vkey2;
38709 
38710   return key1->tile == key2->tile;
38711 }
38712 
38713 BV_DEFINE(packet_edit_tile_extra_100_fields, 3);
38714 
receive_packet_edit_tile_extra_100(struct connection * pc)38715 static struct packet_edit_tile_extra *receive_packet_edit_tile_extra_100(struct connection *pc)
38716 {
38717   packet_edit_tile_extra_100_fields fields;
38718   struct packet_edit_tile_extra *old;
38719   struct genhash **hash = pc->phs.received + PACKET_EDIT_TILE_EXTRA;
38720   RECEIVE_PACKET_START(packet_edit_tile_extra, real_packet);
38721 
38722   DIO_BV_GET(&din, fields);
38723   if (!DIO_GET(sint32, &din, "tile", &real_packet->tile)) {
38724     RECEIVE_PACKET_FIELD_ERROR(tile);
38725   }
38726 
38727   log_packet_detailed("packet_edit_tile_extra_100: got info about (%d)",
38728     real_packet->tile);
38729 
38730   if (NULL == *hash) {
38731     *hash = genhash_new_full(hash_packet_edit_tile_extra_100, cmp_packet_edit_tile_extra_100,
38732                              NULL, NULL, NULL, free);
38733   }
38734 
38735   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
38736     *real_packet = *old;
38737   } else {
38738     int tile = real_packet->tile;
38739 
38740     log_packet_detailed("  no old info");
38741     memset(real_packet, 0, sizeof(*real_packet));
38742 
38743     real_packet->tile = tile;
38744   }
38745 
38746   if (BV_ISSET(fields, 0)) {
38747     log_packet_detailed("  got field 'extra_type_id'");
38748     if (!DIO_GET(sint8, &din, "extra_type_id", &real_packet->extra_type_id)) {
38749       RECEIVE_PACKET_FIELD_ERROR(extra_type_id);
38750     }
38751   }
38752   real_packet->removal = BV_ISSET(fields, 1);
38753   if (BV_ISSET(fields, 2)) {
38754     log_packet_detailed("  got field 'size'");
38755     if (!DIO_GET(uint8, &din, "size", &real_packet->size)) {
38756       RECEIVE_PACKET_FIELD_ERROR(size);
38757     }
38758   }
38759 
38760   if (NULL == old) {
38761     old = fc_malloc(sizeof(*old));
38762     *old = *real_packet;
38763     genhash_insert(*hash, old, old);
38764   } else {
38765     *old = *real_packet;
38766   }
38767   RECEIVE_PACKET_END(real_packet);
38768 }
38769 
send_packet_edit_tile_extra_100(struct connection * pc,const struct packet_edit_tile_extra * packet)38770 static int send_packet_edit_tile_extra_100(struct connection *pc, const struct packet_edit_tile_extra *packet)
38771 {
38772   const struct packet_edit_tile_extra *real_packet = packet;
38773   packet_edit_tile_extra_100_fields fields;
38774   struct packet_edit_tile_extra *old;
38775   bool differ;
38776   struct genhash **hash = pc->phs.sent + PACKET_EDIT_TILE_EXTRA;
38777   int different = 0;
38778   SEND_PACKET_START(PACKET_EDIT_TILE_EXTRA);
38779 
38780   log_packet_detailed("packet_edit_tile_extra_100: sending info about (%d)",
38781     real_packet->tile);
38782 
38783   if (NULL == *hash) {
38784     *hash = genhash_new_full(hash_packet_edit_tile_extra_100, cmp_packet_edit_tile_extra_100,
38785                              NULL, NULL, NULL, free);
38786   }
38787   BV_CLR_ALL(fields);
38788 
38789   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
38790     old = fc_malloc(sizeof(*old));
38791     *old = *real_packet;
38792     genhash_insert(*hash, old, old);
38793     memset(old, 0, sizeof(*old));
38794     different = 1;      /* Force to send. */
38795   }
38796 
38797   differ = (old->extra_type_id != real_packet->extra_type_id);
38798   if (differ) {
38799     different++;
38800     BV_SET(fields, 0);
38801   }
38802 
38803   differ = (old->removal != real_packet->removal);
38804   if (differ) {
38805     different++;
38806   }
38807   if (packet->removal) {
38808     BV_SET(fields, 1);
38809   }
38810 
38811   differ = (old->size != real_packet->size);
38812   if (differ) {
38813     different++;
38814     BV_SET(fields, 2);
38815   }
38816 
38817 
38818   DIO_BV_PUT(&dout, "fields", fields);
38819   DIO_PUT(sint32, &dout, "tile", real_packet->tile);
38820 
38821   if (BV_ISSET(fields, 0)) {
38822     log_packet_detailed("  field 'extra_type_id' has changed");
38823     DIO_PUT(sint8, &dout, "extra_type_id", real_packet->extra_type_id);
38824   }
38825   /* field 1 is folded into the header */
38826   if (BV_ISSET(fields, 2)) {
38827     log_packet_detailed("  field 'size' has changed");
38828     DIO_PUT(uint8, &dout, "size", real_packet->size);
38829   }
38830 
38831   *old = *real_packet;
38832   SEND_PACKET_END(PACKET_EDIT_TILE_EXTRA);
38833 }
38834 
send_packet_edit_tile_extra(struct connection * pc,const struct packet_edit_tile_extra * packet)38835 int send_packet_edit_tile_extra(struct connection *pc, const struct packet_edit_tile_extra *packet)
38836 {
38837   if (!pc->used) {
38838     log_error("WARNING: trying to send data to the closed connection %s",
38839               conn_description(pc));
38840     return -1;
38841   }
38842   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_TILE_EXTRA].packet != NULL, -1,
38843                         "Handler for PACKET_EDIT_TILE_EXTRA not installed");
38844   return pc->phs.handlers->send[PACKET_EDIT_TILE_EXTRA].packet(pc, packet);
38845 }
38846 
dsend_packet_edit_tile_extra(struct connection * pc,int tile,int extra_type_id,bool removal,int size)38847 int dsend_packet_edit_tile_extra(struct connection *pc, int tile, int extra_type_id, bool removal, int size)
38848 {
38849   struct packet_edit_tile_extra packet, *real_packet = &packet;
38850 
38851   real_packet->tile = tile;
38852   real_packet->extra_type_id = extra_type_id;
38853   real_packet->removal = removal;
38854   real_packet->size = size;
38855 
38856   return send_packet_edit_tile_extra(pc, real_packet);
38857 }
38858 
receive_packet_edit_startpos_100(struct connection * pc)38859 static struct packet_edit_startpos *receive_packet_edit_startpos_100(struct connection *pc)
38860 {
38861   RECEIVE_PACKET_START(packet_edit_startpos, real_packet);
38862   if (!DIO_GET(sint32, &din, "id", &real_packet->id)) {
38863     RECEIVE_PACKET_FIELD_ERROR(id);
38864   }
38865   if (!DIO_GET(bool8, &din, "removal", &real_packet->removal)) {
38866     RECEIVE_PACKET_FIELD_ERROR(removal);
38867   }
38868   if (!DIO_GET(sint32, &din, "tag", &real_packet->tag)) {
38869     RECEIVE_PACKET_FIELD_ERROR(tag);
38870   }
38871 
38872   log_packet_detailed("packet_edit_startpos_100: got info about ()");
38873   RECEIVE_PACKET_END(real_packet);
38874 }
38875 
send_packet_edit_startpos_100(struct connection * pc,const struct packet_edit_startpos * packet)38876 static int send_packet_edit_startpos_100(struct connection *pc, const struct packet_edit_startpos *packet)
38877 {
38878   const struct packet_edit_startpos *real_packet = packet;
38879   SEND_PACKET_START(PACKET_EDIT_STARTPOS);
38880 
38881   log_packet_detailed("packet_edit_startpos_100: sending info about ()");
38882 
38883   DIO_PUT(sint32, &dout, "id", real_packet->id);
38884   DIO_PUT(bool8, &dout, "removal", real_packet->removal);
38885   DIO_PUT(sint32, &dout, "tag", real_packet->tag);
38886 
38887   SEND_PACKET_END(PACKET_EDIT_STARTPOS);
38888 }
38889 
send_packet_edit_startpos(struct connection * pc,const struct packet_edit_startpos * packet)38890 int send_packet_edit_startpos(struct connection *pc, const struct packet_edit_startpos *packet)
38891 {
38892   if (!pc->used) {
38893     log_error("WARNING: trying to send data to the closed connection %s",
38894               conn_description(pc));
38895     return -1;
38896   }
38897   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_STARTPOS].packet != NULL, -1,
38898                         "Handler for PACKET_EDIT_STARTPOS not installed");
38899   return pc->phs.handlers->send[PACKET_EDIT_STARTPOS].packet(pc, packet);
38900 }
38901 
dsend_packet_edit_startpos(struct connection * pc,int id,bool removal,int tag)38902 int dsend_packet_edit_startpos(struct connection *pc, int id, bool removal, int tag)
38903 {
38904   struct packet_edit_startpos packet, *real_packet = &packet;
38905 
38906   real_packet->id = id;
38907   real_packet->removal = removal;
38908   real_packet->tag = tag;
38909 
38910   return send_packet_edit_startpos(pc, real_packet);
38911 }
38912 
receive_packet_edit_startpos_full_100(struct connection * pc)38913 static struct packet_edit_startpos_full *receive_packet_edit_startpos_full_100(struct connection *pc)
38914 {
38915   RECEIVE_PACKET_START(packet_edit_startpos_full, real_packet);
38916   if (!DIO_GET(sint32, &din, "id", &real_packet->id)) {
38917     RECEIVE_PACKET_FIELD_ERROR(id);
38918   }
38919   if (!DIO_GET(bool8, &din, "exclude", &real_packet->exclude)) {
38920     RECEIVE_PACKET_FIELD_ERROR(exclude);
38921   }
38922   if (!DIO_BV_GET(&din, real_packet->nations)) {
38923     RECEIVE_PACKET_FIELD_ERROR(nations);
38924   }
38925 
38926   log_packet_detailed("packet_edit_startpos_full_100: got info about ()");
38927   RECEIVE_PACKET_END(real_packet);
38928 }
38929 
send_packet_edit_startpos_full_100(struct connection * pc,const struct packet_edit_startpos_full * packet)38930 static int send_packet_edit_startpos_full_100(struct connection *pc, const struct packet_edit_startpos_full *packet)
38931 {
38932   const struct packet_edit_startpos_full *real_packet = packet;
38933   SEND_PACKET_START(PACKET_EDIT_STARTPOS_FULL);
38934 
38935   log_packet_detailed("packet_edit_startpos_full_100: sending info about ()");
38936 
38937   DIO_PUT(sint32, &dout, "id", real_packet->id);
38938   DIO_PUT(bool8, &dout, "exclude", real_packet->exclude);
38939 DIO_BV_PUT(&dout, "nations", packet->nations);
38940 
38941   SEND_PACKET_END(PACKET_EDIT_STARTPOS_FULL);
38942 }
38943 
send_packet_edit_startpos_full(struct connection * pc,const struct packet_edit_startpos_full * packet)38944 int send_packet_edit_startpos_full(struct connection *pc, const struct packet_edit_startpos_full *packet)
38945 {
38946   if (!pc->used) {
38947     log_error("WARNING: trying to send data to the closed connection %s",
38948               conn_description(pc));
38949     return -1;
38950   }
38951   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_STARTPOS_FULL].packet != NULL, -1,
38952                         "Handler for PACKET_EDIT_STARTPOS_FULL not installed");
38953   return pc->phs.handlers->send[PACKET_EDIT_STARTPOS_FULL].packet(pc, packet);
38954 }
38955 
hash_packet_edit_tile_100(const void * vkey)38956 static genhash_val_t hash_packet_edit_tile_100(const void *vkey)
38957 {
38958   const struct packet_edit_tile *key = (const struct packet_edit_tile *) vkey;
38959 
38960   return key->tile;
38961 }
38962 
cmp_packet_edit_tile_100(const void * vkey1,const void * vkey2)38963 static bool cmp_packet_edit_tile_100(const void *vkey1, const void *vkey2)
38964 {
38965   const struct packet_edit_tile *key1 = (const struct packet_edit_tile *) vkey1;
38966   const struct packet_edit_tile *key2 = (const struct packet_edit_tile *) vkey2;
38967 
38968   return key1->tile == key2->tile;
38969 }
38970 
38971 BV_DEFINE(packet_edit_tile_100_fields, 5);
38972 
receive_packet_edit_tile_100(struct connection * pc)38973 static struct packet_edit_tile *receive_packet_edit_tile_100(struct connection *pc)
38974 {
38975   packet_edit_tile_100_fields fields;
38976   struct packet_edit_tile *old;
38977   struct genhash **hash = pc->phs.received + PACKET_EDIT_TILE;
38978   RECEIVE_PACKET_START(packet_edit_tile, real_packet);
38979 
38980   DIO_BV_GET(&din, fields);
38981   if (!DIO_GET(sint32, &din, "tile", &real_packet->tile)) {
38982     RECEIVE_PACKET_FIELD_ERROR(tile);
38983   }
38984 
38985   log_packet_detailed("packet_edit_tile_100: got info about (%d)",
38986     real_packet->tile);
38987 
38988   if (NULL == *hash) {
38989     *hash = genhash_new_full(hash_packet_edit_tile_100, cmp_packet_edit_tile_100,
38990                              NULL, NULL, NULL, free);
38991   }
38992 
38993   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
38994     *real_packet = *old;
38995   } else {
38996     int tile = real_packet->tile;
38997 
38998     log_packet_detailed("  no old info");
38999     memset(real_packet, 0, sizeof(*real_packet));
39000 
39001     real_packet->tile = tile;
39002   }
39003 
39004   if (BV_ISSET(fields, 0)) {
39005     log_packet_detailed("  got field 'extras'");
39006     if (!DIO_BV_GET(&din, real_packet->extras)) {
39007       RECEIVE_PACKET_FIELD_ERROR(extras);
39008     }
39009   }
39010   if (BV_ISSET(fields, 1)) {
39011     log_packet_detailed("  got field 'resource'");
39012     {
39013       int readin;
39014 
39015       if (!DIO_GET(uint8, &din, "resource", &readin)) {
39016         RECEIVE_PACKET_FIELD_ERROR(resource);
39017       }
39018       real_packet->resource = readin;
39019     }
39020   }
39021   if (BV_ISSET(fields, 2)) {
39022     log_packet_detailed("  got field 'terrain'");
39023     {
39024       int readin;
39025 
39026       if (!DIO_GET(uint8, &din, "terrain", &readin)) {
39027         RECEIVE_PACKET_FIELD_ERROR(terrain);
39028       }
39029       real_packet->terrain = readin;
39030     }
39031   }
39032   if (BV_ISSET(fields, 3)) {
39033     log_packet_detailed("  got field 'startpos_nation'");
39034     {
39035       int readin;
39036 
39037       if (!DIO_GET(sint16, &din, "startpos_nation", &readin)) {
39038         RECEIVE_PACKET_FIELD_ERROR(startpos_nation);
39039       }
39040       real_packet->startpos_nation = readin;
39041     }
39042   }
39043   if (BV_ISSET(fields, 4)) {
39044     log_packet_detailed("  got field 'label'");
39045     if (!DIO_GET(string, &din, "label", real_packet->label, sizeof(real_packet->label))) {
39046       RECEIVE_PACKET_FIELD_ERROR(label);
39047     }
39048   }
39049 
39050   if (NULL == old) {
39051     old = fc_malloc(sizeof(*old));
39052     *old = *real_packet;
39053     genhash_insert(*hash, old, old);
39054   } else {
39055     *old = *real_packet;
39056   }
39057   RECEIVE_PACKET_END(real_packet);
39058 }
39059 
send_packet_edit_tile_100(struct connection * pc,const struct packet_edit_tile * packet)39060 static int send_packet_edit_tile_100(struct connection *pc, const struct packet_edit_tile *packet)
39061 {
39062   const struct packet_edit_tile *real_packet = packet;
39063   packet_edit_tile_100_fields fields;
39064   struct packet_edit_tile *old;
39065   bool differ;
39066   struct genhash **hash = pc->phs.sent + PACKET_EDIT_TILE;
39067   int different = 0;
39068   SEND_PACKET_START(PACKET_EDIT_TILE);
39069 
39070   log_packet_detailed("packet_edit_tile_100: sending info about (%d)",
39071     real_packet->tile);
39072 
39073   if (NULL == *hash) {
39074     *hash = genhash_new_full(hash_packet_edit_tile_100, cmp_packet_edit_tile_100,
39075                              NULL, NULL, NULL, free);
39076   }
39077   BV_CLR_ALL(fields);
39078 
39079   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
39080     old = fc_malloc(sizeof(*old));
39081     *old = *real_packet;
39082     genhash_insert(*hash, old, old);
39083     memset(old, 0, sizeof(*old));
39084     different = 1;      /* Force to send. */
39085   }
39086 
39087   differ = !BV_ARE_EQUAL(old->extras, real_packet->extras);
39088   if (differ) {
39089     different++;
39090     BV_SET(fields, 0);
39091   }
39092 
39093   differ = (old->resource != real_packet->resource);
39094   if (differ) {
39095     different++;
39096     BV_SET(fields, 1);
39097   }
39098 
39099   differ = (old->terrain != real_packet->terrain);
39100   if (differ) {
39101     different++;
39102     BV_SET(fields, 2);
39103   }
39104 
39105   differ = (old->startpos_nation != real_packet->startpos_nation);
39106   if (differ) {
39107     different++;
39108     BV_SET(fields, 3);
39109   }
39110 
39111   differ = (strcmp(old->label, real_packet->label) != 0);
39112   if (differ) {
39113     different++;
39114     BV_SET(fields, 4);
39115   }
39116 
39117 
39118   DIO_BV_PUT(&dout, "fields", fields);
39119   DIO_PUT(sint32, &dout, "tile", real_packet->tile);
39120 
39121   if (BV_ISSET(fields, 0)) {
39122     log_packet_detailed("  field 'extras' has changed");
39123   DIO_BV_PUT(&dout, "extras", packet->extras);
39124   }
39125   if (BV_ISSET(fields, 1)) {
39126     log_packet_detailed("  field 'resource' has changed");
39127     DIO_PUT(uint8, &dout, "resource", real_packet->resource);
39128   }
39129   if (BV_ISSET(fields, 2)) {
39130     log_packet_detailed("  field 'terrain' has changed");
39131     DIO_PUT(uint8, &dout, "terrain", real_packet->terrain);
39132   }
39133   if (BV_ISSET(fields, 3)) {
39134     log_packet_detailed("  field 'startpos_nation' has changed");
39135     DIO_PUT(sint16, &dout, "startpos_nation", real_packet->startpos_nation);
39136   }
39137   if (BV_ISSET(fields, 4)) {
39138     log_packet_detailed("  field 'label' has changed");
39139     DIO_PUT(string, &dout, "label", real_packet->label);
39140   }
39141 
39142   *old = *real_packet;
39143   SEND_PACKET_END(PACKET_EDIT_TILE);
39144 }
39145 
send_packet_edit_tile(struct connection * pc,const struct packet_edit_tile * packet)39146 int send_packet_edit_tile(struct connection *pc, const struct packet_edit_tile *packet)
39147 {
39148   if (!pc->used) {
39149     log_error("WARNING: trying to send data to the closed connection %s",
39150               conn_description(pc));
39151     return -1;
39152   }
39153   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_TILE].packet != NULL, -1,
39154                         "Handler for PACKET_EDIT_TILE not installed");
39155   return pc->phs.handlers->send[PACKET_EDIT_TILE].packet(pc, packet);
39156 }
39157 
39158 #define hash_packet_edit_unit_create_100 hash_const
39159 
39160 #define cmp_packet_edit_unit_create_100 cmp_const
39161 
39162 BV_DEFINE(packet_edit_unit_create_100_fields, 5);
39163 
receive_packet_edit_unit_create_100(struct connection * pc)39164 static struct packet_edit_unit_create *receive_packet_edit_unit_create_100(struct connection *pc)
39165 {
39166   packet_edit_unit_create_100_fields fields;
39167   struct packet_edit_unit_create *old;
39168   struct genhash **hash = pc->phs.received + PACKET_EDIT_UNIT_CREATE;
39169   RECEIVE_PACKET_START(packet_edit_unit_create, real_packet);
39170 
39171   DIO_BV_GET(&din, fields);
39172 
39173   log_packet_detailed("packet_edit_unit_create_100: got info about ()");
39174 
39175   if (NULL == *hash) {
39176     *hash = genhash_new_full(hash_packet_edit_unit_create_100, cmp_packet_edit_unit_create_100,
39177                              NULL, NULL, NULL, free);
39178   }
39179 
39180   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
39181     *real_packet = *old;
39182   } else {
39183     log_packet_detailed("  no old info");
39184     memset(real_packet, 0, sizeof(*real_packet));
39185   }
39186 
39187   if (BV_ISSET(fields, 0)) {
39188     log_packet_detailed("  got field 'owner'");
39189     if (!DIO_GET(uint8, &din, "owner", &real_packet->owner)) {
39190       RECEIVE_PACKET_FIELD_ERROR(owner);
39191     }
39192   }
39193   if (BV_ISSET(fields, 1)) {
39194     log_packet_detailed("  got field 'tile'");
39195     if (!DIO_GET(sint32, &din, "tile", &real_packet->tile)) {
39196       RECEIVE_PACKET_FIELD_ERROR(tile);
39197     }
39198   }
39199   if (BV_ISSET(fields, 2)) {
39200     log_packet_detailed("  got field 'type'");
39201     {
39202       int readin;
39203 
39204       if (!DIO_GET(uint8, &din, "type", &readin)) {
39205         RECEIVE_PACKET_FIELD_ERROR(type);
39206       }
39207       real_packet->type = readin;
39208     }
39209   }
39210   if (BV_ISSET(fields, 3)) {
39211     log_packet_detailed("  got field 'count'");
39212     if (!DIO_GET(uint8, &din, "count", &real_packet->count)) {
39213       RECEIVE_PACKET_FIELD_ERROR(count);
39214     }
39215   }
39216   if (BV_ISSET(fields, 4)) {
39217     log_packet_detailed("  got field 'tag'");
39218     if (!DIO_GET(sint32, &din, "tag", &real_packet->tag)) {
39219       RECEIVE_PACKET_FIELD_ERROR(tag);
39220     }
39221   }
39222 
39223   if (NULL == old) {
39224     old = fc_malloc(sizeof(*old));
39225     *old = *real_packet;
39226     genhash_insert(*hash, old, old);
39227   } else {
39228     *old = *real_packet;
39229   }
39230   RECEIVE_PACKET_END(real_packet);
39231 }
39232 
send_packet_edit_unit_create_100(struct connection * pc,const struct packet_edit_unit_create * packet)39233 static int send_packet_edit_unit_create_100(struct connection *pc, const struct packet_edit_unit_create *packet)
39234 {
39235   const struct packet_edit_unit_create *real_packet = packet;
39236   packet_edit_unit_create_100_fields fields;
39237   struct packet_edit_unit_create *old;
39238   bool differ;
39239   struct genhash **hash = pc->phs.sent + PACKET_EDIT_UNIT_CREATE;
39240   int different = 0;
39241   SEND_PACKET_START(PACKET_EDIT_UNIT_CREATE);
39242 
39243   log_packet_detailed("packet_edit_unit_create_100: sending info about ()");
39244 
39245   if (NULL == *hash) {
39246     *hash = genhash_new_full(hash_packet_edit_unit_create_100, cmp_packet_edit_unit_create_100,
39247                              NULL, NULL, NULL, free);
39248   }
39249   BV_CLR_ALL(fields);
39250 
39251   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
39252     old = fc_malloc(sizeof(*old));
39253     *old = *real_packet;
39254     genhash_insert(*hash, old, old);
39255     memset(old, 0, sizeof(*old));
39256     different = 1;      /* Force to send. */
39257   }
39258 
39259   differ = (old->owner != real_packet->owner);
39260   if (differ) {
39261     different++;
39262     BV_SET(fields, 0);
39263   }
39264 
39265   differ = (old->tile != real_packet->tile);
39266   if (differ) {
39267     different++;
39268     BV_SET(fields, 1);
39269   }
39270 
39271   differ = (old->type != real_packet->type);
39272   if (differ) {
39273     different++;
39274     BV_SET(fields, 2);
39275   }
39276 
39277   differ = (old->count != real_packet->count);
39278   if (differ) {
39279     different++;
39280     BV_SET(fields, 3);
39281   }
39282 
39283   differ = (old->tag != real_packet->tag);
39284   if (differ) {
39285     different++;
39286     BV_SET(fields, 4);
39287   }
39288 
39289 
39290   DIO_BV_PUT(&dout, "fields", fields);
39291 
39292   if (BV_ISSET(fields, 0)) {
39293     log_packet_detailed("  field 'owner' has changed");
39294     DIO_PUT(uint8, &dout, "owner", real_packet->owner);
39295   }
39296   if (BV_ISSET(fields, 1)) {
39297     log_packet_detailed("  field 'tile' has changed");
39298     DIO_PUT(sint32, &dout, "tile", real_packet->tile);
39299   }
39300   if (BV_ISSET(fields, 2)) {
39301     log_packet_detailed("  field 'type' has changed");
39302     DIO_PUT(uint8, &dout, "type", real_packet->type);
39303   }
39304   if (BV_ISSET(fields, 3)) {
39305     log_packet_detailed("  field 'count' has changed");
39306     DIO_PUT(uint8, &dout, "count", real_packet->count);
39307   }
39308   if (BV_ISSET(fields, 4)) {
39309     log_packet_detailed("  field 'tag' has changed");
39310     DIO_PUT(sint32, &dout, "tag", real_packet->tag);
39311   }
39312 
39313   *old = *real_packet;
39314   SEND_PACKET_END(PACKET_EDIT_UNIT_CREATE);
39315 }
39316 
send_packet_edit_unit_create(struct connection * pc,const struct packet_edit_unit_create * packet)39317 int send_packet_edit_unit_create(struct connection *pc, const struct packet_edit_unit_create *packet)
39318 {
39319   if (!pc->used) {
39320     log_error("WARNING: trying to send data to the closed connection %s",
39321               conn_description(pc));
39322     return -1;
39323   }
39324   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_UNIT_CREATE].packet != NULL, -1,
39325                         "Handler for PACKET_EDIT_UNIT_CREATE not installed");
39326   return pc->phs.handlers->send[PACKET_EDIT_UNIT_CREATE].packet(pc, packet);
39327 }
39328 
dsend_packet_edit_unit_create(struct connection * pc,int owner,int tile,Unit_type_id type,int count,int tag)39329 int dsend_packet_edit_unit_create(struct connection *pc, int owner, int tile, Unit_type_id type, int count, int tag)
39330 {
39331   struct packet_edit_unit_create packet, *real_packet = &packet;
39332 
39333   real_packet->owner = owner;
39334   real_packet->tile = tile;
39335   real_packet->type = type;
39336   real_packet->count = count;
39337   real_packet->tag = tag;
39338 
39339   return send_packet_edit_unit_create(pc, real_packet);
39340 }
39341 
39342 #define hash_packet_edit_unit_remove_100 hash_const
39343 
39344 #define cmp_packet_edit_unit_remove_100 cmp_const
39345 
39346 BV_DEFINE(packet_edit_unit_remove_100_fields, 4);
39347 
receive_packet_edit_unit_remove_100(struct connection * pc)39348 static struct packet_edit_unit_remove *receive_packet_edit_unit_remove_100(struct connection *pc)
39349 {
39350   packet_edit_unit_remove_100_fields fields;
39351   struct packet_edit_unit_remove *old;
39352   struct genhash **hash = pc->phs.received + PACKET_EDIT_UNIT_REMOVE;
39353   RECEIVE_PACKET_START(packet_edit_unit_remove, real_packet);
39354 
39355   DIO_BV_GET(&din, fields);
39356 
39357   log_packet_detailed("packet_edit_unit_remove_100: got info about ()");
39358 
39359   if (NULL == *hash) {
39360     *hash = genhash_new_full(hash_packet_edit_unit_remove_100, cmp_packet_edit_unit_remove_100,
39361                              NULL, NULL, NULL, free);
39362   }
39363 
39364   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
39365     *real_packet = *old;
39366   } else {
39367     log_packet_detailed("  no old info");
39368     memset(real_packet, 0, sizeof(*real_packet));
39369   }
39370 
39371   if (BV_ISSET(fields, 0)) {
39372     log_packet_detailed("  got field 'owner'");
39373     if (!DIO_GET(uint8, &din, "owner", &real_packet->owner)) {
39374       RECEIVE_PACKET_FIELD_ERROR(owner);
39375     }
39376   }
39377   if (BV_ISSET(fields, 1)) {
39378     log_packet_detailed("  got field 'tile'");
39379     if (!DIO_GET(sint32, &din, "tile", &real_packet->tile)) {
39380       RECEIVE_PACKET_FIELD_ERROR(tile);
39381     }
39382   }
39383   if (BV_ISSET(fields, 2)) {
39384     log_packet_detailed("  got field 'type'");
39385     {
39386       int readin;
39387 
39388       if (!DIO_GET(uint8, &din, "type", &readin)) {
39389         RECEIVE_PACKET_FIELD_ERROR(type);
39390       }
39391       real_packet->type = readin;
39392     }
39393   }
39394   if (BV_ISSET(fields, 3)) {
39395     log_packet_detailed("  got field 'count'");
39396     if (!DIO_GET(uint8, &din, "count", &real_packet->count)) {
39397       RECEIVE_PACKET_FIELD_ERROR(count);
39398     }
39399   }
39400 
39401   if (NULL == old) {
39402     old = fc_malloc(sizeof(*old));
39403     *old = *real_packet;
39404     genhash_insert(*hash, old, old);
39405   } else {
39406     *old = *real_packet;
39407   }
39408   RECEIVE_PACKET_END(real_packet);
39409 }
39410 
send_packet_edit_unit_remove_100(struct connection * pc,const struct packet_edit_unit_remove * packet)39411 static int send_packet_edit_unit_remove_100(struct connection *pc, const struct packet_edit_unit_remove *packet)
39412 {
39413   const struct packet_edit_unit_remove *real_packet = packet;
39414   packet_edit_unit_remove_100_fields fields;
39415   struct packet_edit_unit_remove *old;
39416   bool differ;
39417   struct genhash **hash = pc->phs.sent + PACKET_EDIT_UNIT_REMOVE;
39418   int different = 0;
39419   SEND_PACKET_START(PACKET_EDIT_UNIT_REMOVE);
39420 
39421   log_packet_detailed("packet_edit_unit_remove_100: sending info about ()");
39422 
39423   if (NULL == *hash) {
39424     *hash = genhash_new_full(hash_packet_edit_unit_remove_100, cmp_packet_edit_unit_remove_100,
39425                              NULL, NULL, NULL, free);
39426   }
39427   BV_CLR_ALL(fields);
39428 
39429   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
39430     old = fc_malloc(sizeof(*old));
39431     *old = *real_packet;
39432     genhash_insert(*hash, old, old);
39433     memset(old, 0, sizeof(*old));
39434     different = 1;      /* Force to send. */
39435   }
39436 
39437   differ = (old->owner != real_packet->owner);
39438   if (differ) {
39439     different++;
39440     BV_SET(fields, 0);
39441   }
39442 
39443   differ = (old->tile != real_packet->tile);
39444   if (differ) {
39445     different++;
39446     BV_SET(fields, 1);
39447   }
39448 
39449   differ = (old->type != real_packet->type);
39450   if (differ) {
39451     different++;
39452     BV_SET(fields, 2);
39453   }
39454 
39455   differ = (old->count != real_packet->count);
39456   if (differ) {
39457     different++;
39458     BV_SET(fields, 3);
39459   }
39460 
39461 
39462   DIO_BV_PUT(&dout, "fields", fields);
39463 
39464   if (BV_ISSET(fields, 0)) {
39465     log_packet_detailed("  field 'owner' has changed");
39466     DIO_PUT(uint8, &dout, "owner", real_packet->owner);
39467   }
39468   if (BV_ISSET(fields, 1)) {
39469     log_packet_detailed("  field 'tile' has changed");
39470     DIO_PUT(sint32, &dout, "tile", real_packet->tile);
39471   }
39472   if (BV_ISSET(fields, 2)) {
39473     log_packet_detailed("  field 'type' has changed");
39474     DIO_PUT(uint8, &dout, "type", real_packet->type);
39475   }
39476   if (BV_ISSET(fields, 3)) {
39477     log_packet_detailed("  field 'count' has changed");
39478     DIO_PUT(uint8, &dout, "count", real_packet->count);
39479   }
39480 
39481   *old = *real_packet;
39482   SEND_PACKET_END(PACKET_EDIT_UNIT_REMOVE);
39483 }
39484 
send_packet_edit_unit_remove(struct connection * pc,const struct packet_edit_unit_remove * packet)39485 int send_packet_edit_unit_remove(struct connection *pc, const struct packet_edit_unit_remove *packet)
39486 {
39487   if (!pc->used) {
39488     log_error("WARNING: trying to send data to the closed connection %s",
39489               conn_description(pc));
39490     return -1;
39491   }
39492   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_UNIT_REMOVE].packet != NULL, -1,
39493                         "Handler for PACKET_EDIT_UNIT_REMOVE not installed");
39494   return pc->phs.handlers->send[PACKET_EDIT_UNIT_REMOVE].packet(pc, packet);
39495 }
39496 
dsend_packet_edit_unit_remove(struct connection * pc,int owner,int tile,Unit_type_id type,int count)39497 int dsend_packet_edit_unit_remove(struct connection *pc, int owner, int tile, Unit_type_id type, int count)
39498 {
39499   struct packet_edit_unit_remove packet, *real_packet = &packet;
39500 
39501   real_packet->owner = owner;
39502   real_packet->tile = tile;
39503   real_packet->type = type;
39504   real_packet->count = count;
39505 
39506   return send_packet_edit_unit_remove(pc, real_packet);
39507 }
39508 
39509 #define hash_packet_edit_unit_remove_by_id_100 hash_const
39510 
39511 #define cmp_packet_edit_unit_remove_by_id_100 cmp_const
39512 
39513 BV_DEFINE(packet_edit_unit_remove_by_id_100_fields, 1);
39514 
receive_packet_edit_unit_remove_by_id_100(struct connection * pc)39515 static struct packet_edit_unit_remove_by_id *receive_packet_edit_unit_remove_by_id_100(struct connection *pc)
39516 {
39517   packet_edit_unit_remove_by_id_100_fields fields;
39518   struct packet_edit_unit_remove_by_id *old;
39519   struct genhash **hash = pc->phs.received + PACKET_EDIT_UNIT_REMOVE_BY_ID;
39520   RECEIVE_PACKET_START(packet_edit_unit_remove_by_id, real_packet);
39521 
39522   DIO_BV_GET(&din, fields);
39523 
39524   log_packet_detailed("packet_edit_unit_remove_by_id_100: got info about ()");
39525 
39526   if (NULL == *hash) {
39527     *hash = genhash_new_full(hash_packet_edit_unit_remove_by_id_100, cmp_packet_edit_unit_remove_by_id_100,
39528                              NULL, NULL, NULL, free);
39529   }
39530 
39531   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
39532     *real_packet = *old;
39533   } else {
39534     log_packet_detailed("  no old info");
39535     memset(real_packet, 0, sizeof(*real_packet));
39536   }
39537 
39538   if (BV_ISSET(fields, 0)) {
39539     log_packet_detailed("  got field 'id'");
39540     if (!DIO_GET(uint16, &din, "id", &real_packet->id)) {
39541       RECEIVE_PACKET_FIELD_ERROR(id);
39542     }
39543   }
39544 
39545   if (NULL == old) {
39546     old = fc_malloc(sizeof(*old));
39547     *old = *real_packet;
39548     genhash_insert(*hash, old, old);
39549   } else {
39550     *old = *real_packet;
39551   }
39552   RECEIVE_PACKET_END(real_packet);
39553 }
39554 
send_packet_edit_unit_remove_by_id_100(struct connection * pc,const struct packet_edit_unit_remove_by_id * packet)39555 static int send_packet_edit_unit_remove_by_id_100(struct connection *pc, const struct packet_edit_unit_remove_by_id *packet)
39556 {
39557   const struct packet_edit_unit_remove_by_id *real_packet = packet;
39558   packet_edit_unit_remove_by_id_100_fields fields;
39559   struct packet_edit_unit_remove_by_id *old;
39560   bool differ;
39561   struct genhash **hash = pc->phs.sent + PACKET_EDIT_UNIT_REMOVE_BY_ID;
39562   int different = 0;
39563   SEND_PACKET_START(PACKET_EDIT_UNIT_REMOVE_BY_ID);
39564 
39565   log_packet_detailed("packet_edit_unit_remove_by_id_100: sending info about ()");
39566 
39567   if (NULL == *hash) {
39568     *hash = genhash_new_full(hash_packet_edit_unit_remove_by_id_100, cmp_packet_edit_unit_remove_by_id_100,
39569                              NULL, NULL, NULL, free);
39570   }
39571   BV_CLR_ALL(fields);
39572 
39573   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
39574     old = fc_malloc(sizeof(*old));
39575     *old = *real_packet;
39576     genhash_insert(*hash, old, old);
39577     memset(old, 0, sizeof(*old));
39578     different = 1;      /* Force to send. */
39579   }
39580 
39581   differ = (old->id != real_packet->id);
39582   if (differ) {
39583     different++;
39584     BV_SET(fields, 0);
39585   }
39586 
39587 
39588   DIO_BV_PUT(&dout, "fields", fields);
39589 
39590   if (BV_ISSET(fields, 0)) {
39591     log_packet_detailed("  field 'id' has changed");
39592     DIO_PUT(uint16, &dout, "id", real_packet->id);
39593   }
39594 
39595   *old = *real_packet;
39596   SEND_PACKET_END(PACKET_EDIT_UNIT_REMOVE_BY_ID);
39597 }
39598 
send_packet_edit_unit_remove_by_id(struct connection * pc,const struct packet_edit_unit_remove_by_id * packet)39599 int send_packet_edit_unit_remove_by_id(struct connection *pc, const struct packet_edit_unit_remove_by_id *packet)
39600 {
39601   if (!pc->used) {
39602     log_error("WARNING: trying to send data to the closed connection %s",
39603               conn_description(pc));
39604     return -1;
39605   }
39606   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_UNIT_REMOVE_BY_ID].packet != NULL, -1,
39607                         "Handler for PACKET_EDIT_UNIT_REMOVE_BY_ID not installed");
39608   return pc->phs.handlers->send[PACKET_EDIT_UNIT_REMOVE_BY_ID].packet(pc, packet);
39609 }
39610 
dsend_packet_edit_unit_remove_by_id(struct connection * pc,int id)39611 int dsend_packet_edit_unit_remove_by_id(struct connection *pc, int id)
39612 {
39613   struct packet_edit_unit_remove_by_id packet, *real_packet = &packet;
39614 
39615   real_packet->id = id;
39616 
39617   return send_packet_edit_unit_remove_by_id(pc, real_packet);
39618 }
39619 
hash_packet_edit_unit_100(const void * vkey)39620 static genhash_val_t hash_packet_edit_unit_100(const void *vkey)
39621 {
39622   const struct packet_edit_unit *key = (const struct packet_edit_unit *) vkey;
39623 
39624   return key->id;
39625 }
39626 
cmp_packet_edit_unit_100(const void * vkey1,const void * vkey2)39627 static bool cmp_packet_edit_unit_100(const void *vkey1, const void *vkey2)
39628 {
39629   const struct packet_edit_unit *key1 = (const struct packet_edit_unit *) vkey1;
39630   const struct packet_edit_unit *key2 = (const struct packet_edit_unit *) vkey2;
39631 
39632   return key1->id == key2->id;
39633 }
39634 
39635 BV_DEFINE(packet_edit_unit_100_fields, 15);
39636 
receive_packet_edit_unit_100(struct connection * pc)39637 static struct packet_edit_unit *receive_packet_edit_unit_100(struct connection *pc)
39638 {
39639   packet_edit_unit_100_fields fields;
39640   struct packet_edit_unit *old;
39641   struct genhash **hash = pc->phs.received + PACKET_EDIT_UNIT;
39642   RECEIVE_PACKET_START(packet_edit_unit, real_packet);
39643 
39644   DIO_BV_GET(&din, fields);
39645   if (!DIO_GET(uint16, &din, "id", &real_packet->id)) {
39646     RECEIVE_PACKET_FIELD_ERROR(id);
39647   }
39648 
39649   log_packet_detailed("packet_edit_unit_100: got info about (%d)",
39650     real_packet->id);
39651 
39652   if (NULL == *hash) {
39653     *hash = genhash_new_full(hash_packet_edit_unit_100, cmp_packet_edit_unit_100,
39654                              NULL, NULL, NULL, free);
39655   }
39656 
39657   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
39658     *real_packet = *old;
39659   } else {
39660     int id = real_packet->id;
39661 
39662     log_packet_detailed("  no old info");
39663     memset(real_packet, 0, sizeof(*real_packet));
39664 
39665     real_packet->id = id;
39666   }
39667 
39668   if (BV_ISSET(fields, 0)) {
39669     log_packet_detailed("  got field 'utype'");
39670     {
39671       int readin;
39672 
39673       if (!DIO_GET(uint8, &din, "utype", &readin)) {
39674         RECEIVE_PACKET_FIELD_ERROR(utype);
39675       }
39676       real_packet->utype = readin;
39677     }
39678   }
39679   if (BV_ISSET(fields, 1)) {
39680     log_packet_detailed("  got field 'owner'");
39681     if (!DIO_GET(uint8, &din, "owner", &real_packet->owner)) {
39682       RECEIVE_PACKET_FIELD_ERROR(owner);
39683     }
39684   }
39685   if (BV_ISSET(fields, 2)) {
39686     log_packet_detailed("  got field 'homecity'");
39687     if (!DIO_GET(uint16, &din, "homecity", &real_packet->homecity)) {
39688       RECEIVE_PACKET_FIELD_ERROR(homecity);
39689     }
39690   }
39691   if (BV_ISSET(fields, 3)) {
39692     log_packet_detailed("  got field 'moves_left'");
39693     if (!DIO_GET(uint16, &din, "moves_left", &real_packet->moves_left)) {
39694       RECEIVE_PACKET_FIELD_ERROR(moves_left);
39695     }
39696   }
39697   if (BV_ISSET(fields, 4)) {
39698     log_packet_detailed("  got field 'hp'");
39699     if (!DIO_GET(uint8, &din, "hp", &real_packet->hp)) {
39700       RECEIVE_PACKET_FIELD_ERROR(hp);
39701     }
39702   }
39703   if (BV_ISSET(fields, 5)) {
39704     log_packet_detailed("  got field 'veteran'");
39705     if (!DIO_GET(uint8, &din, "veteran", &real_packet->veteran)) {
39706       RECEIVE_PACKET_FIELD_ERROR(veteran);
39707     }
39708   }
39709   if (BV_ISSET(fields, 6)) {
39710     log_packet_detailed("  got field 'fuel'");
39711     if (!DIO_GET(uint8, &din, "fuel", &real_packet->fuel)) {
39712       RECEIVE_PACKET_FIELD_ERROR(fuel);
39713     }
39714   }
39715   if (BV_ISSET(fields, 7)) {
39716     log_packet_detailed("  got field 'activity'");
39717     {
39718       int readin;
39719 
39720       if (!DIO_GET(uint8, &din, "activity", &readin)) {
39721         RECEIVE_PACKET_FIELD_ERROR(activity);
39722       }
39723       real_packet->activity = readin;
39724     }
39725   }
39726   if (BV_ISSET(fields, 8)) {
39727     log_packet_detailed("  got field 'activity_count'");
39728     if (!DIO_GET(uint16, &din, "activity_count", &real_packet->activity_count)) {
39729       RECEIVE_PACKET_FIELD_ERROR(activity_count);
39730     }
39731   }
39732   if (BV_ISSET(fields, 9)) {
39733     log_packet_detailed("  got field 'activity_base'");
39734     {
39735       int readin;
39736 
39737       if (!DIO_GET(sint8, &din, "activity_base", &readin)) {
39738         RECEIVE_PACKET_FIELD_ERROR(activity_base);
39739       }
39740       real_packet->activity_base = readin;
39741     }
39742   }
39743   real_packet->debug = BV_ISSET(fields, 10);
39744   real_packet->moved = BV_ISSET(fields, 11);
39745   real_packet->paradropped = BV_ISSET(fields, 12);
39746   real_packet->done_moving = BV_ISSET(fields, 13);
39747   if (BV_ISSET(fields, 14)) {
39748     log_packet_detailed("  got field 'transported_by'");
39749     if (!DIO_GET(uint16, &din, "transported_by", &real_packet->transported_by)) {
39750       RECEIVE_PACKET_FIELD_ERROR(transported_by);
39751     }
39752   }
39753 
39754   if (NULL == old) {
39755     old = fc_malloc(sizeof(*old));
39756     *old = *real_packet;
39757     genhash_insert(*hash, old, old);
39758   } else {
39759     *old = *real_packet;
39760   }
39761   RECEIVE_PACKET_END(real_packet);
39762 }
39763 
send_packet_edit_unit_100(struct connection * pc,const struct packet_edit_unit * packet)39764 static int send_packet_edit_unit_100(struct connection *pc, const struct packet_edit_unit *packet)
39765 {
39766   const struct packet_edit_unit *real_packet = packet;
39767   packet_edit_unit_100_fields fields;
39768   struct packet_edit_unit *old;
39769   bool differ;
39770   struct genhash **hash = pc->phs.sent + PACKET_EDIT_UNIT;
39771   int different = 0;
39772   SEND_PACKET_START(PACKET_EDIT_UNIT);
39773 
39774   log_packet_detailed("packet_edit_unit_100: sending info about (%d)",
39775     real_packet->id);
39776 
39777   if (NULL == *hash) {
39778     *hash = genhash_new_full(hash_packet_edit_unit_100, cmp_packet_edit_unit_100,
39779                              NULL, NULL, NULL, free);
39780   }
39781   BV_CLR_ALL(fields);
39782 
39783   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
39784     old = fc_malloc(sizeof(*old));
39785     *old = *real_packet;
39786     genhash_insert(*hash, old, old);
39787     memset(old, 0, sizeof(*old));
39788     different = 1;      /* Force to send. */
39789   }
39790 
39791   differ = (old->utype != real_packet->utype);
39792   if (differ) {
39793     different++;
39794     BV_SET(fields, 0);
39795   }
39796 
39797   differ = (old->owner != real_packet->owner);
39798   if (differ) {
39799     different++;
39800     BV_SET(fields, 1);
39801   }
39802 
39803   differ = (old->homecity != real_packet->homecity);
39804   if (differ) {
39805     different++;
39806     BV_SET(fields, 2);
39807   }
39808 
39809   differ = (old->moves_left != real_packet->moves_left);
39810   if (differ) {
39811     different++;
39812     BV_SET(fields, 3);
39813   }
39814 
39815   differ = (old->hp != real_packet->hp);
39816   if (differ) {
39817     different++;
39818     BV_SET(fields, 4);
39819   }
39820 
39821   differ = (old->veteran != real_packet->veteran);
39822   if (differ) {
39823     different++;
39824     BV_SET(fields, 5);
39825   }
39826 
39827   differ = (old->fuel != real_packet->fuel);
39828   if (differ) {
39829     different++;
39830     BV_SET(fields, 6);
39831   }
39832 
39833   differ = (old->activity != real_packet->activity);
39834   if (differ) {
39835     different++;
39836     BV_SET(fields, 7);
39837   }
39838 
39839   differ = (old->activity_count != real_packet->activity_count);
39840   if (differ) {
39841     different++;
39842     BV_SET(fields, 8);
39843   }
39844 
39845   differ = (old->activity_base != real_packet->activity_base);
39846   if (differ) {
39847     different++;
39848     BV_SET(fields, 9);
39849   }
39850 
39851   differ = (old->debug != real_packet->debug);
39852   if (differ) {
39853     different++;
39854   }
39855   if (packet->debug) {
39856     BV_SET(fields, 10);
39857   }
39858 
39859   differ = (old->moved != real_packet->moved);
39860   if (differ) {
39861     different++;
39862   }
39863   if (packet->moved) {
39864     BV_SET(fields, 11);
39865   }
39866 
39867   differ = (old->paradropped != real_packet->paradropped);
39868   if (differ) {
39869     different++;
39870   }
39871   if (packet->paradropped) {
39872     BV_SET(fields, 12);
39873   }
39874 
39875   differ = (old->done_moving != real_packet->done_moving);
39876   if (differ) {
39877     different++;
39878   }
39879   if (packet->done_moving) {
39880     BV_SET(fields, 13);
39881   }
39882 
39883   differ = (old->transported_by != real_packet->transported_by);
39884   if (differ) {
39885     different++;
39886     BV_SET(fields, 14);
39887   }
39888 
39889 
39890   DIO_BV_PUT(&dout, "fields", fields);
39891   DIO_PUT(uint16, &dout, "id", real_packet->id);
39892 
39893   if (BV_ISSET(fields, 0)) {
39894     log_packet_detailed("  field 'utype' has changed");
39895     DIO_PUT(uint8, &dout, "utype", real_packet->utype);
39896   }
39897   if (BV_ISSET(fields, 1)) {
39898     log_packet_detailed("  field 'owner' has changed");
39899     DIO_PUT(uint8, &dout, "owner", real_packet->owner);
39900   }
39901   if (BV_ISSET(fields, 2)) {
39902     log_packet_detailed("  field 'homecity' has changed");
39903     DIO_PUT(uint16, &dout, "homecity", real_packet->homecity);
39904   }
39905   if (BV_ISSET(fields, 3)) {
39906     log_packet_detailed("  field 'moves_left' has changed");
39907     DIO_PUT(uint16, &dout, "moves_left", real_packet->moves_left);
39908   }
39909   if (BV_ISSET(fields, 4)) {
39910     log_packet_detailed("  field 'hp' has changed");
39911     DIO_PUT(uint8, &dout, "hp", real_packet->hp);
39912   }
39913   if (BV_ISSET(fields, 5)) {
39914     log_packet_detailed("  field 'veteran' has changed");
39915     DIO_PUT(uint8, &dout, "veteran", real_packet->veteran);
39916   }
39917   if (BV_ISSET(fields, 6)) {
39918     log_packet_detailed("  field 'fuel' has changed");
39919     DIO_PUT(uint8, &dout, "fuel", real_packet->fuel);
39920   }
39921   if (BV_ISSET(fields, 7)) {
39922     log_packet_detailed("  field 'activity' has changed");
39923     DIO_PUT(uint8, &dout, "activity", real_packet->activity);
39924   }
39925   if (BV_ISSET(fields, 8)) {
39926     log_packet_detailed("  field 'activity_count' has changed");
39927     DIO_PUT(uint16, &dout, "activity_count", real_packet->activity_count);
39928   }
39929   if (BV_ISSET(fields, 9)) {
39930     log_packet_detailed("  field 'activity_base' has changed");
39931     DIO_PUT(sint8, &dout, "activity_base", real_packet->activity_base);
39932   }
39933   /* field 10 is folded into the header */
39934   /* field 11 is folded into the header */
39935   /* field 12 is folded into the header */
39936   /* field 13 is folded into the header */
39937   if (BV_ISSET(fields, 14)) {
39938     log_packet_detailed("  field 'transported_by' has changed");
39939     DIO_PUT(uint16, &dout, "transported_by", real_packet->transported_by);
39940   }
39941 
39942   *old = *real_packet;
39943   SEND_PACKET_END(PACKET_EDIT_UNIT);
39944 }
39945 
send_packet_edit_unit(struct connection * pc,const struct packet_edit_unit * packet)39946 int send_packet_edit_unit(struct connection *pc, const struct packet_edit_unit *packet)
39947 {
39948   if (!pc->used) {
39949     log_error("WARNING: trying to send data to the closed connection %s",
39950               conn_description(pc));
39951     return -1;
39952   }
39953   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_UNIT].packet != NULL, -1,
39954                         "Handler for PACKET_EDIT_UNIT not installed");
39955   return pc->phs.handlers->send[PACKET_EDIT_UNIT].packet(pc, packet);
39956 }
39957 
39958 #define hash_packet_edit_city_create_100 hash_const
39959 
39960 #define cmp_packet_edit_city_create_100 cmp_const
39961 
39962 BV_DEFINE(packet_edit_city_create_100_fields, 4);
39963 
receive_packet_edit_city_create_100(struct connection * pc)39964 static struct packet_edit_city_create *receive_packet_edit_city_create_100(struct connection *pc)
39965 {
39966   packet_edit_city_create_100_fields fields;
39967   struct packet_edit_city_create *old;
39968   struct genhash **hash = pc->phs.received + PACKET_EDIT_CITY_CREATE;
39969   RECEIVE_PACKET_START(packet_edit_city_create, real_packet);
39970 
39971   DIO_BV_GET(&din, fields);
39972 
39973   log_packet_detailed("packet_edit_city_create_100: got info about ()");
39974 
39975   if (NULL == *hash) {
39976     *hash = genhash_new_full(hash_packet_edit_city_create_100, cmp_packet_edit_city_create_100,
39977                              NULL, NULL, NULL, free);
39978   }
39979 
39980   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
39981     *real_packet = *old;
39982   } else {
39983     log_packet_detailed("  no old info");
39984     memset(real_packet, 0, sizeof(*real_packet));
39985   }
39986 
39987   if (BV_ISSET(fields, 0)) {
39988     log_packet_detailed("  got field 'owner'");
39989     if (!DIO_GET(uint8, &din, "owner", &real_packet->owner)) {
39990       RECEIVE_PACKET_FIELD_ERROR(owner);
39991     }
39992   }
39993   if (BV_ISSET(fields, 1)) {
39994     log_packet_detailed("  got field 'tile'");
39995     if (!DIO_GET(sint32, &din, "tile", &real_packet->tile)) {
39996       RECEIVE_PACKET_FIELD_ERROR(tile);
39997     }
39998   }
39999   if (BV_ISSET(fields, 2)) {
40000     log_packet_detailed("  got field 'size'");
40001     if (!DIO_GET(uint8, &din, "size", &real_packet->size)) {
40002       RECEIVE_PACKET_FIELD_ERROR(size);
40003     }
40004   }
40005   if (BV_ISSET(fields, 3)) {
40006     log_packet_detailed("  got field 'tag'");
40007     if (!DIO_GET(sint32, &din, "tag", &real_packet->tag)) {
40008       RECEIVE_PACKET_FIELD_ERROR(tag);
40009     }
40010   }
40011 
40012   if (NULL == old) {
40013     old = fc_malloc(sizeof(*old));
40014     *old = *real_packet;
40015     genhash_insert(*hash, old, old);
40016   } else {
40017     *old = *real_packet;
40018   }
40019   RECEIVE_PACKET_END(real_packet);
40020 }
40021 
send_packet_edit_city_create_100(struct connection * pc,const struct packet_edit_city_create * packet)40022 static int send_packet_edit_city_create_100(struct connection *pc, const struct packet_edit_city_create *packet)
40023 {
40024   const struct packet_edit_city_create *real_packet = packet;
40025   packet_edit_city_create_100_fields fields;
40026   struct packet_edit_city_create *old;
40027   bool differ;
40028   struct genhash **hash = pc->phs.sent + PACKET_EDIT_CITY_CREATE;
40029   int different = 0;
40030   SEND_PACKET_START(PACKET_EDIT_CITY_CREATE);
40031 
40032   log_packet_detailed("packet_edit_city_create_100: sending info about ()");
40033 
40034   if (NULL == *hash) {
40035     *hash = genhash_new_full(hash_packet_edit_city_create_100, cmp_packet_edit_city_create_100,
40036                              NULL, NULL, NULL, free);
40037   }
40038   BV_CLR_ALL(fields);
40039 
40040   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
40041     old = fc_malloc(sizeof(*old));
40042     *old = *real_packet;
40043     genhash_insert(*hash, old, old);
40044     memset(old, 0, sizeof(*old));
40045     different = 1;      /* Force to send. */
40046   }
40047 
40048   differ = (old->owner != real_packet->owner);
40049   if (differ) {
40050     different++;
40051     BV_SET(fields, 0);
40052   }
40053 
40054   differ = (old->tile != real_packet->tile);
40055   if (differ) {
40056     different++;
40057     BV_SET(fields, 1);
40058   }
40059 
40060   differ = (old->size != real_packet->size);
40061   if (differ) {
40062     different++;
40063     BV_SET(fields, 2);
40064   }
40065 
40066   differ = (old->tag != real_packet->tag);
40067   if (differ) {
40068     different++;
40069     BV_SET(fields, 3);
40070   }
40071 
40072 
40073   DIO_BV_PUT(&dout, "fields", fields);
40074 
40075   if (BV_ISSET(fields, 0)) {
40076     log_packet_detailed("  field 'owner' has changed");
40077     DIO_PUT(uint8, &dout, "owner", real_packet->owner);
40078   }
40079   if (BV_ISSET(fields, 1)) {
40080     log_packet_detailed("  field 'tile' has changed");
40081     DIO_PUT(sint32, &dout, "tile", real_packet->tile);
40082   }
40083   if (BV_ISSET(fields, 2)) {
40084     log_packet_detailed("  field 'size' has changed");
40085     DIO_PUT(uint8, &dout, "size", real_packet->size);
40086   }
40087   if (BV_ISSET(fields, 3)) {
40088     log_packet_detailed("  field 'tag' has changed");
40089     DIO_PUT(sint32, &dout, "tag", real_packet->tag);
40090   }
40091 
40092   *old = *real_packet;
40093   SEND_PACKET_END(PACKET_EDIT_CITY_CREATE);
40094 }
40095 
send_packet_edit_city_create(struct connection * pc,const struct packet_edit_city_create * packet)40096 int send_packet_edit_city_create(struct connection *pc, const struct packet_edit_city_create *packet)
40097 {
40098   if (!pc->used) {
40099     log_error("WARNING: trying to send data to the closed connection %s",
40100               conn_description(pc));
40101     return -1;
40102   }
40103   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_CITY_CREATE].packet != NULL, -1,
40104                         "Handler for PACKET_EDIT_CITY_CREATE not installed");
40105   return pc->phs.handlers->send[PACKET_EDIT_CITY_CREATE].packet(pc, packet);
40106 }
40107 
dsend_packet_edit_city_create(struct connection * pc,int owner,int tile,int size,int tag)40108 int dsend_packet_edit_city_create(struct connection *pc, int owner, int tile, int size, int tag)
40109 {
40110   struct packet_edit_city_create packet, *real_packet = &packet;
40111 
40112   real_packet->owner = owner;
40113   real_packet->tile = tile;
40114   real_packet->size = size;
40115   real_packet->tag = tag;
40116 
40117   return send_packet_edit_city_create(pc, real_packet);
40118 }
40119 
40120 #define hash_packet_edit_city_remove_100 hash_const
40121 
40122 #define cmp_packet_edit_city_remove_100 cmp_const
40123 
40124 BV_DEFINE(packet_edit_city_remove_100_fields, 1);
40125 
receive_packet_edit_city_remove_100(struct connection * pc)40126 static struct packet_edit_city_remove *receive_packet_edit_city_remove_100(struct connection *pc)
40127 {
40128   packet_edit_city_remove_100_fields fields;
40129   struct packet_edit_city_remove *old;
40130   struct genhash **hash = pc->phs.received + PACKET_EDIT_CITY_REMOVE;
40131   RECEIVE_PACKET_START(packet_edit_city_remove, real_packet);
40132 
40133   DIO_BV_GET(&din, fields);
40134 
40135   log_packet_detailed("packet_edit_city_remove_100: got info about ()");
40136 
40137   if (NULL == *hash) {
40138     *hash = genhash_new_full(hash_packet_edit_city_remove_100, cmp_packet_edit_city_remove_100,
40139                              NULL, NULL, NULL, free);
40140   }
40141 
40142   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
40143     *real_packet = *old;
40144   } else {
40145     log_packet_detailed("  no old info");
40146     memset(real_packet, 0, sizeof(*real_packet));
40147   }
40148 
40149   if (BV_ISSET(fields, 0)) {
40150     log_packet_detailed("  got field 'id'");
40151     if (!DIO_GET(uint16, &din, "id", &real_packet->id)) {
40152       RECEIVE_PACKET_FIELD_ERROR(id);
40153     }
40154   }
40155 
40156   if (NULL == old) {
40157     old = fc_malloc(sizeof(*old));
40158     *old = *real_packet;
40159     genhash_insert(*hash, old, old);
40160   } else {
40161     *old = *real_packet;
40162   }
40163   RECEIVE_PACKET_END(real_packet);
40164 }
40165 
send_packet_edit_city_remove_100(struct connection * pc,const struct packet_edit_city_remove * packet)40166 static int send_packet_edit_city_remove_100(struct connection *pc, const struct packet_edit_city_remove *packet)
40167 {
40168   const struct packet_edit_city_remove *real_packet = packet;
40169   packet_edit_city_remove_100_fields fields;
40170   struct packet_edit_city_remove *old;
40171   bool differ;
40172   struct genhash **hash = pc->phs.sent + PACKET_EDIT_CITY_REMOVE;
40173   int different = 0;
40174   SEND_PACKET_START(PACKET_EDIT_CITY_REMOVE);
40175 
40176   log_packet_detailed("packet_edit_city_remove_100: sending info about ()");
40177 
40178   if (NULL == *hash) {
40179     *hash = genhash_new_full(hash_packet_edit_city_remove_100, cmp_packet_edit_city_remove_100,
40180                              NULL, NULL, NULL, free);
40181   }
40182   BV_CLR_ALL(fields);
40183 
40184   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
40185     old = fc_malloc(sizeof(*old));
40186     *old = *real_packet;
40187     genhash_insert(*hash, old, old);
40188     memset(old, 0, sizeof(*old));
40189     different = 1;      /* Force to send. */
40190   }
40191 
40192   differ = (old->id != real_packet->id);
40193   if (differ) {
40194     different++;
40195     BV_SET(fields, 0);
40196   }
40197 
40198 
40199   DIO_BV_PUT(&dout, "fields", fields);
40200 
40201   if (BV_ISSET(fields, 0)) {
40202     log_packet_detailed("  field 'id' has changed");
40203     DIO_PUT(uint16, &dout, "id", real_packet->id);
40204   }
40205 
40206   *old = *real_packet;
40207   SEND_PACKET_END(PACKET_EDIT_CITY_REMOVE);
40208 }
40209 
send_packet_edit_city_remove(struct connection * pc,const struct packet_edit_city_remove * packet)40210 int send_packet_edit_city_remove(struct connection *pc, const struct packet_edit_city_remove *packet)
40211 {
40212   if (!pc->used) {
40213     log_error("WARNING: trying to send data to the closed connection %s",
40214               conn_description(pc));
40215     return -1;
40216   }
40217   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_CITY_REMOVE].packet != NULL, -1,
40218                         "Handler for PACKET_EDIT_CITY_REMOVE not installed");
40219   return pc->phs.handlers->send[PACKET_EDIT_CITY_REMOVE].packet(pc, packet);
40220 }
40221 
dsend_packet_edit_city_remove(struct connection * pc,int id)40222 int dsend_packet_edit_city_remove(struct connection *pc, int id)
40223 {
40224   struct packet_edit_city_remove packet, *real_packet = &packet;
40225 
40226   real_packet->id = id;
40227 
40228   return send_packet_edit_city_remove(pc, real_packet);
40229 }
40230 
hash_packet_edit_city_100(const void * vkey)40231 static genhash_val_t hash_packet_edit_city_100(const void *vkey)
40232 {
40233   const struct packet_edit_city *key = (const struct packet_edit_city *) vkey;
40234 
40235   return key->id;
40236 }
40237 
cmp_packet_edit_city_100(const void * vkey1,const void * vkey2)40238 static bool cmp_packet_edit_city_100(const void *vkey1, const void *vkey2)
40239 {
40240   const struct packet_edit_city *key1 = (const struct packet_edit_city *) vkey1;
40241   const struct packet_edit_city *key2 = (const struct packet_edit_city *) vkey2;
40242 
40243   return key1->id == key2->id;
40244 }
40245 
40246 BV_DEFINE(packet_edit_city_100_fields, 29);
40247 
receive_packet_edit_city_100(struct connection * pc)40248 static struct packet_edit_city *receive_packet_edit_city_100(struct connection *pc)
40249 {
40250   packet_edit_city_100_fields fields;
40251   struct packet_edit_city *old;
40252   struct genhash **hash = pc->phs.received + PACKET_EDIT_CITY;
40253   RECEIVE_PACKET_START(packet_edit_city, real_packet);
40254 
40255   DIO_BV_GET(&din, fields);
40256   if (!DIO_GET(uint16, &din, "id", &real_packet->id)) {
40257     RECEIVE_PACKET_FIELD_ERROR(id);
40258   }
40259 
40260   log_packet_detailed("packet_edit_city_100: got info about (%d)",
40261     real_packet->id);
40262 
40263   if (NULL == *hash) {
40264     *hash = genhash_new_full(hash_packet_edit_city_100, cmp_packet_edit_city_100,
40265                              NULL, NULL, NULL, free);
40266   }
40267 
40268   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
40269     *real_packet = *old;
40270   } else {
40271     int id = real_packet->id;
40272 
40273     log_packet_detailed("  no old info");
40274     memset(real_packet, 0, sizeof(*real_packet));
40275 
40276     real_packet->id = id;
40277   }
40278 
40279   if (BV_ISSET(fields, 0)) {
40280     log_packet_detailed("  got field 'name'");
40281     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
40282       RECEIVE_PACKET_FIELD_ERROR(name);
40283     }
40284   }
40285   if (BV_ISSET(fields, 1)) {
40286     log_packet_detailed("  got field 'owner'");
40287     if (!DIO_GET(uint8, &din, "owner", &real_packet->owner)) {
40288       RECEIVE_PACKET_FIELD_ERROR(owner);
40289     }
40290   }
40291   if (BV_ISSET(fields, 2)) {
40292     log_packet_detailed("  got field 'original'");
40293     if (!DIO_GET(uint8, &din, "original", &real_packet->original)) {
40294       RECEIVE_PACKET_FIELD_ERROR(original);
40295     }
40296   }
40297   if (BV_ISSET(fields, 3)) {
40298     log_packet_detailed("  got field 'size'");
40299     if (!DIO_GET(uint8, &din, "size", &real_packet->size)) {
40300       RECEIVE_PACKET_FIELD_ERROR(size);
40301     }
40302   }
40303   if (BV_ISSET(fields, 4)) {
40304     log_packet_detailed("  got field 'history'");
40305     if (!DIO_GET(uint16, &din, "history", &real_packet->history)) {
40306       RECEIVE_PACKET_FIELD_ERROR(history);
40307     }
40308   }
40309   if (BV_ISSET(fields, 5)) {
40310     log_packet_detailed("  got field 'ppl_happy'");
40311 
40312     {
40313       int i;
40314 
40315       for (i = 0; i < 5; i++) {
40316         if (!DIO_GET(uint8, &din, "ppl_happy", &real_packet->ppl_happy[i])) {
40317           RECEIVE_PACKET_FIELD_ERROR(ppl_happy);
40318         }
40319       }
40320     }
40321   }
40322   if (BV_ISSET(fields, 6)) {
40323     log_packet_detailed("  got field 'ppl_content'");
40324 
40325     {
40326       int i;
40327 
40328       for (i = 0; i < 5; i++) {
40329         if (!DIO_GET(uint8, &din, "ppl_content", &real_packet->ppl_content[i])) {
40330           RECEIVE_PACKET_FIELD_ERROR(ppl_content);
40331         }
40332       }
40333     }
40334   }
40335   if (BV_ISSET(fields, 7)) {
40336     log_packet_detailed("  got field 'ppl_unhappy'");
40337 
40338     {
40339       int i;
40340 
40341       for (i = 0; i < 5; i++) {
40342         if (!DIO_GET(uint8, &din, "ppl_unhappy", &real_packet->ppl_unhappy[i])) {
40343           RECEIVE_PACKET_FIELD_ERROR(ppl_unhappy);
40344         }
40345       }
40346     }
40347   }
40348   if (BV_ISSET(fields, 8)) {
40349     log_packet_detailed("  got field 'ppl_angry'");
40350 
40351     {
40352       int i;
40353 
40354       for (i = 0; i < 5; i++) {
40355         if (!DIO_GET(uint8, &din, "ppl_angry", &real_packet->ppl_angry[i])) {
40356           RECEIVE_PACKET_FIELD_ERROR(ppl_angry);
40357         }
40358       }
40359     }
40360   }
40361   if (BV_ISSET(fields, 9)) {
40362     log_packet_detailed("  got field 'specialists_size'");
40363     if (!DIO_GET(uint8, &din, "specialists_size", &real_packet->specialists_size)) {
40364       RECEIVE_PACKET_FIELD_ERROR(specialists_size);
40365     }
40366   }
40367   if (BV_ISSET(fields, 10)) {
40368     log_packet_detailed("  got field 'specialists'");
40369 
40370     {
40371       int i;
40372 
40373       if (real_packet->specialists_size > SP_MAX) {
40374         RECEIVE_PACKET_FIELD_ERROR(specialists, ": truncation array");
40375       }
40376       for (i = 0; i < real_packet->specialists_size; i++) {
40377         if (!DIO_GET(uint8, &din, "specialists", &real_packet->specialists[i])) {
40378           RECEIVE_PACKET_FIELD_ERROR(specialists);
40379         }
40380       }
40381     }
40382   }
40383   if (BV_ISSET(fields, 11)) {
40384     log_packet_detailed("  got field 'trade'");
40385 
40386     {
40387       int i;
40388 
40389       for (i = 0; i < MAX_TRADE_ROUTES; i++) {
40390         if (!DIO_GET(uint16, &din, "trade", &real_packet->trade[i])) {
40391           RECEIVE_PACKET_FIELD_ERROR(trade);
40392         }
40393       }
40394     }
40395   }
40396   if (BV_ISSET(fields, 12)) {
40397     log_packet_detailed("  got field 'food_stock'");
40398     if (!DIO_GET(uint16, &din, "food_stock", &real_packet->food_stock)) {
40399       RECEIVE_PACKET_FIELD_ERROR(food_stock);
40400     }
40401   }
40402   if (BV_ISSET(fields, 13)) {
40403     log_packet_detailed("  got field 'shield_stock'");
40404     if (!DIO_GET(uint16, &din, "shield_stock", &real_packet->shield_stock)) {
40405       RECEIVE_PACKET_FIELD_ERROR(shield_stock);
40406     }
40407   }
40408   real_packet->airlift = BV_ISSET(fields, 14);
40409   real_packet->debug = BV_ISSET(fields, 15);
40410   real_packet->did_buy = BV_ISSET(fields, 16);
40411   real_packet->did_sell = BV_ISSET(fields, 17);
40412   real_packet->was_happy = BV_ISSET(fields, 18);
40413   if (BV_ISSET(fields, 19)) {
40414     log_packet_detailed("  got field 'anarchy'");
40415     if (!DIO_GET(uint8, &din, "anarchy", &real_packet->anarchy)) {
40416       RECEIVE_PACKET_FIELD_ERROR(anarchy);
40417     }
40418   }
40419   if (BV_ISSET(fields, 20)) {
40420     log_packet_detailed("  got field 'rapture'");
40421     if (!DIO_GET(uint8, &din, "rapture", &real_packet->rapture)) {
40422       RECEIVE_PACKET_FIELD_ERROR(rapture);
40423     }
40424   }
40425   if (BV_ISSET(fields, 21)) {
40426     log_packet_detailed("  got field 'steal'");
40427     if (!DIO_GET(uint8, &din, "steal", &real_packet->steal)) {
40428       RECEIVE_PACKET_FIELD_ERROR(steal);
40429     }
40430   }
40431   if (BV_ISSET(fields, 22)) {
40432     log_packet_detailed("  got field 'turn_founded'");
40433     if (!DIO_GET(sint16, &din, "turn_founded", &real_packet->turn_founded)) {
40434       RECEIVE_PACKET_FIELD_ERROR(turn_founded);
40435     }
40436   }
40437   if (BV_ISSET(fields, 23)) {
40438     log_packet_detailed("  got field 'turn_last_built'");
40439     if (!DIO_GET(sint16, &din, "turn_last_built", &real_packet->turn_last_built)) {
40440       RECEIVE_PACKET_FIELD_ERROR(turn_last_built);
40441     }
40442   }
40443   if (BV_ISSET(fields, 24)) {
40444     log_packet_detailed("  got field 'built'");
40445 
40446     for (;;) {
40447       int i;
40448 
40449       if (!DIO_GET(uint8, &din, "built", &i)) {
40450         RECEIVE_PACKET_FIELD_ERROR(built);
40451       }
40452       if (i == 255) {
40453         break;
40454       }
40455       if (i > B_LAST) {
40456         RECEIVE_PACKET_FIELD_ERROR(built,
40457                                    ": unexpected value %d "
40458                                    "(> B_LAST) in array diff",
40459                                    i);
40460       } else {
40461         if (!DIO_GET(sint32, &din, "built", &real_packet->built[i])) {
40462           RECEIVE_PACKET_FIELD_ERROR(built);
40463         }
40464       }
40465     }
40466   }
40467   if (BV_ISSET(fields, 25)) {
40468     log_packet_detailed("  got field 'production_kind'");
40469     if (!DIO_GET(uint8, &din, "production_kind", &real_packet->production_kind)) {
40470       RECEIVE_PACKET_FIELD_ERROR(production_kind);
40471     }
40472   }
40473   if (BV_ISSET(fields, 26)) {
40474     log_packet_detailed("  got field 'production_value'");
40475     if (!DIO_GET(uint8, &din, "production_value", &real_packet->production_value)) {
40476       RECEIVE_PACKET_FIELD_ERROR(production_value);
40477     }
40478   }
40479   if (BV_ISSET(fields, 27)) {
40480     log_packet_detailed("  got field 'last_turns_shield_surplus'");
40481     if (!DIO_GET(uint16, &din, "last_turns_shield_surplus", &real_packet->last_turns_shield_surplus)) {
40482       RECEIVE_PACKET_FIELD_ERROR(last_turns_shield_surplus);
40483     }
40484   }
40485   if (BV_ISSET(fields, 28)) {
40486     log_packet_detailed("  got field 'city_options'");
40487     if (!DIO_BV_GET(&din, real_packet->city_options)) {
40488       RECEIVE_PACKET_FIELD_ERROR(city_options);
40489     }
40490   }
40491 
40492   if (NULL == old) {
40493     old = fc_malloc(sizeof(*old));
40494     *old = *real_packet;
40495     genhash_insert(*hash, old, old);
40496   } else {
40497     *old = *real_packet;
40498   }
40499   RECEIVE_PACKET_END(real_packet);
40500 }
40501 
send_packet_edit_city_100(struct connection * pc,const struct packet_edit_city * packet)40502 static int send_packet_edit_city_100(struct connection *pc, const struct packet_edit_city *packet)
40503 {
40504   const struct packet_edit_city *real_packet = packet;
40505   packet_edit_city_100_fields fields;
40506   struct packet_edit_city *old;
40507   bool differ;
40508   struct genhash **hash = pc->phs.sent + PACKET_EDIT_CITY;
40509   int different = 0;
40510   SEND_PACKET_START(PACKET_EDIT_CITY);
40511 
40512   log_packet_detailed("packet_edit_city_100: sending info about (%d)",
40513     real_packet->id);
40514 
40515   if (NULL == *hash) {
40516     *hash = genhash_new_full(hash_packet_edit_city_100, cmp_packet_edit_city_100,
40517                              NULL, NULL, NULL, free);
40518   }
40519   BV_CLR_ALL(fields);
40520 
40521   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
40522     old = fc_malloc(sizeof(*old));
40523     *old = *real_packet;
40524     genhash_insert(*hash, old, old);
40525     memset(old, 0, sizeof(*old));
40526     different = 1;      /* Force to send. */
40527   }
40528 
40529   differ = (strcmp(old->name, real_packet->name) != 0);
40530   if (differ) {
40531     different++;
40532     BV_SET(fields, 0);
40533   }
40534 
40535   differ = (old->owner != real_packet->owner);
40536   if (differ) {
40537     different++;
40538     BV_SET(fields, 1);
40539   }
40540 
40541   differ = (old->original != real_packet->original);
40542   if (differ) {
40543     different++;
40544     BV_SET(fields, 2);
40545   }
40546 
40547   differ = (old->size != real_packet->size);
40548   if (differ) {
40549     different++;
40550     BV_SET(fields, 3);
40551   }
40552 
40553   differ = (old->history != real_packet->history);
40554   if (differ) {
40555     different++;
40556     BV_SET(fields, 4);
40557   }
40558 
40559 
40560     {
40561       differ = (5 != 5);
40562       if (!differ) {
40563         int i;
40564 
40565         for (i = 0; i < 5; i++) {
40566           if (old->ppl_happy[i] != real_packet->ppl_happy[i]) {
40567             differ = TRUE;
40568             break;
40569           }
40570         }
40571       }
40572     }
40573   if (differ) {
40574     different++;
40575     BV_SET(fields, 5);
40576   }
40577 
40578 
40579     {
40580       differ = (5 != 5);
40581       if (!differ) {
40582         int i;
40583 
40584         for (i = 0; i < 5; i++) {
40585           if (old->ppl_content[i] != real_packet->ppl_content[i]) {
40586             differ = TRUE;
40587             break;
40588           }
40589         }
40590       }
40591     }
40592   if (differ) {
40593     different++;
40594     BV_SET(fields, 6);
40595   }
40596 
40597 
40598     {
40599       differ = (5 != 5);
40600       if (!differ) {
40601         int i;
40602 
40603         for (i = 0; i < 5; i++) {
40604           if (old->ppl_unhappy[i] != real_packet->ppl_unhappy[i]) {
40605             differ = TRUE;
40606             break;
40607           }
40608         }
40609       }
40610     }
40611   if (differ) {
40612     different++;
40613     BV_SET(fields, 7);
40614   }
40615 
40616 
40617     {
40618       differ = (5 != 5);
40619       if (!differ) {
40620         int i;
40621 
40622         for (i = 0; i < 5; i++) {
40623           if (old->ppl_angry[i] != real_packet->ppl_angry[i]) {
40624             differ = TRUE;
40625             break;
40626           }
40627         }
40628       }
40629     }
40630   if (differ) {
40631     different++;
40632     BV_SET(fields, 8);
40633   }
40634 
40635   differ = (old->specialists_size != real_packet->specialists_size);
40636   if (differ) {
40637     different++;
40638     BV_SET(fields, 9);
40639   }
40640 
40641 
40642     {
40643       differ = (old->specialists_size != real_packet->specialists_size);
40644       if (!differ) {
40645         int i;
40646 
40647         for (i = 0; i < real_packet->specialists_size; i++) {
40648           if (old->specialists[i] != real_packet->specialists[i]) {
40649             differ = TRUE;
40650             break;
40651           }
40652         }
40653       }
40654     }
40655   if (differ) {
40656     different++;
40657     BV_SET(fields, 10);
40658   }
40659 
40660 
40661     {
40662       differ = (MAX_TRADE_ROUTES != MAX_TRADE_ROUTES);
40663       if (!differ) {
40664         int i;
40665 
40666         for (i = 0; i < MAX_TRADE_ROUTES; i++) {
40667           if (old->trade[i] != real_packet->trade[i]) {
40668             differ = TRUE;
40669             break;
40670           }
40671         }
40672       }
40673     }
40674   if (differ) {
40675     different++;
40676     BV_SET(fields, 11);
40677   }
40678 
40679   differ = (old->food_stock != real_packet->food_stock);
40680   if (differ) {
40681     different++;
40682     BV_SET(fields, 12);
40683   }
40684 
40685   differ = (old->shield_stock != real_packet->shield_stock);
40686   if (differ) {
40687     different++;
40688     BV_SET(fields, 13);
40689   }
40690 
40691   differ = (old->airlift != real_packet->airlift);
40692   if (differ) {
40693     different++;
40694   }
40695   if (packet->airlift) {
40696     BV_SET(fields, 14);
40697   }
40698 
40699   differ = (old->debug != real_packet->debug);
40700   if (differ) {
40701     different++;
40702   }
40703   if (packet->debug) {
40704     BV_SET(fields, 15);
40705   }
40706 
40707   differ = (old->did_buy != real_packet->did_buy);
40708   if (differ) {
40709     different++;
40710   }
40711   if (packet->did_buy) {
40712     BV_SET(fields, 16);
40713   }
40714 
40715   differ = (old->did_sell != real_packet->did_sell);
40716   if (differ) {
40717     different++;
40718   }
40719   if (packet->did_sell) {
40720     BV_SET(fields, 17);
40721   }
40722 
40723   differ = (old->was_happy != real_packet->was_happy);
40724   if (differ) {
40725     different++;
40726   }
40727   if (packet->was_happy) {
40728     BV_SET(fields, 18);
40729   }
40730 
40731   differ = (old->anarchy != real_packet->anarchy);
40732   if (differ) {
40733     different++;
40734     BV_SET(fields, 19);
40735   }
40736 
40737   differ = (old->rapture != real_packet->rapture);
40738   if (differ) {
40739     different++;
40740     BV_SET(fields, 20);
40741   }
40742 
40743   differ = (old->steal != real_packet->steal);
40744   if (differ) {
40745     different++;
40746     BV_SET(fields, 21);
40747   }
40748 
40749   differ = (old->turn_founded != real_packet->turn_founded);
40750   if (differ) {
40751     different++;
40752     BV_SET(fields, 22);
40753   }
40754 
40755   differ = (old->turn_last_built != real_packet->turn_last_built);
40756   if (differ) {
40757     different++;
40758     BV_SET(fields, 23);
40759   }
40760 
40761 
40762     {
40763       differ = (B_LAST != B_LAST);
40764       if (!differ) {
40765         int i;
40766 
40767         for (i = 0; i < B_LAST; i++) {
40768           if (old->built[i] != real_packet->built[i]) {
40769             differ = TRUE;
40770             break;
40771           }
40772         }
40773       }
40774     }
40775   if (differ) {
40776     different++;
40777     BV_SET(fields, 24);
40778   }
40779 
40780   differ = (old->production_kind != real_packet->production_kind);
40781   if (differ) {
40782     different++;
40783     BV_SET(fields, 25);
40784   }
40785 
40786   differ = (old->production_value != real_packet->production_value);
40787   if (differ) {
40788     different++;
40789     BV_SET(fields, 26);
40790   }
40791 
40792   differ = (old->last_turns_shield_surplus != real_packet->last_turns_shield_surplus);
40793   if (differ) {
40794     different++;
40795     BV_SET(fields, 27);
40796   }
40797 
40798   differ = !BV_ARE_EQUAL(old->city_options, real_packet->city_options);
40799   if (differ) {
40800     different++;
40801     BV_SET(fields, 28);
40802   }
40803 
40804 
40805   DIO_BV_PUT(&dout, "fields", fields);
40806   DIO_PUT(uint16, &dout, "id", real_packet->id);
40807 
40808   if (BV_ISSET(fields, 0)) {
40809     log_packet_detailed("  field 'name' has changed");
40810     DIO_PUT(string, &dout, "name", real_packet->name);
40811   }
40812   if (BV_ISSET(fields, 1)) {
40813     log_packet_detailed("  field 'owner' has changed");
40814     DIO_PUT(uint8, &dout, "owner", real_packet->owner);
40815   }
40816   if (BV_ISSET(fields, 2)) {
40817     log_packet_detailed("  field 'original' has changed");
40818     DIO_PUT(uint8, &dout, "original", real_packet->original);
40819   }
40820   if (BV_ISSET(fields, 3)) {
40821     log_packet_detailed("  field 'size' has changed");
40822     DIO_PUT(uint8, &dout, "size", real_packet->size);
40823   }
40824   if (BV_ISSET(fields, 4)) {
40825     log_packet_detailed("  field 'history' has changed");
40826     DIO_PUT(uint16, &dout, "history", real_packet->history);
40827   }
40828   if (BV_ISSET(fields, 5)) {
40829     log_packet_detailed("  field 'ppl_happy' has changed");
40830 
40831     {
40832       int i;
40833 
40834       for (i = 0; i < 5; i++) {
40835         dio_put_uint8(&dout, real_packet->ppl_happy[i]);
40836       }
40837     }
40838   }
40839   if (BV_ISSET(fields, 6)) {
40840     log_packet_detailed("  field 'ppl_content' has changed");
40841 
40842     {
40843       int i;
40844 
40845       for (i = 0; i < 5; i++) {
40846         dio_put_uint8(&dout, real_packet->ppl_content[i]);
40847       }
40848     }
40849   }
40850   if (BV_ISSET(fields, 7)) {
40851     log_packet_detailed("  field 'ppl_unhappy' has changed");
40852 
40853     {
40854       int i;
40855 
40856       for (i = 0; i < 5; i++) {
40857         dio_put_uint8(&dout, real_packet->ppl_unhappy[i]);
40858       }
40859     }
40860   }
40861   if (BV_ISSET(fields, 8)) {
40862     log_packet_detailed("  field 'ppl_angry' has changed");
40863 
40864     {
40865       int i;
40866 
40867       for (i = 0; i < 5; i++) {
40868         dio_put_uint8(&dout, real_packet->ppl_angry[i]);
40869       }
40870     }
40871   }
40872   if (BV_ISSET(fields, 9)) {
40873     log_packet_detailed("  field 'specialists_size' has changed");
40874     DIO_PUT(uint8, &dout, "specialists_size", real_packet->specialists_size);
40875   }
40876   if (BV_ISSET(fields, 10)) {
40877     log_packet_detailed("  field 'specialists' has changed");
40878 
40879     {
40880       int i;
40881 
40882       for (i = 0; i < real_packet->specialists_size; i++) {
40883         dio_put_uint8(&dout, real_packet->specialists[i]);
40884       }
40885     }
40886   }
40887   if (BV_ISSET(fields, 11)) {
40888     log_packet_detailed("  field 'trade' has changed");
40889 
40890     {
40891       int i;
40892 
40893       for (i = 0; i < MAX_TRADE_ROUTES; i++) {
40894         dio_put_uint16(&dout, real_packet->trade[i]);
40895       }
40896     }
40897   }
40898   if (BV_ISSET(fields, 12)) {
40899     log_packet_detailed("  field 'food_stock' has changed");
40900     DIO_PUT(uint16, &dout, "food_stock", real_packet->food_stock);
40901   }
40902   if (BV_ISSET(fields, 13)) {
40903     log_packet_detailed("  field 'shield_stock' has changed");
40904     DIO_PUT(uint16, &dout, "shield_stock", real_packet->shield_stock);
40905   }
40906   /* field 14 is folded into the header */
40907   /* field 15 is folded into the header */
40908   /* field 16 is folded into the header */
40909   /* field 17 is folded into the header */
40910   /* field 18 is folded into the header */
40911   if (BV_ISSET(fields, 19)) {
40912     log_packet_detailed("  field 'anarchy' has changed");
40913     DIO_PUT(uint8, &dout, "anarchy", real_packet->anarchy);
40914   }
40915   if (BV_ISSET(fields, 20)) {
40916     log_packet_detailed("  field 'rapture' has changed");
40917     DIO_PUT(uint8, &dout, "rapture", real_packet->rapture);
40918   }
40919   if (BV_ISSET(fields, 21)) {
40920     log_packet_detailed("  field 'steal' has changed");
40921     DIO_PUT(uint8, &dout, "steal", real_packet->steal);
40922   }
40923   if (BV_ISSET(fields, 22)) {
40924     log_packet_detailed("  field 'turn_founded' has changed");
40925     DIO_PUT(sint16, &dout, "turn_founded", real_packet->turn_founded);
40926   }
40927   if (BV_ISSET(fields, 23)) {
40928     log_packet_detailed("  field 'turn_last_built' has changed");
40929     DIO_PUT(sint16, &dout, "turn_last_built", real_packet->turn_last_built);
40930   }
40931   if (BV_ISSET(fields, 24)) {
40932     log_packet_detailed("  field 'built' has changed");
40933 
40934     {
40935       int i;
40936 
40937       fc_assert(B_LAST < 255);
40938 
40939       for (i = 0; i < B_LAST; i++) {
40940         if (old->built[i] != real_packet->built[i]) {
40941           dio_put_uint8(&dout, i);
40942           dio_put_sint32(&dout, real_packet->built[i]);
40943         }
40944       }
40945       dio_put_uint8(&dout, 255);
40946     }
40947   }
40948   if (BV_ISSET(fields, 25)) {
40949     log_packet_detailed("  field 'production_kind' has changed");
40950     DIO_PUT(uint8, &dout, "production_kind", real_packet->production_kind);
40951   }
40952   if (BV_ISSET(fields, 26)) {
40953     log_packet_detailed("  field 'production_value' has changed");
40954     DIO_PUT(uint8, &dout, "production_value", real_packet->production_value);
40955   }
40956   if (BV_ISSET(fields, 27)) {
40957     log_packet_detailed("  field 'last_turns_shield_surplus' has changed");
40958     DIO_PUT(uint16, &dout, "last_turns_shield_surplus", real_packet->last_turns_shield_surplus);
40959   }
40960   if (BV_ISSET(fields, 28)) {
40961     log_packet_detailed("  field 'city_options' has changed");
40962   DIO_BV_PUT(&dout, "city_options", packet->city_options);
40963   }
40964 
40965   *old = *real_packet;
40966   SEND_PACKET_END(PACKET_EDIT_CITY);
40967 }
40968 
send_packet_edit_city(struct connection * pc,const struct packet_edit_city * packet)40969 int send_packet_edit_city(struct connection *pc, const struct packet_edit_city *packet)
40970 {
40971   if (!pc->used) {
40972     log_error("WARNING: trying to send data to the closed connection %s",
40973               conn_description(pc));
40974     return -1;
40975   }
40976   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_CITY].packet != NULL, -1,
40977                         "Handler for PACKET_EDIT_CITY not installed");
40978   return pc->phs.handlers->send[PACKET_EDIT_CITY].packet(pc, packet);
40979 }
40980 
40981 #define hash_packet_edit_player_create_100 hash_const
40982 
40983 #define cmp_packet_edit_player_create_100 cmp_const
40984 
40985 BV_DEFINE(packet_edit_player_create_100_fields, 1);
40986 
receive_packet_edit_player_create_100(struct connection * pc)40987 static struct packet_edit_player_create *receive_packet_edit_player_create_100(struct connection *pc)
40988 {
40989   packet_edit_player_create_100_fields fields;
40990   struct packet_edit_player_create *old;
40991   struct genhash **hash = pc->phs.received + PACKET_EDIT_PLAYER_CREATE;
40992   RECEIVE_PACKET_START(packet_edit_player_create, real_packet);
40993 
40994   DIO_BV_GET(&din, fields);
40995 
40996   log_packet_detailed("packet_edit_player_create_100: got info about ()");
40997 
40998   if (NULL == *hash) {
40999     *hash = genhash_new_full(hash_packet_edit_player_create_100, cmp_packet_edit_player_create_100,
41000                              NULL, NULL, NULL, free);
41001   }
41002 
41003   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
41004     *real_packet = *old;
41005   } else {
41006     log_packet_detailed("  no old info");
41007     memset(real_packet, 0, sizeof(*real_packet));
41008   }
41009 
41010   if (BV_ISSET(fields, 0)) {
41011     log_packet_detailed("  got field 'tag'");
41012     if (!DIO_GET(sint32, &din, "tag", &real_packet->tag)) {
41013       RECEIVE_PACKET_FIELD_ERROR(tag);
41014     }
41015   }
41016 
41017   if (NULL == old) {
41018     old = fc_malloc(sizeof(*old));
41019     *old = *real_packet;
41020     genhash_insert(*hash, old, old);
41021   } else {
41022     *old = *real_packet;
41023   }
41024   RECEIVE_PACKET_END(real_packet);
41025 }
41026 
send_packet_edit_player_create_100(struct connection * pc,const struct packet_edit_player_create * packet)41027 static int send_packet_edit_player_create_100(struct connection *pc, const struct packet_edit_player_create *packet)
41028 {
41029   const struct packet_edit_player_create *real_packet = packet;
41030   packet_edit_player_create_100_fields fields;
41031   struct packet_edit_player_create *old;
41032   bool differ;
41033   struct genhash **hash = pc->phs.sent + PACKET_EDIT_PLAYER_CREATE;
41034   int different = 0;
41035   SEND_PACKET_START(PACKET_EDIT_PLAYER_CREATE);
41036 
41037   log_packet_detailed("packet_edit_player_create_100: sending info about ()");
41038 
41039   if (NULL == *hash) {
41040     *hash = genhash_new_full(hash_packet_edit_player_create_100, cmp_packet_edit_player_create_100,
41041                              NULL, NULL, NULL, free);
41042   }
41043   BV_CLR_ALL(fields);
41044 
41045   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
41046     old = fc_malloc(sizeof(*old));
41047     *old = *real_packet;
41048     genhash_insert(*hash, old, old);
41049     memset(old, 0, sizeof(*old));
41050     different = 1;      /* Force to send. */
41051   }
41052 
41053   differ = (old->tag != real_packet->tag);
41054   if (differ) {
41055     different++;
41056     BV_SET(fields, 0);
41057   }
41058 
41059 
41060   DIO_BV_PUT(&dout, "fields", fields);
41061 
41062   if (BV_ISSET(fields, 0)) {
41063     log_packet_detailed("  field 'tag' has changed");
41064     DIO_PUT(sint32, &dout, "tag", real_packet->tag);
41065   }
41066 
41067   *old = *real_packet;
41068   SEND_PACKET_END(PACKET_EDIT_PLAYER_CREATE);
41069 }
41070 
send_packet_edit_player_create(struct connection * pc,const struct packet_edit_player_create * packet)41071 int send_packet_edit_player_create(struct connection *pc, const struct packet_edit_player_create *packet)
41072 {
41073   if (!pc->used) {
41074     log_error("WARNING: trying to send data to the closed connection %s",
41075               conn_description(pc));
41076     return -1;
41077   }
41078   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_PLAYER_CREATE].packet != NULL, -1,
41079                         "Handler for PACKET_EDIT_PLAYER_CREATE not installed");
41080   return pc->phs.handlers->send[PACKET_EDIT_PLAYER_CREATE].packet(pc, packet);
41081 }
41082 
dsend_packet_edit_player_create(struct connection * pc,int tag)41083 int dsend_packet_edit_player_create(struct connection *pc, int tag)
41084 {
41085   struct packet_edit_player_create packet, *real_packet = &packet;
41086 
41087   real_packet->tag = tag;
41088 
41089   return send_packet_edit_player_create(pc, real_packet);
41090 }
41091 
41092 #define hash_packet_edit_player_remove_100 hash_const
41093 
41094 #define cmp_packet_edit_player_remove_100 cmp_const
41095 
41096 BV_DEFINE(packet_edit_player_remove_100_fields, 1);
41097 
receive_packet_edit_player_remove_100(struct connection * pc)41098 static struct packet_edit_player_remove *receive_packet_edit_player_remove_100(struct connection *pc)
41099 {
41100   packet_edit_player_remove_100_fields fields;
41101   struct packet_edit_player_remove *old;
41102   struct genhash **hash = pc->phs.received + PACKET_EDIT_PLAYER_REMOVE;
41103   RECEIVE_PACKET_START(packet_edit_player_remove, real_packet);
41104 
41105   DIO_BV_GET(&din, fields);
41106 
41107   log_packet_detailed("packet_edit_player_remove_100: got info about ()");
41108 
41109   if (NULL == *hash) {
41110     *hash = genhash_new_full(hash_packet_edit_player_remove_100, cmp_packet_edit_player_remove_100,
41111                              NULL, NULL, NULL, free);
41112   }
41113 
41114   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
41115     *real_packet = *old;
41116   } else {
41117     log_packet_detailed("  no old info");
41118     memset(real_packet, 0, sizeof(*real_packet));
41119   }
41120 
41121   if (BV_ISSET(fields, 0)) {
41122     log_packet_detailed("  got field 'id'");
41123     if (!DIO_GET(uint8, &din, "id", &real_packet->id)) {
41124       RECEIVE_PACKET_FIELD_ERROR(id);
41125     }
41126   }
41127 
41128   if (NULL == old) {
41129     old = fc_malloc(sizeof(*old));
41130     *old = *real_packet;
41131     genhash_insert(*hash, old, old);
41132   } else {
41133     *old = *real_packet;
41134   }
41135   RECEIVE_PACKET_END(real_packet);
41136 }
41137 
send_packet_edit_player_remove_100(struct connection * pc,const struct packet_edit_player_remove * packet)41138 static int send_packet_edit_player_remove_100(struct connection *pc, const struct packet_edit_player_remove *packet)
41139 {
41140   const struct packet_edit_player_remove *real_packet = packet;
41141   packet_edit_player_remove_100_fields fields;
41142   struct packet_edit_player_remove *old;
41143   bool differ;
41144   struct genhash **hash = pc->phs.sent + PACKET_EDIT_PLAYER_REMOVE;
41145   int different = 0;
41146   SEND_PACKET_START(PACKET_EDIT_PLAYER_REMOVE);
41147 
41148   log_packet_detailed("packet_edit_player_remove_100: sending info about ()");
41149 
41150   if (NULL == *hash) {
41151     *hash = genhash_new_full(hash_packet_edit_player_remove_100, cmp_packet_edit_player_remove_100,
41152                              NULL, NULL, NULL, free);
41153   }
41154   BV_CLR_ALL(fields);
41155 
41156   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
41157     old = fc_malloc(sizeof(*old));
41158     *old = *real_packet;
41159     genhash_insert(*hash, old, old);
41160     memset(old, 0, sizeof(*old));
41161     different = 1;      /* Force to send. */
41162   }
41163 
41164   differ = (old->id != real_packet->id);
41165   if (differ) {
41166     different++;
41167     BV_SET(fields, 0);
41168   }
41169 
41170 
41171   DIO_BV_PUT(&dout, "fields", fields);
41172 
41173   if (BV_ISSET(fields, 0)) {
41174     log_packet_detailed("  field 'id' has changed");
41175     DIO_PUT(uint8, &dout, "id", real_packet->id);
41176   }
41177 
41178   *old = *real_packet;
41179   SEND_PACKET_END(PACKET_EDIT_PLAYER_REMOVE);
41180 }
41181 
send_packet_edit_player_remove(struct connection * pc,const struct packet_edit_player_remove * packet)41182 int send_packet_edit_player_remove(struct connection *pc, const struct packet_edit_player_remove *packet)
41183 {
41184   if (!pc->used) {
41185     log_error("WARNING: trying to send data to the closed connection %s",
41186               conn_description(pc));
41187     return -1;
41188   }
41189   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_PLAYER_REMOVE].packet != NULL, -1,
41190                         "Handler for PACKET_EDIT_PLAYER_REMOVE not installed");
41191   return pc->phs.handlers->send[PACKET_EDIT_PLAYER_REMOVE].packet(pc, packet);
41192 }
41193 
dsend_packet_edit_player_remove(struct connection * pc,int id)41194 int dsend_packet_edit_player_remove(struct connection *pc, int id)
41195 {
41196   struct packet_edit_player_remove packet, *real_packet = &packet;
41197 
41198   real_packet->id = id;
41199 
41200   return send_packet_edit_player_remove(pc, real_packet);
41201 }
41202 
hash_packet_edit_player_100(const void * vkey)41203 static genhash_val_t hash_packet_edit_player_100(const void *vkey)
41204 {
41205   const struct packet_edit_player *key = (const struct packet_edit_player *) vkey;
41206 
41207   return key->id;
41208 }
41209 
cmp_packet_edit_player_100(const void * vkey1,const void * vkey2)41210 static bool cmp_packet_edit_player_100(const void *vkey1, const void *vkey2)
41211 {
41212   const struct packet_edit_player *key1 = (const struct packet_edit_player *) vkey1;
41213   const struct packet_edit_player *key2 = (const struct packet_edit_player *) vkey2;
41214 
41215   return key1->id == key2->id;
41216 }
41217 
41218 BV_DEFINE(packet_edit_player_100_fields, 24);
41219 
receive_packet_edit_player_100(struct connection * pc)41220 static struct packet_edit_player *receive_packet_edit_player_100(struct connection *pc)
41221 {
41222   packet_edit_player_100_fields fields;
41223   struct packet_edit_player *old;
41224   struct genhash **hash = pc->phs.received + PACKET_EDIT_PLAYER;
41225   RECEIVE_PACKET_START(packet_edit_player, real_packet);
41226 
41227   DIO_BV_GET(&din, fields);
41228   if (!DIO_GET(uint8, &din, "id", &real_packet->id)) {
41229     RECEIVE_PACKET_FIELD_ERROR(id);
41230   }
41231 
41232   log_packet_detailed("packet_edit_player_100: got info about (%d)",
41233     real_packet->id);
41234 
41235   if (NULL == *hash) {
41236     *hash = genhash_new_full(hash_packet_edit_player_100, cmp_packet_edit_player_100,
41237                              NULL, NULL, NULL, free);
41238   }
41239 
41240   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
41241     *real_packet = *old;
41242   } else {
41243     int id = real_packet->id;
41244 
41245     log_packet_detailed("  no old info");
41246     memset(real_packet, 0, sizeof(*real_packet));
41247 
41248     real_packet->id = id;
41249   }
41250 
41251   if (BV_ISSET(fields, 0)) {
41252     log_packet_detailed("  got field 'name'");
41253     if (!DIO_GET(string, &din, "name", real_packet->name, sizeof(real_packet->name))) {
41254       RECEIVE_PACKET_FIELD_ERROR(name);
41255     }
41256   }
41257   if (BV_ISSET(fields, 1)) {
41258     log_packet_detailed("  got field 'username'");
41259     if (!DIO_GET(string, &din, "username", real_packet->username, sizeof(real_packet->username))) {
41260       RECEIVE_PACKET_FIELD_ERROR(username);
41261     }
41262   }
41263   if (BV_ISSET(fields, 2)) {
41264     log_packet_detailed("  got field 'ranked_username'");
41265     if (!DIO_GET(string, &din, "ranked_username", real_packet->ranked_username, sizeof(real_packet->ranked_username))) {
41266       RECEIVE_PACKET_FIELD_ERROR(ranked_username);
41267     }
41268   }
41269   if (BV_ISSET(fields, 3)) {
41270     log_packet_detailed("  got field 'user_turns'");
41271     if (!DIO_GET(sint16, &din, "user_turns", &real_packet->user_turns)) {
41272       RECEIVE_PACKET_FIELD_ERROR(user_turns);
41273     }
41274   }
41275   real_packet->is_male = BV_ISSET(fields, 4);
41276   if (BV_ISSET(fields, 5)) {
41277     log_packet_detailed("  got field 'government'");
41278     {
41279       int readin;
41280 
41281       if (!DIO_GET(sint8, &din, "government", &readin)) {
41282         RECEIVE_PACKET_FIELD_ERROR(government);
41283       }
41284       real_packet->government = readin;
41285     }
41286   }
41287   if (BV_ISSET(fields, 6)) {
41288     log_packet_detailed("  got field 'target_government'");
41289     {
41290       int readin;
41291 
41292       if (!DIO_GET(sint8, &din, "target_government", &readin)) {
41293         RECEIVE_PACKET_FIELD_ERROR(target_government);
41294       }
41295       real_packet->target_government = readin;
41296     }
41297   }
41298   if (BV_ISSET(fields, 7)) {
41299     log_packet_detailed("  got field 'nation'");
41300     {
41301       int readin;
41302 
41303       if (!DIO_GET(sint16, &din, "nation", &readin)) {
41304         RECEIVE_PACKET_FIELD_ERROR(nation);
41305       }
41306       real_packet->nation = readin;
41307     }
41308   }
41309   if (BV_ISSET(fields, 8)) {
41310     log_packet_detailed("  got field 'team'");
41311     if (!DIO_GET(uint8, &din, "team", &real_packet->team)) {
41312       RECEIVE_PACKET_FIELD_ERROR(team);
41313     }
41314   }
41315   real_packet->phase_done = BV_ISSET(fields, 9);
41316   if (BV_ISSET(fields, 10)) {
41317     log_packet_detailed("  got field 'nturns_idle'");
41318     if (!DIO_GET(sint16, &din, "nturns_idle", &real_packet->nturns_idle)) {
41319       RECEIVE_PACKET_FIELD_ERROR(nturns_idle);
41320     }
41321   }
41322   real_packet->is_alive = BV_ISSET(fields, 11);
41323   if (BV_ISSET(fields, 12)) {
41324     log_packet_detailed("  got field 'revolution_finishes'");
41325     if (!DIO_GET(sint16, &din, "revolution_finishes", &real_packet->revolution_finishes)) {
41326       RECEIVE_PACKET_FIELD_ERROR(revolution_finishes);
41327     }
41328   }
41329   real_packet->capital = BV_ISSET(fields, 13);
41330   if (BV_ISSET(fields, 14)) {
41331     log_packet_detailed("  got field 'embassy'");
41332     if (!DIO_BV_GET(&din, real_packet->embassy)) {
41333       RECEIVE_PACKET_FIELD_ERROR(embassy);
41334     }
41335   }
41336   if (BV_ISSET(fields, 15)) {
41337     log_packet_detailed("  got field 'gold'");
41338     if (!DIO_GET(uint32, &din, "gold", &real_packet->gold)) {
41339       RECEIVE_PACKET_FIELD_ERROR(gold);
41340     }
41341   }
41342   if (BV_ISSET(fields, 16)) {
41343     log_packet_detailed("  got field 'tax'");
41344     if (!DIO_GET(uint8, &din, "tax", &real_packet->tax)) {
41345       RECEIVE_PACKET_FIELD_ERROR(tax);
41346     }
41347   }
41348   if (BV_ISSET(fields, 17)) {
41349     log_packet_detailed("  got field 'science'");
41350     if (!DIO_GET(uint8, &din, "science", &real_packet->science)) {
41351       RECEIVE_PACKET_FIELD_ERROR(science);
41352     }
41353   }
41354   if (BV_ISSET(fields, 18)) {
41355     log_packet_detailed("  got field 'luxury'");
41356     if (!DIO_GET(uint8, &din, "luxury", &real_packet->luxury)) {
41357       RECEIVE_PACKET_FIELD_ERROR(luxury);
41358     }
41359   }
41360   if (BV_ISSET(fields, 19)) {
41361     log_packet_detailed("  got field 'future_tech'");
41362     if (!DIO_GET(uint16, &din, "future_tech", &real_packet->future_tech)) {
41363       RECEIVE_PACKET_FIELD_ERROR(future_tech);
41364     }
41365   }
41366   if (BV_ISSET(fields, 20)) {
41367     log_packet_detailed("  got field 'researching'");
41368     if (!DIO_GET(uint8, &din, "researching", &real_packet->researching)) {
41369       RECEIVE_PACKET_FIELD_ERROR(researching);
41370     }
41371   }
41372   if (BV_ISSET(fields, 21)) {
41373     log_packet_detailed("  got field 'bulbs_researched'");
41374     if (!DIO_GET(uint32, &din, "bulbs_researched", &real_packet->bulbs_researched)) {
41375       RECEIVE_PACKET_FIELD_ERROR(bulbs_researched);
41376     }
41377   }
41378   if (BV_ISSET(fields, 22)) {
41379     log_packet_detailed("  got field 'inventions'");
41380 
41381     for (;;) {
41382       int i;
41383 
41384       if (!DIO_GET(uint8, &din, "inventions", &i)) {
41385         RECEIVE_PACKET_FIELD_ERROR(inventions);
41386       }
41387       if (i == 255) {
41388         break;
41389       }
41390       if (i > A_LAST+1) {
41391         RECEIVE_PACKET_FIELD_ERROR(inventions,
41392                                    ": unexpected value %d "
41393                                    "(> A_LAST+1) in array diff",
41394                                    i);
41395       } else {
41396         if (!DIO_GET(bool8, &din, "inventions", &real_packet->inventions[i])) {
41397           RECEIVE_PACKET_FIELD_ERROR(inventions);
41398         }
41399       }
41400     }
41401   }
41402   real_packet->ai = BV_ISSET(fields, 23);
41403 
41404   if (NULL == old) {
41405     old = fc_malloc(sizeof(*old));
41406     *old = *real_packet;
41407     genhash_insert(*hash, old, old);
41408   } else {
41409     *old = *real_packet;
41410   }
41411   RECEIVE_PACKET_END(real_packet);
41412 }
41413 
send_packet_edit_player_100(struct connection * pc,const struct packet_edit_player * packet)41414 static int send_packet_edit_player_100(struct connection *pc, const struct packet_edit_player *packet)
41415 {
41416   const struct packet_edit_player *real_packet = packet;
41417   packet_edit_player_100_fields fields;
41418   struct packet_edit_player *old;
41419   bool differ;
41420   struct genhash **hash = pc->phs.sent + PACKET_EDIT_PLAYER;
41421   int different = 0;
41422   SEND_PACKET_START(PACKET_EDIT_PLAYER);
41423 
41424   log_packet_detailed("packet_edit_player_100: sending info about (%d)",
41425     real_packet->id);
41426 
41427   if (NULL == *hash) {
41428     *hash = genhash_new_full(hash_packet_edit_player_100, cmp_packet_edit_player_100,
41429                              NULL, NULL, NULL, free);
41430   }
41431   BV_CLR_ALL(fields);
41432 
41433   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
41434     old = fc_malloc(sizeof(*old));
41435     *old = *real_packet;
41436     genhash_insert(*hash, old, old);
41437     memset(old, 0, sizeof(*old));
41438     different = 1;      /* Force to send. */
41439   }
41440 
41441   differ = (strcmp(old->name, real_packet->name) != 0);
41442   if (differ) {
41443     different++;
41444     BV_SET(fields, 0);
41445   }
41446 
41447   differ = (strcmp(old->username, real_packet->username) != 0);
41448   if (differ) {
41449     different++;
41450     BV_SET(fields, 1);
41451   }
41452 
41453   differ = (strcmp(old->ranked_username, real_packet->ranked_username) != 0);
41454   if (differ) {
41455     different++;
41456     BV_SET(fields, 2);
41457   }
41458 
41459   differ = (old->user_turns != real_packet->user_turns);
41460   if (differ) {
41461     different++;
41462     BV_SET(fields, 3);
41463   }
41464 
41465   differ = (old->is_male != real_packet->is_male);
41466   if (differ) {
41467     different++;
41468   }
41469   if (packet->is_male) {
41470     BV_SET(fields, 4);
41471   }
41472 
41473   differ = (old->government != real_packet->government);
41474   if (differ) {
41475     different++;
41476     BV_SET(fields, 5);
41477   }
41478 
41479   differ = (old->target_government != real_packet->target_government);
41480   if (differ) {
41481     different++;
41482     BV_SET(fields, 6);
41483   }
41484 
41485   differ = (old->nation != real_packet->nation);
41486   if (differ) {
41487     different++;
41488     BV_SET(fields, 7);
41489   }
41490 
41491   differ = (old->team != real_packet->team);
41492   if (differ) {
41493     different++;
41494     BV_SET(fields, 8);
41495   }
41496 
41497   differ = (old->phase_done != real_packet->phase_done);
41498   if (differ) {
41499     different++;
41500   }
41501   if (packet->phase_done) {
41502     BV_SET(fields, 9);
41503   }
41504 
41505   differ = (old->nturns_idle != real_packet->nturns_idle);
41506   if (differ) {
41507     different++;
41508     BV_SET(fields, 10);
41509   }
41510 
41511   differ = (old->is_alive != real_packet->is_alive);
41512   if (differ) {
41513     different++;
41514   }
41515   if (packet->is_alive) {
41516     BV_SET(fields, 11);
41517   }
41518 
41519   differ = (old->revolution_finishes != real_packet->revolution_finishes);
41520   if (differ) {
41521     different++;
41522     BV_SET(fields, 12);
41523   }
41524 
41525   differ = (old->capital != real_packet->capital);
41526   if (differ) {
41527     different++;
41528   }
41529   if (packet->capital) {
41530     BV_SET(fields, 13);
41531   }
41532 
41533   differ = !BV_ARE_EQUAL(old->embassy, real_packet->embassy);
41534   if (differ) {
41535     different++;
41536     BV_SET(fields, 14);
41537   }
41538 
41539   differ = (old->gold != real_packet->gold);
41540   if (differ) {
41541     different++;
41542     BV_SET(fields, 15);
41543   }
41544 
41545   differ = (old->tax != real_packet->tax);
41546   if (differ) {
41547     different++;
41548     BV_SET(fields, 16);
41549   }
41550 
41551   differ = (old->science != real_packet->science);
41552   if (differ) {
41553     different++;
41554     BV_SET(fields, 17);
41555   }
41556 
41557   differ = (old->luxury != real_packet->luxury);
41558   if (differ) {
41559     different++;
41560     BV_SET(fields, 18);
41561   }
41562 
41563   differ = (old->future_tech != real_packet->future_tech);
41564   if (differ) {
41565     different++;
41566     BV_SET(fields, 19);
41567   }
41568 
41569   differ = (old->researching != real_packet->researching);
41570   if (differ) {
41571     different++;
41572     BV_SET(fields, 20);
41573   }
41574 
41575   differ = (old->bulbs_researched != real_packet->bulbs_researched);
41576   if (differ) {
41577     different++;
41578     BV_SET(fields, 21);
41579   }
41580 
41581 
41582     {
41583       differ = (A_LAST+1 != A_LAST+1);
41584       if (!differ) {
41585         int i;
41586 
41587         for (i = 0; i < A_LAST+1; i++) {
41588           if (old->inventions[i] != real_packet->inventions[i]) {
41589             differ = TRUE;
41590             break;
41591           }
41592         }
41593       }
41594     }
41595   if (differ) {
41596     different++;
41597     BV_SET(fields, 22);
41598   }
41599 
41600   differ = (old->ai != real_packet->ai);
41601   if (differ) {
41602     different++;
41603   }
41604   if (packet->ai) {
41605     BV_SET(fields, 23);
41606   }
41607 
41608 
41609   DIO_BV_PUT(&dout, "fields", fields);
41610   DIO_PUT(uint8, &dout, "id", real_packet->id);
41611 
41612   if (BV_ISSET(fields, 0)) {
41613     log_packet_detailed("  field 'name' has changed");
41614     DIO_PUT(string, &dout, "name", real_packet->name);
41615   }
41616   if (BV_ISSET(fields, 1)) {
41617     log_packet_detailed("  field 'username' has changed");
41618     DIO_PUT(string, &dout, "username", real_packet->username);
41619   }
41620   if (BV_ISSET(fields, 2)) {
41621     log_packet_detailed("  field 'ranked_username' has changed");
41622     DIO_PUT(string, &dout, "ranked_username", real_packet->ranked_username);
41623   }
41624   if (BV_ISSET(fields, 3)) {
41625     log_packet_detailed("  field 'user_turns' has changed");
41626     DIO_PUT(sint16, &dout, "user_turns", real_packet->user_turns);
41627   }
41628   /* field 4 is folded into the header */
41629   if (BV_ISSET(fields, 5)) {
41630     log_packet_detailed("  field 'government' has changed");
41631     DIO_PUT(sint8, &dout, "government", real_packet->government);
41632   }
41633   if (BV_ISSET(fields, 6)) {
41634     log_packet_detailed("  field 'target_government' has changed");
41635     DIO_PUT(sint8, &dout, "target_government", real_packet->target_government);
41636   }
41637   if (BV_ISSET(fields, 7)) {
41638     log_packet_detailed("  field 'nation' has changed");
41639     DIO_PUT(sint16, &dout, "nation", real_packet->nation);
41640   }
41641   if (BV_ISSET(fields, 8)) {
41642     log_packet_detailed("  field 'team' has changed");
41643     DIO_PUT(uint8, &dout, "team", real_packet->team);
41644   }
41645   /* field 9 is folded into the header */
41646   if (BV_ISSET(fields, 10)) {
41647     log_packet_detailed("  field 'nturns_idle' has changed");
41648     DIO_PUT(sint16, &dout, "nturns_idle", real_packet->nturns_idle);
41649   }
41650   /* field 11 is folded into the header */
41651   if (BV_ISSET(fields, 12)) {
41652     log_packet_detailed("  field 'revolution_finishes' has changed");
41653     DIO_PUT(sint16, &dout, "revolution_finishes", real_packet->revolution_finishes);
41654   }
41655   /* field 13 is folded into the header */
41656   if (BV_ISSET(fields, 14)) {
41657     log_packet_detailed("  field 'embassy' has changed");
41658   DIO_BV_PUT(&dout, "embassy", packet->embassy);
41659   }
41660   if (BV_ISSET(fields, 15)) {
41661     log_packet_detailed("  field 'gold' has changed");
41662     DIO_PUT(uint32, &dout, "gold", real_packet->gold);
41663   }
41664   if (BV_ISSET(fields, 16)) {
41665     log_packet_detailed("  field 'tax' has changed");
41666     DIO_PUT(uint8, &dout, "tax", real_packet->tax);
41667   }
41668   if (BV_ISSET(fields, 17)) {
41669     log_packet_detailed("  field 'science' has changed");
41670     DIO_PUT(uint8, &dout, "science", real_packet->science);
41671   }
41672   if (BV_ISSET(fields, 18)) {
41673     log_packet_detailed("  field 'luxury' has changed");
41674     DIO_PUT(uint8, &dout, "luxury", real_packet->luxury);
41675   }
41676   if (BV_ISSET(fields, 19)) {
41677     log_packet_detailed("  field 'future_tech' has changed");
41678     DIO_PUT(uint16, &dout, "future_tech", real_packet->future_tech);
41679   }
41680   if (BV_ISSET(fields, 20)) {
41681     log_packet_detailed("  field 'researching' has changed");
41682     DIO_PUT(uint8, &dout, "researching", real_packet->researching);
41683   }
41684   if (BV_ISSET(fields, 21)) {
41685     log_packet_detailed("  field 'bulbs_researched' has changed");
41686     DIO_PUT(uint32, &dout, "bulbs_researched", real_packet->bulbs_researched);
41687   }
41688   if (BV_ISSET(fields, 22)) {
41689     log_packet_detailed("  field 'inventions' has changed");
41690 
41691     {
41692       int i;
41693 
41694       fc_assert(A_LAST+1 < 255);
41695 
41696       for (i = 0; i < A_LAST+1; i++) {
41697         if (old->inventions[i] != real_packet->inventions[i]) {
41698           dio_put_uint8(&dout, i);
41699           dio_put_bool8(&dout, real_packet->inventions[i]);
41700         }
41701       }
41702       dio_put_uint8(&dout, 255);
41703     }
41704   }
41705   /* field 23 is folded into the header */
41706 
41707   *old = *real_packet;
41708   SEND_PACKET_END(PACKET_EDIT_PLAYER);
41709 }
41710 
send_packet_edit_player(struct connection * pc,const struct packet_edit_player * packet)41711 int send_packet_edit_player(struct connection *pc, const struct packet_edit_player *packet)
41712 {
41713   if (!pc->used) {
41714     log_error("WARNING: trying to send data to the closed connection %s",
41715               conn_description(pc));
41716     return -1;
41717   }
41718   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_PLAYER].packet != NULL, -1,
41719                         "Handler for PACKET_EDIT_PLAYER not installed");
41720   return pc->phs.handlers->send[PACKET_EDIT_PLAYER].packet(pc, packet);
41721 }
41722 
lsend_packet_edit_player(struct conn_list * dest,const struct packet_edit_player * packet)41723 void lsend_packet_edit_player(struct conn_list *dest, const struct packet_edit_player *packet)
41724 {
41725   conn_list_iterate(dest, pconn) {
41726     send_packet_edit_player(pconn, packet);
41727   } conn_list_iterate_end;
41728 }
41729 
41730 #define hash_packet_edit_player_vision_100 hash_const
41731 
41732 #define cmp_packet_edit_player_vision_100 cmp_const
41733 
41734 BV_DEFINE(packet_edit_player_vision_100_fields, 4);
41735 
receive_packet_edit_player_vision_100(struct connection * pc)41736 static struct packet_edit_player_vision *receive_packet_edit_player_vision_100(struct connection *pc)
41737 {
41738   packet_edit_player_vision_100_fields fields;
41739   struct packet_edit_player_vision *old;
41740   struct genhash **hash = pc->phs.received + PACKET_EDIT_PLAYER_VISION;
41741   RECEIVE_PACKET_START(packet_edit_player_vision, real_packet);
41742 
41743   DIO_BV_GET(&din, fields);
41744 
41745   log_packet_detailed("packet_edit_player_vision_100: got info about ()");
41746 
41747   if (NULL == *hash) {
41748     *hash = genhash_new_full(hash_packet_edit_player_vision_100, cmp_packet_edit_player_vision_100,
41749                              NULL, NULL, NULL, free);
41750   }
41751 
41752   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
41753     *real_packet = *old;
41754   } else {
41755     log_packet_detailed("  no old info");
41756     memset(real_packet, 0, sizeof(*real_packet));
41757   }
41758 
41759   if (BV_ISSET(fields, 0)) {
41760     log_packet_detailed("  got field 'player'");
41761     if (!DIO_GET(uint8, &din, "player", &real_packet->player)) {
41762       RECEIVE_PACKET_FIELD_ERROR(player);
41763     }
41764   }
41765   if (BV_ISSET(fields, 1)) {
41766     log_packet_detailed("  got field 'tile'");
41767     if (!DIO_GET(sint32, &din, "tile", &real_packet->tile)) {
41768       RECEIVE_PACKET_FIELD_ERROR(tile);
41769     }
41770   }
41771   real_packet->known = BV_ISSET(fields, 2);
41772   if (BV_ISSET(fields, 3)) {
41773     log_packet_detailed("  got field 'size'");
41774     if (!DIO_GET(uint8, &din, "size", &real_packet->size)) {
41775       RECEIVE_PACKET_FIELD_ERROR(size);
41776     }
41777   }
41778 
41779   if (NULL == old) {
41780     old = fc_malloc(sizeof(*old));
41781     *old = *real_packet;
41782     genhash_insert(*hash, old, old);
41783   } else {
41784     *old = *real_packet;
41785   }
41786   RECEIVE_PACKET_END(real_packet);
41787 }
41788 
send_packet_edit_player_vision_100(struct connection * pc,const struct packet_edit_player_vision * packet)41789 static int send_packet_edit_player_vision_100(struct connection *pc, const struct packet_edit_player_vision *packet)
41790 {
41791   const struct packet_edit_player_vision *real_packet = packet;
41792   packet_edit_player_vision_100_fields fields;
41793   struct packet_edit_player_vision *old;
41794   bool differ;
41795   struct genhash **hash = pc->phs.sent + PACKET_EDIT_PLAYER_VISION;
41796   int different = 0;
41797   SEND_PACKET_START(PACKET_EDIT_PLAYER_VISION);
41798 
41799   log_packet_detailed("packet_edit_player_vision_100: sending info about ()");
41800 
41801   if (NULL == *hash) {
41802     *hash = genhash_new_full(hash_packet_edit_player_vision_100, cmp_packet_edit_player_vision_100,
41803                              NULL, NULL, NULL, free);
41804   }
41805   BV_CLR_ALL(fields);
41806 
41807   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
41808     old = fc_malloc(sizeof(*old));
41809     *old = *real_packet;
41810     genhash_insert(*hash, old, old);
41811     memset(old, 0, sizeof(*old));
41812     different = 1;      /* Force to send. */
41813   }
41814 
41815   differ = (old->player != real_packet->player);
41816   if (differ) {
41817     different++;
41818     BV_SET(fields, 0);
41819   }
41820 
41821   differ = (old->tile != real_packet->tile);
41822   if (differ) {
41823     different++;
41824     BV_SET(fields, 1);
41825   }
41826 
41827   differ = (old->known != real_packet->known);
41828   if (differ) {
41829     different++;
41830   }
41831   if (packet->known) {
41832     BV_SET(fields, 2);
41833   }
41834 
41835   differ = (old->size != real_packet->size);
41836   if (differ) {
41837     different++;
41838     BV_SET(fields, 3);
41839   }
41840 
41841 
41842   DIO_BV_PUT(&dout, "fields", fields);
41843 
41844   if (BV_ISSET(fields, 0)) {
41845     log_packet_detailed("  field 'player' has changed");
41846     DIO_PUT(uint8, &dout, "player", real_packet->player);
41847   }
41848   if (BV_ISSET(fields, 1)) {
41849     log_packet_detailed("  field 'tile' has changed");
41850     DIO_PUT(sint32, &dout, "tile", real_packet->tile);
41851   }
41852   /* field 2 is folded into the header */
41853   if (BV_ISSET(fields, 3)) {
41854     log_packet_detailed("  field 'size' has changed");
41855     DIO_PUT(uint8, &dout, "size", real_packet->size);
41856   }
41857 
41858   *old = *real_packet;
41859   SEND_PACKET_END(PACKET_EDIT_PLAYER_VISION);
41860 }
41861 
send_packet_edit_player_vision(struct connection * pc,const struct packet_edit_player_vision * packet)41862 int send_packet_edit_player_vision(struct connection *pc, const struct packet_edit_player_vision *packet)
41863 {
41864   if (!pc->used) {
41865     log_error("WARNING: trying to send data to the closed connection %s",
41866               conn_description(pc));
41867     return -1;
41868   }
41869   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_PLAYER_VISION].packet != NULL, -1,
41870                         "Handler for PACKET_EDIT_PLAYER_VISION not installed");
41871   return pc->phs.handlers->send[PACKET_EDIT_PLAYER_VISION].packet(pc, packet);
41872 }
41873 
dsend_packet_edit_player_vision(struct connection * pc,int player,int tile,bool known,int size)41874 int dsend_packet_edit_player_vision(struct connection *pc, int player, int tile, bool known, int size)
41875 {
41876   struct packet_edit_player_vision packet, *real_packet = &packet;
41877 
41878   real_packet->player = player;
41879   real_packet->tile = tile;
41880   real_packet->known = known;
41881   real_packet->size = size;
41882 
41883   return send_packet_edit_player_vision(pc, real_packet);
41884 }
41885 
41886 #define hash_packet_edit_game_100 hash_const
41887 
41888 #define cmp_packet_edit_game_100 cmp_const
41889 
41890 BV_DEFINE(packet_edit_game_100_fields, 9);
41891 
receive_packet_edit_game_100(struct connection * pc)41892 static struct packet_edit_game *receive_packet_edit_game_100(struct connection *pc)
41893 {
41894   packet_edit_game_100_fields fields;
41895   struct packet_edit_game *old;
41896   struct genhash **hash = pc->phs.received + PACKET_EDIT_GAME;
41897   RECEIVE_PACKET_START(packet_edit_game, real_packet);
41898 
41899   DIO_BV_GET(&din, fields);
41900 
41901   log_packet_detailed("packet_edit_game_100: got info about ()");
41902 
41903   if (NULL == *hash) {
41904     *hash = genhash_new_full(hash_packet_edit_game_100, cmp_packet_edit_game_100,
41905                              NULL, NULL, NULL, free);
41906   }
41907 
41908   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
41909     *real_packet = *old;
41910   } else {
41911     log_packet_detailed("  no old info");
41912     memset(real_packet, 0, sizeof(*real_packet));
41913   }
41914 
41915   if (BV_ISSET(fields, 0)) {
41916     log_packet_detailed("  got field 'year32'");
41917     if (!DIO_GET(sint32, &din, "year32", &real_packet->year32)) {
41918       RECEIVE_PACKET_FIELD_ERROR(year32);
41919     }
41920   }
41921   real_packet->scenario = BV_ISSET(fields, 1);
41922   if (BV_ISSET(fields, 2)) {
41923     log_packet_detailed("  got field 'scenario_name'");
41924     if (!DIO_GET(string, &din, "scenario_name", real_packet->scenario_name, sizeof(real_packet->scenario_name))) {
41925       RECEIVE_PACKET_FIELD_ERROR(scenario_name);
41926     }
41927   }
41928   if (BV_ISSET(fields, 3)) {
41929     log_packet_detailed("  got field 'scenario_authors'");
41930     if (!DIO_GET(string, &din, "scenario_authors", real_packet->scenario_authors, sizeof(real_packet->scenario_authors))) {
41931       RECEIVE_PACKET_FIELD_ERROR(scenario_authors);
41932     }
41933   }
41934   real_packet->scenario_random = BV_ISSET(fields, 4);
41935   real_packet->scenario_players = BV_ISSET(fields, 5);
41936   real_packet->startpos_nations = BV_ISSET(fields, 6);
41937   real_packet->prevent_new_cities = BV_ISSET(fields, 7);
41938   real_packet->lake_flooding = BV_ISSET(fields, 8);
41939 
41940   if (NULL == old) {
41941     old = fc_malloc(sizeof(*old));
41942     *old = *real_packet;
41943     genhash_insert(*hash, old, old);
41944   } else {
41945     *old = *real_packet;
41946   }
41947   RECEIVE_PACKET_END(real_packet);
41948 }
41949 
send_packet_edit_game_100(struct connection * pc,const struct packet_edit_game * packet)41950 static int send_packet_edit_game_100(struct connection *pc, const struct packet_edit_game *packet)
41951 {
41952   const struct packet_edit_game *real_packet = packet;
41953   packet_edit_game_100_fields fields;
41954   struct packet_edit_game *old;
41955   bool differ;
41956   struct genhash **hash = pc->phs.sent + PACKET_EDIT_GAME;
41957   int different = 0;
41958   SEND_PACKET_START(PACKET_EDIT_GAME);
41959 
41960   log_packet_detailed("packet_edit_game_100: sending info about ()");
41961 
41962   if (NULL == *hash) {
41963     *hash = genhash_new_full(hash_packet_edit_game_100, cmp_packet_edit_game_100,
41964                              NULL, NULL, NULL, free);
41965   }
41966   BV_CLR_ALL(fields);
41967 
41968   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
41969     old = fc_malloc(sizeof(*old));
41970     *old = *real_packet;
41971     genhash_insert(*hash, old, old);
41972     memset(old, 0, sizeof(*old));
41973     different = 1;      /* Force to send. */
41974   }
41975 
41976   differ = (old->year32 != real_packet->year32);
41977   if (differ) {
41978     different++;
41979     BV_SET(fields, 0);
41980   }
41981 
41982   differ = (old->scenario != real_packet->scenario);
41983   if (differ) {
41984     different++;
41985   }
41986   if (packet->scenario) {
41987     BV_SET(fields, 1);
41988   }
41989 
41990   differ = (strcmp(old->scenario_name, real_packet->scenario_name) != 0);
41991   if (differ) {
41992     different++;
41993     BV_SET(fields, 2);
41994   }
41995 
41996   differ = (strcmp(old->scenario_authors, real_packet->scenario_authors) != 0);
41997   if (differ) {
41998     different++;
41999     BV_SET(fields, 3);
42000   }
42001 
42002   differ = (old->scenario_random != real_packet->scenario_random);
42003   if (differ) {
42004     different++;
42005   }
42006   if (packet->scenario_random) {
42007     BV_SET(fields, 4);
42008   }
42009 
42010   differ = (old->scenario_players != real_packet->scenario_players);
42011   if (differ) {
42012     different++;
42013   }
42014   if (packet->scenario_players) {
42015     BV_SET(fields, 5);
42016   }
42017 
42018   differ = (old->startpos_nations != real_packet->startpos_nations);
42019   if (differ) {
42020     different++;
42021   }
42022   if (packet->startpos_nations) {
42023     BV_SET(fields, 6);
42024   }
42025 
42026   differ = (old->prevent_new_cities != real_packet->prevent_new_cities);
42027   if (differ) {
42028     different++;
42029   }
42030   if (packet->prevent_new_cities) {
42031     BV_SET(fields, 7);
42032   }
42033 
42034   differ = (old->lake_flooding != real_packet->lake_flooding);
42035   if (differ) {
42036     different++;
42037   }
42038   if (packet->lake_flooding) {
42039     BV_SET(fields, 8);
42040   }
42041 
42042 
42043   DIO_BV_PUT(&dout, "fields", fields);
42044 
42045   if (BV_ISSET(fields, 0)) {
42046     log_packet_detailed("  field 'year32' has changed");
42047     DIO_PUT(sint32, &dout, "year32", real_packet->year32);
42048   }
42049   /* field 1 is folded into the header */
42050   if (BV_ISSET(fields, 2)) {
42051     log_packet_detailed("  field 'scenario_name' has changed");
42052     DIO_PUT(string, &dout, "scenario_name", real_packet->scenario_name);
42053   }
42054   if (BV_ISSET(fields, 3)) {
42055     log_packet_detailed("  field 'scenario_authors' has changed");
42056     DIO_PUT(string, &dout, "scenario_authors", real_packet->scenario_authors);
42057   }
42058   /* field 4 is folded into the header */
42059   /* field 5 is folded into the header */
42060   /* field 6 is folded into the header */
42061   /* field 7 is folded into the header */
42062   /* field 8 is folded into the header */
42063 
42064   *old = *real_packet;
42065   SEND_PACKET_END(PACKET_EDIT_GAME);
42066 }
42067 
42068 #define hash_packet_edit_game_101 hash_const
42069 
42070 #define cmp_packet_edit_game_101 cmp_const
42071 
42072 BV_DEFINE(packet_edit_game_101_fields, 9);
42073 
receive_packet_edit_game_101(struct connection * pc)42074 static struct packet_edit_game *receive_packet_edit_game_101(struct connection *pc)
42075 {
42076   packet_edit_game_101_fields fields;
42077   struct packet_edit_game *old;
42078   struct genhash **hash = pc->phs.received + PACKET_EDIT_GAME;
42079   RECEIVE_PACKET_START(packet_edit_game, real_packet);
42080 
42081   DIO_BV_GET(&din, fields);
42082 
42083   log_packet_detailed("packet_edit_game_101: got info about ()");
42084 
42085   if (NULL == *hash) {
42086     *hash = genhash_new_full(hash_packet_edit_game_101, cmp_packet_edit_game_101,
42087                              NULL, NULL, NULL, free);
42088   }
42089 
42090   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
42091     *real_packet = *old;
42092   } else {
42093     log_packet_detailed("  no old info");
42094     memset(real_packet, 0, sizeof(*real_packet));
42095   }
42096 
42097   if (BV_ISSET(fields, 0)) {
42098     log_packet_detailed("  got field 'year16'");
42099     if (!DIO_GET(sint16, &din, "year16", &real_packet->year16)) {
42100       RECEIVE_PACKET_FIELD_ERROR(year16);
42101     }
42102   }
42103   real_packet->scenario = BV_ISSET(fields, 1);
42104   if (BV_ISSET(fields, 2)) {
42105     log_packet_detailed("  got field 'scenario_name'");
42106     if (!DIO_GET(string, &din, "scenario_name", real_packet->scenario_name, sizeof(real_packet->scenario_name))) {
42107       RECEIVE_PACKET_FIELD_ERROR(scenario_name);
42108     }
42109   }
42110   if (BV_ISSET(fields, 3)) {
42111     log_packet_detailed("  got field 'scenario_authors'");
42112     if (!DIO_GET(string, &din, "scenario_authors", real_packet->scenario_authors, sizeof(real_packet->scenario_authors))) {
42113       RECEIVE_PACKET_FIELD_ERROR(scenario_authors);
42114     }
42115   }
42116   real_packet->scenario_random = BV_ISSET(fields, 4);
42117   real_packet->scenario_players = BV_ISSET(fields, 5);
42118   real_packet->startpos_nations = BV_ISSET(fields, 6);
42119   real_packet->prevent_new_cities = BV_ISSET(fields, 7);
42120   real_packet->lake_flooding = BV_ISSET(fields, 8);
42121 
42122   if (NULL == old) {
42123     old = fc_malloc(sizeof(*old));
42124     *old = *real_packet;
42125     genhash_insert(*hash, old, old);
42126   } else {
42127     *old = *real_packet;
42128   }
42129   RECEIVE_PACKET_END(real_packet);
42130 }
42131 
send_packet_edit_game_101(struct connection * pc,const struct packet_edit_game * packet)42132 static int send_packet_edit_game_101(struct connection *pc, const struct packet_edit_game *packet)
42133 {
42134   const struct packet_edit_game *real_packet = packet;
42135   packet_edit_game_101_fields fields;
42136   struct packet_edit_game *old;
42137   bool differ;
42138   struct genhash **hash = pc->phs.sent + PACKET_EDIT_GAME;
42139   int different = 0;
42140   SEND_PACKET_START(PACKET_EDIT_GAME);
42141 
42142   log_packet_detailed("packet_edit_game_101: sending info about ()");
42143 
42144   if (NULL == *hash) {
42145     *hash = genhash_new_full(hash_packet_edit_game_101, cmp_packet_edit_game_101,
42146                              NULL, NULL, NULL, free);
42147   }
42148   BV_CLR_ALL(fields);
42149 
42150   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
42151     old = fc_malloc(sizeof(*old));
42152     *old = *real_packet;
42153     genhash_insert(*hash, old, old);
42154     memset(old, 0, sizeof(*old));
42155     different = 1;      /* Force to send. */
42156   }
42157 
42158   differ = (old->year16 != real_packet->year16);
42159   if (differ) {
42160     different++;
42161     BV_SET(fields, 0);
42162   }
42163 
42164   differ = (old->scenario != real_packet->scenario);
42165   if (differ) {
42166     different++;
42167   }
42168   if (packet->scenario) {
42169     BV_SET(fields, 1);
42170   }
42171 
42172   differ = (strcmp(old->scenario_name, real_packet->scenario_name) != 0);
42173   if (differ) {
42174     different++;
42175     BV_SET(fields, 2);
42176   }
42177 
42178   differ = (strcmp(old->scenario_authors, real_packet->scenario_authors) != 0);
42179   if (differ) {
42180     different++;
42181     BV_SET(fields, 3);
42182   }
42183 
42184   differ = (old->scenario_random != real_packet->scenario_random);
42185   if (differ) {
42186     different++;
42187   }
42188   if (packet->scenario_random) {
42189     BV_SET(fields, 4);
42190   }
42191 
42192   differ = (old->scenario_players != real_packet->scenario_players);
42193   if (differ) {
42194     different++;
42195   }
42196   if (packet->scenario_players) {
42197     BV_SET(fields, 5);
42198   }
42199 
42200   differ = (old->startpos_nations != real_packet->startpos_nations);
42201   if (differ) {
42202     different++;
42203   }
42204   if (packet->startpos_nations) {
42205     BV_SET(fields, 6);
42206   }
42207 
42208   differ = (old->prevent_new_cities != real_packet->prevent_new_cities);
42209   if (differ) {
42210     different++;
42211   }
42212   if (packet->prevent_new_cities) {
42213     BV_SET(fields, 7);
42214   }
42215 
42216   differ = (old->lake_flooding != real_packet->lake_flooding);
42217   if (differ) {
42218     different++;
42219   }
42220   if (packet->lake_flooding) {
42221     BV_SET(fields, 8);
42222   }
42223 
42224 
42225   DIO_BV_PUT(&dout, "fields", fields);
42226 
42227   if (BV_ISSET(fields, 0)) {
42228     log_packet_detailed("  field 'year16' has changed");
42229     DIO_PUT(sint16, &dout, "year16", real_packet->year16);
42230   }
42231   /* field 1 is folded into the header */
42232   if (BV_ISSET(fields, 2)) {
42233     log_packet_detailed("  field 'scenario_name' has changed");
42234     DIO_PUT(string, &dout, "scenario_name", real_packet->scenario_name);
42235   }
42236   if (BV_ISSET(fields, 3)) {
42237     log_packet_detailed("  field 'scenario_authors' has changed");
42238     DIO_PUT(string, &dout, "scenario_authors", real_packet->scenario_authors);
42239   }
42240   /* field 4 is folded into the header */
42241   /* field 5 is folded into the header */
42242   /* field 6 is folded into the header */
42243   /* field 7 is folded into the header */
42244   /* field 8 is folded into the header */
42245 
42246   *old = *real_packet;
42247   SEND_PACKET_END(PACKET_EDIT_GAME);
42248 }
42249 
send_packet_edit_game(struct connection * pc,const struct packet_edit_game * packet)42250 int send_packet_edit_game(struct connection *pc, const struct packet_edit_game *packet)
42251 {
42252   if (!pc->used) {
42253     log_error("WARNING: trying to send data to the closed connection %s",
42254               conn_description(pc));
42255     return -1;
42256   }
42257   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_GAME].packet != NULL, -1,
42258                         "Handler for PACKET_EDIT_GAME not installed");
42259   return pc->phs.handlers->send[PACKET_EDIT_GAME].packet(pc, packet);
42260 }
42261 
42262 #define hash_packet_edit_scenario_desc_100 hash_const
42263 
42264 #define cmp_packet_edit_scenario_desc_100 cmp_const
42265 
42266 BV_DEFINE(packet_edit_scenario_desc_100_fields, 1);
42267 
receive_packet_edit_scenario_desc_100(struct connection * pc)42268 static struct packet_edit_scenario_desc *receive_packet_edit_scenario_desc_100(struct connection *pc)
42269 {
42270   packet_edit_scenario_desc_100_fields fields;
42271   struct packet_edit_scenario_desc *old;
42272   struct genhash **hash = pc->phs.received + PACKET_EDIT_SCENARIO_DESC;
42273   RECEIVE_PACKET_START(packet_edit_scenario_desc, real_packet);
42274 
42275   DIO_BV_GET(&din, fields);
42276 
42277   log_packet_detailed("packet_edit_scenario_desc_100: got info about ()");
42278 
42279   if (NULL == *hash) {
42280     *hash = genhash_new_full(hash_packet_edit_scenario_desc_100, cmp_packet_edit_scenario_desc_100,
42281                              NULL, NULL, NULL, free);
42282   }
42283 
42284   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
42285     *real_packet = *old;
42286   } else {
42287     log_packet_detailed("  no old info");
42288     memset(real_packet, 0, sizeof(*real_packet));
42289   }
42290 
42291   if (BV_ISSET(fields, 0)) {
42292     log_packet_detailed("  got field 'scenario_desc'");
42293     if (!DIO_GET(string, &din, "scenario_desc", real_packet->scenario_desc, sizeof(real_packet->scenario_desc))) {
42294       RECEIVE_PACKET_FIELD_ERROR(scenario_desc);
42295     }
42296   }
42297 
42298   if (NULL == old) {
42299     old = fc_malloc(sizeof(*old));
42300     *old = *real_packet;
42301     genhash_insert(*hash, old, old);
42302   } else {
42303     *old = *real_packet;
42304   }
42305   RECEIVE_PACKET_END(real_packet);
42306 }
42307 
send_packet_edit_scenario_desc_100(struct connection * pc,const struct packet_edit_scenario_desc * packet)42308 static int send_packet_edit_scenario_desc_100(struct connection *pc, const struct packet_edit_scenario_desc *packet)
42309 {
42310   const struct packet_edit_scenario_desc *real_packet = packet;
42311   packet_edit_scenario_desc_100_fields fields;
42312   struct packet_edit_scenario_desc *old;
42313   bool differ;
42314   struct genhash **hash = pc->phs.sent + PACKET_EDIT_SCENARIO_DESC;
42315   int different = 0;
42316   SEND_PACKET_START(PACKET_EDIT_SCENARIO_DESC);
42317 
42318   log_packet_detailed("packet_edit_scenario_desc_100: sending info about ()");
42319 
42320   if (NULL == *hash) {
42321     *hash = genhash_new_full(hash_packet_edit_scenario_desc_100, cmp_packet_edit_scenario_desc_100,
42322                              NULL, NULL, NULL, free);
42323   }
42324   BV_CLR_ALL(fields);
42325 
42326   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
42327     old = fc_malloc(sizeof(*old));
42328     *old = *real_packet;
42329     genhash_insert(*hash, old, old);
42330     memset(old, 0, sizeof(*old));
42331     different = 1;      /* Force to send. */
42332   }
42333 
42334   differ = (strcmp(old->scenario_desc, real_packet->scenario_desc) != 0);
42335   if (differ) {
42336     different++;
42337     BV_SET(fields, 0);
42338   }
42339 
42340 
42341   DIO_BV_PUT(&dout, "fields", fields);
42342 
42343   if (BV_ISSET(fields, 0)) {
42344     log_packet_detailed("  field 'scenario_desc' has changed");
42345     DIO_PUT(string, &dout, "scenario_desc", real_packet->scenario_desc);
42346   }
42347 
42348   *old = *real_packet;
42349   SEND_PACKET_END(PACKET_EDIT_SCENARIO_DESC);
42350 }
42351 
send_packet_edit_scenario_desc(struct connection * pc,const struct packet_edit_scenario_desc * packet)42352 int send_packet_edit_scenario_desc(struct connection *pc, const struct packet_edit_scenario_desc *packet)
42353 {
42354   if (!pc->used) {
42355     log_error("WARNING: trying to send data to the closed connection %s",
42356               conn_description(pc));
42357     return -1;
42358   }
42359   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_SCENARIO_DESC].packet != NULL, -1,
42360                         "Handler for PACKET_EDIT_SCENARIO_DESC not installed");
42361   return pc->phs.handlers->send[PACKET_EDIT_SCENARIO_DESC].packet(pc, packet);
42362 }
42363 
42364 #define hash_packet_edit_object_created_100 hash_const
42365 
42366 #define cmp_packet_edit_object_created_100 cmp_const
42367 
42368 BV_DEFINE(packet_edit_object_created_100_fields, 2);
42369 
receive_packet_edit_object_created_100(struct connection * pc)42370 static struct packet_edit_object_created *receive_packet_edit_object_created_100(struct connection *pc)
42371 {
42372   packet_edit_object_created_100_fields fields;
42373   struct packet_edit_object_created *old;
42374   struct genhash **hash = pc->phs.received + PACKET_EDIT_OBJECT_CREATED;
42375   RECEIVE_PACKET_START(packet_edit_object_created, real_packet);
42376 
42377   DIO_BV_GET(&din, fields);
42378 
42379   log_packet_detailed("packet_edit_object_created_100: got info about ()");
42380 
42381   if (NULL == *hash) {
42382     *hash = genhash_new_full(hash_packet_edit_object_created_100, cmp_packet_edit_object_created_100,
42383                              NULL, NULL, NULL, free);
42384   }
42385 
42386   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
42387     *real_packet = *old;
42388   } else {
42389     log_packet_detailed("  no old info");
42390     memset(real_packet, 0, sizeof(*real_packet));
42391   }
42392 
42393   if (BV_ISSET(fields, 0)) {
42394     log_packet_detailed("  got field 'tag'");
42395     if (!DIO_GET(sint32, &din, "tag", &real_packet->tag)) {
42396       RECEIVE_PACKET_FIELD_ERROR(tag);
42397     }
42398   }
42399   if (BV_ISSET(fields, 1)) {
42400     log_packet_detailed("  got field 'id'");
42401     if (!DIO_GET(sint32, &din, "id", &real_packet->id)) {
42402       RECEIVE_PACKET_FIELD_ERROR(id);
42403     }
42404   }
42405 
42406   if (NULL == old) {
42407     old = fc_malloc(sizeof(*old));
42408     *old = *real_packet;
42409     genhash_insert(*hash, old, old);
42410   } else {
42411     *old = *real_packet;
42412   }
42413   RECEIVE_PACKET_END(real_packet);
42414 }
42415 
send_packet_edit_object_created_100(struct connection * pc,const struct packet_edit_object_created * packet)42416 static int send_packet_edit_object_created_100(struct connection *pc, const struct packet_edit_object_created *packet)
42417 {
42418   const struct packet_edit_object_created *real_packet = packet;
42419   packet_edit_object_created_100_fields fields;
42420   struct packet_edit_object_created *old;
42421   bool differ;
42422   struct genhash **hash = pc->phs.sent + PACKET_EDIT_OBJECT_CREATED;
42423   int different = 0;
42424   SEND_PACKET_START(PACKET_EDIT_OBJECT_CREATED);
42425 
42426   log_packet_detailed("packet_edit_object_created_100: sending info about ()");
42427 
42428   if (NULL == *hash) {
42429     *hash = genhash_new_full(hash_packet_edit_object_created_100, cmp_packet_edit_object_created_100,
42430                              NULL, NULL, NULL, free);
42431   }
42432   BV_CLR_ALL(fields);
42433 
42434   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
42435     old = fc_malloc(sizeof(*old));
42436     *old = *real_packet;
42437     genhash_insert(*hash, old, old);
42438     memset(old, 0, sizeof(*old));
42439     different = 1;      /* Force to send. */
42440   }
42441 
42442   differ = (old->tag != real_packet->tag);
42443   if (differ) {
42444     different++;
42445     BV_SET(fields, 0);
42446   }
42447 
42448   differ = (old->id != real_packet->id);
42449   if (differ) {
42450     different++;
42451     BV_SET(fields, 1);
42452   }
42453 
42454 
42455   DIO_BV_PUT(&dout, "fields", fields);
42456 
42457   if (BV_ISSET(fields, 0)) {
42458     log_packet_detailed("  field 'tag' has changed");
42459     DIO_PUT(sint32, &dout, "tag", real_packet->tag);
42460   }
42461   if (BV_ISSET(fields, 1)) {
42462     log_packet_detailed("  field 'id' has changed");
42463     DIO_PUT(sint32, &dout, "id", real_packet->id);
42464   }
42465 
42466   *old = *real_packet;
42467   SEND_PACKET_END(PACKET_EDIT_OBJECT_CREATED);
42468 }
42469 
send_packet_edit_object_created(struct connection * pc,const struct packet_edit_object_created * packet)42470 int send_packet_edit_object_created(struct connection *pc, const struct packet_edit_object_created *packet)
42471 {
42472   if (!pc->used) {
42473     log_error("WARNING: trying to send data to the closed connection %s",
42474               conn_description(pc));
42475     return -1;
42476   }
42477   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_OBJECT_CREATED].packet != NULL, -1,
42478                         "Handler for PACKET_EDIT_OBJECT_CREATED not installed");
42479   return pc->phs.handlers->send[PACKET_EDIT_OBJECT_CREATED].packet(pc, packet);
42480 }
42481 
dsend_packet_edit_object_created(struct connection * pc,int tag,int id)42482 int dsend_packet_edit_object_created(struct connection *pc, int tag, int id)
42483 {
42484   struct packet_edit_object_created packet, *real_packet = &packet;
42485 
42486   real_packet->tag = tag;
42487   real_packet->id = id;
42488 
42489   return send_packet_edit_object_created(pc, real_packet);
42490 }
42491 
42492 #define hash_packet_play_music_100 hash_const
42493 
42494 #define cmp_packet_play_music_100 cmp_const
42495 
42496 BV_DEFINE(packet_play_music_100_fields, 1);
42497 
receive_packet_play_music_100(struct connection * pc)42498 static struct packet_play_music *receive_packet_play_music_100(struct connection *pc)
42499 {
42500   packet_play_music_100_fields fields;
42501   struct packet_play_music *old;
42502   struct genhash **hash = pc->phs.received + PACKET_PLAY_MUSIC;
42503   RECEIVE_PACKET_START(packet_play_music, real_packet);
42504 
42505   DIO_BV_GET(&din, fields);
42506 
42507   log_packet_detailed("packet_play_music_100: got info about ()");
42508 
42509   if (NULL == *hash) {
42510     *hash = genhash_new_full(hash_packet_play_music_100, cmp_packet_play_music_100,
42511                              NULL, NULL, NULL, free);
42512   }
42513 
42514   if (genhash_lookup(*hash, real_packet, (void **) &old)) {
42515     *real_packet = *old;
42516   } else {
42517     log_packet_detailed("  no old info");
42518     memset(real_packet, 0, sizeof(*real_packet));
42519   }
42520 
42521   if (BV_ISSET(fields, 0)) {
42522     log_packet_detailed("  got field 'tag'");
42523     if (!DIO_GET(string, &din, "tag", real_packet->tag, sizeof(real_packet->tag))) {
42524       RECEIVE_PACKET_FIELD_ERROR(tag);
42525     }
42526   }
42527 
42528   if (NULL == old) {
42529     old = fc_malloc(sizeof(*old));
42530     *old = *real_packet;
42531     genhash_insert(*hash, old, old);
42532   } else {
42533     *old = *real_packet;
42534   }
42535   RECEIVE_PACKET_END(real_packet);
42536 }
42537 
send_packet_play_music_100(struct connection * pc,const struct packet_play_music * packet)42538 static int send_packet_play_music_100(struct connection *pc, const struct packet_play_music *packet)
42539 {
42540   const struct packet_play_music *real_packet = packet;
42541   packet_play_music_100_fields fields;
42542   struct packet_play_music *old;
42543   bool differ;
42544   struct genhash **hash = pc->phs.sent + PACKET_PLAY_MUSIC;
42545   int different = 0;
42546   SEND_PACKET_START(PACKET_PLAY_MUSIC);
42547 
42548   log_packet_detailed("packet_play_music_100: sending info about ()");
42549 
42550   if (NULL == *hash) {
42551     *hash = genhash_new_full(hash_packet_play_music_100, cmp_packet_play_music_100,
42552                              NULL, NULL, NULL, free);
42553   }
42554   BV_CLR_ALL(fields);
42555 
42556   if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
42557     old = fc_malloc(sizeof(*old));
42558     *old = *real_packet;
42559     genhash_insert(*hash, old, old);
42560     memset(old, 0, sizeof(*old));
42561     different = 1;      /* Force to send. */
42562   }
42563 
42564   differ = (strcmp(old->tag, real_packet->tag) != 0);
42565   if (differ) {
42566     different++;
42567     BV_SET(fields, 0);
42568   }
42569 
42570 
42571   DIO_BV_PUT(&dout, "fields", fields);
42572 
42573   if (BV_ISSET(fields, 0)) {
42574     log_packet_detailed("  field 'tag' has changed");
42575     DIO_PUT(string, &dout, "tag", real_packet->tag);
42576   }
42577 
42578   *old = *real_packet;
42579   SEND_PACKET_END(PACKET_PLAY_MUSIC);
42580 }
42581 
send_packet_play_music(struct connection * pc,const struct packet_play_music * packet)42582 int send_packet_play_music(struct connection *pc, const struct packet_play_music *packet)
42583 {
42584   if (!pc->used) {
42585     log_error("WARNING: trying to send data to the closed connection %s",
42586               conn_description(pc));
42587     return -1;
42588   }
42589   fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAY_MUSIC].packet != NULL, -1,
42590                         "Handler for PACKET_PLAY_MUSIC not installed");
42591   return pc->phs.handlers->send[PACKET_PLAY_MUSIC].packet(pc, packet);
42592 }
42593 
lsend_packet_play_music(struct conn_list * dest,const struct packet_play_music * packet)42594 void lsend_packet_play_music(struct conn_list *dest, const struct packet_play_music *packet)
42595 {
42596   conn_list_iterate(dest, pconn) {
42597     send_packet_play_music(pconn, packet);
42598   } conn_list_iterate_end;
42599 }
42600 
packet_handlers_fill_initial(struct packet_handlers * phandlers)42601 void packet_handlers_fill_initial(struct packet_handlers *phandlers)
42602 {
42603   fc_assert_msg(has_capability("techloss_forgiveness", our_capability),
42604                 "Packets have support for unknown 'techloss_forgiveness' capability!");
42605   fc_assert_msg(has_capability("year32", our_capability),
42606                 "Packets have support for unknown 'year32' capability!");
42607   phandlers->send[PACKET_WORKER_TASK].packet = (int(*)(struct connection *, const void *)) send_packet_worker_task_100;
42608   phandlers->receive[PACKET_WORKER_TASK] = (void *(*)(struct connection *)) receive_packet_worker_task_100;
42609   phandlers->send[PACKET_PLAYER_ATTRIBUTE_CHUNK].packet = (int(*)(struct connection *, const void *)) send_packet_player_attribute_chunk_100;
42610   phandlers->receive[PACKET_PLAYER_ATTRIBUTE_CHUNK] = (void *(*)(struct connection *)) receive_packet_player_attribute_chunk_100;
42611   phandlers->send[PACKET_EDIT_STARTPOS].packet = (int(*)(struct connection *, const void *)) send_packet_edit_startpos_100;
42612   phandlers->receive[PACKET_EDIT_STARTPOS] = (void *(*)(struct connection *)) receive_packet_edit_startpos_100;
42613   phandlers->send[PACKET_EDIT_STARTPOS_FULL].packet = (int(*)(struct connection *, const void *)) send_packet_edit_startpos_full_100;
42614   phandlers->receive[PACKET_EDIT_STARTPOS_FULL] = (void *(*)(struct connection *)) receive_packet_edit_startpos_full_100;
42615   if (is_server()) {
42616     phandlers->send[PACKET_PROCESSING_STARTED].no_packet = (int(*)(struct connection *)) send_packet_processing_started_100;
42617     phandlers->send[PACKET_PROCESSING_FINISHED].no_packet = (int(*)(struct connection *)) send_packet_processing_finished_100;
42618     phandlers->send[PACKET_SERVER_JOIN_REPLY].packet = (int(*)(struct connection *, const void *)) send_packet_server_join_reply_100;
42619     phandlers->send[PACKET_AUTHENTICATION_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_authentication_req_100;
42620     phandlers->send[PACKET_SERVER_SHUTDOWN].no_packet = (int(*)(struct connection *)) send_packet_server_shutdown_100;
42621     phandlers->send[PACKET_ENDGAME_REPORT].packet = (int(*)(struct connection *, const void *)) send_packet_endgame_report_100;
42622     phandlers->send[PACKET_ENDGAME_PLAYER].packet = (int(*)(struct connection *, const void *)) send_packet_endgame_player_100;
42623     phandlers->send[PACKET_TILE_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_tile_info_100;
42624     phandlers->send[PACKET_TIMEOUT_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_timeout_info_100;
42625     phandlers->send[PACKET_MAP_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_map_info_100;
42626     phandlers->send[PACKET_NUKE_TILE_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_nuke_tile_info_100;
42627     phandlers->send[PACKET_TEAM_NAME_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_team_name_info_100;
42628     phandlers->send[PACKET_ACHIEVEMENT_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_achievement_info_100;
42629     phandlers->send[PACKET_CHAT_MSG].packet = (int(*)(struct connection *, const void *)) send_packet_chat_msg_100;
42630     phandlers->send[PACKET_EARLY_CHAT_MSG].packet = (int(*)(struct connection *, const void *)) send_packet_early_chat_msg_100;
42631     phandlers->send[PACKET_CONNECT_MSG].packet = (int(*)(struct connection *, const void *)) send_packet_connect_msg_100;
42632     phandlers->send[PACKET_CITY_REMOVE].packet = (int(*)(struct connection *, const void *)) send_packet_city_remove_100;
42633     phandlers->send[PACKET_CITY_INFO].force_to_send = (int(*)(struct connection *, const void *, bool)) send_packet_city_info_100;
42634     phandlers->send[PACKET_CITY_SHORT_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_city_short_info_100;
42635     phandlers->send[PACKET_CITY_NAME_SUGGESTION_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_city_name_suggestion_info_100;
42636     phandlers->send[PACKET_CITY_SABOTAGE_LIST].packet = (int(*)(struct connection *, const void *)) send_packet_city_sabotage_list_100;
42637     phandlers->send[PACKET_PLAYER_REMOVE].packet = (int(*)(struct connection *, const void *)) send_packet_player_remove_100;
42638     phandlers->send[PACKET_PLAYER_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_player_info_100;
42639     phandlers->send[PACKET_PLAYER_DIPLSTATE].packet = (int(*)(struct connection *, const void *)) send_packet_player_diplstate_100;
42640     phandlers->send[PACKET_RESEARCH_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_research_info_100;
42641     phandlers->send[PACKET_UNIT_REMOVE].packet = (int(*)(struct connection *, const void *)) send_packet_unit_remove_100;
42642     phandlers->send[PACKET_UNIT_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_unit_info_100;
42643     phandlers->send[PACKET_UNIT_SHORT_INFO].force_to_send = (int(*)(struct connection *, const void *, bool)) send_packet_unit_short_info_100;
42644     phandlers->send[PACKET_UNIT_COMBAT_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_unit_combat_info_100;
42645     phandlers->send[PACKET_UNIT_ACTION_ANSWER].packet = (int(*)(struct connection *, const void *)) send_packet_unit_action_answer_100;
42646     phandlers->send[PACKET_UNIT_ACTIONS].packet = (int(*)(struct connection *, const void *)) send_packet_unit_actions_100;
42647     phandlers->send[PACKET_DIPLOMACY_INIT_MEETING].packet = (int(*)(struct connection *, const void *)) send_packet_diplomacy_init_meeting_100;
42648     phandlers->send[PACKET_DIPLOMACY_CANCEL_MEETING].packet = (int(*)(struct connection *, const void *)) send_packet_diplomacy_cancel_meeting_100;
42649     phandlers->send[PACKET_DIPLOMACY_CREATE_CLAUSE].packet = (int(*)(struct connection *, const void *)) send_packet_diplomacy_create_clause_100;
42650     phandlers->send[PACKET_DIPLOMACY_REMOVE_CLAUSE].packet = (int(*)(struct connection *, const void *)) send_packet_diplomacy_remove_clause_100;
42651     phandlers->send[PACKET_DIPLOMACY_ACCEPT_TREATY].packet = (int(*)(struct connection *, const void *)) send_packet_diplomacy_accept_treaty_100;
42652     phandlers->send[PACKET_PAGE_MSG].packet = (int(*)(struct connection *, const void *)) send_packet_page_msg_100;
42653     phandlers->send[PACKET_PAGE_MSG_PART].packet = (int(*)(struct connection *, const void *)) send_packet_page_msg_part_100;
42654     phandlers->send[PACKET_CONN_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_conn_info_100;
42655     phandlers->send[PACKET_CONN_PING_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_conn_ping_info_100;
42656     phandlers->send[PACKET_CONN_PING].no_packet = (int(*)(struct connection *)) send_packet_conn_ping_100;
42657     phandlers->send[PACKET_END_PHASE].no_packet = (int(*)(struct connection *)) send_packet_end_phase_100;
42658     phandlers->send[PACKET_START_PHASE].packet = (int(*)(struct connection *, const void *)) send_packet_start_phase_100;
42659     phandlers->send[PACKET_BEGIN_TURN].no_packet = (int(*)(struct connection *)) send_packet_begin_turn_100;
42660     phandlers->send[PACKET_END_TURN].no_packet = (int(*)(struct connection *)) send_packet_end_turn_100;
42661     phandlers->send[PACKET_FREEZE_CLIENT].no_packet = (int(*)(struct connection *)) send_packet_freeze_client_100;
42662     phandlers->send[PACKET_THAW_CLIENT].no_packet = (int(*)(struct connection *)) send_packet_thaw_client_100;
42663     phandlers->send[PACKET_RULESET_UNIT].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_unit_100;
42664     phandlers->send[PACKET_RULESET_UNIT_BONUS].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_unit_bonus_100;
42665     phandlers->send[PACKET_RULESET_UNIT_FLAG].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_unit_flag_100;
42666     phandlers->send[PACKET_RULESET_GAME].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_game_100;
42667     phandlers->send[PACKET_RULESET_SPECIALIST].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_specialist_100;
42668     phandlers->send[PACKET_RULESET_GOVERNMENT_RULER_TITLE].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_government_ruler_title_100;
42669     phandlers->send[PACKET_RULESET_TECH].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_tech_100;
42670     phandlers->send[PACKET_RULESET_TECH_FLAG].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_tech_flag_100;
42671     phandlers->send[PACKET_RULESET_GOVERNMENT].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_government_100;
42672     phandlers->send[PACKET_RULESET_TERRAIN_CONTROL].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_terrain_control_100;
42673     phandlers->send[PACKET_RULESETS_READY].no_packet = (int(*)(struct connection *)) send_packet_rulesets_ready_100;
42674     phandlers->send[PACKET_RULESET_NATION_SETS].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_nation_sets_100;
42675     phandlers->send[PACKET_RULESET_NATION_GROUPS].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_nation_groups_100;
42676     phandlers->send[PACKET_RULESET_NATION].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_nation_100;
42677     phandlers->send[PACKET_NATION_AVAILABILITY].packet = (int(*)(struct connection *, const void *)) send_packet_nation_availability_100;
42678     phandlers->send[PACKET_RULESET_STYLE].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_style_100;
42679     phandlers->send[PACKET_RULESET_CITY].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_city_100;
42680     phandlers->send[PACKET_RULESET_BUILDING].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_building_100;
42681     phandlers->send[PACKET_RULESET_TERRAIN].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_terrain_100;
42682     phandlers->send[PACKET_RULESET_TERRAIN_FLAG].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_terrain_flag_100;
42683     phandlers->send[PACKET_RULESET_UNIT_CLASS].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_unit_class_100;
42684     phandlers->send[PACKET_RULESET_EXTRA].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_extra_100;
42685     phandlers->send[PACKET_RULESET_BASE].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_base_100;
42686     phandlers->send[PACKET_RULESET_ROAD].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_road_100;
42687     phandlers->send[PACKET_RULESET_DISASTER].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_disaster_100;
42688     phandlers->send[PACKET_RULESET_ACHIEVEMENT].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_achievement_100;
42689     phandlers->send[PACKET_RULESET_TRADE].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_trade_100;
42690     phandlers->send[PACKET_RULESET_ACTION].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_action_100;
42691     phandlers->send[PACKET_RULESET_ACTION_ENABLER].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_action_enabler_100;
42692     phandlers->send[PACKET_RULESET_MUSIC].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_music_100;
42693     phandlers->send[PACKET_RULESET_MULTIPLIER].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_multiplier_100;
42694     phandlers->send[PACKET_RULESET_CONTROL].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_control_100;
42695     phandlers->send[PACKET_RULESET_SUMMARY].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_summary_100;
42696     phandlers->send[PACKET_RULESET_DESCRIPTION_PART].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_description_part_100;
42697     phandlers->send[PACKET_SINGLE_WANT_HACK_REPLY].packet = (int(*)(struct connection *, const void *)) send_packet_single_want_hack_reply_100;
42698     phandlers->send[PACKET_RULESET_CHOICES].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_choices_100;
42699     phandlers->send[PACKET_GAME_LOAD].packet = (int(*)(struct connection *, const void *)) send_packet_game_load_100;
42700     phandlers->send[PACKET_SERVER_SETTING_CONTROL].packet = (int(*)(struct connection *, const void *)) send_packet_server_setting_control_100;
42701     phandlers->send[PACKET_SERVER_SETTING_CONST].packet = (int(*)(struct connection *, const void *)) send_packet_server_setting_const_100;
42702     phandlers->send[PACKET_SERVER_SETTING_BOOL].packet = (int(*)(struct connection *, const void *)) send_packet_server_setting_bool_100;
42703     phandlers->send[PACKET_SERVER_SETTING_INT].packet = (int(*)(struct connection *, const void *)) send_packet_server_setting_int_100;
42704     phandlers->send[PACKET_SERVER_SETTING_STR].packet = (int(*)(struct connection *, const void *)) send_packet_server_setting_str_100;
42705     phandlers->send[PACKET_SERVER_SETTING_ENUM].packet = (int(*)(struct connection *, const void *)) send_packet_server_setting_enum_100;
42706     phandlers->send[PACKET_SERVER_SETTING_BITWISE].packet = (int(*)(struct connection *, const void *)) send_packet_server_setting_bitwise_100;
42707     phandlers->send[PACKET_SET_TOPOLOGY].packet = (int(*)(struct connection *, const void *)) send_packet_set_topology_100;
42708     phandlers->send[PACKET_RULESET_EFFECT].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_effect_100;
42709     phandlers->send[PACKET_RULESET_RESOURCE].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_resource_100;
42710     phandlers->send[PACKET_SCENARIO_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_scenario_info_100;
42711     phandlers->send[PACKET_SCENARIO_DESCRIPTION].packet = (int(*)(struct connection *, const void *)) send_packet_scenario_description_100;
42712     phandlers->send[PACKET_VOTE_NEW].packet = (int(*)(struct connection *, const void *)) send_packet_vote_new_100;
42713     phandlers->send[PACKET_VOTE_UPDATE].packet = (int(*)(struct connection *, const void *)) send_packet_vote_update_100;
42714     phandlers->send[PACKET_VOTE_REMOVE].packet = (int(*)(struct connection *, const void *)) send_packet_vote_remove_100;
42715     phandlers->send[PACKET_VOTE_RESOLVE].packet = (int(*)(struct connection *, const void *)) send_packet_vote_resolve_100;
42716     phandlers->send[PACKET_EDIT_OBJECT_CREATED].packet = (int(*)(struct connection *, const void *)) send_packet_edit_object_created_100;
42717     phandlers->send[PACKET_PLAY_MUSIC].packet = (int(*)(struct connection *, const void *)) send_packet_play_music_100;
42718     phandlers->receive[PACKET_SERVER_JOIN_REQ] = (void *(*)(struct connection *)) receive_packet_server_join_req_100;
42719     phandlers->receive[PACKET_AUTHENTICATION_REPLY] = (void *(*)(struct connection *)) receive_packet_authentication_reply_100;
42720     phandlers->receive[PACKET_NATION_SELECT_REQ] = (void *(*)(struct connection *)) receive_packet_nation_select_req_100;
42721     phandlers->receive[PACKET_PLAYER_READY] = (void *(*)(struct connection *)) receive_packet_player_ready_100;
42722     phandlers->receive[PACKET_CHAT_MSG_REQ] = (void *(*)(struct connection *)) receive_packet_chat_msg_req_100;
42723     phandlers->receive[PACKET_CITY_SELL] = (void *(*)(struct connection *)) receive_packet_city_sell_100;
42724     phandlers->receive[PACKET_CITY_BUY] = (void *(*)(struct connection *)) receive_packet_city_buy_100;
42725     phandlers->receive[PACKET_CITY_CHANGE] = (void *(*)(struct connection *)) receive_packet_city_change_100;
42726     phandlers->receive[PACKET_CITY_WORKLIST] = (void *(*)(struct connection *)) receive_packet_city_worklist_100;
42727     phandlers->receive[PACKET_CITY_MAKE_SPECIALIST] = (void *(*)(struct connection *)) receive_packet_city_make_specialist_100;
42728     phandlers->receive[PACKET_CITY_MAKE_WORKER] = (void *(*)(struct connection *)) receive_packet_city_make_worker_100;
42729     phandlers->receive[PACKET_CITY_CHANGE_SPECIALIST] = (void *(*)(struct connection *)) receive_packet_city_change_specialist_100;
42730     phandlers->receive[PACKET_CITY_RENAME] = (void *(*)(struct connection *)) receive_packet_city_rename_100;
42731     phandlers->receive[PACKET_CITY_OPTIONS_REQ] = (void *(*)(struct connection *)) receive_packet_city_options_req_100;
42732     phandlers->receive[PACKET_CITY_REFRESH] = (void *(*)(struct connection *)) receive_packet_city_refresh_100;
42733     phandlers->receive[PACKET_CITY_NAME_SUGGESTION_REQ] = (void *(*)(struct connection *)) receive_packet_city_name_suggestion_req_100;
42734     phandlers->receive[PACKET_PLAYER_PHASE_DONE] = (void *(*)(struct connection *)) receive_packet_player_phase_done_100;
42735     phandlers->receive[PACKET_PLAYER_RATES] = (void *(*)(struct connection *)) receive_packet_player_rates_100;
42736     phandlers->receive[PACKET_PLAYER_CHANGE_GOVERNMENT] = (void *(*)(struct connection *)) receive_packet_player_change_government_100;
42737     phandlers->receive[PACKET_PLAYER_ATTRIBUTE_BLOCK] = (void *(*)(struct connection *)) receive_packet_player_attribute_block_100;
42738     phandlers->receive[PACKET_PLAYER_MULTIPLIER] = (void *(*)(struct connection *)) receive_packet_player_multiplier_100;
42739     phandlers->receive[PACKET_PLAYER_RESEARCH] = (void *(*)(struct connection *)) receive_packet_player_research_100;
42740     phandlers->receive[PACKET_PLAYER_TECH_GOAL] = (void *(*)(struct connection *)) receive_packet_player_tech_goal_100;
42741     phandlers->receive[PACKET_UNIT_BUILD_CITY] = (void *(*)(struct connection *)) receive_packet_unit_build_city_100;
42742     phandlers->receive[PACKET_UNIT_DISBAND] = (void *(*)(struct connection *)) receive_packet_unit_disband_100;
42743     phandlers->receive[PACKET_UNIT_CHANGE_HOMECITY] = (void *(*)(struct connection *)) receive_packet_unit_change_homecity_100;
42744     phandlers->receive[PACKET_UNIT_BATTLEGROUP] = (void *(*)(struct connection *)) receive_packet_unit_battlegroup_100;
42745     phandlers->receive[PACKET_UNIT_ORDERS] = (void *(*)(struct connection *)) receive_packet_unit_orders_100;
42746     phandlers->receive[PACKET_UNIT_AUTOSETTLERS] = (void *(*)(struct connection *)) receive_packet_unit_autosettlers_100;
42747     phandlers->receive[PACKET_UNIT_LOAD] = (void *(*)(struct connection *)) receive_packet_unit_load_100;
42748     phandlers->receive[PACKET_UNIT_UNLOAD] = (void *(*)(struct connection *)) receive_packet_unit_unload_100;
42749     phandlers->receive[PACKET_UNIT_UPGRADE] = (void *(*)(struct connection *)) receive_packet_unit_upgrade_100;
42750     phandlers->receive[PACKET_UNIT_NUKE] = (void *(*)(struct connection *)) receive_packet_unit_nuke_100;
42751     phandlers->receive[PACKET_UNIT_PARADROP_TO] = (void *(*)(struct connection *)) receive_packet_unit_paradrop_to_100;
42752     phandlers->receive[PACKET_UNIT_AIRLIFT] = (void *(*)(struct connection *)) receive_packet_unit_airlift_100;
42753     phandlers->receive[PACKET_UNIT_ACTION_QUERY] = (void *(*)(struct connection *)) receive_packet_unit_action_query_100;
42754     phandlers->receive[PACKET_UNIT_TYPE_UPGRADE] = (void *(*)(struct connection *)) receive_packet_unit_type_upgrade_100;
42755     phandlers->receive[PACKET_UNIT_DO_ACTION] = (void *(*)(struct connection *)) receive_packet_unit_do_action_100;
42756     phandlers->receive[PACKET_UNIT_GET_ACTIONS] = (void *(*)(struct connection *)) receive_packet_unit_get_actions_100;
42757     phandlers->receive[PACKET_UNIT_CHANGE_ACTIVITY] = (void *(*)(struct connection *)) receive_packet_unit_change_activity_100;
42758     phandlers->receive[PACKET_DIPLOMACY_INIT_MEETING_REQ] = (void *(*)(struct connection *)) receive_packet_diplomacy_init_meeting_req_100;
42759     phandlers->receive[PACKET_DIPLOMACY_CANCEL_MEETING_REQ] = (void *(*)(struct connection *)) receive_packet_diplomacy_cancel_meeting_req_100;
42760     phandlers->receive[PACKET_DIPLOMACY_CREATE_CLAUSE_REQ] = (void *(*)(struct connection *)) receive_packet_diplomacy_create_clause_req_100;
42761     phandlers->receive[PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ] = (void *(*)(struct connection *)) receive_packet_diplomacy_remove_clause_req_100;
42762     phandlers->receive[PACKET_DIPLOMACY_ACCEPT_TREATY_REQ] = (void *(*)(struct connection *)) receive_packet_diplomacy_accept_treaty_req_100;
42763     phandlers->receive[PACKET_DIPLOMACY_CANCEL_PACT] = (void *(*)(struct connection *)) receive_packet_diplomacy_cancel_pact_100;
42764     phandlers->receive[PACKET_REPORT_REQ] = (void *(*)(struct connection *)) receive_packet_report_req_100;
42765     phandlers->receive[PACKET_CONN_PONG] = (void *(*)(struct connection *)) receive_packet_conn_pong_100;
42766     phandlers->receive[PACKET_CLIENT_HEARTBEAT] = (void *(*)(struct connection *)) receive_packet_client_heartbeat_100;
42767     phandlers->receive[PACKET_CLIENT_INFO] = (void *(*)(struct connection *)) receive_packet_client_info_100;
42768     phandlers->receive[PACKET_SPACESHIP_LAUNCH] = (void *(*)(struct connection *)) receive_packet_spaceship_launch_100;
42769     phandlers->receive[PACKET_SPACESHIP_PLACE] = (void *(*)(struct connection *)) receive_packet_spaceship_place_100;
42770     phandlers->receive[PACKET_SINGLE_WANT_HACK_REQ] = (void *(*)(struct connection *)) receive_packet_single_want_hack_req_100;
42771     phandlers->receive[PACKET_SAVE_SCENARIO] = (void *(*)(struct connection *)) receive_packet_save_scenario_100;
42772     phandlers->receive[PACKET_VOTE_SUBMIT] = (void *(*)(struct connection *)) receive_packet_vote_submit_100;
42773     phandlers->receive[PACKET_EDIT_MODE] = (void *(*)(struct connection *)) receive_packet_edit_mode_100;
42774     phandlers->receive[PACKET_EDIT_RECALCULATE_BORDERS] = (void *(*)(struct connection *)) receive_packet_edit_recalculate_borders_100;
42775     phandlers->receive[PACKET_EDIT_CHECK_TILES] = (void *(*)(struct connection *)) receive_packet_edit_check_tiles_100;
42776     phandlers->receive[PACKET_EDIT_TOGGLE_FOGOFWAR] = (void *(*)(struct connection *)) receive_packet_edit_toggle_fogofwar_100;
42777     phandlers->receive[PACKET_EDIT_TILE_TERRAIN] = (void *(*)(struct connection *)) receive_packet_edit_tile_terrain_100;
42778     phandlers->receive[PACKET_EDIT_TILE_RESOURCE] = (void *(*)(struct connection *)) receive_packet_edit_tile_resource_100;
42779     phandlers->receive[PACKET_EDIT_TILE_EXTRA] = (void *(*)(struct connection *)) receive_packet_edit_tile_extra_100;
42780     phandlers->receive[PACKET_EDIT_TILE] = (void *(*)(struct connection *)) receive_packet_edit_tile_100;
42781     phandlers->receive[PACKET_EDIT_UNIT_CREATE] = (void *(*)(struct connection *)) receive_packet_edit_unit_create_100;
42782     phandlers->receive[PACKET_EDIT_UNIT_REMOVE] = (void *(*)(struct connection *)) receive_packet_edit_unit_remove_100;
42783     phandlers->receive[PACKET_EDIT_UNIT_REMOVE_BY_ID] = (void *(*)(struct connection *)) receive_packet_edit_unit_remove_by_id_100;
42784     phandlers->receive[PACKET_EDIT_UNIT] = (void *(*)(struct connection *)) receive_packet_edit_unit_100;
42785     phandlers->receive[PACKET_EDIT_CITY_CREATE] = (void *(*)(struct connection *)) receive_packet_edit_city_create_100;
42786     phandlers->receive[PACKET_EDIT_CITY_REMOVE] = (void *(*)(struct connection *)) receive_packet_edit_city_remove_100;
42787     phandlers->receive[PACKET_EDIT_CITY] = (void *(*)(struct connection *)) receive_packet_edit_city_100;
42788     phandlers->receive[PACKET_EDIT_PLAYER_CREATE] = (void *(*)(struct connection *)) receive_packet_edit_player_create_100;
42789     phandlers->receive[PACKET_EDIT_PLAYER_REMOVE] = (void *(*)(struct connection *)) receive_packet_edit_player_remove_100;
42790     phandlers->receive[PACKET_EDIT_PLAYER] = (void *(*)(struct connection *)) receive_packet_edit_player_100;
42791     phandlers->receive[PACKET_EDIT_PLAYER_VISION] = (void *(*)(struct connection *)) receive_packet_edit_player_vision_100;
42792     phandlers->receive[PACKET_EDIT_SCENARIO_DESC] = (void *(*)(struct connection *)) receive_packet_edit_scenario_desc_100;
42793   } else {
42794     phandlers->send[PACKET_SERVER_JOIN_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_server_join_req_100;
42795     phandlers->send[PACKET_AUTHENTICATION_REPLY].packet = (int(*)(struct connection *, const void *)) send_packet_authentication_reply_100;
42796     phandlers->send[PACKET_NATION_SELECT_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_nation_select_req_100;
42797     phandlers->send[PACKET_PLAYER_READY].packet = (int(*)(struct connection *, const void *)) send_packet_player_ready_100;
42798     phandlers->send[PACKET_CHAT_MSG_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_chat_msg_req_100;
42799     phandlers->send[PACKET_CITY_SELL].packet = (int(*)(struct connection *, const void *)) send_packet_city_sell_100;
42800     phandlers->send[PACKET_CITY_BUY].packet = (int(*)(struct connection *, const void *)) send_packet_city_buy_100;
42801     phandlers->send[PACKET_CITY_CHANGE].packet = (int(*)(struct connection *, const void *)) send_packet_city_change_100;
42802     phandlers->send[PACKET_CITY_WORKLIST].packet = (int(*)(struct connection *, const void *)) send_packet_city_worklist_100;
42803     phandlers->send[PACKET_CITY_MAKE_SPECIALIST].packet = (int(*)(struct connection *, const void *)) send_packet_city_make_specialist_100;
42804     phandlers->send[PACKET_CITY_MAKE_WORKER].packet = (int(*)(struct connection *, const void *)) send_packet_city_make_worker_100;
42805     phandlers->send[PACKET_CITY_CHANGE_SPECIALIST].packet = (int(*)(struct connection *, const void *)) send_packet_city_change_specialist_100;
42806     phandlers->send[PACKET_CITY_RENAME].packet = (int(*)(struct connection *, const void *)) send_packet_city_rename_100;
42807     phandlers->send[PACKET_CITY_OPTIONS_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_city_options_req_100;
42808     phandlers->send[PACKET_CITY_REFRESH].packet = (int(*)(struct connection *, const void *)) send_packet_city_refresh_100;
42809     phandlers->send[PACKET_CITY_NAME_SUGGESTION_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_city_name_suggestion_req_100;
42810     phandlers->send[PACKET_PLAYER_PHASE_DONE].packet = (int(*)(struct connection *, const void *)) send_packet_player_phase_done_100;
42811     phandlers->send[PACKET_PLAYER_RATES].packet = (int(*)(struct connection *, const void *)) send_packet_player_rates_100;
42812     phandlers->send[PACKET_PLAYER_CHANGE_GOVERNMENT].packet = (int(*)(struct connection *, const void *)) send_packet_player_change_government_100;
42813     phandlers->send[PACKET_PLAYER_ATTRIBUTE_BLOCK].no_packet = (int(*)(struct connection *)) send_packet_player_attribute_block_100;
42814     phandlers->send[PACKET_PLAYER_MULTIPLIER].packet = (int(*)(struct connection *, const void *)) send_packet_player_multiplier_100;
42815     phandlers->send[PACKET_PLAYER_RESEARCH].packet = (int(*)(struct connection *, const void *)) send_packet_player_research_100;
42816     phandlers->send[PACKET_PLAYER_TECH_GOAL].packet = (int(*)(struct connection *, const void *)) send_packet_player_tech_goal_100;
42817     phandlers->send[PACKET_UNIT_BUILD_CITY].packet = (int(*)(struct connection *, const void *)) send_packet_unit_build_city_100;
42818     phandlers->send[PACKET_UNIT_DISBAND].packet = (int(*)(struct connection *, const void *)) send_packet_unit_disband_100;
42819     phandlers->send[PACKET_UNIT_CHANGE_HOMECITY].packet = (int(*)(struct connection *, const void *)) send_packet_unit_change_homecity_100;
42820     phandlers->send[PACKET_UNIT_BATTLEGROUP].packet = (int(*)(struct connection *, const void *)) send_packet_unit_battlegroup_100;
42821     phandlers->send[PACKET_UNIT_ORDERS].packet = (int(*)(struct connection *, const void *)) send_packet_unit_orders_100;
42822     phandlers->send[PACKET_UNIT_AUTOSETTLERS].packet = (int(*)(struct connection *, const void *)) send_packet_unit_autosettlers_100;
42823     phandlers->send[PACKET_UNIT_LOAD].packet = (int(*)(struct connection *, const void *)) send_packet_unit_load_100;
42824     phandlers->send[PACKET_UNIT_UNLOAD].packet = (int(*)(struct connection *, const void *)) send_packet_unit_unload_100;
42825     phandlers->send[PACKET_UNIT_UPGRADE].packet = (int(*)(struct connection *, const void *)) send_packet_unit_upgrade_100;
42826     phandlers->send[PACKET_UNIT_NUKE].packet = (int(*)(struct connection *, const void *)) send_packet_unit_nuke_100;
42827     phandlers->send[PACKET_UNIT_PARADROP_TO].packet = (int(*)(struct connection *, const void *)) send_packet_unit_paradrop_to_100;
42828     phandlers->send[PACKET_UNIT_AIRLIFT].packet = (int(*)(struct connection *, const void *)) send_packet_unit_airlift_100;
42829     phandlers->send[PACKET_UNIT_ACTION_QUERY].packet = (int(*)(struct connection *, const void *)) send_packet_unit_action_query_100;
42830     phandlers->send[PACKET_UNIT_TYPE_UPGRADE].packet = (int(*)(struct connection *, const void *)) send_packet_unit_type_upgrade_100;
42831     phandlers->send[PACKET_UNIT_DO_ACTION].packet = (int(*)(struct connection *, const void *)) send_packet_unit_do_action_100;
42832     phandlers->send[PACKET_UNIT_GET_ACTIONS].packet = (int(*)(struct connection *, const void *)) send_packet_unit_get_actions_100;
42833     phandlers->send[PACKET_UNIT_CHANGE_ACTIVITY].packet = (int(*)(struct connection *, const void *)) send_packet_unit_change_activity_100;
42834     phandlers->send[PACKET_DIPLOMACY_INIT_MEETING_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_diplomacy_init_meeting_req_100;
42835     phandlers->send[PACKET_DIPLOMACY_CANCEL_MEETING_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_diplomacy_cancel_meeting_req_100;
42836     phandlers->send[PACKET_DIPLOMACY_CREATE_CLAUSE_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_diplomacy_create_clause_req_100;
42837     phandlers->send[PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_diplomacy_remove_clause_req_100;
42838     phandlers->send[PACKET_DIPLOMACY_ACCEPT_TREATY_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_diplomacy_accept_treaty_req_100;
42839     phandlers->send[PACKET_DIPLOMACY_CANCEL_PACT].packet = (int(*)(struct connection *, const void *)) send_packet_diplomacy_cancel_pact_100;
42840     phandlers->send[PACKET_REPORT_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_report_req_100;
42841     phandlers->send[PACKET_CONN_PONG].no_packet = (int(*)(struct connection *)) send_packet_conn_pong_100;
42842     phandlers->send[PACKET_CLIENT_HEARTBEAT].no_packet = (int(*)(struct connection *)) send_packet_client_heartbeat_100;
42843     phandlers->send[PACKET_CLIENT_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_client_info_100;
42844     phandlers->send[PACKET_SPACESHIP_LAUNCH].no_packet = (int(*)(struct connection *)) send_packet_spaceship_launch_100;
42845     phandlers->send[PACKET_SPACESHIP_PLACE].packet = (int(*)(struct connection *, const void *)) send_packet_spaceship_place_100;
42846     phandlers->send[PACKET_SINGLE_WANT_HACK_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_single_want_hack_req_100;
42847     phandlers->send[PACKET_SAVE_SCENARIO].packet = (int(*)(struct connection *, const void *)) send_packet_save_scenario_100;
42848     phandlers->send[PACKET_VOTE_SUBMIT].packet = (int(*)(struct connection *, const void *)) send_packet_vote_submit_100;
42849     phandlers->send[PACKET_EDIT_MODE].packet = (int(*)(struct connection *, const void *)) send_packet_edit_mode_100;
42850     phandlers->send[PACKET_EDIT_RECALCULATE_BORDERS].no_packet = (int(*)(struct connection *)) send_packet_edit_recalculate_borders_100;
42851     phandlers->send[PACKET_EDIT_CHECK_TILES].no_packet = (int(*)(struct connection *)) send_packet_edit_check_tiles_100;
42852     phandlers->send[PACKET_EDIT_TOGGLE_FOGOFWAR].packet = (int(*)(struct connection *, const void *)) send_packet_edit_toggle_fogofwar_100;
42853     phandlers->send[PACKET_EDIT_TILE_TERRAIN].packet = (int(*)(struct connection *, const void *)) send_packet_edit_tile_terrain_100;
42854     phandlers->send[PACKET_EDIT_TILE_RESOURCE].packet = (int(*)(struct connection *, const void *)) send_packet_edit_tile_resource_100;
42855     phandlers->send[PACKET_EDIT_TILE_EXTRA].packet = (int(*)(struct connection *, const void *)) send_packet_edit_tile_extra_100;
42856     phandlers->send[PACKET_EDIT_TILE].packet = (int(*)(struct connection *, const void *)) send_packet_edit_tile_100;
42857     phandlers->send[PACKET_EDIT_UNIT_CREATE].packet = (int(*)(struct connection *, const void *)) send_packet_edit_unit_create_100;
42858     phandlers->send[PACKET_EDIT_UNIT_REMOVE].packet = (int(*)(struct connection *, const void *)) send_packet_edit_unit_remove_100;
42859     phandlers->send[PACKET_EDIT_UNIT_REMOVE_BY_ID].packet = (int(*)(struct connection *, const void *)) send_packet_edit_unit_remove_by_id_100;
42860     phandlers->send[PACKET_EDIT_UNIT].packet = (int(*)(struct connection *, const void *)) send_packet_edit_unit_100;
42861     phandlers->send[PACKET_EDIT_CITY_CREATE].packet = (int(*)(struct connection *, const void *)) send_packet_edit_city_create_100;
42862     phandlers->send[PACKET_EDIT_CITY_REMOVE].packet = (int(*)(struct connection *, const void *)) send_packet_edit_city_remove_100;
42863     phandlers->send[PACKET_EDIT_CITY].packet = (int(*)(struct connection *, const void *)) send_packet_edit_city_100;
42864     phandlers->send[PACKET_EDIT_PLAYER_CREATE].packet = (int(*)(struct connection *, const void *)) send_packet_edit_player_create_100;
42865     phandlers->send[PACKET_EDIT_PLAYER_REMOVE].packet = (int(*)(struct connection *, const void *)) send_packet_edit_player_remove_100;
42866     phandlers->send[PACKET_EDIT_PLAYER].packet = (int(*)(struct connection *, const void *)) send_packet_edit_player_100;
42867     phandlers->send[PACKET_EDIT_PLAYER_VISION].packet = (int(*)(struct connection *, const void *)) send_packet_edit_player_vision_100;
42868     phandlers->send[PACKET_EDIT_SCENARIO_DESC].packet = (int(*)(struct connection *, const void *)) send_packet_edit_scenario_desc_100;
42869     phandlers->receive[PACKET_PROCESSING_STARTED] = (void *(*)(struct connection *)) receive_packet_processing_started_100;
42870     phandlers->receive[PACKET_PROCESSING_FINISHED] = (void *(*)(struct connection *)) receive_packet_processing_finished_100;
42871     phandlers->receive[PACKET_SERVER_JOIN_REPLY] = (void *(*)(struct connection *)) receive_packet_server_join_reply_100;
42872     phandlers->receive[PACKET_AUTHENTICATION_REQ] = (void *(*)(struct connection *)) receive_packet_authentication_req_100;
42873     phandlers->receive[PACKET_SERVER_SHUTDOWN] = (void *(*)(struct connection *)) receive_packet_server_shutdown_100;
42874     phandlers->receive[PACKET_ENDGAME_REPORT] = (void *(*)(struct connection *)) receive_packet_endgame_report_100;
42875     phandlers->receive[PACKET_ENDGAME_PLAYER] = (void *(*)(struct connection *)) receive_packet_endgame_player_100;
42876     phandlers->receive[PACKET_TILE_INFO] = (void *(*)(struct connection *)) receive_packet_tile_info_100;
42877     phandlers->receive[PACKET_TIMEOUT_INFO] = (void *(*)(struct connection *)) receive_packet_timeout_info_100;
42878     phandlers->receive[PACKET_MAP_INFO] = (void *(*)(struct connection *)) receive_packet_map_info_100;
42879     phandlers->receive[PACKET_NUKE_TILE_INFO] = (void *(*)(struct connection *)) receive_packet_nuke_tile_info_100;
42880     phandlers->receive[PACKET_TEAM_NAME_INFO] = (void *(*)(struct connection *)) receive_packet_team_name_info_100;
42881     phandlers->receive[PACKET_ACHIEVEMENT_INFO] = (void *(*)(struct connection *)) receive_packet_achievement_info_100;
42882     phandlers->receive[PACKET_CHAT_MSG] = (void *(*)(struct connection *)) receive_packet_chat_msg_100;
42883     phandlers->receive[PACKET_EARLY_CHAT_MSG] = (void *(*)(struct connection *)) receive_packet_early_chat_msg_100;
42884     phandlers->receive[PACKET_CONNECT_MSG] = (void *(*)(struct connection *)) receive_packet_connect_msg_100;
42885     phandlers->receive[PACKET_CITY_REMOVE] = (void *(*)(struct connection *)) receive_packet_city_remove_100;
42886     phandlers->receive[PACKET_CITY_INFO] = (void *(*)(struct connection *)) receive_packet_city_info_100;
42887     phandlers->receive[PACKET_CITY_SHORT_INFO] = (void *(*)(struct connection *)) receive_packet_city_short_info_100;
42888     phandlers->receive[PACKET_CITY_NAME_SUGGESTION_INFO] = (void *(*)(struct connection *)) receive_packet_city_name_suggestion_info_100;
42889     phandlers->receive[PACKET_CITY_SABOTAGE_LIST] = (void *(*)(struct connection *)) receive_packet_city_sabotage_list_100;
42890     phandlers->receive[PACKET_PLAYER_REMOVE] = (void *(*)(struct connection *)) receive_packet_player_remove_100;
42891     phandlers->receive[PACKET_PLAYER_INFO] = (void *(*)(struct connection *)) receive_packet_player_info_100;
42892     phandlers->receive[PACKET_PLAYER_DIPLSTATE] = (void *(*)(struct connection *)) receive_packet_player_diplstate_100;
42893     phandlers->receive[PACKET_RESEARCH_INFO] = (void *(*)(struct connection *)) receive_packet_research_info_100;
42894     phandlers->receive[PACKET_UNIT_REMOVE] = (void *(*)(struct connection *)) receive_packet_unit_remove_100;
42895     phandlers->receive[PACKET_UNIT_INFO] = (void *(*)(struct connection *)) receive_packet_unit_info_100;
42896     phandlers->receive[PACKET_UNIT_SHORT_INFO] = (void *(*)(struct connection *)) receive_packet_unit_short_info_100;
42897     phandlers->receive[PACKET_UNIT_COMBAT_INFO] = (void *(*)(struct connection *)) receive_packet_unit_combat_info_100;
42898     phandlers->receive[PACKET_UNIT_ACTION_ANSWER] = (void *(*)(struct connection *)) receive_packet_unit_action_answer_100;
42899     phandlers->receive[PACKET_UNIT_ACTIONS] = (void *(*)(struct connection *)) receive_packet_unit_actions_100;
42900     phandlers->receive[PACKET_DIPLOMACY_INIT_MEETING] = (void *(*)(struct connection *)) receive_packet_diplomacy_init_meeting_100;
42901     phandlers->receive[PACKET_DIPLOMACY_CANCEL_MEETING] = (void *(*)(struct connection *)) receive_packet_diplomacy_cancel_meeting_100;
42902     phandlers->receive[PACKET_DIPLOMACY_CREATE_CLAUSE] = (void *(*)(struct connection *)) receive_packet_diplomacy_create_clause_100;
42903     phandlers->receive[PACKET_DIPLOMACY_REMOVE_CLAUSE] = (void *(*)(struct connection *)) receive_packet_diplomacy_remove_clause_100;
42904     phandlers->receive[PACKET_DIPLOMACY_ACCEPT_TREATY] = (void *(*)(struct connection *)) receive_packet_diplomacy_accept_treaty_100;
42905     phandlers->receive[PACKET_PAGE_MSG] = (void *(*)(struct connection *)) receive_packet_page_msg_100;
42906     phandlers->receive[PACKET_PAGE_MSG_PART] = (void *(*)(struct connection *)) receive_packet_page_msg_part_100;
42907     phandlers->receive[PACKET_CONN_INFO] = (void *(*)(struct connection *)) receive_packet_conn_info_100;
42908     phandlers->receive[PACKET_CONN_PING_INFO] = (void *(*)(struct connection *)) receive_packet_conn_ping_info_100;
42909     phandlers->receive[PACKET_CONN_PING] = (void *(*)(struct connection *)) receive_packet_conn_ping_100;
42910     phandlers->receive[PACKET_END_PHASE] = (void *(*)(struct connection *)) receive_packet_end_phase_100;
42911     phandlers->receive[PACKET_START_PHASE] = (void *(*)(struct connection *)) receive_packet_start_phase_100;
42912     phandlers->receive[PACKET_BEGIN_TURN] = (void *(*)(struct connection *)) receive_packet_begin_turn_100;
42913     phandlers->receive[PACKET_END_TURN] = (void *(*)(struct connection *)) receive_packet_end_turn_100;
42914     phandlers->receive[PACKET_FREEZE_CLIENT] = (void *(*)(struct connection *)) receive_packet_freeze_client_100;
42915     phandlers->receive[PACKET_THAW_CLIENT] = (void *(*)(struct connection *)) receive_packet_thaw_client_100;
42916     phandlers->receive[PACKET_RULESET_UNIT] = (void *(*)(struct connection *)) receive_packet_ruleset_unit_100;
42917     phandlers->receive[PACKET_RULESET_UNIT_BONUS] = (void *(*)(struct connection *)) receive_packet_ruleset_unit_bonus_100;
42918     phandlers->receive[PACKET_RULESET_UNIT_FLAG] = (void *(*)(struct connection *)) receive_packet_ruleset_unit_flag_100;
42919     phandlers->receive[PACKET_RULESET_GAME] = (void *(*)(struct connection *)) receive_packet_ruleset_game_100;
42920     phandlers->receive[PACKET_RULESET_SPECIALIST] = (void *(*)(struct connection *)) receive_packet_ruleset_specialist_100;
42921     phandlers->receive[PACKET_RULESET_GOVERNMENT_RULER_TITLE] = (void *(*)(struct connection *)) receive_packet_ruleset_government_ruler_title_100;
42922     phandlers->receive[PACKET_RULESET_TECH] = (void *(*)(struct connection *)) receive_packet_ruleset_tech_100;
42923     phandlers->receive[PACKET_RULESET_TECH_FLAG] = (void *(*)(struct connection *)) receive_packet_ruleset_tech_flag_100;
42924     phandlers->receive[PACKET_RULESET_GOVERNMENT] = (void *(*)(struct connection *)) receive_packet_ruleset_government_100;
42925     phandlers->receive[PACKET_RULESET_TERRAIN_CONTROL] = (void *(*)(struct connection *)) receive_packet_ruleset_terrain_control_100;
42926     phandlers->receive[PACKET_RULESETS_READY] = (void *(*)(struct connection *)) receive_packet_rulesets_ready_100;
42927     phandlers->receive[PACKET_RULESET_NATION_SETS] = (void *(*)(struct connection *)) receive_packet_ruleset_nation_sets_100;
42928     phandlers->receive[PACKET_RULESET_NATION_GROUPS] = (void *(*)(struct connection *)) receive_packet_ruleset_nation_groups_100;
42929     phandlers->receive[PACKET_RULESET_NATION] = (void *(*)(struct connection *)) receive_packet_ruleset_nation_100;
42930     phandlers->receive[PACKET_NATION_AVAILABILITY] = (void *(*)(struct connection *)) receive_packet_nation_availability_100;
42931     phandlers->receive[PACKET_RULESET_STYLE] = (void *(*)(struct connection *)) receive_packet_ruleset_style_100;
42932     phandlers->receive[PACKET_RULESET_CITY] = (void *(*)(struct connection *)) receive_packet_ruleset_city_100;
42933     phandlers->receive[PACKET_RULESET_BUILDING] = (void *(*)(struct connection *)) receive_packet_ruleset_building_100;
42934     phandlers->receive[PACKET_RULESET_TERRAIN] = (void *(*)(struct connection *)) receive_packet_ruleset_terrain_100;
42935     phandlers->receive[PACKET_RULESET_TERRAIN_FLAG] = (void *(*)(struct connection *)) receive_packet_ruleset_terrain_flag_100;
42936     phandlers->receive[PACKET_RULESET_UNIT_CLASS] = (void *(*)(struct connection *)) receive_packet_ruleset_unit_class_100;
42937     phandlers->receive[PACKET_RULESET_EXTRA] = (void *(*)(struct connection *)) receive_packet_ruleset_extra_100;
42938     phandlers->receive[PACKET_RULESET_BASE] = (void *(*)(struct connection *)) receive_packet_ruleset_base_100;
42939     phandlers->receive[PACKET_RULESET_ROAD] = (void *(*)(struct connection *)) receive_packet_ruleset_road_100;
42940     phandlers->receive[PACKET_RULESET_DISASTER] = (void *(*)(struct connection *)) receive_packet_ruleset_disaster_100;
42941     phandlers->receive[PACKET_RULESET_ACHIEVEMENT] = (void *(*)(struct connection *)) receive_packet_ruleset_achievement_100;
42942     phandlers->receive[PACKET_RULESET_TRADE] = (void *(*)(struct connection *)) receive_packet_ruleset_trade_100;
42943     phandlers->receive[PACKET_RULESET_ACTION] = (void *(*)(struct connection *)) receive_packet_ruleset_action_100;
42944     phandlers->receive[PACKET_RULESET_ACTION_ENABLER] = (void *(*)(struct connection *)) receive_packet_ruleset_action_enabler_100;
42945     phandlers->receive[PACKET_RULESET_MUSIC] = (void *(*)(struct connection *)) receive_packet_ruleset_music_100;
42946     phandlers->receive[PACKET_RULESET_MULTIPLIER] = (void *(*)(struct connection *)) receive_packet_ruleset_multiplier_100;
42947     phandlers->receive[PACKET_RULESET_CONTROL] = (void *(*)(struct connection *)) receive_packet_ruleset_control_100;
42948     phandlers->receive[PACKET_RULESET_SUMMARY] = (void *(*)(struct connection *)) receive_packet_ruleset_summary_100;
42949     phandlers->receive[PACKET_RULESET_DESCRIPTION_PART] = (void *(*)(struct connection *)) receive_packet_ruleset_description_part_100;
42950     phandlers->receive[PACKET_SINGLE_WANT_HACK_REPLY] = (void *(*)(struct connection *)) receive_packet_single_want_hack_reply_100;
42951     phandlers->receive[PACKET_RULESET_CHOICES] = (void *(*)(struct connection *)) receive_packet_ruleset_choices_100;
42952     phandlers->receive[PACKET_GAME_LOAD] = (void *(*)(struct connection *)) receive_packet_game_load_100;
42953     phandlers->receive[PACKET_SERVER_SETTING_CONTROL] = (void *(*)(struct connection *)) receive_packet_server_setting_control_100;
42954     phandlers->receive[PACKET_SERVER_SETTING_CONST] = (void *(*)(struct connection *)) receive_packet_server_setting_const_100;
42955     phandlers->receive[PACKET_SERVER_SETTING_BOOL] = (void *(*)(struct connection *)) receive_packet_server_setting_bool_100;
42956     phandlers->receive[PACKET_SERVER_SETTING_INT] = (void *(*)(struct connection *)) receive_packet_server_setting_int_100;
42957     phandlers->receive[PACKET_SERVER_SETTING_STR] = (void *(*)(struct connection *)) receive_packet_server_setting_str_100;
42958     phandlers->receive[PACKET_SERVER_SETTING_ENUM] = (void *(*)(struct connection *)) receive_packet_server_setting_enum_100;
42959     phandlers->receive[PACKET_SERVER_SETTING_BITWISE] = (void *(*)(struct connection *)) receive_packet_server_setting_bitwise_100;
42960     phandlers->receive[PACKET_SET_TOPOLOGY] = (void *(*)(struct connection *)) receive_packet_set_topology_100;
42961     phandlers->receive[PACKET_RULESET_EFFECT] = (void *(*)(struct connection *)) receive_packet_ruleset_effect_100;
42962     phandlers->receive[PACKET_RULESET_RESOURCE] = (void *(*)(struct connection *)) receive_packet_ruleset_resource_100;
42963     phandlers->receive[PACKET_SCENARIO_INFO] = (void *(*)(struct connection *)) receive_packet_scenario_info_100;
42964     phandlers->receive[PACKET_SCENARIO_DESCRIPTION] = (void *(*)(struct connection *)) receive_packet_scenario_description_100;
42965     phandlers->receive[PACKET_VOTE_NEW] = (void *(*)(struct connection *)) receive_packet_vote_new_100;
42966     phandlers->receive[PACKET_VOTE_UPDATE] = (void *(*)(struct connection *)) receive_packet_vote_update_100;
42967     phandlers->receive[PACKET_VOTE_REMOVE] = (void *(*)(struct connection *)) receive_packet_vote_remove_100;
42968     phandlers->receive[PACKET_VOTE_RESOLVE] = (void *(*)(struct connection *)) receive_packet_vote_resolve_100;
42969     phandlers->receive[PACKET_EDIT_OBJECT_CREATED] = (void *(*)(struct connection *)) receive_packet_edit_object_created_100;
42970     phandlers->receive[PACKET_PLAY_MUSIC] = (void *(*)(struct connection *)) receive_packet_play_music_100;
42971   }
42972 }
42973 
packet_handlers_fill_capability(struct packet_handlers * phandlers,const char * capability)42974 void packet_handlers_fill_capability(struct packet_handlers *phandlers,
42975                                      const char *capability)
42976 {
42977   if (is_server()) {
42978     if (has_capability("techloss_forgiveness", capability) && has_capability("year32", capability)) {
42979       log_packet_detailed("PACKET_GAME_INFO: using variant=100 cap=%s", capability);
42980       phandlers->send[PACKET_GAME_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_game_info_100;
42981     } else if (has_capability("techloss_forgiveness", capability) && !has_capability("year32", capability)) {
42982       log_packet_detailed("PACKET_GAME_INFO: using variant=101 cap=%s", capability);
42983       phandlers->send[PACKET_GAME_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_game_info_101;
42984     } else if (has_capability("year32", capability) && !has_capability("techloss_forgiveness", capability)) {
42985       log_packet_detailed("PACKET_GAME_INFO: using variant=102 cap=%s", capability);
42986       phandlers->send[PACKET_GAME_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_game_info_102;
42987     } else if (!has_capability("techloss_forgiveness", capability) && !has_capability("year32", capability)) {
42988       log_packet_detailed("PACKET_GAME_INFO: using variant=103 cap=%s", capability);
42989       phandlers->send[PACKET_GAME_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_game_info_103;
42990     } else {
42991       log_error("Unknown PACKET_GAME_INFO variant for cap %s", capability);
42992     }
42993     if (has_capability("year32", capability)) {
42994       log_packet_detailed("PACKET_NEW_YEAR: using variant=100 cap=%s", capability);
42995       phandlers->send[PACKET_NEW_YEAR].packet = (int(*)(struct connection *, const void *)) send_packet_new_year_100;
42996     } else if (!has_capability("year32", capability)) {
42997       log_packet_detailed("PACKET_NEW_YEAR: using variant=101 cap=%s", capability);
42998       phandlers->send[PACKET_NEW_YEAR].packet = (int(*)(struct connection *, const void *)) send_packet_new_year_101;
42999     } else {
43000       log_error("Unknown PACKET_NEW_YEAR variant for cap %s", capability);
43001     }
43002     if (has_capability("year32", capability)) {
43003       log_packet_detailed("PACKET_SPACESHIP_INFO: using variant=100 cap=%s", capability);
43004       phandlers->send[PACKET_SPACESHIP_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_spaceship_info_100;
43005     } else if (!has_capability("year32", capability)) {
43006       log_packet_detailed("PACKET_SPACESHIP_INFO: using variant=101 cap=%s", capability);
43007       phandlers->send[PACKET_SPACESHIP_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_spaceship_info_101;
43008     } else {
43009       log_error("Unknown PACKET_SPACESHIP_INFO variant for cap %s", capability);
43010     }
43011     if (has_capability("year32", capability)) {
43012       log_packet_detailed("PACKET_EDIT_GAME: using variant=100 cap=%s", capability);
43013       phandlers->receive[PACKET_EDIT_GAME] = (void *(*)(struct connection *)) receive_packet_edit_game_100;
43014     } else if (!has_capability("year32", capability)) {
43015       log_packet_detailed("PACKET_EDIT_GAME: using variant=101 cap=%s", capability);
43016       phandlers->receive[PACKET_EDIT_GAME] = (void *(*)(struct connection *)) receive_packet_edit_game_101;
43017     } else {
43018       log_error("Unknown PACKET_EDIT_GAME variant for cap %s", capability);
43019     }
43020   } else {
43021     if (has_capability("year32", capability)) {
43022       log_packet_detailed("PACKET_EDIT_GAME: using variant=100 cap=%s", capability);
43023       phandlers->send[PACKET_EDIT_GAME].packet = (int(*)(struct connection *, const void *)) send_packet_edit_game_100;
43024     } else if (!has_capability("year32", capability)) {
43025       log_packet_detailed("PACKET_EDIT_GAME: using variant=101 cap=%s", capability);
43026       phandlers->send[PACKET_EDIT_GAME].packet = (int(*)(struct connection *, const void *)) send_packet_edit_game_101;
43027     } else {
43028       log_error("Unknown PACKET_EDIT_GAME variant for cap %s", capability);
43029     }
43030     if (has_capability("techloss_forgiveness", capability) && has_capability("year32", capability)) {
43031       log_packet_detailed("PACKET_GAME_INFO: using variant=100 cap=%s", capability);
43032       phandlers->receive[PACKET_GAME_INFO] = (void *(*)(struct connection *)) receive_packet_game_info_100;
43033     } else if (has_capability("techloss_forgiveness", capability) && !has_capability("year32", capability)) {
43034       log_packet_detailed("PACKET_GAME_INFO: using variant=101 cap=%s", capability);
43035       phandlers->receive[PACKET_GAME_INFO] = (void *(*)(struct connection *)) receive_packet_game_info_101;
43036     } else if (has_capability("year32", capability) && !has_capability("techloss_forgiveness", capability)) {
43037       log_packet_detailed("PACKET_GAME_INFO: using variant=102 cap=%s", capability);
43038       phandlers->receive[PACKET_GAME_INFO] = (void *(*)(struct connection *)) receive_packet_game_info_102;
43039     } else if (!has_capability("techloss_forgiveness", capability) && !has_capability("year32", capability)) {
43040       log_packet_detailed("PACKET_GAME_INFO: using variant=103 cap=%s", capability);
43041       phandlers->receive[PACKET_GAME_INFO] = (void *(*)(struct connection *)) receive_packet_game_info_103;
43042     } else {
43043       log_error("Unknown PACKET_GAME_INFO variant for cap %s", capability);
43044     }
43045     if (has_capability("year32", capability)) {
43046       log_packet_detailed("PACKET_NEW_YEAR: using variant=100 cap=%s", capability);
43047       phandlers->receive[PACKET_NEW_YEAR] = (void *(*)(struct connection *)) receive_packet_new_year_100;
43048     } else if (!has_capability("year32", capability)) {
43049       log_packet_detailed("PACKET_NEW_YEAR: using variant=101 cap=%s", capability);
43050       phandlers->receive[PACKET_NEW_YEAR] = (void *(*)(struct connection *)) receive_packet_new_year_101;
43051     } else {
43052       log_error("Unknown PACKET_NEW_YEAR variant for cap %s", capability);
43053     }
43054     if (has_capability("year32", capability)) {
43055       log_packet_detailed("PACKET_SPACESHIP_INFO: using variant=100 cap=%s", capability);
43056       phandlers->receive[PACKET_SPACESHIP_INFO] = (void *(*)(struct connection *)) receive_packet_spaceship_info_100;
43057     } else if (!has_capability("year32", capability)) {
43058       log_packet_detailed("PACKET_SPACESHIP_INFO: using variant=101 cap=%s", capability);
43059       phandlers->receive[PACKET_SPACESHIP_INFO] = (void *(*)(struct connection *)) receive_packet_spaceship_info_101;
43060     } else {
43061       log_error("Unknown PACKET_SPACESHIP_INFO variant for cap %s", capability);
43062     }
43063   }
43064 }
43065